repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
nmdp-bioinformatics/SeqAnn | seqann/util.py | checkseq | def checkseq(sequence: str=None, code="ATGC") -> bool:
"""
:param sequence: The input sequence.
:type sequence: Seq
:rtype: bool
"""
for base in sequence:
if base not in code:
return False
return True | python | def checkseq(sequence: str=None, code="ATGC") -> bool:
"""
:param sequence: The input sequence.
:type sequence: Seq
:rtype: bool
"""
for base in sequence:
if base not in code:
return False
return True | [
"def",
"checkseq",
"(",
"sequence",
":",
"str",
"=",
"None",
",",
"code",
"=",
"\"ATGC\"",
")",
"->",
"bool",
":",
"for",
"base",
"in",
"sequence",
":",
"if",
"base",
"not",
"in",
"code",
":",
"return",
"False",
"return",
"True"
] | :param sequence: The input sequence.
:type sequence: Seq
:rtype: bool | [
":",
"param",
"sequence",
":",
"The",
"input",
"sequence",
".",
":",
"type",
"sequence",
":",
"Seq",
":",
"rtype",
":",
"bool"
] | 5ce91559b0a4fbe4fb7758e034eb258202632463 | https://github.com/nmdp-bioinformatics/SeqAnn/blob/5ce91559b0a4fbe4fb7758e034eb258202632463/seqann/util.py#L36-L45 | train | Checks if the input sequence contains the given code. |
nmdp-bioinformatics/SeqAnn | seqann/util.py | _deserialize_primitive | def _deserialize_primitive(data, klass):
"""
Deserializes to primitive type.
:param data: data to deserialize.
:param klass: class literal.
:return: int, long, float, str, bool.
:rtype: int | long | float | str | bool
"""
try:
value = klass(data)
except UnicodeEncodeError:
... | python | def _deserialize_primitive(data, klass):
"""
Deserializes to primitive type.
:param data: data to deserialize.
:param klass: class literal.
:return: int, long, float, str, bool.
:rtype: int | long | float | str | bool
"""
try:
value = klass(data)
except UnicodeEncodeError:
... | [
"def",
"_deserialize_primitive",
"(",
"data",
",",
"klass",
")",
":",
"try",
":",
"value",
"=",
"klass",
"(",
"data",
")",
"except",
"UnicodeEncodeError",
":",
"value",
"=",
"unicode",
"(",
"data",
")",
"except",
"TypeError",
":",
"value",
"=",
"data",
"... | Deserializes to primitive type.
:param data: data to deserialize.
:param klass: class literal.
:return: int, long, float, str, bool.
:rtype: int | long | float | str | bool | [
"Deserializes",
"to",
"primitive",
"type",
"."
] | 5ce91559b0a4fbe4fb7758e034eb258202632463 | https://github.com/nmdp-bioinformatics/SeqAnn/blob/5ce91559b0a4fbe4fb7758e034eb258202632463/seqann/util.py#L229-L245 | train | Deserializes to primitive type. |
nmdp-bioinformatics/SeqAnn | seqann/util.py | deserialize_date | def deserialize_date(string):
"""
Deserializes string to date.
:param string: str.
:type string: str
:return: date.
:rtype: date
"""
try:
from dateutil.parser import parse
return parse(string).date()
except ImportError:
return string | python | def deserialize_date(string):
"""
Deserializes string to date.
:param string: str.
:type string: str
:return: date.
:rtype: date
"""
try:
from dateutil.parser import parse
return parse(string).date()
except ImportError:
return string | [
"def",
"deserialize_date",
"(",
"string",
")",
":",
"try",
":",
"from",
"dateutil",
".",
"parser",
"import",
"parse",
"return",
"parse",
"(",
"string",
")",
".",
"date",
"(",
")",
"except",
"ImportError",
":",
"return",
"string"
] | Deserializes string to date.
:param string: str.
:type string: str
:return: date.
:rtype: date | [
"Deserializes",
"string",
"to",
"date",
"."
] | 5ce91559b0a4fbe4fb7758e034eb258202632463 | https://github.com/nmdp-bioinformatics/SeqAnn/blob/5ce91559b0a4fbe4fb7758e034eb258202632463/seqann/util.py#L257-L270 | train | Deserializes string to date. |
nmdp-bioinformatics/SeqAnn | seqann/util.py | deserialize_model | def deserialize_model(data, klass):
"""
Deserializes list or dict to model.
:param data: dict, list.
:type data: dict | list
:param klass: class literal.
:return: model object.
"""
instance = klass()
if not instance.swagger_types:
return data
for attr, attr_type in ite... | python | def deserialize_model(data, klass):
"""
Deserializes list or dict to model.
:param data: dict, list.
:type data: dict | list
:param klass: class literal.
:return: model object.
"""
instance = klass()
if not instance.swagger_types:
return data
for attr, attr_type in ite... | [
"def",
"deserialize_model",
"(",
"data",
",",
"klass",
")",
":",
"instance",
"=",
"klass",
"(",
")",
"if",
"not",
"instance",
".",
"swagger_types",
":",
"return",
"data",
"for",
"attr",
",",
"attr_type",
"in",
"iteritems",
"(",
"instance",
".",
"swagger_ty... | Deserializes list or dict to model.
:param data: dict, list.
:type data: dict | list
:param klass: class literal.
:return: model object. | [
"Deserializes",
"list",
"or",
"dict",
"to",
"model",
"."
] | 5ce91559b0a4fbe4fb7758e034eb258202632463 | https://github.com/nmdp-bioinformatics/SeqAnn/blob/5ce91559b0a4fbe4fb7758e034eb258202632463/seqann/util.py#L291-L312 | train | Deserializes list or dict to model object. |
heronotears/lazyxml | lazyxml/__init__.py | dump | def dump(obj, fp, **kw):
r"""Dump python object to file.
>>> import lazyxml
>>> data = {'demo': {'foo': 1, 'bar': 2}}
>>> lazyxml.dump(data, 'dump.xml')
>>> with open('dump-fp.xml', 'w') as fp:
>>> lazyxml.dump(data, fp)
>>> from cStringIO import StringIO
>>> data = {'demo': {'foo'... | python | def dump(obj, fp, **kw):
r"""Dump python object to file.
>>> import lazyxml
>>> data = {'demo': {'foo': 1, 'bar': 2}}
>>> lazyxml.dump(data, 'dump.xml')
>>> with open('dump-fp.xml', 'w') as fp:
>>> lazyxml.dump(data, fp)
>>> from cStringIO import StringIO
>>> data = {'demo': {'foo'... | [
"def",
"dump",
"(",
"obj",
",",
"fp",
",",
"*",
"*",
"kw",
")",
":",
"xml",
"=",
"dumps",
"(",
"obj",
",",
"*",
"*",
"kw",
")",
"if",
"isinstance",
"(",
"fp",
",",
"basestring",
")",
":",
"with",
"open",
"(",
"fp",
",",
"'w'",
")",
"as",
"f... | r"""Dump python object to file.
>>> import lazyxml
>>> data = {'demo': {'foo': 1, 'bar': 2}}
>>> lazyxml.dump(data, 'dump.xml')
>>> with open('dump-fp.xml', 'w') as fp:
>>> lazyxml.dump(data, fp)
>>> from cStringIO import StringIO
>>> data = {'demo': {'foo': 1, 'bar': 2}}
>>> buffe... | [
"r",
"Dump",
"python",
"object",
"to",
"file",
"."
] | e3f1ebd3f34cfa03d022ddec90e17d60c1c81953 | https://github.com/heronotears/lazyxml/blob/e3f1ebd3f34cfa03d022ddec90e17d60c1c81953/lazyxml/__init__.py#L149-L180 | train | r Dump a Python object to xml. |
LISE-B26/pylabcontrol | pylabcontrol/data_processing/signal_processing.py | power_spectral_density | def power_spectral_density(x, time_step, freq_range = None):
"""
returns the *single sided* power spectral density of the time trace x which is sampled at intervals time_step
Args:
x (array): timetrace
time_step (float): sampling interval of x
freq_range (array or tuple): frequency ... | python | def power_spectral_density(x, time_step, freq_range = None):
"""
returns the *single sided* power spectral density of the time trace x which is sampled at intervals time_step
Args:
x (array): timetrace
time_step (float): sampling interval of x
freq_range (array or tuple): frequency ... | [
"def",
"power_spectral_density",
"(",
"x",
",",
"time_step",
",",
"freq_range",
"=",
"None",
")",
":",
"N",
"=",
"len",
"(",
"x",
")",
"P",
"=",
"2",
"*",
"np",
".",
"abs",
"(",
"np",
".",
"fft",
".",
"rfft",
"(",
"x",
")",
")",
"**",
"2",
"/... | returns the *single sided* power spectral density of the time trace x which is sampled at intervals time_step
Args:
x (array): timetrace
time_step (float): sampling interval of x
freq_range (array or tuple): frequency range in the form [f_min, f_max] to return only the spectrum within this ... | [
"returns",
"the",
"*",
"single",
"sided",
"*",
"power",
"spectral",
"density",
"of",
"the",
"time",
"trace",
"x",
"which",
"is",
"sampled",
"at",
"intervals",
"time_step",
"Args",
":",
"x",
"(",
"array",
")",
":",
"timetrace",
"time_step",
"(",
"float",
... | 67482e5157fcd1c40705e5c2cacfb93564703ed0 | https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/pylabcontrol/data_processing/signal_processing.py#L23-L43 | train | Returns the power spectral density of the time trace x at intervals time_step |
LISE-B26/pylabcontrol | build/lib/pylabcontrol/src/core/probe.py | Probe.value | def value(self):
"""
reads the value from the instrument
"""
value = getattr(self.instrument, self.probe_name)
self.buffer.append(value)
return value | python | def value(self):
"""
reads the value from the instrument
"""
value = getattr(self.instrument, self.probe_name)
self.buffer.append(value)
return value | [
"def",
"value",
"(",
"self",
")",
":",
"value",
"=",
"getattr",
"(",
"self",
".",
"instrument",
",",
"self",
".",
"probe_name",
")",
"self",
".",
"buffer",
".",
"append",
"(",
"value",
")",
"return",
"value"
] | reads the value from the instrument | [
"reads",
"the",
"value",
"from",
"the",
"instrument"
] | 67482e5157fcd1c40705e5c2cacfb93564703ed0 | https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/core/probe.py#L58-L66 | train | reads the value from the instrument and adds it to the buffer |
bennylope/smartystreets.py | smartystreets/data.py | Address.location | def location(self):
"""
Returns the geolocation as a lat/lng pair
"""
try:
lat, lng = self["metadata"]["latitude"], self["metadata"]["longitude"]
except KeyError:
return None
if not lat or not lng:
return None
return lat, lng | python | def location(self):
"""
Returns the geolocation as a lat/lng pair
"""
try:
lat, lng = self["metadata"]["latitude"], self["metadata"]["longitude"]
except KeyError:
return None
if not lat or not lng:
return None
return lat, lng | [
"def",
"location",
"(",
"self",
")",
":",
"try",
":",
"lat",
",",
"lng",
"=",
"self",
"[",
"\"metadata\"",
"]",
"[",
"\"latitude\"",
"]",
",",
"self",
"[",
"\"metadata\"",
"]",
"[",
"\"longitude\"",
"]",
"except",
"KeyError",
":",
"return",
"None",
"if... | Returns the geolocation as a lat/lng pair | [
"Returns",
"the",
"geolocation",
"as",
"a",
"lat",
"/",
"lng",
"pair"
] | f45e37dd52ea7cec8ed43ce2b64724beb6dbbb69 | https://github.com/bennylope/smartystreets.py/blob/f45e37dd52ea7cec8ed43ce2b64724beb6dbbb69/smartystreets/data.py#L15-L27 | train | Returns the geolocation as a lat / lng pair
|
bennylope/smartystreets.py | smartystreets/data.py | AddressCollection.get | def get(self, key):
"""
Returns an address by user controlled input ID
:param key: an input_id used to tag a lookup address
:return: a matching Address
"""
try:
return self[self.id_lookup.get(key)]
except TypeError:
raise KeyError | python | def get(self, key):
"""
Returns an address by user controlled input ID
:param key: an input_id used to tag a lookup address
:return: a matching Address
"""
try:
return self[self.id_lookup.get(key)]
except TypeError:
raise KeyError | [
"def",
"get",
"(",
"self",
",",
"key",
")",
":",
"try",
":",
"return",
"self",
"[",
"self",
".",
"id_lookup",
".",
"get",
"(",
"key",
")",
"]",
"except",
"TypeError",
":",
"raise",
"KeyError"
] | Returns an address by user controlled input ID
:param key: an input_id used to tag a lookup address
:return: a matching Address | [
"Returns",
"an",
"address",
"by",
"user",
"controlled",
"input",
"ID"
] | f45e37dd52ea7cec8ed43ce2b64724beb6dbbb69 | https://github.com/bennylope/smartystreets.py/blob/f45e37dd52ea7cec8ed43ce2b64724beb6dbbb69/smartystreets/data.py#L87-L98 | train | Returns an address by user controlled input ID |
bennylope/smartystreets.py | smartystreets/data.py | AddressCollection.get_index | def get_index(self, key):
"""
Returns an address by input index, a value that matches the list index of the provided
lookup value, not necessarily the result.
:param key: an input_index matching the index of the provided address
:return: a matching Address
"""
tr... | python | def get_index(self, key):
"""
Returns an address by input index, a value that matches the list index of the provided
lookup value, not necessarily the result.
:param key: an input_index matching the index of the provided address
:return: a matching Address
"""
tr... | [
"def",
"get_index",
"(",
"self",
",",
"key",
")",
":",
"try",
":",
"return",
"self",
"[",
"self",
".",
"index_lookup",
".",
"get",
"(",
"key",
")",
"]",
"except",
"TypeError",
":",
"raise",
"KeyError"
] | Returns an address by input index, a value that matches the list index of the provided
lookup value, not necessarily the result.
:param key: an input_index matching the index of the provided address
:return: a matching Address | [
"Returns",
"an",
"address",
"by",
"input",
"index",
"a",
"value",
"that",
"matches",
"the",
"list",
"index",
"of",
"the",
"provided",
"lookup",
"value",
"not",
"necessarily",
"the",
"result",
"."
] | f45e37dd52ea7cec8ed43ce2b64724beb6dbbb69 | https://github.com/bennylope/smartystreets.py/blob/f45e37dd52ea7cec8ed43ce2b64724beb6dbbb69/smartystreets/data.py#L100-L112 | train | Returns an address by input index |
LISE-B26/pylabcontrol | build/lib/tools/export_default.py | export_default_instruments | def export_default_instruments(target_folder, source_folder = None, raise_errors = False, verbose=True):
"""
tries to instantiate all the instruments that are imported in /instruments/__init__.py
and saves instruments that could be instantiate into a .b2 file in the folder path
Args:
target_fold... | python | def export_default_instruments(target_folder, source_folder = None, raise_errors = False, verbose=True):
"""
tries to instantiate all the instruments that are imported in /instruments/__init__.py
and saves instruments that could be instantiate into a .b2 file in the folder path
Args:
target_fold... | [
"def",
"export_default_instruments",
"(",
"target_folder",
",",
"source_folder",
"=",
"None",
",",
"raise_errors",
"=",
"False",
",",
"verbose",
"=",
"True",
")",
":",
"print",
"(",
"'export_def_instr called'",
")",
"instruments_to_load",
"=",
"get_classes_in_folder",... | tries to instantiate all the instruments that are imported in /instruments/__init__.py
and saves instruments that could be instantiate into a .b2 file in the folder path
Args:
target_folder: target path for .b26 files | [
"tries",
"to",
"instantiate",
"all",
"the",
"instruments",
"that",
"are",
"imported",
"in",
"/",
"instruments",
"/",
"__init__",
".",
"py",
"and",
"saves",
"instruments",
"that",
"could",
"be",
"instantiate",
"into",
"a",
".",
"b2",
"file",
"in",
"the",
"f... | 67482e5157fcd1c40705e5c2cacfb93564703ed0 | https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/tools/export_default.py#L115-L144 | train | Exports all the instruments that are imported in source_folder into target_folder. |
zero-os/zerotier_client | zerotier/NetworkRule.py | NetworkRule.create | def create(action=None, etherType=None, ruleNo=None):
"""
:type action: str
:type etherType: int
:type ruleNo: int
:rtype: NetworkRule
"""
return NetworkRule(
action=action,
etherType=etherType,
ruleNo=ruleNo,
) | python | def create(action=None, etherType=None, ruleNo=None):
"""
:type action: str
:type etherType: int
:type ruleNo: int
:rtype: NetworkRule
"""
return NetworkRule(
action=action,
etherType=etherType,
ruleNo=ruleNo,
) | [
"def",
"create",
"(",
"action",
"=",
"None",
",",
"etherType",
"=",
"None",
",",
"ruleNo",
"=",
"None",
")",
":",
"return",
"NetworkRule",
"(",
"action",
"=",
"action",
",",
"etherType",
"=",
"etherType",
",",
"ruleNo",
"=",
"ruleNo",
",",
")"
] | :type action: str
:type etherType: int
:type ruleNo: int
:rtype: NetworkRule | [
":",
"type",
"action",
":",
"str",
":",
"type",
"etherType",
":",
"int",
":",
"type",
"ruleNo",
":",
"int",
":",
"rtype",
":",
"NetworkRule"
] | 03993da11e69d837a0308a2f41ae7b378692fd82 | https://github.com/zero-os/zerotier_client/blob/03993da11e69d837a0308a2f41ae7b378692fd82/zerotier/NetworkRule.py#L14-L26 | train | Create a new NetworkRule object. |
etal/biofrills | biofrills/stats/chisq.py | chisqprob | def chisqprob(x, df):
"""
Probability value (1-tail) for the Chi^2 probability distribution.
Broadcasting rules apply.
Parameters
----------
x : array_like or float > 0
df : array_like or float, probably int >= 1
Returns
-------
chisqprob : ndarray
The area from `chis... | python | def chisqprob(x, df):
"""
Probability value (1-tail) for the Chi^2 probability distribution.
Broadcasting rules apply.
Parameters
----------
x : array_like or float > 0
df : array_like or float, probably int >= 1
Returns
-------
chisqprob : ndarray
The area from `chis... | [
"def",
"chisqprob",
"(",
"x",
",",
"df",
")",
":",
"if",
"x",
"<=",
"0",
":",
"return",
"1.0",
"if",
"x",
"==",
"0",
":",
"return",
"0.0",
"if",
"df",
"<=",
"0",
":",
"raise",
"ValueError",
"(",
"\"Domain error.\"",
")",
"if",
"x",
"<",
"1.0",
... | Probability value (1-tail) for the Chi^2 probability distribution.
Broadcasting rules apply.
Parameters
----------
x : array_like or float > 0
df : array_like or float, probably int >= 1
Returns
-------
chisqprob : ndarray
The area from `chisq` to infinity under the Chi^2 pro... | [
"Probability",
"value",
"(",
"1",
"-",
"tail",
")",
"for",
"the",
"Chi^2",
"probability",
"distribution",
"."
] | 36684bb6c7632f96215e8b2b4ebc86640f331bcd | https://github.com/etal/biofrills/blob/36684bb6c7632f96215e8b2b4ebc86640f331bcd/biofrills/stats/chisq.py#L17-L44 | train | Calculates the Chisq probability value for a given number of degrees of freedom x. |
etal/biofrills | biofrills/stats/chisq.py | _igamc | def _igamc(a, x):
"""Complemented incomplete Gamma integral.
SYNOPSIS:
double a, x, y, igamc();
y = igamc( a, x );
DESCRIPTION:
The function is defined by::
igamc(a,x) = 1 - igam(a,x)
inf.
-
... | python | def _igamc(a, x):
"""Complemented incomplete Gamma integral.
SYNOPSIS:
double a, x, y, igamc();
y = igamc( a, x );
DESCRIPTION:
The function is defined by::
igamc(a,x) = 1 - igam(a,x)
inf.
-
... | [
"def",
"_igamc",
"(",
"a",
",",
"x",
")",
":",
"# Compute x**a * exp(-x) / Gamma(a)",
"ax",
"=",
"math",
".",
"exp",
"(",
"a",
"*",
"math",
".",
"log",
"(",
"x",
")",
"-",
"x",
"-",
"math",
".",
"lgamma",
"(",
"a",
")",
")",
"# Continued fraction",
... | Complemented incomplete Gamma integral.
SYNOPSIS:
double a, x, y, igamc();
y = igamc( a, x );
DESCRIPTION:
The function is defined by::
igamc(a,x) = 1 - igam(a,x)
inf.
-
1 | | -t a... | [
"Complemented",
"incomplete",
"Gamma",
"integral",
"."
] | 36684bb6c7632f96215e8b2b4ebc86640f331bcd | https://github.com/etal/biofrills/blob/36684bb6c7632f96215e8b2b4ebc86640f331bcd/biofrills/stats/chisq.py#L47-L110 | train | Complemented incomplete Gamma integral. |
etal/biofrills | biofrills/stats/chisq.py | _igam | def _igam(a, x):
"""Left tail of incomplete Gamma function:
inf. k
a -x - x
x e > ----------
- -
k=0 | (a+k+1)
"""
# Compute x**a * exp(-x) / Gamma(a)
ax = math.exp(a * math.log(x) - x - math.lgamma(a))
# Power series
r ... | python | def _igam(a, x):
"""Left tail of incomplete Gamma function:
inf. k
a -x - x
x e > ----------
- -
k=0 | (a+k+1)
"""
# Compute x**a * exp(-x) / Gamma(a)
ax = math.exp(a * math.log(x) - x - math.lgamma(a))
# Power series
r ... | [
"def",
"_igam",
"(",
"a",
",",
"x",
")",
":",
"# Compute x**a * exp(-x) / Gamma(a)",
"ax",
"=",
"math",
".",
"exp",
"(",
"a",
"*",
"math",
".",
"log",
"(",
"x",
")",
"-",
"x",
"-",
"math",
".",
"lgamma",
"(",
"a",
")",
")",
"# Power series",
"r",
... | Left tail of incomplete Gamma function:
inf. k
a -x - x
x e > ----------
- -
k=0 | (a+k+1) | [
"Left",
"tail",
"of",
"incomplete",
"Gamma",
"function",
":"
] | 36684bb6c7632f96215e8b2b4ebc86640f331bcd | https://github.com/etal/biofrills/blob/36684bb6c7632f96215e8b2b4ebc86640f331bcd/biofrills/stats/chisq.py#L113-L135 | train | Left tail of incomplete Gamma function |
lreis2415/PyGeoC | examples/ex04_watershed_delineation.py | main | def main():
"""The simplest usage of watershed delineation based on TauDEM."""
dem = '../tests/data/Jamaica_dem.tif'
num_proc = 2
wp = '../tests/data/tmp_results/wtsd_delineation'
TauDEMWorkflow.watershed_delineation(num_proc, dem, workingdir=wp) | python | def main():
"""The simplest usage of watershed delineation based on TauDEM."""
dem = '../tests/data/Jamaica_dem.tif'
num_proc = 2
wp = '../tests/data/tmp_results/wtsd_delineation'
TauDEMWorkflow.watershed_delineation(num_proc, dem, workingdir=wp) | [
"def",
"main",
"(",
")",
":",
"dem",
"=",
"'../tests/data/Jamaica_dem.tif'",
"num_proc",
"=",
"2",
"wp",
"=",
"'../tests/data/tmp_results/wtsd_delineation'",
"TauDEMWorkflow",
".",
"watershed_delineation",
"(",
"num_proc",
",",
"dem",
",",
"workingdir",
"=",
"wp",
"... | The simplest usage of watershed delineation based on TauDEM. | [
"The",
"simplest",
"usage",
"of",
"watershed",
"delineation",
"based",
"on",
"TauDEM",
"."
] | 9a92d1a229bb74298e3c57f27c97079980b5f729 | https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/examples/ex04_watershed_delineation.py#L8-L14 | train | The simplest usage of watershed delineation based on TauDEM. |
zero-os/zerotier_client | zerotier/SystemStatus.py | SystemStatus.create | def create(clock=None, loginMethods=None, online=None, paidPlans=None, smsEnabled=None, stripePublishableKey=None, uptime=None, user=None, version=None):
"""
:type clock: int
:type loginMethods: dict
:type online: bool
:type paidPlans: dict
:type smsEnabled: bool
... | python | def create(clock=None, loginMethods=None, online=None, paidPlans=None, smsEnabled=None, stripePublishableKey=None, uptime=None, user=None, version=None):
"""
:type clock: int
:type loginMethods: dict
:type online: bool
:type paidPlans: dict
:type smsEnabled: bool
... | [
"def",
"create",
"(",
"clock",
"=",
"None",
",",
"loginMethods",
"=",
"None",
",",
"online",
"=",
"None",
",",
"paidPlans",
"=",
"None",
",",
"smsEnabled",
"=",
"None",
",",
"stripePublishableKey",
"=",
"None",
",",
"uptime",
"=",
"None",
",",
"user",
... | :type clock: int
:type loginMethods: dict
:type online: bool
:type paidPlans: dict
:type smsEnabled: bool
:type stripePublishableKey: str
:type uptime: int
:type user: User
:type version: str
:rtype: SystemStatus | [
":",
"type",
"clock",
":",
"int",
":",
"type",
"loginMethods",
":",
"dict",
":",
"type",
"online",
":",
"bool",
":",
"type",
"paidPlans",
":",
"dict",
":",
"type",
"smsEnabled",
":",
"bool",
":",
"type",
"stripePublishableKey",
":",
"str",
":",
"type",
... | 03993da11e69d837a0308a2f41ae7b378692fd82 | https://github.com/zero-os/zerotier_client/blob/03993da11e69d837a0308a2f41ae7b378692fd82/zerotier/SystemStatus.py#L15-L39 | train | Creates a new SystemStatus object. |
LISE-B26/pylabcontrol | build/lib/pylabcontrol/tools/export_default.py | find_exportable_in_python_files | def find_exportable_in_python_files(folder_name, class_type, verbose = True):
"""
load all the instruments or script objects that are located in folder_name and
return a dictionary with the script class name and path_to_python_file
Args:
folder_name (string): folder in which to search for class ... | python | def find_exportable_in_python_files(folder_name, class_type, verbose = True):
"""
load all the instruments or script objects that are located in folder_name and
return a dictionary with the script class name and path_to_python_file
Args:
folder_name (string): folder in which to search for class ... | [
"def",
"find_exportable_in_python_files",
"(",
"folder_name",
",",
"class_type",
",",
"verbose",
"=",
"True",
")",
":",
"# if the module name was passed instead of a filename, figure out the path to the module",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"folder_nam... | load all the instruments or script objects that are located in folder_name and
return a dictionary with the script class name and path_to_python_file
Args:
folder_name (string): folder in which to search for class objects / or name of module
class_type (string or class): class type for which to ... | [
"load",
"all",
"the",
"instruments",
"or",
"script",
"objects",
"that",
"are",
"located",
"in",
"folder_name",
"and",
"return",
"a",
"dictionary",
"with",
"the",
"script",
"class",
"name",
"and",
"path_to_python_file",
"Args",
":",
"folder_name",
"(",
"string",
... | 67482e5157fcd1c40705e5c2cacfb93564703ed0 | https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/tools/export_default.py#L26-L81 | train | Find all the instruments or scripts that are located in folder_name and return a dictionary with the class name and path_to_python_file. |
toros-astro/corral | corral/qa.py | default_qai | def default_qai(qareport):
"""QAI = 2 * (TP * (PT/PNC) * COV) / (1 + exp(MSE/tau))
Where:
TP: If all tests passes is 1, 0 otherwise.
PT: Processors and commands tested.
PCN: The number number of processors (Loader, Steps and Alerts)
and commands.
COV: The code cover... | python | def default_qai(qareport):
"""QAI = 2 * (TP * (PT/PNC) * COV) / (1 + exp(MSE/tau))
Where:
TP: If all tests passes is 1, 0 otherwise.
PT: Processors and commands tested.
PCN: The number number of processors (Loader, Steps and Alerts)
and commands.
COV: The code cover... | [
"def",
"default_qai",
"(",
"qareport",
")",
":",
"TP",
"=",
"1.",
"if",
"qareport",
".",
"is_test_sucess",
"else",
"0.",
"PCN",
"=",
"qareport",
".",
"processors_number",
"+",
"qareport",
".",
"commands_number",
"PT_div_PCN",
"=",
"float",
"(",
"qareport",
"... | QAI = 2 * (TP * (PT/PNC) * COV) / (1 + exp(MSE/tau))
Where:
TP: If all tests passes is 1, 0 otherwise.
PT: Processors and commands tested.
PCN: The number number of processors (Loader, Steps and Alerts)
and commands.
COV: The code coverage (between 0 and 1).
MSE... | [
"QAI",
"=",
"2",
"*",
"(",
"TP",
"*",
"(",
"PT",
"/",
"PNC",
")",
"*",
"COV",
")",
"/",
"(",
"1",
"+",
"exp",
"(",
"MSE",
"/",
"tau",
"))"
] | 75474b38ff366330d33644461a902d07374a5bbc | https://github.com/toros-astro/corral/blob/75474b38ff366330d33644461a902d07374a5bbc/corral/qa.py#L380-L403 | train | Default QAI for the given Qareport. |
CitrineInformatics/pif-dft | dfttopif/parsers/pwscf.py | PwscfParser._get_line | def _get_line(self, search_string, search_file, return_string=True, case_sens=True):
'''Return the first line containing a set of strings in a file.
If return_string is False, we just return whether such a line
was found. If case_sens is False, the search is case
insensitive.
'... | python | def _get_line(self, search_string, search_file, return_string=True, case_sens=True):
'''Return the first line containing a set of strings in a file.
If return_string is False, we just return whether such a line
was found. If case_sens is False, the search is case
insensitive.
'... | [
"def",
"_get_line",
"(",
"self",
",",
"search_string",
",",
"search_file",
",",
"return_string",
"=",
"True",
",",
"case_sens",
"=",
"True",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"search_file",
")",
":",
"# if single search string",
"if",
... | Return the first line containing a set of strings in a file.
If return_string is False, we just return whether such a line
was found. If case_sens is False, the search is case
insensitive. | [
"Return",
"the",
"first",
"line",
"containing",
"a",
"set",
"of",
"strings",
"in",
"a",
"file",
"."
] | d5411dc1f6c6e8d454b132977ca7ab3bb8131a80 | https://github.com/CitrineInformatics/pif-dft/blob/d5411dc1f6c6e8d454b132977ca7ab3bb8131a80/dfttopif/parsers/pwscf.py#L66-L88 | train | Return the first line containing a set of strings in a file. |
CitrineInformatics/pif-dft | dfttopif/parsers/pwscf.py | PwscfParser.get_cutoff_energy | def get_cutoff_energy(self):
'''Determine the cutoff energy from the output'''
return Value(
scalars=[Scalar(value=self.settings["kinetic-energy cutoff"])],
units=self.settings['kinetic-energy cutoff units']
) | python | def get_cutoff_energy(self):
'''Determine the cutoff energy from the output'''
return Value(
scalars=[Scalar(value=self.settings["kinetic-energy cutoff"])],
units=self.settings['kinetic-energy cutoff units']
) | [
"def",
"get_cutoff_energy",
"(",
"self",
")",
":",
"return",
"Value",
"(",
"scalars",
"=",
"[",
"Scalar",
"(",
"value",
"=",
"self",
".",
"settings",
"[",
"\"kinetic-energy cutoff\"",
"]",
")",
"]",
",",
"units",
"=",
"self",
".",
"settings",
"[",
"'kine... | Determine the cutoff energy from the output | [
"Determine",
"the",
"cutoff",
"energy",
"from",
"the",
"output"
] | d5411dc1f6c6e8d454b132977ca7ab3bb8131a80 | https://github.com/CitrineInformatics/pif-dft/blob/d5411dc1f6c6e8d454b132977ca7ab3bb8131a80/dfttopif/parsers/pwscf.py#L98-L103 | train | Determine the cutoff energy from the output |
CitrineInformatics/pif-dft | dfttopif/parsers/pwscf.py | PwscfParser._is_converged | def _is_converged(self):
'''Determine if calculation converged; for a relaxation (static) run
we look for ionic (electronic) convergence in the output'''
if self.is_relaxed():
# relaxation run case
return self._get_line(['End of', 'Geometry Optimization'], self.outputf, r... | python | def _is_converged(self):
'''Determine if calculation converged; for a relaxation (static) run
we look for ionic (electronic) convergence in the output'''
if self.is_relaxed():
# relaxation run case
return self._get_line(['End of', 'Geometry Optimization'], self.outputf, r... | [
"def",
"_is_converged",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_relaxed",
"(",
")",
":",
"# relaxation run case",
"return",
"self",
".",
"_get_line",
"(",
"[",
"'End of'",
",",
"'Geometry Optimization'",
"]",
",",
"self",
".",
"outputf",
",",
"return_s... | Determine if calculation converged; for a relaxation (static) run
we look for ionic (electronic) convergence in the output | [
"Determine",
"if",
"calculation",
"converged",
";",
"for",
"a",
"relaxation",
"(",
"static",
")",
"run",
"we",
"look",
"for",
"ionic",
"(",
"electronic",
")",
"convergence",
"in",
"the",
"output"
] | d5411dc1f6c6e8d454b132977ca7ab3bb8131a80 | https://github.com/CitrineInformatics/pif-dft/blob/d5411dc1f6c6e8d454b132977ca7ab3bb8131a80/dfttopif/parsers/pwscf.py#L114-L122 | train | Determine if calculation converged ; for a relaxation run
we look for ionic run
we look for convergence in the output |
CitrineInformatics/pif-dft | dfttopif/parsers/pwscf.py | PwscfParser.get_KPPRA | def get_KPPRA(self):
'''Determine the no. of k-points in the BZ (from the input) times the
no. of atoms (from the output)'''
# Find the no. of k-points
fp = open(self.inputf).readlines()
for l,ll in enumerate(fp):
if "K_POINTS" in ll:
# determine the t... | python | def get_KPPRA(self):
'''Determine the no. of k-points in the BZ (from the input) times the
no. of atoms (from the output)'''
# Find the no. of k-points
fp = open(self.inputf).readlines()
for l,ll in enumerate(fp):
if "K_POINTS" in ll:
# determine the t... | [
"def",
"get_KPPRA",
"(",
"self",
")",
":",
"# Find the no. of k-points",
"fp",
"=",
"open",
"(",
"self",
".",
"inputf",
")",
".",
"readlines",
"(",
")",
"for",
"l",
",",
"ll",
"in",
"enumerate",
"(",
"fp",
")",
":",
"if",
"\"K_POINTS\"",
"in",
"ll",
... | Determine the no. of k-points in the BZ (from the input) times the
no. of atoms (from the output) | [
"Determine",
"the",
"no",
".",
"of",
"k",
"-",
"points",
"in",
"the",
"BZ",
"(",
"from",
"the",
"input",
")",
"times",
"the",
"no",
".",
"of",
"atoms",
"(",
"from",
"the",
"output",
")"
] | d5411dc1f6c6e8d454b132977ca7ab3bb8131a80 | https://github.com/CitrineInformatics/pif-dft/blob/d5411dc1f6c6e8d454b132977ca7ab3bb8131a80/dfttopif/parsers/pwscf.py#L124-L164 | train | Determine the no. of k - points in the BZ ( from the input ) times the
no. of atoms ( from the output ) |
CitrineInformatics/pif-dft | dfttopif/parsers/pwscf.py | PwscfParser.get_pp_name | def get_pp_name(self):
'''Determine the pseudopotential names from the output'''
ppnames = []
# Find the number of atom types
natomtypes = int(self._get_line('number of atomic types', self.outputf).split()[5])
# Find the pseudopotential names
with open(self.outputf) as fp... | python | def get_pp_name(self):
'''Determine the pseudopotential names from the output'''
ppnames = []
# Find the number of atom types
natomtypes = int(self._get_line('number of atomic types', self.outputf).split()[5])
# Find the pseudopotential names
with open(self.outputf) as fp... | [
"def",
"get_pp_name",
"(",
"self",
")",
":",
"ppnames",
"=",
"[",
"]",
"# Find the number of atom types",
"natomtypes",
"=",
"int",
"(",
"self",
".",
"_get_line",
"(",
"'number of atomic types'",
",",
"self",
".",
"outputf",
")",
".",
"split",
"(",
")",
"[",... | Determine the pseudopotential names from the output | [
"Determine",
"the",
"pseudopotential",
"names",
"from",
"the",
"output"
] | d5411dc1f6c6e8d454b132977ca7ab3bb8131a80 | https://github.com/CitrineInformatics/pif-dft/blob/d5411dc1f6c6e8d454b132977ca7ab3bb8131a80/dfttopif/parsers/pwscf.py#L171-L183 | train | Determine the pseudopotential names from the output file |
CitrineInformatics/pif-dft | dfttopif/parsers/pwscf.py | PwscfParser.get_U_settings | def get_U_settings(self):
'''Determine the DFT+U type and parameters from the output'''
with open(self.outputf) as fp:
for line in fp:
if "LDA+U calculation" in line:
U_param = {}
U_param['Type'] = line.split()[0]
U_... | python | def get_U_settings(self):
'''Determine the DFT+U type and parameters from the output'''
with open(self.outputf) as fp:
for line in fp:
if "LDA+U calculation" in line:
U_param = {}
U_param['Type'] = line.split()[0]
U_... | [
"def",
"get_U_settings",
"(",
"self",
")",
":",
"with",
"open",
"(",
"self",
".",
"outputf",
")",
"as",
"fp",
":",
"for",
"line",
"in",
"fp",
":",
"if",
"\"LDA+U calculation\"",
"in",
"line",
":",
"U_param",
"=",
"{",
"}",
"U_param",
"[",
"'Type'",
"... | Determine the DFT+U type and parameters from the output | [
"Determine",
"the",
"DFT",
"+",
"U",
"type",
"and",
"parameters",
"from",
"the",
"output"
] | d5411dc1f6c6e8d454b132977ca7ab3bb8131a80 | https://github.com/CitrineInformatics/pif-dft/blob/d5411dc1f6c6e8d454b132977ca7ab3bb8131a80/dfttopif/parsers/pwscf.py#L185-L205 | train | Determine the DFT + U type and parameters from the output file |
CitrineInformatics/pif-dft | dfttopif/parsers/pwscf.py | PwscfParser.get_vdW_settings | def get_vdW_settings(self):
'''Determine the vdW type if using vdW xc functional or correction
scheme from the input otherwise'''
xc = self.get_xc_functional().scalars[0].value
if 'vdw' in xc.lower(): # vdW xc functional
return Value(scalars=[Scalar(value=xc)])
else:
... | python | def get_vdW_settings(self):
'''Determine the vdW type if using vdW xc functional or correction
scheme from the input otherwise'''
xc = self.get_xc_functional().scalars[0].value
if 'vdw' in xc.lower(): # vdW xc functional
return Value(scalars=[Scalar(value=xc)])
else:
... | [
"def",
"get_vdW_settings",
"(",
"self",
")",
":",
"xc",
"=",
"self",
".",
"get_xc_functional",
"(",
")",
".",
"scalars",
"[",
"0",
"]",
".",
"value",
"if",
"'vdw'",
"in",
"xc",
".",
"lower",
"(",
")",
":",
"# vdW xc functional",
"return",
"Value",
"(",... | Determine the vdW type if using vdW xc functional or correction
scheme from the input otherwise | [
"Determine",
"the",
"vdW",
"type",
"if",
"using",
"vdW",
"xc",
"functional",
"or",
"correction",
"scheme",
"from",
"the",
"input",
"otherwise"
] | d5411dc1f6c6e8d454b132977ca7ab3bb8131a80 | https://github.com/CitrineInformatics/pif-dft/blob/d5411dc1f6c6e8d454b132977ca7ab3bb8131a80/dfttopif/parsers/pwscf.py#L207-L224 | train | Determine the vdW type if using vdW xc functional or correction
scheme from the input otherwise return None |
CitrineInformatics/pif-dft | dfttopif/parsers/pwscf.py | PwscfParser.get_stresses | def get_stresses(self):
'''Determine the stress tensor from the output'''
if "stress" not in self.settings:
return None
wrapped = [[Scalar(value=x) for x in y] for y in self.settings["stress"]]
return Property(matrices=[wrapped], units=self.settings["stress units"]) | python | def get_stresses(self):
'''Determine the stress tensor from the output'''
if "stress" not in self.settings:
return None
wrapped = [[Scalar(value=x) for x in y] for y in self.settings["stress"]]
return Property(matrices=[wrapped], units=self.settings["stress units"]) | [
"def",
"get_stresses",
"(",
"self",
")",
":",
"if",
"\"stress\"",
"not",
"in",
"self",
".",
"settings",
":",
"return",
"None",
"wrapped",
"=",
"[",
"[",
"Scalar",
"(",
"value",
"=",
"x",
")",
"for",
"x",
"in",
"y",
"]",
"for",
"y",
"in",
"self",
... | Determine the stress tensor from the output | [
"Determine",
"the",
"stress",
"tensor",
"from",
"the",
"output"
] | d5411dc1f6c6e8d454b132977ca7ab3bb8131a80 | https://github.com/CitrineInformatics/pif-dft/blob/d5411dc1f6c6e8d454b132977ca7ab3bb8131a80/dfttopif/parsers/pwscf.py#L230-L235 | train | Determine the stress tensor from the output |
CitrineInformatics/pif-dft | dfttopif/parsers/pwscf.py | PwscfParser.get_output_structure | def get_output_structure(self):
'''Determine the structure from the output'''
bohr_to_angstrom = 0.529177249
# determine the number of atoms
natoms = int(float(self._get_line('number of atoms/cell', self.outputf).split('=')[-1]))
# determine the initial lattice parameter
... | python | def get_output_structure(self):
'''Determine the structure from the output'''
bohr_to_angstrom = 0.529177249
# determine the number of atoms
natoms = int(float(self._get_line('number of atoms/cell', self.outputf).split('=')[-1]))
# determine the initial lattice parameter
... | [
"def",
"get_output_structure",
"(",
"self",
")",
":",
"bohr_to_angstrom",
"=",
"0.529177249",
"# determine the number of atoms",
"natoms",
"=",
"int",
"(",
"float",
"(",
"self",
".",
"_get_line",
"(",
"'number of atoms/cell'",
",",
"self",
".",
"outputf",
")",
"."... | Determine the structure from the output | [
"Determine",
"the",
"structure",
"from",
"the",
"output"
] | d5411dc1f6c6e8d454b132977ca7ab3bb8131a80 | https://github.com/CitrineInformatics/pif-dft/blob/d5411dc1f6c6e8d454b132977ca7ab3bb8131a80/dfttopif/parsers/pwscf.py#L237-L317 | train | Determine the structure from the output file |
CitrineInformatics/pif-dft | dfttopif/parsers/pwscf.py | PwscfParser.get_dos | def get_dos(self):
'''Find the total DOS shifted by the Fermi energy'''
# find the dos file
fildos = ''
for f in self._files:
with open(f, 'r') as fp:
first_line = next(fp)
if "E (eV)" in first_line and "Int dos(E)" in first_line:
... | python | def get_dos(self):
'''Find the total DOS shifted by the Fermi energy'''
# find the dos file
fildos = ''
for f in self._files:
with open(f, 'r') as fp:
first_line = next(fp)
if "E (eV)" in first_line and "Int dos(E)" in first_line:
... | [
"def",
"get_dos",
"(",
"self",
")",
":",
"# find the dos file",
"fildos",
"=",
"''",
"for",
"f",
"in",
"self",
".",
"_files",
":",
"with",
"open",
"(",
"f",
",",
"'r'",
")",
"as",
"fp",
":",
"first_line",
"=",
"next",
"(",
"fp",
")",
"if",
"\"E (eV... | Find the total DOS shifted by the Fermi energy | [
"Find",
"the",
"total",
"DOS",
"shifted",
"by",
"the",
"Fermi",
"energy"
] | d5411dc1f6c6e8d454b132977ca7ab3bb8131a80 | https://github.com/CitrineInformatics/pif-dft/blob/d5411dc1f6c6e8d454b132977ca7ab3bb8131a80/dfttopif/parsers/pwscf.py#L319-L347 | train | Find the total DOS shifted by the Fermi energy |
CitrineInformatics/pif-dft | dfttopif/parsers/pwscf.py | PwscfParser.get_band_gap | def get_band_gap(self):
'''Compute the band gap from the DOS'''
dosdata = self.get_dos()
if type(dosdata) == type(None):
return None # cannot find DOS
else:
energy = dosdata.conditions.scalars
dos = dosdata.scalars
step_size = energy[1].val... | python | def get_band_gap(self):
'''Compute the band gap from the DOS'''
dosdata = self.get_dos()
if type(dosdata) == type(None):
return None # cannot find DOS
else:
energy = dosdata.conditions.scalars
dos = dosdata.scalars
step_size = energy[1].val... | [
"def",
"get_band_gap",
"(",
"self",
")",
":",
"dosdata",
"=",
"self",
".",
"get_dos",
"(",
")",
"if",
"type",
"(",
"dosdata",
")",
"==",
"type",
"(",
"None",
")",
":",
"return",
"None",
"# cannot find DOS",
"else",
":",
"energy",
"=",
"dosdata",
".",
... | Compute the band gap from the DOS | [
"Compute",
"the",
"band",
"gap",
"from",
"the",
"DOS"
] | d5411dc1f6c6e8d454b132977ca7ab3bb8131a80 | https://github.com/CitrineInformatics/pif-dft/blob/d5411dc1f6c6e8d454b132977ca7ab3bb8131a80/dfttopif/parsers/pwscf.py#L369-L396 | train | Compute the band gap from the DOS |
idlesign/django-sitecats | sitecats/toolbox.py | get_category_aliases_under | def get_category_aliases_under(parent_alias=None):
"""Returns a list of category aliases under the given parent.
Could be useful to pass to `ModelWithCategory.enable_category_lists_editor`
in `additional_parents_aliases` parameter.
:param str|None parent_alias: Parent alias or None to categories under... | python | def get_category_aliases_under(parent_alias=None):
"""Returns a list of category aliases under the given parent.
Could be useful to pass to `ModelWithCategory.enable_category_lists_editor`
in `additional_parents_aliases` parameter.
:param str|None parent_alias: Parent alias or None to categories under... | [
"def",
"get_category_aliases_under",
"(",
"parent_alias",
"=",
"None",
")",
":",
"return",
"[",
"ch",
".",
"alias",
"for",
"ch",
"in",
"get_cache",
"(",
")",
".",
"get_children_for",
"(",
"parent_alias",
",",
"only_with_aliases",
"=",
"True",
")",
"]"
] | Returns a list of category aliases under the given parent.
Could be useful to pass to `ModelWithCategory.enable_category_lists_editor`
in `additional_parents_aliases` parameter.
:param str|None parent_alias: Parent alias or None to categories under root
:rtype: list
:return: a list of category ali... | [
"Returns",
"a",
"list",
"of",
"category",
"aliases",
"under",
"the",
"given",
"parent",
"."
] | 9b45e91fc0dcb63a0011780437fe28145e3ecce9 | https://github.com/idlesign/django-sitecats/blob/9b45e91fc0dcb63a0011780437fe28145e3ecce9/sitecats/toolbox.py#L16-L26 | train | Returns a list of category aliases under the given parent. |
idlesign/django-sitecats | sitecats/toolbox.py | get_category_lists | def get_category_lists(init_kwargs=None, additional_parents_aliases=None, obj=None):
"""Returns a list of CategoryList objects, optionally associated with
a given model instance.
:param dict|None init_kwargs:
:param list|None additional_parents_aliases:
:param Model|None obj: Model instance to get ... | python | def get_category_lists(init_kwargs=None, additional_parents_aliases=None, obj=None):
"""Returns a list of CategoryList objects, optionally associated with
a given model instance.
:param dict|None init_kwargs:
:param list|None additional_parents_aliases:
:param Model|None obj: Model instance to get ... | [
"def",
"get_category_lists",
"(",
"init_kwargs",
"=",
"None",
",",
"additional_parents_aliases",
"=",
"None",
",",
"obj",
"=",
"None",
")",
":",
"init_kwargs",
"=",
"init_kwargs",
"or",
"{",
"}",
"additional_parents_aliases",
"=",
"additional_parents_aliases",
"or",... | Returns a list of CategoryList objects, optionally associated with
a given model instance.
:param dict|None init_kwargs:
:param list|None additional_parents_aliases:
:param Model|None obj: Model instance to get categories for
:rtype: list
:return: | [
"Returns",
"a",
"list",
"of",
"CategoryList",
"objects",
"optionally",
"associated",
"with",
"a",
"given",
"model",
"instance",
"."
] | 9b45e91fc0dcb63a0011780437fe28145e3ecce9 | https://github.com/idlesign/django-sitecats/blob/9b45e91fc0dcb63a0011780437fe28145e3ecce9/sitecats/toolbox.py#L29-L68 | train | Returns a list of CategoryList objects optionally associated with a given model instance. |
idlesign/django-sitecats | sitecats/toolbox.py | CategoryRequestHandler.register_lists | def register_lists(self, category_lists, lists_init_kwargs=None, editor_init_kwargs=None):
"""Registers CategoryList objects to handle their requests.
:param list category_lists: CategoryList objects
:param dict lists_init_kwargs: Attributes to apply to each of CategoryList objects
"""
... | python | def register_lists(self, category_lists, lists_init_kwargs=None, editor_init_kwargs=None):
"""Registers CategoryList objects to handle their requests.
:param list category_lists: CategoryList objects
:param dict lists_init_kwargs: Attributes to apply to each of CategoryList objects
"""
... | [
"def",
"register_lists",
"(",
"self",
",",
"category_lists",
",",
"lists_init_kwargs",
"=",
"None",
",",
"editor_init_kwargs",
"=",
"None",
")",
":",
"lists_init_kwargs",
"=",
"lists_init_kwargs",
"or",
"{",
"}",
"editor_init_kwargs",
"=",
"editor_init_kwargs",
"or"... | Registers CategoryList objects to handle their requests.
:param list category_lists: CategoryList objects
:param dict lists_init_kwargs: Attributes to apply to each of CategoryList objects | [
"Registers",
"CategoryList",
"objects",
"to",
"handle",
"their",
"requests",
"."
] | 9b45e91fc0dcb63a0011780437fe28145e3ecce9 | https://github.com/idlesign/django-sitecats/blob/9b45e91fc0dcb63a0011780437fe28145e3ecce9/sitecats/toolbox.py#L254-L280 | train | Registers CategoryList objects to handle their requests. |
idlesign/django-sitecats | sitecats/toolbox.py | CategoryRequestHandler.action_remove | def action_remove(cls, request, category_list):
"""Handles `remove` action from CategoryList editor.
Removes an actual category if a target object is not set for the list.
Removes a tie-to-category object if a target object is set for the list.
:param Request request: Django request ob... | python | def action_remove(cls, request, category_list):
"""Handles `remove` action from CategoryList editor.
Removes an actual category if a target object is not set for the list.
Removes a tie-to-category object if a target object is set for the list.
:param Request request: Django request ob... | [
"def",
"action_remove",
"(",
"cls",
",",
"request",
",",
"category_list",
")",
":",
"if",
"not",
"category_list",
".",
"editor",
".",
"allow_remove",
":",
"raise",
"SitecatsSecurityException",
"(",
"'`action_remove()` is not supported by parent `%s`category.'",
"%",
"ca... | Handles `remove` action from CategoryList editor.
Removes an actual category if a target object is not set for the list.
Removes a tie-to-category object if a target object is set for the list.
:param Request request: Django request object
:param CategoryList category_list: CategoryLis... | [
"Handles",
"remove",
"action",
"from",
"CategoryList",
"editor",
"."
] | 9b45e91fc0dcb63a0011780437fe28145e3ecce9 | https://github.com/idlesign/django-sitecats/blob/9b45e91fc0dcb63a0011780437fe28145e3ecce9/sitecats/toolbox.py#L283-L342 | train | Handles remove action from CategoryList editor. |
idlesign/django-sitecats | sitecats/toolbox.py | CategoryRequestHandler.action_add | def action_add(cls, request, category_list):
"""Handles `add` action from CategoryList editor.
Adds an actual category if a target object is not set for the list.
Adds a tie-to-category object if a target object is set for the list.
:param Request request: Django request object
... | python | def action_add(cls, request, category_list):
"""Handles `add` action from CategoryList editor.
Adds an actual category if a target object is not set for the list.
Adds a tie-to-category object if a target object is set for the list.
:param Request request: Django request object
... | [
"def",
"action_add",
"(",
"cls",
",",
"request",
",",
"category_list",
")",
":",
"if",
"not",
"category_list",
".",
"editor",
".",
"allow_add",
":",
"raise",
"SitecatsSecurityException",
"(",
"'`action_add()` is not supported by `%s` category.'",
"%",
"category_list",
... | Handles `add` action from CategoryList editor.
Adds an actual category if a target object is not set for the list.
Adds a tie-to-category object if a target object is set for the list.
:param Request request: Django request object
:param CategoryList category_list: CategoryList object ... | [
"Handles",
"add",
"action",
"from",
"CategoryList",
"editor",
"."
] | 9b45e91fc0dcb63a0011780437fe28145e3ecce9 | https://github.com/idlesign/django-sitecats/blob/9b45e91fc0dcb63a0011780437fe28145e3ecce9/sitecats/toolbox.py#L345-L418 | train | Handles add action from CategoryList editor. |
idlesign/django-sitecats | sitecats/toolbox.py | CategoryRequestHandler.listen | def listen(self):
"""Instructs handler to listen to Django request and handle
CategoryList editor requests (if any).
:return: None on success otherwise and exception from SitecatsException family is raised.
"""
requested_action = self._request.POST.get('category_action', False)
... | python | def listen(self):
"""Instructs handler to listen to Django request and handle
CategoryList editor requests (if any).
:return: None on success otherwise and exception from SitecatsException family is raised.
"""
requested_action = self._request.POST.get('category_action', False)
... | [
"def",
"listen",
"(",
"self",
")",
":",
"requested_action",
"=",
"self",
".",
"_request",
".",
"POST",
".",
"get",
"(",
"'category_action'",
",",
"False",
")",
"if",
"not",
"requested_action",
":",
"return",
"None",
"# No action supplied. Pass.",
"if",
"reques... | Instructs handler to listen to Django request and handle
CategoryList editor requests (if any).
:return: None on success otherwise and exception from SitecatsException family is raised. | [
"Instructs",
"handler",
"to",
"listen",
"to",
"Django",
"request",
"and",
"handle",
"CategoryList",
"editor",
"requests",
"(",
"if",
"any",
")",
"."
] | 9b45e91fc0dcb63a0011780437fe28145e3ecce9 | https://github.com/idlesign/django-sitecats/blob/9b45e91fc0dcb63a0011780437fe28145e3ecce9/sitecats/toolbox.py#L420-L457 | train | Instructs handler to listen to Django request and handle CategoryList editor requests. |
MacHu-GWU/single_file_module-project | sfm/fingerprint.py | FingerPrint.use | def use(self, algorithm):
"""Change the hash algorithm you gonna use.
"""
try:
self.hash_algo = self._mapper[algorithm.strip().lower()]
except IndexError: # pragma: no cover
template = "'%s' is not supported, try one of %s."
raise ValueError(template ... | python | def use(self, algorithm):
"""Change the hash algorithm you gonna use.
"""
try:
self.hash_algo = self._mapper[algorithm.strip().lower()]
except IndexError: # pragma: no cover
template = "'%s' is not supported, try one of %s."
raise ValueError(template ... | [
"def",
"use",
"(",
"self",
",",
"algorithm",
")",
":",
"try",
":",
"self",
".",
"hash_algo",
"=",
"self",
".",
"_mapper",
"[",
"algorithm",
".",
"strip",
"(",
")",
".",
"lower",
"(",
")",
"]",
"except",
"IndexError",
":",
"# pragma: no cover",
"templat... | Change the hash algorithm you gonna use. | [
"Change",
"the",
"hash",
"algorithm",
"you",
"gonna",
"use",
"."
] | 01f7a6b250853bebfd73de275895bf274325cfc1 | https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/fingerprint.py#L76-L83 | train | Change the hash algorithm you gonna use. |
MacHu-GWU/single_file_module-project | sfm/fingerprint.py | FingerPrint.of_bytes | def of_bytes(self, py_bytes):
"""
Use default hash method to return hash value of bytes.
:type py_bytes: binary_type
:param py_bytes: a binary object
"""
m = self.hash_algo()
m.update(py_bytes)
return self.digest(m) | python | def of_bytes(self, py_bytes):
"""
Use default hash method to return hash value of bytes.
:type py_bytes: binary_type
:param py_bytes: a binary object
"""
m = self.hash_algo()
m.update(py_bytes)
return self.digest(m) | [
"def",
"of_bytes",
"(",
"self",
",",
"py_bytes",
")",
":",
"m",
"=",
"self",
".",
"hash_algo",
"(",
")",
"m",
".",
"update",
"(",
"py_bytes",
")",
"return",
"self",
".",
"digest",
"(",
"m",
")"
] | Use default hash method to return hash value of bytes.
:type py_bytes: binary_type
:param py_bytes: a binary object | [
"Use",
"default",
"hash",
"method",
"to",
"return",
"hash",
"value",
"of",
"bytes",
"."
] | 01f7a6b250853bebfd73de275895bf274325cfc1 | https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/fingerprint.py#L150-L159 | train | Return the hash value of the given bytes. |
MacHu-GWU/single_file_module-project | sfm/fingerprint.py | FingerPrint.of_text | def of_text(self, text, encoding="utf-8"):
"""
Use default hash method to return hash value of a piece of string
default setting use 'utf-8' encoding.
:type text: text_type
:param text: a text object
"""
m = self.hash_algo()
m.update(text.encode(encoding)... | python | def of_text(self, text, encoding="utf-8"):
"""
Use default hash method to return hash value of a piece of string
default setting use 'utf-8' encoding.
:type text: text_type
:param text: a text object
"""
m = self.hash_algo()
m.update(text.encode(encoding)... | [
"def",
"of_text",
"(",
"self",
",",
"text",
",",
"encoding",
"=",
"\"utf-8\"",
")",
":",
"m",
"=",
"self",
".",
"hash_algo",
"(",
")",
"m",
".",
"update",
"(",
"text",
".",
"encode",
"(",
"encoding",
")",
")",
"return",
"self",
".",
"digest",
"(",
... | Use default hash method to return hash value of a piece of string
default setting use 'utf-8' encoding.
:type text: text_type
:param text: a text object | [
"Use",
"default",
"hash",
"method",
"to",
"return",
"hash",
"value",
"of",
"a",
"piece",
"of",
"string",
"default",
"setting",
"use",
"utf",
"-",
"8",
"encoding",
"."
] | 01f7a6b250853bebfd73de275895bf274325cfc1 | https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/fingerprint.py#L161-L171 | train | Return the hash value of a piece of text |
MacHu-GWU/single_file_module-project | sfm/fingerprint.py | FingerPrint.of_pyobj | def of_pyobj(self, pyobj):
"""
Use default hash method to return hash value of a piece of Python
picklable object.
:param pyobj: any python object
"""
m = self.hash_algo()
m.update(pickle.dumps(pyobj, protocol=self.pk_protocol))
return self.digest(m) | python | def of_pyobj(self, pyobj):
"""
Use default hash method to return hash value of a piece of Python
picklable object.
:param pyobj: any python object
"""
m = self.hash_algo()
m.update(pickle.dumps(pyobj, protocol=self.pk_protocol))
return self.digest(m) | [
"def",
"of_pyobj",
"(",
"self",
",",
"pyobj",
")",
":",
"m",
"=",
"self",
".",
"hash_algo",
"(",
")",
"m",
".",
"update",
"(",
"pickle",
".",
"dumps",
"(",
"pyobj",
",",
"protocol",
"=",
"self",
".",
"pk_protocol",
")",
")",
"return",
"self",
".",
... | Use default hash method to return hash value of a piece of Python
picklable object.
:param pyobj: any python object | [
"Use",
"default",
"hash",
"method",
"to",
"return",
"hash",
"value",
"of",
"a",
"piece",
"of",
"Python",
"picklable",
"object",
"."
] | 01f7a6b250853bebfd73de275895bf274325cfc1 | https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/fingerprint.py#L173-L182 | train | Returns the hash value of a piece of Python
picklable object. |
MacHu-GWU/single_file_module-project | sfm/fingerprint.py | FingerPrint.of_file | def of_file(self, abspath, nbytes=0, chunk_size=1024):
"""
Use default hash method to return hash value of a piece of a file
Estimate processing time on:
:type abspath: text_type
:param abspath: the absolute path to the file.
:type nbytes: int
:param nbytes: on... | python | def of_file(self, abspath, nbytes=0, chunk_size=1024):
"""
Use default hash method to return hash value of a piece of a file
Estimate processing time on:
:type abspath: text_type
:param abspath: the absolute path to the file.
:type nbytes: int
:param nbytes: on... | [
"def",
"of_file",
"(",
"self",
",",
"abspath",
",",
"nbytes",
"=",
"0",
",",
"chunk_size",
"=",
"1024",
")",
":",
"if",
"nbytes",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"\"chunk_size cannot smaller than 0\"",
")",
"if",
"chunk_size",
"<",
"1",
":",
"... | Use default hash method to return hash value of a piece of a file
Estimate processing time on:
:type abspath: text_type
:param abspath: the absolute path to the file.
:type nbytes: int
:param nbytes: only has first N bytes of the file. if 0, hash all file.
:type chunk... | [
"Use",
"default",
"hash",
"method",
"to",
"return",
"hash",
"value",
"of",
"a",
"piece",
"of",
"a",
"file"
] | 01f7a6b250853bebfd73de275895bf274325cfc1 | https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/fingerprint.py#L184-L242 | train | Return the hash value of a piece of a file. |
ariebovenberg/snug | tutorial/composed_oop.py | BaseQuery.check_response | def check_response(self, resp):
"""raise a descriptive exception on a "bad request" response"""
if resp.status_code == 400:
raise ApiException(json.loads(resp.content).get('message'))
return resp | python | def check_response(self, resp):
"""raise a descriptive exception on a "bad request" response"""
if resp.status_code == 400:
raise ApiException(json.loads(resp.content).get('message'))
return resp | [
"def",
"check_response",
"(",
"self",
",",
"resp",
")",
":",
"if",
"resp",
".",
"status_code",
"==",
"400",
":",
"raise",
"ApiException",
"(",
"json",
".",
"loads",
"(",
"resp",
".",
"content",
")",
".",
"get",
"(",
"'message'",
")",
")",
"return",
"... | raise a descriptive exception on a "bad request" response | [
"raise",
"a",
"descriptive",
"exception",
"on",
"a",
"bad",
"request",
"response"
] | 4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef | https://github.com/ariebovenberg/snug/blob/4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef/tutorial/composed_oop.py#L36-L40 | train | raise an exception on a bad request response |
vasilcovsky/pytinypng | pytinypng/api.py | shrink | def shrink(image, apikey):
"""To shrink a PNG image, post the data to the API service.
The response is a JSON message.
The initial request must be authorized with HTTP Basic authorization.
@param image: PNG image bytes sequence
@param apikey: TinyPNG API key
@param filename: filename of input f... | python | def shrink(image, apikey):
"""To shrink a PNG image, post the data to the API service.
The response is a JSON message.
The initial request must be authorized with HTTP Basic authorization.
@param image: PNG image bytes sequence
@param apikey: TinyPNG API key
@param filename: filename of input f... | [
"def",
"shrink",
"(",
"image",
",",
"apikey",
")",
":",
"def",
"_handle_response",
"(",
"response",
")",
":",
"body",
"=",
"json",
".",
"loads",
"(",
"response",
".",
"read",
"(",
")",
")",
"if",
"response",
".",
"code",
"==",
"TinyPNGResponse",
".",
... | To shrink a PNG image, post the data to the API service.
The response is a JSON message.
The initial request must be authorized with HTTP Basic authorization.
@param image: PNG image bytes sequence
@param apikey: TinyPNG API key
@param filename: filename of input file | [
"To",
"shrink",
"a",
"PNG",
"image",
"post",
"the",
"data",
"to",
"the",
"API",
"service",
".",
"The",
"response",
"is",
"a",
"JSON",
"message",
".",
"The",
"initial",
"request",
"must",
"be",
"authorized",
"with",
"HTTP",
"Basic",
"authorization",
"."
] | ac633e4aa41122c49a806f411e43a76d8f73058e | https://github.com/vasilcovsky/pytinypng/blob/ac633e4aa41122c49a806f411e43a76d8f73058e/pytinypng/api.py#L10-L41 | train | This function is used to shrink a PNG image to a TinyPNG image file. |
koszullab/metaTOR | metator/metator.py | download_and_install_dependencies | def download_and_install_dependencies():
"""Setup URLS and download dependencies for Python 3.6+
"""
try:
import requests
except ImportError:
raise ValueError("Python 3.6+ is required.")
dependencies = {"hmm_databases": HMM_URL}
if sys.platform.startswith("linux") or "bsd" in ... | python | def download_and_install_dependencies():
"""Setup URLS and download dependencies for Python 3.6+
"""
try:
import requests
except ImportError:
raise ValueError("Python 3.6+ is required.")
dependencies = {"hmm_databases": HMM_URL}
if sys.platform.startswith("linux") or "bsd" in ... | [
"def",
"download_and_install_dependencies",
"(",
")",
":",
"try",
":",
"import",
"requests",
"except",
"ImportError",
":",
"raise",
"ValueError",
"(",
"\"Python 3.6+ is required.\"",
")",
"dependencies",
"=",
"{",
"\"hmm_databases\"",
":",
"HMM_URL",
"}",
"if",
"sys... | Setup URLS and download dependencies for Python 3.6+ | [
"Setup",
"URLS",
"and",
"download",
"dependencies",
"for",
"Python",
"3",
".",
"6",
"+"
] | 0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a | https://github.com/koszullab/metaTOR/blob/0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a/metator/metator.py#L20-L94 | train | Download and install dependencies for Python 3. 6 + |
koszullab/metaTOR | metator/metator.py | main | def main():
"""This module just acts as an entry point to the bulk of the pipeline.
All argument parsing is delegated to metator.sh
"""
metator_args = sys.argv[1:]
entry_point = pkg_resources.resource_filename("metator", "bin/metator.sh")
try:
metator_process = subprocess.Popen((entry_... | python | def main():
"""This module just acts as an entry point to the bulk of the pipeline.
All argument parsing is delegated to metator.sh
"""
metator_args = sys.argv[1:]
entry_point = pkg_resources.resource_filename("metator", "bin/metator.sh")
try:
metator_process = subprocess.Popen((entry_... | [
"def",
"main",
"(",
")",
":",
"metator_args",
"=",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
"entry_point",
"=",
"pkg_resources",
".",
"resource_filename",
"(",
"\"metator\"",
",",
"\"bin/metator.sh\"",
")",
"try",
":",
"metator_process",
"=",
"subprocess",
".... | This module just acts as an entry point to the bulk of the pipeline.
All argument parsing is delegated to metator.sh | [
"This",
"module",
"just",
"acts",
"as",
"an",
"entry",
"point",
"to",
"the",
"bulk",
"of",
"the",
"pipeline",
".",
"All",
"argument",
"parsing",
"is",
"delegated",
"to",
"metator",
".",
"sh"
] | 0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a | https://github.com/koszullab/metaTOR/blob/0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a/metator/metator.py#L97-L111 | train | This module is used to run the bulk of the pipeline. It is intended to be used by the user as a command line interface to the bulk of the pipeline. |
Godley/MuseParse | MuseParse/classes/ObjectHierarchy/ItemClasses/Directions.py | Text.get | def get(self):
"""
method to fetch all contents as a list
:return: list
"""
ret_list = []
if hasattr(self, "font"):
ret_list.append(self.font)
if hasattr(self, "size"):
ret_list.append(self.size)
if hasattr(self, "text"):
... | python | def get(self):
"""
method to fetch all contents as a list
:return: list
"""
ret_list = []
if hasattr(self, "font"):
ret_list.append(self.font)
if hasattr(self, "size"):
ret_list.append(self.size)
if hasattr(self, "text"):
... | [
"def",
"get",
"(",
"self",
")",
":",
"ret_list",
"=",
"[",
"]",
"if",
"hasattr",
"(",
"self",
",",
"\"font\"",
")",
":",
"ret_list",
".",
"append",
"(",
"self",
".",
"font",
")",
"if",
"hasattr",
"(",
"self",
",",
"\"size\"",
")",
":",
"ret_list",
... | method to fetch all contents as a list
:return: list | [
"method",
"to",
"fetch",
"all",
"contents",
"as",
"a",
"list"
] | 23cecafa1fdc0f2d6a87760553572b459f3c9904 | https://github.com/Godley/MuseParse/blob/23cecafa1fdc0f2d6a87760553572b459f3c9904/MuseParse/classes/ObjectHierarchy/ItemClasses/Directions.py#L33-L46 | train | method to fetch all contents as a list |
Godley/MuseParse | MuseParse/classes/ObjectHierarchy/ItemClasses/Directions.py | Text.toLily | def toLily(self):
'''
Method which converts the object instance and its attributes to a string of lilypond code
:return: str of lilypond code
'''
lilystring = ""
if hasattr(self, "size"):
try:
size = float(self.size)
lilystrin... | python | def toLily(self):
'''
Method which converts the object instance and its attributes to a string of lilypond code
:return: str of lilypond code
'''
lilystring = ""
if hasattr(self, "size"):
try:
size = float(self.size)
lilystrin... | [
"def",
"toLily",
"(",
"self",
")",
":",
"lilystring",
"=",
"\"\"",
"if",
"hasattr",
"(",
"self",
",",
"\"size\"",
")",
":",
"try",
":",
"size",
"=",
"float",
"(",
"self",
".",
"size",
")",
"lilystring",
"+=",
"\"\\\\abs-fontsize #\"",
"+",
"str",
"(",
... | Method which converts the object instance and its attributes to a string of lilypond code
:return: str of lilypond code | [
"Method",
"which",
"converts",
"the",
"object",
"instance",
"and",
"its",
"attributes",
"to",
"a",
"string",
"of",
"lilypond",
"code"
] | 23cecafa1fdc0f2d6a87760553572b459f3c9904 | https://github.com/Godley/MuseParse/blob/23cecafa1fdc0f2d6a87760553572b459f3c9904/MuseParse/classes/ObjectHierarchy/ItemClasses/Directions.py#L48-L94 | train | Method which converts the object instance and its attributes to a string of lilypond code. |
MacHu-GWU/single_file_module-project | sfm/rerecipe.py | extract_by_prefix_surfix | def extract_by_prefix_surfix(text,
prefix,
surfix,
minlen=None,
maxlen=None,
include=False):
"""Extract the text in between a prefix and surfix. It use non-greedy match.
... | python | def extract_by_prefix_surfix(text,
prefix,
surfix,
minlen=None,
maxlen=None,
include=False):
"""Extract the text in between a prefix and surfix. It use non-greedy match.
... | [
"def",
"extract_by_prefix_surfix",
"(",
"text",
",",
"prefix",
",",
"surfix",
",",
"minlen",
"=",
"None",
",",
"maxlen",
"=",
"None",
",",
"include",
"=",
"False",
")",
":",
"if",
"minlen",
"is",
"None",
":",
"minlen",
"=",
"0",
"if",
"maxlen",
"is",
... | Extract the text in between a prefix and surfix. It use non-greedy match.
:param text: text body
:type text: str
:param prefix: the prefix
:type prefix: str
:param surfix: the surfix
:type surfix: str
:param minlen: the min matched string length
:type minlen: int
:param maxlen: ... | [
"Extract",
"the",
"text",
"in",
"between",
"a",
"prefix",
"and",
"surfix",
".",
"It",
"use",
"non",
"-",
"greedy",
"match",
"."
] | 01f7a6b250853bebfd73de275895bf274325cfc1 | https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/rerecipe.py#L13-L48 | train | Extract the text in between a prefix and surfix. It use non - greedy match. |
MacHu-GWU/single_file_module-project | sfm/rerecipe.py | extract_number | def extract_number(text):
"""Extract digit character from text.
"""
result = list()
chunk = list()
valid_char = set(".1234567890")
for char in text:
if char in valid_char:
chunk.append(char)
else:
result.append("".join(chunk))
chunk = list()
... | python | def extract_number(text):
"""Extract digit character from text.
"""
result = list()
chunk = list()
valid_char = set(".1234567890")
for char in text:
if char in valid_char:
chunk.append(char)
else:
result.append("".join(chunk))
chunk = list()
... | [
"def",
"extract_number",
"(",
"text",
")",
":",
"result",
"=",
"list",
"(",
")",
"chunk",
"=",
"list",
"(",
")",
"valid_char",
"=",
"set",
"(",
"\".1234567890\"",
")",
"for",
"char",
"in",
"text",
":",
"if",
"char",
"in",
"valid_char",
":",
"chunk",
... | Extract digit character from text. | [
"Extract",
"digit",
"character",
"from",
"text",
"."
] | 01f7a6b250853bebfd73de275895bf274325cfc1 | https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/rerecipe.py#L51-L78 | train | Extract digit character from text.
|
MacHu-GWU/single_file_module-project | sfm/rerecipe.py | extract_email | def extract_email(text):
"""Extract email from text.
"""
result = list()
for tp in re.findall(_regex_extract_email, text.lower()):
for email in tp:
if re.match(_regex_validate_email, email):
result.append(email)
return result | python | def extract_email(text):
"""Extract email from text.
"""
result = list()
for tp in re.findall(_regex_extract_email, text.lower()):
for email in tp:
if re.match(_regex_validate_email, email):
result.append(email)
return result | [
"def",
"extract_email",
"(",
"text",
")",
":",
"result",
"=",
"list",
"(",
")",
"for",
"tp",
"in",
"re",
".",
"findall",
"(",
"_regex_extract_email",
",",
"text",
".",
"lower",
"(",
")",
")",
":",
"for",
"email",
"in",
"tp",
":",
"if",
"re",
".",
... | Extract email from text. | [
"Extract",
"email",
"from",
"text",
"."
] | 01f7a6b250853bebfd73de275895bf274325cfc1 | https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/rerecipe.py#L87-L95 | train | Extract email from text. |
PSPC-SPAC-buyandsell/didauth | didauth/headers.py | HeaderSigner.sign | def sign(self, headers: Mapping, method=None, path=None):
"""
Add Signature Authorization header to case-insensitive header dict.
`headers` is a case-insensitive dict of mutable headers.
`host` is a override for the 'host' header (defaults to value in
headers).
`meth... | python | def sign(self, headers: Mapping, method=None, path=None):
"""
Add Signature Authorization header to case-insensitive header dict.
`headers` is a case-insensitive dict of mutable headers.
`host` is a override for the 'host' header (defaults to value in
headers).
`meth... | [
"def",
"sign",
"(",
"self",
",",
"headers",
":",
"Mapping",
",",
"method",
"=",
"None",
",",
"path",
"=",
"None",
")",
":",
"required_headers",
"=",
"self",
".",
"header_list",
"message",
"=",
"generate_message",
"(",
"required_headers",
",",
"headers",
",... | Add Signature Authorization header to case-insensitive header dict.
`headers` is a case-insensitive dict of mutable headers.
`host` is a override for the 'host' header (defaults to value in
headers).
`method` is the HTTP method (required when using '(request-target)').
`path... | [
"Add",
"Signature",
"Authorization",
"header",
"to",
"case",
"-",
"insensitive",
"header",
"dict",
"."
] | e242fff8eddebf6ed52a65b161a229cdfbf5226e | https://github.com/PSPC-SPAC-buyandsell/didauth/blob/e242fff8eddebf6ed52a65b161a229cdfbf5226e/didauth/headers.py#L60-L77 | train | Add Signature Authorization header to case - insensitive header dict. |
PSPC-SPAC-buyandsell/didauth | didauth/headers.py | HeaderVerifier.verify | async def verify(self, headers: Mapping, method=None, path=None):
"""
Parse Signature Authorization header and verify signature
`headers` is a dict or multidict of headers
`host` is a override for the 'host' header (defaults to value in
headers).
`method` is the HTTP... | python | async def verify(self, headers: Mapping, method=None, path=None):
"""
Parse Signature Authorization header and verify signature
`headers` is a dict or multidict of headers
`host` is a override for the 'host' header (defaults to value in
headers).
`method` is the HTTP... | [
"async",
"def",
"verify",
"(",
"self",
",",
"headers",
":",
"Mapping",
",",
"method",
"=",
"None",
",",
"path",
"=",
"None",
")",
":",
"if",
"not",
"'authorization'",
"in",
"headers",
":",
"return",
"False",
"auth_type",
",",
"auth_params",
"=",
"parse_a... | Parse Signature Authorization header and verify signature
`headers` is a dict or multidict of headers
`host` is a override for the 'host' header (defaults to value in
headers).
`method` is the HTTP method (required when using '(request-target)').
`path` is the HTTP path (req... | [
"Parse",
"Signature",
"Authorization",
"header",
"and",
"verify",
"signature"
] | e242fff8eddebf6ed52a65b161a229cdfbf5226e | https://github.com/PSPC-SPAC-buyandsell/didauth/blob/e242fff8eddebf6ed52a65b161a229cdfbf5226e/didauth/headers.py#L92-L147 | train | Verify the signature of a request. |
TylerTemp/docpie | docpie/pie.py | Docpie.docpie | def docpie(self, argv=None):
"""match the argv for each usages, return dict.
if argv is None, it will use sys.argv instead.
if argv is str, it will call argv.split() first.
this function will check the options in self.extra and handle it first.
Which means it may not try to matc... | python | def docpie(self, argv=None):
"""match the argv for each usages, return dict.
if argv is None, it will use sys.argv instead.
if argv is str, it will call argv.split() first.
this function will check the options in self.extra and handle it first.
Which means it may not try to matc... | [
"def",
"docpie",
"(",
"self",
",",
"argv",
"=",
"None",
")",
":",
"token",
"=",
"self",
".",
"_prepare_token",
"(",
"argv",
")",
"# check first, raise after",
"# so `-hwhatever` can trigger `-h` first",
"self",
".",
"check_flag_and_handler",
"(",
"token",
")",
"if... | match the argv for each usages, return dict.
if argv is None, it will use sys.argv instead.
if argv is str, it will call argv.split() first.
this function will check the options in self.extra and handle it first.
Which means it may not try to match any usages because of the checking. | [
"match",
"the",
"argv",
"for",
"each",
"usages",
"return",
"dict",
"."
] | e658454b81b6c79a020d499f12ad73496392c09a | https://github.com/TylerTemp/docpie/blob/e658454b81b6c79a020d499f12ad73496392c09a/docpie/pie.py#L128-L168 | train | match the argv for each usages return a dict. |
TylerTemp/docpie | docpie/pie.py | Docpie.clone_exception | def clone_exception(error, args):
"""
return a new cloned error
when do:
```
try:
do_sth()
except BaseException as e:
handle(e)
def handle(error):
# do sth with error
raise e # <- won't work!
This can ge... | python | def clone_exception(error, args):
"""
return a new cloned error
when do:
```
try:
do_sth()
except BaseException as e:
handle(e)
def handle(error):
# do sth with error
raise e # <- won't work!
This can ge... | [
"def",
"clone_exception",
"(",
"error",
",",
"args",
")",
":",
"new_error",
"=",
"error",
".",
"__class__",
"(",
"*",
"args",
")",
"new_error",
".",
"__dict__",
"=",
"error",
".",
"__dict__",
"return",
"new_error"
] | return a new cloned error
when do:
```
try:
do_sth()
except BaseException as e:
handle(e)
def handle(error):
# do sth with error
raise e # <- won't work!
This can generate a new cloned error of the same class
P... | [
"return",
"a",
"new",
"cloned",
"error"
] | e658454b81b6c79a020d499f12ad73496392c09a | https://github.com/TylerTemp/docpie/blob/e658454b81b6c79a020d499f12ad73496392c09a/docpie/pie.py#L425-L454 | train | Clone an exception and return a new cloned error. |
TylerTemp/docpie | docpie/pie.py | Docpie.help_handler | def help_handler(docpie, flag):
"""Default help(`--help`, `-h`) handler. print help string and exit.
when help = 'short_brief', flag startswith `--` will print
the full `doc`, `-` for "Usage" section and "Option" section only.
when help = 'short_brief_notice', flag startswith `--` will ... | python | def help_handler(docpie, flag):
"""Default help(`--help`, `-h`) handler. print help string and exit.
when help = 'short_brief', flag startswith `--` will print
the full `doc`, `-` for "Usage" section and "Option" section only.
when help = 'short_brief_notice', flag startswith `--` will ... | [
"def",
"help_handler",
"(",
"docpie",
",",
"flag",
")",
":",
"help_type",
"=",
"docpie",
".",
"help",
"helpstyle",
"=",
"docpie",
".",
"helpstyle",
"if",
"helpstyle",
"==",
"'python'",
":",
"doc",
"=",
"Docpie",
".",
"help_style_python",
"(",
"docpie",
"."... | Default help(`--help`, `-h`) handler. print help string and exit.
when help = 'short_brief', flag startswith `--` will print
the full `doc`, `-` for "Usage" section and "Option" section only.
when help = 'short_brief_notice', flag startswith `--` will print
the full `doc`, `-` for "Usag... | [
"Default",
"help",
"(",
"--",
"help",
"-",
"h",
")",
"handler",
".",
"print",
"help",
"string",
"and",
"exit",
"."
] | e658454b81b6c79a020d499f12ad73496392c09a | https://github.com/TylerTemp/docpie/blob/e658454b81b6c79a020d499f12ad73496392c09a/docpie/pie.py#L457-L502 | train | Default help handler. Prints the help string and exit. |
TylerTemp/docpie | docpie/pie.py | Docpie.to_dict | def to_dict(self): # cls, self):
"""Convert Docpie into a JSONlizable dict.
Use it in this way:
pie = Docpie(__doc__)
json.dumps(pie.convert_2_dict())
Note the `extra` info will be lost if you costomize that,
because a function is not JSONlizable.
You can use `... | python | def to_dict(self): # cls, self):
"""Convert Docpie into a JSONlizable dict.
Use it in this way:
pie = Docpie(__doc__)
json.dumps(pie.convert_2_dict())
Note the `extra` info will be lost if you costomize that,
because a function is not JSONlizable.
You can use `... | [
"def",
"to_dict",
"(",
"self",
")",
":",
"# cls, self):",
"config",
"=",
"{",
"'stdopt'",
":",
"self",
".",
"stdopt",
",",
"'attachopt'",
":",
"self",
".",
"attachopt",
",",
"'attachvalue'",
":",
"self",
".",
"attachvalue",
",",
"'auto2dashes'",
":",
"self... | Convert Docpie into a JSONlizable dict.
Use it in this way:
pie = Docpie(__doc__)
json.dumps(pie.convert_2_dict())
Note the `extra` info will be lost if you costomize that,
because a function is not JSONlizable.
You can use `set_config(extra={...})` to set it back. | [
"Convert",
"Docpie",
"into",
"a",
"JSONlizable",
"dict",
"."
] | e658454b81b6c79a020d499f12ad73496392c09a | https://github.com/TylerTemp/docpie/blob/e658454b81b6c79a020d499f12ad73496392c09a/docpie/pie.py#L547-L597 | train | Convert the Docpie into a JSONlizable dict. |
TylerTemp/docpie | docpie/pie.py | Docpie.from_dict | def from_dict(cls, dic):
"""Convert dict generated by `convert_2_dict` into Docpie instance
You can do this:
pie = Docpie(__doc__)
clone_pie = json.loads(pie.convert_2_docpie(
json.dumps(pie.convert_2_dict())
))
Note if you changed `extra`, it will be lost.
... | python | def from_dict(cls, dic):
"""Convert dict generated by `convert_2_dict` into Docpie instance
You can do this:
pie = Docpie(__doc__)
clone_pie = json.loads(pie.convert_2_docpie(
json.dumps(pie.convert_2_dict())
))
Note if you changed `extra`, it will be lost.
... | [
"def",
"from_dict",
"(",
"cls",
",",
"dic",
")",
":",
"if",
"'__version__'",
"not",
"in",
"dic",
":",
"raise",
"ValueError",
"(",
"'Not support old docpie data'",
")",
"data_version",
"=",
"int",
"(",
"dic",
"[",
"'__version__'",
"]",
".",
"replace",
"(",
... | Convert dict generated by `convert_2_dict` into Docpie instance
You can do this:
pie = Docpie(__doc__)
clone_pie = json.loads(pie.convert_2_docpie(
json.dumps(pie.convert_2_dict())
))
Note if you changed `extra`, it will be lost.
You can use `set_config(extr... | [
"Convert",
"dict",
"generated",
"by",
"convert_2_dict",
"into",
"Docpie",
"instance"
] | e658454b81b6c79a020d499f12ad73496392c09a | https://github.com/TylerTemp/docpie/blob/e658454b81b6c79a020d499f12ad73496392c09a/docpie/pie.py#L602-L651 | train | Convert dict generated by convert_2_dict into Docpie instance |
TylerTemp/docpie | docpie/pie.py | Docpie.set_config | def set_config(self, **config):
"""Shadow all the current config."""
reinit = False
if 'stdopt' in config:
stdopt = config.pop('stdopt')
reinit = (stdopt != self.stdopt)
self.stdopt = stdopt
if 'attachopt' in config:
attachopt = config.pop(... | python | def set_config(self, **config):
"""Shadow all the current config."""
reinit = False
if 'stdopt' in config:
stdopt = config.pop('stdopt')
reinit = (stdopt != self.stdopt)
self.stdopt = stdopt
if 'attachopt' in config:
attachopt = config.pop(... | [
"def",
"set_config",
"(",
"self",
",",
"*",
"*",
"config",
")",
":",
"reinit",
"=",
"False",
"if",
"'stdopt'",
"in",
"config",
":",
"stdopt",
"=",
"config",
".",
"pop",
"(",
"'stdopt'",
")",
"reinit",
"=",
"(",
"stdopt",
"!=",
"self",
".",
"stdopt",
... | Shadow all the current config. | [
"Shadow",
"all",
"the",
"current",
"config",
"."
] | e658454b81b6c79a020d499f12ad73496392c09a | https://github.com/TylerTemp/docpie/blob/e658454b81b6c79a020d499f12ad73496392c09a/docpie/pie.py#L655-L714 | train | Shadow all the current config. |
TylerTemp/docpie | docpie/pie.py | Docpie.find_flag_alias | def find_flag_alias(self, flag):
"""Return alias set of a flag; return None if flag is not defined in
"Options".
"""
for each in self.opt_names:
if flag in each:
result = set(each) # a copy
result.remove(flag)
return result
... | python | def find_flag_alias(self, flag):
"""Return alias set of a flag; return None if flag is not defined in
"Options".
"""
for each in self.opt_names:
if flag in each:
result = set(each) # a copy
result.remove(flag)
return result
... | [
"def",
"find_flag_alias",
"(",
"self",
",",
"flag",
")",
":",
"for",
"each",
"in",
"self",
".",
"opt_names",
":",
"if",
"flag",
"in",
"each",
":",
"result",
"=",
"set",
"(",
"each",
")",
"# a copy",
"result",
".",
"remove",
"(",
"flag",
")",
"return"... | Return alias set of a flag; return None if flag is not defined in
"Options". | [
"Return",
"alias",
"set",
"of",
"a",
"flag",
";",
"return",
"None",
"if",
"flag",
"is",
"not",
"defined",
"in",
"Options",
"."
] | e658454b81b6c79a020d499f12ad73496392c09a | https://github.com/TylerTemp/docpie/blob/e658454b81b6c79a020d499f12ad73496392c09a/docpie/pie.py#L749-L758 | train | Return alias set of a flag ; return None if flag is not defined in the options. |
TylerTemp/docpie | docpie/pie.py | Docpie.set_auto_handler | def set_auto_handler(self, flag, handler):
"""Set pre-auto-handler for a flag.
the handler must accept two argument: first the `pie` which
referent to the current `Docpie` instance, second, the `flag`
which is the flag found in `argv`.
Different from `extra` argument, this will... | python | def set_auto_handler(self, flag, handler):
"""Set pre-auto-handler for a flag.
the handler must accept two argument: first the `pie` which
referent to the current `Docpie` instance, second, the `flag`
which is the flag found in `argv`.
Different from `extra` argument, this will... | [
"def",
"set_auto_handler",
"(",
"self",
",",
"flag",
",",
"handler",
")",
":",
"assert",
"flag",
".",
"startswith",
"(",
"'-'",
")",
"and",
"flag",
"not",
"in",
"(",
"'-'",
",",
"'--'",
")",
"alias",
"=",
"self",
".",
"find_flag_alias",
"(",
"flag",
... | Set pre-auto-handler for a flag.
the handler must accept two argument: first the `pie` which
referent to the current `Docpie` instance, second, the `flag`
which is the flag found in `argv`.
Different from `extra` argument, this will set the alias
option you defined in `Option` ... | [
"Set",
"pre",
"-",
"auto",
"-",
"handler",
"for",
"a",
"flag",
"."
] | e658454b81b6c79a020d499f12ad73496392c09a | https://github.com/TylerTemp/docpie/blob/e658454b81b6c79a020d499f12ad73496392c09a/docpie/pie.py#L760-L775 | train | Set the handler for a flag. |
TylerTemp/docpie | docpie/pie.py | Docpie.preview | def preview(self, stream=sys.stdout):
"""A quick preview of docpie. Print all the parsed object"""
write = stream.write
write(('[Quick preview of Docpie %s]' % self._version).center(80, '='))
write('\n')
write(' sections '.center(80, '-'))
write('\n')
write(se... | python | def preview(self, stream=sys.stdout):
"""A quick preview of docpie. Print all the parsed object"""
write = stream.write
write(('[Quick preview of Docpie %s]' % self._version).center(80, '='))
write('\n')
write(' sections '.center(80, '-'))
write('\n')
write(se... | [
"def",
"preview",
"(",
"self",
",",
"stream",
"=",
"sys",
".",
"stdout",
")",
":",
"write",
"=",
"stream",
".",
"write",
"write",
"(",
"(",
"'[Quick preview of Docpie %s]'",
"%",
"self",
".",
"_version",
")",
".",
"center",
"(",
"80",
",",
"'='",
")",
... | A quick preview of docpie. Print all the parsed object | [
"A",
"quick",
"preview",
"of",
"docpie",
".",
"Print",
"all",
"the",
"parsed",
"object"
] | e658454b81b6c79a020d499f12ad73496392c09a | https://github.com/TylerTemp/docpie/blob/e658454b81b6c79a020d499f12ad73496392c09a/docpie/pie.py#L777-L837 | train | A quick preview of docpie. Print all the parsed object. |
nugget/python-anthemav | anthemav/protocol.py | AVR.refresh_core | def refresh_core(self):
"""Query device for all attributes that exist regardless of power state.
This will force a refresh for all device queries that are valid to
request at any time. It's the only safe suite of queries that we can
make if we do not know the current state (on or off+s... | python | def refresh_core(self):
"""Query device for all attributes that exist regardless of power state.
This will force a refresh for all device queries that are valid to
request at any time. It's the only safe suite of queries that we can
make if we do not know the current state (on or off+s... | [
"def",
"refresh_core",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"'Sending out mass query for all attributes'",
")",
"for",
"key",
"in",
"ATTR_CORE",
":",
"self",
".",
"query",
"(",
"key",
")"
] | Query device for all attributes that exist regardless of power state.
This will force a refresh for all device queries that are valid to
request at any time. It's the only safe suite of queries that we can
make if we do not know the current state (on or off+standby).
This does not ret... | [
"Query",
"device",
"for",
"all",
"attributes",
"that",
"exist",
"regardless",
"of",
"power",
"state",
"."
] | c3cee38f2d452c1ab1335d9885e0769ec24d5f90 | https://github.com/nugget/python-anthemav/blob/c3cee38f2d452c1ab1335d9885e0769ec24d5f90/anthemav/protocol.py#L109-L120 | train | Query all attributes that exist regardless of power state. |
nugget/python-anthemav | anthemav/protocol.py | AVR.poweron_refresh | def poweron_refresh(self):
"""Keep requesting all attributes until it works.
Immediately after a power on event (POW1) the AVR is inconsistent with
which attributes can be successfully queried. When we detect that
power has just been turned on, we loop every second making a bulk
... | python | def poweron_refresh(self):
"""Keep requesting all attributes until it works.
Immediately after a power on event (POW1) the AVR is inconsistent with
which attributes can be successfully queried. When we detect that
power has just been turned on, we loop every second making a bulk
... | [
"def",
"poweron_refresh",
"(",
"self",
")",
":",
"if",
"self",
".",
"_poweron_refresh_successful",
":",
"return",
"else",
":",
"self",
".",
"refresh_all",
"(",
")",
"self",
".",
"_loop",
".",
"call_later",
"(",
"2",
",",
"self",
".",
"poweron_refresh",
")"... | Keep requesting all attributes until it works.
Immediately after a power on event (POW1) the AVR is inconsistent with
which attributes can be successfully queried. When we detect that
power has just been turned on, we loop every second making a bulk
query for every known attribute. Th... | [
"Keep",
"requesting",
"all",
"attributes",
"until",
"it",
"works",
"."
] | c3cee38f2d452c1ab1335d9885e0769ec24d5f90 | https://github.com/nugget/python-anthemav/blob/c3cee38f2d452c1ab1335d9885e0769ec24d5f90/anthemav/protocol.py#L122-L136 | train | Keep requesting all attributes until power on event is detected. |
nugget/python-anthemav | anthemav/protocol.py | AVR.refresh_all | def refresh_all(self):
"""Query device for all attributes that are known.
This will force a refresh for all device queries that the module is
aware of. In theory, this will completely populate the internal state
table for all attributes.
This does not return any data, it just ... | python | def refresh_all(self):
"""Query device for all attributes that are known.
This will force a refresh for all device queries that the module is
aware of. In theory, this will completely populate the internal state
table for all attributes.
This does not return any data, it just ... | [
"def",
"refresh_all",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"'refresh_all'",
")",
"for",
"key",
"in",
"LOOKUP",
":",
"self",
".",
"query",
"(",
"key",
")"
] | Query device for all attributes that are known.
This will force a refresh for all device queries that the module is
aware of. In theory, this will completely populate the internal state
table for all attributes.
This does not return any data, it just issues the queries. | [
"Query",
"device",
"for",
"all",
"attributes",
"that",
"are",
"known",
"."
] | c3cee38f2d452c1ab1335d9885e0769ec24d5f90 | https://github.com/nugget/python-anthemav/blob/c3cee38f2d452c1ab1335d9885e0769ec24d5f90/anthemav/protocol.py#L139-L150 | train | Query all known attributes and refresh the internal state table for all known attributes. |
nugget/python-anthemav | anthemav/protocol.py | AVR.connection_made | def connection_made(self, transport):
"""Called when asyncio.Protocol establishes the network connection."""
self.log.info('Connection established to AVR')
self.transport = transport
#self.transport.set_write_buffer_limits(0)
limit_low, limit_high = self.transport.get_write_buff... | python | def connection_made(self, transport):
"""Called when asyncio.Protocol establishes the network connection."""
self.log.info('Connection established to AVR')
self.transport = transport
#self.transport.set_write_buffer_limits(0)
limit_low, limit_high = self.transport.get_write_buff... | [
"def",
"connection_made",
"(",
"self",
",",
"transport",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"'Connection established to AVR'",
")",
"self",
".",
"transport",
"=",
"transport",
"#self.transport.set_write_buffer_limits(0)",
"limit_low",
",",
"limit_high",
... | Called when asyncio.Protocol establishes the network connection. | [
"Called",
"when",
"asyncio",
".",
"Protocol",
"establishes",
"the",
"network",
"connection",
"."
] | c3cee38f2d452c1ab1335d9885e0769ec24d5f90 | https://github.com/nugget/python-anthemav/blob/c3cee38f2d452c1ab1335d9885e0769ec24d5f90/anthemav/protocol.py#L157-L167 | train | Called when asyncio. Protocol establishes the network connection. |
nugget/python-anthemav | anthemav/protocol.py | AVR.data_received | def data_received(self, data):
"""Called when asyncio.Protocol detects received data from network."""
self.buffer += data.decode()
self.log.debug('Received %d bytes from AVR: %s', len(self.buffer), self.buffer)
self._assemble_buffer() | python | def data_received(self, data):
"""Called when asyncio.Protocol detects received data from network."""
self.buffer += data.decode()
self.log.debug('Received %d bytes from AVR: %s', len(self.buffer), self.buffer)
self._assemble_buffer() | [
"def",
"data_received",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"buffer",
"+=",
"data",
".",
"decode",
"(",
")",
"self",
".",
"log",
".",
"debug",
"(",
"'Received %d bytes from AVR: %s'",
",",
"len",
"(",
"self",
".",
"buffer",
")",
",",
"self... | Called when asyncio.Protocol detects received data from network. | [
"Called",
"when",
"asyncio",
".",
"Protocol",
"detects",
"received",
"data",
"from",
"network",
"."
] | c3cee38f2d452c1ab1335d9885e0769ec24d5f90 | https://github.com/nugget/python-anthemav/blob/c3cee38f2d452c1ab1335d9885e0769ec24d5f90/anthemav/protocol.py#L169-L173 | train | Called when asyncio. Protocol detects received data from network. |
nugget/python-anthemav | anthemav/protocol.py | AVR.connection_lost | def connection_lost(self, exc):
"""Called when asyncio.Protocol loses the network connection."""
if exc is None:
self.log.warning('eof from receiver?')
else:
self.log.warning('Lost connection to receiver: %s', exc)
self.transport = None
if self._connecti... | python | def connection_lost(self, exc):
"""Called when asyncio.Protocol loses the network connection."""
if exc is None:
self.log.warning('eof from receiver?')
else:
self.log.warning('Lost connection to receiver: %s', exc)
self.transport = None
if self._connecti... | [
"def",
"connection_lost",
"(",
"self",
",",
"exc",
")",
":",
"if",
"exc",
"is",
"None",
":",
"self",
".",
"log",
".",
"warning",
"(",
"'eof from receiver?'",
")",
"else",
":",
"self",
".",
"log",
".",
"warning",
"(",
"'Lost connection to receiver: %s'",
",... | Called when asyncio.Protocol loses the network connection. | [
"Called",
"when",
"asyncio",
".",
"Protocol",
"loses",
"the",
"network",
"connection",
"."
] | c3cee38f2d452c1ab1335d9885e0769ec24d5f90 | https://github.com/nugget/python-anthemav/blob/c3cee38f2d452c1ab1335d9885e0769ec24d5f90/anthemav/protocol.py#L175-L185 | train | Called when asyncio. Protocol loses the network connection. |
nugget/python-anthemav | anthemav/protocol.py | AVR._assemble_buffer | def _assemble_buffer(self):
"""Split up received data from device into individual commands.
Data sent by the device is a sequence of datagrams separated by
semicolons. It's common to receive a burst of them all in one
submission when there's a lot of device activity. This function
... | python | def _assemble_buffer(self):
"""Split up received data from device into individual commands.
Data sent by the device is a sequence of datagrams separated by
semicolons. It's common to receive a burst of them all in one
submission when there's a lot of device activity. This function
... | [
"def",
"_assemble_buffer",
"(",
"self",
")",
":",
"self",
".",
"transport",
".",
"pause_reading",
"(",
")",
"for",
"message",
"in",
"self",
".",
"buffer",
".",
"split",
"(",
"';'",
")",
":",
"if",
"message",
"!=",
"''",
":",
"self",
".",
"log",
".",
... | Split up received data from device into individual commands.
Data sent by the device is a sequence of datagrams separated by
semicolons. It's common to receive a burst of them all in one
submission when there's a lot of device activity. This function
disassembles the chain of datagram... | [
"Split",
"up",
"received",
"data",
"from",
"device",
"into",
"individual",
"commands",
"."
] | c3cee38f2d452c1ab1335d9885e0769ec24d5f90 | https://github.com/nugget/python-anthemav/blob/c3cee38f2d452c1ab1335d9885e0769ec24d5f90/anthemav/protocol.py#L187-L206 | train | Assemble the buffer into individual commands. |
nugget/python-anthemav | anthemav/protocol.py | AVR._populate_inputs | def _populate_inputs(self, total):
"""Request the names for all active, configured inputs on the device.
Once we learn how many inputs are configured, this function is called
which will ask for the name of each active input.
"""
total = total + 1
for input_number in rang... | python | def _populate_inputs(self, total):
"""Request the names for all active, configured inputs on the device.
Once we learn how many inputs are configured, this function is called
which will ask for the name of each active input.
"""
total = total + 1
for input_number in rang... | [
"def",
"_populate_inputs",
"(",
"self",
",",
"total",
")",
":",
"total",
"=",
"total",
"+",
"1",
"for",
"input_number",
"in",
"range",
"(",
"1",
",",
"total",
")",
":",
"self",
".",
"query",
"(",
"'ISN'",
"+",
"str",
"(",
"input_number",
")",
".",
... | Request the names for all active, configured inputs on the device.
Once we learn how many inputs are configured, this function is called
which will ask for the name of each active input. | [
"Request",
"the",
"names",
"for",
"all",
"active",
"configured",
"inputs",
"on",
"the",
"device",
"."
] | c3cee38f2d452c1ab1335d9885e0769ec24d5f90 | https://github.com/nugget/python-anthemav/blob/c3cee38f2d452c1ab1335d9885e0769ec24d5f90/anthemav/protocol.py#L208-L216 | train | Populate the names for all active configured inputs on the device. |
nugget/python-anthemav | anthemav/protocol.py | AVR._parse_message | def _parse_message(self, data):
"""Interpret each message datagram from device and do the needful.
This function receives datagrams from _assemble_buffer and inerprets
what they mean. It's responsible for maintaining the internal state
table for each device attribute and also for firin... | python | def _parse_message(self, data):
"""Interpret each message datagram from device and do the needful.
This function receives datagrams from _assemble_buffer and inerprets
what they mean. It's responsible for maintaining the internal state
table for each device attribute and also for firin... | [
"def",
"_parse_message",
"(",
"self",
",",
"data",
")",
":",
"recognized",
"=",
"False",
"newdata",
"=",
"False",
"if",
"data",
".",
"startswith",
"(",
"'!I'",
")",
":",
"self",
".",
"log",
".",
"warning",
"(",
"'Invalid command: %s'",
",",
"data",
"[",
... | Interpret each message datagram from device and do the needful.
This function receives datagrams from _assemble_buffer and inerprets
what they mean. It's responsible for maintaining the internal state
table for each device attribute and also for firing the update_callback
function (if ... | [
"Interpret",
"each",
"message",
"datagram",
"from",
"device",
"and",
"do",
"the",
"needful",
"."
] | c3cee38f2d452c1ab1335d9885e0769ec24d5f90 | https://github.com/nugget/python-anthemav/blob/c3cee38f2d452c1ab1335d9885e0769ec24d5f90/anthemav/protocol.py#L218-L309 | train | Interpret each message datagram from the device and do the needful. |
nugget/python-anthemav | anthemav/protocol.py | AVR.formatted_command | def formatted_command(self, command):
"""Issue a raw, formatted command to the device.
This function is invoked by both query and command and is the point
where we actually send bytes out over the network. This function does
the wrapping and formatting required by the Anthem API so tha... | python | def formatted_command(self, command):
"""Issue a raw, formatted command to the device.
This function is invoked by both query and command and is the point
where we actually send bytes out over the network. This function does
the wrapping and formatting required by the Anthem API so tha... | [
"def",
"formatted_command",
"(",
"self",
",",
"command",
")",
":",
"command",
"=",
"command",
"command",
"=",
"command",
".",
"encode",
"(",
")",
"self",
".",
"log",
".",
"debug",
"(",
"'> %s'",
",",
"command",
")",
"try",
":",
"self",
".",
"transport"... | Issue a raw, formatted command to the device.
This function is invoked by both query and command and is the point
where we actually send bytes out over the network. This function does
the wrapping and formatting required by the Anthem API so that the
higher-level function can just oper... | [
"Issue",
"a",
"raw",
"formatted",
"command",
"to",
"the",
"device",
"."
] | c3cee38f2d452c1ab1335d9885e0769ec24d5f90 | https://github.com/nugget/python-anthemav/blob/c3cee38f2d452c1ab1335d9885e0769ec24d5f90/anthemav/protocol.py#L354-L378 | train | Issue a raw formatted command to the device. |
nugget/python-anthemav | anthemav/protocol.py | AVR.dump_rawdata | def dump_rawdata(self):
"""Return contents of transport object for debugging forensics."""
if hasattr(self, 'transport'):
attrs = vars(self.transport)
return ', '.join("%s: %s" % item for item in attrs.items()) | python | def dump_rawdata(self):
"""Return contents of transport object for debugging forensics."""
if hasattr(self, 'transport'):
attrs = vars(self.transport)
return ', '.join("%s: %s" % item for item in attrs.items()) | [
"def",
"dump_rawdata",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'transport'",
")",
":",
"attrs",
"=",
"vars",
"(",
"self",
".",
"transport",
")",
"return",
"', '",
".",
"join",
"(",
"\"%s: %s\"",
"%",
"item",
"for",
"item",
"in",
"a... | Return contents of transport object for debugging forensics. | [
"Return",
"contents",
"of",
"transport",
"object",
"for",
"debugging",
"forensics",
"."
] | c3cee38f2d452c1ab1335d9885e0769ec24d5f90 | https://github.com/nugget/python-anthemav/blob/c3cee38f2d452c1ab1335d9885e0769ec24d5f90/anthemav/protocol.py#L852-L856 | train | Return contents of the transport object for debugging forensics. |
kentik/kentikapi-py | kentikapi/v5/tagging.py | Batch.add_upsert | def add_upsert(self, value, criteria):
"""Add a tag or populator to the batch by value and criteria"""
value = value.strip()
v = value.lower()
self.lower_val_to_val[v] = value
criteria_array = self.upserts.get(v)
if criteria_array is None:
criteria_array = []... | python | def add_upsert(self, value, criteria):
"""Add a tag or populator to the batch by value and criteria"""
value = value.strip()
v = value.lower()
self.lower_val_to_val[v] = value
criteria_array = self.upserts.get(v)
if criteria_array is None:
criteria_array = []... | [
"def",
"add_upsert",
"(",
"self",
",",
"value",
",",
"criteria",
")",
":",
"value",
"=",
"value",
".",
"strip",
"(",
")",
"v",
"=",
"value",
".",
"lower",
"(",
")",
"self",
".",
"lower_val_to_val",
"[",
"v",
"]",
"=",
"value",
"criteria_array",
"=",
... | Add a tag or populator to the batch by value and criteria | [
"Add",
"a",
"tag",
"or",
"populator",
"to",
"the",
"batch",
"by",
"value",
"and",
"criteria"
] | aa94c0b7eaf88409818b97967d7293e309e11bab | https://github.com/kentik/kentikapi-py/blob/aa94c0b7eaf88409818b97967d7293e309e11bab/kentikapi/v5/tagging.py#L25-L38 | train | Add a tag or populator to the batch by value and criteria |
kentik/kentikapi-py | kentikapi/v5/tagging.py | Batch.add_delete | def add_delete(self, value):
"""Delete a tag or populator by value - these are processed before upserts"""
value = value.strip()
v = value.lower()
self.lower_val_to_val[v] = value
if len(v) == 0:
raise ValueError("Invalid value for delete. Value is empty.")
... | python | def add_delete(self, value):
"""Delete a tag or populator by value - these are processed before upserts"""
value = value.strip()
v = value.lower()
self.lower_val_to_val[v] = value
if len(v) == 0:
raise ValueError("Invalid value for delete. Value is empty.")
... | [
"def",
"add_delete",
"(",
"self",
",",
"value",
")",
":",
"value",
"=",
"value",
".",
"strip",
"(",
")",
"v",
"=",
"value",
".",
"lower",
"(",
")",
"self",
".",
"lower_val_to_val",
"[",
"v",
"]",
"=",
"value",
"if",
"len",
"(",
"v",
")",
"==",
... | Delete a tag or populator by value - these are processed before upserts | [
"Delete",
"a",
"tag",
"or",
"populator",
"by",
"value",
"-",
"these",
"are",
"processed",
"before",
"upserts"
] | aa94c0b7eaf88409818b97967d7293e309e11bab | https://github.com/kentik/kentikapi-py/blob/aa94c0b7eaf88409818b97967d7293e309e11bab/kentikapi/v5/tagging.py#L40-L49 | train | Add a delete tag or populator by value - these are processed before upserts |
kentik/kentikapi-py | kentikapi/v5/tagging.py | Batch.parts | def parts(self):
"""Return an array of batch parts to submit"""
parts = []
upserts = dict()
deletes = []
# we keep track of the batch size as we go (pretty close approximation!) so we can chunk it small enough
# to limit the HTTP posts to under 700KB - server limits to... | python | def parts(self):
"""Return an array of batch parts to submit"""
parts = []
upserts = dict()
deletes = []
# we keep track of the batch size as we go (pretty close approximation!) so we can chunk it small enough
# to limit the HTTP posts to under 700KB - server limits to... | [
"def",
"parts",
"(",
"self",
")",
":",
"parts",
"=",
"[",
"]",
"upserts",
"=",
"dict",
"(",
")",
"deletes",
"=",
"[",
"]",
"# we keep track of the batch size as we go (pretty close approximation!) so we can chunk it small enough",
"# to limit the HTTP posts to under 700KB - s... | Return an array of batch parts to submit | [
"Return",
"an",
"array",
"of",
"batch",
"parts",
"to",
"submit"
] | aa94c0b7eaf88409818b97967d7293e309e11bab | https://github.com/kentik/kentikapi-py/blob/aa94c0b7eaf88409818b97967d7293e309e11bab/kentikapi/v5/tagging.py#L51-L105 | train | Return an array of batch parts to submit |
kentik/kentikapi-py | kentikapi/v5/tagging.py | BatchPart.build_json | def build_json(self, guid):
"""Build JSON with the input guid"""
upserts = []
for value in self.upserts:
upserts.append({"value": value, "criteria": self.upserts[value]})
return json.dumps({'replace_all': self.replace_all, 'guid': guid,
'complete': ... | python | def build_json(self, guid):
"""Build JSON with the input guid"""
upserts = []
for value in self.upserts:
upserts.append({"value": value, "criteria": self.upserts[value]})
return json.dumps({'replace_all': self.replace_all, 'guid': guid,
'complete': ... | [
"def",
"build_json",
"(",
"self",
",",
"guid",
")",
":",
"upserts",
"=",
"[",
"]",
"for",
"value",
"in",
"self",
".",
"upserts",
":",
"upserts",
".",
"append",
"(",
"{",
"\"value\"",
":",
"value",
",",
"\"criteria\"",
":",
"self",
".",
"upserts",
"["... | Build JSON with the input guid | [
"Build",
"JSON",
"with",
"the",
"input",
"guid"
] | aa94c0b7eaf88409818b97967d7293e309e11bab | https://github.com/kentik/kentikapi-py/blob/aa94c0b7eaf88409818b97967d7293e309e11bab/kentikapi/v5/tagging.py#L124-L130 | train | Build the JSON with the input guid |
kentik/kentikapi-py | kentikapi/v5/tagging.py | Criteria._ensure_field | def _ensure_field(self, key):
"""Ensure a non-array field"""
if self._has_field:
self._size += 2 # comma, space
self._has_field = True
self._size += len(key) + 4 | python | def _ensure_field(self, key):
"""Ensure a non-array field"""
if self._has_field:
self._size += 2 # comma, space
self._has_field = True
self._size += len(key) + 4 | [
"def",
"_ensure_field",
"(",
"self",
",",
"key",
")",
":",
"if",
"self",
".",
"_has_field",
":",
"self",
".",
"_size",
"+=",
"2",
"# comma, space",
"self",
".",
"_has_field",
"=",
"True",
"self",
".",
"_size",
"+=",
"len",
"(",
"key",
")",
"+",
"4"
] | Ensure a non-array field | [
"Ensure",
"a",
"non",
"-",
"array",
"field"
] | aa94c0b7eaf88409818b97967d7293e309e11bab | https://github.com/kentik/kentikapi-py/blob/aa94c0b7eaf88409818b97967d7293e309e11bab/kentikapi/v5/tagging.py#L156-L162 | train | Ensure a non - array field |
kentik/kentikapi-py | kentikapi/v5/tagging.py | Criteria._ensure_array | def _ensure_array(self, key, value):
"""Ensure an array field"""
if key not in self._json_dict:
self._json_dict[key] = []
self._size += 2 # brackets
self._ensure_field(key)
if len(self._json_dict[key]) > 0:
# this array already has an... | python | def _ensure_array(self, key, value):
"""Ensure an array field"""
if key not in self._json_dict:
self._json_dict[key] = []
self._size += 2 # brackets
self._ensure_field(key)
if len(self._json_dict[key]) > 0:
# this array already has an... | [
"def",
"_ensure_array",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"if",
"key",
"not",
"in",
"self",
".",
"_json_dict",
":",
"self",
".",
"_json_dict",
"[",
"key",
"]",
"=",
"[",
"]",
"self",
".",
"_size",
"+=",
"2",
"# brackets",
"self",
"."... | Ensure an array field | [
"Ensure",
"an",
"array",
"field"
] | aa94c0b7eaf88409818b97967d7293e309e11bab | https://github.com/kentik/kentikapi-py/blob/aa94c0b7eaf88409818b97967d7293e309e11bab/kentikapi/v5/tagging.py#L164-L180 | train | Ensure a field is an array |
kentik/kentikapi-py | kentikapi/v5/tagging.py | Criteria.add_tcp_flag | def add_tcp_flag(self, tcp_flag):
"""Add a single TCP flag - will be OR'd into the existing bitmask"""
if tcp_flag not in [1, 2, 4, 8, 16, 32, 64, 128]:
raise ValueError("Invalid TCP flag. Valid: [1, 2, 4, 8, 16,32, 64, 128]")
prev_size = 0
if self._json_dict.get('tcp_flag... | python | def add_tcp_flag(self, tcp_flag):
"""Add a single TCP flag - will be OR'd into the existing bitmask"""
if tcp_flag not in [1, 2, 4, 8, 16, 32, 64, 128]:
raise ValueError("Invalid TCP flag. Valid: [1, 2, 4, 8, 16,32, 64, 128]")
prev_size = 0
if self._json_dict.get('tcp_flag... | [
"def",
"add_tcp_flag",
"(",
"self",
",",
"tcp_flag",
")",
":",
"if",
"tcp_flag",
"not",
"in",
"[",
"1",
",",
"2",
",",
"4",
",",
"8",
",",
"16",
",",
"32",
",",
"64",
",",
"128",
"]",
":",
"raise",
"ValueError",
"(",
"\"Invalid TCP flag. Valid: [1, 2... | Add a single TCP flag - will be OR'd into the existing bitmask | [
"Add",
"a",
"single",
"TCP",
"flag",
"-",
"will",
"be",
"OR",
"d",
"into",
"the",
"existing",
"bitmask"
] | aa94c0b7eaf88409818b97967d7293e309e11bab | https://github.com/kentik/kentikapi-py/blob/aa94c0b7eaf88409818b97967d7293e309e11bab/kentikapi/v5/tagging.py#L283-L304 | train | Add a single TCP flag to the bitmask |
kentik/kentikapi-py | kentikapi/v5/tagging.py | Criteria.set_tcp_flags | def set_tcp_flags(self, tcp_flags):
"""Set the complete tcp flag bitmask"""
if tcp_flags < 0 or tcp_flags > 255:
raise ValueError("Invalid tcp_flags. Valid: 0-255.")
prev_size = 0
if self._json_dict.get('tcp_flags') is not None:
prev_size = len(str(self._json_di... | python | def set_tcp_flags(self, tcp_flags):
"""Set the complete tcp flag bitmask"""
if tcp_flags < 0 or tcp_flags > 255:
raise ValueError("Invalid tcp_flags. Valid: 0-255.")
prev_size = 0
if self._json_dict.get('tcp_flags') is not None:
prev_size = len(str(self._json_di... | [
"def",
"set_tcp_flags",
"(",
"self",
",",
"tcp_flags",
")",
":",
"if",
"tcp_flags",
"<",
"0",
"or",
"tcp_flags",
">",
"255",
":",
"raise",
"ValueError",
"(",
"\"Invalid tcp_flags. Valid: 0-255.\"",
")",
"prev_size",
"=",
"0",
"if",
"self",
".",
"_json_dict",
... | Set the complete tcp flag bitmask | [
"Set",
"the",
"complete",
"tcp",
"flag",
"bitmask"
] | aa94c0b7eaf88409818b97967d7293e309e11bab | https://github.com/kentik/kentikapi-py/blob/aa94c0b7eaf88409818b97967d7293e309e11bab/kentikapi/v5/tagging.py#L306-L325 | train | Set the complete tcp flag bitmask |
kentik/kentikapi-py | kentikapi/v5/tagging.py | Client._submit_batch | def _submit_batch(self, url, batch):
"""Submit the batch, returning the JSON->dict from the last HTTP response"""
# TODO: validate column_name
batch_parts = batch.parts()
guid = ""
headers = {
'User-Agent': 'kentik-python-api/0.1',
'Content-Type': 'applic... | python | def _submit_batch(self, url, batch):
"""Submit the batch, returning the JSON->dict from the last HTTP response"""
# TODO: validate column_name
batch_parts = batch.parts()
guid = ""
headers = {
'User-Agent': 'kentik-python-api/0.1',
'Content-Type': 'applic... | [
"def",
"_submit_batch",
"(",
"self",
",",
"url",
",",
"batch",
")",
":",
"# TODO: validate column_name",
"batch_parts",
"=",
"batch",
".",
"parts",
"(",
")",
"guid",
"=",
"\"\"",
"headers",
"=",
"{",
"'User-Agent'",
":",
"'kentik-python-api/0.1'",
",",
"'Conte... | Submit the batch, returning the JSON->dict from the last HTTP response | [
"Submit",
"the",
"batch",
"returning",
"the",
"JSON",
"-",
">",
"dict",
"from",
"the",
"last",
"HTTP",
"response"
] | aa94c0b7eaf88409818b97967d7293e309e11bab | https://github.com/kentik/kentikapi-py/blob/aa94c0b7eaf88409818b97967d7293e309e11bab/kentikapi/v5/tagging.py#L400-L429 | train | Submit the batch and return the JSON - > dict from the last HTTP response |
kentik/kentikapi-py | kentikapi/v5/tagging.py | Client.submit_populator_batch | def submit_populator_batch(self, column_name, batch):
"""Submit a populator batch
Submit a populator batch as a series of HTTP requests in small chunks,
returning the batch GUID, or raising exception on error."""
if not set(column_name).issubset(_allowedCustomDimensionChars):
... | python | def submit_populator_batch(self, column_name, batch):
"""Submit a populator batch
Submit a populator batch as a series of HTTP requests in small chunks,
returning the batch GUID, or raising exception on error."""
if not set(column_name).issubset(_allowedCustomDimensionChars):
... | [
"def",
"submit_populator_batch",
"(",
"self",
",",
"column_name",
",",
"batch",
")",
":",
"if",
"not",
"set",
"(",
"column_name",
")",
".",
"issubset",
"(",
"_allowedCustomDimensionChars",
")",
":",
"raise",
"ValueError",
"(",
"'Invalid custom dimension name \"%s\":... | Submit a populator batch
Submit a populator batch as a series of HTTP requests in small chunks,
returning the batch GUID, or raising exception on error. | [
"Submit",
"a",
"populator",
"batch"
] | aa94c0b7eaf88409818b97967d7293e309e11bab | https://github.com/kentik/kentikapi-py/blob/aa94c0b7eaf88409818b97967d7293e309e11bab/kentikapi/v5/tagging.py#L431-L446 | train | Submit a batch of populators for a given column. |
kentik/kentikapi-py | kentikapi/v5/tagging.py | Client.submit_tag_batch | def submit_tag_batch(self, batch):
"""Submit a tag batch"""
url = '%s/api/v5/batch/tags' % self.base_url
self._submit_batch(url, batch) | python | def submit_tag_batch(self, batch):
"""Submit a tag batch"""
url = '%s/api/v5/batch/tags' % self.base_url
self._submit_batch(url, batch) | [
"def",
"submit_tag_batch",
"(",
"self",
",",
"batch",
")",
":",
"url",
"=",
"'%s/api/v5/batch/tags'",
"%",
"self",
".",
"base_url",
"self",
".",
"_submit_batch",
"(",
"url",
",",
"batch",
")"
] | Submit a tag batch | [
"Submit",
"a",
"tag",
"batch"
] | aa94c0b7eaf88409818b97967d7293e309e11bab | https://github.com/kentik/kentikapi-py/blob/aa94c0b7eaf88409818b97967d7293e309e11bab/kentikapi/v5/tagging.py#L448-L451 | train | Submit a tag batch |
kentik/kentikapi-py | kentikapi/v5/tagging.py | Client.fetch_batch_status | def fetch_batch_status(self, guid):
"""Fetch the status of a batch, given the guid"""
url = '%s/api/v5/batch/%s/status' % (self.base_url, guid)
headers = {
'User-Agent': 'kentik-python-api/0.1',
'Content-Type': 'application/json',
'X-CH-Auth-Email': self.api_e... | python | def fetch_batch_status(self, guid):
"""Fetch the status of a batch, given the guid"""
url = '%s/api/v5/batch/%s/status' % (self.base_url, guid)
headers = {
'User-Agent': 'kentik-python-api/0.1',
'Content-Type': 'application/json',
'X-CH-Auth-Email': self.api_e... | [
"def",
"fetch_batch_status",
"(",
"self",
",",
"guid",
")",
":",
"url",
"=",
"'%s/api/v5/batch/%s/status'",
"%",
"(",
"self",
".",
"base_url",
",",
"guid",
")",
"headers",
"=",
"{",
"'User-Agent'",
":",
"'kentik-python-api/0.1'",
",",
"'Content-Type'",
":",
"'... | Fetch the status of a batch, given the guid | [
"Fetch",
"the",
"status",
"of",
"a",
"batch",
"given",
"the",
"guid"
] | aa94c0b7eaf88409818b97967d7293e309e11bab | https://github.com/kentik/kentikapi-py/blob/aa94c0b7eaf88409818b97967d7293e309e11bab/kentikapi/v5/tagging.py#L453-L467 | train | Fetch the status of a batch given the guid |
SMAPPNYU/pysmap | pysmap/mltools/crowd_model.py | CrowdModel.predict_imgs | def predict_imgs(self, imgs):
'''
takes an image input and predicts on it
this expects an ndarray (heightxwidthxchannels)
this model shouldbe a (Nx224x224x3) numpy array
this method it noce if you want to do preprocessing
then predict results on those preprocessed images
... | python | def predict_imgs(self, imgs):
'''
takes an image input and predicts on it
this expects an ndarray (heightxwidthxchannels)
this model shouldbe a (Nx224x224x3) numpy array
this method it noce if you want to do preprocessing
then predict results on those preprocessed images
... | [
"def",
"predict_imgs",
"(",
"self",
",",
"imgs",
")",
":",
"imgs",
"=",
"preprocess_input",
"(",
"imgs",
")",
"return",
"self",
".",
"model",
".",
"predict",
"(",
"imgs",
")"
] | takes an image input and predicts on it
this expects an ndarray (heightxwidthxchannels)
this model shouldbe a (Nx224x224x3) numpy array
this method it noce if you want to do preprocessing
then predict results on those preprocessed images
this function expects the image array to b... | [
"takes",
"an",
"image",
"input",
"and",
"predicts",
"on",
"it",
"this",
"expects",
"an",
"ndarray",
"(",
"heightxwidthxchannels",
")",
"this",
"model",
"shouldbe",
"a",
"(",
"Nx224x224x3",
")",
"numpy",
"array",
"this",
"method",
"it",
"noce",
"if",
"you",
... | eb871992f40c53125129535e871525d5623c8c2d | https://github.com/SMAPPNYU/pysmap/blob/eb871992f40c53125129535e871525d5623c8c2d/pysmap/mltools/crowd_model.py#L32-L42 | train | predicts on the images in imgs and returns the result |
SMAPPNYU/pysmap | pysmap/mltools/crowd_model.py | CrowdModel.predict_files | def predict_files(self, files):
'''
reads files off disk, resizes them
and then predicts them, files should
be a list or itrerable of file paths
that lead to images, they are then
loaded with opencv, resized, and predicted
'''
imgs = [0]*len(files)
... | python | def predict_files(self, files):
'''
reads files off disk, resizes them
and then predicts them, files should
be a list or itrerable of file paths
that lead to images, they are then
loaded with opencv, resized, and predicted
'''
imgs = [0]*len(files)
... | [
"def",
"predict_files",
"(",
"self",
",",
"files",
")",
":",
"imgs",
"=",
"[",
"0",
"]",
"*",
"len",
"(",
"files",
")",
"for",
"i",
",",
"file",
"in",
"enumerate",
"(",
"files",
")",
":",
"img",
"=",
"cv2",
".",
"imread",
"(",
"file",
")",
".",... | reads files off disk, resizes them
and then predicts them, files should
be a list or itrerable of file paths
that lead to images, they are then
loaded with opencv, resized, and predicted | [
"reads",
"files",
"off",
"disk",
"resizes",
"them",
"and",
"then",
"predicts",
"them",
"files",
"should",
"be",
"a",
"list",
"or",
"itrerable",
"of",
"file",
"paths",
"that",
"lead",
"to",
"images",
"they",
"are",
"then",
"loaded",
"with",
"opencv",
"resiz... | eb871992f40c53125129535e871525d5623c8c2d | https://github.com/SMAPPNYU/pysmap/blob/eb871992f40c53125129535e871525d5623c8c2d/pysmap/mltools/crowd_model.py#L44-L60 | train | reads files off disk resizes them and predicts them |
koszullab/metaTOR | metator/scripts/fasta_utils.py | rename_genome | def rename_genome(genome_in, genome_out=None):
"""Rename genome and slugify headers
Rename genomes according to a simple naming scheme; this
is mainly done to avoid special character weirdness.
Parameters
----------
genome_in : file, str or pathlib.Path
The input genome to be renamed a... | python | def rename_genome(genome_in, genome_out=None):
"""Rename genome and slugify headers
Rename genomes according to a simple naming scheme; this
is mainly done to avoid special character weirdness.
Parameters
----------
genome_in : file, str or pathlib.Path
The input genome to be renamed a... | [
"def",
"rename_genome",
"(",
"genome_in",
",",
"genome_out",
"=",
"None",
")",
":",
"if",
"genome_out",
"is",
"None",
":",
"genome_out",
"=",
"\"{}_renamed.fa\"",
".",
"format",
"(",
"genome_in",
".",
"split",
"(",
"\".\"",
")",
"[",
"0",
"]",
")",
"with... | Rename genome and slugify headers
Rename genomes according to a simple naming scheme; this
is mainly done to avoid special character weirdness.
Parameters
----------
genome_in : file, str or pathlib.Path
The input genome to be renamed and slugify.
genome_out : file, str or pathlib.Path... | [
"Rename",
"genome",
"and",
"slugify",
"headers"
] | 0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a | https://github.com/koszullab/metaTOR/blob/0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a/metator/scripts/fasta_utils.py#L18-L50 | train | Rename genome and slugify headers |
koszullab/metaTOR | metator/scripts/fasta_utils.py | filter_genome | def filter_genome(genome_in, threshold=500, list_records=None):
"""Filter fasta file according to various parameters.
Filter a fasta file according to size and/or an explicit list of records
to keep.
Parameters
----------
genome_in: file, str or pathlib.Path
The input genome in FASTA f... | python | def filter_genome(genome_in, threshold=500, list_records=None):
"""Filter fasta file according to various parameters.
Filter a fasta file according to size and/or an explicit list of records
to keep.
Parameters
----------
genome_in: file, str or pathlib.Path
The input genome in FASTA f... | [
"def",
"filter_genome",
"(",
"genome_in",
",",
"threshold",
"=",
"500",
",",
"list_records",
"=",
"None",
")",
":",
"if",
"list_records",
"is",
"None",
":",
"def",
"truth",
"(",
"*",
"args",
")",
":",
"del",
"args",
"return",
"True",
"is_a_record_to_keep",... | Filter fasta file according to various parameters.
Filter a fasta file according to size and/or an explicit list of records
to keep.
Parameters
----------
genome_in: file, str or pathlib.Path
The input genome in FASTA format.
threshold: int, optional
The size below which genome... | [
"Filter",
"fasta",
"file",
"according",
"to",
"various",
"parameters",
"."
] | 0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a | https://github.com/koszullab/metaTOR/blob/0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a/metator/scripts/fasta_utils.py#L53-L103 | train | Filter a genome file according to various parameters. |
koszullab/metaTOR | metator/scripts/fasta_utils.py | rename_proteins | def rename_proteins(prot_in, prot_out=None, chunk_size=DEFAULT_CHUNK_SIZE):
"""Rename prodigal output files
Rename output files from prodigal according to the following naming
scheme: >contigX_chunkY__geneZ
Chunk numbering starts at 0 and gene identification is taken from prodigal.
Parameters
... | python | def rename_proteins(prot_in, prot_out=None, chunk_size=DEFAULT_CHUNK_SIZE):
"""Rename prodigal output files
Rename output files from prodigal according to the following naming
scheme: >contigX_chunkY__geneZ
Chunk numbering starts at 0 and gene identification is taken from prodigal.
Parameters
... | [
"def",
"rename_proteins",
"(",
"prot_in",
",",
"prot_out",
"=",
"None",
",",
"chunk_size",
"=",
"DEFAULT_CHUNK_SIZE",
")",
":",
"if",
"prot_out",
"is",
"None",
":",
"prot_out",
"=",
"\"{}_renamed.fa\"",
".",
"format",
"(",
"prot_in",
".",
"split",
"(",
"\".\... | Rename prodigal output files
Rename output files from prodigal according to the following naming
scheme: >contigX_chunkY__geneZ
Chunk numbering starts at 0 and gene identification is taken from prodigal.
Parameters
----------
prot_in : file, str or pathlib.Path
The input protein file ... | [
"Rename",
"prodigal",
"output",
"files"
] | 0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a | https://github.com/koszullab/metaTOR/blob/0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a/metator/scripts/fasta_utils.py#L106-L144 | train | Rename proteins in a file in FASTA format. |
koszullab/metaTOR | metator/scripts/fasta_utils.py | write_records | def write_records(records, output_file, split=False):
"""Write FASTA records
Write a FASTA file from an iterable of records.
Parameters
----------
records : iterable
Input records to write.
output_file : file, str or pathlib.Path
Output FASTA file to be written into.
split... | python | def write_records(records, output_file, split=False):
"""Write FASTA records
Write a FASTA file from an iterable of records.
Parameters
----------
records : iterable
Input records to write.
output_file : file, str or pathlib.Path
Output FASTA file to be written into.
split... | [
"def",
"write_records",
"(",
"records",
",",
"output_file",
",",
"split",
"=",
"False",
")",
":",
"if",
"split",
":",
"for",
"record",
"in",
"records",
":",
"with",
"open",
"(",
"\"{}{}.fa\"",
".",
"format",
"(",
"output_file",
",",
"record",
".",
"id",
... | Write FASTA records
Write a FASTA file from an iterable of records.
Parameters
----------
records : iterable
Input records to write.
output_file : file, str or pathlib.Path
Output FASTA file to be written into.
split : bool, optional
If True, each record is written into... | [
"Write",
"FASTA",
"records"
] | 0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a | https://github.com/koszullab/metaTOR/blob/0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a/metator/scripts/fasta_utils.py#L147-L171 | train | Write a FASTA file from an iterable of records into a single file. |
eclipse/unide.python | src/unide/process.py | Series.add_sample | def add_sample(self, **data):
"""Add a sample to this series."""
missing_dimensions = set(data).difference(self.dimensions)
if missing_dimensions:
raise KeyError('Dimensions not defined in this series: %s'
% ', '.join(missing_dimensions))
for dim ... | python | def add_sample(self, **data):
"""Add a sample to this series."""
missing_dimensions = set(data).difference(self.dimensions)
if missing_dimensions:
raise KeyError('Dimensions not defined in this series: %s'
% ', '.join(missing_dimensions))
for dim ... | [
"def",
"add_sample",
"(",
"self",
",",
"*",
"*",
"data",
")",
":",
"missing_dimensions",
"=",
"set",
"(",
"data",
")",
".",
"difference",
"(",
"self",
".",
"dimensions",
")",
"if",
"missing_dimensions",
":",
"raise",
"KeyError",
"(",
"'Dimensions not defined... | Add a sample to this series. | [
"Add",
"a",
"sample",
"to",
"this",
"series",
"."
] | b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493 | https://github.com/eclipse/unide.python/blob/b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493/src/unide/process.py#L158-L167 | train | Add a sample to this series. |
eclipse/unide.python | src/unide/process.py | Measurement.samples | def samples(self):
"""Yield the samples as dicts, keyed by dimensions."""
names = self.series.dimensions
for values in zip(*(getattr(self.series, name) for name in names)):
yield dict(zip(names, values)) | python | def samples(self):
"""Yield the samples as dicts, keyed by dimensions."""
names = self.series.dimensions
for values in zip(*(getattr(self.series, name) for name in names)):
yield dict(zip(names, values)) | [
"def",
"samples",
"(",
"self",
")",
":",
"names",
"=",
"self",
".",
"series",
".",
"dimensions",
"for",
"values",
"in",
"zip",
"(",
"*",
"(",
"getattr",
"(",
"self",
".",
"series",
",",
"name",
")",
"for",
"name",
"in",
"names",
")",
")",
":",
"y... | Yield the samples as dicts, keyed by dimensions. | [
"Yield",
"the",
"samples",
"as",
"dicts",
"keyed",
"by",
"dimensions",
"."
] | b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493 | https://github.com/eclipse/unide.python/blob/b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493/src/unide/process.py#L298-L302 | train | Yield the samples as dicts keyed by dimensions. |
vasilcovsky/pytinypng | pytinypng/utils.py | write_binary | def write_binary(filename, data):
"""Create path to filename and saves binary data"""
dir = os.path.dirname(filename)
if not os.path.exists(dir):
os.makedirs(dir)
with open(filename, 'wb') as f:
f.write(data) | python | def write_binary(filename, data):
"""Create path to filename and saves binary data"""
dir = os.path.dirname(filename)
if not os.path.exists(dir):
os.makedirs(dir)
with open(filename, 'wb') as f:
f.write(data) | [
"def",
"write_binary",
"(",
"filename",
",",
"data",
")",
":",
"dir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"filename",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"dir",
")",
":",
"os",
".",
"makedirs",
"(",
"dir",
")",
"with... | Create path to filename and saves binary data | [
"Create",
"path",
"to",
"filename",
"and",
"saves",
"binary",
"data"
] | ac633e4aa41122c49a806f411e43a76d8f73058e | https://github.com/vasilcovsky/pytinypng/blob/ac633e4aa41122c49a806f411e43a76d8f73058e/pytinypng/utils.py#L22-L28 | train | Create path to filename and saves binary data |
vasilcovsky/pytinypng | pytinypng/utils.py | files_with_exts | def files_with_exts(root='.', suffix=''):
"""Returns generator that contains filenames
from root directory and ends with suffix
"""
return (os.path.join(rootdir, filename)
for rootdir, dirnames, filenames in os.walk(root)
for filename in filenames
if filename.endsw... | python | def files_with_exts(root='.', suffix=''):
"""Returns generator that contains filenames
from root directory and ends with suffix
"""
return (os.path.join(rootdir, filename)
for rootdir, dirnames, filenames in os.walk(root)
for filename in filenames
if filename.endsw... | [
"def",
"files_with_exts",
"(",
"root",
"=",
"'.'",
",",
"suffix",
"=",
"''",
")",
":",
"return",
"(",
"os",
".",
"path",
".",
"join",
"(",
"rootdir",
",",
"filename",
")",
"for",
"rootdir",
",",
"dirnames",
",",
"filenames",
"in",
"os",
".",
"walk",
... | Returns generator that contains filenames
from root directory and ends with suffix | [
"Returns",
"generator",
"that",
"contains",
"filenames",
"from",
"root",
"directory",
"and",
"ends",
"with",
"suffix"
] | ac633e4aa41122c49a806f411e43a76d8f73058e | https://github.com/vasilcovsky/pytinypng/blob/ac633e4aa41122c49a806f411e43a76d8f73058e/pytinypng/utils.py#L37-L44 | train | Returns generator that contains filenames from root directory and ends with suffix |
vasilcovsky/pytinypng | pytinypng/utils.py | find_apikey | def find_apikey():
"""Finds TinyPNG API key
Search for api key in following order:
- environment variable TINYPNG_APIKEY
- environment variable TINYPNG_API_KEY
- file in local directory tinypng.key
- file in home directory ~/.tinypng.key
If key not found returns None
"""
env_ke... | python | def find_apikey():
"""Finds TinyPNG API key
Search for api key in following order:
- environment variable TINYPNG_APIKEY
- environment variable TINYPNG_API_KEY
- file in local directory tinypng.key
- file in home directory ~/.tinypng.key
If key not found returns None
"""
env_ke... | [
"def",
"find_apikey",
"(",
")",
":",
"env_keys",
"=",
"[",
"'TINYPNG_APIKEY'",
",",
"'TINYPNG_API_KEY'",
"]",
"paths",
"=",
"[",
"]",
"paths",
".",
"append",
"(",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"\".\"",
"... | Finds TinyPNG API key
Search for api key in following order:
- environment variable TINYPNG_APIKEY
- environment variable TINYPNG_API_KEY
- file in local directory tinypng.key
- file in home directory ~/.tinypng.key
If key not found returns None | [
"Finds",
"TinyPNG",
"API",
"key"
] | ac633e4aa41122c49a806f411e43a76d8f73058e | https://github.com/vasilcovsky/pytinypng/blob/ac633e4aa41122c49a806f411e43a76d8f73058e/pytinypng/utils.py#L67-L91 | train | Finds TinyPNG API key in following order |
ihiji/version_utils | version_utils/rpm.py | compare_packages | def compare_packages(rpm_str_a, rpm_str_b, arch_provided=True):
"""Compare two RPM strings to determine which is newer
Parses version information out of RPM package strings of the form
returned by the ``rpm -q`` command and compares their versions to
determine which is newer. Provided strings *do not* ... | python | def compare_packages(rpm_str_a, rpm_str_b, arch_provided=True):
"""Compare two RPM strings to determine which is newer
Parses version information out of RPM package strings of the form
returned by the ``rpm -q`` command and compares their versions to
determine which is newer. Provided strings *do not* ... | [
"def",
"compare_packages",
"(",
"rpm_str_a",
",",
"rpm_str_b",
",",
"arch_provided",
"=",
"True",
")",
":",
"logger",
".",
"debug",
"(",
"'resolve_versions(%s, %s)'",
",",
"rpm_str_a",
",",
"rpm_str_b",
")",
"evr_a",
"=",
"parse_package",
"(",
"rpm_str_a",
",",
... | Compare two RPM strings to determine which is newer
Parses version information out of RPM package strings of the form
returned by the ``rpm -q`` command and compares their versions to
determine which is newer. Provided strings *do not* require an
architecture at the end, although if providing strings w... | [
"Compare",
"two",
"RPM",
"strings",
"to",
"determine",
"which",
"is",
"newer"
] | 7f63d80faca8e76274b6e8dff7637cc7cb8d848c | https://github.com/ihiji/version_utils/blob/7f63d80faca8e76274b6e8dff7637cc7cb8d848c/version_utils/rpm.py#L41-L65 | train | Compares two RPM packages and returns 1 if the RPM string is newer or - 1 if the RPM string is newer. |
ihiji/version_utils | version_utils/rpm.py | compare_evrs | def compare_evrs(evr_a, evr_b):
"""Compare two EVR tuples to determine which is newer
This method compares the epoch, version, and release of the
provided package strings, assuming that epoch is 0 if not provided.
Comparison is performed on the epoch, then the version, and then
the release. If at a... | python | def compare_evrs(evr_a, evr_b):
"""Compare two EVR tuples to determine which is newer
This method compares the epoch, version, and release of the
provided package strings, assuming that epoch is 0 if not provided.
Comparison is performed on the epoch, then the version, and then
the release. If at a... | [
"def",
"compare_evrs",
"(",
"evr_a",
",",
"evr_b",
")",
":",
"a_epoch",
",",
"a_ver",
",",
"a_rel",
"=",
"evr_a",
"b_epoch",
",",
"b_ver",
",",
"b_rel",
"=",
"evr_b",
"if",
"a_epoch",
"!=",
"b_epoch",
":",
"return",
"a_newer",
"if",
"a_epoch",
">",
"b_... | Compare two EVR tuples to determine which is newer
This method compares the epoch, version, and release of the
provided package strings, assuming that epoch is 0 if not provided.
Comparison is performed on the epoch, then the version, and then
the release. If at any point a non-equality is found, the r... | [
"Compare",
"two",
"EVR",
"tuples",
"to",
"determine",
"which",
"is",
"newer"
] | 7f63d80faca8e76274b6e8dff7637cc7cb8d848c | https://github.com/ihiji/version_utils/blob/7f63d80faca8e76274b6e8dff7637cc7cb8d848c/version_utils/rpm.py#L68-L90 | train | Compares two EVR tuples to determine which is newer
|
ihiji/version_utils | version_utils/rpm.py | compare_versions | def compare_versions(version_a, version_b):
"""Compare two RPM version strings
Compares two RPM version strings and returns an integer indicating
the result of the comparison. The method of comparison mirrors that
used by RPM, so results should be the same for any standard RPM
package.
To perf... | python | def compare_versions(version_a, version_b):
"""Compare two RPM version strings
Compares two RPM version strings and returns an integer indicating
the result of the comparison. The method of comparison mirrors that
used by RPM, so results should be the same for any standard RPM
package.
To perf... | [
"def",
"compare_versions",
"(",
"version_a",
",",
"version_b",
")",
":",
"logger",
".",
"debug",
"(",
"'compare_versions(%s, %s)'",
",",
"version_a",
",",
"version_b",
")",
"if",
"version_a",
"==",
"version_b",
":",
"return",
"a_eq_b",
"try",
":",
"chars_a",
"... | Compare two RPM version strings
Compares two RPM version strings and returns an integer indicating
the result of the comparison. The method of comparison mirrors that
used by RPM, so results should be the same for any standard RPM
package.
To perform the comparison, the strings are first checked f... | [
"Compare",
"two",
"RPM",
"version",
"strings"
] | 7f63d80faca8e76274b6e8dff7637cc7cb8d848c | https://github.com/ihiji/version_utils/blob/7f63d80faca8e76274b6e8dff7637cc7cb8d848c/version_utils/rpm.py#L115-L185 | train | Compares two RPM version strings and returns the result of the comparison. |
ihiji/version_utils | version_utils/rpm.py | package | def package(package_string, arch_included=True):
"""Parse an RPM version string
Parses most (all tested) RPM version strings to get their name,
epoch, version, release, and architecture information. Epoch (also
called serial) is an optional component for RPM versions, and it
is also optional when p... | python | def package(package_string, arch_included=True):
"""Parse an RPM version string
Parses most (all tested) RPM version strings to get their name,
epoch, version, release, and architecture information. Epoch (also
called serial) is an optional component for RPM versions, and it
is also optional when p... | [
"def",
"package",
"(",
"package_string",
",",
"arch_included",
"=",
"True",
")",
":",
"logger",
".",
"debug",
"(",
"'package(%s, %s)'",
",",
"package_string",
",",
"arch_included",
")",
"pkg_info",
"=",
"parse_package",
"(",
"package_string",
",",
"arch_included",... | Parse an RPM version string
Parses most (all tested) RPM version strings to get their name,
epoch, version, release, and architecture information. Epoch (also
called serial) is an optional component for RPM versions, and it
is also optional when providing a version string to this function.
RPM assu... | [
"Parse",
"an",
"RPM",
"version",
"string"
] | 7f63d80faca8e76274b6e8dff7637cc7cb8d848c | https://github.com/ihiji/version_utils/blob/7f63d80faca8e76274b6e8dff7637cc7cb8d848c/version_utils/rpm.py#L188-L209 | train | Parses an RPM version string and returns a common. Package object containing all parsed information. |
ihiji/version_utils | version_utils/rpm.py | parse_package | def parse_package(package_string, arch_included=True):
"""Parse an RPM version string to get name, version, and arch
Splits most (all tested) RPM version strings into name, epoch,
version, release, and architecture. Epoch (also called serial) is
an optional component of RPM versioning and is also optio... | python | def parse_package(package_string, arch_included=True):
"""Parse an RPM version string to get name, version, and arch
Splits most (all tested) RPM version strings into name, epoch,
version, release, and architecture. Epoch (also called serial) is
an optional component of RPM versioning and is also optio... | [
"def",
"parse_package",
"(",
"package_string",
",",
"arch_included",
"=",
"True",
")",
":",
"# Yum sets epoch values to 0 if they are not specified",
"logger",
".",
"debug",
"(",
"'parse_package(%s, %s)'",
",",
"package_string",
",",
"arch_included",
")",
"default_epoch",
... | Parse an RPM version string to get name, version, and arch
Splits most (all tested) RPM version strings into name, epoch,
version, release, and architecture. Epoch (also called serial) is
an optional component of RPM versioning and is also optional in
version strings provided to this function. RPM assu... | [
"Parse",
"an",
"RPM",
"version",
"string",
"to",
"get",
"name",
"version",
"and",
"arch"
] | 7f63d80faca8e76274b6e8dff7637cc7cb8d848c | https://github.com/ihiji/version_utils/blob/7f63d80faca8e76274b6e8dff7637cc7cb8d848c/version_utils/rpm.py#L212-L252 | train | Parse an RPM version string to get name version and arch. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.