repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
koszullab/metaTOR | metator/scripts/bins.py | merge_fasta | def merge_fasta(fasta_file, output_dir):
"""Merge chunks into complete FASTA bins
Merge bin chunks by appending consecutive chunks to one another.
Parameters
----------
fasta_file : file, str or pathlib.Path
The FASTA file containing the chunks to merge.
output_dir : str or pathlib.Pa... | python | def merge_fasta(fasta_file, output_dir):
"""Merge chunks into complete FASTA bins
Merge bin chunks by appending consecutive chunks to one another.
Parameters
----------
fasta_file : file, str or pathlib.Path
The FASTA file containing the chunks to merge.
output_dir : str or pathlib.Pa... | [
"def",
"merge_fasta",
"(",
"fasta_file",
",",
"output_dir",
")",
":",
"# First, define some functions for ordering chunks and detecting",
"# consecutive chunk sequences",
"def",
"chunk_lexicographic_order",
"(",
"chunk",
")",
":",
"\"\"\"A quick callback to sort chunk ids lexicog... | Merge chunks into complete FASTA bins
Merge bin chunks by appending consecutive chunks to one another.
Parameters
----------
fasta_file : file, str or pathlib.Path
The FASTA file containing the chunks to merge.
output_dir : str or pathlib.Path
The output directory to write the merg... | [
"Merge",
"chunks",
"into",
"complete",
"FASTA",
"bins"
] | 0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a | https://github.com/koszullab/metaTOR/blob/0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a/metator/scripts/bins.py#L246-L327 | train | Merge chunks into complete FASTA bin. |
ariebovenberg/snug | snug/_async.py | _asyncio_send | async def _asyncio_send(loop, req, *, timeout=10, max_redirects=10):
"""A rudimentary HTTP client using :mod:`asyncio`"""
if not any(h.lower() == 'user-agent' for h in req.headers):
req = req.with_headers({'User-Agent': _ASYNCIO_USER_AGENT})
url = urllib.parse.urlsplit(
req.url + '?' + urlli... | python | async def _asyncio_send(loop, req, *, timeout=10, max_redirects=10):
"""A rudimentary HTTP client using :mod:`asyncio`"""
if not any(h.lower() == 'user-agent' for h in req.headers):
req = req.with_headers({'User-Agent': _ASYNCIO_USER_AGENT})
url = urllib.parse.urlsplit(
req.url + '?' + urlli... | [
"async",
"def",
"_asyncio_send",
"(",
"loop",
",",
"req",
",",
"*",
",",
"timeout",
"=",
"10",
",",
"max_redirects",
"=",
"10",
")",
":",
"if",
"not",
"any",
"(",
"h",
".",
"lower",
"(",
")",
"==",
"'user-agent'",
"for",
"h",
"in",
"req",
".",
"h... | A rudimentary HTTP client using :mod:`asyncio` | [
"A",
"rudimentary",
"HTTP",
"client",
"using",
":",
"mod",
":",
"asyncio"
] | 4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef | https://github.com/ariebovenberg/snug/blob/4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef/snug/_async.py#L28-L61 | train | A rudimentary HTTP client using asyncio. |
nugget/python-anthemav | anthemav/tools.py | console | def console(loop, log):
"""Connect to receiver and show events as they occur.
Pulls the following arguments from the command line (not method arguments):
:param host:
Hostname or IP Address of the device.
:param port:
TCP port number of the device.
:param verbose:
Show debu... | python | def console(loop, log):
"""Connect to receiver and show events as they occur.
Pulls the following arguments from the command line (not method arguments):
:param host:
Hostname or IP Address of the device.
:param port:
TCP port number of the device.
:param verbose:
Show debu... | [
"def",
"console",
"(",
"loop",
",",
"log",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"console",
".",
"__doc__",
")",
"parser",
".",
"add_argument",
"(",
"'--host'",
",",
"default",
"=",
"'127.0.0.1'",
",",
"help",... | Connect to receiver and show events as they occur.
Pulls the following arguments from the command line (not method arguments):
:param host:
Hostname or IP Address of the device.
:param port:
TCP port number of the device.
:param verbose:
Show debug logging. | [
"Connect",
"to",
"receiver",
"and",
"show",
"events",
"as",
"they",
"occur",
"."
] | c3cee38f2d452c1ab1335d9885e0769ec24d5f90 | https://github.com/nugget/python-anthemav/blob/c3cee38f2d452c1ab1335d9885e0769ec24d5f90/anthemav/tools.py#L12-L57 | train | Connect to receiver and show events as they occur. |
nugget/python-anthemav | anthemav/tools.py | monitor | def monitor():
"""Wrapper to call console with a loop."""
log = logging.getLogger(__name__)
loop = asyncio.get_event_loop()
asyncio.ensure_future(console(loop, log))
loop.run_forever() | python | def monitor():
"""Wrapper to call console with a loop."""
log = logging.getLogger(__name__)
loop = asyncio.get_event_loop()
asyncio.ensure_future(console(loop, log))
loop.run_forever() | [
"def",
"monitor",
"(",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"loop",
"=",
"asyncio",
".",
"get_event_loop",
"(",
")",
"asyncio",
".",
"ensure_future",
"(",
"console",
"(",
"loop",
",",
"log",
")",
")",
"loop",
".",
... | Wrapper to call console with a loop. | [
"Wrapper",
"to",
"call",
"console",
"with",
"a",
"loop",
"."
] | c3cee38f2d452c1ab1335d9885e0769ec24d5f90 | https://github.com/nugget/python-anthemav/blob/c3cee38f2d452c1ab1335d9885e0769ec24d5f90/anthemav/tools.py#L60-L65 | train | Wrapper to call console with a loop. |
eclipse/unide.python | src/unide/schema.py | make_object | def make_object(cls, data):
"""Creates an API object of class `cls`, setting its `_data` to
data. Subclasses of `Object` are required to use this to build a
new, empty instance without using their constructor.
"""
if issubclass(cls, Object):
self = object.__new__(cls)
self._data = da... | python | def make_object(cls, data):
"""Creates an API object of class `cls`, setting its `_data` to
data. Subclasses of `Object` are required to use this to build a
new, empty instance without using their constructor.
"""
if issubclass(cls, Object):
self = object.__new__(cls)
self._data = da... | [
"def",
"make_object",
"(",
"cls",
",",
"data",
")",
":",
"if",
"issubclass",
"(",
"cls",
",",
"Object",
")",
":",
"self",
"=",
"object",
".",
"__new__",
"(",
"cls",
")",
"self",
".",
"_data",
"=",
"data",
"else",
":",
"self",
"=",
"data",
"return",... | Creates an API object of class `cls`, setting its `_data` to
data. Subclasses of `Object` are required to use this to build a
new, empty instance without using their constructor. | [
"Creates",
"an",
"API",
"object",
"of",
"class",
"cls",
"setting",
"its",
"_data",
"to",
"data",
".",
"Subclasses",
"of",
"Object",
"are",
"required",
"to",
"use",
"this",
"to",
"build",
"a",
"new",
"empty",
"instance",
"without",
"using",
"their",
"constr... | b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493 | https://github.com/eclipse/unide.python/blob/b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493/src/unide/schema.py#L296-L306 | train | Creates an API object of class cls setting its _data to
data. |
eclipse/unide.python | src/unide/schema.py | String | def String(length=None, **kwargs):
"""A string valued property with max. `length`."""
return Property(
length=length,
types=stringy_types,
convert=to_string,
**kwargs
) | python | def String(length=None, **kwargs):
"""A string valued property with max. `length`."""
return Property(
length=length,
types=stringy_types,
convert=to_string,
**kwargs
) | [
"def",
"String",
"(",
"length",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"Property",
"(",
"length",
"=",
"length",
",",
"types",
"=",
"stringy_types",
",",
"convert",
"=",
"to_string",
",",
"*",
"*",
"kwargs",
")"
] | A string valued property with max. `length`. | [
"A",
"string",
"valued",
"property",
"with",
"max",
".",
"length",
"."
] | b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493 | https://github.com/eclipse/unide.python/blob/b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493/src/unide/schema.py#L365-L372 | train | A string valued property with max. length. |
eclipse/unide.python | src/unide/schema.py | Datetime | def Datetime(null=True, **kwargs):
"""A datetime property."""
return Property(
types=datetime.datetime,
convert=util.local_timezone,
load=dateutil.parser.parse,
null=null,
**kwargs
) | python | def Datetime(null=True, **kwargs):
"""A datetime property."""
return Property(
types=datetime.datetime,
convert=util.local_timezone,
load=dateutil.parser.parse,
null=null,
**kwargs
) | [
"def",
"Datetime",
"(",
"null",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"Property",
"(",
"types",
"=",
"datetime",
".",
"datetime",
",",
"convert",
"=",
"util",
".",
"local_timezone",
",",
"load",
"=",
"dateutil",
".",
"parser",
".",
... | A datetime property. | [
"A",
"datetime",
"property",
"."
] | b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493 | https://github.com/eclipse/unide.python/blob/b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493/src/unide/schema.py#L395-L403 | train | A datetime property. |
eclipse/unide.python | src/unide/schema.py | InstanceOf | def InstanceOf(cls, **kwargs):
"""A property that is an instance of `cls`."""
return Property(types=cls, load=cls.load, **kwargs) | python | def InstanceOf(cls, **kwargs):
"""A property that is an instance of `cls`."""
return Property(types=cls, load=cls.load, **kwargs) | [
"def",
"InstanceOf",
"(",
"cls",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"Property",
"(",
"types",
"=",
"cls",
",",
"load",
"=",
"cls",
".",
"load",
",",
"*",
"*",
"kwargs",
")"
] | A property that is an instance of `cls`. | [
"A",
"property",
"that",
"is",
"an",
"instance",
"of",
"cls",
"."
] | b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493 | https://github.com/eclipse/unide.python/blob/b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493/src/unide/schema.py#L406-L408 | train | A property that is an instance of cls. |
eclipse/unide.python | src/unide/schema.py | ListOf | def ListOf(cls, **kwargs):
"""A property that is a list of `cls`."""
def _list_load(value):
return [cls.load(d) for d in value]
return Property(types=list, load=_list_load, default=list, **kwargs) | python | def ListOf(cls, **kwargs):
"""A property that is a list of `cls`."""
def _list_load(value):
return [cls.load(d) for d in value]
return Property(types=list, load=_list_load, default=list, **kwargs) | [
"def",
"ListOf",
"(",
"cls",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"_list_load",
"(",
"value",
")",
":",
"return",
"[",
"cls",
".",
"load",
"(",
"d",
")",
"for",
"d",
"in",
"value",
"]",
"return",
"Property",
"(",
"types",
"=",
"list",
",",
... | A property that is a list of `cls`. | [
"A",
"property",
"that",
"is",
"a",
"list",
"of",
"cls",
"."
] | b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493 | https://github.com/eclipse/unide.python/blob/b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493/src/unide/schema.py#L411-L417 | train | A property that is a list of cls. |
eclipse/unide.python | src/unide/schema.py | Property.check | def check(self, obj, value, errors):
"""
Check if `value` is valid this property in the entity `obj`. Append
validation results to `errors` (list).
"""
fieldname = "%s.%s" % (type(obj).__name__, self._name)
if value is None:
if not self._null:
... | python | def check(self, obj, value, errors):
"""
Check if `value` is valid this property in the entity `obj`. Append
validation results to `errors` (list).
"""
fieldname = "%s.%s" % (type(obj).__name__, self._name)
if value is None:
if not self._null:
... | [
"def",
"check",
"(",
"self",
",",
"obj",
",",
"value",
",",
"errors",
")",
":",
"fieldname",
"=",
"\"%s.%s\"",
"%",
"(",
"type",
"(",
"obj",
")",
".",
"__name__",
",",
"self",
".",
"_name",
")",
"if",
"value",
"is",
"None",
":",
"if",
"not",
"sel... | Check if `value` is valid this property in the entity `obj`. Append
validation results to `errors` (list). | [
"Check",
"if",
"value",
"is",
"valid",
"this",
"property",
"in",
"the",
"entity",
"obj",
".",
"Append",
"validation",
"results",
"to",
"errors",
"(",
"list",
")",
"."
] | b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493 | https://github.com/eclipse/unide.python/blob/b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493/src/unide/schema.py#L108-L126 | train | Check if value is valid this property in the entity obj. Appends validation results to errors. |
eclipse/unide.python | src/unide/schema.py | HasDimensions.add_dimension | def add_dimension(self, name, data=None):
"""Add a named dimension to this entity."""
self.dimensions.add(name)
if data is None:
valobj = self.__dimtype__()
else:
valobj = make_object(self.__dimtype__, data)
self._data[name] = valobj
setattr(self, ... | python | def add_dimension(self, name, data=None):
"""Add a named dimension to this entity."""
self.dimensions.add(name)
if data is None:
valobj = self.__dimtype__()
else:
valobj = make_object(self.__dimtype__, data)
self._data[name] = valobj
setattr(self, ... | [
"def",
"add_dimension",
"(",
"self",
",",
"name",
",",
"data",
"=",
"None",
")",
":",
"self",
".",
"dimensions",
".",
"add",
"(",
"name",
")",
"if",
"data",
"is",
"None",
":",
"valobj",
"=",
"self",
".",
"__dimtype__",
"(",
")",
"else",
":",
"valob... | Add a named dimension to this entity. | [
"Add",
"a",
"named",
"dimension",
"to",
"this",
"entity",
"."
] | b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493 | https://github.com/eclipse/unide.python/blob/b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493/src/unide/schema.py#L323-L332 | train | Add a named dimension to this entity. |
MoseleyBioinformaticsLab/mwtab | mwtab/mwtab.py | MWTabFile.read | def read(self, filehandle):
"""Read data into a :class:`~mwtab.mwtab.MWTabFile` instance.
:param filehandle: file-like object.
:type filehandle: :py:class:`io.TextIOWrapper`, :py:class:`gzip.GzipFile`,
:py:class:`bz2.BZ2File`, :py:class:`zipfile.ZipFile`
:retur... | python | def read(self, filehandle):
"""Read data into a :class:`~mwtab.mwtab.MWTabFile` instance.
:param filehandle: file-like object.
:type filehandle: :py:class:`io.TextIOWrapper`, :py:class:`gzip.GzipFile`,
:py:class:`bz2.BZ2File`, :py:class:`zipfile.ZipFile`
:retur... | [
"def",
"read",
"(",
"self",
",",
"filehandle",
")",
":",
"input_str",
"=",
"filehandle",
".",
"read",
"(",
")",
"mwtab_str",
"=",
"self",
".",
"_is_mwtab",
"(",
"input_str",
")",
"json_str",
"=",
"self",
".",
"_is_json",
"(",
"input_str",
")",
"if",
"n... | Read data into a :class:`~mwtab.mwtab.MWTabFile` instance.
:param filehandle: file-like object.
:type filehandle: :py:class:`io.TextIOWrapper`, :py:class:`gzip.GzipFile`,
:py:class:`bz2.BZ2File`, :py:class:`zipfile.ZipFile`
:return: None
:rtype: :py:obj:`None` | [
"Read",
"data",
"into",
"a",
":",
"class",
":",
"~mwtab",
".",
"mwtab",
".",
"MWTabFile",
"instance",
"."
] | 8c0ae8ab2aa621662f99589ed41e481cf8b7152b | https://github.com/MoseleyBioinformaticsLab/mwtab/blob/8c0ae8ab2aa621662f99589ed41e481cf8b7152b/mwtab/mwtab.py#L63-L89 | train | Reads the data into a : class : ~mwtab. mwtab. MWTabFile instance. |
MoseleyBioinformaticsLab/mwtab | mwtab/mwtab.py | MWTabFile.write | def write(self, filehandle, file_format):
"""Write :class:`~mwtab.mwtab.MWTabFile` data into file.
:param filehandle: file-like object.
:type filehandle: :py:class:`io.TextIOWrapper`
:param str file_format: Format to use to write data: `mwtab` or `json`.
:return: None
:r... | python | def write(self, filehandle, file_format):
"""Write :class:`~mwtab.mwtab.MWTabFile` data into file.
:param filehandle: file-like object.
:type filehandle: :py:class:`io.TextIOWrapper`
:param str file_format: Format to use to write data: `mwtab` or `json`.
:return: None
:r... | [
"def",
"write",
"(",
"self",
",",
"filehandle",
",",
"file_format",
")",
":",
"try",
":",
"if",
"file_format",
"==",
"\"json\"",
":",
"json_str",
"=",
"self",
".",
"_to_json",
"(",
")",
"filehandle",
".",
"write",
"(",
"json_str",
")",
"elif",
"file_form... | Write :class:`~mwtab.mwtab.MWTabFile` data into file.
:param filehandle: file-like object.
:type filehandle: :py:class:`io.TextIOWrapper`
:param str file_format: Format to use to write data: `mwtab` or `json`.
:return: None
:rtype: :py:obj:`None` | [
"Write",
":",
"class",
":",
"~mwtab",
".",
"mwtab",
".",
"MWTabFile",
"data",
"into",
"file",
"."
] | 8c0ae8ab2aa621662f99589ed41e481cf8b7152b | https://github.com/MoseleyBioinformaticsLab/mwtab/blob/8c0ae8ab2aa621662f99589ed41e481cf8b7152b/mwtab/mwtab.py#L91-L111 | train | Writes the data into file. |
MoseleyBioinformaticsLab/mwtab | mwtab/mwtab.py | MWTabFile._build_mwtabfile | def _build_mwtabfile(self, mwtab_str):
"""Build :class:`~mwtab.mwtab.MWTabFile` instance.
:param mwtab_str: String in `mwtab` format.
:type mwtab_str: :py:class:`str` or :py:class:`bytes`
:return: instance of :class:`~mwtab.mwtab.MWTabFile`.
:rtype: :class:`~mwtab.mwtab.MWTabFil... | python | def _build_mwtabfile(self, mwtab_str):
"""Build :class:`~mwtab.mwtab.MWTabFile` instance.
:param mwtab_str: String in `mwtab` format.
:type mwtab_str: :py:class:`str` or :py:class:`bytes`
:return: instance of :class:`~mwtab.mwtab.MWTabFile`.
:rtype: :class:`~mwtab.mwtab.MWTabFil... | [
"def",
"_build_mwtabfile",
"(",
"self",
",",
"mwtab_str",
")",
":",
"mwtab_file",
"=",
"self",
"lexer",
"=",
"tokenizer",
"(",
"mwtab_str",
")",
"token",
"=",
"next",
"(",
"lexer",
")",
"while",
"token",
".",
"key",
"!=",
"\"!#ENDFILE\"",
":",
"if",
"tok... | Build :class:`~mwtab.mwtab.MWTabFile` instance.
:param mwtab_str: String in `mwtab` format.
:type mwtab_str: :py:class:`str` or :py:class:`bytes`
:return: instance of :class:`~mwtab.mwtab.MWTabFile`.
:rtype: :class:`~mwtab.mwtab.MWTabFile` | [
"Build",
":",
"class",
":",
"~mwtab",
".",
"mwtab",
".",
"MWTabFile",
"instance",
"."
] | 8c0ae8ab2aa621662f99589ed41e481cf8b7152b | https://github.com/MoseleyBioinformaticsLab/mwtab/blob/8c0ae8ab2aa621662f99589ed41e481cf8b7152b/mwtab/mwtab.py#L129-L148 | train | Build a MWTabFile instance from a string in mwtab format. |
MoseleyBioinformaticsLab/mwtab | mwtab/mwtab.py | MWTabFile._build_block | def _build_block(self, lexer):
"""Build individual text block of :class:`~mwtab.mwtab.MWTabFile` instance.
:param lexer: instance of the mwtab tokenizer.
:type lexer: :func:`~mwtab.tokenizer.tokenizer`
:return: Section dictionary.
:rtype: :py:class:`collections.OrderedDict`
... | python | def _build_block(self, lexer):
"""Build individual text block of :class:`~mwtab.mwtab.MWTabFile` instance.
:param lexer: instance of the mwtab tokenizer.
:type lexer: :func:`~mwtab.tokenizer.tokenizer`
:return: Section dictionary.
:rtype: :py:class:`collections.OrderedDict`
... | [
"def",
"_build_block",
"(",
"self",
",",
"lexer",
")",
":",
"section",
"=",
"OrderedDict",
"(",
")",
"token",
"=",
"next",
"(",
"lexer",
")",
"while",
"not",
"token",
".",
"key",
".",
"startswith",
"(",
"\"#ENDSECTION\"",
")",
":",
"if",
"token",
".",
... | Build individual text block of :class:`~mwtab.mwtab.MWTabFile` instance.
:param lexer: instance of the mwtab tokenizer.
:type lexer: :func:`~mwtab.tokenizer.tokenizer`
:return: Section dictionary.
:rtype: :py:class:`collections.OrderedDict` | [
"Build",
"individual",
"text",
"block",
"of",
":",
"class",
":",
"~mwtab",
".",
"mwtab",
".",
"MWTabFile",
"instance",
"."
] | 8c0ae8ab2aa621662f99589ed41e481cf8b7152b | https://github.com/MoseleyBioinformaticsLab/mwtab/blob/8c0ae8ab2aa621662f99589ed41e481cf8b7152b/mwtab/mwtab.py#L150-L206 | train | Build individual text block of MWTabFile instance. |
MoseleyBioinformaticsLab/mwtab | mwtab/mwtab.py | MWTabFile.print_file | def print_file(self, f=sys.stdout, file_format="mwtab"):
"""Print :class:`~mwtab.mwtab.MWTabFile` into a file or stdout.
:param io.StringIO f: writable file-like stream.
:param str file_format: Format to use: `mwtab` or `json`.
:param f: Print to file or stdout.
:param int tw: T... | python | def print_file(self, f=sys.stdout, file_format="mwtab"):
"""Print :class:`~mwtab.mwtab.MWTabFile` into a file or stdout.
:param io.StringIO f: writable file-like stream.
:param str file_format: Format to use: `mwtab` or `json`.
:param f: Print to file or stdout.
:param int tw: T... | [
"def",
"print_file",
"(",
"self",
",",
"f",
"=",
"sys",
".",
"stdout",
",",
"file_format",
"=",
"\"mwtab\"",
")",
":",
"if",
"file_format",
"==",
"\"mwtab\"",
":",
"for",
"key",
"in",
"self",
":",
"if",
"key",
"==",
"\"SUBJECT_SAMPLE_FACTORS\"",
":",
"pr... | Print :class:`~mwtab.mwtab.MWTabFile` into a file or stdout.
:param io.StringIO f: writable file-like stream.
:param str file_format: Format to use: `mwtab` or `json`.
:param f: Print to file or stdout.
:param int tw: Tab width.
:return: None
:rtype: :py:obj:`None` | [
"Print",
":",
"class",
":",
"~mwtab",
".",
"mwtab",
".",
"MWTabFile",
"into",
"a",
"file",
"or",
"stdout",
"."
] | 8c0ae8ab2aa621662f99589ed41e481cf8b7152b | https://github.com/MoseleyBioinformaticsLab/mwtab/blob/8c0ae8ab2aa621662f99589ed41e481cf8b7152b/mwtab/mwtab.py#L208-L231 | train | Print the current state of the object into a file or stdout. |
MoseleyBioinformaticsLab/mwtab | mwtab/mwtab.py | MWTabFile.print_block | def print_block(self, section_key, f=sys.stdout, file_format="mwtab"):
"""Print `mwtab` section into a file or stdout.
:param str section_key: Section name.
:param io.StringIO f: writable file-like stream.
:param str file_format: Format to use: `mwtab` or `json`.
:return: None
... | python | def print_block(self, section_key, f=sys.stdout, file_format="mwtab"):
"""Print `mwtab` section into a file or stdout.
:param str section_key: Section name.
:param io.StringIO f: writable file-like stream.
:param str file_format: Format to use: `mwtab` or `json`.
:return: None
... | [
"def",
"print_block",
"(",
"self",
",",
"section_key",
",",
"f",
"=",
"sys",
".",
"stdout",
",",
"file_format",
"=",
"\"mwtab\"",
")",
":",
"if",
"file_format",
"==",
"\"mwtab\"",
":",
"for",
"key",
",",
"value",
"in",
"self",
"[",
"section_key",
"]",
... | Print `mwtab` section into a file or stdout.
:param str section_key: Section name.
:param io.StringIO f: writable file-like stream.
:param str file_format: Format to use: `mwtab` or `json`.
:return: None
:rtype: :py:obj:`None` | [
"Print",
"mwtab",
"section",
"into",
"a",
"file",
"or",
"stdout",
"."
] | 8c0ae8ab2aa621662f99589ed41e481cf8b7152b | https://github.com/MoseleyBioinformaticsLab/mwtab/blob/8c0ae8ab2aa621662f99589ed41e481cf8b7152b/mwtab/mwtab.py#L233-L293 | train | Print a block of data into a file or stdout. |
MoseleyBioinformaticsLab/mwtab | mwtab/mwtab.py | MWTabFile._to_mwtab | def _to_mwtab(self):
"""Save :class:`~mwtab.mwtab.MWTabFile` in `mwtab` formatted string.
:return: NMR-STAR string.
:rtype: :py:class:`str`
"""
mwtab_str = io.StringIO()
self.print_file(mwtab_str)
return mwtab_str.getvalue() | python | def _to_mwtab(self):
"""Save :class:`~mwtab.mwtab.MWTabFile` in `mwtab` formatted string.
:return: NMR-STAR string.
:rtype: :py:class:`str`
"""
mwtab_str = io.StringIO()
self.print_file(mwtab_str)
return mwtab_str.getvalue() | [
"def",
"_to_mwtab",
"(",
"self",
")",
":",
"mwtab_str",
"=",
"io",
".",
"StringIO",
"(",
")",
"self",
".",
"print_file",
"(",
"mwtab_str",
")",
"return",
"mwtab_str",
".",
"getvalue",
"(",
")"
] | Save :class:`~mwtab.mwtab.MWTabFile` in `mwtab` formatted string.
:return: NMR-STAR string.
:rtype: :py:class:`str` | [
"Save",
":",
"class",
":",
"~mwtab",
".",
"mwtab",
".",
"MWTabFile",
"in",
"mwtab",
"formatted",
"string",
"."
] | 8c0ae8ab2aa621662f99589ed41e481cf8b7152b | https://github.com/MoseleyBioinformaticsLab/mwtab/blob/8c0ae8ab2aa621662f99589ed41e481cf8b7152b/mwtab/mwtab.py#L303-L311 | train | Save NMR - STAR file in mwtab formatted string. |
MoseleyBioinformaticsLab/mwtab | mwtab/mwtab.py | MWTabFile._is_mwtab | def _is_mwtab(string):
"""Test if input string is in `mwtab` format.
:param string: Input string.
:type string: :py:class:`str` or :py:class:`bytes`
:return: Input string if in mwTab format or False otherwise.
:rtype: :py:class:`str` or :py:obj:`False`
"""
if isi... | python | def _is_mwtab(string):
"""Test if input string is in `mwtab` format.
:param string: Input string.
:type string: :py:class:`str` or :py:class:`bytes`
:return: Input string if in mwTab format or False otherwise.
:rtype: :py:class:`str` or :py:obj:`False`
"""
if isi... | [
"def",
"_is_mwtab",
"(",
"string",
")",
":",
"if",
"isinstance",
"(",
"string",
",",
"str",
")",
":",
"lines",
"=",
"string",
".",
"split",
"(",
"\"\\n\"",
")",
"elif",
"isinstance",
"(",
"string",
",",
"bytes",
")",
":",
"lines",
"=",
"string",
".",... | Test if input string is in `mwtab` format.
:param string: Input string.
:type string: :py:class:`str` or :py:class:`bytes`
:return: Input string if in mwTab format or False otherwise.
:rtype: :py:class:`str` or :py:obj:`False` | [
"Test",
"if",
"input",
"string",
"is",
"in",
"mwtab",
"format",
"."
] | 8c0ae8ab2aa621662f99589ed41e481cf8b7152b | https://github.com/MoseleyBioinformaticsLab/mwtab/blob/8c0ae8ab2aa621662f99589ed41e481cf8b7152b/mwtab/mwtab.py#L314-L334 | train | Test if input string is in mwTab format. |
MoseleyBioinformaticsLab/mwtab | mwtab/mwtab.py | MWTabFile._is_json | def _is_json(string):
"""Test if input string is in JSON format.
:param string: Input string.
:type string: :py:class:`str` or :py:class:`bytes`
:return: Input string if in JSON format or False otherwise.
:rtype: :py:class:`str` or :py:obj:`False`
"""
try:
... | python | def _is_json(string):
"""Test if input string is in JSON format.
:param string: Input string.
:type string: :py:class:`str` or :py:class:`bytes`
:return: Input string if in JSON format or False otherwise.
:rtype: :py:class:`str` or :py:obj:`False`
"""
try:
... | [
"def",
"_is_json",
"(",
"string",
")",
":",
"try",
":",
"if",
"isinstance",
"(",
"string",
",",
"bytes",
")",
":",
"json_str",
"=",
"json",
".",
"loads",
"(",
"string",
".",
"decode",
"(",
"\"utf-8\"",
")",
",",
"object_pairs_hook",
"=",
"OrderedDict",
... | Test if input string is in JSON format.
:param string: Input string.
:type string: :py:class:`str` or :py:class:`bytes`
:return: Input string if in JSON format or False otherwise.
:rtype: :py:class:`str` or :py:obj:`False` | [
"Test",
"if",
"input",
"string",
"is",
"in",
"JSON",
"format",
"."
] | 8c0ae8ab2aa621662f99589ed41e481cf8b7152b | https://github.com/MoseleyBioinformaticsLab/mwtab/blob/8c0ae8ab2aa621662f99589ed41e481cf8b7152b/mwtab/mwtab.py#L337-L354 | train | Test if input string is in JSON format. |
prezi/django-zipkin | django_zipkin/_thrift/zipkinQuery/ZipkinQuery.py | Client.getTraceIdsBySpanName | def getTraceIdsBySpanName(self, service_name, span_name, end_ts, limit, order):
"""
Fetch trace ids by service and span name.
Gets "limit" number of entries from before the "end_ts".
Span name is optional.
Timestamps are in microseconds.
Parameters:
- service_name
- span_name
- ... | python | def getTraceIdsBySpanName(self, service_name, span_name, end_ts, limit, order):
"""
Fetch trace ids by service and span name.
Gets "limit" number of entries from before the "end_ts".
Span name is optional.
Timestamps are in microseconds.
Parameters:
- service_name
- span_name
- ... | [
"def",
"getTraceIdsBySpanName",
"(",
"self",
",",
"service_name",
",",
"span_name",
",",
"end_ts",
",",
"limit",
",",
"order",
")",
":",
"self",
".",
"send_getTraceIdsBySpanName",
"(",
"service_name",
",",
"span_name",
",",
"end_ts",
",",
"limit",
",",
"order"... | Fetch trace ids by service and span name.
Gets "limit" number of entries from before the "end_ts".
Span name is optional.
Timestamps are in microseconds.
Parameters:
- service_name
- span_name
- end_ts
- limit
- order | [
"Fetch",
"trace",
"ids",
"by",
"service",
"and",
"span",
"name",
".",
"Gets",
"limit",
"number",
"of",
"entries",
"from",
"before",
"the",
"end_ts",
"."
] | 158d04cf9c2fe0adcb4cda66a250d9e41eae33f3 | https://github.com/prezi/django-zipkin/blob/158d04cf9c2fe0adcb4cda66a250d9e41eae33f3/django_zipkin/_thrift/zipkinQuery/ZipkinQuery.py#L286-L302 | train | Fetch trace ids by service and span name. |
prezi/django-zipkin | django_zipkin/_thrift/zipkinQuery/ZipkinQuery.py | Client.getTraceIdsByServiceName | def getTraceIdsByServiceName(self, service_name, end_ts, limit, order):
"""
Fetch trace ids by service name.
Gets "limit" number of entries from before the "end_ts".
Timestamps are in microseconds.
Parameters:
- service_name
- end_ts
- limit
- order
"""
self.send_getTra... | python | def getTraceIdsByServiceName(self, service_name, end_ts, limit, order):
"""
Fetch trace ids by service name.
Gets "limit" number of entries from before the "end_ts".
Timestamps are in microseconds.
Parameters:
- service_name
- end_ts
- limit
- order
"""
self.send_getTra... | [
"def",
"getTraceIdsByServiceName",
"(",
"self",
",",
"service_name",
",",
"end_ts",
",",
"limit",
",",
"order",
")",
":",
"self",
".",
"send_getTraceIdsByServiceName",
"(",
"service_name",
",",
"end_ts",
",",
"limit",
",",
"order",
")",
"return",
"self",
".",
... | Fetch trace ids by service name.
Gets "limit" number of entries from before the "end_ts".
Timestamps are in microseconds.
Parameters:
- service_name
- end_ts
- limit
- order | [
"Fetch",
"trace",
"ids",
"by",
"service",
"name",
".",
"Gets",
"limit",
"number",
"of",
"entries",
"from",
"before",
"the",
"end_ts",
"."
] | 158d04cf9c2fe0adcb4cda66a250d9e41eae33f3 | https://github.com/prezi/django-zipkin/blob/158d04cf9c2fe0adcb4cda66a250d9e41eae33f3/django_zipkin/_thrift/zipkinQuery/ZipkinQuery.py#L332-L346 | train | Fetch trace ids by service name. |
prezi/django-zipkin | django_zipkin/_thrift/zipkinQuery/ZipkinQuery.py | Client.getTraceIdsByAnnotation | def getTraceIdsByAnnotation(self, service_name, annotation, value, end_ts, limit, order):
"""
Fetch trace ids with a particular annotation.
Gets "limit" number of entries from before the "end_ts".
When requesting based on time based annotations only pass in the first parameter, "annotation" and leave o... | python | def getTraceIdsByAnnotation(self, service_name, annotation, value, end_ts, limit, order):
"""
Fetch trace ids with a particular annotation.
Gets "limit" number of entries from before the "end_ts".
When requesting based on time based annotations only pass in the first parameter, "annotation" and leave o... | [
"def",
"getTraceIdsByAnnotation",
"(",
"self",
",",
"service_name",
",",
"annotation",
",",
"value",
",",
"end_ts",
",",
"limit",
",",
"order",
")",
":",
"self",
".",
"send_getTraceIdsByAnnotation",
"(",
"service_name",
",",
"annotation",
",",
"value",
",",
"e... | Fetch trace ids with a particular annotation.
Gets "limit" number of entries from before the "end_ts".
When requesting based on time based annotations only pass in the first parameter, "annotation" and leave out
the second "value". If looking for a key-value binary annotation provide both, "annotation" is ... | [
"Fetch",
"trace",
"ids",
"with",
"a",
"particular",
"annotation",
".",
"Gets",
"limit",
"number",
"of",
"entries",
"from",
"before",
"the",
"end_ts",
"."
] | 158d04cf9c2fe0adcb4cda66a250d9e41eae33f3 | https://github.com/prezi/django-zipkin/blob/158d04cf9c2fe0adcb4cda66a250d9e41eae33f3/django_zipkin/_thrift/zipkinQuery/ZipkinQuery.py#L375-L395 | train | This method is used to fetch trace ids with a particular annotation. |
prezi/django-zipkin | django_zipkin/_thrift/zipkinQuery/ZipkinQuery.py | Client.getTracesByIds | def getTracesByIds(self, trace_ids, adjust):
"""
Get the full traces associated with the given trace ids.
Second argument is a list of methods of adjusting the trace
data before returning it. Can be empty.
Parameters:
- trace_ids
- adjust
"""
self.send_getTracesByIds(trace_ids, a... | python | def getTracesByIds(self, trace_ids, adjust):
"""
Get the full traces associated with the given trace ids.
Second argument is a list of methods of adjusting the trace
data before returning it. Can be empty.
Parameters:
- trace_ids
- adjust
"""
self.send_getTracesByIds(trace_ids, a... | [
"def",
"getTracesByIds",
"(",
"self",
",",
"trace_ids",
",",
"adjust",
")",
":",
"self",
".",
"send_getTracesByIds",
"(",
"trace_ids",
",",
"adjust",
")",
"return",
"self",
".",
"recv_getTracesByIds",
"(",
")"
] | Get the full traces associated with the given trace ids.
Second argument is a list of methods of adjusting the trace
data before returning it. Can be empty.
Parameters:
- trace_ids
- adjust | [
"Get",
"the",
"full",
"traces",
"associated",
"with",
"the",
"given",
"trace",
"ids",
"."
] | 158d04cf9c2fe0adcb4cda66a250d9e41eae33f3 | https://github.com/prezi/django-zipkin/blob/158d04cf9c2fe0adcb4cda66a250d9e41eae33f3/django_zipkin/_thrift/zipkinQuery/ZipkinQuery.py#L460-L472 | train | This method is used to get the full traces associated with the given trace ids. |
prezi/django-zipkin | django_zipkin/_thrift/zipkinQuery/ZipkinQuery.py | Client.getTraceTimelinesByIds | def getTraceTimelinesByIds(self, trace_ids, adjust):
"""
Get the trace timelines associated with the given trace ids.
This is a convenience method for users that just want to know
the annotations and the (assumed) order they happened in.
Second argument is a list of methods of adjusting the trace
... | python | def getTraceTimelinesByIds(self, trace_ids, adjust):
"""
Get the trace timelines associated with the given trace ids.
This is a convenience method for users that just want to know
the annotations and the (assumed) order they happened in.
Second argument is a list of methods of adjusting the trace
... | [
"def",
"getTraceTimelinesByIds",
"(",
"self",
",",
"trace_ids",
",",
"adjust",
")",
":",
"self",
".",
"send_getTraceTimelinesByIds",
"(",
"trace_ids",
",",
"adjust",
")",
"return",
"self",
".",
"recv_getTraceTimelinesByIds",
"(",
")"
] | Get the trace timelines associated with the given trace ids.
This is a convenience method for users that just want to know
the annotations and the (assumed) order they happened in.
Second argument is a list of methods of adjusting the trace
data before returning it. Can be empty.
Note that if one ... | [
"Get",
"the",
"trace",
"timelines",
"associated",
"with",
"the",
"given",
"trace",
"ids",
".",
"This",
"is",
"a",
"convenience",
"method",
"for",
"users",
"that",
"just",
"want",
"to",
"know",
"the",
"annotations",
"and",
"the",
"(",
"assumed",
")",
"order... | 158d04cf9c2fe0adcb4cda66a250d9e41eae33f3 | https://github.com/prezi/django-zipkin/blob/158d04cf9c2fe0adcb4cda66a250d9e41eae33f3/django_zipkin/_thrift/zipkinQuery/ZipkinQuery.py#L499-L516 | train | This method returns the trace timelines associated with the given trace ids. |
prezi/django-zipkin | django_zipkin/_thrift/zipkinQuery/ZipkinQuery.py | Client.getTraceSummariesByIds | def getTraceSummariesByIds(self, trace_ids, adjust):
"""
Fetch trace summaries for the given trace ids.
Second argument is a list of methods of adjusting the trace
data before returning it. Can be empty.
Note that if one of the trace ids does not have any data associated with it, it will not be
... | python | def getTraceSummariesByIds(self, trace_ids, adjust):
"""
Fetch trace summaries for the given trace ids.
Second argument is a list of methods of adjusting the trace
data before returning it. Can be empty.
Note that if one of the trace ids does not have any data associated with it, it will not be
... | [
"def",
"getTraceSummariesByIds",
"(",
"self",
",",
"trace_ids",
",",
"adjust",
")",
":",
"self",
".",
"send_getTraceSummariesByIds",
"(",
"trace_ids",
",",
"adjust",
")",
"return",
"self",
".",
"recv_getTraceSummariesByIds",
"(",
")"
] | Fetch trace summaries for the given trace ids.
Second argument is a list of methods of adjusting the trace
data before returning it. Can be empty.
Note that if one of the trace ids does not have any data associated with it, it will not be
represented in the output list.
Parameters:
- trace_i... | [
"Fetch",
"trace",
"summaries",
"for",
"the",
"given",
"trace",
"ids",
"."
] | 158d04cf9c2fe0adcb4cda66a250d9e41eae33f3 | https://github.com/prezi/django-zipkin/blob/158d04cf9c2fe0adcb4cda66a250d9e41eae33f3/django_zipkin/_thrift/zipkinQuery/ZipkinQuery.py#L543-L558 | train | This method is used to fetch trace summaries for the given trace ids. |
prezi/django-zipkin | django_zipkin/_thrift/zipkinQuery/ZipkinQuery.py | Client.getTraceCombosByIds | def getTraceCombosByIds(self, trace_ids, adjust):
"""
Not content with just one of traces, summaries or timelines? Want it all? This is the method for you.
Parameters:
- trace_ids
- adjust
"""
self.send_getTraceCombosByIds(trace_ids, adjust)
return self.recv_getTraceCombosByIds() | python | def getTraceCombosByIds(self, trace_ids, adjust):
"""
Not content with just one of traces, summaries or timelines? Want it all? This is the method for you.
Parameters:
- trace_ids
- adjust
"""
self.send_getTraceCombosByIds(trace_ids, adjust)
return self.recv_getTraceCombosByIds() | [
"def",
"getTraceCombosByIds",
"(",
"self",
",",
"trace_ids",
",",
"adjust",
")",
":",
"self",
".",
"send_getTraceCombosByIds",
"(",
"trace_ids",
",",
"adjust",
")",
"return",
"self",
".",
"recv_getTraceCombosByIds",
"(",
")"
] | Not content with just one of traces, summaries or timelines? Want it all? This is the method for you.
Parameters:
- trace_ids
- adjust | [
"Not",
"content",
"with",
"just",
"one",
"of",
"traces",
"summaries",
"or",
"timelines?",
"Want",
"it",
"all?",
"This",
"is",
"the",
"method",
"for",
"you",
"."
] | 158d04cf9c2fe0adcb4cda66a250d9e41eae33f3 | https://github.com/prezi/django-zipkin/blob/158d04cf9c2fe0adcb4cda66a250d9e41eae33f3/django_zipkin/_thrift/zipkinQuery/ZipkinQuery.py#L585-L594 | train | Get a list of traces by IDs |
prezi/django-zipkin | django_zipkin/_thrift/zipkinQuery/ZipkinQuery.py | Client.setTraceTimeToLive | def setTraceTimeToLive(self, trace_id, ttl_seconds):
"""
Change the TTL of a trace. If we find an interesting trace we want to keep around for further
investigation.
Parameters:
- trace_id
- ttl_seconds
"""
self.send_setTraceTimeToLive(trace_id, ttl_seconds)
self.recv_setTraceTime... | python | def setTraceTimeToLive(self, trace_id, ttl_seconds):
"""
Change the TTL of a trace. If we find an interesting trace we want to keep around for further
investigation.
Parameters:
- trace_id
- ttl_seconds
"""
self.send_setTraceTimeToLive(trace_id, ttl_seconds)
self.recv_setTraceTime... | [
"def",
"setTraceTimeToLive",
"(",
"self",
",",
"trace_id",
",",
"ttl_seconds",
")",
":",
"self",
".",
"send_setTraceTimeToLive",
"(",
"trace_id",
",",
"ttl_seconds",
")",
"self",
".",
"recv_setTraceTimeToLive",
"(",
")"
] | Change the TTL of a trace. If we find an interesting trace we want to keep around for further
investigation.
Parameters:
- trace_id
- ttl_seconds | [
"Change",
"the",
"TTL",
"of",
"a",
"trace",
".",
"If",
"we",
"find",
"an",
"interesting",
"trace",
"we",
"want",
"to",
"keep",
"around",
"for",
"further",
"investigation",
"."
] | 158d04cf9c2fe0adcb4cda66a250d9e41eae33f3 | https://github.com/prezi/django-zipkin/blob/158d04cf9c2fe0adcb4cda66a250d9e41eae33f3/django_zipkin/_thrift/zipkinQuery/ZipkinQuery.py#L685-L695 | train | Sets the TTL of a trace. |
prezi/django-zipkin | django_zipkin/_thrift/zipkinQuery/ZipkinQuery.py | Client.getDependencies | def getDependencies(self, start_time, end_time):
"""
Get an aggregate representation of all services paired with every service they call in to.
This includes information on call counts and mean/stdDev/etc of call durations. The two arguments
specify epoch time in microseconds. The end time is optional ... | python | def getDependencies(self, start_time, end_time):
"""
Get an aggregate representation of all services paired with every service they call in to.
This includes information on call counts and mean/stdDev/etc of call durations. The two arguments
specify epoch time in microseconds. The end time is optional ... | [
"def",
"getDependencies",
"(",
"self",
",",
"start_time",
",",
"end_time",
")",
":",
"self",
".",
"send_getDependencies",
"(",
"start_time",
",",
"end_time",
")",
"return",
"self",
".",
"recv_getDependencies",
"(",
")"
] | Get an aggregate representation of all services paired with every service they call in to.
This includes information on call counts and mean/stdDev/etc of call durations. The two arguments
specify epoch time in microseconds. The end time is optional and defaults to one day after the
start time.
Parame... | [
"Get",
"an",
"aggregate",
"representation",
"of",
"all",
"services",
"paired",
"with",
"every",
"service",
"they",
"call",
"in",
"to",
".",
"This",
"includes",
"information",
"on",
"call",
"counts",
"and",
"mean",
"/",
"stdDev",
"/",
"etc",
"of",
"call",
"... | 158d04cf9c2fe0adcb4cda66a250d9e41eae33f3 | https://github.com/prezi/django-zipkin/blob/158d04cf9c2fe0adcb4cda66a250d9e41eae33f3/django_zipkin/_thrift/zipkinQuery/ZipkinQuery.py#L784-L796 | train | This method returns the aggregate representation of all services paired with every service they call in to. |
prezi/django-zipkin | django_zipkin/_thrift/zipkinQuery/ZipkinQuery.py | Client.getSpanDurations | def getSpanDurations(self, time_stamp, service_name, rpc_name):
"""
Given a time stamp, server service name, and rpc name, fetch all of the client services calling in paired
with the lists of every span duration (list<i64>) from the server to client. The lists of span durations
include information on ca... | python | def getSpanDurations(self, time_stamp, service_name, rpc_name):
"""
Given a time stamp, server service name, and rpc name, fetch all of the client services calling in paired
with the lists of every span duration (list<i64>) from the server to client. The lists of span durations
include information on ca... | [
"def",
"getSpanDurations",
"(",
"self",
",",
"time_stamp",
",",
"service_name",
",",
"rpc_name",
")",
":",
"self",
".",
"send_getSpanDurations",
"(",
"time_stamp",
",",
"service_name",
",",
"rpc_name",
")",
"return",
"self",
".",
"recv_getSpanDurations",
"(",
")... | Given a time stamp, server service name, and rpc name, fetch all of the client services calling in paired
with the lists of every span duration (list<i64>) from the server to client. The lists of span durations
include information on call counts and mean/stdDev/etc of call durations.
The three arguments sp... | [
"Given",
"a",
"time",
"stamp",
"server",
"service",
"name",
"and",
"rpc",
"name",
"fetch",
"all",
"of",
"the",
"client",
"services",
"calling",
"in",
"paired",
"with",
"the",
"lists",
"of",
"every",
"span",
"duration",
"(",
"list<i64",
">",
")",
"from",
... | 158d04cf9c2fe0adcb4cda66a250d9e41eae33f3 | https://github.com/prezi/django-zipkin/blob/158d04cf9c2fe0adcb4cda66a250d9e41eae33f3/django_zipkin/_thrift/zipkinQuery/ZipkinQuery.py#L887-L902 | train | This method is used to fetch all of the span durations from the server to the client. |
prezi/django-zipkin | django_zipkin/_thrift/zipkinQuery/ZipkinQuery.py | Client.getServiceNamesToTraceIds | def getServiceNamesToTraceIds(self, time_stamp, service_name, rpc_name):
"""
Given a time stamp, server service name, and rpc name, fetch all of the client services calling in paired
with the lists of every trace Ids (list<i64>) from the server to client.
The three arguments specify epoch time in micro... | python | def getServiceNamesToTraceIds(self, time_stamp, service_name, rpc_name):
"""
Given a time stamp, server service name, and rpc name, fetch all of the client services calling in paired
with the lists of every trace Ids (list<i64>) from the server to client.
The three arguments specify epoch time in micro... | [
"def",
"getServiceNamesToTraceIds",
"(",
"self",
",",
"time_stamp",
",",
"service_name",
",",
"rpc_name",
")",
":",
"self",
".",
"send_getServiceNamesToTraceIds",
"(",
"time_stamp",
",",
"service_name",
",",
"rpc_name",
")",
"return",
"self",
".",
"recv_getServiceNa... | Given a time stamp, server service name, and rpc name, fetch all of the client services calling in paired
with the lists of every trace Ids (list<i64>) from the server to client.
The three arguments specify epoch time in microseconds, server side service name and rpc name. The return maps
contains the key ... | [
"Given",
"a",
"time",
"stamp",
"server",
"service",
"name",
"and",
"rpc",
"name",
"fetch",
"all",
"of",
"the",
"client",
"services",
"calling",
"in",
"paired",
"with",
"the",
"lists",
"of",
"every",
"trace",
"Ids",
"(",
"list<i64",
">",
")",
"from",
"the... | 158d04cf9c2fe0adcb4cda66a250d9e41eae33f3 | https://github.com/prezi/django-zipkin/blob/158d04cf9c2fe0adcb4cda66a250d9e41eae33f3/django_zipkin/_thrift/zipkinQuery/ZipkinQuery.py#L928-L942 | train | This method is used to fetch all of the client services and trace Ids from the server. |
camptocamp/Studio | studio/lib/datasource_discovery.py | discover_datasources | def discover_datasources(datastore_str):
""" Discover the datasources contained in the datastore
corresponding to the OGR string ogr_str, return an
array of {name,type, hash}"""
datastore = DataStore(datastore_str)
datasources=[]
for ds in datastore.get_datasources():
datasources.ap... | python | def discover_datasources(datastore_str):
""" Discover the datasources contained in the datastore
corresponding to the OGR string ogr_str, return an
array of {name,type, hash}"""
datastore = DataStore(datastore_str)
datasources=[]
for ds in datastore.get_datasources():
datasources.ap... | [
"def",
"discover_datasources",
"(",
"datastore_str",
")",
":",
"datastore",
"=",
"DataStore",
"(",
"datastore_str",
")",
"datasources",
"=",
"[",
"]",
"for",
"ds",
"in",
"datastore",
".",
"get_datasources",
"(",
")",
":",
"datasources",
".",
"append",
"(",
"... | Discover the datasources contained in the datastore
corresponding to the OGR string ogr_str, return an
array of {name,type, hash} | [
"Discover",
"the",
"datasources",
"contained",
"in",
"the",
"datastore",
"corresponding",
"to",
"the",
"OGR",
"string",
"ogr_str",
"return",
"an",
"array",
"of",
"{",
"name",
"type",
"hash",
"}"
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/lib/datasource_discovery.py#L47-L56 | train | Discover the datasources contained in the datastore |
camptocamp/Studio | studio/lib/datasource_discovery.py | discover_datasource_columns | def discover_datasource_columns(datastore_str, datasource_id):
""" Loop through the datastore's datasources to find
the datasource identified by datasource_id, return
the matching datasource's columns. """
datastore = DataStore(datastore_str)
datasource = datastore.get_datasource(datasource_id)
... | python | def discover_datasource_columns(datastore_str, datasource_id):
""" Loop through the datastore's datasources to find
the datasource identified by datasource_id, return
the matching datasource's columns. """
datastore = DataStore(datastore_str)
datasource = datastore.get_datasource(datasource_id)
... | [
"def",
"discover_datasource_columns",
"(",
"datastore_str",
",",
"datasource_id",
")",
":",
"datastore",
"=",
"DataStore",
"(",
"datastore_str",
")",
"datasource",
"=",
"datastore",
".",
"get_datasource",
"(",
"datasource_id",
")",
"if",
"datasource",
".",
"type",
... | Loop through the datastore's datasources to find
the datasource identified by datasource_id, return
the matching datasource's columns. | [
"Loop",
"through",
"the",
"datastore",
"s",
"datasources",
"to",
"find",
"the",
"datasource",
"identified",
"by",
"datasource_id",
"return",
"the",
"matching",
"datasource",
"s",
"columns",
"."
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/lib/datasource_discovery.py#L58-L67 | train | Find the datasource s columns and return them as a list. |
camptocamp/Studio | studio/lib/datasource_discovery.py | OgrDataSource._get_column_type | def _get_column_type(self,column):
""" Return 'numeric' if the column is of type integer or
real, otherwise return 'string'. """
ctype = column.GetType()
if ctype in [ogr.OFTInteger, ogr.OFTReal]:
return 'numeric'
else:
return 'string' | python | def _get_column_type(self,column):
""" Return 'numeric' if the column is of type integer or
real, otherwise return 'string'. """
ctype = column.GetType()
if ctype in [ogr.OFTInteger, ogr.OFTReal]:
return 'numeric'
else:
return 'string' | [
"def",
"_get_column_type",
"(",
"self",
",",
"column",
")",
":",
"ctype",
"=",
"column",
".",
"GetType",
"(",
")",
"if",
"ctype",
"in",
"[",
"ogr",
".",
"OFTInteger",
",",
"ogr",
".",
"OFTReal",
"]",
":",
"return",
"'numeric'",
"else",
":",
"return",
... | Return 'numeric' if the column is of type integer or
real, otherwise return 'string'. | [
"Return",
"numeric",
"if",
"the",
"column",
"is",
"of",
"type",
"integer",
"or",
"real",
"otherwise",
"return",
"string",
"."
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/lib/datasource_discovery.py#L269-L276 | train | Return numeric if the column is of type integer or
real otherwise return string. |
camptocamp/Studio | studio/lib/datasource_discovery.py | OgrDataSource._get_default_mapfile_excerpt | def _get_default_mapfile_excerpt(self):
""" Given an OGR string, an OGR connection and an OGR layer, create and
return a representation of a MapFile LAYER block. """
layerobj = self._get_layer_stub()
classobj = mapscript.classObj()
layerobj.insertClass(classobj)
... | python | def _get_default_mapfile_excerpt(self):
""" Given an OGR string, an OGR connection and an OGR layer, create and
return a representation of a MapFile LAYER block. """
layerobj = self._get_layer_stub()
classobj = mapscript.classObj()
layerobj.insertClass(classobj)
... | [
"def",
"_get_default_mapfile_excerpt",
"(",
"self",
")",
":",
"layerobj",
"=",
"self",
".",
"_get_layer_stub",
"(",
")",
"classobj",
"=",
"mapscript",
".",
"classObj",
"(",
")",
"layerobj",
".",
"insertClass",
"(",
"classobj",
")",
"styleobj",
"=",
"self",
"... | Given an OGR string, an OGR connection and an OGR layer, create and
return a representation of a MapFile LAYER block. | [
"Given",
"an",
"OGR",
"string",
"an",
"OGR",
"connection",
"and",
"an",
"OGR",
"layer",
"create",
"and",
"return",
"a",
"representation",
"of",
"a",
"MapFile",
"LAYER",
"block",
"."
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/lib/datasource_discovery.py#L285-L295 | train | Create and return a MapFile LAYER block. |
camptocamp/Studio | studio/lib/datasource_discovery.py | OgrDataSource._get_layer_stub | def _get_layer_stub(self):
""" builds a minimal mapscript layerobj, with no styling """
layerobj = mapscript.layerObj()
layerobj.name = self.name
layerobj.status = mapscript.MS_ON
projection = self.ogr_layer.GetSpatialRef()
featureIdColumn = self._get_featureId_column()
... | python | def _get_layer_stub(self):
""" builds a minimal mapscript layerobj, with no styling """
layerobj = mapscript.layerObj()
layerobj.name = self.name
layerobj.status = mapscript.MS_ON
projection = self.ogr_layer.GetSpatialRef()
featureIdColumn = self._get_featureId_column()
... | [
"def",
"_get_layer_stub",
"(",
"self",
")",
":",
"layerobj",
"=",
"mapscript",
".",
"layerObj",
"(",
")",
"layerobj",
".",
"name",
"=",
"self",
".",
"name",
"layerobj",
".",
"status",
"=",
"mapscript",
".",
"MS_ON",
"projection",
"=",
"self",
".",
"ogr_l... | builds a minimal mapscript layerobj, with no styling | [
"builds",
"a",
"minimal",
"mapscript",
"layerobj",
"with",
"no",
"styling"
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/lib/datasource_discovery.py#L303-L341 | train | Builds a minimal mapscript layerobj with no styling |
camptocamp/Studio | studio/config/middleware.py | make_app | def make_app(global_conf, full_stack=True, **app_conf):
"""Create a Pylons WSGI application and return it
``global_conf``
The inherited configuration for this application. Normally from
the [DEFAULT] section of the Paste ini file.
``full_stack``
Whether or not this application prov... | python | def make_app(global_conf, full_stack=True, **app_conf):
"""Create a Pylons WSGI application and return it
``global_conf``
The inherited configuration for this application. Normally from
the [DEFAULT] section of the Paste ini file.
``full_stack``
Whether or not this application prov... | [
"def",
"make_app",
"(",
"global_conf",
",",
"full_stack",
"=",
"True",
",",
"*",
"*",
"app_conf",
")",
":",
"# Configure the Pylons environment",
"load_environment",
"(",
"global_conf",
",",
"app_conf",
")",
"# The Pylons WSGI app",
"app",
"=",
"PylonsApp",
"(",
"... | Create a Pylons WSGI application and return it
``global_conf``
The inherited configuration for this application. Normally from
the [DEFAULT] section of the Paste ini file.
``full_stack``
Whether or not this application provides a full WSGI stack (by
default, meaning it handles ... | [
"Create",
"a",
"Pylons",
"WSGI",
"application",
"and",
"return",
"it"
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/config/middleware.py#L35-L88 | train | Create a Pylons WSGI application and return it. |
cocaine/cocaine-tools | cocaine/proxy/mds_direct.py | MDSDirect.reelect_app | def reelect_app(self, request, app):
"""tries to connect to the same app on differnet host from dist-info"""
# disconnect app explicitly to break possibly existing connection
app.disconnect()
endpoints_size = len(app.locator.endpoints)
# try x times, where x is the number of di... | python | def reelect_app(self, request, app):
"""tries to connect to the same app on differnet host from dist-info"""
# disconnect app explicitly to break possibly existing connection
app.disconnect()
endpoints_size = len(app.locator.endpoints)
# try x times, where x is the number of di... | [
"def",
"reelect_app",
"(",
"self",
",",
"request",
",",
"app",
")",
":",
"# disconnect app explicitly to break possibly existing connection",
"app",
".",
"disconnect",
"(",
")",
"endpoints_size",
"=",
"len",
"(",
"app",
".",
"locator",
".",
"endpoints",
")",
"# tr... | tries to connect to the same app on differnet host from dist-info | [
"tries",
"to",
"connect",
"to",
"the",
"same",
"app",
"on",
"differnet",
"host",
"from",
"dist",
"-",
"info"
] | d8834f8e04ca42817d5f4e368d471484d4b3419f | https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/proxy/mds_direct.py#L69-L116 | train | try to connect to the same application on differnet host from dist - info |
cnschema/cdata | cdata/wikify.py | wikidata_get | def wikidata_get(identifier):
"""
https://www.wikidata.org/wiki/Special:EntityData/P248.json
"""
url = 'https://www.wikidata.org/wiki/Special:EntityData/{}.json'.format(identifier)
#logging.info(url)
return json.loads(requests.get(url).content) | python | def wikidata_get(identifier):
"""
https://www.wikidata.org/wiki/Special:EntityData/P248.json
"""
url = 'https://www.wikidata.org/wiki/Special:EntityData/{}.json'.format(identifier)
#logging.info(url)
return json.loads(requests.get(url).content) | [
"def",
"wikidata_get",
"(",
"identifier",
")",
":",
"url",
"=",
"'https://www.wikidata.org/wiki/Special:EntityData/{}.json'",
".",
"format",
"(",
"identifier",
")",
"#logging.info(url)",
"return",
"json",
".",
"loads",
"(",
"requests",
".",
"get",
"(",
"url",
")",
... | https://www.wikidata.org/wiki/Special:EntityData/P248.json | [
"https",
":",
"//",
"www",
".",
"wikidata",
".",
"org",
"/",
"wiki",
"/",
"Special",
":",
"EntityData",
"/",
"P248",
".",
"json"
] | 893e2e1e27b61c8551c8b5f5f9bf05ec61490e23 | https://github.com/cnschema/cdata/blob/893e2e1e27b61c8551c8b5f5f9bf05ec61490e23/cdata/wikify.py#L51-L57 | train | Get a single entity from Wikidata. |
cnschema/cdata | cdata/wikify.py | wikidata_search | def wikidata_search(query, lang="zh", output_lang="en", searchtype="item", max_result=1):
"""
wikification: search wikipedia pages for the given query
https://www.wikidata.org/w/api.php?action=help&modules=wbsearchentities
result format
{
searchinfo: - {
se... | python | def wikidata_search(query, lang="zh", output_lang="en", searchtype="item", max_result=1):
"""
wikification: search wikipedia pages for the given query
https://www.wikidata.org/w/api.php?action=help&modules=wbsearchentities
result format
{
searchinfo: - {
se... | [
"def",
"wikidata_search",
"(",
"query",
",",
"lang",
"=",
"\"zh\"",
",",
"output_lang",
"=",
"\"en\"",
",",
"searchtype",
"=",
"\"item\"",
",",
"max_result",
"=",
"1",
")",
":",
"query",
"=",
"any2unicode",
"(",
"query",
")",
"params",
"=",
"{",
"\"actio... | wikification: search wikipedia pages for the given query
https://www.wikidata.org/w/api.php?action=help&modules=wbsearchentities
result format
{
searchinfo: - {
search: "birthday"
},
search: - [
- {
repository: "",
... | [
"wikification",
":",
"search",
"wikipedia",
"pages",
"for",
"the",
"given",
"query",
"https",
":",
"//",
"www",
".",
"wikidata",
".",
"org",
"/",
"w",
"/",
"api",
".",
"php?action",
"=",
"help&modules",
"=",
"wbsearchentities"
] | 893e2e1e27b61c8551c8b5f5f9bf05ec61490e23 | https://github.com/cnschema/cdata/blob/893e2e1e27b61c8551c8b5f5f9bf05ec61490e23/cdata/wikify.py#L59-L115 | train | Search the Wikidata API for the given query. |
cnschema/cdata | cdata/wikify.py | wikipedia_search | def wikipedia_search(query, lang="en", max_result=1):
"""
https://www.mediawiki.org/wiki/API:Opensearch
"""
query = any2unicode(query)
params = {
"action":"opensearch",
"search": query,
"format":"json",
#"formatversion":2,
#"namespace":0,
"suggest"... | python | def wikipedia_search(query, lang="en", max_result=1):
"""
https://www.mediawiki.org/wiki/API:Opensearch
"""
query = any2unicode(query)
params = {
"action":"opensearch",
"search": query,
"format":"json",
#"formatversion":2,
#"namespace":0,
"suggest"... | [
"def",
"wikipedia_search",
"(",
"query",
",",
"lang",
"=",
"\"en\"",
",",
"max_result",
"=",
"1",
")",
":",
"query",
"=",
"any2unicode",
"(",
"query",
")",
"params",
"=",
"{",
"\"action\"",
":",
"\"opensearch\"",
",",
"\"search\"",
":",
"query",
",",
"\"... | https://www.mediawiki.org/wiki/API:Opensearch | [
"https",
":",
"//",
"www",
".",
"mediawiki",
".",
"org",
"/",
"wiki",
"/",
"API",
":",
"Opensearch"
] | 893e2e1e27b61c8551c8b5f5f9bf05ec61490e23 | https://github.com/cnschema/cdata/blob/893e2e1e27b61c8551c8b5f5f9bf05ec61490e23/cdata/wikify.py#L137-L171 | train | Search the Wikipedia page for items. |
noirbizarre/django-ember | setup.py | pip | def pip(filename):
'''Parse pip requirement file and transform it to setuptools requirements'''
path = join('requirements', filename)
return [line for line in open(path).readlines() if not line.startswith('-e')] | python | def pip(filename):
'''Parse pip requirement file and transform it to setuptools requirements'''
path = join('requirements', filename)
return [line for line in open(path).readlines() if not line.startswith('-e')] | [
"def",
"pip",
"(",
"filename",
")",
":",
"path",
"=",
"join",
"(",
"'requirements'",
",",
"filename",
")",
"return",
"[",
"line",
"for",
"line",
"in",
"open",
"(",
"path",
")",
".",
"readlines",
"(",
")",
"if",
"not",
"line",
".",
"startswith",
"(",
... | Parse pip requirement file and transform it to setuptools requirements | [
"Parse",
"pip",
"requirement",
"file",
"and",
"transform",
"it",
"to",
"setuptools",
"requirements"
] | 47b5dad4f623efaccd3492c11d96fa4afdf8fb33 | https://github.com/noirbizarre/django-ember/blob/47b5dad4f623efaccd3492c11d96fa4afdf8fb33/setup.py#L33-L36 | train | Parse pip requirement file and transform it to setuptools requirements |
tropo/tropo-webapi-python | samples/appengine/main.py | HelloWorld | def HelloWorld(handler, t):
"""
This is the traditional "Hello, World" function. The idiom is used throughout the API. We construct a Tropo object, and then flesh out that object by calling "action" functions (in this case, tropo.say). Then call tropo.Render, which translates the Tropo object into JSON format. ... | python | def HelloWorld(handler, t):
"""
This is the traditional "Hello, World" function. The idiom is used throughout the API. We construct a Tropo object, and then flesh out that object by calling "action" functions (in this case, tropo.say). Then call tropo.Render, which translates the Tropo object into JSON format. ... | [
"def",
"HelloWorld",
"(",
"handler",
",",
"t",
")",
":",
"t",
".",
"say",
"(",
"[",
"\"Hello, World\"",
",",
"\"How ya doing?\"",
"]",
")",
"json",
"=",
"t",
".",
"RenderJson",
"(",
")",
"logging",
".",
"info",
"(",
"\"HelloWorld json: %s\"",
"%",
"json"... | This is the traditional "Hello, World" function. The idiom is used throughout the API. We construct a Tropo object, and then flesh out that object by calling "action" functions (in this case, tropo.say). Then call tropo.Render, which translates the Tropo object into JSON format. Finally, we write the JSON object to the... | [
"This",
"is",
"the",
"traditional",
"Hello",
"World",
"function",
".",
"The",
"idiom",
"is",
"used",
"throughout",
"the",
"API",
".",
"We",
"construct",
"a",
"Tropo",
"object",
"and",
"then",
"flesh",
"out",
"that",
"object",
"by",
"calling",
"action",
"fu... | f87772644a6b45066a4c5218f0c1f6467b64ab3c | https://github.com/tropo/tropo-webapi-python/blob/f87772644a6b45066a4c5218f0c1f6467b64ab3c/samples/appengine/main.py#L19-L26 | train | This is the traditional hello world function. It is used throughout the API. |
tropo/tropo-webapi-python | samples/appengine/main.py | RecordHelloWorld | def RecordHelloWorld(handler, t):
"""
Demonstration of recording a message.
"""
url = "%s/receive_recording.py" % THIS_URL
t.startRecording(url)
t.say ("Hello, World.")
t.stopRecording()
json = t.RenderJson()
logging.info ("RecordHelloWorld json: %s" % json)
handler.response.out.... | python | def RecordHelloWorld(handler, t):
"""
Demonstration of recording a message.
"""
url = "%s/receive_recording.py" % THIS_URL
t.startRecording(url)
t.say ("Hello, World.")
t.stopRecording()
json = t.RenderJson()
logging.info ("RecordHelloWorld json: %s" % json)
handler.response.out.... | [
"def",
"RecordHelloWorld",
"(",
"handler",
",",
"t",
")",
":",
"url",
"=",
"\"%s/receive_recording.py\"",
"%",
"THIS_URL",
"t",
".",
"startRecording",
"(",
"url",
")",
"t",
".",
"say",
"(",
"\"Hello, World.\"",
")",
"t",
".",
"stopRecording",
"(",
")",
"js... | Demonstration of recording a message. | [
"Demonstration",
"of",
"recording",
"a",
"message",
"."
] | f87772644a6b45066a4c5218f0c1f6467b64ab3c | https://github.com/tropo/tropo-webapi-python/blob/f87772644a6b45066a4c5218f0c1f6467b64ab3c/samples/appengine/main.py#L69-L79 | train | Demonstration of recording a message. |
tropo/tropo-webapi-python | samples/appengine/main.py | RedirectDemo | def RedirectDemo(handler, t):
"""
Demonstration of redirecting to another number.
"""
# t.say ("One moment please.")
t.redirect(SIP_PHONE)
json = t.RenderJson()
logging.info ("RedirectDemo json: %s" % json)
handler.response.out.write(json) | python | def RedirectDemo(handler, t):
"""
Demonstration of redirecting to another number.
"""
# t.say ("One moment please.")
t.redirect(SIP_PHONE)
json = t.RenderJson()
logging.info ("RedirectDemo json: %s" % json)
handler.response.out.write(json) | [
"def",
"RedirectDemo",
"(",
"handler",
",",
"t",
")",
":",
"# t.say (\"One moment please.\")",
"t",
".",
"redirect",
"(",
"SIP_PHONE",
")",
"json",
"=",
"t",
".",
"RenderJson",
"(",
")",
"logging",
".",
"info",
"(",
"\"RedirectDemo json: %s\"",
"%",
"json",
... | Demonstration of redirecting to another number. | [
"Demonstration",
"of",
"redirecting",
"to",
"another",
"number",
"."
] | f87772644a6b45066a4c5218f0c1f6467b64ab3c | https://github.com/tropo/tropo-webapi-python/blob/f87772644a6b45066a4c5218f0c1f6467b64ab3c/samples/appengine/main.py#L81-L89 | train | Redirecting to another number. |
tropo/tropo-webapi-python | samples/appengine/main.py | TransferDemo | def TransferDemo(handler, t):
"""
Demonstration of transfering to another number
"""
t.say ("One moment please.")
t.transfer(MY_PHONE)
t.say("Hi. I am a robot")
json = t.RenderJson()
logging.info ("TransferDemo json: %s" % json)
handler.response.out.write(json) | python | def TransferDemo(handler, t):
"""
Demonstration of transfering to another number
"""
t.say ("One moment please.")
t.transfer(MY_PHONE)
t.say("Hi. I am a robot")
json = t.RenderJson()
logging.info ("TransferDemo json: %s" % json)
handler.response.out.write(json) | [
"def",
"TransferDemo",
"(",
"handler",
",",
"t",
")",
":",
"t",
".",
"say",
"(",
"\"One moment please.\"",
")",
"t",
".",
"transfer",
"(",
"MY_PHONE",
")",
"t",
".",
"say",
"(",
"\"Hi. I am a robot\"",
")",
"json",
"=",
"t",
".",
"RenderJson",
"(",
")"... | Demonstration of transfering to another number | [
"Demonstration",
"of",
"transfering",
"to",
"another",
"number"
] | f87772644a6b45066a4c5218f0c1f6467b64ab3c | https://github.com/tropo/tropo-webapi-python/blob/f87772644a6b45066a4c5218f0c1f6467b64ab3c/samples/appengine/main.py#L91-L100 | train | Demo for transfering to another number |
uw-it-aca/uw-restclients-core | restclients_core/util/retry.py | retry | def retry(ExceptionToCheck, tries=4, delay=3, backoff=2, status_codes=[],
logger=None):
"""
Decorator function for retrying the decorated function,
using an exponential or fixed backoff.
Original: https://wiki.python.org/moin/PythonDecoratorLibrary#Retry
ExceptionToCheck: the exception t... | python | def retry(ExceptionToCheck, tries=4, delay=3, backoff=2, status_codes=[],
logger=None):
"""
Decorator function for retrying the decorated function,
using an exponential or fixed backoff.
Original: https://wiki.python.org/moin/PythonDecoratorLibrary#Retry
ExceptionToCheck: the exception t... | [
"def",
"retry",
"(",
"ExceptionToCheck",
",",
"tries",
"=",
"4",
",",
"delay",
"=",
"3",
",",
"backoff",
"=",
"2",
",",
"status_codes",
"=",
"[",
"]",
",",
"logger",
"=",
"None",
")",
":",
"if",
"backoff",
"is",
"None",
"or",
"backoff",
"<=",
"0",
... | Decorator function for retrying the decorated function,
using an exponential or fixed backoff.
Original: https://wiki.python.org/moin/PythonDecoratorLibrary#Retry
ExceptionToCheck: the exception to check. Can be a tuple of
exceptions to check
tries: number of times to try (not retry) before gi... | [
"Decorator",
"function",
"for",
"retrying",
"the",
"decorated",
"function",
"using",
"an",
"exponential",
"or",
"fixed",
"backoff",
"."
] | fda9380dceb6355ec6a3123e88c9ec66ae992682 | https://github.com/uw-it-aca/uw-restclients-core/blob/fda9380dceb6355ec6a3123e88c9ec66ae992682/restclients_core/util/retry.py#L6-L58 | train | Decorator function for retrying a function in a node tree. |
uw-it-aca/uw-restclients-core | restclients_core/dao.py | DAO._custom_response_edit | def _custom_response_edit(self, method, url, headers, body, response):
"""
This method allows a service to edit a response.
If you want to do this, you probably really want to use
_edit_mock_response - this method will operate on Live resources.
"""
if self.get_implement... | python | def _custom_response_edit(self, method, url, headers, body, response):
"""
This method allows a service to edit a response.
If you want to do this, you probably really want to use
_edit_mock_response - this method will operate on Live resources.
"""
if self.get_implement... | [
"def",
"_custom_response_edit",
"(",
"self",
",",
"method",
",",
"url",
",",
"headers",
",",
"body",
",",
"response",
")",
":",
"if",
"self",
".",
"get_implementation",
"(",
")",
".",
"is_mock",
"(",
")",
":",
"delay",
"=",
"self",
".",
"get_setting",
... | This method allows a service to edit a response.
If you want to do this, you probably really want to use
_edit_mock_response - this method will operate on Live resources. | [
"This",
"method",
"allows",
"a",
"service",
"to",
"edit",
"a",
"response",
"."
] | fda9380dceb6355ec6a3123e88c9ec66ae992682 | https://github.com/uw-it-aca/uw-restclients-core/blob/fda9380dceb6355ec6a3123e88c9ec66ae992682/restclients_core/dao.py#L64-L74 | train | This method allows a service to edit a response. |
uw-it-aca/uw-restclients-core | restclients_core/dao.py | DAO.postURL | def postURL(self, url, headers={}, body=None):
"""
Request a URL using the HTTP method POST.
"""
return self._load_resource("POST", url, headers, body) | python | def postURL(self, url, headers={}, body=None):
"""
Request a URL using the HTTP method POST.
"""
return self._load_resource("POST", url, headers, body) | [
"def",
"postURL",
"(",
"self",
",",
"url",
",",
"headers",
"=",
"{",
"}",
",",
"body",
"=",
"None",
")",
":",
"return",
"self",
".",
"_load_resource",
"(",
"\"POST\"",
",",
"url",
",",
"headers",
",",
"body",
")"
] | Request a URL using the HTTP method POST. | [
"Request",
"a",
"URL",
"using",
"the",
"HTTP",
"method",
"POST",
"."
] | fda9380dceb6355ec6a3123e88c9ec66ae992682 | https://github.com/uw-it-aca/uw-restclients-core/blob/fda9380dceb6355ec6a3123e88c9ec66ae992682/restclients_core/dao.py#L100-L104 | train | Request a URL using the HTTP method POST. |
uw-it-aca/uw-restclients-core | restclients_core/dao.py | DAO.putURL | def putURL(self, url, headers, body=None):
"""
Request a URL using the HTTP method PUT.
"""
return self._load_resource("PUT", url, headers, body) | python | def putURL(self, url, headers, body=None):
"""
Request a URL using the HTTP method PUT.
"""
return self._load_resource("PUT", url, headers, body) | [
"def",
"putURL",
"(",
"self",
",",
"url",
",",
"headers",
",",
"body",
"=",
"None",
")",
":",
"return",
"self",
".",
"_load_resource",
"(",
"\"PUT\"",
",",
"url",
",",
"headers",
",",
"body",
")"
] | Request a URL using the HTTP method PUT. | [
"Request",
"a",
"URL",
"using",
"the",
"HTTP",
"method",
"PUT",
"."
] | fda9380dceb6355ec6a3123e88c9ec66ae992682 | https://github.com/uw-it-aca/uw-restclients-core/blob/fda9380dceb6355ec6a3123e88c9ec66ae992682/restclients_core/dao.py#L106-L110 | train | Request a URL using the HTTP method PUT. |
uw-it-aca/uw-restclients-core | restclients_core/dao.py | DAO.patchURL | def patchURL(self, url, headers, body):
"""
Request a URL using the HTTP method PATCH.
"""
return self._load_resource("PATCH", url, headers, body) | python | def patchURL(self, url, headers, body):
"""
Request a URL using the HTTP method PATCH.
"""
return self._load_resource("PATCH", url, headers, body) | [
"def",
"patchURL",
"(",
"self",
",",
"url",
",",
"headers",
",",
"body",
")",
":",
"return",
"self",
".",
"_load_resource",
"(",
"\"PATCH\"",
",",
"url",
",",
"headers",
",",
"body",
")"
] | Request a URL using the HTTP method PATCH. | [
"Request",
"a",
"URL",
"using",
"the",
"HTTP",
"method",
"PATCH",
"."
] | fda9380dceb6355ec6a3123e88c9ec66ae992682 | https://github.com/uw-it-aca/uw-restclients-core/blob/fda9380dceb6355ec6a3123e88c9ec66ae992682/restclients_core/dao.py#L112-L116 | train | Request a URL using the HTTP method PATCH. |
uw-it-aca/uw-restclients-core | restclients_core/dao.py | LiveDAO.create_pool | def create_pool(self):
"""
Return a ConnectionPool instance of given host
:param socket_timeout:
socket timeout for each connection in seconds
"""
service = self.dao.service_name()
ca_certs = self.dao.get_setting("CA_BUNDLE",
... | python | def create_pool(self):
"""
Return a ConnectionPool instance of given host
:param socket_timeout:
socket timeout for each connection in seconds
"""
service = self.dao.service_name()
ca_certs = self.dao.get_setting("CA_BUNDLE",
... | [
"def",
"create_pool",
"(",
"self",
")",
":",
"service",
"=",
"self",
".",
"dao",
".",
"service_name",
"(",
")",
"ca_certs",
"=",
"self",
".",
"dao",
".",
"get_setting",
"(",
"\"CA_BUNDLE\"",
",",
"\"/etc/ssl/certs/ca-bundle.crt\"",
")",
"cert_file",
"=",
"se... | Return a ConnectionPool instance of given host
:param socket_timeout:
socket timeout for each connection in seconds | [
"Return",
"a",
"ConnectionPool",
"instance",
"of",
"given",
"host",
":",
"param",
"socket_timeout",
":",
"socket",
"timeout",
"for",
"each",
"connection",
"in",
"seconds"
] | fda9380dceb6355ec6a3123e88c9ec66ae992682 | https://github.com/uw-it-aca/uw-restclients-core/blob/fda9380dceb6355ec6a3123e88c9ec66ae992682/restclients_core/dao.py#L331-L370 | train | Create a ConnectionPool instance of given host. |
jpgxs/pyopsview | pyopsview/v2/client.py | Client._get_schema_loader | def _get_schema_loader(self, strict=False):
"""Gets a closure for schema.load_schema with the correct/current
Opsview version
"""
return functools.partial(schema.load_schema, version=self.version,
strict=strict) | python | def _get_schema_loader(self, strict=False):
"""Gets a closure for schema.load_schema with the correct/current
Opsview version
"""
return functools.partial(schema.load_schema, version=self.version,
strict=strict) | [
"def",
"_get_schema_loader",
"(",
"self",
",",
"strict",
"=",
"False",
")",
":",
"return",
"functools",
".",
"partial",
"(",
"schema",
".",
"load_schema",
",",
"version",
"=",
"self",
".",
"version",
",",
"strict",
"=",
"strict",
")"
] | Gets a closure for schema.load_schema with the correct/current
Opsview version | [
"Gets",
"a",
"closure",
"for",
"schema",
".",
"load_schema",
"with",
"the",
"correct",
"/",
"current",
"Opsview",
"version"
] | 5bbef35e463eda6dc67b0c34d3633a5a1c75a932 | https://github.com/jpgxs/pyopsview/blob/5bbef35e463eda6dc67b0c34d3633a5a1c75a932/pyopsview/v2/client.py#L57-L62 | train | Gets a closure for schema. load_schema with the correct version |
camptocamp/Studio | studio/config/environment.py | load_environment | def load_environment(global_conf, app_conf):
"""Configure the Pylons environment via the ``pylons.config``
object
"""
# Pylons paths
root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
paths = dict(root=root,
controllers=os.path.join(root, 'controllers'),
... | python | def load_environment(global_conf, app_conf):
"""Configure the Pylons environment via the ``pylons.config``
object
"""
# Pylons paths
root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
paths = dict(root=root,
controllers=os.path.join(root, 'controllers'),
... | [
"def",
"load_environment",
"(",
"global_conf",
",",
"app_conf",
")",
":",
"# Pylons paths",
"root",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"__file__",
")",
")",
")",
... | Configure the Pylons environment via the ``pylons.config``
object | [
"Configure",
"the",
"Pylons",
"environment",
"via",
"the",
"pylons",
".",
"config",
"object"
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/config/environment.py#L34-L75 | train | Configure the Pylons environment via the pylons. config object |
camptocamp/Studio | studio/config/routing.py | make_map | def make_map():
"""Create, configure and return the routes Mapper"""
map = Mapper(directory=config['pylons.paths']['controllers'],
always_scan=config['debug'], explicit=True)
map.minimization = False
# The ErrorController route (handles 404/500 error pages); it should
# likely ... | python | def make_map():
"""Create, configure and return the routes Mapper"""
map = Mapper(directory=config['pylons.paths']['controllers'],
always_scan=config['debug'], explicit=True)
map.minimization = False
# The ErrorController route (handles 404/500 error pages); it should
# likely ... | [
"def",
"make_map",
"(",
")",
":",
"map",
"=",
"Mapper",
"(",
"directory",
"=",
"config",
"[",
"'pylons.paths'",
"]",
"[",
"'controllers'",
"]",
",",
"always_scan",
"=",
"config",
"[",
"'debug'",
"]",
",",
"explicit",
"=",
"True",
")",
"map",
".",
"mini... | Create, configure and return the routes Mapper | [
"Create",
"configure",
"and",
"return",
"the",
"routes",
"Mapper"
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/config/routing.py#L29-L80 | train | Create and configure and return the routes Mapper |
mete0r/hypua2jamo | src/hypua2jamo/decoder.py | _uptrace | def _uptrace(nodelist, node):
'''
노드를 상향 추적한다.
현 노드로부터 조상 노드들을 차례로 순회하며 반환한다.
루트 노드는 제외한다.
'''
if node.parent_index is None:
return
parent = nodelist[node.parent_index]
for x in _uptrace(nodelist, parent):
yield x
yield node | python | def _uptrace(nodelist, node):
'''
노드를 상향 추적한다.
현 노드로부터 조상 노드들을 차례로 순회하며 반환한다.
루트 노드는 제외한다.
'''
if node.parent_index is None:
return
parent = nodelist[node.parent_index]
for x in _uptrace(nodelist, parent):
yield x
yield node | [
"def",
"_uptrace",
"(",
"nodelist",
",",
"node",
")",
":",
"if",
"node",
".",
"parent_index",
"is",
"None",
":",
"return",
"parent",
"=",
"nodelist",
"[",
"node",
".",
"parent_index",
"]",
"for",
"x",
"in",
"_uptrace",
"(",
"nodelist",
",",
"parent",
"... | 노드를 상향 추적한다.
현 노드로부터 조상 노드들을 차례로 순회하며 반환한다.
루트 노드는 제외한다. | [
"노드를",
"상향",
"추적한다",
"."
] | caceb33a26c27645703d659a82bb1152deef1469 | https://github.com/mete0r/hypua2jamo/blob/caceb33a26c27645703d659a82bb1152deef1469/src/hypua2jamo/decoder.py#L262-L275 | train | Yields the nodes that are not in the tree. |
cnschema/cdata | cdata/misc.py | main_subtask | def main_subtask(module_name, method_prefixs=["task_"], optional_params={}):
"""
http://stackoverflow.com/questions/3217673/why-use-argparse-rather-than-optparse
As of 2.7, optparse is deprecated, and will hopefully go away in the future
"""
parser = argparse.ArgumentParser(description="")
parse... | python | def main_subtask(module_name, method_prefixs=["task_"], optional_params={}):
"""
http://stackoverflow.com/questions/3217673/why-use-argparse-rather-than-optparse
As of 2.7, optparse is deprecated, and will hopefully go away in the future
"""
parser = argparse.ArgumentParser(description="")
parse... | [
"def",
"main_subtask",
"(",
"module_name",
",",
"method_prefixs",
"=",
"[",
"\"task_\"",
"]",
",",
"optional_params",
"=",
"{",
"}",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"\"",
")",
"parser",
".",
"add_argumen... | http://stackoverflow.com/questions/3217673/why-use-argparse-rather-than-optparse
As of 2.7, optparse is deprecated, and will hopefully go away in the future | [
"http",
":",
"//",
"stackoverflow",
".",
"com",
"/",
"questions",
"/",
"3217673",
"/",
"why",
"-",
"use",
"-",
"argparse",
"-",
"rather",
"-",
"than",
"-",
"optparse",
"As",
"of",
"2",
".",
"7",
"optparse",
"is",
"deprecated",
"and",
"will",
"hopefully... | 893e2e1e27b61c8551c8b5f5f9bf05ec61490e23 | https://github.com/cnschema/cdata/blob/893e2e1e27b61c8551c8b5f5f9bf05ec61490e23/cdata/misc.py#L24-L58 | train | Main function for the main task. |
mete0r/hypua2jamo | setup.py | setup_dir | def setup_dir(f):
''' Decorate f to run inside the directory where setup.py resides.
'''
setup_dir = os.path.dirname(os.path.abspath(__file__))
def wrapped(*args, **kwargs):
with chdir(setup_dir):
return f(*args, **kwargs)
return wrapped | python | def setup_dir(f):
''' Decorate f to run inside the directory where setup.py resides.
'''
setup_dir = os.path.dirname(os.path.abspath(__file__))
def wrapped(*args, **kwargs):
with chdir(setup_dir):
return f(*args, **kwargs)
return wrapped | [
"def",
"setup_dir",
"(",
"f",
")",
":",
"setup_dir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"__file__",
")",
")",
"def",
"wrapped",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"with",
"chdir"... | Decorate f to run inside the directory where setup.py resides. | [
"Decorate",
"f",
"to",
"run",
"inside",
"the",
"directory",
"where",
"setup",
".",
"py",
"resides",
"."
] | caceb33a26c27645703d659a82bb1152deef1469 | https://github.com/mete0r/hypua2jamo/blob/caceb33a26c27645703d659a82bb1152deef1469/setup.py#L33-L42 | train | Decorator to run inside the directory where setup. py resides. |
bitlabstudio/django-feedback-form | feedback_form/templatetags/feedback_tags.py | feedback_form | def feedback_form(context):
"""Template tag to render a feedback form."""
user = None
url = None
if context.get('request'):
url = context['request'].path
if context['request'].user.is_authenticated():
user = context['request'].user
return {
'form': FeedbackForm(ur... | python | def feedback_form(context):
"""Template tag to render a feedback form."""
user = None
url = None
if context.get('request'):
url = context['request'].path
if context['request'].user.is_authenticated():
user = context['request'].user
return {
'form': FeedbackForm(ur... | [
"def",
"feedback_form",
"(",
"context",
")",
":",
"user",
"=",
"None",
"url",
"=",
"None",
"if",
"context",
".",
"get",
"(",
"'request'",
")",
":",
"url",
"=",
"context",
"[",
"'request'",
"]",
".",
"path",
"if",
"context",
"[",
"'request'",
"]",
"."... | Template tag to render a feedback form. | [
"Template",
"tag",
"to",
"render",
"a",
"feedback",
"form",
"."
] | e3b5acbbde37caddab2da65f0fd5d7f3a8c8c597 | https://github.com/bitlabstudio/django-feedback-form/blob/e3b5acbbde37caddab2da65f0fd5d7f3a8c8c597/feedback_form/templatetags/feedback_tags.py#L11-L24 | train | Template tag to render a feedback form. |
nickelkr/yfi | yfi/yql.py | Yql.select | def select(self, *itms):
"""Joins the items to be selected and inserts the current table name"""
if not itms:
itms = ['*']
self.terms.append("select %s from %s" % (', '.join(itms), self.table))
return self | python | def select(self, *itms):
"""Joins the items to be selected and inserts the current table name"""
if not itms:
itms = ['*']
self.terms.append("select %s from %s" % (', '.join(itms), self.table))
return self | [
"def",
"select",
"(",
"self",
",",
"*",
"itms",
")",
":",
"if",
"not",
"itms",
":",
"itms",
"=",
"[",
"'*'",
"]",
"self",
".",
"terms",
".",
"append",
"(",
"\"select %s from %s\"",
"%",
"(",
"', '",
".",
"join",
"(",
"itms",
")",
",",
"self",
"."... | Joins the items to be selected and inserts the current table name | [
"Joins",
"the",
"items",
"to",
"be",
"selected",
"and",
"inserts",
"the",
"current",
"table",
"name"
] | 720773ea311abe01be83982f26a61ef744f9f648 | https://github.com/nickelkr/yfi/blob/720773ea311abe01be83982f26a61ef744f9f648/yfi/yql.py#L45-L50 | train | Joins the items to be selected and inserts the current table name |
nickelkr/yfi | yfi/yql.py | Yql._in | def _in(self, *lst):
"""Build out the in clause. Using _in due to shadowing for in"""
self.terms.append('in (%s)' % ', '.join(['"%s"' % x for x in lst]))
return self | python | def _in(self, *lst):
"""Build out the in clause. Using _in due to shadowing for in"""
self.terms.append('in (%s)' % ', '.join(['"%s"' % x for x in lst]))
return self | [
"def",
"_in",
"(",
"self",
",",
"*",
"lst",
")",
":",
"self",
".",
"terms",
".",
"append",
"(",
"'in (%s)'",
"%",
"', '",
".",
"join",
"(",
"[",
"'\"%s\"'",
"%",
"x",
"for",
"x",
"in",
"lst",
"]",
")",
")",
"return",
"self"
] | Build out the in clause. Using _in due to shadowing for in | [
"Build",
"out",
"the",
"in",
"clause",
".",
"Using",
"_in",
"due",
"to",
"shadowing",
"for",
"in"
] | 720773ea311abe01be83982f26a61ef744f9f648 | https://github.com/nickelkr/yfi/blob/720773ea311abe01be83982f26a61ef744f9f648/yfi/yql.py#L57-L60 | train | Build out the in clause. Using _in due to shadowing for in |
nickelkr/yfi | yfi/yql.py | Yql.compile | def compile(self):
"""Take all of the 'parts' components and build the complete query to be passed
to Yahoo YQL"""
cs = ""
for term in self.terms:
if cs:
cs += " "
cs += term
self.compiled_str = urllib.parse.quote(cs)
return self | python | def compile(self):
"""Take all of the 'parts' components and build the complete query to be passed
to Yahoo YQL"""
cs = ""
for term in self.terms:
if cs:
cs += " "
cs += term
self.compiled_str = urllib.parse.quote(cs)
return self | [
"def",
"compile",
"(",
"self",
")",
":",
"cs",
"=",
"\"\"",
"for",
"term",
"in",
"self",
".",
"terms",
":",
"if",
"cs",
":",
"cs",
"+=",
"\" \"",
"cs",
"+=",
"term",
"self",
".",
"compiled_str",
"=",
"urllib",
".",
"parse",
".",
"quote",
"(",
"cs... | Take all of the 'parts' components and build the complete query to be passed
to Yahoo YQL | [
"Take",
"all",
"of",
"the",
"parts",
"components",
"and",
"build",
"the",
"complete",
"query",
"to",
"be",
"passed",
"to",
"Yahoo",
"YQL"
] | 720773ea311abe01be83982f26a61ef744f9f648 | https://github.com/nickelkr/yfi/blob/720773ea311abe01be83982f26a61ef744f9f648/yfi/yql.py#L69-L78 | train | Compile the query to be passed to Yahoo YQL |
nickelkr/yfi | yfi/yql.py | Yql.run | def run(self):
"""Execute the query inside of self.compiled_str. This method returns a JSON
object for easy manipulation unless another format is specified"""
self.compile()
s = "%s&format=%s" % (self.compiled_str, self.format)
s = "%s%s&env=%s" % (self.endpoint, s, urllib.pa... | python | def run(self):
"""Execute the query inside of self.compiled_str. This method returns a JSON
object for easy manipulation unless another format is specified"""
self.compile()
s = "%s&format=%s" % (self.compiled_str, self.format)
s = "%s%s&env=%s" % (self.endpoint, s, urllib.pa... | [
"def",
"run",
"(",
"self",
")",
":",
"self",
".",
"compile",
"(",
")",
"s",
"=",
"\"%s&format=%s\"",
"%",
"(",
"self",
".",
"compiled_str",
",",
"self",
".",
"format",
")",
"s",
"=",
"\"%s%s&env=%s\"",
"%",
"(",
"self",
".",
"endpoint",
",",
"s",
"... | Execute the query inside of self.compiled_str. This method returns a JSON
object for easy manipulation unless another format is specified | [
"Execute",
"the",
"query",
"inside",
"of",
"self",
".",
"compiled_str",
".",
"This",
"method",
"returns",
"a",
"JSON",
"object",
"for",
"easy",
"manipulation",
"unless",
"another",
"format",
"is",
"specified"
] | 720773ea311abe01be83982f26a61ef744f9f648 | https://github.com/nickelkr/yfi/blob/720773ea311abe01be83982f26a61ef744f9f648/yfi/yql.py#L91-L105 | train | Execute the query inside of self. compiled_str. This method returns a JSON
object for easy manipulation unless another format is specified. |
MoseleyBioinformaticsLab/mwtab | mwtab/fileio.py | _generate_filenames | def _generate_filenames(sources):
"""Generate filenames.
:param tuple sources: Sequence of strings representing path to file(s).
:return: Path to file(s).
:rtype: :py:class:`str`
"""
for source in sources:
if os.path.isdir(source):
for path, dirlist, filelist in os.walk(sour... | python | def _generate_filenames(sources):
"""Generate filenames.
:param tuple sources: Sequence of strings representing path to file(s).
:return: Path to file(s).
:rtype: :py:class:`str`
"""
for source in sources:
if os.path.isdir(source):
for path, dirlist, filelist in os.walk(sour... | [
"def",
"_generate_filenames",
"(",
"sources",
")",
":",
"for",
"source",
"in",
"sources",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"source",
")",
":",
"for",
"path",
",",
"dirlist",
",",
"filelist",
"in",
"os",
".",
"walk",
"(",
"source",
")"... | Generate filenames.
:param tuple sources: Sequence of strings representing path to file(s).
:return: Path to file(s).
:rtype: :py:class:`str` | [
"Generate",
"filenames",
"."
] | 8c0ae8ab2aa621662f99589ed41e481cf8b7152b | https://github.com/MoseleyBioinformaticsLab/mwtab/blob/8c0ae8ab2aa621662f99589ed41e481cf8b7152b/mwtab/fileio.py#L43-L73 | train | Generate filenames. |
MoseleyBioinformaticsLab/mwtab | mwtab/fileio.py | _generate_handles | def _generate_handles(filenames):
"""Open a sequence of filenames one at time producing file objects.
The file is closed immediately when proceeding to the next iteration.
:param generator filenames: Generator object that yields the path to each file, one at a time.
:return: Filehandle to be processed ... | python | def _generate_handles(filenames):
"""Open a sequence of filenames one at time producing file objects.
The file is closed immediately when proceeding to the next iteration.
:param generator filenames: Generator object that yields the path to each file, one at a time.
:return: Filehandle to be processed ... | [
"def",
"_generate_handles",
"(",
"filenames",
")",
":",
"for",
"fname",
"in",
"filenames",
":",
"path",
"=",
"GenericFilePath",
"(",
"fname",
")",
"for",
"filehandle",
",",
"source",
"in",
"path",
".",
"open",
"(",
")",
":",
"yield",
"filehandle",
",",
"... | Open a sequence of filenames one at time producing file objects.
The file is closed immediately when proceeding to the next iteration.
:param generator filenames: Generator object that yields the path to each file, one at a time.
:return: Filehandle to be processed into an instance. | [
"Open",
"a",
"sequence",
"of",
"filenames",
"one",
"at",
"time",
"producing",
"file",
"objects",
".",
"The",
"file",
"is",
"closed",
"immediately",
"when",
"proceeding",
"to",
"the",
"next",
"iteration",
"."
] | 8c0ae8ab2aa621662f99589ed41e481cf8b7152b | https://github.com/MoseleyBioinformaticsLab/mwtab/blob/8c0ae8ab2aa621662f99589ed41e481cf8b7152b/mwtab/fileio.py#L76-L87 | train | Open a sequence of filenames one at a time producing file objects. |
MoseleyBioinformaticsLab/mwtab | mwtab/fileio.py | read_files | def read_files(*sources, **kwds):
"""Construct a generator that yields file instances.
:param sources: One or more strings representing path to file(s).
"""
filenames = _generate_filenames(sources)
filehandles = _generate_handles(filenames)
for fh, source in filehandles:
try:
... | python | def read_files(*sources, **kwds):
"""Construct a generator that yields file instances.
:param sources: One or more strings representing path to file(s).
"""
filenames = _generate_filenames(sources)
filehandles = _generate_handles(filenames)
for fh, source in filehandles:
try:
... | [
"def",
"read_files",
"(",
"*",
"sources",
",",
"*",
"*",
"kwds",
")",
":",
"filenames",
"=",
"_generate_filenames",
"(",
"sources",
")",
"filehandles",
"=",
"_generate_handles",
"(",
"filenames",
")",
"for",
"fh",
",",
"source",
"in",
"filehandles",
":",
"... | Construct a generator that yields file instances.
:param sources: One or more strings representing path to file(s). | [
"Construct",
"a",
"generator",
"that",
"yields",
"file",
"instances",
"."
] | 8c0ae8ab2aa621662f99589ed41e481cf8b7152b | https://github.com/MoseleyBioinformaticsLab/mwtab/blob/8c0ae8ab2aa621662f99589ed41e481cf8b7152b/mwtab/fileio.py#L90-L115 | train | Construct a generator that yields file instances. |
MoseleyBioinformaticsLab/mwtab | mwtab/fileio.py | GenericFilePath.open | def open(self):
"""Generator that opens and yields filehandles using appropriate facilities:
test if path represents a local file or file over URL, if file is compressed
or not.
:return: Filehandle to be processed into an instance.
"""
is_url = self.is_url(self.path)
... | python | def open(self):
"""Generator that opens and yields filehandles using appropriate facilities:
test if path represents a local file or file over URL, if file is compressed
or not.
:return: Filehandle to be processed into an instance.
"""
is_url = self.is_url(self.path)
... | [
"def",
"open",
"(",
"self",
")",
":",
"is_url",
"=",
"self",
".",
"is_url",
"(",
"self",
".",
"path",
")",
"compression_type",
"=",
"self",
".",
"is_compressed",
"(",
"self",
".",
"path",
")",
"if",
"not",
"compression_type",
":",
"if",
"is_url",
":",
... | Generator that opens and yields filehandles using appropriate facilities:
test if path represents a local file or file over URL, if file is compressed
or not.
:return: Filehandle to be processed into an instance. | [
"Generator",
"that",
"opens",
"and",
"yields",
"filehandles",
"using",
"appropriate",
"facilities",
":",
"test",
"if",
"path",
"represents",
"a",
"local",
"file",
"or",
"file",
"over",
"URL",
"if",
"file",
"is",
"compressed",
"or",
"not",
"."
] | 8c0ae8ab2aa621662f99589ed41e481cf8b7152b | https://github.com/MoseleyBioinformaticsLab/mwtab/blob/8c0ae8ab2aa621662f99589ed41e481cf8b7152b/mwtab/fileio.py#L128-L183 | train | Generator that opens and yields filehandles using appropriate facilities. |
MoseleyBioinformaticsLab/mwtab | mwtab/fileio.py | GenericFilePath.is_compressed | def is_compressed(path):
"""Test if path represents compressed file(s).
:param str path: Path to file(s).
:return: String specifying compression type if compressed, "" otherwise.
:rtype: :py:class:`str`
"""
if path.endswith(".zip"):
return "zip"
elif ... | python | def is_compressed(path):
"""Test if path represents compressed file(s).
:param str path: Path to file(s).
:return: String specifying compression type if compressed, "" otherwise.
:rtype: :py:class:`str`
"""
if path.endswith(".zip"):
return "zip"
elif ... | [
"def",
"is_compressed",
"(",
"path",
")",
":",
"if",
"path",
".",
"endswith",
"(",
"\".zip\"",
")",
":",
"return",
"\"zip\"",
"elif",
"path",
".",
"endswith",
"(",
"\".tar.gz\"",
")",
":",
"return",
"\"tar.gz\"",
"elif",
"path",
".",
"endswith",
"(",
"\"... | Test if path represents compressed file(s).
:param str path: Path to file(s).
:return: String specifying compression type if compressed, "" otherwise.
:rtype: :py:class:`str` | [
"Test",
"if",
"path",
"represents",
"compressed",
"file",
"(",
"s",
")",
"."
] | 8c0ae8ab2aa621662f99589ed41e481cf8b7152b | https://github.com/MoseleyBioinformaticsLab/mwtab/blob/8c0ae8ab2aa621662f99589ed41e481cf8b7152b/mwtab/fileio.py#L186-L205 | train | Test if path represents compressed file. |
MoseleyBioinformaticsLab/mwtab | mwtab/fileio.py | GenericFilePath.is_url | def is_url(path):
"""Test if path represents a valid URL.
:param str path: Path to file.
:return: True if path is valid url string, False otherwise.
:rtype: :py:obj:`True` or :py:obj:`False`
"""
try:
parse_result = urlparse(path)
return all((parse... | python | def is_url(path):
"""Test if path represents a valid URL.
:param str path: Path to file.
:return: True if path is valid url string, False otherwise.
:rtype: :py:obj:`True` or :py:obj:`False`
"""
try:
parse_result = urlparse(path)
return all((parse... | [
"def",
"is_url",
"(",
"path",
")",
":",
"try",
":",
"parse_result",
"=",
"urlparse",
"(",
"path",
")",
"return",
"all",
"(",
"(",
"parse_result",
".",
"scheme",
",",
"parse_result",
".",
"netloc",
",",
"parse_result",
".",
"path",
")",
")",
"except",
"... | Test if path represents a valid URL.
:param str path: Path to file.
:return: True if path is valid url string, False otherwise.
:rtype: :py:obj:`True` or :py:obj:`False` | [
"Test",
"if",
"path",
"represents",
"a",
"valid",
"URL",
"."
] | 8c0ae8ab2aa621662f99589ed41e481cf8b7152b | https://github.com/MoseleyBioinformaticsLab/mwtab/blob/8c0ae8ab2aa621662f99589ed41e481cf8b7152b/mwtab/fileio.py#L208-L219 | train | Test if path represents a valid url string. |
camptocamp/Studio | studio/lib/auth.py | AuthMiddleware | def AuthMiddleware(app):
"""
Add authentication and authorization middleware to the ``app``.
"""
# url_for mustn't be used here because AuthMiddleware is built once at startup,
# url path can be reconstructed only on http requests (based on environ)
basic_redirect_form = BasicRedirectFormPlugin(... | python | def AuthMiddleware(app):
"""
Add authentication and authorization middleware to the ``app``.
"""
# url_for mustn't be used here because AuthMiddleware is built once at startup,
# url path can be reconstructed only on http requests (based on environ)
basic_redirect_form = BasicRedirectFormPlugin(... | [
"def",
"AuthMiddleware",
"(",
"app",
")",
":",
"# url_for mustn't be used here because AuthMiddleware is built once at startup,",
"# url path can be reconstructed only on http requests (based on environ)",
"basic_redirect_form",
"=",
"BasicRedirectFormPlugin",
"(",
"login_form_url",
"=",
... | Add authentication and authorization middleware to the ``app``. | [
"Add",
"authentication",
"and",
"authorization",
"middleware",
"to",
"the",
"app",
"."
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/lib/auth.py#L154-L183 | train | Add authentication and authorization middleware to the app. |
camptocamp/Studio | studio/lib/auth.py | BasicRedirectFormPlugin._get_full_path | def _get_full_path(self, path, environ):
"""
Return the full path to ``path`` by prepending the SCRIPT_NAME.
If ``path`` is a URL, do nothing.
"""
if path.startswith('/'):
path = environ.get('SCRIPT_NAME', '') + path
return path | python | def _get_full_path(self, path, environ):
"""
Return the full path to ``path`` by prepending the SCRIPT_NAME.
If ``path`` is a URL, do nothing.
"""
if path.startswith('/'):
path = environ.get('SCRIPT_NAME', '') + path
return path | [
"def",
"_get_full_path",
"(",
"self",
",",
"path",
",",
"environ",
")",
":",
"if",
"path",
".",
"startswith",
"(",
"'/'",
")",
":",
"path",
"=",
"environ",
".",
"get",
"(",
"'SCRIPT_NAME'",
",",
"''",
")",
"+",
"path",
"return",
"path"
] | Return the full path to ``path`` by prepending the SCRIPT_NAME.
If ``path`` is a URL, do nothing. | [
"Return",
"the",
"full",
"path",
"to",
"path",
"by",
"prepending",
"the",
"SCRIPT_NAME",
".",
"If",
"path",
"is",
"a",
"URL",
"do",
"nothing",
"."
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/lib/auth.py#L130-L139 | train | Return the full path to the given path. |
camptocamp/Studio | studio/lib/auth.py | BasicRedirectFormPlugin._replace_qs | def _replace_qs(self, url, qs):
"""
Replace the query string of ``url`` with ``qs`` and return the new URL.
"""
url_parts = list(urlparse(url))
url_parts[4] = qs
return urlunparse(url_parts) | python | def _replace_qs(self, url, qs):
"""
Replace the query string of ``url`` with ``qs`` and return the new URL.
"""
url_parts = list(urlparse(url))
url_parts[4] = qs
return urlunparse(url_parts) | [
"def",
"_replace_qs",
"(",
"self",
",",
"url",
",",
"qs",
")",
":",
"url_parts",
"=",
"list",
"(",
"urlparse",
"(",
"url",
")",
")",
"url_parts",
"[",
"4",
"]",
"=",
"qs",
"return",
"urlunparse",
"(",
"url_parts",
")"
] | Replace the query string of ``url`` with ``qs`` and return the new URL. | [
"Replace",
"the",
"query",
"string",
"of",
"url",
"with",
"qs",
"and",
"return",
"the",
"new",
"URL",
"."
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/lib/auth.py#L141-L148 | train | Replace the query string of url with qs and return the new URL. |
prezi/django-zipkin | django_zipkin/_thrift/zipkinCollector/ZipkinCollector.py | Client.storeTopAnnotations | def storeTopAnnotations(self, service_name, annotations):
"""
Aggregates methods
Parameters:
- service_name
- annotations
"""
self.send_storeTopAnnotations(service_name, annotations)
self.recv_storeTopAnnotations() | python | def storeTopAnnotations(self, service_name, annotations):
"""
Aggregates methods
Parameters:
- service_name
- annotations
"""
self.send_storeTopAnnotations(service_name, annotations)
self.recv_storeTopAnnotations() | [
"def",
"storeTopAnnotations",
"(",
"self",
",",
"service_name",
",",
"annotations",
")",
":",
"self",
".",
"send_storeTopAnnotations",
"(",
"service_name",
",",
"annotations",
")",
"self",
".",
"recv_storeTopAnnotations",
"(",
")"
] | Aggregates methods
Parameters:
- service_name
- annotations | [
"Aggregates",
"methods"
] | 158d04cf9c2fe0adcb4cda66a250d9e41eae33f3 | https://github.com/prezi/django-zipkin/blob/158d04cf9c2fe0adcb4cda66a250d9e41eae33f3/django_zipkin/_thrift/zipkinCollector/ZipkinCollector.py#L52-L61 | train | Stores the given annotations for the specified service. |
prezi/django-zipkin | django_zipkin/_thrift/zipkinCollector/ZipkinCollector.py | Client.storeTopKeyValueAnnotations | def storeTopKeyValueAnnotations(self, service_name, annotations):
"""
Parameters:
- service_name
- annotations
"""
self.send_storeTopKeyValueAnnotations(service_name, annotations)
self.recv_storeTopKeyValueAnnotations() | python | def storeTopKeyValueAnnotations(self, service_name, annotations):
"""
Parameters:
- service_name
- annotations
"""
self.send_storeTopKeyValueAnnotations(service_name, annotations)
self.recv_storeTopKeyValueAnnotations() | [
"def",
"storeTopKeyValueAnnotations",
"(",
"self",
",",
"service_name",
",",
"annotations",
")",
":",
"self",
".",
"send_storeTopKeyValueAnnotations",
"(",
"service_name",
",",
"annotations",
")",
"self",
".",
"recv_storeTopKeyValueAnnotations",
"(",
")"
] | Parameters:
- service_name
- annotations | [
"Parameters",
":",
"-",
"service_name",
"-",
"annotations"
] | 158d04cf9c2fe0adcb4cda66a250d9e41eae33f3 | https://github.com/prezi/django-zipkin/blob/158d04cf9c2fe0adcb4cda66a250d9e41eae33f3/django_zipkin/_thrift/zipkinCollector/ZipkinCollector.py#L86-L93 | train | Stores the given annotations in the specified service. |
pjamesjoyce/lcopt | lcopt/settings.py | LcoptSettings.write | def write(self):
"""write the current settings to the config file"""
with open(storage.config_file, 'w') as cfg:
yaml.dump(self.as_dict(), cfg, default_flow_style=False)
storage.refresh() | python | def write(self):
"""write the current settings to the config file"""
with open(storage.config_file, 'w') as cfg:
yaml.dump(self.as_dict(), cfg, default_flow_style=False)
storage.refresh() | [
"def",
"write",
"(",
"self",
")",
":",
"with",
"open",
"(",
"storage",
".",
"config_file",
",",
"'w'",
")",
"as",
"cfg",
":",
"yaml",
".",
"dump",
"(",
"self",
".",
"as_dict",
"(",
")",
",",
"cfg",
",",
"default_flow_style",
"=",
"False",
")",
"sto... | write the current settings to the config file | [
"write",
"the",
"current",
"settings",
"to",
"the",
"config",
"file"
] | 3f1caca31fece4a3068a384900707e6d21d04597 | https://github.com/pjamesjoyce/lcopt/blob/3f1caca31fece4a3068a384900707e6d21d04597/lcopt/settings.py#L98-L103 | train | write the current settings to the config file |
camsaul/django-rest-params | django_rest_params/decorators.py | params | def params(**kwargs):
"""
Request fn decorator that builds up a list of params and automatically returns a 400 if they are invalid.
The validated params are passed to the wrapped function as kwargs.
"""
# Types that we'll all for as 'tuple' params
TUPLE_TYPES = tuple, set, frozenset, li... | python | def params(**kwargs):
"""
Request fn decorator that builds up a list of params and automatically returns a 400 if they are invalid.
The validated params are passed to the wrapped function as kwargs.
"""
# Types that we'll all for as 'tuple' params
TUPLE_TYPES = tuple, set, frozenset, li... | [
"def",
"params",
"(",
"*",
"*",
"kwargs",
")",
":",
"# Types that we'll all for as 'tuple' params",
"TUPLE_TYPES",
"=",
"tuple",
",",
"set",
",",
"frozenset",
",",
"list",
"if",
"(",
"sys",
".",
"version_info",
">",
"(",
"3",
",",
"0",
")",
")",
":",
"VA... | Request fn decorator that builds up a list of params and automatically returns a 400 if they are invalid.
The validated params are passed to the wrapped function as kwargs. | [
"Request",
"fn",
"decorator",
"that",
"builds",
"up",
"a",
"list",
"of",
"params",
"and",
"automatically",
"returns",
"a",
"400",
"if",
"they",
"are",
"invalid",
".",
"The",
"validated",
"params",
"are",
"passed",
"to",
"the",
"wrapped",
"function",
"as",
... | afda9709481760e9d1044ebed9446b78c108acad | https://github.com/camsaul/django-rest-params/blob/afda9709481760e9d1044ebed9446b78c108acad/django_rest_params/decorators.py#L13-L242 | train | Request fn decorator that builds up a list of params and automatically returns a 400 if they are invalid. |
torre76/gd_shortener | gdshortener/gdshortener.py | GDBaseShortener.lookup | def lookup(self, short_url):
'''
Lookup an URL shortened with `is.gd - v.gd url service <http://is.gd/developers.php>`_ and return the real url
:param short_url: the url shortened with .gd service
:type short_url: str.
:returns: str. -- T... | python | def lookup(self, short_url):
'''
Lookup an URL shortened with `is.gd - v.gd url service <http://is.gd/developers.php>`_ and return the real url
:param short_url: the url shortened with .gd service
:type short_url: str.
:returns: str. -- T... | [
"def",
"lookup",
"(",
"self",
",",
"short_url",
")",
":",
"if",
"short_url",
"is",
"None",
"or",
"not",
"isinstance",
"(",
"short_url",
",",
"basestring",
")",
"or",
"len",
"(",
"short_url",
".",
"strip",
"(",
")",
")",
"==",
"0",
":",
"raise",
"GDMa... | Lookup an URL shortened with `is.gd - v.gd url service <http://is.gd/developers.php>`_ and return the real url
:param short_url: the url shortened with .gd service
:type short_url: str.
:returns: str. -- The original url that was shortened with .gd service
... | [
"Lookup",
"an",
"URL",
"shortened",
"with",
"is",
".",
"gd",
"-",
"v",
".",
"gd",
"url",
"service",
"<http",
":",
"//",
"is",
".",
"gd",
"/",
"developers",
".",
"php",
">",
"_",
"and",
"return",
"the",
"real",
"url",
":",
"param",
"short_url",
":",... | a34becf15512e6193960c93edad6258928705bfa | https://github.com/torre76/gd_shortener/blob/a34becf15512e6193960c93edad6258928705bfa/gdshortener/gdshortener.py#L161-L208 | train | This method will attempt to lookup an url shortened with is. gd - v. gd url service <http://is. gd - v. gd url service <http://is. gd - v. gd url service <http://is. gd - v. gd url service <http://is. gd - v. gd url service <http://is. gd - v. gd url service <http://is. gd - v. gd url service <http://is. gd |
torre76/gd_shortener | gdshortener/gdshortener.py | GDBaseShortener.shorten | def shorten(self, url, custom_url = None, log_stat = False):
'''
Shorten an URL using `is.gd - v.gd url shortener service <http://is.gd/developers.php>`_.
:param url: URL that had to be shortened
:type url: str.
:param custom_url: if spec... | python | def shorten(self, url, custom_url = None, log_stat = False):
'''
Shorten an URL using `is.gd - v.gd url shortener service <http://is.gd/developers.php>`_.
:param url: URL that had to be shortened
:type url: str.
:param custom_url: if spec... | [
"def",
"shorten",
"(",
"self",
",",
"url",
",",
"custom_url",
"=",
"None",
",",
"log_stat",
"=",
"False",
")",
":",
"if",
"url",
"is",
"None",
"or",
"not",
"isinstance",
"(",
"url",
",",
"basestring",
")",
"or",
"len",
"(",
"url",
".",
"strip",
"("... | Shorten an URL using `is.gd - v.gd url shortener service <http://is.gd/developers.php>`_.
:param url: URL that had to be shortened
:type url: str.
:param custom_url: if specified, the url generated will be http://is.gd/<custom_url> (or http://v.gd/<custom_ur... | [
"Shorten",
"an",
"URL",
"using",
"is",
".",
"gd",
"-",
"v",
".",
"gd",
"url",
"shortener",
"service",
"<http",
":",
"//",
"is",
".",
"gd",
"/",
"developers",
".",
"php",
">",
"_",
".",
":",
"param",
"url",
":",
"URL",
"that",
"had",
"to",
"be",
... | a34becf15512e6193960c93edad6258928705bfa | https://github.com/torre76/gd_shortener/blob/a34becf15512e6193960c93edad6258928705bfa/gdshortener/gdshortener.py#L211-L273 | train | Shorten an url using is. gd - url shortener service. |
camptocamp/Studio | studio/lib/sa_types.py | JsonString.process_bind_param | def process_bind_param(self, value, dialect):
"""convert value from python object to json"""
if value is not None:
value = simplejson.dumps(value)
return value | python | def process_bind_param(self, value, dialect):
"""convert value from python object to json"""
if value is not None:
value = simplejson.dumps(value)
return value | [
"def",
"process_bind_param",
"(",
"self",
",",
"value",
",",
"dialect",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"value",
"=",
"simplejson",
".",
"dumps",
"(",
"value",
")",
"return",
"value"
] | convert value from python object to json | [
"convert",
"value",
"from",
"python",
"object",
"to",
"json"
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/lib/sa_types.py#L26-L30 | train | convert value from python object to json |
camptocamp/Studio | studio/lib/sa_types.py | JsonString.process_result_value | def process_result_value(self, value, dialect):
"""convert value from json to a python object"""
if value is not None:
value = simplejson.loads(value)
return value | python | def process_result_value(self, value, dialect):
"""convert value from json to a python object"""
if value is not None:
value = simplejson.loads(value)
return value | [
"def",
"process_result_value",
"(",
"self",
",",
"value",
",",
"dialect",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"value",
"=",
"simplejson",
".",
"loads",
"(",
"value",
")",
"return",
"value"
] | convert value from json to a python object | [
"convert",
"value",
"from",
"json",
"to",
"a",
"python",
"object"
] | 43cb7298434fb606b15136801b79b03571a2f27e | https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/lib/sa_types.py#L32-L36 | train | convert value from json to python object |
SergeySatskiy/cdm-pythonparser | cdmpyparser.py | trim_docstring | def trim_docstring(docstring):
"""Taken from http://www.python.org/dev/peps/pep-0257/"""
if not docstring:
return ''
# Convert tabs to spaces (following the normal Python rules)
# and split into a list of lines:
lines = docstring.expandtabs().splitlines()
# Determine minimum indentatio... | python | def trim_docstring(docstring):
"""Taken from http://www.python.org/dev/peps/pep-0257/"""
if not docstring:
return ''
# Convert tabs to spaces (following the normal Python rules)
# and split into a list of lines:
lines = docstring.expandtabs().splitlines()
# Determine minimum indentatio... | [
"def",
"trim_docstring",
"(",
"docstring",
")",
":",
"if",
"not",
"docstring",
":",
"return",
"''",
"# Convert tabs to spaces (following the normal Python rules)",
"# and split into a list of lines:",
"lines",
"=",
"docstring",
".",
"expandtabs",
"(",
")",
".",
"splitline... | Taken from http://www.python.org/dev/peps/pep-0257/ | [
"Taken",
"from",
"http",
":",
"//",
"www",
".",
"python",
".",
"org",
"/",
"dev",
"/",
"peps",
"/",
"pep",
"-",
"0257",
"/"
] | 7e933aca899b1853d744082313ffc3a8b1154505 | https://github.com/SergeySatskiy/cdm-pythonparser/blob/7e933aca899b1853d744082313ffc3a8b1154505/cdmpyparser.py#L26-L57 | train | Removes leading and trailing blank lines from a docstring. |
SergeySatskiy/cdm-pythonparser | cdmpyparser.py | getBriefModuleInfoFromFile | def getBriefModuleInfoFromFile(fileName):
"""Builds the brief module info from file"""
modInfo = BriefModuleInfo()
_cdmpyparser.getBriefModuleInfoFromFile(modInfo, fileName)
modInfo.flush()
return modInfo | python | def getBriefModuleInfoFromFile(fileName):
"""Builds the brief module info from file"""
modInfo = BriefModuleInfo()
_cdmpyparser.getBriefModuleInfoFromFile(modInfo, fileName)
modInfo.flush()
return modInfo | [
"def",
"getBriefModuleInfoFromFile",
"(",
"fileName",
")",
":",
"modInfo",
"=",
"BriefModuleInfo",
"(",
")",
"_cdmpyparser",
".",
"getBriefModuleInfoFromFile",
"(",
"modInfo",
",",
"fileName",
")",
"modInfo",
".",
"flush",
"(",
")",
"return",
"modInfo"
] | Builds the brief module info from file | [
"Builds",
"the",
"brief",
"module",
"info",
"from",
"file"
] | 7e933aca899b1853d744082313ffc3a8b1154505 | https://github.com/SergeySatskiy/cdm-pythonparser/blob/7e933aca899b1853d744082313ffc3a8b1154505/cdmpyparser.py#L609-L614 | train | Builds the brief module info from a file |
SergeySatskiy/cdm-pythonparser | cdmpyparser.py | getBriefModuleInfoFromMemory | def getBriefModuleInfoFromMemory(content):
"""Builds the brief module info from memory"""
modInfo = BriefModuleInfo()
_cdmpyparser.getBriefModuleInfoFromMemory(modInfo, content)
modInfo.flush()
return modInfo | python | def getBriefModuleInfoFromMemory(content):
"""Builds the brief module info from memory"""
modInfo = BriefModuleInfo()
_cdmpyparser.getBriefModuleInfoFromMemory(modInfo, content)
modInfo.flush()
return modInfo | [
"def",
"getBriefModuleInfoFromMemory",
"(",
"content",
")",
":",
"modInfo",
"=",
"BriefModuleInfo",
"(",
")",
"_cdmpyparser",
".",
"getBriefModuleInfoFromMemory",
"(",
"modInfo",
",",
"content",
")",
"modInfo",
".",
"flush",
"(",
")",
"return",
"modInfo"
] | Builds the brief module info from memory | [
"Builds",
"the",
"brief",
"module",
"info",
"from",
"memory"
] | 7e933aca899b1853d744082313ffc3a8b1154505 | https://github.com/SergeySatskiy/cdm-pythonparser/blob/7e933aca899b1853d744082313ffc3a8b1154505/cdmpyparser.py#L617-L622 | train | Builds the brief module info from memory |
SergeySatskiy/cdm-pythonparser | cdmpyparser.py | ImportWhat.getDisplayName | def getDisplayName(self):
"""Provides a name for display purpose respecting the alias"""
if self.alias == "":
return self.name
return self.name + " as " + self.alias | python | def getDisplayName(self):
"""Provides a name for display purpose respecting the alias"""
if self.alias == "":
return self.name
return self.name + " as " + self.alias | [
"def",
"getDisplayName",
"(",
"self",
")",
":",
"if",
"self",
".",
"alias",
"==",
"\"\"",
":",
"return",
"self",
".",
"name",
"return",
"self",
".",
"name",
"+",
"\" as \"",
"+",
"self",
".",
"alias"
] | Provides a name for display purpose respecting the alias | [
"Provides",
"a",
"name",
"for",
"display",
"purpose",
"respecting",
"the",
"alias"
] | 7e933aca899b1853d744082313ffc3a8b1154505 | https://github.com/SergeySatskiy/cdm-pythonparser/blob/7e933aca899b1853d744082313ffc3a8b1154505/cdmpyparser.py#L124-L128 | train | Provides a name for display purpose respecting the alias |
SergeySatskiy/cdm-pythonparser | cdmpyparser.py | Decorator.getDisplayName | def getDisplayName(self):
"""Provides a name for display purpose"""
displayName = self.name
if self.arguments:
displayName += "(" + ", ".join(self.arguments) + ")"
return displayName | python | def getDisplayName(self):
"""Provides a name for display purpose"""
displayName = self.name
if self.arguments:
displayName += "(" + ", ".join(self.arguments) + ")"
return displayName | [
"def",
"getDisplayName",
"(",
"self",
")",
":",
"displayName",
"=",
"self",
".",
"name",
"if",
"self",
".",
"arguments",
":",
"displayName",
"+=",
"\"(\"",
"+",
"\", \"",
".",
"join",
"(",
"self",
".",
"arguments",
")",
"+",
"\")\"",
"return",
"displayNa... | Provides a name for display purpose | [
"Provides",
"a",
"name",
"for",
"display",
"purpose"
] | 7e933aca899b1853d744082313ffc3a8b1154505 | https://github.com/SergeySatskiy/cdm-pythonparser/blob/7e933aca899b1853d744082313ffc3a8b1154505/cdmpyparser.py#L223-L228 | train | Provides a name for display purpose |
SergeySatskiy/cdm-pythonparser | cdmpyparser.py | Function.niceStringify | def niceStringify(self, level):
"""Returns a string representation with new lines and shifts"""
out = level * " " + \
"Function[" + str(self.keywordLine) + \
":" + str(self.keywordPos) + \
":" + self._getLPA() + \
":" + str(self.colonLine) + \
... | python | def niceStringify(self, level):
"""Returns a string representation with new lines and shifts"""
out = level * " " + \
"Function[" + str(self.keywordLine) + \
":" + str(self.keywordPos) + \
":" + self._getLPA() + \
":" + str(self.colonLine) + \
... | [
"def",
"niceStringify",
"(",
"self",
",",
"level",
")",
":",
"out",
"=",
"level",
"*",
"\" \"",
"+",
"\"Function[\"",
"+",
"str",
"(",
"self",
".",
"keywordLine",
")",
"+",
"\":\"",
"+",
"str",
"(",
"self",
".",
"keywordPos",
")",
"+",
"\":\"",
"+... | Returns a string representation with new lines and shifts | [
"Returns",
"a",
"string",
"representation",
"with",
"new",
"lines",
"and",
"shifts"
] | 7e933aca899b1853d744082313ffc3a8b1154505 | https://github.com/SergeySatskiy/cdm-pythonparser/blob/7e933aca899b1853d744082313ffc3a8b1154505/cdmpyparser.py#L301-L324 | train | Returns a string representation of the current object with new lines and shifts |
SergeySatskiy/cdm-pythonparser | cdmpyparser.py | Function.getDisplayName | def getDisplayName(self):
"""Provides a name for display purpose"""
displayName = self.name + "("
if self.isAsync:
displayName = "async " + displayName
first = True
for arg in self.arguments:
if first:
displayName += str(arg)
... | python | def getDisplayName(self):
"""Provides a name for display purpose"""
displayName = self.name + "("
if self.isAsync:
displayName = "async " + displayName
first = True
for arg in self.arguments:
if first:
displayName += str(arg)
... | [
"def",
"getDisplayName",
"(",
"self",
")",
":",
"displayName",
"=",
"self",
".",
"name",
"+",
"\"(\"",
"if",
"self",
".",
"isAsync",
":",
"displayName",
"=",
"\"async \"",
"+",
"displayName",
"first",
"=",
"True",
"for",
"arg",
"in",
"self",
".",
"argume... | Provides a name for display purpose | [
"Provides",
"a",
"name",
"for",
"display",
"purpose"
] | 7e933aca899b1853d744082313ffc3a8b1154505 | https://github.com/SergeySatskiy/cdm-pythonparser/blob/7e933aca899b1853d744082313ffc3a8b1154505/cdmpyparser.py#L326-L341 | train | Provides a name for display purpose |
SergeySatskiy/cdm-pythonparser | cdmpyparser.py | BriefModuleInfo.flush | def flush(self):
"""Flushes the collected information"""
self.__flushLevel(0)
if self.__lastImport is not None:
self.imports.append(self.__lastImport) | python | def flush(self):
"""Flushes the collected information"""
self.__flushLevel(0)
if self.__lastImport is not None:
self.imports.append(self.__lastImport) | [
"def",
"flush",
"(",
"self",
")",
":",
"self",
".",
"__flushLevel",
"(",
"0",
")",
"if",
"self",
".",
"__lastImport",
"is",
"not",
"None",
":",
"self",
".",
"imports",
".",
"append",
"(",
"self",
".",
"__lastImport",
")"
] | Flushes the collected information | [
"Flushes",
"the",
"collected",
"information"
] | 7e933aca899b1853d744082313ffc3a8b1154505 | https://github.com/SergeySatskiy/cdm-pythonparser/blob/7e933aca899b1853d744082313ffc3a8b1154505/cdmpyparser.py#L456-L460 | train | Flushes the collected information |
SergeySatskiy/cdm-pythonparser | cdmpyparser.py | BriefModuleInfo.__flushLevel | def __flushLevel(self, level):
"""Merge the found objects to the required level"""
objectsCount = len(self.objectsStack)
while objectsCount > level:
lastIndex = objectsCount - 1
if lastIndex == 0:
# We have exactly one element in the stack
... | python | def __flushLevel(self, level):
"""Merge the found objects to the required level"""
objectsCount = len(self.objectsStack)
while objectsCount > level:
lastIndex = objectsCount - 1
if lastIndex == 0:
# We have exactly one element in the stack
... | [
"def",
"__flushLevel",
"(",
"self",
",",
"level",
")",
":",
"objectsCount",
"=",
"len",
"(",
"self",
".",
"objectsStack",
")",
"while",
"objectsCount",
">",
"level",
":",
"lastIndex",
"=",
"objectsCount",
"-",
"1",
"if",
"lastIndex",
"==",
"0",
":",
"# W... | Merge the found objects to the required level | [
"Merge",
"the",
"found",
"objects",
"to",
"the",
"required",
"level"
] | 7e933aca899b1853d744082313ffc3a8b1154505 | https://github.com/SergeySatskiy/cdm-pythonparser/blob/7e933aca899b1853d744082313ffc3a8b1154505/cdmpyparser.py#L462-L486 | train | Merge the found objects to the required level |
SergeySatskiy/cdm-pythonparser | cdmpyparser.py | BriefModuleInfo._onEncoding | def _onEncoding(self, encString, line, pos, absPosition):
"""Memorizes module encoding"""
self.encoding = Encoding(encString, line, pos, absPosition) | python | def _onEncoding(self, encString, line, pos, absPosition):
"""Memorizes module encoding"""
self.encoding = Encoding(encString, line, pos, absPosition) | [
"def",
"_onEncoding",
"(",
"self",
",",
"encString",
",",
"line",
",",
"pos",
",",
"absPosition",
")",
":",
"self",
".",
"encoding",
"=",
"Encoding",
"(",
"encString",
",",
"line",
",",
"pos",
",",
"absPosition",
")"
] | Memorizes module encoding | [
"Memorizes",
"module",
"encoding"
] | 7e933aca899b1853d744082313ffc3a8b1154505 | https://github.com/SergeySatskiy/cdm-pythonparser/blob/7e933aca899b1853d744082313ffc3a8b1154505/cdmpyparser.py#L488-L490 | train | Memorizes module encoding |
SergeySatskiy/cdm-pythonparser | cdmpyparser.py | BriefModuleInfo._onGlobal | def _onGlobal(self, name, line, pos, absPosition, level):
"""Memorizes a global variable"""
# level is ignored
for item in self.globals:
if item.name == name:
return
self.globals.append(Global(name, line, pos, absPosition)) | python | def _onGlobal(self, name, line, pos, absPosition, level):
"""Memorizes a global variable"""
# level is ignored
for item in self.globals:
if item.name == name:
return
self.globals.append(Global(name, line, pos, absPosition)) | [
"def",
"_onGlobal",
"(",
"self",
",",
"name",
",",
"line",
",",
"pos",
",",
"absPosition",
",",
"level",
")",
":",
"# level is ignored",
"for",
"item",
"in",
"self",
".",
"globals",
":",
"if",
"item",
".",
"name",
"==",
"name",
":",
"return",
"self",
... | Memorizes a global variable | [
"Memorizes",
"a",
"global",
"variable"
] | 7e933aca899b1853d744082313ffc3a8b1154505 | https://github.com/SergeySatskiy/cdm-pythonparser/blob/7e933aca899b1853d744082313ffc3a8b1154505/cdmpyparser.py#L492-L498 | train | Memorizes a global variable |
SergeySatskiy/cdm-pythonparser | cdmpyparser.py | BriefModuleInfo._onClass | def _onClass(self, name, line, pos, absPosition,
keywordLine, keywordPos,
colonLine, colonPos, level):
"""Memorizes a class"""
self.__flushLevel(level)
c = Class(name, line, pos, absPosition, keywordLine, keywordPos,
colonLine, colonPos)
... | python | def _onClass(self, name, line, pos, absPosition,
keywordLine, keywordPos,
colonLine, colonPos, level):
"""Memorizes a class"""
self.__flushLevel(level)
c = Class(name, line, pos, absPosition, keywordLine, keywordPos,
colonLine, colonPos)
... | [
"def",
"_onClass",
"(",
"self",
",",
"name",
",",
"line",
",",
"pos",
",",
"absPosition",
",",
"keywordLine",
",",
"keywordPos",
",",
"colonLine",
",",
"colonPos",
",",
"level",
")",
":",
"self",
".",
"__flushLevel",
"(",
"level",
")",
"c",
"=",
"Class... | Memorizes a class | [
"Memorizes",
"a",
"class"
] | 7e933aca899b1853d744082313ffc3a8b1154505 | https://github.com/SergeySatskiy/cdm-pythonparser/blob/7e933aca899b1853d744082313ffc3a8b1154505/cdmpyparser.py#L500-L510 | train | Memorizes a class |
SergeySatskiy/cdm-pythonparser | cdmpyparser.py | BriefModuleInfo._onFunction | def _onFunction(self, name, line, pos, absPosition,
keywordLine, keywordPos,
colonLine, colonPos, level,
isAsync, returnAnnotation):
"""Memorizes a function"""
self.__flushLevel(level)
f = Function(name, line, pos, absPosition, keywordL... | python | def _onFunction(self, name, line, pos, absPosition,
keywordLine, keywordPos,
colonLine, colonPos, level,
isAsync, returnAnnotation):
"""Memorizes a function"""
self.__flushLevel(level)
f = Function(name, line, pos, absPosition, keywordL... | [
"def",
"_onFunction",
"(",
"self",
",",
"name",
",",
"line",
",",
"pos",
",",
"absPosition",
",",
"keywordLine",
",",
"keywordPos",
",",
"colonLine",
",",
"colonPos",
",",
"level",
",",
"isAsync",
",",
"returnAnnotation",
")",
":",
"self",
".",
"__flushLev... | Memorizes a function | [
"Memorizes",
"a",
"function"
] | 7e933aca899b1853d744082313ffc3a8b1154505 | https://github.com/SergeySatskiy/cdm-pythonparser/blob/7e933aca899b1853d744082313ffc3a8b1154505/cdmpyparser.py#L512-L523 | train | Memorizes a function |
SergeySatskiy/cdm-pythonparser | cdmpyparser.py | BriefModuleInfo._onWhat | def _onWhat(self, name, line, pos, absPosition):
"""Memorizes an imported item"""
self.__lastImport.what.append(ImportWhat(name, line, pos, absPosition)) | python | def _onWhat(self, name, line, pos, absPosition):
"""Memorizes an imported item"""
self.__lastImport.what.append(ImportWhat(name, line, pos, absPosition)) | [
"def",
"_onWhat",
"(",
"self",
",",
"name",
",",
"line",
",",
"pos",
",",
"absPosition",
")",
":",
"self",
".",
"__lastImport",
".",
"what",
".",
"append",
"(",
"ImportWhat",
"(",
"name",
",",
"line",
",",
"pos",
",",
"absPosition",
")",
")"
] | Memorizes an imported item | [
"Memorizes",
"an",
"imported",
"item"
] | 7e933aca899b1853d744082313ffc3a8b1154505 | https://github.com/SergeySatskiy/cdm-pythonparser/blob/7e933aca899b1853d744082313ffc3a8b1154505/cdmpyparser.py#L538-L540 | train | Memorizes an imported item |
SergeySatskiy/cdm-pythonparser | cdmpyparser.py | BriefModuleInfo._onClassAttribute | def _onClassAttribute(self, name, line, pos, absPosition, level):
"""Memorizes a class attribute"""
# A class must be on the top of the stack
attributes = self.objectsStack[level].classAttributes
for item in attributes:
if item.name == name:
return
att... | python | def _onClassAttribute(self, name, line, pos, absPosition, level):
"""Memorizes a class attribute"""
# A class must be on the top of the stack
attributes = self.objectsStack[level].classAttributes
for item in attributes:
if item.name == name:
return
att... | [
"def",
"_onClassAttribute",
"(",
"self",
",",
"name",
",",
"line",
",",
"pos",
",",
"absPosition",
",",
"level",
")",
":",
"# A class must be on the top of the stack",
"attributes",
"=",
"self",
".",
"objectsStack",
"[",
"level",
"]",
".",
"classAttributes",
"fo... | Memorizes a class attribute | [
"Memorizes",
"a",
"class",
"attribute"
] | 7e933aca899b1853d744082313ffc3a8b1154505 | https://github.com/SergeySatskiy/cdm-pythonparser/blob/7e933aca899b1853d744082313ffc3a8b1154505/cdmpyparser.py#L542-L549 | train | Memorizes a class attribute |
SergeySatskiy/cdm-pythonparser | cdmpyparser.py | BriefModuleInfo._onInstanceAttribute | def _onInstanceAttribute(self, name, line, pos, absPosition, level):
"""Memorizes a class instance attribute"""
# Instance attributes may appear in member functions only so we already
# have a function on the stack of objects. To get the class object one
# more step is required so we -1 ... | python | def _onInstanceAttribute(self, name, line, pos, absPosition, level):
"""Memorizes a class instance attribute"""
# Instance attributes may appear in member functions only so we already
# have a function on the stack of objects. To get the class object one
# more step is required so we -1 ... | [
"def",
"_onInstanceAttribute",
"(",
"self",
",",
"name",
",",
"line",
",",
"pos",
",",
"absPosition",
",",
"level",
")",
":",
"# Instance attributes may appear in member functions only so we already",
"# have a function on the stack of objects. To get the class object one",
"# mo... | Memorizes a class instance attribute | [
"Memorizes",
"a",
"class",
"instance",
"attribute"
] | 7e933aca899b1853d744082313ffc3a8b1154505 | https://github.com/SergeySatskiy/cdm-pythonparser/blob/7e933aca899b1853d744082313ffc3a8b1154505/cdmpyparser.py#L551-L560 | train | Memorizes a class instance attribute |
SergeySatskiy/cdm-pythonparser | cdmpyparser.py | BriefModuleInfo._onDecorator | def _onDecorator(self, name, line, pos, absPosition):
"""Memorizes a function or a class decorator"""
# A class or a function must be on the top of the stack
d = Decorator(name, line, pos, absPosition)
if self.__lastDecorators is None:
self.__lastDecorators = [d]
else... | python | def _onDecorator(self, name, line, pos, absPosition):
"""Memorizes a function or a class decorator"""
# A class or a function must be on the top of the stack
d = Decorator(name, line, pos, absPosition)
if self.__lastDecorators is None:
self.__lastDecorators = [d]
else... | [
"def",
"_onDecorator",
"(",
"self",
",",
"name",
",",
"line",
",",
"pos",
",",
"absPosition",
")",
":",
"# A class or a function must be on the top of the stack",
"d",
"=",
"Decorator",
"(",
"name",
",",
"line",
",",
"pos",
",",
"absPosition",
")",
"if",
"self... | Memorizes a function or a class decorator | [
"Memorizes",
"a",
"function",
"or",
"a",
"class",
"decorator"
] | 7e933aca899b1853d744082313ffc3a8b1154505 | https://github.com/SergeySatskiy/cdm-pythonparser/blob/7e933aca899b1853d744082313ffc3a8b1154505/cdmpyparser.py#L562-L569 | train | Memorizes a function or a class decorator |
SergeySatskiy/cdm-pythonparser | cdmpyparser.py | BriefModuleInfo._onArgument | def _onArgument(self, name, annotation):
"""Memorizes a function argument"""
self.objectsStack[-1].arguments.append(Argument(name, annotation)) | python | def _onArgument(self, name, annotation):
"""Memorizes a function argument"""
self.objectsStack[-1].arguments.append(Argument(name, annotation)) | [
"def",
"_onArgument",
"(",
"self",
",",
"name",
",",
"annotation",
")",
":",
"self",
".",
"objectsStack",
"[",
"-",
"1",
"]",
".",
"arguments",
".",
"append",
"(",
"Argument",
"(",
"name",
",",
"annotation",
")",
")"
] | Memorizes a function argument | [
"Memorizes",
"a",
"function",
"argument"
] | 7e933aca899b1853d744082313ffc3a8b1154505 | https://github.com/SergeySatskiy/cdm-pythonparser/blob/7e933aca899b1853d744082313ffc3a8b1154505/cdmpyparser.py#L583-L585 | train | Memorizes a function argument |
SergeySatskiy/cdm-pythonparser | cdmpyparser.py | BriefModuleInfo._onError | def _onError(self, message):
"""Memorizies a parser error message"""
self.isOK = False
if message.strip() != "":
self.errors.append(message) | python | def _onError(self, message):
"""Memorizies a parser error message"""
self.isOK = False
if message.strip() != "":
self.errors.append(message) | [
"def",
"_onError",
"(",
"self",
",",
"message",
")",
":",
"self",
".",
"isOK",
"=",
"False",
"if",
"message",
".",
"strip",
"(",
")",
"!=",
"\"\"",
":",
"self",
".",
"errors",
".",
"append",
"(",
"message",
")"
] | Memorizies a parser error message | [
"Memorizies",
"a",
"parser",
"error",
"message"
] | 7e933aca899b1853d744082313ffc3a8b1154505 | https://github.com/SergeySatskiy/cdm-pythonparser/blob/7e933aca899b1853d744082313ffc3a8b1154505/cdmpyparser.py#L596-L600 | train | Memorizies a parser error message |
SergeySatskiy/cdm-pythonparser | cdmpyparser.py | BriefModuleInfo._onLexerError | def _onLexerError(self, message):
"""Memorizes a lexer error message"""
self.isOK = False
if message.strip() != "":
self.lexerErrors.append(message) | python | def _onLexerError(self, message):
"""Memorizes a lexer error message"""
self.isOK = False
if message.strip() != "":
self.lexerErrors.append(message) | [
"def",
"_onLexerError",
"(",
"self",
",",
"message",
")",
":",
"self",
".",
"isOK",
"=",
"False",
"if",
"message",
".",
"strip",
"(",
")",
"!=",
"\"\"",
":",
"self",
".",
"lexerErrors",
".",
"append",
"(",
"message",
")"
] | Memorizes a lexer error message | [
"Memorizes",
"a",
"lexer",
"error",
"message"
] | 7e933aca899b1853d744082313ffc3a8b1154505 | https://github.com/SergeySatskiy/cdm-pythonparser/blob/7e933aca899b1853d744082313ffc3a8b1154505/cdmpyparser.py#L602-L606 | train | Memorizes a lexer error message |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.