partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
valid | scaffold | Start a new site. | inkblock/main.py | def scaffold():
"""Start a new site."""
click.echo("A whole new site? Awesome.")
title = click.prompt("What's the title?")
url = click.prompt("Great. What's url? http://")
# Make sure that title doesn't exist.
click.echo("Got it. Creating %s..." % url) | def scaffold():
"""Start a new site."""
click.echo("A whole new site? Awesome.")
title = click.prompt("What's the title?")
url = click.prompt("Great. What's url? http://")
# Make sure that title doesn't exist.
click.echo("Got it. Creating %s..." % url) | [
"Start",
"a",
"new",
"site",
"."
] | skoczen/inkblock | python | https://github.com/skoczen/inkblock/blob/099f834c1e9fc0938abaa8824725eeac57603f6c/inkblock/main.py#L1369-L1376 | [
"def",
"scaffold",
"(",
")",
":",
"click",
".",
"echo",
"(",
"\"A whole new site? Awesome.\"",
")",
"title",
"=",
"click",
".",
"prompt",
"(",
"\"What's the title?\"",
")",
"url",
"=",
"click",
".",
"prompt",
"(",
"\"Great. What's url? http://\"",
")",
"# Make s... | 099f834c1e9fc0938abaa8824725eeac57603f6c |
valid | publish | Publish the site | inkblock/main.py | def publish():
"""Publish the site"""
try:
build_site(dev_mode=False, clean=True)
click.echo('Deploying the site...')
# call("firebase deploy", shell=True)
call("rsync -avz -e ssh --progress %s/ %s" % (BUILD_DIR, CONFIG["scp_target"],), shell=True)
if "cloudflare" in CONF... | def publish():
"""Publish the site"""
try:
build_site(dev_mode=False, clean=True)
click.echo('Deploying the site...')
# call("firebase deploy", shell=True)
call("rsync -avz -e ssh --progress %s/ %s" % (BUILD_DIR, CONFIG["scp_target"],), shell=True)
if "cloudflare" in CONF... | [
"Publish",
"the",
"site"
] | skoczen/inkblock | python | https://github.com/skoczen/inkblock/blob/099f834c1e9fc0938abaa8824725eeac57603f6c/inkblock/main.py#L1381-L1392 | [
"def",
"publish",
"(",
")",
":",
"try",
":",
"build_site",
"(",
"dev_mode",
"=",
"False",
",",
"clean",
"=",
"True",
")",
"click",
".",
"echo",
"(",
"'Deploying the site...'",
")",
"# call(\"firebase deploy\", shell=True)",
"call",
"(",
"\"rsync -avz -e ssh --prog... | 099f834c1e9fc0938abaa8824725eeac57603f6c |
valid | promote | Schedule all the social media posts. | inkblock/main.py | def promote():
"""Schedule all the social media posts."""
if "BUFFER_ACCESS_TOKEN" not in os.environ:
warn("Missing BUFFER_ACCESS_TOKEN.")
echo("To publish to social medial, you'll need an access token for buffer.")
echo("The simplest way to get one is to create a new app here: https://... | def promote():
"""Schedule all the social media posts."""
if "BUFFER_ACCESS_TOKEN" not in os.environ:
warn("Missing BUFFER_ACCESS_TOKEN.")
echo("To publish to social medial, you'll need an access token for buffer.")
echo("The simplest way to get one is to create a new app here: https://... | [
"Schedule",
"all",
"the",
"social",
"media",
"posts",
"."
] | skoczen/inkblock | python | https://github.com/skoczen/inkblock/blob/099f834c1e9fc0938abaa8824725eeac57603f6c/inkblock/main.py#L1396-L1573 | [
"def",
"promote",
"(",
")",
":",
"if",
"\"BUFFER_ACCESS_TOKEN\"",
"not",
"in",
"os",
".",
"environ",
":",
"warn",
"(",
"\"Missing BUFFER_ACCESS_TOKEN.\"",
")",
"echo",
"(",
"\"To publish to social medial, you'll need an access token for buffer.\"",
")",
"echo",
"(",
"\"... | 099f834c1e9fc0938abaa8824725eeac57603f6c |
valid | Git.get_branches | Returns a list of the branches | gitwrapperlib/gitwrapperlib.py | def get_branches(self):
"""Returns a list of the branches"""
return [self._sanitize(branch)
for branch in self._git.branch(color="never").splitlines()] | def get_branches(self):
"""Returns a list of the branches"""
return [self._sanitize(branch)
for branch in self._git.branch(color="never").splitlines()] | [
"Returns",
"a",
"list",
"of",
"the",
"branches"
] | costastf/gitwrapperlib | python | https://github.com/costastf/gitwrapperlib/blob/3d7ab65fee906e30e4fa4608c4b2fdc266e5af6d/gitwrapperlib/gitwrapperlib.py#L139-L142 | [
"def",
"get_branches",
"(",
"self",
")",
":",
"return",
"[",
"self",
".",
"_sanitize",
"(",
"branch",
")",
"for",
"branch",
"in",
"self",
".",
"_git",
".",
"branch",
"(",
"color",
"=",
"\"never\"",
")",
".",
"splitlines",
"(",
")",
"]"
] | 3d7ab65fee906e30e4fa4608c4b2fdc266e5af6d |
valid | Git.get_current_branch | Returns the currently active branch | gitwrapperlib/gitwrapperlib.py | def get_current_branch(self):
"""Returns the currently active branch"""
return next((self._sanitize(branch)
for branch in self._git.branch(color="never").splitlines()
if branch.startswith('*')),
None) | def get_current_branch(self):
"""Returns the currently active branch"""
return next((self._sanitize(branch)
for branch in self._git.branch(color="never").splitlines()
if branch.startswith('*')),
None) | [
"Returns",
"the",
"currently",
"active",
"branch"
] | costastf/gitwrapperlib | python | https://github.com/costastf/gitwrapperlib/blob/3d7ab65fee906e30e4fa4608c4b2fdc266e5af6d/gitwrapperlib/gitwrapperlib.py#L152-L157 | [
"def",
"get_current_branch",
"(",
"self",
")",
":",
"return",
"next",
"(",
"(",
"self",
".",
"_sanitize",
"(",
"branch",
")",
"for",
"branch",
"in",
"self",
".",
"_git",
".",
"branch",
"(",
"color",
"=",
"\"never\"",
")",
".",
"splitlines",
"(",
")",
... | 3d7ab65fee906e30e4fa4608c4b2fdc266e5af6d |
valid | Git.create_patch | Create a patch between tags | gitwrapperlib/gitwrapperlib.py | def create_patch(self, from_tag, to_tag):
"""Create a patch between tags"""
return str(self._git.diff('{}..{}'.format(from_tag, to_tag), _tty_out=False)) | def create_patch(self, from_tag, to_tag):
"""Create a patch between tags"""
return str(self._git.diff('{}..{}'.format(from_tag, to_tag), _tty_out=False)) | [
"Create",
"a",
"patch",
"between",
"tags"
] | costastf/gitwrapperlib | python | https://github.com/costastf/gitwrapperlib/blob/3d7ab65fee906e30e4fa4608c4b2fdc266e5af6d/gitwrapperlib/gitwrapperlib.py#L183-L185 | [
"def",
"create_patch",
"(",
"self",
",",
"from_tag",
",",
"to_tag",
")",
":",
"return",
"str",
"(",
"self",
".",
"_git",
".",
"diff",
"(",
"'{}..{}'",
".",
"format",
"(",
"from_tag",
",",
"to_tag",
")",
",",
"_tty_out",
"=",
"False",
")",
")"
] | 3d7ab65fee906e30e4fa4608c4b2fdc266e5af6d |
valid | one | Create a callable that applies ``func`` to a value in a sequence.
If the value is not a sequence or is an empty sequence then ``None`` is
returned.
:type func: `callable`
:param func: Callable to be applied to each result.
:type n: `int`
:param n: Index of the value to apply ``func`` to. | txspinneret/query.py | def one(func, n=0):
"""
Create a callable that applies ``func`` to a value in a sequence.
If the value is not a sequence or is an empty sequence then ``None`` is
returned.
:type func: `callable`
:param func: Callable to be applied to each result.
:type n: `int`
:param n: Index of th... | def one(func, n=0):
"""
Create a callable that applies ``func`` to a value in a sequence.
If the value is not a sequence or is an empty sequence then ``None`` is
returned.
:type func: `callable`
:param func: Callable to be applied to each result.
:type n: `int`
:param n: Index of th... | [
"Create",
"a",
"callable",
"that",
"applies",
"func",
"to",
"a",
"value",
"in",
"a",
"sequence",
"."
] | jonathanj/txspinneret | python | https://github.com/jonathanj/txspinneret/blob/717008a2c313698984a23e3f3fc62ea3675ed02d/txspinneret/query.py#L38-L55 | [
"def",
"one",
"(",
"func",
",",
"n",
"=",
"0",
")",
":",
"def",
"_one",
"(",
"result",
")",
":",
"if",
"_isSequenceTypeNotText",
"(",
"result",
")",
"and",
"len",
"(",
"result",
")",
">",
"n",
":",
"return",
"func",
"(",
"result",
"[",
"n",
"]",
... | 717008a2c313698984a23e3f3fc62ea3675ed02d |
valid | many | Create a callable that applies ``func`` to every value in a sequence.
If the value is not a sequence then an empty list is returned.
:type func: `callable`
:param func: Callable to be applied to the first result. | txspinneret/query.py | def many(func):
"""
Create a callable that applies ``func`` to every value in a sequence.
If the value is not a sequence then an empty list is returned.
:type func: `callable`
:param func: Callable to be applied to the first result.
"""
def _many(result):
if _isSequenceTypeNotText... | def many(func):
"""
Create a callable that applies ``func`` to every value in a sequence.
If the value is not a sequence then an empty list is returned.
:type func: `callable`
:param func: Callable to be applied to the first result.
"""
def _many(result):
if _isSequenceTypeNotText... | [
"Create",
"a",
"callable",
"that",
"applies",
"func",
"to",
"every",
"value",
"in",
"a",
"sequence",
"."
] | jonathanj/txspinneret | python | https://github.com/jonathanj/txspinneret/blob/717008a2c313698984a23e3f3fc62ea3675ed02d/txspinneret/query.py#L59-L72 | [
"def",
"many",
"(",
"func",
")",
":",
"def",
"_many",
"(",
"result",
")",
":",
"if",
"_isSequenceTypeNotText",
"(",
"result",
")",
":",
"return",
"map",
"(",
"func",
",",
"result",
")",
"return",
"[",
"]",
"return",
"maybe",
"(",
"_many",
",",
"defau... | 717008a2c313698984a23e3f3fc62ea3675ed02d |
valid | Text | Parse a value as text.
:type value: `unicode` or `bytes`
:param value: Text value to parse
:type encoding: `bytes`
:param encoding: Encoding to treat ``bytes`` values as, defaults to
``utf-8``.
:rtype: `unicode`
:return: Parsed text or ``None`` if ``value`` is neither `bytes` nor
... | txspinneret/query.py | def Text(value, encoding=None):
"""
Parse a value as text.
:type value: `unicode` or `bytes`
:param value: Text value to parse
:type encoding: `bytes`
:param encoding: Encoding to treat ``bytes`` values as, defaults to
``utf-8``.
:rtype: `unicode`
:return: Parsed text or ``N... | def Text(value, encoding=None):
"""
Parse a value as text.
:type value: `unicode` or `bytes`
:param value: Text value to parse
:type encoding: `bytes`
:param encoding: Encoding to treat ``bytes`` values as, defaults to
``utf-8``.
:rtype: `unicode`
:return: Parsed text or ``N... | [
"Parse",
"a",
"value",
"as",
"text",
"."
] | jonathanj/txspinneret | python | https://github.com/jonathanj/txspinneret/blob/717008a2c313698984a23e3f3fc62ea3675ed02d/txspinneret/query.py#L76-L97 | [
"def",
"Text",
"(",
"value",
",",
"encoding",
"=",
"None",
")",
":",
"if",
"encoding",
"is",
"None",
":",
"encoding",
"=",
"'utf-8'",
"if",
"isinstance",
"(",
"value",
",",
"bytes",
")",
":",
"return",
"value",
".",
"decode",
"(",
"encoding",
")",
"e... | 717008a2c313698984a23e3f3fc62ea3675ed02d |
valid | Integer | Parse a value as an integer.
:type value: `unicode` or `bytes`
:param value: Text value to parse
:type base: `unicode` or `bytes`
:param base: Base to assume ``value`` is specified in.
:type encoding: `bytes`
:param encoding: Encoding to treat ``bytes`` values as, defaults to
``utf... | txspinneret/query.py | def Integer(value, base=10, encoding=None):
"""
Parse a value as an integer.
:type value: `unicode` or `bytes`
:param value: Text value to parse
:type base: `unicode` or `bytes`
:param base: Base to assume ``value`` is specified in.
:type encoding: `bytes`
:param encoding: Encoding... | def Integer(value, base=10, encoding=None):
"""
Parse a value as an integer.
:type value: `unicode` or `bytes`
:param value: Text value to parse
:type base: `unicode` or `bytes`
:param base: Base to assume ``value`` is specified in.
:type encoding: `bytes`
:param encoding: Encoding... | [
"Parse",
"a",
"value",
"as",
"an",
"integer",
"."
] | jonathanj/txspinneret | python | https://github.com/jonathanj/txspinneret/blob/717008a2c313698984a23e3f3fc62ea3675ed02d/txspinneret/query.py#L101-L122 | [
"def",
"Integer",
"(",
"value",
",",
"base",
"=",
"10",
",",
"encoding",
"=",
"None",
")",
":",
"try",
":",
"return",
"int",
"(",
"Text",
"(",
"value",
",",
"encoding",
")",
",",
"base",
")",
"except",
"(",
"TypeError",
",",
"ValueError",
")",
":",... | 717008a2c313698984a23e3f3fc62ea3675ed02d |
valid | Boolean | Parse a value as a boolean.
:type value: `unicode` or `bytes`
:param value: Text value to parse.
:type true: `tuple` of `unicode`
:param true: Values to compare, ignoring case, for ``True`` values.
:type false: `tuple` of `unicode`
:param false: Values to compare, ignoring case, for ``Fals... | txspinneret/query.py | def Boolean(value, true=(u'yes', u'1', u'true'), false=(u'no', u'0', u'false'),
encoding=None):
"""
Parse a value as a boolean.
:type value: `unicode` or `bytes`
:param value: Text value to parse.
:type true: `tuple` of `unicode`
:param true: Values to compare, ignoring case, for... | def Boolean(value, true=(u'yes', u'1', u'true'), false=(u'no', u'0', u'false'),
encoding=None):
"""
Parse a value as a boolean.
:type value: `unicode` or `bytes`
:param value: Text value to parse.
:type true: `tuple` of `unicode`
:param true: Values to compare, ignoring case, for... | [
"Parse",
"a",
"value",
"as",
"a",
"boolean",
"."
] | jonathanj/txspinneret | python | https://github.com/jonathanj/txspinneret/blob/717008a2c313698984a23e3f3fc62ea3675ed02d/txspinneret/query.py#L148-L177 | [
"def",
"Boolean",
"(",
"value",
",",
"true",
"=",
"(",
"u'yes'",
",",
"u'1'",
",",
"u'true'",
")",
",",
"false",
"=",
"(",
"u'no'",
",",
"u'0'",
",",
"u'false'",
")",
",",
"encoding",
"=",
"None",
")",
":",
"value",
"=",
"Text",
"(",
"value",
","... | 717008a2c313698984a23e3f3fc62ea3675ed02d |
valid | Delimited | Parse a value as a delimited list.
:type value: `unicode` or `bytes`
:param value: Text value to parse.
:type parser: `callable` taking a `unicode` parameter
:param parser: Callable to map over the delimited text values.
:type delimiter: `unicode`
:param delimiter: Delimiter text.
:ty... | txspinneret/query.py | def Delimited(value, parser=Text, delimiter=u',', encoding=None):
"""
Parse a value as a delimited list.
:type value: `unicode` or `bytes`
:param value: Text value to parse.
:type parser: `callable` taking a `unicode` parameter
:param parser: Callable to map over the delimited text values.
... | def Delimited(value, parser=Text, delimiter=u',', encoding=None):
"""
Parse a value as a delimited list.
:type value: `unicode` or `bytes`
:param value: Text value to parse.
:type parser: `callable` taking a `unicode` parameter
:param parser: Callable to map over the delimited text values.
... | [
"Parse",
"a",
"value",
"as",
"a",
"delimited",
"list",
"."
] | jonathanj/txspinneret | python | https://github.com/jonathanj/txspinneret/blob/717008a2c313698984a23e3f3fc62ea3675ed02d/txspinneret/query.py#L181-L204 | [
"def",
"Delimited",
"(",
"value",
",",
"parser",
"=",
"Text",
",",
"delimiter",
"=",
"u','",
",",
"encoding",
"=",
"None",
")",
":",
"value",
"=",
"Text",
"(",
"value",
",",
"encoding",
")",
"if",
"value",
"is",
"None",
"or",
"value",
"==",
"u''",
... | 717008a2c313698984a23e3f3fc62ea3675ed02d |
valid | Timestamp | Parse a value as a POSIX timestamp in seconds.
:type value: `unicode` or `bytes`
:param value: Text value to parse, which should be the number of seconds
since the epoch.
:type _divisor: `float`
:param _divisor: Number to divide the value by.
:type tz: `tzinfo`
:param tz: Timezone,... | txspinneret/query.py | def Timestamp(value, _divisor=1., tz=UTC, encoding=None):
"""
Parse a value as a POSIX timestamp in seconds.
:type value: `unicode` or `bytes`
:param value: Text value to parse, which should be the number of seconds
since the epoch.
:type _divisor: `float`
:param _divisor: Number to ... | def Timestamp(value, _divisor=1., tz=UTC, encoding=None):
"""
Parse a value as a POSIX timestamp in seconds.
:type value: `unicode` or `bytes`
:param value: Text value to parse, which should be the number of seconds
since the epoch.
:type _divisor: `float`
:param _divisor: Number to ... | [
"Parse",
"a",
"value",
"as",
"a",
"POSIX",
"timestamp",
"in",
"seconds",
"."
] | jonathanj/txspinneret | python | https://github.com/jonathanj/txspinneret/blob/717008a2c313698984a23e3f3fc62ea3675ed02d/txspinneret/query.py#L208-L233 | [
"def",
"Timestamp",
"(",
"value",
",",
"_divisor",
"=",
"1.",
",",
"tz",
"=",
"UTC",
",",
"encoding",
"=",
"None",
")",
":",
"value",
"=",
"Float",
"(",
"value",
",",
"encoding",
")",
"if",
"value",
"is",
"not",
"None",
":",
"value",
"=",
"value",
... | 717008a2c313698984a23e3f3fc62ea3675ed02d |
valid | parse | Parse query parameters.
:type expected: `dict` mapping `bytes` to `callable`
:param expected: Mapping of query argument names to argument parsing
callables.
:type query: `dict` mapping `bytes` to `list` of `bytes`
:param query: Mapping of query argument names to lists of argument values,
... | txspinneret/query.py | def parse(expected, query):
"""
Parse query parameters.
:type expected: `dict` mapping `bytes` to `callable`
:param expected: Mapping of query argument names to argument parsing
callables.
:type query: `dict` mapping `bytes` to `list` of `bytes`
:param query: Mapping of query argumen... | def parse(expected, query):
"""
Parse query parameters.
:type expected: `dict` mapping `bytes` to `callable`
:param expected: Mapping of query argument names to argument parsing
callables.
:type query: `dict` mapping `bytes` to `list` of `bytes`
:param query: Mapping of query argumen... | [
"Parse",
"query",
"parameters",
"."
] | jonathanj/txspinneret | python | https://github.com/jonathanj/txspinneret/blob/717008a2c313698984a23e3f3fc62ea3675ed02d/txspinneret/query.py#L256-L274 | [
"def",
"parse",
"(",
"expected",
",",
"query",
")",
":",
"return",
"dict",
"(",
"(",
"key",
",",
"parser",
"(",
"query",
".",
"get",
"(",
"key",
",",
"[",
"]",
")",
")",
")",
"for",
"key",
",",
"parser",
"in",
"expected",
".",
"items",
"(",
")"... | 717008a2c313698984a23e3f3fc62ea3675ed02d |
valid | CloudWatch.put | Put metrics to cloudwatch. Metric shoult be instance or list of
instances of CloudWatchMetric | pycloudwatch/sender.py | def put(self, metrics):
"""
Put metrics to cloudwatch. Metric shoult be instance or list of
instances of CloudWatchMetric
"""
if type(metrics) == list:
for metric in metrics:
self.c.put_metric_data(**metric)
else:
self.c.put_metric_... | def put(self, metrics):
"""
Put metrics to cloudwatch. Metric shoult be instance or list of
instances of CloudWatchMetric
"""
if type(metrics) == list:
for metric in metrics:
self.c.put_metric_data(**metric)
else:
self.c.put_metric_... | [
"Put",
"metrics",
"to",
"cloudwatch",
".",
"Metric",
"shoult",
"be",
"instance",
"or",
"list",
"of",
"instances",
"of",
"CloudWatchMetric"
] | adubkov/py-cloudwatch | python | https://github.com/adubkov/py-cloudwatch/blob/755bac7c153f75c4f0aa73ce14ca333cc4affb36/pycloudwatch/sender.py#L14-L23 | [
"def",
"put",
"(",
"self",
",",
"metrics",
")",
":",
"if",
"type",
"(",
"metrics",
")",
"==",
"list",
":",
"for",
"metric",
"in",
"metrics",
":",
"self",
".",
"c",
".",
"put_metric_data",
"(",
"*",
"*",
"metric",
")",
"else",
":",
"self",
".",
"c... | 755bac7c153f75c4f0aa73ce14ca333cc4affb36 |
valid | _renderResource | Render a given resource.
See `IResource.render <twisted:twisted.web.resource.IResource.render>`. | txspinneret/resource.py | def _renderResource(resource, request):
"""
Render a given resource.
See `IResource.render <twisted:twisted.web.resource.IResource.render>`.
"""
meth = getattr(resource, 'render_' + nativeString(request.method), None)
if meth is None:
try:
allowedMethods = resource.allowedMe... | def _renderResource(resource, request):
"""
Render a given resource.
See `IResource.render <twisted:twisted.web.resource.IResource.render>`.
"""
meth = getattr(resource, 'render_' + nativeString(request.method), None)
if meth is None:
try:
allowedMethods = resource.allowedMe... | [
"Render",
"a",
"given",
"resource",
"."
] | jonathanj/txspinneret | python | https://github.com/jonathanj/txspinneret/blob/717008a2c313698984a23e3f3fc62ea3675ed02d/txspinneret/resource.py#L27-L40 | [
"def",
"_renderResource",
"(",
"resource",
",",
"request",
")",
":",
"meth",
"=",
"getattr",
"(",
"resource",
",",
"'render_'",
"+",
"nativeString",
"(",
"request",
".",
"method",
")",
",",
"None",
")",
"if",
"meth",
"is",
"None",
":",
"try",
":",
"all... | 717008a2c313698984a23e3f3fc62ea3675ed02d |
valid | SpinneretResource._adaptToResource | Adapt a result to `IResource`.
Several adaptions are tried they are, in order: ``None``,
`IRenderable <twisted:twisted.web.iweb.IRenderable>`, `IResource
<twisted:twisted.web.resource.IResource>`, and `URLPath
<twisted:twisted.python.urlpath.URLPath>`. Anything else is returned as
... | txspinneret/resource.py | def _adaptToResource(self, result):
"""
Adapt a result to `IResource`.
Several adaptions are tried they are, in order: ``None``,
`IRenderable <twisted:twisted.web.iweb.IRenderable>`, `IResource
<twisted:twisted.web.resource.IResource>`, and `URLPath
<twisted:twisted.pyth... | def _adaptToResource(self, result):
"""
Adapt a result to `IResource`.
Several adaptions are tried they are, in order: ``None``,
`IRenderable <twisted:twisted.web.iweb.IRenderable>`, `IResource
<twisted:twisted.web.resource.IResource>`, and `URLPath
<twisted:twisted.pyth... | [
"Adapt",
"a",
"result",
"to",
"IResource",
"."
] | jonathanj/txspinneret | python | https://github.com/jonathanj/txspinneret/blob/717008a2c313698984a23e3f3fc62ea3675ed02d/txspinneret/resource.py#L96-L127 | [
"def",
"_adaptToResource",
"(",
"self",
",",
"result",
")",
":",
"if",
"result",
"is",
"None",
":",
"return",
"NotFound",
"(",
")",
"spinneretResource",
"=",
"ISpinneretResource",
"(",
"result",
",",
"None",
")",
"if",
"spinneretResource",
"is",
"not",
"None... | 717008a2c313698984a23e3f3fc62ea3675ed02d |
valid | SpinneretResource._handleRenderResult | Handle the result from `IResource.render`.
If the result is a `Deferred` then return `NOT_DONE_YET` and add
a callback to write the result to the request when it arrives. | txspinneret/resource.py | def _handleRenderResult(self, request, result):
"""
Handle the result from `IResource.render`.
If the result is a `Deferred` then return `NOT_DONE_YET` and add
a callback to write the result to the request when it arrives.
"""
def _requestFinished(result, cancel):
... | def _handleRenderResult(self, request, result):
"""
Handle the result from `IResource.render`.
If the result is a `Deferred` then return `NOT_DONE_YET` and add
a callback to write the result to the request when it arrives.
"""
def _requestFinished(result, cancel):
... | [
"Handle",
"the",
"result",
"from",
"IResource",
".",
"render",
"."
] | jonathanj/txspinneret | python | https://github.com/jonathanj/txspinneret/blob/717008a2c313698984a23e3f3fc62ea3675ed02d/txspinneret/resource.py#L150-L175 | [
"def",
"_handleRenderResult",
"(",
"self",
",",
"request",
",",
"result",
")",
":",
"def",
"_requestFinished",
"(",
"result",
",",
"cancel",
")",
":",
"cancel",
"(",
")",
"return",
"result",
"if",
"not",
"isinstance",
"(",
"result",
",",
"Deferred",
")",
... | 717008a2c313698984a23e3f3fc62ea3675ed02d |
valid | ContentTypeNegotiator._negotiateHandler | Negotiate a handler based on the content types acceptable to the
client.
:rtype: 2-`tuple` of `twisted.web.iweb.IResource` and `bytes`
:return: Pair of a resource and the content type. | txspinneret/resource.py | def _negotiateHandler(self, request):
"""
Negotiate a handler based on the content types acceptable to the
client.
:rtype: 2-`tuple` of `twisted.web.iweb.IResource` and `bytes`
:return: Pair of a resource and the content type.
"""
accept = _parseAccept(request.re... | def _negotiateHandler(self, request):
"""
Negotiate a handler based on the content types acceptable to the
client.
:rtype: 2-`tuple` of `twisted.web.iweb.IResource` and `bytes`
:return: Pair of a resource and the content type.
"""
accept = _parseAccept(request.re... | [
"Negotiate",
"a",
"handler",
"based",
"on",
"the",
"content",
"types",
"acceptable",
"to",
"the",
"client",
"."
] | jonathanj/txspinneret | python | https://github.com/jonathanj/txspinneret/blob/717008a2c313698984a23e3f3fc62ea3675ed02d/txspinneret/resource.py#L221-L238 | [
"def",
"_negotiateHandler",
"(",
"self",
",",
"request",
")",
":",
"accept",
"=",
"_parseAccept",
"(",
"request",
".",
"requestHeaders",
".",
"getRawHeaders",
"(",
"'Accept'",
")",
")",
"for",
"contentType",
"in",
"accept",
".",
"keys",
"(",
")",
":",
"han... | 717008a2c313698984a23e3f3fc62ea3675ed02d |
valid | _parseAccept | Parse and sort an ``Accept`` header.
The header is sorted according to the ``q`` parameter for each header value.
@rtype: `OrderedDict` mapping `bytes` to `dict`
@return: Mapping of media types to header parameters. | txspinneret/util.py | def _parseAccept(headers):
"""
Parse and sort an ``Accept`` header.
The header is sorted according to the ``q`` parameter for each header value.
@rtype: `OrderedDict` mapping `bytes` to `dict`
@return: Mapping of media types to header parameters.
"""
def sort(value):
return float(v... | def _parseAccept(headers):
"""
Parse and sort an ``Accept`` header.
The header is sorted according to the ``q`` parameter for each header value.
@rtype: `OrderedDict` mapping `bytes` to `dict`
@return: Mapping of media types to header parameters.
"""
def sort(value):
return float(v... | [
"Parse",
"and",
"sort",
"an",
"Accept",
"header",
"."
] | jonathanj/txspinneret | python | https://github.com/jonathanj/txspinneret/blob/717008a2c313698984a23e3f3fc62ea3675ed02d/txspinneret/util.py#L13-L24 | [
"def",
"_parseAccept",
"(",
"headers",
")",
":",
"def",
"sort",
"(",
"value",
")",
":",
"return",
"float",
"(",
"value",
"[",
"1",
"]",
".",
"get",
"(",
"'q'",
",",
"1",
")",
")",
"return",
"OrderedDict",
"(",
"sorted",
"(",
"_splitHeaders",
"(",
"... | 717008a2c313698984a23e3f3fc62ea3675ed02d |
valid | _splitHeaders | Split an HTTP header whose components are separated with commas.
Each component is then split on semicolons and the component arguments
converted into a `dict`.
@return: `list` of 2-`tuple` of `bytes`, `dict`
@return: List of header arguments and mapping of component argument names
to values. | txspinneret/util.py | def _splitHeaders(headers):
"""
Split an HTTP header whose components are separated with commas.
Each component is then split on semicolons and the component arguments
converted into a `dict`.
@return: `list` of 2-`tuple` of `bytes`, `dict`
@return: List of header arguments and mapping of comp... | def _splitHeaders(headers):
"""
Split an HTTP header whose components are separated with commas.
Each component is then split on semicolons and the component arguments
converted into a `dict`.
@return: `list` of 2-`tuple` of `bytes`, `dict`
@return: List of header arguments and mapping of comp... | [
"Split",
"an",
"HTTP",
"header",
"whose",
"components",
"are",
"separated",
"with",
"commas",
"."
] | jonathanj/txspinneret | python | https://github.com/jonathanj/txspinneret/blob/717008a2c313698984a23e3f3fc62ea3675ed02d/txspinneret/util.py#L28-L42 | [
"def",
"_splitHeaders",
"(",
"headers",
")",
":",
"return",
"[",
"cgi",
".",
"parse_header",
"(",
"value",
")",
"for",
"value",
"in",
"chain",
".",
"from_iterable",
"(",
"s",
".",
"split",
"(",
"','",
")",
"for",
"s",
"in",
"headers",
"if",
"s",
")",... | 717008a2c313698984a23e3f3fc62ea3675ed02d |
valid | contentEncoding | Extract an encoding from a ``Content-Type`` header.
@type requestHeaders: `twisted.web.http_headers.Headers`
@param requestHeaders: Request headers.
@type encoding: `bytes`
@param encoding: Default encoding to assume if the ``Content-Type``
header is lacking one. Defaults to ``UTF-8``.
... | txspinneret/util.py | def contentEncoding(requestHeaders, encoding=None):
"""
Extract an encoding from a ``Content-Type`` header.
@type requestHeaders: `twisted.web.http_headers.Headers`
@param requestHeaders: Request headers.
@type encoding: `bytes`
@param encoding: Default encoding to assume if the ``Content-Ty... | def contentEncoding(requestHeaders, encoding=None):
"""
Extract an encoding from a ``Content-Type`` header.
@type requestHeaders: `twisted.web.http_headers.Headers`
@param requestHeaders: Request headers.
@type encoding: `bytes`
@param encoding: Default encoding to assume if the ``Content-Ty... | [
"Extract",
"an",
"encoding",
"from",
"a",
"Content",
"-",
"Type",
"header",
"."
] | jonathanj/txspinneret | python | https://github.com/jonathanj/txspinneret/blob/717008a2c313698984a23e3f3fc62ea3675ed02d/txspinneret/util.py#L46-L66 | [
"def",
"contentEncoding",
"(",
"requestHeaders",
",",
"encoding",
"=",
"None",
")",
":",
"if",
"encoding",
"is",
"None",
":",
"encoding",
"=",
"b'utf-8'",
"headers",
"=",
"_splitHeaders",
"(",
"requestHeaders",
".",
"getRawHeaders",
"(",
"b'Content-Type'",
",",
... | 717008a2c313698984a23e3f3fc62ea3675ed02d |
valid | maybe | Create a nil-safe callable decorator.
If the wrapped callable receives ``None`` as its argument, it will return
``None`` immediately. | txspinneret/util.py | def maybe(f, default=None):
"""
Create a nil-safe callable decorator.
If the wrapped callable receives ``None`` as its argument, it will return
``None`` immediately.
"""
@wraps(f)
def _maybe(x, *a, **kw):
if x is None:
return default
return f(x, *a, **kw)
ret... | def maybe(f, default=None):
"""
Create a nil-safe callable decorator.
If the wrapped callable receives ``None`` as its argument, it will return
``None`` immediately.
"""
@wraps(f)
def _maybe(x, *a, **kw):
if x is None:
return default
return f(x, *a, **kw)
ret... | [
"Create",
"a",
"nil",
"-",
"safe",
"callable",
"decorator",
"."
] | jonathanj/txspinneret | python | https://github.com/jonathanj/txspinneret/blob/717008a2c313698984a23e3f3fc62ea3675ed02d/txspinneret/util.py#L70-L82 | [
"def",
"maybe",
"(",
"f",
",",
"default",
"=",
"None",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"_maybe",
"(",
"x",
",",
"*",
"a",
",",
"*",
"*",
"kw",
")",
":",
"if",
"x",
"is",
"None",
":",
"return",
"default",
"return",
"f",
"(",
"x... | 717008a2c313698984a23e3f3fc62ea3675ed02d |
valid | settings | Get or set `Settings._wrapped`
:param str path: a python module file,
if user set it,write config to `Settings._wrapped`
:param str with_path: search path
:return: A instance of `Settings` | cliez/conf/__init__.py | def settings(path=None, with_path=None):
"""
Get or set `Settings._wrapped`
:param str path: a python module file,
if user set it,write config to `Settings._wrapped`
:param str with_path: search path
:return: A instance of `Settings`
"""
if path:
Settings.bind(path, with_pa... | def settings(path=None, with_path=None):
"""
Get or set `Settings._wrapped`
:param str path: a python module file,
if user set it,write config to `Settings._wrapped`
:param str with_path: search path
:return: A instance of `Settings`
"""
if path:
Settings.bind(path, with_pa... | [
"Get",
"or",
"set",
"Settings",
".",
"_wrapped"
] | wangwenpei/cliez | python | https://github.com/wangwenpei/cliez/blob/d6fe775544cd380735c56c8a4a79bc2ad22cb6c4/cliez/conf/__init__.py#L46-L59 | [
"def",
"settings",
"(",
"path",
"=",
"None",
",",
"with_path",
"=",
"None",
")",
":",
"if",
"path",
":",
"Settings",
".",
"bind",
"(",
"path",
",",
"with_path",
"=",
"with_path",
")",
"return",
"Settings",
".",
"_wrapped"
] | d6fe775544cd380735c56c8a4a79bc2ad22cb6c4 |
valid | Settings.bind | bind user variable to `_wrapped`
.. note::
you don't need call this method by yourself.
program will call it in `cliez.parser.parse`
.. expection::
if path is not correct,will cause an `ImportError`
:param str mod_path: module path, *use dot style,'mo... | cliez/conf/__init__.py | def bind(mod_path, with_path=None):
"""
bind user variable to `_wrapped`
.. note::
you don't need call this method by yourself.
program will call it in `cliez.parser.parse`
.. expection::
if path is not correct,will cause an `ImportError`
... | def bind(mod_path, with_path=None):
"""
bind user variable to `_wrapped`
.. note::
you don't need call this method by yourself.
program will call it in `cliez.parser.parse`
.. expection::
if path is not correct,will cause an `ImportError`
... | [
"bind",
"user",
"variable",
"to",
"_wrapped"
] | wangwenpei/cliez | python | https://github.com/wangwenpei/cliez/blob/d6fe775544cd380735c56c8a4a79bc2ad22cb6c4/cliez/conf/__init__.py#L71-L114 | [
"def",
"bind",
"(",
"mod_path",
",",
"with_path",
"=",
"None",
")",
":",
"if",
"with_path",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"with_path",
")",
":",
"sys",
".",
"path",
".",
"insert",
"(",
"0",
",",
"with_path",
")",
"else",
":",
"... | d6fe775544cd380735c56c8a4a79bc2ad22cb6c4 |
valid | get_version | Get the version from version module without importing more than
necessary. | setup.py | def get_version():
"""
Get the version from version module without importing more than
necessary.
"""
version_module_path = os.path.join(
os.path.dirname(__file__), "txspinneret", "_version.py")
# The version module contains a variable called __version__
with open(version_module_path... | def get_version():
"""
Get the version from version module without importing more than
necessary.
"""
version_module_path = os.path.join(
os.path.dirname(__file__), "txspinneret", "_version.py")
# The version module contains a variable called __version__
with open(version_module_path... | [
"Get",
"the",
"version",
"from",
"version",
"module",
"without",
"importing",
"more",
"than",
"necessary",
"."
] | jonathanj/txspinneret | python | https://github.com/jonathanj/txspinneret/blob/717008a2c313698984a23e3f3fc62ea3675ed02d/setup.py#L7-L17 | [
"def",
"get_version",
"(",
")",
":",
"version_module_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"\"txspinneret\"",
",",
"\"_version.py\"",
")",
"# The version module contains a variable called __v... | 717008a2c313698984a23e3f3fc62ea3675ed02d |
valid | TX.send | send a transaction immediately. Failed transactions are picked up by the TxBroadcaster
:param ip: specific peer IP to send tx to
:param port: port of specific peer
:param use_open_peers: use Arky's broadcast method | ark/transactions.py | def send(self, use_open_peers=True, queue=True, **kw):
"""
send a transaction immediately. Failed transactions are picked up by the TxBroadcaster
:param ip: specific peer IP to send tx to
:param port: port of specific peer
:param use_open_peers: use Arky's broadcast method
... | def send(self, use_open_peers=True, queue=True, **kw):
"""
send a transaction immediately. Failed transactions are picked up by the TxBroadcaster
:param ip: specific peer IP to send tx to
:param port: port of specific peer
:param use_open_peers: use Arky's broadcast method
... | [
"send",
"a",
"transaction",
"immediately",
".",
"Failed",
"transactions",
"are",
"picked",
"up",
"by",
"the",
"TxBroadcaster"
] | BlockHub/django-ark | python | https://github.com/BlockHub/django-ark/blob/424c3b4f258ba756aa63b2da185d0c0ef946f75f/ark/transactions.py#L43-L75 | [
"def",
"send",
"(",
"self",
",",
"use_open_peers",
"=",
"True",
",",
"queue",
"=",
"True",
",",
"*",
"*",
"kw",
")",
":",
"if",
"not",
"use_open_peers",
":",
"ip",
"=",
"kw",
".",
"get",
"(",
"'ip'",
")",
"port",
"=",
"kw",
".",
"get",
"(",
"'p... | 424c3b4f258ba756aa63b2da185d0c0ef946f75f |
valid | TX.check_confirmations_or_resend | check if a tx is confirmed, else resend it.
:param use_open_peers: select random peers fro api/peers endpoint | ark/transactions.py | def check_confirmations_or_resend(self, use_open_peers=False, **kw):
"""
check if a tx is confirmed, else resend it.
:param use_open_peers: select random peers fro api/peers endpoint
"""
if self.confirmations() == 0:
self.send(use_open_peers, **kw) | def check_confirmations_or_resend(self, use_open_peers=False, **kw):
"""
check if a tx is confirmed, else resend it.
:param use_open_peers: select random peers fro api/peers endpoint
"""
if self.confirmations() == 0:
self.send(use_open_peers, **kw) | [
"check",
"if",
"a",
"tx",
"is",
"confirmed",
"else",
"resend",
"it",
"."
] | BlockHub/django-ark | python | https://github.com/BlockHub/django-ark/blob/424c3b4f258ba756aa63b2da185d0c0ef946f75f/ark/transactions.py#L89-L96 | [
"def",
"check_confirmations_or_resend",
"(",
"self",
",",
"use_open_peers",
"=",
"False",
",",
"*",
"*",
"kw",
")",
":",
"if",
"self",
".",
"confirmations",
"(",
")",
"==",
"0",
":",
"self",
".",
"send",
"(",
"use_open_peers",
",",
"*",
"*",
"kw",
")"
... | 424c3b4f258ba756aa63b2da185d0c0ef946f75f |
valid | command_list | Get sub-command list
.. note::
Don't use logger handle this function errors.
Because the error should be a code error,not runtime error.
:return: `list` matched sub-parser | cliez/parser.py | def command_list():
"""
Get sub-command list
.. note::
Don't use logger handle this function errors.
Because the error should be a code error,not runtime error.
:return: `list` matched sub-parser
"""
from cliez.conf import COMPONENT_ROOT
root = COMPONENT_ROOT
if ro... | def command_list():
"""
Get sub-command list
.. note::
Don't use logger handle this function errors.
Because the error should be a code error,not runtime error.
:return: `list` matched sub-parser
"""
from cliez.conf import COMPONENT_ROOT
root = COMPONENT_ROOT
if ro... | [
"Get",
"sub",
"-",
"command",
"list"
] | wangwenpei/cliez | python | https://github.com/wangwenpei/cliez/blob/d6fe775544cd380735c56c8a4a79bc2ad22cb6c4/cliez/parser.py#L20-L53 | [
"def",
"command_list",
"(",
")",
":",
"from",
"cliez",
".",
"conf",
"import",
"COMPONENT_ROOT",
"root",
"=",
"COMPONENT_ROOT",
"if",
"root",
"is",
"None",
":",
"sys",
".",
"stderr",
".",
"write",
"(",
"\"cliez.conf.COMPONENT_ROOT not set.\\n\"",
")",
"sys",
".... | d6fe775544cd380735c56c8a4a79bc2ad22cb6c4 |
valid | append_arguments | Add class options to argparser options.
:param cliez.component.Component klass: subclass of Component
:param Namespace sub_parsers:
:param str default_epilog: default_epilog
:param list general_arguments: global options, defined by user
:return: Namespace subparser | cliez/parser.py | def append_arguments(klass, sub_parsers, default_epilog, general_arguments):
"""
Add class options to argparser options.
:param cliez.component.Component klass: subclass of Component
:param Namespace sub_parsers:
:param str default_epilog: default_epilog
:param list general_arguments: global op... | def append_arguments(klass, sub_parsers, default_epilog, general_arguments):
"""
Add class options to argparser options.
:param cliez.component.Component klass: subclass of Component
:param Namespace sub_parsers:
:param str default_epilog: default_epilog
:param list general_arguments: global op... | [
"Add",
"class",
"options",
"to",
"argparser",
"options",
"."
] | wangwenpei/cliez | python | https://github.com/wangwenpei/cliez/blob/d6fe775544cd380735c56c8a4a79bc2ad22cb6c4/cliez/parser.py#L56-L97 | [
"def",
"append_arguments",
"(",
"klass",
",",
"sub_parsers",
",",
"default_epilog",
",",
"general_arguments",
")",
":",
"entry_name",
"=",
"hump_to_underscore",
"(",
"klass",
".",
"__name__",
")",
".",
"replace",
"(",
"'_component'",
",",
"''",
")",
"# set sub c... | d6fe775544cd380735c56c8a4a79bc2ad22cb6c4 |
valid | parse | parser cliez app
:param argparse.ArgumentParser parser: an instance
of argparse.ArgumentParser
:param argv: argument list,default is `sys.argv`
:type argv: list or tuple
:param str settings: settings option name,
default is settings.
:param object no_args_func: a callable object.i... | cliez/parser.py | def parse(parser, argv=None, settings_key='settings', no_args_func=None):
"""
parser cliez app
:param argparse.ArgumentParser parser: an instance
of argparse.ArgumentParser
:param argv: argument list,default is `sys.argv`
:type argv: list or tuple
:param str settings: settings option n... | def parse(parser, argv=None, settings_key='settings', no_args_func=None):
"""
parser cliez app
:param argparse.ArgumentParser parser: an instance
of argparse.ArgumentParser
:param argv: argument list,default is `sys.argv`
:type argv: list or tuple
:param str settings: settings option n... | [
"parser",
"cliez",
"app"
] | wangwenpei/cliez | python | https://github.com/wangwenpei/cliez/blob/d6fe775544cd380735c56c8a4a79bc2ad22cb6c4/cliez/parser.py#L100-L202 | [
"def",
"parse",
"(",
"parser",
",",
"argv",
"=",
"None",
",",
"settings_key",
"=",
"'settings'",
",",
"no_args_func",
"=",
"None",
")",
":",
"argv",
"=",
"argv",
"or",
"sys",
".",
"argv",
"commands",
"=",
"command_list",
"(",
")",
"if",
"type",
"(",
... | d6fe775544cd380735c56c8a4a79bc2ad22cb6c4 |
valid | include_file | .. deprecated 2.1::
Don't use this any more.
It's not pythonic.
include file like php include.
include is very useful when we need to split large config file | cliez/utils.py | def include_file(filename, global_vars=None, local_vars=None):
"""
.. deprecated 2.1::
Don't use this any more.
It's not pythonic.
include file like php include.
include is very useful when we need to split large config file
"""
if global_vars is None:
global_vars = s... | def include_file(filename, global_vars=None, local_vars=None):
"""
.. deprecated 2.1::
Don't use this any more.
It's not pythonic.
include file like php include.
include is very useful when we need to split large config file
"""
if global_vars is None:
global_vars = s... | [
"..",
"deprecated",
"2",
".",
"1",
"::",
"Don",
"t",
"use",
"this",
"any",
"more",
"."
] | wangwenpei/cliez | python | https://github.com/wangwenpei/cliez/blob/d6fe775544cd380735c56c8a4a79bc2ad22cb6c4/cliez/utils.py#L5-L25 | [
"def",
"include_file",
"(",
"filename",
",",
"global_vars",
"=",
"None",
",",
"local_vars",
"=",
"None",
")",
":",
"if",
"global_vars",
"is",
"None",
":",
"global_vars",
"=",
"sys",
".",
"_getframe",
"(",
"1",
")",
".",
"f_globals",
"if",
"local_vars",
"... | d6fe775544cd380735c56c8a4a79bc2ad22cb6c4 |
valid | hump_to_underscore | Convert Hump style to underscore
:param name: Hump Character
:return: str | cliez/utils.py | def hump_to_underscore(name):
"""
Convert Hump style to underscore
:param name: Hump Character
:return: str
"""
new_name = ''
pos = 0
for c in name:
if pos == 0:
new_name = c.lower()
elif 65 <= ord(c) <= 90:
new_name += '_' + c.lower()
... | def hump_to_underscore(name):
"""
Convert Hump style to underscore
:param name: Hump Character
:return: str
"""
new_name = ''
pos = 0
for c in name:
if pos == 0:
new_name = c.lower()
elif 65 <= ord(c) <= 90:
new_name += '_' + c.lower()
... | [
"Convert",
"Hump",
"style",
"to",
"underscore"
] | wangwenpei/cliez | python | https://github.com/wangwenpei/cliez/blob/d6fe775544cd380735c56c8a4a79bc2ad22cb6c4/cliez/utils.py#L28-L48 | [
"def",
"hump_to_underscore",
"(",
"name",
")",
":",
"new_name",
"=",
"''",
"pos",
"=",
"0",
"for",
"c",
"in",
"name",
":",
"if",
"pos",
"==",
"0",
":",
"new_name",
"=",
"c",
".",
"lower",
"(",
")",
"elif",
"65",
"<=",
"ord",
"(",
"c",
")",
"<="... | d6fe775544cd380735c56c8a4a79bc2ad22cb6c4 |
valid | FuelCheckClient.get_fuel_prices | Fetches fuel prices for all stations. | nsw_fuel/client.py | def get_fuel_prices(self) -> GetFuelPricesResponse:
"""Fetches fuel prices for all stations."""
response = requests.get(
'{}/prices'.format(API_URL_BASE),
headers=self._get_headers(),
timeout=self._timeout,
)
if not response.ok:
raise Fuel... | def get_fuel_prices(self) -> GetFuelPricesResponse:
"""Fetches fuel prices for all stations."""
response = requests.get(
'{}/prices'.format(API_URL_BASE),
headers=self._get_headers(),
timeout=self._timeout,
)
if not response.ok:
raise Fuel... | [
"Fetches",
"fuel",
"prices",
"for",
"all",
"stations",
"."
] | nickw444/nsw-fuel-api-client | python | https://github.com/nickw444/nsw-fuel-api-client/blob/06bd9ae7ad094d5965fce3a9468785247e1b5a39/nsw_fuel/client.py#L34-L45 | [
"def",
"get_fuel_prices",
"(",
"self",
")",
"->",
"GetFuelPricesResponse",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"'{}/prices'",
".",
"format",
"(",
"API_URL_BASE",
")",
",",
"headers",
"=",
"self",
".",
"_get_headers",
"(",
")",
",",
"timeout",
... | 06bd9ae7ad094d5965fce3a9468785247e1b5a39 |
valid | FuelCheckClient.get_fuel_prices_for_station | Gets the fuel prices for a specific fuel station. | nsw_fuel/client.py | def get_fuel_prices_for_station(
self,
station: int
) -> List[Price]:
"""Gets the fuel prices for a specific fuel station."""
response = requests.get(
'{}/prices/station/{}'.format(API_URL_BASE, station),
headers=self._get_headers(),
timeou... | def get_fuel_prices_for_station(
self,
station: int
) -> List[Price]:
"""Gets the fuel prices for a specific fuel station."""
response = requests.get(
'{}/prices/station/{}'.format(API_URL_BASE, station),
headers=self._get_headers(),
timeou... | [
"Gets",
"the",
"fuel",
"prices",
"for",
"a",
"specific",
"fuel",
"station",
"."
] | nickw444/nsw-fuel-api-client | python | https://github.com/nickw444/nsw-fuel-api-client/blob/06bd9ae7ad094d5965fce3a9468785247e1b5a39/nsw_fuel/client.py#L47-L62 | [
"def",
"get_fuel_prices_for_station",
"(",
"self",
",",
"station",
":",
"int",
")",
"->",
"List",
"[",
"Price",
"]",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"'{}/prices/station/{}'",
".",
"format",
"(",
"API_URL_BASE",
",",
"station",
")",
",",
... | 06bd9ae7ad094d5965fce3a9468785247e1b5a39 |
valid | FuelCheckClient.get_fuel_prices_within_radius | Gets all the fuel prices within the specified radius. | nsw_fuel/client.py | def get_fuel_prices_within_radius(
self, latitude: float, longitude: float, radius: int,
fuel_type: str, brands: Optional[List[str]] = None
) -> List[StationPrice]:
"""Gets all the fuel prices within the specified radius."""
if brands is None:
brands = []
... | def get_fuel_prices_within_radius(
self, latitude: float, longitude: float, radius: int,
fuel_type: str, brands: Optional[List[str]] = None
) -> List[StationPrice]:
"""Gets all the fuel prices within the specified radius."""
if brands is None:
brands = []
... | [
"Gets",
"all",
"the",
"fuel",
"prices",
"within",
"the",
"specified",
"radius",
"."
] | nickw444/nsw-fuel-api-client | python | https://github.com/nickw444/nsw-fuel-api-client/blob/06bd9ae7ad094d5965fce3a9468785247e1b5a39/nsw_fuel/client.py#L64-L101 | [
"def",
"get_fuel_prices_within_radius",
"(",
"self",
",",
"latitude",
":",
"float",
",",
"longitude",
":",
"float",
",",
"radius",
":",
"int",
",",
"fuel_type",
":",
"str",
",",
"brands",
":",
"Optional",
"[",
"List",
"[",
"str",
"]",
"]",
"=",
"None",
... | 06bd9ae7ad094d5965fce3a9468785247e1b5a39 |
valid | FuelCheckClient.get_fuel_price_trends | Gets the fuel price trends for the given location and fuel types. | nsw_fuel/client.py | def get_fuel_price_trends(self, latitude: float, longitude: float,
fuel_types: List[str]) -> PriceTrends:
"""Gets the fuel price trends for the given location and fuel types."""
response = requests.post(
'{}/prices/trends/'.format(API_URL_BASE),
json... | def get_fuel_price_trends(self, latitude: float, longitude: float,
fuel_types: List[str]) -> PriceTrends:
"""Gets the fuel price trends for the given location and fuel types."""
response = requests.post(
'{}/prices/trends/'.format(API_URL_BASE),
json... | [
"Gets",
"the",
"fuel",
"price",
"trends",
"for",
"the",
"given",
"location",
"and",
"fuel",
"types",
"."
] | nickw444/nsw-fuel-api-client | python | https://github.com/nickw444/nsw-fuel-api-client/blob/06bd9ae7ad094d5965fce3a9468785247e1b5a39/nsw_fuel/client.py#L103-L132 | [
"def",
"get_fuel_price_trends",
"(",
"self",
",",
"latitude",
":",
"float",
",",
"longitude",
":",
"float",
",",
"fuel_types",
":",
"List",
"[",
"str",
"]",
")",
"->",
"PriceTrends",
":",
"response",
"=",
"requests",
".",
"post",
"(",
"'{}/prices/trends/'",
... | 06bd9ae7ad094d5965fce3a9468785247e1b5a39 |
valid | FuelCheckClient.get_reference_data | Fetches API reference data.
:param modified_since: The response will be empty if no
changes have been made to the reference data since this
timestamp, otherwise all reference data will be returned. | nsw_fuel/client.py | def get_reference_data(
self,
modified_since: Optional[datetime.datetime] = None
) -> GetReferenceDataResponse:
"""
Fetches API reference data.
:param modified_since: The response will be empty if no
changes have been made to the reference data since this
... | def get_reference_data(
self,
modified_since: Optional[datetime.datetime] = None
) -> GetReferenceDataResponse:
"""
Fetches API reference data.
:param modified_since: The response will be empty if no
changes have been made to the reference data since this
... | [
"Fetches",
"API",
"reference",
"data",
"."
] | nickw444/nsw-fuel-api-client | python | https://github.com/nickw444/nsw-fuel-api-client/blob/06bd9ae7ad094d5965fce3a9468785247e1b5a39/nsw_fuel/client.py#L134-L162 | [
"def",
"get_reference_data",
"(",
"self",
",",
"modified_since",
":",
"Optional",
"[",
"datetime",
".",
"datetime",
"]",
"=",
"None",
")",
"->",
"GetReferenceDataResponse",
":",
"if",
"modified_since",
"is",
"None",
":",
"modified_since",
"=",
"datetime",
".",
... | 06bd9ae7ad094d5965fce3a9468785247e1b5a39 |
valid | RequireConfigMixin.parse_require | check and get require config
:param dict env: user config node
:param list keys: check keys
.. note::
option and key name must be same.
:param dict defaults: default value for keys
:return: dict.env with verified.
.. exception::
will r... | cliez/mixins.py | def parse_require(self, env, keys, defaults={}):
"""
check and get require config
:param dict env: user config node
:param list keys: check keys
.. note::
option and key name must be same.
:param dict defaults: default value for keys
:return:... | def parse_require(self, env, keys, defaults={}):
"""
check and get require config
:param dict env: user config node
:param list keys: check keys
.. note::
option and key name must be same.
:param dict defaults: default value for keys
:return:... | [
"check",
"and",
"get",
"require",
"config",
":",
"param",
"dict",
"env",
":",
"user",
"config",
"node",
":",
"param",
"list",
"keys",
":",
"check",
"keys",
"..",
"note",
"::"
] | wangwenpei/cliez | python | https://github.com/wangwenpei/cliez/blob/d6fe775544cd380735c56c8a4a79bc2ad22cb6c4/cliez/mixins.py#L55-L86 | [
"def",
"parse_require",
"(",
"self",
",",
"env",
",",
"keys",
",",
"defaults",
"=",
"{",
"}",
")",
":",
"for",
"k",
"in",
"keys",
":",
"env",
"[",
"k",
"]",
"=",
"getattr",
"(",
"self",
".",
"options",
",",
"k",
")",
"or",
"env",
".",
"get",
... | d6fe775544cd380735c56c8a4a79bc2ad22cb6c4 |
valid | PyTemplate.pre | Called before template is applied. | python_template/newmodule.py | def pre(self, command, output_dir, vars):
"""
Called before template is applied.
"""
# import pdb;pdb.set_trace()
vars['license_name'] = 'Apache'
vars['year'] = time.strftime('%Y', time.localtime()) | def pre(self, command, output_dir, vars):
"""
Called before template is applied.
"""
# import pdb;pdb.set_trace()
vars['license_name'] = 'Apache'
vars['year'] = time.strftime('%Y', time.localtime()) | [
"Called",
"before",
"template",
"is",
"applied",
"."
] | jonEbird/standard-paster | python | https://github.com/jonEbird/standard-paster/blob/2edc12893e488c7ac77b66683d9e62a0f2822f35/python_template/newmodule.py#L27-L33 | [
"def",
"pre",
"(",
"self",
",",
"command",
",",
"output_dir",
",",
"vars",
")",
":",
"# import pdb;pdb.set_trace()",
"vars",
"[",
"'license_name'",
"]",
"=",
"'Apache'",
"vars",
"[",
"'year'",
"]",
"=",
"time",
".",
"strftime",
"(",
"'%Y'",
",",
"time",
... | 2edc12893e488c7ac77b66683d9e62a0f2822f35 |
valid | Text | Match a route parameter.
`Any` is a synonym for `Text`.
:type name: `bytes`
:param name: Route parameter name.
:type encoding: `bytes`
:param encoding: Default encoding to assume if the ``Content-Type``
header is lacking one.
:return: ``callable`` suitable for use with `route` or `... | txspinneret/route.py | def Text(name, encoding=None):
"""
Match a route parameter.
`Any` is a synonym for `Text`.
:type name: `bytes`
:param name: Route parameter name.
:type encoding: `bytes`
:param encoding: Default encoding to assume if the ``Content-Type``
header is lacking one.
:return: ``ca... | def Text(name, encoding=None):
"""
Match a route parameter.
`Any` is a synonym for `Text`.
:type name: `bytes`
:param name: Route parameter name.
:type encoding: `bytes`
:param encoding: Default encoding to assume if the ``Content-Type``
header is lacking one.
:return: ``ca... | [
"Match",
"a",
"route",
"parameter",
"."
] | jonathanj/txspinneret | python | https://github.com/jonathanj/txspinneret/blob/717008a2c313698984a23e3f3fc62ea3675ed02d/txspinneret/route.py#L31-L50 | [
"def",
"Text",
"(",
"name",
",",
"encoding",
"=",
"None",
")",
":",
"def",
"_match",
"(",
"request",
",",
"value",
")",
":",
"return",
"name",
",",
"query",
".",
"Text",
"(",
"value",
",",
"encoding",
"=",
"contentEncoding",
"(",
"request",
".",
"req... | 717008a2c313698984a23e3f3fc62ea3675ed02d |
valid | Integer | Match an integer route parameter.
:type name: `bytes`
:param name: Route parameter name.
:type base: `int`
:param base: Base to interpret the value in.
:type encoding: `bytes`
:param encoding: Default encoding to assume if the ``Content-Type``
header is lacking one.
:return: `... | txspinneret/route.py | def Integer(name, base=10, encoding=None):
"""
Match an integer route parameter.
:type name: `bytes`
:param name: Route parameter name.
:type base: `int`
:param base: Base to interpret the value in.
:type encoding: `bytes`
:param encoding: Default encoding to assume if the ``Conten... | def Integer(name, base=10, encoding=None):
"""
Match an integer route parameter.
:type name: `bytes`
:param name: Route parameter name.
:type base: `int`
:param base: Base to interpret the value in.
:type encoding: `bytes`
:param encoding: Default encoding to assume if the ``Conten... | [
"Match",
"an",
"integer",
"route",
"parameter",
"."
] | jonathanj/txspinneret | python | https://github.com/jonathanj/txspinneret/blob/717008a2c313698984a23e3f3fc62ea3675ed02d/txspinneret/route.py#L58-L79 | [
"def",
"Integer",
"(",
"name",
",",
"base",
"=",
"10",
",",
"encoding",
"=",
"None",
")",
":",
"def",
"_match",
"(",
"request",
",",
"value",
")",
":",
"return",
"name",
",",
"query",
".",
"Integer",
"(",
"value",
",",
"base",
"=",
"base",
",",
"... | 717008a2c313698984a23e3f3fc62ea3675ed02d |
valid | _matchRoute | Match a request path against our path components.
The path components are always matched relative to their parent is in the
resource hierarchy, in other words it is only possible to match URIs nested
more deeply than the parent resource.
:type components: ``iterable`` of `bytes` or `callable`
:pa... | txspinneret/route.py | def _matchRoute(components, request, segments, partialMatching):
"""
Match a request path against our path components.
The path components are always matched relative to their parent is in the
resource hierarchy, in other words it is only possible to match URIs nested
more deeply than the parent re... | def _matchRoute(components, request, segments, partialMatching):
"""
Match a request path against our path components.
The path components are always matched relative to their parent is in the
resource hierarchy, in other words it is only possible to match URIs nested
more deeply than the parent re... | [
"Match",
"a",
"request",
"path",
"against",
"our",
"path",
"components",
"."
] | jonathanj/txspinneret | python | https://github.com/jonathanj/txspinneret/blob/717008a2c313698984a23e3f3fc62ea3675ed02d/txspinneret/route.py#L83-L147 | [
"def",
"_matchRoute",
"(",
"components",
",",
"request",
",",
"segments",
",",
"partialMatching",
")",
":",
"if",
"len",
"(",
"components",
")",
"==",
"1",
"and",
"isinstance",
"(",
"components",
"[",
"0",
"]",
",",
"bytes",
")",
":",
"components",
"=",
... | 717008a2c313698984a23e3f3fc62ea3675ed02d |
valid | routedResource | Decorate a router-producing callable to instead produce a resource.
This simply produces a new callable that invokes the original callable, and
calls ``resource`` on the ``routerAttribute``.
If the router producer has multiple routers the attribute can be altered to
choose the appropriate one, for exa... | txspinneret/route.py | def routedResource(f, routerAttribute='router'):
"""
Decorate a router-producing callable to instead produce a resource.
This simply produces a new callable that invokes the original callable, and
calls ``resource`` on the ``routerAttribute``.
If the router producer has multiple routers the attrib... | def routedResource(f, routerAttribute='router'):
"""
Decorate a router-producing callable to instead produce a resource.
This simply produces a new callable that invokes the original callable, and
calls ``resource`` on the ``routerAttribute``.
If the router producer has multiple routers the attrib... | [
"Decorate",
"a",
"router",
"-",
"producing",
"callable",
"to",
"instead",
"produce",
"a",
"resource",
"."
] | jonathanj/txspinneret | python | https://github.com/jonathanj/txspinneret/blob/717008a2c313698984a23e3f3fc62ea3675ed02d/txspinneret/route.py#L336-L375 | [
"def",
"routedResource",
"(",
"f",
",",
"routerAttribute",
"=",
"'router'",
")",
":",
"return",
"wraps",
"(",
"f",
")",
"(",
"lambda",
"*",
"a",
",",
"*",
"*",
"kw",
":",
"getattr",
"(",
"f",
"(",
"*",
"a",
",",
"*",
"*",
"kw",
")",
",",
"route... | 717008a2c313698984a23e3f3fc62ea3675ed02d |
valid | Router._forObject | Create a new `Router` instance, with it's own set of routes, for
``obj``. | txspinneret/route.py | def _forObject(self, obj):
"""
Create a new `Router` instance, with it's own set of routes, for
``obj``.
"""
router = type(self)()
router._routes = list(self._routes)
router._self = obj
return router | def _forObject(self, obj):
"""
Create a new `Router` instance, with it's own set of routes, for
``obj``.
"""
router = type(self)()
router._routes = list(self._routes)
router._self = obj
return router | [
"Create",
"a",
"new",
"Router",
"instance",
"with",
"it",
"s",
"own",
"set",
"of",
"routes",
"for",
"obj",
"."
] | jonathanj/txspinneret | python | https://github.com/jonathanj/txspinneret/blob/717008a2c313698984a23e3f3fc62ea3675ed02d/txspinneret/route.py#L277-L285 | [
"def",
"_forObject",
"(",
"self",
",",
"obj",
")",
":",
"router",
"=",
"type",
"(",
"self",
")",
"(",
")",
"router",
".",
"_routes",
"=",
"list",
"(",
"self",
".",
"_routes",
")",
"router",
".",
"_self",
"=",
"obj",
"return",
"router"
] | 717008a2c313698984a23e3f3fc62ea3675ed02d |
valid | Router._addRoute | Add a route handler and matcher to the collection of possible routes. | txspinneret/route.py | def _addRoute(self, f, matcher):
"""
Add a route handler and matcher to the collection of possible routes.
"""
self._routes.append((f.func_name, f, matcher)) | def _addRoute(self, f, matcher):
"""
Add a route handler and matcher to the collection of possible routes.
"""
self._routes.append((f.func_name, f, matcher)) | [
"Add",
"a",
"route",
"handler",
"and",
"matcher",
"to",
"the",
"collection",
"of",
"possible",
"routes",
"."
] | jonathanj/txspinneret | python | https://github.com/jonathanj/txspinneret/blob/717008a2c313698984a23e3f3fc62ea3675ed02d/txspinneret/route.py#L294-L298 | [
"def",
"_addRoute",
"(",
"self",
",",
"f",
",",
"matcher",
")",
":",
"self",
".",
"_routes",
".",
"append",
"(",
"(",
"f",
".",
"func_name",
",",
"f",
",",
"matcher",
")",
")"
] | 717008a2c313698984a23e3f3fc62ea3675ed02d |
valid | Router.route | See `txspinneret.route.route`.
This decorator can be stacked with itself to specify multiple routes
with a single handler. | txspinneret/route.py | def route(self, *components):
"""
See `txspinneret.route.route`.
This decorator can be stacked with itself to specify multiple routes
with a single handler.
"""
def _factory(f):
self._addRoute(f, route(*components))
return f
return _factor... | def route(self, *components):
"""
See `txspinneret.route.route`.
This decorator can be stacked with itself to specify multiple routes
with a single handler.
"""
def _factory(f):
self._addRoute(f, route(*components))
return f
return _factor... | [
"See",
"txspinneret",
".",
"route",
".",
"route",
"."
] | jonathanj/txspinneret | python | https://github.com/jonathanj/txspinneret/blob/717008a2c313698984a23e3f3fc62ea3675ed02d/txspinneret/route.py#L309-L319 | [
"def",
"route",
"(",
"self",
",",
"*",
"components",
")",
":",
"def",
"_factory",
"(",
"f",
")",
":",
"self",
".",
"_addRoute",
"(",
"f",
",",
"route",
"(",
"*",
"components",
")",
")",
"return",
"f",
"return",
"_factory"
] | 717008a2c313698984a23e3f3fc62ea3675ed02d |
valid | Router.subroute | See `txspinneret.route.subroute`.
This decorator can be stacked with itself to specify multiple routes
with a single handler. | txspinneret/route.py | def subroute(self, *components):
"""
See `txspinneret.route.subroute`.
This decorator can be stacked with itself to specify multiple routes
with a single handler.
"""
def _factory(f):
self._addRoute(f, subroute(*components))
return f
retur... | def subroute(self, *components):
"""
See `txspinneret.route.subroute`.
This decorator can be stacked with itself to specify multiple routes
with a single handler.
"""
def _factory(f):
self._addRoute(f, subroute(*components))
return f
retur... | [
"See",
"txspinneret",
".",
"route",
".",
"subroute",
"."
] | jonathanj/txspinneret | python | https://github.com/jonathanj/txspinneret/blob/717008a2c313698984a23e3f3fc62ea3675ed02d/txspinneret/route.py#L322-L332 | [
"def",
"subroute",
"(",
"self",
",",
"*",
"components",
")",
":",
"def",
"_factory",
"(",
"f",
")",
":",
"self",
".",
"_addRoute",
"(",
"f",
",",
"subroute",
"(",
"*",
"components",
")",
")",
"return",
"f",
"return",
"_factory"
] | 717008a2c313698984a23e3f3fc62ea3675ed02d |
valid | _tempfile | Create a NamedTemporaryFile instance to be passed to atomic_writer | json_storage_manager/atomic.py | def _tempfile(filename):
"""
Create a NamedTemporaryFile instance to be passed to atomic_writer
"""
return tempfile.NamedTemporaryFile(mode='w',
dir=os.path.dirname(filename),
prefix=os.path.basename(filename),
... | def _tempfile(filename):
"""
Create a NamedTemporaryFile instance to be passed to atomic_writer
"""
return tempfile.NamedTemporaryFile(mode='w',
dir=os.path.dirname(filename),
prefix=os.path.basename(filename),
... | [
"Create",
"a",
"NamedTemporaryFile",
"instance",
"to",
"be",
"passed",
"to",
"atomic_writer"
] | hefnawi/json-storage-manager | python | https://github.com/hefnawi/json-storage-manager/blob/c7521fc4a576cf23a8c2454106bed6fb8c951b8d/json_storage_manager/atomic.py#L9-L17 | [
"def",
"_tempfile",
"(",
"filename",
")",
":",
"return",
"tempfile",
".",
"NamedTemporaryFile",
"(",
"mode",
"=",
"'w'",
",",
"dir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"filename",
")",
",",
"prefix",
"=",
"os",
".",
"path",
".",
"basename",
... | c7521fc4a576cf23a8c2454106bed6fb8c951b8d |
valid | atomic_write | Open a NamedTemoraryFile handle in a context manager | json_storage_manager/atomic.py | def atomic_write(filename):
"""
Open a NamedTemoraryFile handle in a context manager
"""
f = _tempfile(os.fsencode(filename))
try:
yield f
finally:
f.close()
# replace the original file with the new temp file (atomic on success)
os.replace(f.name, filename) | def atomic_write(filename):
"""
Open a NamedTemoraryFile handle in a context manager
"""
f = _tempfile(os.fsencode(filename))
try:
yield f
finally:
f.close()
# replace the original file with the new temp file (atomic on success)
os.replace(f.name, filename) | [
"Open",
"a",
"NamedTemoraryFile",
"handle",
"in",
"a",
"context",
"manager"
] | hefnawi/json-storage-manager | python | https://github.com/hefnawi/json-storage-manager/blob/c7521fc4a576cf23a8c2454106bed6fb8c951b8d/json_storage_manager/atomic.py#L21-L33 | [
"def",
"atomic_write",
"(",
"filename",
")",
":",
"f",
"=",
"_tempfile",
"(",
"os",
".",
"fsencode",
"(",
"filename",
")",
")",
"try",
":",
"yield",
"f",
"finally",
":",
"f",
".",
"close",
"(",
")",
"# replace the original file with the new temp file (atomic o... | c7521fc4a576cf23a8c2454106bed6fb8c951b8d |
valid | get_item | Read entry from JSON file | json_storage_manager/atomic.py | def get_item(filename, uuid):
"""
Read entry from JSON file
"""
with open(os.fsencode(str(filename)), "r") as f:
data = json.load(f)
results = [i for i in data if i["uuid"] == str(uuid)]
if results:
return results
return None | def get_item(filename, uuid):
"""
Read entry from JSON file
"""
with open(os.fsencode(str(filename)), "r") as f:
data = json.load(f)
results = [i for i in data if i["uuid"] == str(uuid)]
if results:
return results
return None | [
"Read",
"entry",
"from",
"JSON",
"file"
] | hefnawi/json-storage-manager | python | https://github.com/hefnawi/json-storage-manager/blob/c7521fc4a576cf23a8c2454106bed6fb8c951b8d/json_storage_manager/atomic.py#L36-L45 | [
"def",
"get_item",
"(",
"filename",
",",
"uuid",
")",
":",
"with",
"open",
"(",
"os",
".",
"fsencode",
"(",
"str",
"(",
"filename",
")",
")",
",",
"\"r\"",
")",
"as",
"f",
":",
"data",
"=",
"json",
".",
"load",
"(",
"f",
")",
"results",
"=",
"[... | c7521fc4a576cf23a8c2454106bed6fb8c951b8d |
valid | set_item | Save entry to JSON file | json_storage_manager/atomic.py | def set_item(filename, item):
"""
Save entry to JSON file
"""
with atomic_write(os.fsencode(str(filename))) as temp_file:
with open(os.fsencode(str(filename))) as products_file:
# load the JSON data into memory
products_data = json.load(products_file)
# check if U... | def set_item(filename, item):
"""
Save entry to JSON file
"""
with atomic_write(os.fsencode(str(filename))) as temp_file:
with open(os.fsencode(str(filename))) as products_file:
# load the JSON data into memory
products_data = json.load(products_file)
# check if U... | [
"Save",
"entry",
"to",
"JSON",
"file"
] | hefnawi/json-storage-manager | python | https://github.com/hefnawi/json-storage-manager/blob/c7521fc4a576cf23a8c2454106bed6fb8c951b8d/json_storage_manager/atomic.py#L48-L65 | [
"def",
"set_item",
"(",
"filename",
",",
"item",
")",
":",
"with",
"atomic_write",
"(",
"os",
".",
"fsencode",
"(",
"str",
"(",
"filename",
")",
")",
")",
"as",
"temp_file",
":",
"with",
"open",
"(",
"os",
".",
"fsencode",
"(",
"str",
"(",
"filename"... | c7521fc4a576cf23a8c2454106bed6fb8c951b8d |
valid | update_item | Update entry by UUID in the JSON file | json_storage_manager/atomic.py | def update_item(filename, item, uuid):
"""
Update entry by UUID in the JSON file
"""
with atomic_write(os.fsencode(str(filename))) as temp_file:
with open(os.fsencode(str(filename))) as products_file:
# load the JSON data into memory
products_data = json.load(products_fil... | def update_item(filename, item, uuid):
"""
Update entry by UUID in the JSON file
"""
with atomic_write(os.fsencode(str(filename))) as temp_file:
with open(os.fsencode(str(filename))) as products_file:
# load the JSON data into memory
products_data = json.load(products_fil... | [
"Update",
"entry",
"by",
"UUID",
"in",
"the",
"JSON",
"file"
] | hefnawi/json-storage-manager | python | https://github.com/hefnawi/json-storage-manager/blob/c7521fc4a576cf23a8c2454106bed6fb8c951b8d/json_storage_manager/atomic.py#L68-L88 | [
"def",
"update_item",
"(",
"filename",
",",
"item",
",",
"uuid",
")",
":",
"with",
"atomic_write",
"(",
"os",
".",
"fsencode",
"(",
"str",
"(",
"filename",
")",
")",
")",
"as",
"temp_file",
":",
"with",
"open",
"(",
"os",
".",
"fsencode",
"(",
"str",... | c7521fc4a576cf23a8c2454106bed6fb8c951b8d |
valid | CheckComponent.run | .. todo::
check network connection
:param Namespace options: parse result from argparse
:return: | cliez/components/check.py | def run(self, options):
"""
.. todo::
check network connection
:param Namespace options: parse result from argparse
:return:
"""
self.logger.debug("debug enabled...")
depends = ['git']
nil_tools = []
self.logger.info("depends list: ... | def run(self, options):
"""
.. todo::
check network connection
:param Namespace options: parse result from argparse
:return:
"""
self.logger.debug("debug enabled...")
depends = ['git']
nil_tools = []
self.logger.info("depends list: ... | [
"..",
"todo",
"::"
] | wangwenpei/cliez | python | https://github.com/wangwenpei/cliez/blob/d6fe775544cd380735c56c8a4a79bc2ad22cb6c4/cliez/components/check.py#L22-L64 | [
"def",
"run",
"(",
"self",
",",
"options",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"\"debug enabled...\"",
")",
"depends",
"=",
"[",
"'git'",
"]",
"nil_tools",
"=",
"[",
"]",
"self",
".",
"logger",
".",
"info",
"(",
"\"depends list: %s\"",
... | d6fe775544cd380735c56c8a4a79bc2ad22cb6c4 |
valid | ExperimentData.experiment_data | :param commit: the commit that all the experiments should have happened or None to include all
:type commit: str
:param must_contain_results: include only tags that contain results
:type must_contain_results: bool
:return: all the experiment data
:rtype: dict | experimenter/data.py | def experiment_data(self, commit=None, must_contain_results=False):
"""
:param commit: the commit that all the experiments should have happened or None to include all
:type commit: str
:param must_contain_results: include only tags that contain results
:type must_contain_results:... | def experiment_data(self, commit=None, must_contain_results=False):
"""
:param commit: the commit that all the experiments should have happened or None to include all
:type commit: str
:param must_contain_results: include only tags that contain results
:type must_contain_results:... | [
":",
"param",
"commit",
":",
"the",
"commit",
"that",
"all",
"the",
"experiments",
"should",
"have",
"happened",
"or",
"None",
"to",
"include",
"all",
":",
"type",
"commit",
":",
"str",
":",
"param",
"must_contain_results",
":",
"include",
"only",
"tags",
... | mallamanis/experimenter | python | https://github.com/mallamanis/experimenter/blob/2ed5ce85084cc47251ccba3aae0cb3431fbe4259/experimenter/data.py#L13-L32 | [
"def",
"experiment_data",
"(",
"self",
",",
"commit",
"=",
"None",
",",
"must_contain_results",
"=",
"False",
")",
":",
"results",
"=",
"{",
"}",
"for",
"tag",
"in",
"self",
".",
"__repository",
".",
"tags",
":",
"if",
"not",
"tag",
".",
"name",
".",
... | 2ed5ce85084cc47251ccba3aae0cb3431fbe4259 |
valid | ExperimentData.delete | Delete an experiment by removing the associated tag.
:param experiment_name: the name of the experiment to be deleted
:type experiment_name: str
:rtype bool
:return if deleting succeeded | experimenter/data.py | def delete(self, experiment_name):
"""
Delete an experiment by removing the associated tag.
:param experiment_name: the name of the experiment to be deleted
:type experiment_name: str
:rtype bool
:return if deleting succeeded
"""
if not experiment_name.sta... | def delete(self, experiment_name):
"""
Delete an experiment by removing the associated tag.
:param experiment_name: the name of the experiment to be deleted
:type experiment_name: str
:rtype bool
:return if deleting succeeded
"""
if not experiment_name.sta... | [
"Delete",
"an",
"experiment",
"by",
"removing",
"the",
"associated",
"tag",
".",
":",
"param",
"experiment_name",
":",
"the",
"name",
"of",
"the",
"experiment",
"to",
"be",
"deleted",
":",
"type",
"experiment_name",
":",
"str",
":",
"rtype",
"bool",
":",
"... | mallamanis/experimenter | python | https://github.com/mallamanis/experimenter/blob/2ed5ce85084cc47251ccba3aae0cb3431fbe4259/experimenter/data.py#L34-L49 | [
"def",
"delete",
"(",
"self",
",",
"experiment_name",
")",
":",
"if",
"not",
"experiment_name",
".",
"startswith",
"(",
"self",
".",
"__tag_prefix",
")",
":",
"target_tag",
"=",
"self",
".",
"__tag_prefix",
"+",
"experiment_name",
"else",
":",
"target_tag",
... | 2ed5ce85084cc47251ccba3aae0cb3431fbe4259 |
valid | main | Register your own mode and handle method here. | scripts/check_ssh.py | def main():
"""Register your own mode and handle method here."""
plugin = Register()
if plugin.args.option == 'command':
plugin.command_handle()
else:
plugin.unknown("Unknown actions.") | def main():
"""Register your own mode and handle method here."""
plugin = Register()
if plugin.args.option == 'command':
plugin.command_handle()
else:
plugin.unknown("Unknown actions.") | [
"Register",
"your",
"own",
"mode",
"and",
"handle",
"method",
"here",
"."
] | crazy-canux/arguspy | python | https://github.com/crazy-canux/arguspy/blob/e9486b5df61978a990d56bf43de35f3a4cdefcc3/scripts/check_ssh.py#L104-L110 | [
"def",
"main",
"(",
")",
":",
"plugin",
"=",
"Register",
"(",
")",
"if",
"plugin",
".",
"args",
".",
"option",
"==",
"'command'",
":",
"plugin",
".",
"command_handle",
"(",
")",
"else",
":",
"plugin",
".",
"unknown",
"(",
"\"Unknown actions.\"",
")"
] | e9486b5df61978a990d56bf43de35f3a4cdefcc3 |
valid | Command.command_handle | Get the number of the shell command. | scripts/check_ssh.py | def command_handle(self):
"""Get the number of the shell command."""
self.__results = self.execute(self.args.command)
self.close()
self.logger.debug("results: {}".format(self.__results))
if not self.__results:
self.unknown("{} return nothing.".format(self.args.comman... | def command_handle(self):
"""Get the number of the shell command."""
self.__results = self.execute(self.args.command)
self.close()
self.logger.debug("results: {}".format(self.__results))
if not self.__results:
self.unknown("{} return nothing.".format(self.args.comman... | [
"Get",
"the",
"number",
"of",
"the",
"shell",
"command",
"."
] | crazy-canux/arguspy | python | https://github.com/crazy-canux/arguspy/blob/e9486b5df61978a990d56bf43de35f3a4cdefcc3/scripts/check_ssh.py#L54-L93 | [
"def",
"command_handle",
"(",
"self",
")",
":",
"self",
".",
"__results",
"=",
"self",
".",
"execute",
"(",
"self",
".",
"args",
".",
"command",
")",
"self",
".",
"close",
"(",
")",
"self",
".",
"logger",
".",
"debug",
"(",
"\"results: {}\"",
".",
"f... | e9486b5df61978a990d56bf43de35f3a4cdefcc3 |
valid | Ssh.execute | Execute a shell command. | arguspy/ssh_paramiko.py | def execute(self, command, timeout=None):
"""Execute a shell command."""
try:
self.channel = self.ssh.get_transport().open_session()
except paramiko.SSHException as e:
self.unknown("Create channel error: %s" % e)
try:
self.channel.settimeout(self.args.... | def execute(self, command, timeout=None):
"""Execute a shell command."""
try:
self.channel = self.ssh.get_transport().open_session()
except paramiko.SSHException as e:
self.unknown("Create channel error: %s" % e)
try:
self.channel.settimeout(self.args.... | [
"Execute",
"a",
"shell",
"command",
"."
] | crazy-canux/arguspy | python | https://github.com/crazy-canux/arguspy/blob/e9486b5df61978a990d56bf43de35f3a4cdefcc3/arguspy/ssh_paramiko.py#L51-L82 | [
"def",
"execute",
"(",
"self",
",",
"command",
",",
"timeout",
"=",
"None",
")",
":",
"try",
":",
"self",
".",
"channel",
"=",
"self",
".",
"ssh",
".",
"get_transport",
"(",
")",
".",
"open_session",
"(",
")",
"except",
"paramiko",
".",
"SSHException",... | e9486b5df61978a990d56bf43de35f3a4cdefcc3 |
valid | Ssh.close | Close and exit the connection. | arguspy/ssh_paramiko.py | def close(self):
"""Close and exit the connection."""
try:
self.ssh.close()
self.logger.debug("close connect succeed.")
except paramiko.SSHException as e:
self.unknown("close connect error: %s" % e) | def close(self):
"""Close and exit the connection."""
try:
self.ssh.close()
self.logger.debug("close connect succeed.")
except paramiko.SSHException as e:
self.unknown("close connect error: %s" % e) | [
"Close",
"and",
"exit",
"the",
"connection",
"."
] | crazy-canux/arguspy | python | https://github.com/crazy-canux/arguspy/blob/e9486b5df61978a990d56bf43de35f3a4cdefcc3/arguspy/ssh_paramiko.py#L84-L90 | [
"def",
"close",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"ssh",
".",
"close",
"(",
")",
"self",
".",
"logger",
".",
"debug",
"(",
"\"close connect succeed.\"",
")",
"except",
"paramiko",
".",
"SSHException",
"as",
"e",
":",
"self",
".",
"unknown... | e9486b5df61978a990d56bf43de35f3a4cdefcc3 |
valid | slinky | Simple program that creates an temp S3 link. | slinky/__init__.py | def slinky(filename, seconds_available, bucket_name, aws_key, aws_secret):
"""Simple program that creates an temp S3 link."""
if not os.environ.get('AWS_ACCESS_KEY_ID') and os.environ.get('AWS_SECRET_ACCESS_KEY'):
print 'Need to set environment variables for AWS access and create a slinky bucket.'
exi... | def slinky(filename, seconds_available, bucket_name, aws_key, aws_secret):
"""Simple program that creates an temp S3 link."""
if not os.environ.get('AWS_ACCESS_KEY_ID') and os.environ.get('AWS_SECRET_ACCESS_KEY'):
print 'Need to set environment variables for AWS access and create a slinky bucket.'
exi... | [
"Simple",
"program",
"that",
"creates",
"an",
"temp",
"S3",
"link",
"."
] | bwghughes/slinky | python | https://github.com/bwghughes/slinky/blob/e9967d4e6a670e3a04dd741f8cd843668dda24bb/slinky/__init__.py#L18-L24 | [
"def",
"slinky",
"(",
"filename",
",",
"seconds_available",
",",
"bucket_name",
",",
"aws_key",
",",
"aws_secret",
")",
":",
"if",
"not",
"os",
".",
"environ",
".",
"get",
"(",
"'AWS_ACCESS_KEY_ID'",
")",
"and",
"os",
".",
"environ",
".",
"get",
"(",
"'A... | e9967d4e6a670e3a04dd741f8cd843668dda24bb |
valid | Process.check_readable | Poll ``self.stdout`` and return True if it is readable.
:param float timeout: seconds to wait I/O
:return: True if readable, else False
:rtype: boolean | headlessvim/process.py | def check_readable(self, timeout):
"""
Poll ``self.stdout`` and return True if it is readable.
:param float timeout: seconds to wait I/O
:return: True if readable, else False
:rtype: boolean
"""
rlist, wlist, xlist = select.select([self._stdout], [], [], timeout)... | def check_readable(self, timeout):
"""
Poll ``self.stdout`` and return True if it is readable.
:param float timeout: seconds to wait I/O
:return: True if readable, else False
:rtype: boolean
"""
rlist, wlist, xlist = select.select([self._stdout], [], [], timeout)... | [
"Poll",
"self",
".",
"stdout",
"and",
"return",
"True",
"if",
"it",
"is",
"readable",
"."
] | manicmaniac/headlessvim | python | https://github.com/manicmaniac/headlessvim/blob/3e4657f95d981ddf21fd285b7e1b9da2154f9cb9/headlessvim/process.py#L50-L59 | [
"def",
"check_readable",
"(",
"self",
",",
"timeout",
")",
":",
"rlist",
",",
"wlist",
",",
"xlist",
"=",
"select",
".",
"select",
"(",
"[",
"self",
".",
"_stdout",
"]",
",",
"[",
"]",
",",
"[",
"]",
",",
"timeout",
")",
"return",
"bool",
"(",
"l... | 3e4657f95d981ddf21fd285b7e1b9da2154f9cb9 |
valid | get_indices_list | Retrieve a list of characters and escape codes where each escape
code uses only one index. The indexes will not match up with the
indexes in the original string. | fmtblock/escapecodes.py | def get_indices_list(s: Any) -> List[str]:
""" Retrieve a list of characters and escape codes where each escape
code uses only one index. The indexes will not match up with the
indexes in the original string.
"""
indices = get_indices(s)
return [
indices[i] for i in sorted(indice... | def get_indices_list(s: Any) -> List[str]:
""" Retrieve a list of characters and escape codes where each escape
code uses only one index. The indexes will not match up with the
indexes in the original string.
"""
indices = get_indices(s)
return [
indices[i] for i in sorted(indice... | [
"Retrieve",
"a",
"list",
"of",
"characters",
"and",
"escape",
"codes",
"where",
"each",
"escape",
"code",
"uses",
"only",
"one",
"index",
".",
"The",
"indexes",
"will",
"not",
"match",
"up",
"with",
"the",
"indexes",
"in",
"the",
"original",
"string",
"."
... | welbornprod/fmtblock | python | https://github.com/welbornprod/fmtblock/blob/92a5529235d557170ed21e058e3c5995197facbe/fmtblock/escapecodes.py#L94-L102 | [
"def",
"get_indices_list",
"(",
"s",
":",
"Any",
")",
"->",
"List",
"[",
"str",
"]",
":",
"indices",
"=",
"get_indices",
"(",
"s",
")",
"return",
"[",
"indices",
"[",
"i",
"]",
"for",
"i",
"in",
"sorted",
"(",
"indices",
",",
"key",
"=",
"int",
"... | 92a5529235d557170ed21e058e3c5995197facbe |
valid | strip_codes | Strip all color codes from a string.
Returns empty string for "falsey" inputs. | fmtblock/escapecodes.py | def strip_codes(s: Any) -> str:
""" Strip all color codes from a string.
Returns empty string for "falsey" inputs.
"""
return codepat.sub('', str(s) if (s or (s == 0)) else '') | def strip_codes(s: Any) -> str:
""" Strip all color codes from a string.
Returns empty string for "falsey" inputs.
"""
return codepat.sub('', str(s) if (s or (s == 0)) else '') | [
"Strip",
"all",
"color",
"codes",
"from",
"a",
"string",
".",
"Returns",
"empty",
"string",
"for",
"falsey",
"inputs",
"."
] | welbornprod/fmtblock | python | https://github.com/welbornprod/fmtblock/blob/92a5529235d557170ed21e058e3c5995197facbe/fmtblock/escapecodes.py#L110-L114 | [
"def",
"strip_codes",
"(",
"s",
":",
"Any",
")",
"->",
"str",
":",
"return",
"codepat",
".",
"sub",
"(",
"''",
",",
"str",
"(",
"s",
")",
"if",
"(",
"s",
"or",
"(",
"s",
"==",
"0",
")",
")",
"else",
"''",
")"
] | 92a5529235d557170ed21e058e3c5995197facbe |
valid | AbstractBundle.init_build | Called when builder group collect files
Resolves absolute url if relative passed
:type asset: static_bundle.builders.Asset
:type builder: static_bundle.builders.StandardBuilder | static_bundle/bundles.py | def init_build(self, asset, builder):
"""
Called when builder group collect files
Resolves absolute url if relative passed
:type asset: static_bundle.builders.Asset
:type builder: static_bundle.builders.StandardBuilder
"""
if not self.abs_path:
rel_pa... | def init_build(self, asset, builder):
"""
Called when builder group collect files
Resolves absolute url if relative passed
:type asset: static_bundle.builders.Asset
:type builder: static_bundle.builders.StandardBuilder
"""
if not self.abs_path:
rel_pa... | [
"Called",
"when",
"builder",
"group",
"collect",
"files",
"Resolves",
"absolute",
"url",
"if",
"relative",
"passed"
] | Rikanishu/static-bundle | python | https://github.com/Rikanishu/static-bundle/blob/2f6458cb9d9d9049b4fd829f7d6951a45d547c68/static_bundle/bundles.py#L48-L60 | [
"def",
"init_build",
"(",
"self",
",",
"asset",
",",
"builder",
")",
":",
"if",
"not",
"self",
".",
"abs_path",
":",
"rel_path",
"=",
"utils",
".",
"prepare_path",
"(",
"self",
".",
"rel_bundle_path",
")",
"self",
".",
"abs_bundle_path",
"=",
"utils",
".... | 2f6458cb9d9d9049b4fd829f7d6951a45d547c68 |
valid | AbstractBundle.add_file | Add single file or list of files to bundle
:type: file_path: str|unicode | static_bundle/bundles.py | def add_file(self, *args):
"""
Add single file or list of files to bundle
:type: file_path: str|unicode
"""
for file_path in args:
self.files.append(FilePath(file_path, self)) | def add_file(self, *args):
"""
Add single file or list of files to bundle
:type: file_path: str|unicode
"""
for file_path in args:
self.files.append(FilePath(file_path, self)) | [
"Add",
"single",
"file",
"or",
"list",
"of",
"files",
"to",
"bundle"
] | Rikanishu/static-bundle | python | https://github.com/Rikanishu/static-bundle/blob/2f6458cb9d9d9049b4fd829f7d6951a45d547c68/static_bundle/bundles.py#L62-L69 | [
"def",
"add_file",
"(",
"self",
",",
"*",
"args",
")",
":",
"for",
"file_path",
"in",
"args",
":",
"self",
".",
"files",
".",
"append",
"(",
"FilePath",
"(",
"file_path",
",",
"self",
")",
")"
] | 2f6458cb9d9d9049b4fd829f7d6951a45d547c68 |
valid | AbstractBundle.add_directory | Add directory or directories list to bundle
:param exclusions: List of excluded paths
:type path: str|unicode
:type exclusions: list | static_bundle/bundles.py | def add_directory(self, *args, **kwargs):
"""
Add directory or directories list to bundle
:param exclusions: List of excluded paths
:type path: str|unicode
:type exclusions: list
"""
exc = kwargs.get('exclusions', None)
for path in args:
self... | def add_directory(self, *args, **kwargs):
"""
Add directory or directories list to bundle
:param exclusions: List of excluded paths
:type path: str|unicode
:type exclusions: list
"""
exc = kwargs.get('exclusions', None)
for path in args:
self... | [
"Add",
"directory",
"or",
"directories",
"list",
"to",
"bundle"
] | Rikanishu/static-bundle | python | https://github.com/Rikanishu/static-bundle/blob/2f6458cb9d9d9049b4fd829f7d6951a45d547c68/static_bundle/bundles.py#L71-L82 | [
"def",
"add_directory",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"exc",
"=",
"kwargs",
".",
"get",
"(",
"'exclusions'",
",",
"None",
")",
"for",
"path",
"in",
"args",
":",
"self",
".",
"files",
".",
"append",
"(",
"Director... | 2f6458cb9d9d9049b4fd829f7d6951a45d547c68 |
valid | AbstractBundle.add_path_object | Add custom path objects
:type: path_object: static_bundle.paths.AbstractPath | static_bundle/bundles.py | def add_path_object(self, *args):
"""
Add custom path objects
:type: path_object: static_bundle.paths.AbstractPath
"""
for obj in args:
obj.bundle = self
self.files.append(obj) | def add_path_object(self, *args):
"""
Add custom path objects
:type: path_object: static_bundle.paths.AbstractPath
"""
for obj in args:
obj.bundle = self
self.files.append(obj) | [
"Add",
"custom",
"path",
"objects"
] | Rikanishu/static-bundle | python | https://github.com/Rikanishu/static-bundle/blob/2f6458cb9d9d9049b4fd829f7d6951a45d547c68/static_bundle/bundles.py#L84-L92 | [
"def",
"add_path_object",
"(",
"self",
",",
"*",
"args",
")",
":",
"for",
"obj",
"in",
"args",
":",
"obj",
".",
"bundle",
"=",
"self",
"self",
".",
"files",
".",
"append",
"(",
"obj",
")"
] | 2f6458cb9d9d9049b4fd829f7d6951a45d547c68 |
valid | AbstractBundle.add_prepare_handler | Add prepare handler to bundle
:type: prepare_handler: static_bundle.handlers.AbstractPrepareHandler | static_bundle/bundles.py | def add_prepare_handler(self, prepare_handlers):
"""
Add prepare handler to bundle
:type: prepare_handler: static_bundle.handlers.AbstractPrepareHandler
"""
if not isinstance(prepare_handlers, static_bundle.BUNDLE_ITERABLE_TYPES):
prepare_handlers = [prepare_handlers... | def add_prepare_handler(self, prepare_handlers):
"""
Add prepare handler to bundle
:type: prepare_handler: static_bundle.handlers.AbstractPrepareHandler
"""
if not isinstance(prepare_handlers, static_bundle.BUNDLE_ITERABLE_TYPES):
prepare_handlers = [prepare_handlers... | [
"Add",
"prepare",
"handler",
"to",
"bundle"
] | Rikanishu/static-bundle | python | https://github.com/Rikanishu/static-bundle/blob/2f6458cb9d9d9049b4fd829f7d6951a45d547c68/static_bundle/bundles.py#L94-L105 | [
"def",
"add_prepare_handler",
"(",
"self",
",",
"prepare_handlers",
")",
":",
"if",
"not",
"isinstance",
"(",
"prepare_handlers",
",",
"static_bundle",
".",
"BUNDLE_ITERABLE_TYPES",
")",
":",
"prepare_handlers",
"=",
"[",
"prepare_handlers",
"]",
"if",
"self",
"."... | 2f6458cb9d9d9049b4fd829f7d6951a45d547c68 |
valid | AbstractBundle.prepare | Called when builder run collect files in builder group
:rtype: list[static_bundle.files.StaticFileResult] | static_bundle/bundles.py | def prepare(self):
"""
Called when builder run collect files in builder group
:rtype: list[static_bundle.files.StaticFileResult]
"""
result_files = self.collect_files()
chain = self.prepare_handlers_chain
if chain is None:
# default handlers
... | def prepare(self):
"""
Called when builder run collect files in builder group
:rtype: list[static_bundle.files.StaticFileResult]
"""
result_files = self.collect_files()
chain = self.prepare_handlers_chain
if chain is None:
# default handlers
... | [
"Called",
"when",
"builder",
"run",
"collect",
"files",
"in",
"builder",
"group"
] | Rikanishu/static-bundle | python | https://github.com/Rikanishu/static-bundle/blob/2f6458cb9d9d9049b4fd829f7d6951a45d547c68/static_bundle/bundles.py#L107-L122 | [
"def",
"prepare",
"(",
"self",
")",
":",
"result_files",
"=",
"self",
".",
"collect_files",
"(",
")",
"chain",
"=",
"self",
".",
"prepare_handlers_chain",
"if",
"chain",
"is",
"None",
":",
"# default handlers",
"chain",
"=",
"[",
"LessCompilerPrepareHandler",
... | 2f6458cb9d9d9049b4fd829f7d6951a45d547c68 |
valid | main | Register your own mode and handle method here. | scripts/check_ftp.py | def main():
"""Register your own mode and handle method here."""
plugin = Register()
if plugin.args.option == 'filenumber':
plugin.filenumber_handle()
else:
plugin.unknown("Unknown actions.") | def main():
"""Register your own mode and handle method here."""
plugin = Register()
if plugin.args.option == 'filenumber':
plugin.filenumber_handle()
else:
plugin.unknown("Unknown actions.") | [
"Register",
"your",
"own",
"mode",
"and",
"handle",
"method",
"here",
"."
] | crazy-canux/arguspy | python | https://github.com/crazy-canux/arguspy/blob/e9486b5df61978a990d56bf43de35f3a4cdefcc3/scripts/check_ftp.py#L120-L126 | [
"def",
"main",
"(",
")",
":",
"plugin",
"=",
"Register",
"(",
")",
"if",
"plugin",
".",
"args",
".",
"option",
"==",
"'filenumber'",
":",
"plugin",
".",
"filenumber_handle",
"(",
")",
"else",
":",
"plugin",
".",
"unknown",
"(",
"\"Unknown actions.\"",
")... | e9486b5df61978a990d56bf43de35f3a4cdefcc3 |
valid | FileNumber.filenumber_handle | Get the number of files in the folder. | scripts/check_ftp.py | def filenumber_handle(self):
"""Get the number of files in the folder."""
self.__results = []
self.__dirs = []
self.__files = []
self.__ftp = self.connect()
self.__ftp.dir(self.args.path, self.__results.append)
self.logger.debug("dir results: {}".format(self.__res... | def filenumber_handle(self):
"""Get the number of files in the folder."""
self.__results = []
self.__dirs = []
self.__files = []
self.__ftp = self.connect()
self.__ftp.dir(self.args.path, self.__results.append)
self.logger.debug("dir results: {}".format(self.__res... | [
"Get",
"the",
"number",
"of",
"files",
"in",
"the",
"folder",
"."
] | crazy-canux/arguspy | python | https://github.com/crazy-canux/arguspy/blob/e9486b5df61978a990d56bf43de35f3a4cdefcc3/scripts/check_ftp.py#L70-L109 | [
"def",
"filenumber_handle",
"(",
"self",
")",
":",
"self",
".",
"__results",
"=",
"[",
"]",
"self",
".",
"__dirs",
"=",
"[",
"]",
"self",
".",
"__files",
"=",
"[",
"]",
"self",
".",
"__ftp",
"=",
"self",
".",
"connect",
"(",
")",
"self",
".",
"__... | e9486b5df61978a990d56bf43de35f3a4cdefcc3 |
valid | DataStore.register_json | Register the contents as JSON | libardurep/datastore.py | def register_json(self, data):
"""
Register the contents as JSON
"""
j = json.loads(data)
self.last_data_timestamp = \
datetime.datetime.utcnow().replace(microsecond=0).isoformat()
try:
for v in j:
# prepare the sensor entry con... | def register_json(self, data):
"""
Register the contents as JSON
"""
j = json.loads(data)
self.last_data_timestamp = \
datetime.datetime.utcnow().replace(microsecond=0).isoformat()
try:
for v in j:
# prepare the sensor entry con... | [
"Register",
"the",
"contents",
"as",
"JSON"
] | zwischenloesung/ardu-report-lib | python | https://github.com/zwischenloesung/ardu-report-lib/blob/51bd4a07e036065aafcb1273b151bea3fdfa50fa/libardurep/datastore.py#L112-L152 | [
"def",
"register_json",
"(",
"self",
",",
"data",
")",
":",
"j",
"=",
"json",
".",
"loads",
"(",
"data",
")",
"self",
".",
"last_data_timestamp",
"=",
"datetime",
".",
"datetime",
".",
"utcnow",
"(",
")",
".",
"replace",
"(",
"microsecond",
"=",
"0",
... | 51bd4a07e036065aafcb1273b151bea3fdfa50fa |
valid | DataStore.get_text | Get the data in text form (i.e. human readable) | libardurep/datastore.py | def get_text(self):
"""
Get the data in text form (i.e. human readable)
"""
t = "==== " + str(self.last_data_timestamp) + " ====\n"
for k in self.data:
t += k + " " + str(self.data[k][self.value_key])
u = ""
if self.unit_key in self.data[k]:
... | def get_text(self):
"""
Get the data in text form (i.e. human readable)
"""
t = "==== " + str(self.last_data_timestamp) + " ====\n"
for k in self.data:
t += k + " " + str(self.data[k][self.value_key])
u = ""
if self.unit_key in self.data[k]:
... | [
"Get",
"the",
"data",
"in",
"text",
"form",
"(",
"i",
".",
"e",
".",
"human",
"readable",
")"
] | zwischenloesung/ardu-report-lib | python | https://github.com/zwischenloesung/ardu-report-lib/blob/51bd4a07e036065aafcb1273b151bea3fdfa50fa/libardurep/datastore.py#L154-L176 | [
"def",
"get_text",
"(",
"self",
")",
":",
"t",
"=",
"\"==== \"",
"+",
"str",
"(",
"self",
".",
"last_data_timestamp",
")",
"+",
"\" ====\\n\"",
"for",
"k",
"in",
"self",
".",
"data",
":",
"t",
"+=",
"k",
"+",
"\" \"",
"+",
"str",
"(",
"self",
".",
... | 51bd4a07e036065aafcb1273b151bea3fdfa50fa |
valid | DataStore.get_translated_data | Translate the data with the translation table | libardurep/datastore.py | def get_translated_data(self):
"""
Translate the data with the translation table
"""
j = {}
for k in self.data:
d = {}
for l in self.data[k]:
d[self.translation_keys[l]] = self.data[k][l]
j[k] = d
return j | def get_translated_data(self):
"""
Translate the data with the translation table
"""
j = {}
for k in self.data:
d = {}
for l in self.data[k]:
d[self.translation_keys[l]] = self.data[k][l]
j[k] = d
return j | [
"Translate",
"the",
"data",
"with",
"the",
"translation",
"table"
] | zwischenloesung/ardu-report-lib | python | https://github.com/zwischenloesung/ardu-report-lib/blob/51bd4a07e036065aafcb1273b151bea3fdfa50fa/libardurep/datastore.py#L178-L188 | [
"def",
"get_translated_data",
"(",
"self",
")",
":",
"j",
"=",
"{",
"}",
"for",
"k",
"in",
"self",
".",
"data",
":",
"d",
"=",
"{",
"}",
"for",
"l",
"in",
"self",
".",
"data",
"[",
"k",
"]",
":",
"d",
"[",
"self",
".",
"translation_keys",
"[",
... | 51bd4a07e036065aafcb1273b151bea3fdfa50fa |
valid | DataStore.get_json | Get the data in JSON form | libardurep/datastore.py | def get_json(self, prettyprint=False, translate=True):
"""
Get the data in JSON form
"""
j = []
if translate:
d = self.get_translated_data()
else:
d = self.data
for k in d:
j.append(d[k])
if prettyprint:
j = ... | def get_json(self, prettyprint=False, translate=True):
"""
Get the data in JSON form
"""
j = []
if translate:
d = self.get_translated_data()
else:
d = self.data
for k in d:
j.append(d[k])
if prettyprint:
j = ... | [
"Get",
"the",
"data",
"in",
"JSON",
"form"
] | zwischenloesung/ardu-report-lib | python | https://github.com/zwischenloesung/ardu-report-lib/blob/51bd4a07e036065aafcb1273b151bea3fdfa50fa/libardurep/datastore.py#L190-L205 | [
"def",
"get_json",
"(",
"self",
",",
"prettyprint",
"=",
"False",
",",
"translate",
"=",
"True",
")",
":",
"j",
"=",
"[",
"]",
"if",
"translate",
":",
"d",
"=",
"self",
".",
"get_translated_data",
"(",
")",
"else",
":",
"d",
"=",
"self",
".",
"data... | 51bd4a07e036065aafcb1273b151bea3fdfa50fa |
valid | DataStore.get_json_tuples | Get the data as JSON tuples | libardurep/datastore.py | def get_json_tuples(self, prettyprint=False, translate=True):
"""
Get the data as JSON tuples
"""
j = self.get_json(prettyprint, translate)
if len(j) > 2:
if prettyprint:
j = j[1:-2] + ",\n"
else:
j = j[1:-1] + ","
e... | def get_json_tuples(self, prettyprint=False, translate=True):
"""
Get the data as JSON tuples
"""
j = self.get_json(prettyprint, translate)
if len(j) > 2:
if prettyprint:
j = j[1:-2] + ",\n"
else:
j = j[1:-1] + ","
e... | [
"Get",
"the",
"data",
"as",
"JSON",
"tuples"
] | zwischenloesung/ardu-report-lib | python | https://github.com/zwischenloesung/ardu-report-lib/blob/51bd4a07e036065aafcb1273b151bea3fdfa50fa/libardurep/datastore.py#L207-L219 | [
"def",
"get_json_tuples",
"(",
"self",
",",
"prettyprint",
"=",
"False",
",",
"translate",
"=",
"True",
")",
":",
"j",
"=",
"self",
".",
"get_json",
"(",
"prettyprint",
",",
"translate",
")",
"if",
"len",
"(",
"j",
")",
">",
"2",
":",
"if",
"prettypr... | 51bd4a07e036065aafcb1273b151bea3fdfa50fa |
valid | ShirtsIORequest.get | Issues a GET request against the API, properly formatting the params
:param url: a string, the url you are requesting
:param params: a dict, the key-value of all the paramaters needed
in the request
:returns: a dict parsed of the JSON response | ShirtsIO/request.py | def get(self, url, params={}):
"""
Issues a GET request against the API, properly formatting the params
:param url: a string, the url you are requesting
:param params: a dict, the key-value of all the paramaters needed
in the request
:returns: a dict parse... | def get(self, url, params={}):
"""
Issues a GET request against the API, properly formatting the params
:param url: a string, the url you are requesting
:param params: a dict, the key-value of all the paramaters needed
in the request
:returns: a dict parse... | [
"Issues",
"a",
"GET",
"request",
"against",
"the",
"API",
"properly",
"formatting",
"the",
"params"
] | tklovett/PyShirtsIO | python | https://github.com/tklovett/PyShirtsIO/blob/ff2f2d3b5e4ab2813abbce8545b27319c6af0def/ShirtsIO/request.py#L15-L31 | [
"def",
"get",
"(",
"self",
",",
"url",
",",
"params",
"=",
"{",
"}",
")",
":",
"params",
".",
"update",
"(",
"{",
"'api_key'",
":",
"self",
".",
"api_key",
"}",
")",
"try",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"self",
".",
"host",
... | ff2f2d3b5e4ab2813abbce8545b27319c6af0def |
valid | ShirtsIORequest.post | Issues a POST request against the API, allows for multipart data uploads
:param url: a string, the url you are requesting
:param params: a dict, the key-value of all the parameters needed
in the request
:param files: a list, the list of tuples of files
:returns: ... | ShirtsIO/request.py | def post(self, url, params={}, files=None):
"""
Issues a POST request against the API, allows for multipart data uploads
:param url: a string, the url you are requesting
:param params: a dict, the key-value of all the parameters needed
in the request
:para... | def post(self, url, params={}, files=None):
"""
Issues a POST request against the API, allows for multipart data uploads
:param url: a string, the url you are requesting
:param params: a dict, the key-value of all the parameters needed
in the request
:para... | [
"Issues",
"a",
"POST",
"request",
"against",
"the",
"API",
"allows",
"for",
"multipart",
"data",
"uploads"
] | tklovett/PyShirtsIO | python | https://github.com/tklovett/PyShirtsIO/blob/ff2f2d3b5e4ab2813abbce8545b27319c6af0def/ShirtsIO/request.py#L33-L49 | [
"def",
"post",
"(",
"self",
",",
"url",
",",
"params",
"=",
"{",
"}",
",",
"files",
"=",
"None",
")",
":",
"params",
".",
"update",
"(",
"{",
"'api_key'",
":",
"self",
".",
"api_key",
"}",
")",
"try",
":",
"response",
"=",
"requests",
".",
"post"... | ff2f2d3b5e4ab2813abbce8545b27319c6af0def |
valid | ShirtsIORequest.json_parse | Wraps and abstracts content validation and JSON parsing
to make sure the user gets the correct response.
:param content: The content returned from the web request to be parsed as json
:returns: a dict of the json response | ShirtsIO/request.py | def json_parse(self, content):
"""
Wraps and abstracts content validation and JSON parsing
to make sure the user gets the correct response.
:param content: The content returned from the web request to be parsed as json
:returns: a dict of the json response
... | def json_parse(self, content):
"""
Wraps and abstracts content validation and JSON parsing
to make sure the user gets the correct response.
:param content: The content returned from the web request to be parsed as json
:returns: a dict of the json response
... | [
"Wraps",
"and",
"abstracts",
"content",
"validation",
"and",
"JSON",
"parsing",
"to",
"make",
"sure",
"the",
"user",
"gets",
"the",
"correct",
"response",
".",
":",
"param",
"content",
":",
"The",
"content",
"returned",
"from",
"the",
"web",
"request",
"to",... | tklovett/PyShirtsIO | python | https://github.com/tklovett/PyShirtsIO/blob/ff2f2d3b5e4ab2813abbce8545b27319c6af0def/ShirtsIO/request.py#L51-L72 | [
"def",
"json_parse",
"(",
"self",
",",
"content",
")",
":",
"try",
":",
"data",
"=",
"json",
".",
"loads",
"(",
"content",
")",
"except",
"ValueError",
",",
"e",
":",
"return",
"{",
"'meta'",
":",
"{",
"'status'",
":",
"500",
",",
"'msg'",
":",
"'S... | ff2f2d3b5e4ab2813abbce8545b27319c6af0def |
valid | ConfigStore.load_values | Go through the env var map, transferring the values to this object
as attributes.
:raises: RuntimeError if a required env var isn't defined. | evarify/evar.py | def load_values(self):
"""
Go through the env var map, transferring the values to this object
as attributes.
:raises: RuntimeError if a required env var isn't defined.
"""
for config_name, evar in self.evar_defs.items():
if evar.is_required and evar.name not... | def load_values(self):
"""
Go through the env var map, transferring the values to this object
as attributes.
:raises: RuntimeError if a required env var isn't defined.
"""
for config_name, evar in self.evar_defs.items():
if evar.is_required and evar.name not... | [
"Go",
"through",
"the",
"env",
"var",
"map",
"transferring",
"the",
"values",
"to",
"this",
"object",
"as",
"attributes",
"."
] | gtaylor/evarify | python | https://github.com/gtaylor/evarify/blob/37cec29373c820eda96939633e2067d55598915b/evarify/evar.py#L23-L49 | [
"def",
"load_values",
"(",
"self",
")",
":",
"for",
"config_name",
",",
"evar",
"in",
"self",
".",
"evar_defs",
".",
"items",
"(",
")",
":",
"if",
"evar",
".",
"is_required",
"and",
"evar",
".",
"name",
"not",
"in",
"os",
".",
"environ",
":",
"raise"... | 37cec29373c820eda96939633e2067d55598915b |
valid | embed_data | Create a temporary directory with input data for the test.
The directory contents is copied from a directory with the same name as the module located in the same directory of
the test module. | zerotk/easyfs/fixtures.py | def embed_data(request):
"""
Create a temporary directory with input data for the test.
The directory contents is copied from a directory with the same name as the module located in the same directory of
the test module.
"""
result = _EmbedDataFixture(request)
result.delete_data_dir()
re... | def embed_data(request):
"""
Create a temporary directory with input data for the test.
The directory contents is copied from a directory with the same name as the module located in the same directory of
the test module.
"""
result = _EmbedDataFixture(request)
result.delete_data_dir()
re... | [
"Create",
"a",
"temporary",
"directory",
"with",
"input",
"data",
"for",
"the",
"test",
".",
"The",
"directory",
"contents",
"is",
"copied",
"from",
"a",
"directory",
"with",
"the",
"same",
"name",
"as",
"the",
"module",
"located",
"in",
"the",
"same",
"di... | zerotk/easyfs | python | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/fixtures.py#L153-L163 | [
"def",
"embed_data",
"(",
"request",
")",
":",
"result",
"=",
"_EmbedDataFixture",
"(",
"request",
")",
"result",
".",
"delete_data_dir",
"(",
")",
"result",
".",
"create_data_dir",
"(",
")",
"yield",
"result",
"result",
".",
"delete_data_dir",
"(",
")"
] | 140923db51fb91d5a5847ad17412e8bce51ba3da |
valid | _EmbedDataFixture.get_filename | Returns an absolute filename in the data-directory (standardized by StandardizePath).
@params parts: list(unicode)
Path parts. Each part is joined to form a path.
:rtype: unicode
:returns:
The full path prefixed with the data-directory.
@remarks:
Th... | zerotk/easyfs/fixtures.py | def get_filename(self, *parts):
'''
Returns an absolute filename in the data-directory (standardized by StandardizePath).
@params parts: list(unicode)
Path parts. Each part is joined to form a path.
:rtype: unicode
:returns:
The full path prefixed with t... | def get_filename(self, *parts):
'''
Returns an absolute filename in the data-directory (standardized by StandardizePath).
@params parts: list(unicode)
Path parts. Each part is joined to form a path.
:rtype: unicode
:returns:
The full path prefixed with t... | [
"Returns",
"an",
"absolute",
"filename",
"in",
"the",
"data",
"-",
"directory",
"(",
"standardized",
"by",
"StandardizePath",
")",
"."
] | zerotk/easyfs | python | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/fixtures.py#L43-L61 | [
"def",
"get_filename",
"(",
"self",
",",
"*",
"parts",
")",
":",
"from",
"zerotk",
".",
"easyfs",
"import",
"StandardizePath",
"result",
"=",
"[",
"self",
".",
"_data_dir",
"]",
"+",
"list",
"(",
"parts",
")",
"result",
"=",
"'/'",
".",
"join",
"(",
... | 140923db51fb91d5a5847ad17412e8bce51ba3da |
valid | _EmbedDataFixture.assert_equal_files | Compare two files contents. If the files differ, show the diff and write a nice HTML
diff file into the data directory.
Searches for the filenames both inside and outside the data directory (in that order).
:param unicode obtained_fn: basename to obtained file into the data directory, or full ... | zerotk/easyfs/fixtures.py | def assert_equal_files(self, obtained_fn, expected_fn, fix_callback=lambda x:x, binary=False, encoding=None):
'''
Compare two files contents. If the files differ, show the diff and write a nice HTML
diff file into the data directory.
Searches for the filenames both inside and outside th... | def assert_equal_files(self, obtained_fn, expected_fn, fix_callback=lambda x:x, binary=False, encoding=None):
'''
Compare two files contents. If the files differ, show the diff and write a nice HTML
diff file into the data directory.
Searches for the filenames both inside and outside th... | [
"Compare",
"two",
"files",
"contents",
".",
"If",
"the",
"files",
"differ",
"show",
"the",
"diff",
"and",
"write",
"a",
"nice",
"HTML",
"diff",
"file",
"into",
"the",
"data",
"directory",
"."
] | zerotk/easyfs | python | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/fixtures.py#L66-L135 | [
"def",
"assert_equal_files",
"(",
"self",
",",
"obtained_fn",
",",
"expected_fn",
",",
"fix_callback",
"=",
"lambda",
"x",
":",
"x",
",",
"binary",
"=",
"False",
",",
"encoding",
"=",
"None",
")",
":",
"import",
"os",
"from",
"zerotk",
".",
"easyfs",
"im... | 140923db51fb91d5a5847ad17412e8bce51ba3da |
valid | _EmbedDataFixture._generate_html_diff | Returns a nice side-by-side diff of the given files, as a string. | zerotk/easyfs/fixtures.py | def _generate_html_diff(self, expected_fn, expected_lines, obtained_fn, obtained_lines):
"""
Returns a nice side-by-side diff of the given files, as a string.
"""
import difflib
differ = difflib.HtmlDiff()
return differ.make_file(
fromlines=expected_lines,
... | def _generate_html_diff(self, expected_fn, expected_lines, obtained_fn, obtained_lines):
"""
Returns a nice side-by-side diff of the given files, as a string.
"""
import difflib
differ = difflib.HtmlDiff()
return differ.make_file(
fromlines=expected_lines,
... | [
"Returns",
"a",
"nice",
"side",
"-",
"by",
"-",
"side",
"diff",
"of",
"the",
"given",
"files",
"as",
"a",
"string",
"."
] | zerotk/easyfs | python | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/fixtures.py#L137-L149 | [
"def",
"_generate_html_diff",
"(",
"self",
",",
"expected_fn",
",",
"expected_lines",
",",
"obtained_fn",
",",
"obtained_lines",
")",
":",
"import",
"difflib",
"differ",
"=",
"difflib",
".",
"HtmlDiff",
"(",
")",
"return",
"differ",
".",
"make_file",
"(",
"fro... | 140923db51fb91d5a5847ad17412e8bce51ba3da |
valid | Network.add_peer | Add a peer or multiple peers to the PEERS variable, takes a single string or a list.
:param peer(list or string) | dpostools/api.py | def add_peer(self, peer):
"""
Add a peer or multiple peers to the PEERS variable, takes a single string or a list.
:param peer(list or string)
"""
if type(peer) == list:
for i in peer:
check_url(i)
self.PEERS.extend(peer)
elif type... | def add_peer(self, peer):
"""
Add a peer or multiple peers to the PEERS variable, takes a single string or a list.
:param peer(list or string)
"""
if type(peer) == list:
for i in peer:
check_url(i)
self.PEERS.extend(peer)
elif type... | [
"Add",
"a",
"peer",
"or",
"multiple",
"peers",
"to",
"the",
"PEERS",
"variable",
"takes",
"a",
"single",
"string",
"or",
"a",
"list",
"."
] | BlockHub/blockhubdpostools | python | https://github.com/BlockHub/blockhubdpostools/blob/27712cd97cd3658ee54a4330ff3135b51a01d7d1/dpostools/api.py#L36-L48 | [
"def",
"add_peer",
"(",
"self",
",",
"peer",
")",
":",
"if",
"type",
"(",
"peer",
")",
"==",
"list",
":",
"for",
"i",
"in",
"peer",
":",
"check_url",
"(",
"i",
")",
"self",
".",
"PEERS",
".",
"extend",
"(",
"peer",
")",
"elif",
"type",
"(",
"pe... | 27712cd97cd3658ee54a4330ff3135b51a01d7d1 |
valid | Network.remove_peer | remove one or multiple peers from PEERS variable
:param peer(list or string): | dpostools/api.py | def remove_peer(self, peer):
"""
remove one or multiple peers from PEERS variable
:param peer(list or string):
"""
if type(peer) == list:
for x in peer:
check_url(x)
for i in self.PEERS:
if x in i:
... | def remove_peer(self, peer):
"""
remove one or multiple peers from PEERS variable
:param peer(list or string):
"""
if type(peer) == list:
for x in peer:
check_url(x)
for i in self.PEERS:
if x in i:
... | [
"remove",
"one",
"or",
"multiple",
"peers",
"from",
"PEERS",
"variable"
] | BlockHub/blockhubdpostools | python | https://github.com/BlockHub/blockhubdpostools/blob/27712cd97cd3658ee54a4330ff3135b51a01d7d1/dpostools/api.py#L50-L68 | [
"def",
"remove_peer",
"(",
"self",
",",
"peer",
")",
":",
"if",
"type",
"(",
"peer",
")",
"==",
"list",
":",
"for",
"x",
"in",
"peer",
":",
"check_url",
"(",
"x",
")",
"for",
"i",
"in",
"self",
".",
"PEERS",
":",
"if",
"x",
"in",
"i",
":",
"s... | 27712cd97cd3658ee54a4330ff3135b51a01d7d1 |
valid | Network.status | check the status of the network and the peers
:return: network_height, peer_status | dpostools/api.py | def status(self):
"""
check the status of the network and the peers
:return: network_height, peer_status
"""
peer = random.choice(self.PEERS)
formatted_peer = 'http://{}:4001'.format(peer)
peerdata = requests.get(url=formatted_peer + '/api/peers/').json()['peers'... | def status(self):
"""
check the status of the network and the peers
:return: network_height, peer_status
"""
peer = random.choice(self.PEERS)
formatted_peer = 'http://{}:4001'.format(peer)
peerdata = requests.get(url=formatted_peer + '/api/peers/').json()['peers'... | [
"check",
"the",
"status",
"of",
"the",
"network",
"and",
"the",
"peers"
] | BlockHub/blockhubdpostools | python | https://github.com/BlockHub/blockhubdpostools/blob/27712cd97cd3658ee54a4330ff3135b51a01d7d1/dpostools/api.py#L76-L101 | [
"def",
"status",
"(",
"self",
")",
":",
"peer",
"=",
"random",
".",
"choice",
"(",
"self",
".",
"PEERS",
")",
"formatted_peer",
"=",
"'http://{}:4001'",
".",
"format",
"(",
"peer",
")",
"peerdata",
"=",
"requests",
".",
"get",
"(",
"url",
"=",
"formatt... | 27712cd97cd3658ee54a4330ff3135b51a01d7d1 |
valid | Network.broadcast_tx | broadcasts a transaction to the peerslist using ark-js library | dpostools/api.py | def broadcast_tx(self, address, amount, secret, secondsecret=None, vendorfield=''):
"""broadcasts a transaction to the peerslist using ark-js library"""
peer = random.choice(self.PEERS)
park = Park(
peer,
4001,
constants.ARK_NETHASH,
'1.1.1'
... | def broadcast_tx(self, address, amount, secret, secondsecret=None, vendorfield=''):
"""broadcasts a transaction to the peerslist using ark-js library"""
peer = random.choice(self.PEERS)
park = Park(
peer,
4001,
constants.ARK_NETHASH,
'1.1.1'
... | [
"broadcasts",
"a",
"transaction",
"to",
"the",
"peerslist",
"using",
"ark",
"-",
"js",
"library"
] | BlockHub/blockhubdpostools | python | https://github.com/BlockHub/blockhubdpostools/blob/27712cd97cd3658ee54a4330ff3135b51a01d7d1/dpostools/api.py#L103-L114 | [
"def",
"broadcast_tx",
"(",
"self",
",",
"address",
",",
"amount",
",",
"secret",
",",
"secondsecret",
"=",
"None",
",",
"vendorfield",
"=",
"''",
")",
":",
"peer",
"=",
"random",
".",
"choice",
"(",
"self",
".",
"PEERS",
")",
"park",
"=",
"Park",
"(... | 27712cd97cd3658ee54a4330ff3135b51a01d7d1 |
valid | OrbApiFactory.register | Exposes a given service to this API. | pyramid_orb/api.py | def register(self, service, name=''):
"""
Exposes a given service to this API.
"""
try:
is_model = issubclass(service, orb.Model)
except StandardError:
is_model = False
# expose an ORB table dynamically as a service
if is_model:
... | def register(self, service, name=''):
"""
Exposes a given service to this API.
"""
try:
is_model = issubclass(service, orb.Model)
except StandardError:
is_model = False
# expose an ORB table dynamically as a service
if is_model:
... | [
"Exposes",
"a",
"given",
"service",
"to",
"this",
"API",
"."
] | orb-framework/pyramid_orb | python | https://github.com/orb-framework/pyramid_orb/blob/e5c716fc75626e1cd966f7bd87b470a8b71126bf/pyramid_orb/api.py#L161-L175 | [
"def",
"register",
"(",
"self",
",",
"service",
",",
"name",
"=",
"''",
")",
":",
"try",
":",
"is_model",
"=",
"issubclass",
"(",
"service",
",",
"orb",
".",
"Model",
")",
"except",
"StandardError",
":",
"is_model",
"=",
"False",
"# expose an ORB table dyn... | e5c716fc75626e1cd966f7bd87b470a8b71126bf |
valid | main | Register your own mode and handle method here. | scripts/check_mysql.py | def main():
"""Register your own mode and handle method here."""
plugin = Register()
if plugin.args.option == 'sql':
plugin.sql_handle()
else:
plugin.unknown("Unknown actions.") | def main():
"""Register your own mode and handle method here."""
plugin = Register()
if plugin.args.option == 'sql':
plugin.sql_handle()
else:
plugin.unknown("Unknown actions.") | [
"Register",
"your",
"own",
"mode",
"and",
"handle",
"method",
"here",
"."
] | crazy-canux/arguspy | python | https://github.com/crazy-canux/arguspy/blob/e9486b5df61978a990d56bf43de35f3a4cdefcc3/scripts/check_mysql.py#L96-L102 | [
"def",
"main",
"(",
")",
":",
"plugin",
"=",
"Register",
"(",
")",
"if",
"plugin",
".",
"args",
".",
"option",
"==",
"'sql'",
":",
"plugin",
".",
"sql_handle",
"(",
")",
"else",
":",
"plugin",
".",
"unknown",
"(",
"\"Unknown actions.\"",
")"
] | e9486b5df61978a990d56bf43de35f3a4cdefcc3 |
valid | LessCompilerPrepareHandler.prepare | :type input_files: list[static_bundle.files.StaticFileResult]
:type bundle: static_bundle.bundles.AbstractBundle
:rtype: list | static_bundle/handlers.py | def prepare(self, input_files, bundle):
"""
:type input_files: list[static_bundle.files.StaticFileResult]
:type bundle: static_bundle.bundles.AbstractBundle
:rtype: list
"""
out = []
for input_file in input_files:
if input_file.extension == "less" and ... | def prepare(self, input_files, bundle):
"""
:type input_files: list[static_bundle.files.StaticFileResult]
:type bundle: static_bundle.bundles.AbstractBundle
:rtype: list
"""
out = []
for input_file in input_files:
if input_file.extension == "less" and ... | [
":",
"type",
"input_files",
":",
"list",
"[",
"static_bundle",
".",
"files",
".",
"StaticFileResult",
"]",
":",
"type",
"bundle",
":",
"static_bundle",
".",
"bundles",
".",
"AbstractBundle",
":",
"rtype",
":",
"list"
] | Rikanishu/static-bundle | python | https://github.com/Rikanishu/static-bundle/blob/2f6458cb9d9d9049b4fd829f7d6951a45d547c68/static_bundle/handlers.py#L42-L56 | [
"def",
"prepare",
"(",
"self",
",",
"input_files",
",",
"bundle",
")",
":",
"out",
"=",
"[",
"]",
"for",
"input_file",
"in",
"input_files",
":",
"if",
"input_file",
".",
"extension",
"==",
"\"less\"",
"and",
"os",
".",
"path",
".",
"isfile",
"(",
"inpu... | 2f6458cb9d9d9049b4fd829f7d6951a45d547c68 |
valid | main | Main entry point, expects doctopt arg dict as argd. | fmtblock/__main__.py | def main():
""" Main entry point, expects doctopt arg dict as argd. """
global DEBUG
argd = docopt(USAGESTR, version=VERSIONSTR, script=SCRIPT)
DEBUG = argd['--debug']
width = parse_int(argd['--width'] or DEFAULT_WIDTH) or 1
indent = parse_int(argd['--indent'] or (argd['--INDENT'] or 0))
pr... | def main():
""" Main entry point, expects doctopt arg dict as argd. """
global DEBUG
argd = docopt(USAGESTR, version=VERSIONSTR, script=SCRIPT)
DEBUG = argd['--debug']
width = parse_int(argd['--width'] or DEFAULT_WIDTH) or 1
indent = parse_int(argd['--indent'] or (argd['--INDENT'] or 0))
pr... | [
"Main",
"entry",
"point",
"expects",
"doctopt",
"arg",
"dict",
"as",
"argd",
"."
] | welbornprod/fmtblock | python | https://github.com/welbornprod/fmtblock/blob/92a5529235d557170ed21e058e3c5995197facbe/fmtblock/__main__.py#L86-L139 | [
"def",
"main",
"(",
")",
":",
"global",
"DEBUG",
"argd",
"=",
"docopt",
"(",
"USAGESTR",
",",
"version",
"=",
"VERSIONSTR",
",",
"script",
"=",
"SCRIPT",
")",
"DEBUG",
"=",
"argd",
"[",
"'--debug'",
"]",
"width",
"=",
"parse_int",
"(",
"argd",
"[",
"... | 92a5529235d557170ed21e058e3c5995197facbe |
valid | debug | Print a message only if DEBUG is truthy. | fmtblock/__main__.py | def debug(*args, **kwargs):
""" Print a message only if DEBUG is truthy. """
if not (DEBUG and args):
return None
# Include parent class name when given.
parent = kwargs.get('parent', None)
with suppress(KeyError):
kwargs.pop('parent')
# Go back more than once when given.
b... | def debug(*args, **kwargs):
""" Print a message only if DEBUG is truthy. """
if not (DEBUG and args):
return None
# Include parent class name when given.
parent = kwargs.get('parent', None)
with suppress(KeyError):
kwargs.pop('parent')
# Go back more than once when given.
b... | [
"Print",
"a",
"message",
"only",
"if",
"DEBUG",
"is",
"truthy",
"."
] | welbornprod/fmtblock | python | https://github.com/welbornprod/fmtblock/blob/92a5529235d557170ed21e058e3c5995197facbe/fmtblock/__main__.py#L142-L177 | [
"def",
"debug",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"(",
"DEBUG",
"and",
"args",
")",
":",
"return",
"None",
"# Include parent class name when given.",
"parent",
"=",
"kwargs",
".",
"get",
"(",
"'parent'",
",",
"None",
")",
... | 92a5529235d557170ed21e058e3c5995197facbe |
valid | parse_int | Parse a string as an integer.
Exit with a message on failure. | fmtblock/__main__.py | def parse_int(s):
""" Parse a string as an integer.
Exit with a message on failure.
"""
try:
val = int(s)
except ValueError:
print_err('\nInvalid integer: {}'.format(s))
sys.exit(1)
return val | def parse_int(s):
""" Parse a string as an integer.
Exit with a message on failure.
"""
try:
val = int(s)
except ValueError:
print_err('\nInvalid integer: {}'.format(s))
sys.exit(1)
return val | [
"Parse",
"a",
"string",
"as",
"an",
"integer",
".",
"Exit",
"with",
"a",
"message",
"on",
"failure",
"."
] | welbornprod/fmtblock | python | https://github.com/welbornprod/fmtblock/blob/92a5529235d557170ed21e058e3c5995197facbe/fmtblock/__main__.py#L180-L189 | [
"def",
"parse_int",
"(",
"s",
")",
":",
"try",
":",
"val",
"=",
"int",
"(",
"s",
")",
"except",
"ValueError",
":",
"print_err",
"(",
"'\\nInvalid integer: {}'",
".",
"format",
"(",
"s",
")",
")",
"sys",
".",
"exit",
"(",
"1",
")",
"return",
"val"
] | 92a5529235d557170ed21e058e3c5995197facbe |
valid | try_read_file | If `s` is a file name, read the file and return it's content.
Otherwise, return the original string.
Returns None if the file was opened, but errored during reading. | fmtblock/__main__.py | def try_read_file(s):
""" If `s` is a file name, read the file and return it's content.
Otherwise, return the original string.
Returns None if the file was opened, but errored during reading.
"""
try:
with open(s, 'r') as f:
data = f.read()
except FileNotFoundError:
... | def try_read_file(s):
""" If `s` is a file name, read the file and return it's content.
Otherwise, return the original string.
Returns None if the file was opened, but errored during reading.
"""
try:
with open(s, 'r') as f:
data = f.read()
except FileNotFoundError:
... | [
"If",
"s",
"is",
"a",
"file",
"name",
"read",
"the",
"file",
"and",
"return",
"it",
"s",
"content",
".",
"Otherwise",
"return",
"the",
"original",
"string",
".",
"Returns",
"None",
"if",
"the",
"file",
"was",
"opened",
"but",
"errored",
"during",
"readin... | welbornprod/fmtblock | python | https://github.com/welbornprod/fmtblock/blob/92a5529235d557170ed21e058e3c5995197facbe/fmtblock/__main__.py#L206-L220 | [
"def",
"try_read_file",
"(",
"s",
")",
":",
"try",
":",
"with",
"open",
"(",
"s",
",",
"'r'",
")",
"as",
"f",
":",
"data",
"=",
"f",
".",
"read",
"(",
")",
"except",
"FileNotFoundError",
":",
"# Not a file name.",
"return",
"s",
"except",
"EnvironmentE... | 92a5529235d557170ed21e058e3c5995197facbe |
valid | Vim.close | Disconnect and close *Vim*. | headlessvim/__init__.py | def close(self):
"""
Disconnect and close *Vim*.
"""
self._tempfile.close()
self._process.terminate()
if self._process.is_alive():
self._process.kill() | def close(self):
"""
Disconnect and close *Vim*.
"""
self._tempfile.close()
self._process.terminate()
if self._process.is_alive():
self._process.kill() | [
"Disconnect",
"and",
"close",
"*",
"Vim",
"*",
"."
] | manicmaniac/headlessvim | python | https://github.com/manicmaniac/headlessvim/blob/3e4657f95d981ddf21fd285b7e1b9da2154f9cb9/headlessvim/__init__.py#L98-L105 | [
"def",
"close",
"(",
"self",
")",
":",
"self",
".",
"_tempfile",
".",
"close",
"(",
")",
"self",
".",
"_process",
".",
"terminate",
"(",
")",
"if",
"self",
".",
"_process",
".",
"is_alive",
"(",
")",
":",
"self",
".",
"_process",
".",
"kill",
"(",
... | 3e4657f95d981ddf21fd285b7e1b9da2154f9cb9 |
valid | Vim.send_keys | Send a raw key sequence to *Vim*.
.. note:: *Vim* style key sequence notation (like ``<Esc>``)
is not recognized.
Use escaped characters (like ``'\033'``) instead.
Example:
>>> import headlessvim
>>> with headlessvim.open() as vim:
... v... | headlessvim/__init__.py | def send_keys(self, keys, wait=True):
"""
Send a raw key sequence to *Vim*.
.. note:: *Vim* style key sequence notation (like ``<Esc>``)
is not recognized.
Use escaped characters (like ``'\033'``) instead.
Example:
>>> import headlessvim
... | def send_keys(self, keys, wait=True):
"""
Send a raw key sequence to *Vim*.
.. note:: *Vim* style key sequence notation (like ``<Esc>``)
is not recognized.
Use escaped characters (like ``'\033'``) instead.
Example:
>>> import headlessvim
... | [
"Send",
"a",
"raw",
"key",
"sequence",
"to",
"*",
"Vim",
"*",
"."
] | manicmaniac/headlessvim | python | https://github.com/manicmaniac/headlessvim/blob/3e4657f95d981ddf21fd285b7e1b9da2154f9cb9/headlessvim/__init__.py#L159-L182 | [
"def",
"send_keys",
"(",
"self",
",",
"keys",
",",
"wait",
"=",
"True",
")",
":",
"self",
".",
"_process",
".",
"stdin",
".",
"write",
"(",
"bytearray",
"(",
"keys",
",",
"self",
".",
"_encoding",
")",
")",
"self",
".",
"_process",
".",
"stdin",
".... | 3e4657f95d981ddf21fd285b7e1b9da2154f9cb9 |
valid | Vim.wait | Wait for response until timeout.
If timeout is specified to None, ``self.timeout`` is used.
:param float timeout: seconds to wait I/O | headlessvim/__init__.py | def wait(self, timeout=None):
"""
Wait for response until timeout.
If timeout is specified to None, ``self.timeout`` is used.
:param float timeout: seconds to wait I/O
"""
if timeout is None:
timeout = self._timeout
while self._process.check_readable(... | def wait(self, timeout=None):
"""
Wait for response until timeout.
If timeout is specified to None, ``self.timeout`` is used.
:param float timeout: seconds to wait I/O
"""
if timeout is None:
timeout = self._timeout
while self._process.check_readable(... | [
"Wait",
"for",
"response",
"until",
"timeout",
".",
"If",
"timeout",
"is",
"specified",
"to",
"None",
"self",
".",
"timeout",
"is",
"used",
"."
] | manicmaniac/headlessvim | python | https://github.com/manicmaniac/headlessvim/blob/3e4657f95d981ddf21fd285b7e1b9da2154f9cb9/headlessvim/__init__.py#L184-L194 | [
"def",
"wait",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"if",
"timeout",
"is",
"None",
":",
"timeout",
"=",
"self",
".",
"_timeout",
"while",
"self",
".",
"_process",
".",
"check_readable",
"(",
"timeout",
")",
":",
"self",
".",
"_flush",
... | 3e4657f95d981ddf21fd285b7e1b9da2154f9cb9 |
valid | Vim.install_plugin | Install *Vim* plugin.
:param string dir: the root directory contains *Vim* script
:param string entry_script: path to the initializing script | headlessvim/__init__.py | def install_plugin(self, dir, entry_script=None):
"""
Install *Vim* plugin.
:param string dir: the root directory contains *Vim* script
:param string entry_script: path to the initializing script
"""
self.runtimepath.append(dir)
if entry_script is not None:
... | def install_plugin(self, dir, entry_script=None):
"""
Install *Vim* plugin.
:param string dir: the root directory contains *Vim* script
:param string entry_script: path to the initializing script
"""
self.runtimepath.append(dir)
if entry_script is not None:
... | [
"Install",
"*",
"Vim",
"*",
"plugin",
"."
] | manicmaniac/headlessvim | python | https://github.com/manicmaniac/headlessvim/blob/3e4657f95d981ddf21fd285b7e1b9da2154f9cb9/headlessvim/__init__.py#L196-L205 | [
"def",
"install_plugin",
"(",
"self",
",",
"dir",
",",
"entry_script",
"=",
"None",
")",
":",
"self",
".",
"runtimepath",
".",
"append",
"(",
"dir",
")",
"if",
"entry_script",
"is",
"not",
"None",
":",
"self",
".",
"command",
"(",
"'runtime! {0}'",
".",
... | 3e4657f95d981ddf21fd285b7e1b9da2154f9cb9 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.