1 """Shared utility functions."""
4 from traceback import format_exception
7 def format_exc_skip(skip, limit=None):
8 """Like traceback.format_exc but allow skipping the first frames."""
9 etype, val, tb = sys.exc_info()
12 return (''.join(format_exception(etype, val, tb, limit))).rstrip()
15 # Taken from SimpleNamespace in python 3
17 """Helper class for version info."""
19 def __init__(self, **kwargs):
20 """Create the Version object."""
21 self.__dict__.update(kwargs)
24 """Return str representation of the Version."""
25 keys = sorted(self.__dict__)
26 items = ("{}={!r}".format(k, self.__dict__[k]) for k in keys)
27 return "{}({})".format(type(self).__name__, ", ".join(items))
29 def __eq__(self, other):
30 """Check if version is same as other."""
31 return self.__dict__ == other.__dict__
34 def get_client_info(kind, type_, method_spec):
35 """Returns a tuple describing the client."""
36 name = "python{}-{}".format(sys.version_info[0], kind)
37 attributes = {"license": "Apache v2",
38 "website": "github.com/neovim/pynvim"}
39 return (name, VERSION.__dict__, type_, method_spec, attributes)
42 VERSION = Version(major=0, minor=4, patch=2, prerelease='')