repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
tomnor/channelpack | channelpack/pack.py | ChannelPack.query_names | def query_names(self, pat):
"""pat a shell pattern. See fnmatch.fnmatchcase. Print the
results to stdout."""
for item in self.chnames.items():
if fnmatch.fnmatchcase(item[1], pat):
print item | python | def query_names(self, pat):
"""pat a shell pattern. See fnmatch.fnmatchcase. Print the
results to stdout."""
for item in self.chnames.items():
if fnmatch.fnmatchcase(item[1], pat):
print item | [
"def",
"query_names",
"(",
"self",
",",
"pat",
")",
":",
"for",
"item",
"in",
"self",
".",
"chnames",
".",
"items",
"(",
")",
":",
"if",
"fnmatch",
".",
"fnmatchcase",
"(",
"item",
"[",
"1",
"]",
",",
"pat",
")",
":",
"print",
"item"
] | pat a shell pattern. See fnmatch.fnmatchcase. Print the
results to stdout. | [
"pat",
"a",
"shell",
"pattern",
".",
"See",
"fnmatch",
".",
"fnmatchcase",
".",
"Print",
"the",
"results",
"to",
"stdout",
"."
] | train | https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pack.py#L940-L946 |
tomnor/channelpack | channelpack/pack.py | ChannelPack.set_basefilemtime | def set_basefilemtime(self):
"""Set attributes mtimestamp and mtimefs. If the global list
ORIGINEXTENSIONS include any items, try and look for files (in
the directory where self.filename is sitting) with the same base
name as the loaded file, but with an extension specified in
OR... | python | def set_basefilemtime(self):
"""Set attributes mtimestamp and mtimefs. If the global list
ORIGINEXTENSIONS include any items, try and look for files (in
the directory where self.filename is sitting) with the same base
name as the loaded file, but with an extension specified in
OR... | [
"def",
"set_basefilemtime",
"(",
"self",
")",
":",
"dirpath",
"=",
"os",
".",
"path",
".",
"split",
"(",
"self",
".",
"filename",
")",
"[",
"0",
"]",
"name",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"self",
".",
"fs",
")",
".",
"split",
"(",... | Set attributes mtimestamp and mtimefs. If the global list
ORIGINEXTENSIONS include any items, try and look for files (in
the directory where self.filename is sitting) with the same base
name as the loaded file, but with an extension specified in
ORIGINEXTENSIONS.
mtimestamp is a... | [
"Set",
"attributes",
"mtimestamp",
"and",
"mtimefs",
".",
"If",
"the",
"global",
"list",
"ORIGINEXTENSIONS",
"include",
"any",
"items",
"try",
"and",
"look",
"for",
"files",
"(",
"in",
"the",
"directory",
"where",
"self",
".",
"filename",
"is",
"sitting",
")... | train | https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pack.py#L948-L984 |
tomnor/channelpack | channelpack/pack.py | _ConditionConfigure.set_condition | def set_condition(self, conkey, val):
"""Set condition conkey to value val. Convert val to str if not
None.
conkey: str
A valid condition key.
val: str, int, float, None
Can always be None. Can be number or string depending on conkey.
"""
if not... | python | def set_condition(self, conkey, val):
"""Set condition conkey to value val. Convert val to str if not
None.
conkey: str
A valid condition key.
val: str, int, float, None
Can always be None. Can be number or string depending on conkey.
"""
if not... | [
"def",
"set_condition",
"(",
"self",
",",
"conkey",
",",
"val",
")",
":",
"if",
"not",
"any",
"(",
"[",
"conkey",
".",
"startswith",
"(",
"c",
")",
"for",
"c",
"in",
"_COND_PREFIXES",
"]",
")",
":",
"raise",
"KeyError",
"(",
"conkey",
")",
"if",
"v... | Set condition conkey to value val. Convert val to str if not
None.
conkey: str
A valid condition key.
val: str, int, float, None
Can always be None. Can be number or string depending on conkey. | [
"Set",
"condition",
"conkey",
"to",
"value",
"val",
".",
"Convert",
"val",
"to",
"str",
"if",
"not",
"None",
"."
] | train | https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pack.py#L1013-L1030 |
tomnor/channelpack | channelpack/pack.py | _ConditionConfigure.spit_config | def spit_config(self, conf_file, firstwordonly=False):
"""conf_file a file opened for writing."""
cfg = ConfigParser.RawConfigParser()
for sec in _CONFIG_SECS:
cfg.add_section(sec)
sec = 'channels'
for i in sorted(self.pack.D):
cfg.set(sec, str(i),
... | python | def spit_config(self, conf_file, firstwordonly=False):
"""conf_file a file opened for writing."""
cfg = ConfigParser.RawConfigParser()
for sec in _CONFIG_SECS:
cfg.add_section(sec)
sec = 'channels'
for i in sorted(self.pack.D):
cfg.set(sec, str(i),
... | [
"def",
"spit_config",
"(",
"self",
",",
"conf_file",
",",
"firstwordonly",
"=",
"False",
")",
":",
"cfg",
"=",
"ConfigParser",
".",
"RawConfigParser",
"(",
")",
"for",
"sec",
"in",
"_CONFIG_SECS",
":",
"cfg",
".",
"add_section",
"(",
"sec",
")",
"sec",
"... | conf_file a file opened for writing. | [
"conf_file",
"a",
"file",
"opened",
"for",
"writing",
"."
] | train | https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pack.py#L1032-L1048 |
tomnor/channelpack | channelpack/pack.py | _ConditionConfigure.eat_config | def eat_config(self, conf_file):
"""conf_file a file opened for reading.
Update the packs channel names and the conditions, accordingly.
"""
# Read the file:
cfg = ConfigParser.RawConfigParser()
cfg.readfp(conf_file)
# Update channel names:
sec = 'chan... | python | def eat_config(self, conf_file):
"""conf_file a file opened for reading.
Update the packs channel names and the conditions, accordingly.
"""
# Read the file:
cfg = ConfigParser.RawConfigParser()
cfg.readfp(conf_file)
# Update channel names:
sec = 'chan... | [
"def",
"eat_config",
"(",
"self",
",",
"conf_file",
")",
":",
"# Read the file:",
"cfg",
"=",
"ConfigParser",
".",
"RawConfigParser",
"(",
")",
"cfg",
".",
"readfp",
"(",
"conf_file",
")",
"# Update channel names:",
"sec",
"=",
"'channels'",
"mess",
"=",
"'mis... | conf_file a file opened for reading.
Update the packs channel names and the conditions, accordingly. | [
"conf_file",
"a",
"file",
"opened",
"for",
"reading",
"."
] | train | https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pack.py#L1050-L1088 |
tomnor/channelpack | channelpack/pack.py | _ConditionConfigure.conditions_list | def conditions_list(self, conkey):
"""
Return a (possibly empty) list of conditions based on
conkey. The conditions are returned raw, not parsed.
conkey: str
for cond<n>, startcond<n> or stopcond<n>, specify only the
prefix. The list will be filled with all condi... | python | def conditions_list(self, conkey):
"""
Return a (possibly empty) list of conditions based on
conkey. The conditions are returned raw, not parsed.
conkey: str
for cond<n>, startcond<n> or stopcond<n>, specify only the
prefix. The list will be filled with all condi... | [
"def",
"conditions_list",
"(",
"self",
",",
"conkey",
")",
":",
"L",
"=",
"[",
"]",
"keys",
"=",
"[",
"k",
"for",
"k",
"in",
"self",
".",
"conditions",
"if",
"k",
".",
"startswith",
"(",
"conkey",
")",
"]",
"# sloppy",
"if",
"not",
"keys",
":",
"... | Return a (possibly empty) list of conditions based on
conkey. The conditions are returned raw, not parsed.
conkey: str
for cond<n>, startcond<n> or stopcond<n>, specify only the
prefix. The list will be filled with all conditions. | [
"Return",
"a",
"(",
"possibly",
"empty",
")",
"list",
"of",
"conditions",
"based",
"on",
"conkey",
".",
"The",
"conditions",
"are",
"returned",
"raw",
"not",
"parsed",
"."
] | train | https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pack.py#L1092-L1111 |
tomnor/channelpack | channelpack/pack.py | _ConditionConfigure.cond_int | def cond_int(self, conkey):
"""Return the trailing number from cond if any, as an int. If no
trailing number, return the string conkey as is.
This is used for sorting the conditions properly even when
passing the number 10. The name of this function could be
improved since it mi... | python | def cond_int(self, conkey):
"""Return the trailing number from cond if any, as an int. If no
trailing number, return the string conkey as is.
This is used for sorting the conditions properly even when
passing the number 10. The name of this function could be
improved since it mi... | [
"def",
"cond_int",
"(",
"self",
",",
"conkey",
")",
":",
"m",
"=",
"re",
".",
"match",
"(",
"self",
".",
"numrx",
",",
"conkey",
")",
"if",
"not",
"m",
":",
"return",
"conkey",
"return",
"int",
"(",
"m",
".",
"group",
"(",
"1",
")",
")"
] | Return the trailing number from cond if any, as an int. If no
trailing number, return the string conkey as is.
This is used for sorting the conditions properly even when
passing the number 10. The name of this function could be
improved since it might return a string. | [
"Return",
"the",
"trailing",
"number",
"from",
"cond",
"if",
"any",
"as",
"an",
"int",
".",
"If",
"no",
"trailing",
"number",
"return",
"the",
"string",
"conkey",
"as",
"is",
"."
] | train | https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pack.py#L1125-L1136 |
tomnor/channelpack | channelpack/pack.py | _ConditionConfigure.valid_conkey | def valid_conkey(self, conkey):
"""Check that the conkey is a valid one. Return True if valid. A
condition key is valid if it is one in the _COND_PREFIXES
list. With the prefix removed, the remaining string must be
either a number or the empty string."""
for prefix in _COND_PREF... | python | def valid_conkey(self, conkey):
"""Check that the conkey is a valid one. Return True if valid. A
condition key is valid if it is one in the _COND_PREFIXES
list. With the prefix removed, the remaining string must be
either a number or the empty string."""
for prefix in _COND_PREF... | [
"def",
"valid_conkey",
"(",
"self",
",",
"conkey",
")",
":",
"for",
"prefix",
"in",
"_COND_PREFIXES",
":",
"trailing",
"=",
"conkey",
".",
"lstrip",
"(",
"prefix",
")",
"if",
"trailing",
"==",
"''",
"and",
"conkey",
":",
"# conkey is not empty",
"return",
... | Check that the conkey is a valid one. Return True if valid. A
condition key is valid if it is one in the _COND_PREFIXES
list. With the prefix removed, the remaining string must be
either a number or the empty string. | [
"Check",
"that",
"the",
"conkey",
"is",
"a",
"valid",
"one",
".",
"Return",
"True",
"if",
"valid",
".",
"A",
"condition",
"key",
"is",
"valid",
"if",
"it",
"is",
"one",
"in",
"the",
"_COND_PREFIXES",
"list",
".",
"With",
"the",
"prefix",
"removed",
"th... | train | https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pack.py#L1138-L1154 |
tomnor/channelpack | channelpack/pack.py | _ConditionConfigure.next_conkey | def next_conkey(self, conkey):
"""Return the next <conkey><n> based on conkey as a
string. Example, if 'startcond3' and 'startcond5' exist, this
will return 'startcond6' if 'startcond5' value is not None,
else startcond5 is returned.
It is assumed conkey is a valid condition key... | python | def next_conkey(self, conkey):
"""Return the next <conkey><n> based on conkey as a
string. Example, if 'startcond3' and 'startcond5' exist, this
will return 'startcond6' if 'startcond5' value is not None,
else startcond5 is returned.
It is assumed conkey is a valid condition key... | [
"def",
"next_conkey",
"(",
"self",
",",
"conkey",
")",
":",
"if",
"conkey",
"in",
"self",
".",
"conditions",
":",
"return",
"conkey",
"# Explicit conkey",
"conkeys",
"=",
"self",
".",
"sorted_conkeys",
"(",
"prefix",
"=",
"conkey",
")",
"# Might be empty.",
... | Return the next <conkey><n> based on conkey as a
string. Example, if 'startcond3' and 'startcond5' exist, this
will return 'startcond6' if 'startcond5' value is not None,
else startcond5 is returned.
It is assumed conkey is a valid condition key.
.. warning::
Under c... | [
"Return",
"the",
"next",
"<conkey",
">",
"<n",
">",
"based",
"on",
"conkey",
"as",
"a",
"string",
".",
"Example",
"if",
"startcond3",
"and",
"startcond5",
"exist",
"this",
"will",
"return",
"startcond6",
"if",
"startcond5",
"value",
"is",
"not",
"None",
"e... | train | https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pack.py#L1156-L1184 |
tomnor/channelpack | channelpack/pack.py | _ConditionConfigure.sorted_conkeys | def sorted_conkeys(self, prefix=None):
"""Return all condition keys in self.conditions as a list sorted
suitable for print or write to a file. If prefix is given return
only the ones prefixed with prefix."""
# Make for defined and sorted output:
conkeys = []
for cond in ... | python | def sorted_conkeys(self, prefix=None):
"""Return all condition keys in self.conditions as a list sorted
suitable for print or write to a file. If prefix is given return
only the ones prefixed with prefix."""
# Make for defined and sorted output:
conkeys = []
for cond in ... | [
"def",
"sorted_conkeys",
"(",
"self",
",",
"prefix",
"=",
"None",
")",
":",
"# Make for defined and sorted output:",
"conkeys",
"=",
"[",
"]",
"for",
"cond",
"in",
"_COND_PREFIXES",
":",
"conkeys",
"+=",
"sorted",
"(",
"[",
"key",
"for",
"key",
"in",
"self",... | Return all condition keys in self.conditions as a list sorted
suitable for print or write to a file. If prefix is given return
only the ones prefixed with prefix. | [
"Return",
"all",
"condition",
"keys",
"in",
"self",
".",
"conditions",
"as",
"a",
"list",
"sorted",
"suitable",
"for",
"print",
"or",
"write",
"to",
"a",
"file",
".",
"If",
"prefix",
"is",
"given",
"return",
"only",
"the",
"ones",
"prefixed",
"with",
"pr... | train | https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pack.py#L1186-L1198 |
ulf1/oxyba | oxyba/isordinal.py | isordinal | def isordinal(x):
"""Checks if a list or array contains ordinal data.
Warning:
--------
This is not a reliable check for a variable being
ordinal.
The following criteria are used
- There are more observations than unique values.
Why? Ordinal means discrete or countable and
... | python | def isordinal(x):
"""Checks if a list or array contains ordinal data.
Warning:
--------
This is not a reliable check for a variable being
ordinal.
The following criteria are used
- There are more observations than unique values.
Why? Ordinal means discrete or countable and
... | [
"def",
"isordinal",
"(",
"x",
")",
":",
"import",
"numpy",
"as",
"np",
"if",
"len",
"(",
"x",
")",
"==",
"len",
"(",
"np",
".",
"unique",
"(",
"x",
")",
")",
":",
"return",
"False",
",",
"(",
"\"number of observations equals the \"",
"\"number of unique ... | Checks if a list or array contains ordinal data.
Warning:
--------
This is not a reliable check for a variable being
ordinal.
The following criteria are used
- There are more observations than unique values.
Why? Ordinal means discrete or countable and
I just assume that an or... | [
"Checks",
"if",
"a",
"list",
"or",
"array",
"contains",
"ordinal",
"data",
"."
] | train | https://github.com/ulf1/oxyba/blob/b3043116050de275124365cb11e7df91fb40169d/oxyba/isordinal.py#L2-L49 |
rbarrois/confutils | confutils/merged_config.py | MergedConfig.get | def get(self, key, default=NoDefault):
"""Retrieve a value from its key.
Retrieval steps are:
1) Normalize the key
2) For each option group:
a) Retrieve the value at that key
b) If no value exists, continue
c) If the value is an instance of 'Default', co... | python | def get(self, key, default=NoDefault):
"""Retrieve a value from its key.
Retrieval steps are:
1) Normalize the key
2) For each option group:
a) Retrieve the value at that key
b) If no value exists, continue
c) If the value is an instance of 'Default', co... | [
"def",
"get",
"(",
"self",
",",
"key",
",",
"default",
"=",
"NoDefault",
")",
":",
"key",
"=",
"normalize_key",
"(",
"key",
")",
"if",
"default",
"is",
"NoDefault",
":",
"defaults",
"=",
"[",
"]",
"else",
":",
"defaults",
"=",
"[",
"default",
"]",
... | Retrieve a value from its key.
Retrieval steps are:
1) Normalize the key
2) For each option group:
a) Retrieve the value at that key
b) If no value exists, continue
c) If the value is an instance of 'Default', continue
d) Otherwise, return the value
... | [
"Retrieve",
"a",
"value",
"from",
"its",
"key",
"."
] | train | https://github.com/rbarrois/confutils/blob/26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4/confutils/merged_config.py#L92-L126 |
Valuehorizon/valuehorizon-companies | companies/models.py | Company.get_all_children | def get_all_children(self, include_self=False):
"""
Return all subsidiaries of this company.
"""
ownership = Ownership.objects.filter(parent=self)
subsidiaries = Company.objects.filter(child__in=ownership)
for sub in subsidiaries:
subsidiaries = subsidiaries |... | python | def get_all_children(self, include_self=False):
"""
Return all subsidiaries of this company.
"""
ownership = Ownership.objects.filter(parent=self)
subsidiaries = Company.objects.filter(child__in=ownership)
for sub in subsidiaries:
subsidiaries = subsidiaries |... | [
"def",
"get_all_children",
"(",
"self",
",",
"include_self",
"=",
"False",
")",
":",
"ownership",
"=",
"Ownership",
".",
"objects",
".",
"filter",
"(",
"parent",
"=",
"self",
")",
"subsidiaries",
"=",
"Company",
".",
"objects",
".",
"filter",
"(",
"child__... | Return all subsidiaries of this company. | [
"Return",
"all",
"subsidiaries",
"of",
"this",
"company",
"."
] | train | https://github.com/Valuehorizon/valuehorizon-companies/blob/5366e230da69ee30fcdc1bf4beddc99310f6b767/companies/models.py#L190-L203 |
Valuehorizon/valuehorizon-companies | companies/models.py | Company.get_all_parents | def get_all_parents(self):
"""
Return all parents of this company.
"""
ownership = Ownership.objects.filter(child=self)
parents = Company.objects.filter(parent__in=ownership)
for parent in parents:
parents = parents | parent.get_all_parents()
return pa... | python | def get_all_parents(self):
"""
Return all parents of this company.
"""
ownership = Ownership.objects.filter(child=self)
parents = Company.objects.filter(parent__in=ownership)
for parent in parents:
parents = parents | parent.get_all_parents()
return pa... | [
"def",
"get_all_parents",
"(",
"self",
")",
":",
"ownership",
"=",
"Ownership",
".",
"objects",
".",
"filter",
"(",
"child",
"=",
"self",
")",
"parents",
"=",
"Company",
".",
"objects",
".",
"filter",
"(",
"parent__in",
"=",
"ownership",
")",
"for",
"par... | Return all parents of this company. | [
"Return",
"all",
"parents",
"of",
"this",
"company",
"."
] | train | https://github.com/Valuehorizon/valuehorizon-companies/blob/5366e230da69ee30fcdc1bf4beddc99310f6b767/companies/models.py#L205-L213 |
Valuehorizon/valuehorizon-companies | companies/models.py | Company.get_all_related_companies | def get_all_related_companies(self, include_self=False):
"""
Return all parents and subsidiaries of the company
Include the company if include_self = True
"""
parents = self.get_all_parents()
subsidiaries = self.get_all_children()
related_companies = parents | sub... | python | def get_all_related_companies(self, include_self=False):
"""
Return all parents and subsidiaries of the company
Include the company if include_self = True
"""
parents = self.get_all_parents()
subsidiaries = self.get_all_children()
related_companies = parents | sub... | [
"def",
"get_all_related_companies",
"(",
"self",
",",
"include_self",
"=",
"False",
")",
":",
"parents",
"=",
"self",
".",
"get_all_parents",
"(",
")",
"subsidiaries",
"=",
"self",
".",
"get_all_children",
"(",
")",
"related_companies",
"=",
"parents",
"|",
"s... | Return all parents and subsidiaries of the company
Include the company if include_self = True | [
"Return",
"all",
"parents",
"and",
"subsidiaries",
"of",
"the",
"company",
"Include",
"the",
"company",
"if",
"include_self",
"=",
"True"
] | train | https://github.com/Valuehorizon/valuehorizon-companies/blob/5366e230da69ee30fcdc1bf4beddc99310f6b767/companies/models.py#L215-L231 |
Valuehorizon/valuehorizon-companies | companies/models.py | Company.get_immediate_children | def get_immediate_children(self):
"""
Return all direct subsidiaries of this company.
Excludes subsidiaries of subsidiaries
"""
ownership = Ownership.objects.filter(parent=self)
subsidiaries = Company.objects.filter(child__in=ownership).distinct()
return subsidiar... | python | def get_immediate_children(self):
"""
Return all direct subsidiaries of this company.
Excludes subsidiaries of subsidiaries
"""
ownership = Ownership.objects.filter(parent=self)
subsidiaries = Company.objects.filter(child__in=ownership).distinct()
return subsidiar... | [
"def",
"get_immediate_children",
"(",
"self",
")",
":",
"ownership",
"=",
"Ownership",
".",
"objects",
".",
"filter",
"(",
"parent",
"=",
"self",
")",
"subsidiaries",
"=",
"Company",
".",
"objects",
".",
"filter",
"(",
"child__in",
"=",
"ownership",
")",
"... | Return all direct subsidiaries of this company.
Excludes subsidiaries of subsidiaries | [
"Return",
"all",
"direct",
"subsidiaries",
"of",
"this",
"company",
".",
"Excludes",
"subsidiaries",
"of",
"subsidiaries"
] | train | https://github.com/Valuehorizon/valuehorizon-companies/blob/5366e230da69ee30fcdc1bf4beddc99310f6b767/companies/models.py#L233-L240 |
Valuehorizon/valuehorizon-companies | companies/models.py | Company.get_immediate_children_ownership | def get_immediate_children_ownership(self):
"""
Return all direct subsidiaries of this company AS OWNERSHIP OBJECTS.
Excludes subsidiaries of subsidiaries.
"""
ownership = Ownership.objects.filter(parent=self).select_related('child', 'child__country')
return ownership | python | def get_immediate_children_ownership(self):
"""
Return all direct subsidiaries of this company AS OWNERSHIP OBJECTS.
Excludes subsidiaries of subsidiaries.
"""
ownership = Ownership.objects.filter(parent=self).select_related('child', 'child__country')
return ownership | [
"def",
"get_immediate_children_ownership",
"(",
"self",
")",
":",
"ownership",
"=",
"Ownership",
".",
"objects",
".",
"filter",
"(",
"parent",
"=",
"self",
")",
".",
"select_related",
"(",
"'child'",
",",
"'child__country'",
")",
"return",
"ownership"
] | Return all direct subsidiaries of this company AS OWNERSHIP OBJECTS.
Excludes subsidiaries of subsidiaries. | [
"Return",
"all",
"direct",
"subsidiaries",
"of",
"this",
"company",
"AS",
"OWNERSHIP",
"OBJECTS",
".",
"Excludes",
"subsidiaries",
"of",
"subsidiaries",
"."
] | train | https://github.com/Valuehorizon/valuehorizon-companies/blob/5366e230da69ee30fcdc1bf4beddc99310f6b767/companies/models.py#L242-L249 |
Valuehorizon/valuehorizon-companies | companies/models.py | Company.get_immediate_parents | def get_immediate_parents(self):
"""
Return all direct parents of this company. Excludes parents of parents
"""
ownership = Ownership.objects.filter(child=self)
parents = Company.objects.filter(parent__in=ownership).distinct()
return parents | python | def get_immediate_parents(self):
"""
Return all direct parents of this company. Excludes parents of parents
"""
ownership = Ownership.objects.filter(child=self)
parents = Company.objects.filter(parent__in=ownership).distinct()
return parents | [
"def",
"get_immediate_parents",
"(",
"self",
")",
":",
"ownership",
"=",
"Ownership",
".",
"objects",
".",
"filter",
"(",
"child",
"=",
"self",
")",
"parents",
"=",
"Company",
".",
"objects",
".",
"filter",
"(",
"parent__in",
"=",
"ownership",
")",
".",
... | Return all direct parents of this company. Excludes parents of parents | [
"Return",
"all",
"direct",
"parents",
"of",
"this",
"company",
".",
"Excludes",
"parents",
"of",
"parents"
] | train | https://github.com/Valuehorizon/valuehorizon-companies/blob/5366e230da69ee30fcdc1bf4beddc99310f6b767/companies/models.py#L251-L257 |
Valuehorizon/valuehorizon-companies | companies/models.py | Company.get_directors | def get_directors(self):
"""
Return all directors for this company
"""
directors = Director.objects.filter(company=self, is_current=True).select_related('person')
return directors | python | def get_directors(self):
"""
Return all directors for this company
"""
directors = Director.objects.filter(company=self, is_current=True).select_related('person')
return directors | [
"def",
"get_directors",
"(",
"self",
")",
":",
"directors",
"=",
"Director",
".",
"objects",
".",
"filter",
"(",
"company",
"=",
"self",
",",
"is_current",
"=",
"True",
")",
".",
"select_related",
"(",
"'person'",
")",
"return",
"directors"
] | Return all directors for this company | [
"Return",
"all",
"directors",
"for",
"this",
"company"
] | train | https://github.com/Valuehorizon/valuehorizon-companies/blob/5366e230da69ee30fcdc1bf4beddc99310f6b767/companies/models.py#L259-L264 |
Valuehorizon/valuehorizon-companies | companies/models.py | Company.cache_data | def cache_data(self):
"""
Cache some basic data such as financial statement metrics
"""
# Set Slug if not set
if not self.slug_name:
self.slug_name = slugify(self.name).strip()
if len(self.slug_name) > 255:
self.slug_name = self.slug_name[0... | python | def cache_data(self):
"""
Cache some basic data such as financial statement metrics
"""
# Set Slug if not set
if not self.slug_name:
self.slug_name = slugify(self.name).strip()
if len(self.slug_name) > 255:
self.slug_name = self.slug_name[0... | [
"def",
"cache_data",
"(",
"self",
")",
":",
"# Set Slug if not set",
"if",
"not",
"self",
".",
"slug_name",
":",
"self",
".",
"slug_name",
"=",
"slugify",
"(",
"self",
".",
"name",
")",
".",
"strip",
"(",
")",
"if",
"len",
"(",
"self",
".",
"slug_name"... | Cache some basic data such as financial statement metrics | [
"Cache",
"some",
"basic",
"data",
"such",
"as",
"financial",
"statement",
"metrics"
] | train | https://github.com/Valuehorizon/valuehorizon-companies/blob/5366e230da69ee30fcdc1bf4beddc99310f6b767/companies/models.py#L266-L274 |
Valuehorizon/valuehorizon-companies | companies/models.py | Company.get_name_on_date | def get_name_on_date(self, date):
"""
Get the name of a company on a given date. This takes into accounts and
name changes that may have occurred.
"""
if date is None:
return self.name
post_name_changes = CompanyNameChange.objects.filter(company=self,
... | python | def get_name_on_date(self, date):
"""
Get the name of a company on a given date. This takes into accounts and
name changes that may have occurred.
"""
if date is None:
return self.name
post_name_changes = CompanyNameChange.objects.filter(company=self,
... | [
"def",
"get_name_on_date",
"(",
"self",
",",
"date",
")",
":",
"if",
"date",
"is",
"None",
":",
"return",
"self",
".",
"name",
"post_name_changes",
"=",
"CompanyNameChange",
".",
"objects",
".",
"filter",
"(",
"company",
"=",
"self",
",",
"date__gte",
"=",... | Get the name of a company on a given date. This takes into accounts and
name changes that may have occurred. | [
"Get",
"the",
"name",
"of",
"a",
"company",
"on",
"a",
"given",
"date",
".",
"This",
"takes",
"into",
"accounts",
"and",
"name",
"changes",
"that",
"may",
"have",
"occurred",
"."
] | train | https://github.com/Valuehorizon/valuehorizon-companies/blob/5366e230da69ee30fcdc1bf4beddc99310f6b767/companies/models.py#L276-L289 |
Valuehorizon/valuehorizon-companies | companies/models.py | Company.save | def save(self, *args, **kwargs):
"""
This method autogenerates the auto_generated_description field
"""
# Cache basic data
self.cache_data()
# Ensure slug doesn't change
if self.id is not None:
db_company = Company.objects.get(id=self.id)
... | python | def save(self, *args, **kwargs):
"""
This method autogenerates the auto_generated_description field
"""
# Cache basic data
self.cache_data()
# Ensure slug doesn't change
if self.id is not None:
db_company = Company.objects.get(id=self.id)
... | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Cache basic data",
"self",
".",
"cache_data",
"(",
")",
"# Ensure slug doesn't change",
"if",
"self",
".",
"id",
"is",
"not",
"None",
":",
"db_company",
"=",
"Company",
"... | This method autogenerates the auto_generated_description field | [
"This",
"method",
"autogenerates",
"the",
"auto_generated_description",
"field"
] | train | https://github.com/Valuehorizon/valuehorizon-companies/blob/5366e230da69ee30fcdc1bf4beddc99310f6b767/companies/models.py#L291-L324 |
Valuehorizon/valuehorizon-companies | companies/models.py | Ownership.save | def save(self, *args, **kwargs):
"""
Generate a name, and ensure amount is less than or equal to 100
"""
self.name = str(self.parent.name) + " - " + str(self.child.name) + " - " + str(self.ownership_type)
if self.amount > 100:
raise ValueError("Ownership amoun... | python | def save(self, *args, **kwargs):
"""
Generate a name, and ensure amount is less than or equal to 100
"""
self.name = str(self.parent.name) + " - " + str(self.child.name) + " - " + str(self.ownership_type)
if self.amount > 100:
raise ValueError("Ownership amoun... | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"name",
"=",
"str",
"(",
"self",
".",
"parent",
".",
"name",
")",
"+",
"\" - \"",
"+",
"str",
"(",
"self",
".",
"child",
".",
"name",
")",
"+",
... | Generate a name, and ensure amount is less than or equal to 100 | [
"Generate",
"a",
"name",
"and",
"ensure",
"amount",
"is",
"less",
"than",
"or",
"equal",
"to",
"100"
] | train | https://github.com/Valuehorizon/valuehorizon-companies/blob/5366e230da69ee30fcdc1bf4beddc99310f6b767/companies/models.py#L386-L398 |
Valuehorizon/valuehorizon-companies | companies/models.py | Director.tenure | def tenure(self):
"""
Calculates board tenure in years
"""
if self.end_date:
return round((date.end_date - self.start_date).days / 365., 2)
else:
return round((date.today() - self.start_date).days / 365., 2) | python | def tenure(self):
"""
Calculates board tenure in years
"""
if self.end_date:
return round((date.end_date - self.start_date).days / 365., 2)
else:
return round((date.today() - self.start_date).days / 365., 2) | [
"def",
"tenure",
"(",
"self",
")",
":",
"if",
"self",
".",
"end_date",
":",
"return",
"round",
"(",
"(",
"date",
".",
"end_date",
"-",
"self",
".",
"start_date",
")",
".",
"days",
"/",
"365.",
",",
"2",
")",
"else",
":",
"return",
"round",
"(",
"... | Calculates board tenure in years | [
"Calculates",
"board",
"tenure",
"in",
"years"
] | train | https://github.com/Valuehorizon/valuehorizon-companies/blob/5366e230da69ee30fcdc1bf4beddc99310f6b767/companies/models.py#L423-L430 |
Valuehorizon/valuehorizon-companies | companies/models.py | Director.save | def save(self, *args, **kwargs):
"""
Save the person model so it updates his/her number of board connections field.
Also updates name
"""
self.name = str(self.company.name) + " --- " + str(self.person)
super(Director, self).save(*args, **kwargs) # Call the "real" sa... | python | def save(self, *args, **kwargs):
"""
Save the person model so it updates his/her number of board connections field.
Also updates name
"""
self.name = str(self.company.name) + " --- " + str(self.person)
super(Director, self).save(*args, **kwargs) # Call the "real" sa... | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"name",
"=",
"str",
"(",
"self",
".",
"company",
".",
"name",
")",
"+",
"\" --- \"",
"+",
"str",
"(",
"self",
".",
"person",
")",
"super",
"(",
"D... | Save the person model so it updates his/her number of board connections field.
Also updates name | [
"Save",
"the",
"person",
"model",
"so",
"it",
"updates",
"his",
"/",
"her",
"number",
"of",
"board",
"connections",
"field",
".",
"Also",
"updates",
"name"
] | train | https://github.com/Valuehorizon/valuehorizon-companies/blob/5366e230da69ee30fcdc1bf4beddc99310f6b767/companies/models.py#L432-L442 |
Valuehorizon/valuehorizon-companies | companies/models.py | Executive.save | def save(self, *args, **kwargs):
"""
Updates name
"""
self.name = str(self.company.name) + " --- " + str(self.person)
super(Executive, self).save(*args, **kwargs) | python | def save(self, *args, **kwargs):
"""
Updates name
"""
self.name = str(self.company.name) + " --- " + str(self.person)
super(Executive, self).save(*args, **kwargs) | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"name",
"=",
"str",
"(",
"self",
".",
"company",
".",
"name",
")",
"+",
"\" --- \"",
"+",
"str",
"(",
"self",
".",
"person",
")",
"super",
"(",
"E... | Updates name | [
"Updates",
"name"
] | train | https://github.com/Valuehorizon/valuehorizon-companies/blob/5366e230da69ee30fcdc1bf4beddc99310f6b767/companies/models.py#L466-L472 |
KelSolaar/Oncilla | oncilla/build_toc_tree.py | build_toc_tree | def build_toc_tree(title, input, output, content_directory):
"""
Builds Sphinx documentation table of content tree file.
:param title: Package title.
:type title: unicode
:param input: Input file to convert.
:type input: unicode
:param output: Output file.
:type output: unicode
:par... | python | def build_toc_tree(title, input, output, content_directory):
"""
Builds Sphinx documentation table of content tree file.
:param title: Package title.
:type title: unicode
:param input: Input file to convert.
:type input: unicode
:param output: Output file.
:type output: unicode
:par... | [
"def",
"build_toc_tree",
"(",
"title",
",",
"input",
",",
"output",
",",
"content_directory",
")",
":",
"LOGGER",
".",
"info",
"(",
"\"{0} | Building Sphinx documentation index '{1}' file!\"",
".",
"format",
"(",
"build_toc_tree",
".",
"__name__",
",",
"output",
")"... | Builds Sphinx documentation table of content tree file.
:param title: Package title.
:type title: unicode
:param input: Input file to convert.
:type input: unicode
:param output: Output file.
:type output: unicode
:param content_directory: Directory containing the content to be included in ... | [
"Builds",
"Sphinx",
"documentation",
"table",
"of",
"content",
"tree",
"file",
"."
] | train | https://github.com/KelSolaar/Oncilla/blob/2b4db3704cf2c22a09a207681cb041fff555a994/oncilla/build_toc_tree.py#L73-L124 |
KelSolaar/Oncilla | oncilla/build_toc_tree.py | get_command_line_arguments | def get_command_line_arguments():
"""
Retrieves command line arguments.
:return: Namespace.
:rtype: Namespace
"""
parser = argparse.ArgumentParser(add_help=False)
parser.add_argument("-h",
"--help",
action="help",
hel... | python | def get_command_line_arguments():
"""
Retrieves command line arguments.
:return: Namespace.
:rtype: Namespace
"""
parser = argparse.ArgumentParser(add_help=False)
parser.add_argument("-h",
"--help",
action="help",
hel... | [
"def",
"get_command_line_arguments",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"add_help",
"=",
"False",
")",
"parser",
".",
"add_argument",
"(",
"\"-h\"",
",",
"\"--help\"",
",",
"action",
"=",
"\"help\"",
",",
"help",
"=",
"\"'D... | Retrieves command line arguments.
:return: Namespace.
:rtype: Namespace | [
"Retrieves",
"command",
"line",
"arguments",
"."
] | train | https://github.com/KelSolaar/Oncilla/blob/2b4db3704cf2c22a09a207681cb041fff555a994/oncilla/build_toc_tree.py#L127-L170 |
KelSolaar/Oncilla | oncilla/build_toc_tree.py | main | def main():
"""
Starts the Application.
:return: Definition success.
:rtype: bool
"""
args = get_command_line_arguments()
return build_toc_tree(args.title,
args.input,
args.output,
args.content_directory) | python | def main():
"""
Starts the Application.
:return: Definition success.
:rtype: bool
"""
args = get_command_line_arguments()
return build_toc_tree(args.title,
args.input,
args.output,
args.content_directory) | [
"def",
"main",
"(",
")",
":",
"args",
"=",
"get_command_line_arguments",
"(",
")",
"return",
"build_toc_tree",
"(",
"args",
".",
"title",
",",
"args",
".",
"input",
",",
"args",
".",
"output",
",",
"args",
".",
"content_directory",
")"
] | Starts the Application.
:return: Definition success.
:rtype: bool | [
"Starts",
"the",
"Application",
"."
] | train | https://github.com/KelSolaar/Oncilla/blob/2b4db3704cf2c22a09a207681cb041fff555a994/oncilla/build_toc_tree.py#L174-L186 |
jmgilman/Neolib | neolib/neocodex/blowfish.py | Blowfish.cipher | def cipher (self, xl, xr, direction):
"""Encryption primitive"""
if direction == self.ENCRYPT:
for i in range (16):
xl = xl ^ self.p_boxes[i]
xr = self.__round_func (xl) ^ xr
xl, xr = xr, xl
xl, xr = xr, xl
xr = xr ^ sel... | python | def cipher (self, xl, xr, direction):
"""Encryption primitive"""
if direction == self.ENCRYPT:
for i in range (16):
xl = xl ^ self.p_boxes[i]
xr = self.__round_func (xl) ^ xr
xl, xr = xr, xl
xl, xr = xr, xl
xr = xr ^ sel... | [
"def",
"cipher",
"(",
"self",
",",
"xl",
",",
"xr",
",",
"direction",
")",
":",
"if",
"direction",
"==",
"self",
".",
"ENCRYPT",
":",
"for",
"i",
"in",
"range",
"(",
"16",
")",
":",
"xl",
"=",
"xl",
"^",
"self",
".",
"p_boxes",
"[",
"i",
"]",
... | Encryption primitive | [
"Encryption",
"primitive"
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/neocodex/blowfish.py#L427-L445 |
jmgilman/Neolib | neolib/neocodex/blowfish.py | Blowfish.initCTR | def initCTR(self, iv=0):
"""Initializes CTR mode of the cypher"""
assert struct.calcsize("Q") == self.blocksize()
self.ctr_iv = iv
self._calcCTRBUF() | python | def initCTR(self, iv=0):
"""Initializes CTR mode of the cypher"""
assert struct.calcsize("Q") == self.blocksize()
self.ctr_iv = iv
self._calcCTRBUF() | [
"def",
"initCTR",
"(",
"self",
",",
"iv",
"=",
"0",
")",
":",
"assert",
"struct",
".",
"calcsize",
"(",
"\"Q\"",
")",
"==",
"self",
".",
"blocksize",
"(",
")",
"self",
".",
"ctr_iv",
"=",
"iv",
"self",
".",
"_calcCTRBUF",
"(",
")"
] | Initializes CTR mode of the cypher | [
"Initializes",
"CTR",
"mode",
"of",
"the",
"cypher"
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/neocodex/blowfish.py#L496-L500 |
jmgilman/Neolib | neolib/neocodex/blowfish.py | Blowfish._calcCTRBUF | def _calcCTRBUF(self):
"""Calculates one block of CTR keystream"""
self.ctr_cks = self.encrypt(struct.pack("Q", self.ctr_iv)) # keystream block
self.ctr_iv += 1
self.ctr_pos = 0 | python | def _calcCTRBUF(self):
"""Calculates one block of CTR keystream"""
self.ctr_cks = self.encrypt(struct.pack("Q", self.ctr_iv)) # keystream block
self.ctr_iv += 1
self.ctr_pos = 0 | [
"def",
"_calcCTRBUF",
"(",
"self",
")",
":",
"self",
".",
"ctr_cks",
"=",
"self",
".",
"encrypt",
"(",
"struct",
".",
"pack",
"(",
"\"Q\"",
",",
"self",
".",
"ctr_iv",
")",
")",
"# keystream block",
"self",
".",
"ctr_iv",
"+=",
"1",
"self",
".",
"ctr... | Calculates one block of CTR keystream | [
"Calculates",
"one",
"block",
"of",
"CTR",
"keystream"
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/neocodex/blowfish.py#L503-L507 |
jmgilman/Neolib | neolib/neocodex/blowfish.py | Blowfish._nextCTRByte | def _nextCTRByte(self):
"""Returns one byte of CTR keystream"""
b = ord(self.ctr_cks[self.ctr_pos])
self.ctr_pos += 1
if self.ctr_pos >= len(self.ctr_cks):
self._calcCTRBUF()
return b | python | def _nextCTRByte(self):
"""Returns one byte of CTR keystream"""
b = ord(self.ctr_cks[self.ctr_pos])
self.ctr_pos += 1
if self.ctr_pos >= len(self.ctr_cks):
self._calcCTRBUF()
return b | [
"def",
"_nextCTRByte",
"(",
"self",
")",
":",
"b",
"=",
"ord",
"(",
"self",
".",
"ctr_cks",
"[",
"self",
".",
"ctr_pos",
"]",
")",
"self",
".",
"ctr_pos",
"+=",
"1",
"if",
"self",
".",
"ctr_pos",
">=",
"len",
"(",
"self",
".",
"ctr_cks",
")",
":"... | Returns one byte of CTR keystream | [
"Returns",
"one",
"byte",
"of",
"CTR",
"keystream"
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/neocodex/blowfish.py#L510-L516 |
jmgilman/Neolib | neolib/neocodex/blowfish.py | Blowfish.encryptCTR | def encryptCTR(self, data):
"""
Encrypts a buffer of data with CTR mode. Multiple successive buffers
(beinting to the same logical stream of buffers) can be encrypted
with this method one after the other without any intermediate work.
"""
if type(data) != types.StringType... | python | def encryptCTR(self, data):
"""
Encrypts a buffer of data with CTR mode. Multiple successive buffers
(beinting to the same logical stream of buffers) can be encrypted
with this method one after the other without any intermediate work.
"""
if type(data) != types.StringType... | [
"def",
"encryptCTR",
"(",
"self",
",",
"data",
")",
":",
"if",
"type",
"(",
"data",
")",
"!=",
"types",
".",
"StringType",
":",
"raise",
"RuntimeException",
"(",
"\"Can only work on 8-bit strings\"",
")",
"result",
"=",
"[",
"]",
"for",
"ch",
"in",
"data",... | Encrypts a buffer of data with CTR mode. Multiple successive buffers
(beinting to the same logical stream of buffers) can be encrypted
with this method one after the other without any intermediate work. | [
"Encrypts",
"a",
"buffer",
"of",
"data",
"with",
"CTR",
"mode",
".",
"Multiple",
"successive",
"buffers",
"(",
"beinting",
"to",
"the",
"same",
"logical",
"stream",
"of",
"buffers",
")",
"can",
"be",
"encrypted",
"with",
"this",
"method",
"one",
"after",
"... | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/neocodex/blowfish.py#L519-L530 |
jeff-regier/authortoolkit | authortoolkit/disambiguate.py | coauthor_likelihoods | def coauthor_likelihoods(p1, p2):
"""returns the likelihoods of observing the actual number coauthors shared
by c{p1} and c{p2}, conditioned on whether or not p1 and p2 are a match
"""
def get_coauthors(p):
ret = set()
for m in p.mentions:
for co_m in article_to_mentions[m.a... | python | def coauthor_likelihoods(p1, p2):
"""returns the likelihoods of observing the actual number coauthors shared
by c{p1} and c{p2}, conditioned on whether or not p1 and p2 are a match
"""
def get_coauthors(p):
ret = set()
for m in p.mentions:
for co_m in article_to_mentions[m.a... | [
"def",
"coauthor_likelihoods",
"(",
"p1",
",",
"p2",
")",
":",
"def",
"get_coauthors",
"(",
"p",
")",
":",
"ret",
"=",
"set",
"(",
")",
"for",
"m",
"in",
"p",
".",
"mentions",
":",
"for",
"co_m",
"in",
"article_to_mentions",
"[",
"m",
".",
"article_i... | returns the likelihoods of observing the actual number coauthors shared
by c{p1} and c{p2}, conditioned on whether or not p1 and p2 are a match | [
"returns",
"the",
"likelihoods",
"of",
"observing",
"the",
"actual",
"number",
"coauthors",
"shared",
"by",
"c",
"{",
"p1",
"}",
"and",
"c",
"{",
"p2",
"}",
"conditioned",
"on",
"whether",
"or",
"not",
"p1",
"and",
"p2",
"are",
"a",
"match"
] | train | https://github.com/jeff-regier/authortoolkit/blob/b119a953d46b2e23ad346927a0fb5c5047f28b9b/authortoolkit/disambiguate.py#L78-L100 |
jmgilman/Neolib | neolib/item/Item.py | Item.populate | def populate(self, usr = None, itemID = None):
""" Attempts to populate an item's information with it's ID, returns result
Note that the item id must already be set or otherwise supplied and that the item
must exist in the associated user's inventory.
Parameters:
... | python | def populate(self, usr = None, itemID = None):
""" Attempts to populate an item's information with it's ID, returns result
Note that the item id must already be set or otherwise supplied and that the item
must exist in the associated user's inventory.
Parameters:
... | [
"def",
"populate",
"(",
"self",
",",
"usr",
"=",
"None",
",",
"itemID",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"id",
"and",
"not",
"itemID",
":",
"return",
"False",
"if",
"not",
"self",
".",
"usr",
"and",
"not",
"user",
":",
"return",
"... | Attempts to populate an item's information with it's ID, returns result
Note that the item id must already be set or otherwise supplied and that the item
must exist in the associated user's inventory.
Parameters:
usr (User) -- User who has the item
ite... | [
"Attempts",
"to",
"populate",
"an",
"item",
"s",
"information",
"with",
"it",
"s",
"ID",
"returns",
"result",
"Note",
"that",
"the",
"item",
"id",
"must",
"already",
"be",
"set",
"or",
"otherwise",
"supplied",
"and",
"that",
"the",
"item",
"must",
"exist",... | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/item/Item.py#L83-L133 |
jmgilman/Neolib | neolib/item/Item.py | Item.sendTo | def sendTo(self, loc, usr=None):
""" Transfer's an item from user's inventory to another inventory, returns result
Parameters:
loc (str) -- Location to send the item to (see Item.SHOP, Item.SDB, etc.)
usr (User) -- User who has the item
Returns
... | python | def sendTo(self, loc, usr=None):
""" Transfer's an item from user's inventory to another inventory, returns result
Parameters:
loc (str) -- Location to send the item to (see Item.SHOP, Item.SDB, etc.)
usr (User) -- User who has the item
Returns
... | [
"def",
"sendTo",
"(",
"self",
",",
"loc",
",",
"usr",
"=",
"None",
")",
":",
"if",
"not",
"loc",
"in",
"self",
".",
"_messages",
":",
"return",
"False",
"if",
"not",
"self",
".",
"usr",
"and",
"not",
"usr",
":",
"return",
"False",
"if",
"self",
"... | Transfer's an item from user's inventory to another inventory, returns result
Parameters:
loc (str) -- Location to send the item to (see Item.SHOP, Item.SDB, etc.)
usr (User) -- User who has the item
Returns
bool - True if successful, false otherw... | [
"Transfer",
"s",
"an",
"item",
"from",
"user",
"s",
"inventory",
"to",
"another",
"inventory",
"returns",
"result",
"Parameters",
":",
"loc",
"(",
"str",
")",
"--",
"Location",
"to",
"send",
"the",
"item",
"to",
"(",
"see",
"Item",
".",
"SHOP",
"Item",
... | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/item/Item.py#L135-L158 |
wooyek/django-powerbank | src/django_powerbank/forms/widgets.py | SelectizeSelect.optgroups | def optgroups(self, name, value, attrs=None):
"""Return a list of optgroups for this widget."""
default = (None, [], 0)
groups = [default]
# We must add at least one 'selected' option or widget will show nothing.
for v in value:
if not v:
continue
... | python | def optgroups(self, name, value, attrs=None):
"""Return a list of optgroups for this widget."""
default = (None, [], 0)
groups = [default]
# We must add at least one 'selected' option or widget will show nothing.
for v in value:
if not v:
continue
... | [
"def",
"optgroups",
"(",
"self",
",",
"name",
",",
"value",
",",
"attrs",
"=",
"None",
")",
":",
"default",
"=",
"(",
"None",
",",
"[",
"]",
",",
"0",
")",
"groups",
"=",
"[",
"default",
"]",
"# We must add at least one 'selected' option or widget will show ... | Return a list of optgroups for this widget. | [
"Return",
"a",
"list",
"of",
"optgroups",
"for",
"this",
"widget",
"."
] | train | https://github.com/wooyek/django-powerbank/blob/df91189f2ac18bacc545ccf3c81c4465fb993949/src/django_powerbank/forms/widgets.py#L66-L87 |
defensio/defensio-python | defensio/__init__.py | Defensio.post_document | def post_document(self, data):
"""
Create and analyze a new document
data -- A Dictionary representing the new document
"""
data.update({ 'client' : CLIENT })
return self._call('POST', self._generate_url_path('documents'), data) | python | def post_document(self, data):
"""
Create and analyze a new document
data -- A Dictionary representing the new document
"""
data.update({ 'client' : CLIENT })
return self._call('POST', self._generate_url_path('documents'), data) | [
"def",
"post_document",
"(",
"self",
",",
"data",
")",
":",
"data",
".",
"update",
"(",
"{",
"'client'",
":",
"CLIENT",
"}",
")",
"return",
"self",
".",
"_call",
"(",
"'POST'",
",",
"self",
".",
"_generate_url_path",
"(",
"'documents'",
")",
",",
"data... | Create and analyze a new document
data -- A Dictionary representing the new document | [
"Create",
"and",
"analyze",
"a",
"new",
"document",
"data",
"--",
"A",
"Dictionary",
"representing",
"the",
"new",
"document"
] | train | https://github.com/defensio/defensio-python/blob/c1d2b64be941acb63c452a6d9a5526c59cb37007/defensio/__init__.py#L38-L44 |
defensio/defensio-python | defensio/__init__.py | Defensio.put_document | def put_document(self, signature, data):
"""
Modify the properties of an existing document
signature -- The signature for the desired document
data -- A Dictionary with the new allowed value eg. {'allow': false}
"""
return self._call('PUT', self._generate_url_path('documents', signature), ... | python | def put_document(self, signature, data):
"""
Modify the properties of an existing document
signature -- The signature for the desired document
data -- A Dictionary with the new allowed value eg. {'allow': false}
"""
return self._call('PUT', self._generate_url_path('documents', signature), ... | [
"def",
"put_document",
"(",
"self",
",",
"signature",
",",
"data",
")",
":",
"return",
"self",
".",
"_call",
"(",
"'PUT'",
",",
"self",
".",
"_generate_url_path",
"(",
"'documents'",
",",
"signature",
")",
",",
"data",
")"
] | Modify the properties of an existing document
signature -- The signature for the desired document
data -- A Dictionary with the new allowed value eg. {'allow': false} | [
"Modify",
"the",
"properties",
"of",
"an",
"existing",
"document",
"signature",
"--",
"The",
"signature",
"for",
"the",
"desired",
"document",
"data",
"--",
"A",
"Dictionary",
"with",
"the",
"new",
"allowed",
"value",
"eg",
".",
"{",
"allow",
":",
"false",
... | train | https://github.com/defensio/defensio-python/blob/c1d2b64be941acb63c452a6d9a5526c59cb37007/defensio/__init__.py#L53-L59 |
defensio/defensio-python | defensio/__init__.py | Defensio.get_extended_stats | def get_extended_stats(self, data):
"""
Get more exhaustive statistics for the current user
data -- A dictionary with the range of dates you want the stats for {'from': '2010/01/01', 'to': '2010/01/10'}
"""
return self._call('GET', self._generate_url_path('extended-stats') + '?' + self._urlencode(d... | python | def get_extended_stats(self, data):
"""
Get more exhaustive statistics for the current user
data -- A dictionary with the range of dates you want the stats for {'from': '2010/01/01', 'to': '2010/01/10'}
"""
return self._call('GET', self._generate_url_path('extended-stats') + '?' + self._urlencode(d... | [
"def",
"get_extended_stats",
"(",
"self",
",",
"data",
")",
":",
"return",
"self",
".",
"_call",
"(",
"'GET'",
",",
"self",
".",
"_generate_url_path",
"(",
"'extended-stats'",
")",
"+",
"'?'",
"+",
"self",
".",
"_urlencode",
"(",
"data",
")",
")"
] | Get more exhaustive statistics for the current user
data -- A dictionary with the range of dates you want the stats for {'from': '2010/01/01', 'to': '2010/01/10'} | [
"Get",
"more",
"exhaustive",
"statistics",
"for",
"the",
"current",
"user",
"data",
"--",
"A",
"dictionary",
"with",
"the",
"range",
"of",
"dates",
"you",
"want",
"the",
"stats",
"for",
"{",
"from",
":",
"2010",
"/",
"01",
"/",
"01",
"to",
":",
"2010",... | train | https://github.com/defensio/defensio-python/blob/c1d2b64be941acb63c452a6d9a5526c59cb37007/defensio/__init__.py#L65-L70 |
defensio/defensio-python | defensio/__init__.py | Defensio._call | def _call(self, method, path, data=None):
""" Do the actual HTTP request """
if is_python3():
conn = http.client.HTTPConnection(API_HOST)
else:
conn = httplib.HTTPConnection(API_HOST)
headers = {'User-Agent' : USER_AGENT}
if data:
headers.update( {'Content-type': 'application/x-w... | python | def _call(self, method, path, data=None):
""" Do the actual HTTP request """
if is_python3():
conn = http.client.HTTPConnection(API_HOST)
else:
conn = httplib.HTTPConnection(API_HOST)
headers = {'User-Agent' : USER_AGENT}
if data:
headers.update( {'Content-type': 'application/x-w... | [
"def",
"_call",
"(",
"self",
",",
"method",
",",
"path",
",",
"data",
"=",
"None",
")",
":",
"if",
"is_python3",
"(",
")",
":",
"conn",
"=",
"http",
".",
"client",
".",
"HTTPConnection",
"(",
"API_HOST",
")",
"else",
":",
"conn",
"=",
"httplib",
".... | Do the actual HTTP request | [
"Do",
"the",
"actual",
"HTTP",
"request"
] | train | https://github.com/defensio/defensio-python/blob/c1d2b64be941acb63c452a6d9a5526c59cb37007/defensio/__init__.py#L86-L105 |
defensio/defensio-python | defensio/__init__.py | Defensio._parse_body | def _parse_body(self, body):
""" For just call a deserializer for FORMAT"""
if is_python3():
return json.loads(body.decode('UTF-8'))
else:
return json.loads(body) | python | def _parse_body(self, body):
""" For just call a deserializer for FORMAT"""
if is_python3():
return json.loads(body.decode('UTF-8'))
else:
return json.loads(body) | [
"def",
"_parse_body",
"(",
"self",
",",
"body",
")",
":",
"if",
"is_python3",
"(",
")",
":",
"return",
"json",
".",
"loads",
"(",
"body",
".",
"decode",
"(",
"'UTF-8'",
")",
")",
"else",
":",
"return",
"json",
".",
"loads",
"(",
"body",
")"
] | For just call a deserializer for FORMAT | [
"For",
"just",
"call",
"a",
"deserializer",
"for",
"FORMAT"
] | train | https://github.com/defensio/defensio-python/blob/c1d2b64be941acb63c452a6d9a5526c59cb37007/defensio/__init__.py#L114-L119 |
praekelt/jmbo-competition | competition/admin.py | CompetitionEntryAdmin.get_urls | def get_urls(self):
""" Extend the admin urls for the CompetitionEntryAdmin model
to be able to invoke a CSV export view on the admin model """
urls = super(CompetitionEntryAdmin, self).get_urls()
csv_urls = patterns('',
url(
r'^exportcsv/$',
... | python | def get_urls(self):
""" Extend the admin urls for the CompetitionEntryAdmin model
to be able to invoke a CSV export view on the admin model """
urls = super(CompetitionEntryAdmin, self).get_urls()
csv_urls = patterns('',
url(
r'^exportcsv/$',
... | [
"def",
"get_urls",
"(",
"self",
")",
":",
"urls",
"=",
"super",
"(",
"CompetitionEntryAdmin",
",",
"self",
")",
".",
"get_urls",
"(",
")",
"csv_urls",
"=",
"patterns",
"(",
"''",
",",
"url",
"(",
"r'^exportcsv/$'",
",",
"self",
".",
"admin_site",
".",
... | Extend the admin urls for the CompetitionEntryAdmin model
to be able to invoke a CSV export view on the admin model | [
"Extend",
"the",
"admin",
"urls",
"for",
"the",
"CompetitionEntryAdmin",
"model",
"to",
"be",
"able",
"to",
"invoke",
"a",
"CSV",
"export",
"view",
"on",
"the",
"admin",
"model"
] | train | https://github.com/praekelt/jmbo-competition/blob/7efdc6d2d57077229108e7eb2ae99f87c32210ee/competition/admin.py#L152-L163 |
praekelt/jmbo-competition | competition/admin.py | CompetitionEntryAdmin.csv_export | def csv_export(self, request):
""" Return a CSV document of the competition entry and its user
details
"""
response = HttpResponse(content_type='text/csv')
response['Content-Disposition'] = 'attachment; filename=competitionentries.csv'
# create the csv writer with th... | python | def csv_export(self, request):
""" Return a CSV document of the competition entry and its user
details
"""
response = HttpResponse(content_type='text/csv')
response['Content-Disposition'] = 'attachment; filename=competitionentries.csv'
# create the csv writer with th... | [
"def",
"csv_export",
"(",
"self",
",",
"request",
")",
":",
"response",
"=",
"HttpResponse",
"(",
"content_type",
"=",
"'text/csv'",
")",
"response",
"[",
"'Content-Disposition'",
"]",
"=",
"'attachment; filename=competitionentries.csv'",
"# create the csv writer with the... | Return a CSV document of the competition entry and its user
details | [
"Return",
"a",
"CSV",
"document",
"of",
"the",
"competition",
"entry",
"and",
"its",
"user",
"details"
] | train | https://github.com/praekelt/jmbo-competition/blob/7efdc6d2d57077229108e7eb2ae99f87c32210ee/competition/admin.py#L165-L235 |
klingtnet/sblgntparser | sblgntparser/tools.py | filelist | def filelist(folderpath, ext=None):
'''
Returns a list of all the files contained in the folder specified by `folderpath`.
To filter the files by extension simply add a list containing all the extension with `.` as the second argument.
If `flat` is False, then the Path objects are returned.
'''
... | python | def filelist(folderpath, ext=None):
'''
Returns a list of all the files contained in the folder specified by `folderpath`.
To filter the files by extension simply add a list containing all the extension with `.` as the second argument.
If `flat` is False, then the Path objects are returned.
'''
... | [
"def",
"filelist",
"(",
"folderpath",
",",
"ext",
"=",
"None",
")",
":",
"if",
"not",
"ext",
":",
"ext",
"=",
"[",
"]",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"folderpath",
")",
"and",
"os",
".",
"path",
".",
"isdir",
"(",
"folderpath",
")"... | Returns a list of all the files contained in the folder specified by `folderpath`.
To filter the files by extension simply add a list containing all the extension with `.` as the second argument.
If `flat` is False, then the Path objects are returned. | [
"Returns",
"a",
"list",
"of",
"all",
"the",
"files",
"contained",
"in",
"the",
"folder",
"specified",
"by",
"folderpath",
".",
"To",
"filter",
"the",
"files",
"by",
"extension",
"simply",
"add",
"a",
"list",
"containing",
"all",
"the",
"extension",
"with",
... | train | https://github.com/klingtnet/sblgntparser/blob/535931a833203e5d9065072ec988c575b493d67f/sblgntparser/tools.py#L10-L21 |
klingtnet/sblgntparser | sblgntparser/tools.py | particles | def particles(category=None):
'''
Returns a dict containing old greek particles grouped by category.
'''
filepath = os.path.join(os.path.dirname(__file__), './particles.json')
with open(filepath) as f:
try:
particles = json.load(f)
except ValueError as e:
log.... | python | def particles(category=None):
'''
Returns a dict containing old greek particles grouped by category.
'''
filepath = os.path.join(os.path.dirname(__file__), './particles.json')
with open(filepath) as f:
try:
particles = json.load(f)
except ValueError as e:
log.... | [
"def",
"particles",
"(",
"category",
"=",
"None",
")",
":",
"filepath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"'./particles.json'",
")",
"with",
"open",
"(",
"filepath",
")",
"as",
"f"... | Returns a dict containing old greek particles grouped by category. | [
"Returns",
"a",
"dict",
"containing",
"old",
"greek",
"particles",
"grouped",
"by",
"category",
"."
] | train | https://github.com/klingtnet/sblgntparser/blob/535931a833203e5d9065072ec988c575b493d67f/sblgntparser/tools.py#L23-L39 |
klingtnet/sblgntparser | sblgntparser/tools.py | parts | def parts():
'''
Returns the dictionary with the part as key and the contained book as indices.
'''
parts = {
'Canon': [ _ for _ in range(1, 5) ],
'Apostle': [ 5 ],
'Paul': [ _ for _ in range(6, 19) ],
'General': [ _ for _ in range(19, 26) ],
'Apocalypse': [ 27 ]... | python | def parts():
'''
Returns the dictionary with the part as key and the contained book as indices.
'''
parts = {
'Canon': [ _ for _ in range(1, 5) ],
'Apostle': [ 5 ],
'Paul': [ _ for _ in range(6, 19) ],
'General': [ _ for _ in range(19, 26) ],
'Apocalypse': [ 27 ]... | [
"def",
"parts",
"(",
")",
":",
"parts",
"=",
"{",
"'Canon'",
":",
"[",
"_",
"for",
"_",
"in",
"range",
"(",
"1",
",",
"5",
")",
"]",
",",
"'Apostle'",
":",
"[",
"5",
"]",
",",
"'Paul'",
":",
"[",
"_",
"for",
"_",
"in",
"range",
"(",
"6",
... | Returns the dictionary with the part as key and the contained book as indices. | [
"Returns",
"the",
"dictionary",
"with",
"the",
"part",
"as",
"key",
"and",
"the",
"contained",
"book",
"as",
"indices",
"."
] | train | https://github.com/klingtnet/sblgntparser/blob/535931a833203e5d9065072ec988c575b493d67f/sblgntparser/tools.py#L77-L88 |
cogniteev/docido-python-sdk | docido_sdk/env.py | Environment.component_activated | def component_activated(self, component):
"""Initialize additional member variables for components.
Every component activated through the `Environment` object
gets an additional member variable: `env` (the environment object)
"""
component.env = self
super(Environment, s... | python | def component_activated(self, component):
"""Initialize additional member variables for components.
Every component activated through the `Environment` object
gets an additional member variable: `env` (the environment object)
"""
component.env = self
super(Environment, s... | [
"def",
"component_activated",
"(",
"self",
",",
"component",
")",
":",
"component",
".",
"env",
"=",
"self",
"super",
"(",
"Environment",
",",
"self",
")",
".",
"component_activated",
"(",
"component",
")"
] | Initialize additional member variables for components.
Every component activated through the `Environment` object
gets an additional member variable: `env` (the environment object) | [
"Initialize",
"additional",
"member",
"variables",
"for",
"components",
"."
] | train | https://github.com/cogniteev/docido-python-sdk/blob/58ecb6c6f5757fd40c0601657ab18368da7ddf33/docido_sdk/env.py#L17-L24 |
openbermuda/ripl | ripl/show.py | SlideShow.interpret | def interpret(self, msg):
""" Create a slide show """
self.captions = msg.get('captions', '.')
for item in msg['slides']:
self.add(item) | python | def interpret(self, msg):
""" Create a slide show """
self.captions = msg.get('captions', '.')
for item in msg['slides']:
self.add(item) | [
"def",
"interpret",
"(",
"self",
",",
"msg",
")",
":",
"self",
".",
"captions",
"=",
"msg",
".",
"get",
"(",
"'captions'",
",",
"'.'",
")",
"for",
"item",
"in",
"msg",
"[",
"'slides'",
"]",
":",
"self",
".",
"add",
"(",
"item",
")"
] | Create a slide show | [
"Create",
"a",
"slide",
"show"
] | train | https://github.com/openbermuda/ripl/blob/4886b1a697e4b81c2202db9cb977609e034f8e70/ripl/show.py#L21-L27 |
openbermuda/ripl | ripl/show.py | SlideShow.set_duration | def set_duration(self, duration):
""" Calculate how long each slide should show """
fixed = sum(int(x.get('time', 0)) for x in self.slides)
nfixed = len([x for x in self.slides if x.get('time', 0) > 0])
unfixed = len(self.slides) - nfixed
self.wait = max(1, int(duration / unfi... | python | def set_duration(self, duration):
""" Calculate how long each slide should show """
fixed = sum(int(x.get('time', 0)) for x in self.slides)
nfixed = len([x for x in self.slides if x.get('time', 0) > 0])
unfixed = len(self.slides) - nfixed
self.wait = max(1, int(duration / unfi... | [
"def",
"set_duration",
"(",
"self",
",",
"duration",
")",
":",
"fixed",
"=",
"sum",
"(",
"int",
"(",
"x",
".",
"get",
"(",
"'time'",
",",
"0",
")",
")",
"for",
"x",
"in",
"self",
".",
"slides",
")",
"nfixed",
"=",
"len",
"(",
"[",
"x",
"for",
... | Calculate how long each slide should show | [
"Calculate",
"how",
"long",
"each",
"slide",
"should",
"show"
] | train | https://github.com/openbermuda/ripl/blob/4886b1a697e4b81c2202db9cb977609e034f8e70/ripl/show.py#L50-L58 |
openbermuda/ripl | ripl/show.py | SlideShow.run | def run(self):
""" Run the show """
self.show()
if not self.wait:
return
for image in self.slides:
wait = image.get('time', 0)
wait = max(self.wait, wait)
print('waiting %d seconds %s' % (
wait, image.get('image',... | python | def run(self):
""" Run the show """
self.show()
if not self.wait:
return
for image in self.slides:
wait = image.get('time', 0)
wait = max(self.wait, wait)
print('waiting %d seconds %s' % (
wait, image.get('image',... | [
"def",
"run",
"(",
"self",
")",
":",
"self",
".",
"show",
"(",
")",
"if",
"not",
"self",
".",
"wait",
":",
"return",
"for",
"image",
"in",
"self",
".",
"slides",
":",
"wait",
"=",
"image",
".",
"get",
"(",
"'time'",
",",
"0",
")",
"wait",
"=",
... | Run the show | [
"Run",
"the",
"show"
] | train | https://github.com/openbermuda/ripl/blob/4886b1a697e4b81c2202db9cb977609e034f8e70/ripl/show.py#L60-L75 |
pjuren/pyokit | src/pyokit/io/fastaIterators.py | num_sequences | def num_sequences(fileh):
"""
Determine how many sequences there are in fasta file/stream.
:param fileh: the stream to read the fasta data from, or a string giving
the filename of the file to load. Note that if a stream is
given, it will be consumed by this function
:r... | python | def num_sequences(fileh):
"""
Determine how many sequences there are in fasta file/stream.
:param fileh: the stream to read the fasta data from, or a string giving
the filename of the file to load. Note that if a stream is
given, it will be consumed by this function
:r... | [
"def",
"num_sequences",
"(",
"fileh",
")",
":",
"if",
"type",
"(",
"fileh",
")",
".",
"__name__",
"==",
"\"str\"",
":",
"fh",
"=",
"open",
"(",
"fileh",
")",
"else",
":",
"fh",
"=",
"fileh",
"count",
"=",
"0",
"for",
"_",
"in",
"fastaIterator",
"("... | Determine how many sequences there are in fasta file/stream.
:param fileh: the stream to read the fasta data from, or a string giving
the filename of the file to load. Note that if a stream is
given, it will be consumed by this function
:return: the number of sequences in th... | [
"Determine",
"how",
"many",
"sequences",
"there",
"are",
"in",
"fasta",
"file",
"/",
"stream",
"."
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/fastaIterators.py#L60-L76 |
pjuren/pyokit | src/pyokit/io/fastaIterators.py | __read_seq_header | def __read_seq_header(fh, prev_line):
"""
Given a file handle/stream, read the next fasta header from that stream.
:param fh: filehandle to read from
:param prev_line: the previous line read from this filestream
"""
seq_header = ""
if prev_line is not None and not _isSequenceHead(prev_line):
... | python | def __read_seq_header(fh, prev_line):
"""
Given a file handle/stream, read the next fasta header from that stream.
:param fh: filehandle to read from
:param prev_line: the previous line read from this filestream
"""
seq_header = ""
if prev_line is not None and not _isSequenceHead(prev_line):
... | [
"def",
"__read_seq_header",
"(",
"fh",
",",
"prev_line",
")",
":",
"seq_header",
"=",
"\"\"",
"if",
"prev_line",
"is",
"not",
"None",
"and",
"not",
"_isSequenceHead",
"(",
"prev_line",
")",
":",
"raise",
"FastaFileFormatError",
"(",
"\"terminated on non-read heade... | Given a file handle/stream, read the next fasta header from that stream.
:param fh: filehandle to read from
:param prev_line: the previous line read from this filestream | [
"Given",
"a",
"file",
"handle",
"/",
"stream",
"read",
"the",
"next",
"fasta",
"header",
"from",
"that",
"stream",
"."
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/fastaIterators.py#L103-L118 |
pjuren/pyokit | src/pyokit/io/fastaIterators.py | __read_seq_data | def __read_seq_data(fh):
"""
:return: a tuple of the sequence data and the last line that was read from
the file handle/stream
"""
line = None
seq_data = ""
while line is None or not _isSequenceHead(line):
line = fh.readline()
if line == "":
break # file is finished...
if not _... | python | def __read_seq_data(fh):
"""
:return: a tuple of the sequence data and the last line that was read from
the file handle/stream
"""
line = None
seq_data = ""
while line is None or not _isSequenceHead(line):
line = fh.readline()
if line == "":
break # file is finished...
if not _... | [
"def",
"__read_seq_data",
"(",
"fh",
")",
":",
"line",
"=",
"None",
"seq_data",
"=",
"\"\"",
"while",
"line",
"is",
"None",
"or",
"not",
"_isSequenceHead",
"(",
"line",
")",
":",
"line",
"=",
"fh",
".",
"readline",
"(",
")",
"if",
"line",
"==",
"\"\"... | :return: a tuple of the sequence data and the last line that was read from
the file handle/stream | [
":",
"return",
":",
"a",
"tuple",
"of",
"the",
"sequence",
"data",
"and",
"the",
"last",
"line",
"that",
"was",
"read",
"from",
"the",
"file",
"handle",
"/",
"stream"
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/fastaIterators.py#L121-L134 |
pjuren/pyokit | src/pyokit/io/fastaIterators.py | fastaIterator | def fastaIterator(fn, useMutableString=False, verbose=False):
"""
A generator function which yields fastaSequence objects from a fasta-format
file or stream.
:param fn: a file-like stream or a string; if this is a string, it's
treated as a filename, else it's treated it as a file-like
... | python | def fastaIterator(fn, useMutableString=False, verbose=False):
"""
A generator function which yields fastaSequence objects from a fasta-format
file or stream.
:param fn: a file-like stream or a string; if this is a string, it's
treated as a filename, else it's treated it as a file-like
... | [
"def",
"fastaIterator",
"(",
"fn",
",",
"useMutableString",
"=",
"False",
",",
"verbose",
"=",
"False",
")",
":",
"fh",
"=",
"fn",
"if",
"type",
"(",
"fh",
")",
".",
"__name__",
"==",
"\"str\"",
":",
"fh",
"=",
"open",
"(",
"fh",
")",
"if",
"verbos... | A generator function which yields fastaSequence objects from a fasta-format
file or stream.
:param fn: a file-like stream or a string; if this is a string, it's
treated as a filename, else it's treated it as a file-like
object, which must have a readline() method.
:param useMu... | [
"A",
"generator",
"function",
"which",
"yields",
"fastaSequence",
"objects",
"from",
"a",
"fasta",
"-",
"format",
"file",
"or",
"stream",
"."
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/fastaIterators.py#L148-L186 |
tylerbutler/propane | propane/django/fields.py | dbsafe_encode | def dbsafe_encode(value, compress_object=False):
"""
We use deepcopy() here to avoid a problem with cPickle, where dumps
can generate different character streams for same lookup value if
they are referenced differently.
The reason this is important is because we do all of our lookups as
simple ... | python | def dbsafe_encode(value, compress_object=False):
"""
We use deepcopy() here to avoid a problem with cPickle, where dumps
can generate different character streams for same lookup value if
they are referenced differently.
The reason this is important is because we do all of our lookups as
simple ... | [
"def",
"dbsafe_encode",
"(",
"value",
",",
"compress_object",
"=",
"False",
")",
":",
"if",
"not",
"compress_object",
":",
"value",
"=",
"b64encode",
"(",
"dumps",
"(",
"deepcopy",
"(",
"value",
")",
")",
")",
"else",
":",
"value",
"=",
"b64encode",
"(",... | We use deepcopy() here to avoid a problem with cPickle, where dumps
can generate different character streams for same lookup value if
they are referenced differently.
The reason this is important is because we do all of our lookups as
simple string matches, thus the character streams must be the same
... | [
"We",
"use",
"deepcopy",
"()",
"here",
"to",
"avoid",
"a",
"problem",
"with",
"cPickle",
"where",
"dumps",
"can",
"generate",
"different",
"character",
"streams",
"for",
"same",
"lookup",
"value",
"if",
"they",
"are",
"referenced",
"differently",
"."
] | train | https://github.com/tylerbutler/propane/blob/6c404285ab8d78865b7175a5c8adf8fae12d6be5/propane/django/fields.py#L42-L56 |
tylerbutler/propane | propane/django/fields.py | PickledObjectField.get_default | def get_default(self):
"""
Returns the default value for this field.
The default implementation on models.Field calls force_unicode
on the default, which means you can't set arbitrary Python
objects as the default. To fix this, we just return the value
without calling fo... | python | def get_default(self):
"""
Returns the default value for this field.
The default implementation on models.Field calls force_unicode
on the default, which means you can't set arbitrary Python
objects as the default. To fix this, we just return the value
without calling fo... | [
"def",
"get_default",
"(",
"self",
")",
":",
"if",
"self",
".",
"has_default",
"(",
")",
":",
"if",
"callable",
"(",
"self",
".",
"default",
")",
":",
"return",
"self",
".",
"default",
"(",
")",
"return",
"self",
".",
"default",
"# If the field doesn't h... | Returns the default value for this field.
The default implementation on models.Field calls force_unicode
on the default, which means you can't set arbitrary Python
objects as the default. To fix this, we just return the value
without calling force_unicode on it. Note that if you set a
... | [
"Returns",
"the",
"default",
"value",
"for",
"this",
"field",
"."
] | train | https://github.com/tylerbutler/propane/blob/6c404285ab8d78865b7175a5c8adf8fae12d6be5/propane/django/fields.py#L89-L106 |
tylerbutler/propane | propane/django/fields.py | PickledObjectField.to_python | def to_python(self, value):
"""
B64decode and unpickle the object, optionally decompressing it.
If an error is raised in de-pickling and we're sure the value is
a definite pickle, the error is allowed to propogate. If we
aren't sure if the value is a pickle or not, then we catch... | python | def to_python(self, value):
"""
B64decode and unpickle the object, optionally decompressing it.
If an error is raised in de-pickling and we're sure the value is
a definite pickle, the error is allowed to propogate. If we
aren't sure if the value is a pickle or not, then we catch... | [
"def",
"to_python",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"try",
":",
"value",
"=",
"dbsafe_decode",
"(",
"value",
",",
"self",
".",
"compress",
")",
"except",
":",
"# If the value is a definite pickle; and an error is r... | B64decode and unpickle the object, optionally decompressing it.
If an error is raised in de-pickling and we're sure the value is
a definite pickle, the error is allowed to propogate. If we
aren't sure if the value is a pickle or not, then we catch the
error and return the original value... | [
"B64decode",
"and",
"unpickle",
"the",
"object",
"optionally",
"decompressing",
"it",
"."
] | train | https://github.com/tylerbutler/propane/blob/6c404285ab8d78865b7175a5c8adf8fae12d6be5/propane/django/fields.py#L109-L127 |
tylerbutler/propane | propane/django/fields.py | PickledObjectField.get_db_prep_value | def get_db_prep_value(self, value):
"""
Pickle and b64encode the object, optionally compressing it.
The pickling protocol is specified explicitly (by default 2),
rather than as -1 or HIGHEST_PROTOCOL, because we don't want the
protocol to change over time. If it did, ``exact`` a... | python | def get_db_prep_value(self, value):
"""
Pickle and b64encode the object, optionally compressing it.
The pickling protocol is specified explicitly (by default 2),
rather than as -1 or HIGHEST_PROTOCOL, because we don't want the
protocol to change over time. If it did, ``exact`` a... | [
"def",
"get_db_prep_value",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
"and",
"not",
"isinstance",
"(",
"value",
",",
"PickledObject",
")",
":",
"# We call force_unicode here explicitly, so that the encoded string",
"# isn't rejected by the... | Pickle and b64encode the object, optionally compressing it.
The pickling protocol is specified explicitly (by default 2),
rather than as -1 or HIGHEST_PROTOCOL, because we don't want the
protocol to change over time. If it did, ``exact`` and ``in``
lookups would likely fail, since pickl... | [
"Pickle",
"and",
"b64encode",
"the",
"object",
"optionally",
"compressing",
"it",
"."
] | train | https://github.com/tylerbutler/propane/blob/6c404285ab8d78865b7175a5c8adf8fae12d6be5/propane/django/fields.py#L129-L148 |
kcolford/txt2boil | txt2boil/core/extractor.py | Extractor.nextComment | def nextComment(self, text, start=0):
"""Return the next comment found in text starting at start.
"""
m = min([self.lineComment(text, start),
self.blockComment(text, start),
self._emptylineregex.search(text, start)],
key=lambda m: m.start(0) if... | python | def nextComment(self, text, start=0):
"""Return the next comment found in text starting at start.
"""
m = min([self.lineComment(text, start),
self.blockComment(text, start),
self._emptylineregex.search(text, start)],
key=lambda m: m.start(0) if... | [
"def",
"nextComment",
"(",
"self",
",",
"text",
",",
"start",
"=",
"0",
")",
":",
"m",
"=",
"min",
"(",
"[",
"self",
".",
"lineComment",
"(",
"text",
",",
"start",
")",
",",
"self",
".",
"blockComment",
"(",
"text",
",",
"start",
")",
",",
"self"... | Return the next comment found in text starting at start. | [
"Return",
"the",
"next",
"comment",
"found",
"in",
"text",
"starting",
"at",
"start",
"."
] | train | https://github.com/kcolford/txt2boil/blob/853a47bb8db27c0224531f24dfd02839c983d027/txt2boil/core/extractor.py#L57-L66 |
kcolford/txt2boil | txt2boil/core/extractor.py | Extractor.isLineComment | def isLineComment(self, text):
"""Return true if the text is a line comment.
"""
m = self.lineComment(text, 0)
return m and m.start(0) == 0 and m.end(0) == len(text) | python | def isLineComment(self, text):
"""Return true if the text is a line comment.
"""
m = self.lineComment(text, 0)
return m and m.start(0) == 0 and m.end(0) == len(text) | [
"def",
"isLineComment",
"(",
"self",
",",
"text",
")",
":",
"m",
"=",
"self",
".",
"lineComment",
"(",
"text",
",",
"0",
")",
"return",
"m",
"and",
"m",
".",
"start",
"(",
"0",
")",
"==",
"0",
"and",
"m",
".",
"end",
"(",
"0",
")",
"==",
"len... | Return true if the text is a line comment. | [
"Return",
"true",
"if",
"the",
"text",
"is",
"a",
"line",
"comment",
"."
] | train | https://github.com/kcolford/txt2boil/blob/853a47bb8db27c0224531f24dfd02839c983d027/txt2boil/core/extractor.py#L75-L81 |
kcolford/txt2boil | txt2boil/core/extractor.py | Extractor.nextValidComment | def nextValidComment(self, text, start=0):
"""Return the next actual comment.
"""
m = min([self.lineComment(text, start),
self.blockComment(text, start)],
key=lambda m: m.start(0) if m else len(text))
return m | python | def nextValidComment(self, text, start=0):
"""Return the next actual comment.
"""
m = min([self.lineComment(text, start),
self.blockComment(text, start)],
key=lambda m: m.start(0) if m else len(text))
return m | [
"def",
"nextValidComment",
"(",
"self",
",",
"text",
",",
"start",
"=",
"0",
")",
":",
"m",
"=",
"min",
"(",
"[",
"self",
".",
"lineComment",
"(",
"text",
",",
"start",
")",
",",
"self",
".",
"blockComment",
"(",
"text",
",",
"start",
")",
"]",
"... | Return the next actual comment. | [
"Return",
"the",
"next",
"actual",
"comment",
"."
] | train | https://github.com/kcolford/txt2boil/blob/853a47bb8db27c0224531f24dfd02839c983d027/txt2boil/core/extractor.py#L83-L91 |
kcolford/txt2boil | txt2boil/core/extractor.py | Extractor.extractContent | def extractContent(self, text):
"""Extract the content of comment text.
"""
m = self.nextValidComment(text)
return '' if m is None else m.group(1) | python | def extractContent(self, text):
"""Extract the content of comment text.
"""
m = self.nextValidComment(text)
return '' if m is None else m.group(1) | [
"def",
"extractContent",
"(",
"self",
",",
"text",
")",
":",
"m",
"=",
"self",
".",
"nextValidComment",
"(",
"text",
")",
"return",
"''",
"if",
"m",
"is",
"None",
"else",
"m",
".",
"group",
"(",
"1",
")"
] | Extract the content of comment text. | [
"Extract",
"the",
"content",
"of",
"comment",
"text",
"."
] | train | https://github.com/kcolford/txt2boil/blob/853a47bb8db27c0224531f24dfd02839c983d027/txt2boil/core/extractor.py#L93-L99 |
kcolford/txt2boil | txt2boil/core/extractor.py | Extractor.chunkComment | def chunkComment(self, text, start=0):
"""Return a list of chunks of comments.
"""
# Build a list of comments
comm, out = self.nextComment(text, start), []
while comm:
out.append(comm.group(0))
comm = self.nextComment(text, comm.start(0) + 1)
# ... | python | def chunkComment(self, text, start=0):
"""Return a list of chunks of comments.
"""
# Build a list of comments
comm, out = self.nextComment(text, start), []
while comm:
out.append(comm.group(0))
comm = self.nextComment(text, comm.start(0) + 1)
# ... | [
"def",
"chunkComment",
"(",
"self",
",",
"text",
",",
"start",
"=",
"0",
")",
":",
"# Build a list of comments",
"comm",
",",
"out",
"=",
"self",
".",
"nextComment",
"(",
"text",
",",
"start",
")",
",",
"[",
"]",
"while",
"comm",
":",
"out",
".",
"ap... | Return a list of chunks of comments. | [
"Return",
"a",
"list",
"of",
"chunks",
"of",
"comments",
"."
] | train | https://github.com/kcolford/txt2boil/blob/853a47bb8db27c0224531f24dfd02839c983d027/txt2boil/core/extractor.py#L109-L127 |
kcolford/txt2boil | txt2boil/core/extractor.py | Extractor.comments | def comments(self, text, start=0):
"""Return a list of comments.
"""
out = [self.extractChunkContent(s)
for s in self.chunkComment(text, start)]
return out | python | def comments(self, text, start=0):
"""Return a list of comments.
"""
out = [self.extractChunkContent(s)
for s in self.chunkComment(text, start)]
return out | [
"def",
"comments",
"(",
"self",
",",
"text",
",",
"start",
"=",
"0",
")",
":",
"out",
"=",
"[",
"self",
".",
"extractChunkContent",
"(",
"s",
")",
"for",
"s",
"in",
"self",
".",
"chunkComment",
"(",
"text",
",",
"start",
")",
"]",
"return",
"out"
] | Return a list of comments. | [
"Return",
"a",
"list",
"of",
"comments",
"."
] | train | https://github.com/kcolford/txt2boil/blob/853a47bb8db27c0224531f24dfd02839c983d027/txt2boil/core/extractor.py#L129-L136 |
kcolford/txt2boil | txt2boil/core/extractor.py | Extractor.code | def code(self, text):
"""Return the code instead of the comments.
"""
comm = self.nextValidComment(text)
while comm:
text = text[:comm.start()] + text[comm.end():]
comm = self.nextValidComment(text, comm.end(0))
return text | python | def code(self, text):
"""Return the code instead of the comments.
"""
comm = self.nextValidComment(text)
while comm:
text = text[:comm.start()] + text[comm.end():]
comm = self.nextValidComment(text, comm.end(0))
return text | [
"def",
"code",
"(",
"self",
",",
"text",
")",
":",
"comm",
"=",
"self",
".",
"nextValidComment",
"(",
"text",
")",
"while",
"comm",
":",
"text",
"=",
"text",
"[",
":",
"comm",
".",
"start",
"(",
")",
"]",
"+",
"text",
"[",
"comm",
".",
"end",
"... | Return the code instead of the comments. | [
"Return",
"the",
"code",
"instead",
"of",
"the",
"comments",
"."
] | train | https://github.com/kcolford/txt2boil/blob/853a47bb8db27c0224531f24dfd02839c983d027/txt2boil/core/extractor.py#L138-L147 |
emencia/emencia-django-forum | forum/views/post.py | PostEditView.get_object | def get_object(self, *args, **kwargs):
"""
Should memoize the object to avoid multiple query if get_object is used many times in the view
"""
self.category_instance = get_object_or_404(Category, slug=self.kwargs['category_slug'])
return get_object_or_404(Post, thread__id=self.kwa... | python | def get_object(self, *args, **kwargs):
"""
Should memoize the object to avoid multiple query if get_object is used many times in the view
"""
self.category_instance = get_object_or_404(Category, slug=self.kwargs['category_slug'])
return get_object_or_404(Post, thread__id=self.kwa... | [
"def",
"get_object",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"category_instance",
"=",
"get_object_or_404",
"(",
"Category",
",",
"slug",
"=",
"self",
".",
"kwargs",
"[",
"'category_slug'",
"]",
")",
"return",
"get_... | Should memoize the object to avoid multiple query if get_object is used many times in the view | [
"Should",
"memoize",
"the",
"object",
"to",
"avoid",
"multiple",
"query",
"if",
"get_object",
"is",
"used",
"many",
"times",
"in",
"the",
"view"
] | train | https://github.com/emencia/emencia-django-forum/blob/cda74ed7e5822675c340ee5ec71548d981bccd3b/forum/views/post.py#L42-L47 |
eliasdorneles/jk | jk/__init__.py | each_cons | def each_cons(sequence, size):
"""Iterates lazily through a sequence looking at a sliding window
with given size, for each time.
each_cons([1, 2, 3, 4], 2) --> [(0, 1), (1, 2), (2, 3), (3, 4)]
"""
return zip(*(islice(it, start, None)
for start, it in enumerate(tee(sequence, size)))... | python | def each_cons(sequence, size):
"""Iterates lazily through a sequence looking at a sliding window
with given size, for each time.
each_cons([1, 2, 3, 4], 2) --> [(0, 1), (1, 2), (2, 3), (3, 4)]
"""
return zip(*(islice(it, start, None)
for start, it in enumerate(tee(sequence, size)))... | [
"def",
"each_cons",
"(",
"sequence",
",",
"size",
")",
":",
"return",
"zip",
"(",
"*",
"(",
"islice",
"(",
"it",
",",
"start",
",",
"None",
")",
"for",
"start",
",",
"it",
"in",
"enumerate",
"(",
"tee",
"(",
"sequence",
",",
"size",
")",
")",
")"... | Iterates lazily through a sequence looking at a sliding window
with given size, for each time.
each_cons([1, 2, 3, 4], 2) --> [(0, 1), (1, 2), (2, 3), (3, 4)] | [
"Iterates",
"lazily",
"through",
"a",
"sequence",
"looking",
"at",
"a",
"sliding",
"window",
"with",
"given",
"size",
"for",
"each",
"time",
"."
] | train | https://github.com/eliasdorneles/jk/blob/bf28563cc80e380cc51e837b8ae9a1b0b0ab8704/jk/__init__.py#L29-L36 |
eliasdorneles/jk | jk/__init__.py | slice_before | def slice_before(predicate, iterable):
"""Returns groups of elements from iterable,
slicing just before predicate(elem) is True
"""
if isinstance(predicate, string_type):
predicate = re.compile(predicate)
if hasattr(predicate, 'match'):
predicate = predicate.match
record = []
... | python | def slice_before(predicate, iterable):
"""Returns groups of elements from iterable,
slicing just before predicate(elem) is True
"""
if isinstance(predicate, string_type):
predicate = re.compile(predicate)
if hasattr(predicate, 'match'):
predicate = predicate.match
record = []
... | [
"def",
"slice_before",
"(",
"predicate",
",",
"iterable",
")",
":",
"if",
"isinstance",
"(",
"predicate",
",",
"string_type",
")",
":",
"predicate",
"=",
"re",
".",
"compile",
"(",
"predicate",
")",
"if",
"hasattr",
"(",
"predicate",
",",
"'match'",
")",
... | Returns groups of elements from iterable,
slicing just before predicate(elem) is True | [
"Returns",
"groups",
"of",
"elements",
"from",
"iterable",
"slicing",
"just",
"before",
"predicate",
"(",
"elem",
")",
"is",
"True"
] | train | https://github.com/eliasdorneles/jk/blob/bf28563cc80e380cc51e837b8ae9a1b0b0ab8704/jk/__init__.py#L39-L63 |
eliasdorneles/jk | jk/__init__.py | slice_after | def slice_after(predicate, iterable):
"""Returns groups of elements from iterable,
slicing just after predicate(elem) is True
"""
record = []
for i, item in enumerate(iterable):
record.append(item)
if predicate(item):
yield tuple(record)
record = []
if r... | python | def slice_after(predicate, iterable):
"""Returns groups of elements from iterable,
slicing just after predicate(elem) is True
"""
record = []
for i, item in enumerate(iterable):
record.append(item)
if predicate(item):
yield tuple(record)
record = []
if r... | [
"def",
"slice_after",
"(",
"predicate",
",",
"iterable",
")",
":",
"record",
"=",
"[",
"]",
"for",
"i",
",",
"item",
"in",
"enumerate",
"(",
"iterable",
")",
":",
"record",
".",
"append",
"(",
"item",
")",
"if",
"predicate",
"(",
"item",
")",
":",
... | Returns groups of elements from iterable,
slicing just after predicate(elem) is True | [
"Returns",
"groups",
"of",
"elements",
"from",
"iterable",
"slicing",
"just",
"after",
"predicate",
"(",
"elem",
")",
"is",
"True"
] | train | https://github.com/eliasdorneles/jk/blob/bf28563cc80e380cc51e837b8ae9a1b0b0ab8704/jk/__init__.py#L66-L79 |
smetj/wishbone-decode-perfdata | wishbone_decode_perfdata/perfdata.py | PerfData.__chopStringDict | def __chopStringDict(self, data):
'''Returns a dictionary of the provided raw service/host check string.'''
r = {}
d = data.split('\t')
for item in d:
item_parts = item.split('::')
if len(item_parts) == 2:
(name, value) = item_parts
e... | python | def __chopStringDict(self, data):
'''Returns a dictionary of the provided raw service/host check string.'''
r = {}
d = data.split('\t')
for item in d:
item_parts = item.split('::')
if len(item_parts) == 2:
(name, value) = item_parts
e... | [
"def",
"__chopStringDict",
"(",
"self",
",",
"data",
")",
":",
"r",
"=",
"{",
"}",
"d",
"=",
"data",
".",
"split",
"(",
"'\\t'",
")",
"for",
"item",
"in",
"d",
":",
"item_parts",
"=",
"item",
".",
"split",
"(",
"'::'",
")",
"if",
"len",
"(",
"i... | Returns a dictionary of the provided raw service/host check string. | [
"Returns",
"a",
"dictionary",
"of",
"the",
"provided",
"raw",
"service",
"/",
"host",
"check",
"string",
"."
] | train | https://github.com/smetj/wishbone-decode-perfdata/blob/70dbbc7c27055c730db61de0a8906f3acbad9532/wishbone_decode_perfdata/perfdata.py#L108-L138 |
smetj/wishbone-decode-perfdata | wishbone_decode_perfdata/perfdata.py | PerfData.__filter | def __filter(self, name):
'''Filter out problematic characters.
This should become a separate module allowing the user to define filter rules
from a bootstrap file and most likely become a separate module.
'''
name = name.replace("'", '')
name = name.replace('"', '')
... | python | def __filter(self, name):
'''Filter out problematic characters.
This should become a separate module allowing the user to define filter rules
from a bootstrap file and most likely become a separate module.
'''
name = name.replace("'", '')
name = name.replace('"', '')
... | [
"def",
"__filter",
"(",
"self",
",",
"name",
")",
":",
"name",
"=",
"name",
".",
"replace",
"(",
"\"'\"",
",",
"''",
")",
"name",
"=",
"name",
".",
"replace",
"(",
"'\"'",
",",
"''",
")",
"name",
"=",
"name",
".",
"replace",
"(",
"'!(null)'",
","... | Filter out problematic characters.
This should become a separate module allowing the user to define filter rules
from a bootstrap file and most likely become a separate module. | [
"Filter",
"out",
"problematic",
"characters",
"."
] | train | https://github.com/smetj/wishbone-decode-perfdata/blob/70dbbc7c27055c730db61de0a8906f3acbad9532/wishbone_decode_perfdata/perfdata.py#L140-L153 |
vuolter/autoupgrade | autoupgrade/package.py | Package.smartupgrade | def smartupgrade(self, restart=True, dependencies=False, prerelease=False):
"""
Upgrade the package if there is a later version available.
Args:
restart: restart app if True
dependencies: update package dependencies if True (see pip --no-deps)
prerelease: upda... | python | def smartupgrade(self, restart=True, dependencies=False, prerelease=False):
"""
Upgrade the package if there is a later version available.
Args:
restart: restart app if True
dependencies: update package dependencies if True (see pip --no-deps)
prerelease: upda... | [
"def",
"smartupgrade",
"(",
"self",
",",
"restart",
"=",
"True",
",",
"dependencies",
"=",
"False",
",",
"prerelease",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"check",
"(",
")",
":",
"if",
"self",
".",
"verbose",
":",
"print",
"(",
"\"Packa... | Upgrade the package if there is a later version available.
Args:
restart: restart app if True
dependencies: update package dependencies if True (see pip --no-deps)
prerelease: update to pre-release and development versions | [
"Upgrade",
"the",
"package",
"if",
"there",
"is",
"a",
"later",
"version",
"available",
".",
"Args",
":",
"restart",
":",
"restart",
"app",
"if",
"True",
"dependencies",
":",
"update",
"package",
"dependencies",
"if",
"True",
"(",
"see",
"pip",
"--",
"no",... | train | https://github.com/vuolter/autoupgrade/blob/e34aca9eacd6a6f5c7a7634a67c2ee911d48ac68/autoupgrade/package.py#L45-L61 |
vuolter/autoupgrade | autoupgrade/package.py | Package.upgrade | def upgrade(self, dependencies=False, prerelease=False, force=False):
"""
Upgrade the package unconditionaly
Args:
dependencies: update package dependencies if True (see pip --no-deps)
prerelease: update to pre-release and development versions
force: reinstall... | python | def upgrade(self, dependencies=False, prerelease=False, force=False):
"""
Upgrade the package unconditionaly
Args:
dependencies: update package dependencies if True (see pip --no-deps)
prerelease: update to pre-release and development versions
force: reinstall... | [
"def",
"upgrade",
"(",
"self",
",",
"dependencies",
"=",
"False",
",",
"prerelease",
"=",
"False",
",",
"force",
"=",
"False",
")",
":",
"pip_args",
"=",
"[",
"'install'",
",",
"self",
".",
"pkg",
"]",
"found",
"=",
"self",
".",
"_get_current",
"(",
... | Upgrade the package unconditionaly
Args:
dependencies: update package dependencies if True (see pip --no-deps)
prerelease: update to pre-release and development versions
force: reinstall all packages even if they are already up-to-date
Returns True if pip was sucessfu... | [
"Upgrade",
"the",
"package",
"unconditionaly",
"Args",
":",
"dependencies",
":",
"update",
"package",
"dependencies",
"if",
"True",
"(",
"see",
"pip",
"--",
"no",
"-",
"deps",
")",
"prerelease",
":",
"update",
"to",
"pre",
"-",
"release",
"and",
"development... | train | https://github.com/vuolter/autoupgrade/blob/e34aca9eacd6a6f5c7a7634a67c2ee911d48ac68/autoupgrade/package.py#L63-L104 |
vuolter/autoupgrade | autoupgrade/package.py | Package.restart | def restart(self):
"""
Restart application with same args as it was started.
Does **not** return
"""
if self.verbose:
print("Restarting {} {} ...".format(sys.executable, sys.argv))
os.execl(sys.executable, *([sys.executable] + sys.argv)) | python | def restart(self):
"""
Restart application with same args as it was started.
Does **not** return
"""
if self.verbose:
print("Restarting {} {} ...".format(sys.executable, sys.argv))
os.execl(sys.executable, *([sys.executable] + sys.argv)) | [
"def",
"restart",
"(",
"self",
")",
":",
"if",
"self",
".",
"verbose",
":",
"print",
"(",
"\"Restarting {} {} ...\"",
".",
"format",
"(",
"sys",
".",
"executable",
",",
"sys",
".",
"argv",
")",
")",
"os",
".",
"execl",
"(",
"sys",
".",
"executable",
... | Restart application with same args as it was started.
Does **not** return | [
"Restart",
"application",
"with",
"same",
"args",
"as",
"it",
"was",
"started",
".",
"Does",
"**",
"not",
"**",
"return"
] | train | https://github.com/vuolter/autoupgrade/blob/e34aca9eacd6a6f5c7a7634a67c2ee911d48ac68/autoupgrade/package.py#L106-L113 |
vuolter/autoupgrade | autoupgrade/package.py | Package.check | def check(self):
"""
Check if pkg has a later version
Returns true if later version exists
"""
current = self._get_current()
highest = self._get_highest_version()
return highest > current | python | def check(self):
"""
Check if pkg has a later version
Returns true if later version exists
"""
current = self._get_current()
highest = self._get_highest_version()
return highest > current | [
"def",
"check",
"(",
"self",
")",
":",
"current",
"=",
"self",
".",
"_get_current",
"(",
")",
"highest",
"=",
"self",
".",
"_get_highest_version",
"(",
")",
"return",
"highest",
">",
"current"
] | Check if pkg has a later version
Returns true if later version exists | [
"Check",
"if",
"pkg",
"has",
"a",
"later",
"version",
"Returns",
"true",
"if",
"later",
"version",
"exists"
] | train | https://github.com/vuolter/autoupgrade/blob/e34aca9eacd6a6f5c7a7634a67c2ee911d48ac68/autoupgrade/package.py#L115-L122 |
thomasvandoren/bugzscout-py | doc/example/src/simple_wsgi.py | bugzscout_app | def bugzscout_app(environ, start_response):
"""Simple WSGI application that returns 200 OK response with 'Hellow
world!' in the body. If an uncaught exception is thrown, it is reported to
BugzScout.
:param environ: WSGI environ
:param start_response: function that accepts status string and headers
... | python | def bugzscout_app(environ, start_response):
"""Simple WSGI application that returns 200 OK response with 'Hellow
world!' in the body. If an uncaught exception is thrown, it is reported to
BugzScout.
:param environ: WSGI environ
:param start_response: function that accepts status string and headers
... | [
"def",
"bugzscout_app",
"(",
"environ",
",",
"start_response",
")",
":",
"try",
":",
"start_response",
"(",
"'200 OK'",
",",
"[",
"(",
"'content-type'",
",",
"'text/html'",
")",
"]",
")",
"return",
"[",
"'Hellow world!'",
"]",
"except",
"Exception",
"as",
"e... | Simple WSGI application that returns 200 OK response with 'Hellow
world!' in the body. If an uncaught exception is thrown, it is reported to
BugzScout.
:param environ: WSGI environ
:param start_response: function that accepts status string and headers | [
"Simple",
"WSGI",
"application",
"that",
"returns",
"200",
"OK",
"response",
"with",
"Hellow",
"world!",
"in",
"the",
"body",
".",
"If",
"an",
"uncaught",
"exception",
"is",
"thrown",
"it",
"is",
"reported",
"to",
"BugzScout",
"."
] | train | https://github.com/thomasvandoren/bugzscout-py/blob/514528e958a97e0e7b36870037c5c69661511824/doc/example/src/simple_wsgi.py#L35-L53 |
openpermissions/chub | chub/oauth2.py | RequestToken._request | def _request(self, base_url, client_id, client_secret,
parameters, **kwargs):
"""Make an API request to get the token"""
logging.debug('Getting an OAuth token for client "%s" with scope "%s"',
client_id, parameters.get('scope'))
headers = {'Content-Type': '... | python | def _request(self, base_url, client_id, client_secret,
parameters, **kwargs):
"""Make an API request to get the token"""
logging.debug('Getting an OAuth token for client "%s" with scope "%s"',
client_id, parameters.get('scope'))
headers = {'Content-Type': '... | [
"def",
"_request",
"(",
"self",
",",
"base_url",
",",
"client_id",
",",
"client_secret",
",",
"parameters",
",",
"*",
"*",
"kwargs",
")",
":",
"logging",
".",
"debug",
"(",
"'Getting an OAuth token for client \"%s\" with scope \"%s\"'",
",",
"client_id",
",",
"par... | Make an API request to get the token | [
"Make",
"an",
"API",
"request",
"to",
"get",
"the",
"token"
] | train | https://github.com/openpermissions/chub/blob/00762aa17015f4b3010673d1570c708eab3c34ed/chub/oauth2.py#L227-L246 |
openpermissions/chub | chub/oauth2.py | RequestToken._cached_request | def _cached_request(self, base_url, client_id, client_secret,
parameters, **kwargs):
"""Cache the token request and use cached responses if available"""
key = (base_url, client_id, tuple(parameters.items()))
cached = self._cache.get(key, {})
if not cached.get('ac... | python | def _cached_request(self, base_url, client_id, client_secret,
parameters, **kwargs):
"""Cache the token request and use cached responses if available"""
key = (base_url, client_id, tuple(parameters.items()))
cached = self._cache.get(key, {})
if not cached.get('ac... | [
"def",
"_cached_request",
"(",
"self",
",",
"base_url",
",",
"client_id",
",",
"client_secret",
",",
"parameters",
",",
"*",
"*",
"kwargs",
")",
":",
"key",
"=",
"(",
"base_url",
",",
"client_id",
",",
"tuple",
"(",
"parameters",
".",
"items",
"(",
")",
... | Cache the token request and use cached responses if available | [
"Cache",
"the",
"token",
"request",
"and",
"use",
"cached",
"responses",
"if",
"available"
] | train | https://github.com/openpermissions/chub/blob/00762aa17015f4b3010673d1570c708eab3c34ed/chub/oauth2.py#L257-L274 |
openpermissions/chub | chub/oauth2.py | RequestToken.purge_cache | def purge_cache(self):
"""
Purge expired cached tokens and oldest tokens if more than cache_size
"""
if len(self._cache) > self.max_cache_size:
items = sorted(self._cache.items(), key=lambda (k, v): v['expiry'])
self._cache = {k: v for k, v in items[self.max_cache... | python | def purge_cache(self):
"""
Purge expired cached tokens and oldest tokens if more than cache_size
"""
if len(self._cache) > self.max_cache_size:
items = sorted(self._cache.items(), key=lambda (k, v): v['expiry'])
self._cache = {k: v for k, v in items[self.max_cache... | [
"def",
"purge_cache",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"_cache",
")",
">",
"self",
".",
"max_cache_size",
":",
"items",
"=",
"sorted",
"(",
"self",
".",
"_cache",
".",
"items",
"(",
")",
",",
"key",
"=",
"lambda",
"(",
"k",
"... | Purge expired cached tokens and oldest tokens if more than cache_size | [
"Purge",
"expired",
"cached",
"tokens",
"and",
"oldest",
"tokens",
"if",
"more",
"than",
"cache_size"
] | train | https://github.com/openpermissions/chub/blob/00762aa17015f4b3010673d1570c708eab3c34ed/chub/oauth2.py#L280-L287 |
totokaka/pySpaceGDN | pyspacegdn/spacegdn.py | SpaceGDN._create_user_agent | def _create_user_agent(self):
""" Create the user agent and return it as a string. """
user_agent = '{}/{} {}'.format(pyspacegdn.__title__,
pyspacegdn.__version__,
default_user_agent())
if self.client_name:
... | python | def _create_user_agent(self):
""" Create the user agent and return it as a string. """
user_agent = '{}/{} {}'.format(pyspacegdn.__title__,
pyspacegdn.__version__,
default_user_agent())
if self.client_name:
... | [
"def",
"_create_user_agent",
"(",
"self",
")",
":",
"user_agent",
"=",
"'{}/{} {}'",
".",
"format",
"(",
"pyspacegdn",
".",
"__title__",
",",
"pyspacegdn",
".",
"__version__",
",",
"default_user_agent",
"(",
")",
")",
"if",
"self",
".",
"client_name",
":",
"... | Create the user agent and return it as a string. | [
"Create",
"the",
"user",
"agent",
"and",
"return",
"it",
"as",
"a",
"string",
"."
] | train | https://github.com/totokaka/pySpaceGDN/blob/55c8be8d751e24873e0a7f7e99d2b715442ec878/pyspacegdn/spacegdn.py#L64-L72 |
yv/pathconfig | py_src/pathconfig/config.py | load_configuration | def load_configuration(app_name):
'''
creates a new configuration and loads the appropriate
files.
'''
if sys.prefix == '/usr':
conf_dir = '/etc'
share_dir = '/usr/share'
else:
conf_dir = os.path.join(sys.prefix, 'etc')
share_dir = os.path.join(sys.prefix, 'share'... | python | def load_configuration(app_name):
'''
creates a new configuration and loads the appropriate
files.
'''
if sys.prefix == '/usr':
conf_dir = '/etc'
share_dir = '/usr/share'
else:
conf_dir = os.path.join(sys.prefix, 'etc')
share_dir = os.path.join(sys.prefix, 'share'... | [
"def",
"load_configuration",
"(",
"app_name",
")",
":",
"if",
"sys",
".",
"prefix",
"==",
"'/usr'",
":",
"conf_dir",
"=",
"'/etc'",
"share_dir",
"=",
"'/usr/share'",
"else",
":",
"conf_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"sys",
".",
"prefix",... | creates a new configuration and loads the appropriate
files. | [
"creates",
"a",
"new",
"configuration",
"and",
"loads",
"the",
"appropriate",
"files",
"."
] | train | https://github.com/yv/pathconfig/blob/ae13901773b8465061e2aa93b2a53fd436ab6c69/py_src/pathconfig/config.py#L89-L116 |
yv/pathconfig | py_src/pathconfig/config.py | AppContext.get_config_var | def get_config_var(self, path, env=None):
'''
retrieves the config variable named ``path`` from the config file.
Path elements that start with a $ are replaced with values from the
dict passed as ``env``
'''
if env is None:
env = {}
result = self.conf
... | python | def get_config_var(self, path, env=None):
'''
retrieves the config variable named ``path`` from the config file.
Path elements that start with a $ are replaced with values from the
dict passed as ``env``
'''
if env is None:
env = {}
result = self.conf
... | [
"def",
"get_config_var",
"(",
"self",
",",
"path",
",",
"env",
"=",
"None",
")",
":",
"if",
"env",
"is",
"None",
":",
"env",
"=",
"{",
"}",
"result",
"=",
"self",
".",
"conf",
"for",
"e",
"in",
"path",
".",
"split",
"(",
"'.'",
")",
":",
"if",
... | retrieves the config variable named ``path`` from the config file.
Path elements that start with a $ are replaced with values from the
dict passed as ``env`` | [
"retrieves",
"the",
"config",
"variable",
"named",
"path",
"from",
"the",
"config",
"file",
".",
"Path",
"elements",
"that",
"start",
"with",
"a",
"$",
"are",
"replaced",
"with",
"values",
"from",
"the",
"dict",
"passed",
"as",
"env"
] | train | https://github.com/yv/pathconfig/blob/ae13901773b8465061e2aa93b2a53fd436ab6c69/py_src/pathconfig/config.py#L52-L72 |
hirokiky/uiro | uiro/view.py | get_base_wrappers | def get_base_wrappers(method='get', template_name='', predicates=(), wrappers=()):
""" basic View Wrappers used by view_config.
"""
wrappers += (preserve_view(MethodPredicate(method), *predicates),)
if template_name:
wrappers += (render_template(template_name),)
return wrappers | python | def get_base_wrappers(method='get', template_name='', predicates=(), wrappers=()):
""" basic View Wrappers used by view_config.
"""
wrappers += (preserve_view(MethodPredicate(method), *predicates),)
if template_name:
wrappers += (render_template(template_name),)
return wrappers | [
"def",
"get_base_wrappers",
"(",
"method",
"=",
"'get'",
",",
"template_name",
"=",
"''",
",",
"predicates",
"=",
"(",
")",
",",
"wrappers",
"=",
"(",
")",
")",
":",
"wrappers",
"+=",
"(",
"preserve_view",
"(",
"MethodPredicate",
"(",
"method",
")",
",",... | basic View Wrappers used by view_config. | [
"basic",
"View",
"Wrappers",
"used",
"by",
"view_config",
"."
] | train | https://github.com/hirokiky/uiro/blob/8436976b21ac9b0eac4243768f5ada12479b9e00/uiro/view.py#L14-L22 |
hirokiky/uiro | uiro/view.py | view_config | def view_config(
method='get',
template_name='',
predicates=(),
wrappers=(),
base_wrappers_getter=get_base_wrappers,
):
""" Creating Views applied some configurations
and store it to _wrapped attribute on each Views.
* _wrapped expects to be called by Controller
... | python | def view_config(
method='get',
template_name='',
predicates=(),
wrappers=(),
base_wrappers_getter=get_base_wrappers,
):
""" Creating Views applied some configurations
and store it to _wrapped attribute on each Views.
* _wrapped expects to be called by Controller
... | [
"def",
"view_config",
"(",
"method",
"=",
"'get'",
",",
"template_name",
"=",
"''",
",",
"predicates",
"=",
"(",
")",
",",
"wrappers",
"=",
"(",
")",
",",
"base_wrappers_getter",
"=",
"get_base_wrappers",
",",
")",
":",
"wrappers",
"=",
"base_wrappers_getter... | Creating Views applied some configurations
and store it to _wrapped attribute on each Views.
* _wrapped expects to be called by Controller
(subclasses of uiro.controller.BaseController)
* The original view will not be affected by this decorator. | [
"Creating",
"Views",
"applied",
"some",
"configurations",
"and",
"store",
"it",
"to",
"_wrapped",
"attribute",
"on",
"each",
"Views",
"."
] | train | https://github.com/hirokiky/uiro/blob/8436976b21ac9b0eac4243768f5ada12479b9e00/uiro/view.py#L28-L53 |
hirokiky/uiro | uiro/view.py | preserve_view | def preserve_view(*predicates):
""" Raising ViewNotMatched when applied request was not apposite.
preserve_view calls all Predicates and when return values of them was
all True it will call a wrapped view.
It raises ViewNotMatched if this is not the case.
Predicates:
This decorator takes Predi... | python | def preserve_view(*predicates):
""" Raising ViewNotMatched when applied request was not apposite.
preserve_view calls all Predicates and when return values of them was
all True it will call a wrapped view.
It raises ViewNotMatched if this is not the case.
Predicates:
This decorator takes Predi... | [
"def",
"preserve_view",
"(",
"*",
"predicates",
")",
":",
"def",
"wrapper",
"(",
"view_callable",
")",
":",
"def",
"_wrapped",
"(",
"self",
",",
"request",
",",
"context",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"all",
"(",
"[",
... | Raising ViewNotMatched when applied request was not apposite.
preserve_view calls all Predicates and when return values of them was
all True it will call a wrapped view.
It raises ViewNotMatched if this is not the case.
Predicates:
This decorator takes Predicates one or more, Predicate is callable... | [
"Raising",
"ViewNotMatched",
"when",
"applied",
"request",
"was",
"not",
"apposite",
"."
] | train | https://github.com/hirokiky/uiro/blob/8436976b21ac9b0eac4243768f5ada12479b9e00/uiro/view.py#L56-L75 |
hirokiky/uiro | uiro/view.py | render_template | def render_template(template_name, template_getter=get_app_template):
""" Decorator to specify which template to use for Wrapped Views.
It will return string rendered by specified template and
returned dictionary from wrapped views as a context for template.
The returned value was not dictionary, it do... | python | def render_template(template_name, template_getter=get_app_template):
""" Decorator to specify which template to use for Wrapped Views.
It will return string rendered by specified template and
returned dictionary from wrapped views as a context for template.
The returned value was not dictionary, it do... | [
"def",
"render_template",
"(",
"template_name",
",",
"template_getter",
"=",
"get_app_template",
")",
":",
"def",
"wrapper",
"(",
"func",
")",
":",
"template",
"=",
"template_getter",
"(",
"template_name",
")",
"def",
"_wraped",
"(",
"self",
",",
"request",
",... | Decorator to specify which template to use for Wrapped Views.
It will return string rendered by specified template and
returned dictionary from wrapped views as a context for template.
The returned value was not dictionary, it does nothing,
just returns the result. | [
"Decorator",
"to",
"specify",
"which",
"template",
"to",
"use",
"for",
"Wrapped",
"Views",
"."
] | train | https://github.com/hirokiky/uiro/blob/8436976b21ac9b0eac4243768f5ada12479b9e00/uiro/view.py#L91-L109 |
zvolsky/cnb | cnb.py | rate | def rate(currency, date=None, valid_days_max=None):
"""will return the rate for the currency today or for given date
valid_days_max is used only if service fails and this method try find something in cache
dates from cache will be used in range <date - valid_days_max; date + valid_days_max>
if v... | python | def rate(currency, date=None, valid_days_max=None):
"""will return the rate for the currency today or for given date
valid_days_max is used only if service fails and this method try find something in cache
dates from cache will be used in range <date - valid_days_max; date + valid_days_max>
if v... | [
"def",
"rate",
"(",
"currency",
",",
"date",
"=",
"None",
",",
"valid_days_max",
"=",
"None",
")",
":",
"result",
"=",
"_rate",
"(",
"currency",
",",
"date",
",",
"valid_days_max",
"=",
"valid_days_max",
")",
"return",
"apply_amount",
"(",
"result",
"[",
... | will return the rate for the currency today or for given date
valid_days_max is used only if service fails and this method try find something in cache
dates from cache will be used in range <date - valid_days_max; date + valid_days_max>
if valid_days_max is None (default), VALID_DAYS_MAX_DEFAULT is ... | [
"will",
"return",
"the",
"rate",
"for",
"the",
"currency",
"today",
"or",
"for",
"given",
"date",
"valid_days_max",
"is",
"used",
"only",
"if",
"service",
"fails",
"and",
"this",
"method",
"try",
"find",
"something",
"in",
"cache",
"dates",
"from",
"cache",
... | train | https://github.com/zvolsky/cnb/blob/9471fac447b6463a4cfe2a135c71af8fd8672323/cnb.py#L96-L103 |
zvolsky/cnb | cnb.py | convert | def convert(amount, source, target='CZK', date=None, percent=0, valid_days_max=None):
"""without target parameter returns equivalent of amount+source in CZK
with target parameter returns equivalent of amount+source in given currency
you can calculate with regard to (given) date
you can add additional ma... | python | def convert(amount, source, target='CZK', date=None, percent=0, valid_days_max=None):
"""without target parameter returns equivalent of amount+source in CZK
with target parameter returns equivalent of amount+source in given currency
you can calculate with regard to (given) date
you can add additional ma... | [
"def",
"convert",
"(",
"amount",
",",
"source",
",",
"target",
"=",
"'CZK'",
",",
"date",
"=",
"None",
",",
"percent",
"=",
"0",
",",
"valid_days_max",
"=",
"None",
")",
":",
"if",
"source",
".",
"upper",
"(",
")",
"==",
"'CZK'",
":",
"czk",
"=",
... | without target parameter returns equivalent of amount+source in CZK
with target parameter returns equivalent of amount+source in given currency
you can calculate with regard to (given) date
you can add additional margin with percent parameter
valid_days_max: see rate() | [
"without",
"target",
"parameter",
"returns",
"equivalent",
"of",
"amount",
"+",
"source",
"in",
"CZK",
"with",
"target",
"parameter",
"returns",
"equivalent",
"of",
"amount",
"+",
"source",
"in",
"given",
"currency",
"you",
"can",
"calculate",
"with",
"regard",
... | train | https://github.com/zvolsky/cnb/blob/9471fac447b6463a4cfe2a135c71af8fd8672323/cnb.py#L122-L134 |
zvolsky/cnb | cnb.py | convert_to | def convert_to(target, amount, date=None, percent=0, valid_days_max=None):
"""will convert the amount in CZK into given currency (target)
you can calculate with regard to (given) date
you can add additional margin with percent parameter
valid_days_max: see rate()
"""
if target.upper() == 'CZK':
... | python | def convert_to(target, amount, date=None, percent=0, valid_days_max=None):
"""will convert the amount in CZK into given currency (target)
you can calculate with regard to (given) date
you can add additional margin with percent parameter
valid_days_max: see rate()
"""
if target.upper() == 'CZK':
... | [
"def",
"convert_to",
"(",
"target",
",",
"amount",
",",
"date",
"=",
"None",
",",
"percent",
"=",
"0",
",",
"valid_days_max",
"=",
"None",
")",
":",
"if",
"target",
".",
"upper",
"(",
")",
"==",
"'CZK'",
":",
"result",
"=",
"amount",
"else",
":",
"... | will convert the amount in CZK into given currency (target)
you can calculate with regard to (given) date
you can add additional margin with percent parameter
valid_days_max: see rate() | [
"will",
"convert",
"the",
"amount",
"in",
"CZK",
"into",
"given",
"currency",
"(",
"target",
")",
"you",
"can",
"calculate",
"with",
"regard",
"to",
"(",
"given",
")",
"date",
"you",
"can",
"add",
"additional",
"margin",
"with",
"percent",
"parameter",
"va... | train | https://github.com/zvolsky/cnb/blob/9471fac447b6463a4cfe2a135c71af8fd8672323/cnb.py#L136-L146 |
zvolsky/cnb | cnb.py | worse | def worse(src_amount, src_currency, target_amount_obtained, target_currency, date=None, valid_days_max=None):
"""will calculate a difference between the calculated target amount and the amount you give as src_amount
if you will obtain target_amount_obtained instead
valid_days_max: see rate()
returns a... | python | def worse(src_amount, src_currency, target_amount_obtained, target_currency, date=None, valid_days_max=None):
"""will calculate a difference between the calculated target amount and the amount you give as src_amount
if you will obtain target_amount_obtained instead
valid_days_max: see rate()
returns a... | [
"def",
"worse",
"(",
"src_amount",
",",
"src_currency",
",",
"target_amount_obtained",
",",
"target_currency",
",",
"date",
"=",
"None",
",",
"valid_days_max",
"=",
"None",
")",
":",
"calculated",
"=",
"convert",
"(",
"src_amount",
",",
"src_currency",
",",
"t... | will calculate a difference between the calculated target amount and the amount you give as src_amount
if you will obtain target_amount_obtained instead
valid_days_max: see rate()
returns a tuple: (percent, difference_src_currency, difference_target_currency) | [
"will",
"calculate",
"a",
"difference",
"between",
"the",
"calculated",
"target",
"amount",
"and",
"the",
"amount",
"you",
"give",
"as",
"src_amount",
"if",
"you",
"will",
"obtain",
"target_amount_obtained",
"instead",
"valid_days_max",
":",
"see",
"rate",
"()",
... | train | https://github.com/zvolsky/cnb/blob/9471fac447b6463a4cfe2a135c71af8fd8672323/cnb.py#L148-L162 |
xtrementl/focus | focus/environment/io.py | IOStream.prompt | def prompt(self, prompt_msg=None, newline=False):
""" Writes prompt message to output stream and
reads line from standard input stream.
`prompt_msg`
Message to write.
`newline`
Append newline character to prompt message before writing.
... | python | def prompt(self, prompt_msg=None, newline=False):
""" Writes prompt message to output stream and
reads line from standard input stream.
`prompt_msg`
Message to write.
`newline`
Append newline character to prompt message before writing.
... | [
"def",
"prompt",
"(",
"self",
",",
"prompt_msg",
"=",
"None",
",",
"newline",
"=",
"False",
")",
":",
"if",
"prompt_msg",
"is",
"not",
"None",
":",
"self",
".",
"write",
"(",
"prompt_msg",
",",
"newline",
")",
"return",
"self",
".",
"_input",
".",
"r... | Writes prompt message to output stream and
reads line from standard input stream.
`prompt_msg`
Message to write.
`newline`
Append newline character to prompt message before writing.
Return string. | [
"Writes",
"prompt",
"message",
"to",
"output",
"stream",
"and",
"reads",
"line",
"from",
"standard",
"input",
"stream",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/environment/io.py#L95-L110 |
xtrementl/focus | focus/environment/io.py | IOStream.write | def write(self, buf, newline=True):
""" Writes buffer to output stream.
`buf`
Data buffer to write.
`newline`
Append newline character to buffer before writing.
"""
buf = buf or ''
if newline:
buf += os.linesep
... | python | def write(self, buf, newline=True):
""" Writes buffer to output stream.
`buf`
Data buffer to write.
`newline`
Append newline character to buffer before writing.
"""
buf = buf or ''
if newline:
buf += os.linesep
... | [
"def",
"write",
"(",
"self",
",",
"buf",
",",
"newline",
"=",
"True",
")",
":",
"buf",
"=",
"buf",
"or",
"''",
"if",
"newline",
":",
"buf",
"+=",
"os",
".",
"linesep",
"try",
":",
"self",
".",
"_output",
".",
"write",
"(",
"buf",
")",
"if",
"ha... | Writes buffer to output stream.
`buf`
Data buffer to write.
`newline`
Append newline character to buffer before writing. | [
"Writes",
"buffer",
"to",
"output",
"stream",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/environment/io.py#L112-L134 |
xtrementl/focus | focus/environment/io.py | IOStream.success | def success(self, buf, newline=True):
""" Same as `write`, but adds success coloring if enabled.
`buf`
Data buffer to write.
`newline`
Append newline character to buffer before writing.
"""
if self._colored:
buf = self.ESC... | python | def success(self, buf, newline=True):
""" Same as `write`, but adds success coloring if enabled.
`buf`
Data buffer to write.
`newline`
Append newline character to buffer before writing.
"""
if self._colored:
buf = self.ESC... | [
"def",
"success",
"(",
"self",
",",
"buf",
",",
"newline",
"=",
"True",
")",
":",
"if",
"self",
".",
"_colored",
":",
"buf",
"=",
"self",
".",
"ESCAPE_GREEN",
"+",
"buf",
"+",
"self",
".",
"ESCAPE_CLEAR",
"self",
".",
"write",
"(",
"buf",
",",
"new... | Same as `write`, but adds success coloring if enabled.
`buf`
Data buffer to write.
`newline`
Append newline character to buffer before writing. | [
"Same",
"as",
"write",
"but",
"adds",
"success",
"coloring",
"if",
"enabled",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/environment/io.py#L136-L148 |
xtrementl/focus | focus/environment/io.py | IOStream.error | def error(self, buf, newline=True):
""" Similar to `write`, except it writes buffer to error stream.
If coloring enabled, adds error coloring.
`buf`
Data buffer to write.
`newline`
Append newline character to buffer before writing.
... | python | def error(self, buf, newline=True):
""" Similar to `write`, except it writes buffer to error stream.
If coloring enabled, adds error coloring.
`buf`
Data buffer to write.
`newline`
Append newline character to buffer before writing.
... | [
"def",
"error",
"(",
"self",
",",
"buf",
",",
"newline",
"=",
"True",
")",
":",
"buf",
"=",
"buf",
"or",
"''",
"if",
"self",
".",
"_colored",
":",
"buf",
"=",
"self",
".",
"ESCAPE_RED",
"+",
"buf",
"+",
"self",
".",
"ESCAPE_CLEAR",
"if",
"newline",... | Similar to `write`, except it writes buffer to error stream.
If coloring enabled, adds error coloring.
`buf`
Data buffer to write.
`newline`
Append newline character to buffer before writing. | [
"Similar",
"to",
"write",
"except",
"it",
"writes",
"buffer",
"to",
"error",
"stream",
".",
"If",
"coloring",
"enabled",
"adds",
"error",
"coloring",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/environment/io.py#L150-L175 |
cogniteev/docido-python-sdk | docido_sdk/toolbox/mongo_ext.py | KwargsqlToMongo.convert | def convert(cls, **kwargsql):
"""
:param dict kwargsql:
Kwargsql expression to convert
:return:
filter to be used in :py:method:`pymongo.collection.find`
:rtype: dict
"""
filters = []
for k, v in kwargsql.items():
terms = k.split('... | python | def convert(cls, **kwargsql):
"""
:param dict kwargsql:
Kwargsql expression to convert
:return:
filter to be used in :py:method:`pymongo.collection.find`
:rtype: dict
"""
filters = []
for k, v in kwargsql.items():
terms = k.split('... | [
"def",
"convert",
"(",
"cls",
",",
"*",
"*",
"kwargsql",
")",
":",
"filters",
"=",
"[",
"]",
"for",
"k",
",",
"v",
"in",
"kwargsql",
".",
"items",
"(",
")",
":",
"terms",
"=",
"k",
".",
"split",
"(",
"'__'",
")",
"if",
"terms",
"[",
"-",
"1",... | :param dict kwargsql:
Kwargsql expression to convert
:return:
filter to be used in :py:method:`pymongo.collection.find`
:rtype: dict | [
":",
"param",
"dict",
"kwargsql",
":",
"Kwargsql",
"expression",
"to",
"convert"
] | train | https://github.com/cogniteev/docido-python-sdk/blob/58ecb6c6f5757fd40c0601657ab18368da7ddf33/docido_sdk/toolbox/mongo_ext.py#L47-L87 |
fprimex/plac_ini | plac_ini.py | config_conf | def config_conf(obj):
"Extracts the configuration of the underlying ConfigParser from obj"
# If we ever want to add some default options this is where to do that
cfg = {}
for name in dir(obj):
if name in CONFIG_PARSER_CFG: # argument of ConfigParser
cfg[name] = getattr(obj, name)
... | python | def config_conf(obj):
"Extracts the configuration of the underlying ConfigParser from obj"
# If we ever want to add some default options this is where to do that
cfg = {}
for name in dir(obj):
if name in CONFIG_PARSER_CFG: # argument of ConfigParser
cfg[name] = getattr(obj, name)
... | [
"def",
"config_conf",
"(",
"obj",
")",
":",
"# If we ever want to add some default options this is where to do that",
"cfg",
"=",
"{",
"}",
"for",
"name",
"in",
"dir",
"(",
"obj",
")",
":",
"if",
"name",
"in",
"CONFIG_PARSER_CFG",
":",
"# argument of ConfigParser",
... | Extracts the configuration of the underlying ConfigParser from obj | [
"Extracts",
"the",
"configuration",
"of",
"the",
"underlying",
"ConfigParser",
"from",
"obj"
] | train | https://github.com/fprimex/plac_ini/blob/3f343d88326df9e5faf3a77fcffdd4ca3f5bec04/plac_ini.py#L30-L37 |
fprimex/plac_ini | plac_ini.py | add_gnu_argument | def add_gnu_argument(self, *args, **kwargs):
"Prevent the addition of any single hyphen, multiple letter args"
gnu_args = []
for arg in args:
# Fix if we have at least 3 chars where the first is a hyphen
# and the second is not a hyphen (e.g. -op becomes --op)
if len(arg) > 3 and a... | python | def add_gnu_argument(self, *args, **kwargs):
"Prevent the addition of any single hyphen, multiple letter args"
gnu_args = []
for arg in args:
# Fix if we have at least 3 chars where the first is a hyphen
# and the second is not a hyphen (e.g. -op becomes --op)
if len(arg) > 3 and a... | [
"def",
"add_gnu_argument",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"gnu_args",
"=",
"[",
"]",
"for",
"arg",
"in",
"args",
":",
"# Fix if we have at least 3 chars where the first is a hyphen",
"# and the second is not a hyphen (e.g. -op becomes ... | Prevent the addition of any single hyphen, multiple letter args | [
"Prevent",
"the",
"addition",
"of",
"any",
"single",
"hyphen",
"multiple",
"letter",
"args"
] | train | https://github.com/fprimex/plac_ini/blob/3f343d88326df9e5faf3a77fcffdd4ca3f5bec04/plac_ini.py#L81-L94 |
ipconfiger/result2 | example.py | get_valid_user_by_email | def get_valid_user_by_email(email):
"""
Return user instance
"""
user = get_user(email)
if user:
if user.valid is False:
return Err("user not valid")
return Ok(user)
return Err("user not exists") | python | def get_valid_user_by_email(email):
"""
Return user instance
"""
user = get_user(email)
if user:
if user.valid is False:
return Err("user not valid")
return Ok(user)
return Err("user not exists") | [
"def",
"get_valid_user_by_email",
"(",
"email",
")",
":",
"user",
"=",
"get_user",
"(",
"email",
")",
"if",
"user",
":",
"if",
"user",
".",
"valid",
"is",
"False",
":",
"return",
"Err",
"(",
"\"user not valid\"",
")",
"return",
"Ok",
"(",
"user",
")",
... | Return user instance | [
"Return",
"user",
"instance"
] | train | https://github.com/ipconfiger/result2/blob/7e05054cefd051bd5ae3d3199348c988af4bac7c/example.py#L6-L15 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.