partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | tabarray.saveSV | Save the tabarray to a single flat separated variable (CSV) text file.
Method wraps::
tabular.io.saveSV.
See docstring of tabular.io.saveSV, or Tabular reference documentation, for more information. | tabular/tab.py | def saveSV(self, fname, comments=None, metadata=None, printmetadict=None,
dialect = None, delimiter=None, doublequote=True,
lineterminator='\n', escapechar = None, quoting=csv.QUOTE_MINIMAL,
quotechar='"', skipinitialspace=False,
... | def saveSV(self, fname, comments=None, metadata=None, printmetadict=None,
dialect = None, delimiter=None, doublequote=True,
lineterminator='\n', escapechar = None, quoting=csv.QUOTE_MINIMAL,
quotechar='"', skipinitialspace=False,
... | [
"Save",
"the",
"tabarray",
"to",
"a",
"single",
"flat",
"separated",
"variable",
"(",
"CSV",
")",
"text",
"file",
".",
"Method",
"wraps",
"::"
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/tab.py#L675-L691 | [
"def",
"saveSV",
"(",
"self",
",",
"fname",
",",
"comments",
"=",
"None",
",",
"metadata",
"=",
"None",
",",
"printmetadict",
"=",
"None",
",",
"dialect",
"=",
"None",
",",
"delimiter",
"=",
"None",
",",
"doublequote",
"=",
"True",
",",
"lineterminator",... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | tabarray.savebinary | Save the tabarray to a numpy binary archive (``.npz``).
Save the tabarray to a ``.npz`` zipped file containing ``.npy`` binary
files for data, plus optionally coloring and/or rowdata or simply to a
``.npy`` binary file containing the data but no coloring or rowdata.
Method wr... | tabular/tab.py | def savebinary(self, fname, savecoloring=True):
"""
Save the tabarray to a numpy binary archive (``.npz``).
Save the tabarray to a ``.npz`` zipped file containing ``.npy`` binary
files for data, plus optionally coloring and/or rowdata or simply to a
``.npy`` binary fil... | def savebinary(self, fname, savecoloring=True):
"""
Save the tabarray to a numpy binary archive (``.npz``).
Save the tabarray to a ``.npz`` zipped file containing ``.npy`` binary
files for data, plus optionally coloring and/or rowdata or simply to a
``.npy`` binary fil... | [
"Save",
"the",
"tabarray",
"to",
"a",
"numpy",
"binary",
"archive",
"(",
".",
"npz",
")",
".",
"Save",
"the",
"tabarray",
"to",
"a",
".",
"npz",
"zipped",
"file",
"containing",
".",
"npy",
"binary",
"files",
"for",
"data",
"plus",
"optionally",
"coloring... | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/tab.py#L696-L709 | [
"def",
"savebinary",
"(",
"self",
",",
"fname",
",",
"savecoloring",
"=",
"True",
")",
":",
"io",
".",
"savebinary",
"(",
"fname",
"=",
"fname",
",",
"X",
"=",
"self",
",",
"savecoloring",
"=",
"savecoloring",
")"
] | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | tabarray.colstack | Horizontal stacking for tabarrays.
Stack tabarray(s) in `new` to the right of `self`.
**See also**
:func:`tabular.tabarray.tab_colstack`,
:func:`tabular.spreadsheet.colstack` | tabular/tab.py | def colstack(self, new, mode='abort'):
"""
Horizontal stacking for tabarrays.
Stack tabarray(s) in `new` to the right of `self`.
**See also**
:func:`tabular.tabarray.tab_colstack`,
:func:`tabular.spreadsheet.colstack`
"""
if isinstance... | def colstack(self, new, mode='abort'):
"""
Horizontal stacking for tabarrays.
Stack tabarray(s) in `new` to the right of `self`.
**See also**
:func:`tabular.tabarray.tab_colstack`,
:func:`tabular.spreadsheet.colstack`
"""
if isinstance... | [
"Horizontal",
"stacking",
"for",
"tabarrays",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/tab.py#L713-L728 | [
"def",
"colstack",
"(",
"self",
",",
"new",
",",
"mode",
"=",
"'abort'",
")",
":",
"if",
"isinstance",
"(",
"new",
",",
"list",
")",
":",
"return",
"tab_colstack",
"(",
"[",
"self",
"]",
"+",
"new",
",",
"mode",
")",
"else",
":",
"return",
"tab_col... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | tabarray.rowstack | Vertical stacking for tabarrays.
Stack tabarray(s) in `new` below `self`.
**See also**
:func:`tabular.tabarray.tab_rowstack`,
:func:`tabular.spreadsheet.rowstack` | tabular/tab.py | def rowstack(self, new, mode='nulls'):
"""
Vertical stacking for tabarrays.
Stack tabarray(s) in `new` below `self`.
**See also**
:func:`tabular.tabarray.tab_rowstack`,
:func:`tabular.spreadsheet.rowstack`
"""
if isinstance(new,list):
... | def rowstack(self, new, mode='nulls'):
"""
Vertical stacking for tabarrays.
Stack tabarray(s) in `new` below `self`.
**See also**
:func:`tabular.tabarray.tab_rowstack`,
:func:`tabular.spreadsheet.rowstack`
"""
if isinstance(new,list):
... | [
"Vertical",
"stacking",
"for",
"tabarrays",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/tab.py#L733-L748 | [
"def",
"rowstack",
"(",
"self",
",",
"new",
",",
"mode",
"=",
"'nulls'",
")",
":",
"if",
"isinstance",
"(",
"new",
",",
"list",
")",
":",
"return",
"tab_rowstack",
"(",
"[",
"self",
"]",
"+",
"new",
",",
"mode",
")",
"else",
":",
"return",
"tab_row... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | tabarray.aggregate | Aggregate a tabarray on columns for given functions.
Method wraps::
tabular.spreadsheet.aggregate(self, On, AggFuncDict, AggFunc, returnsort) | tabular/tab.py | def aggregate(self, On=None, AggFuncDict=None, AggFunc=None, AggList =
None, returnsort=False,KeepOthers=True, keyfuncdict=None):
"""
Aggregate a tabarray on columns for given functions.
Method wraps::
tabular.spreadsheet.aggregate(self, On, AggFuncDict, AggFu... | def aggregate(self, On=None, AggFuncDict=None, AggFunc=None, AggList =
None, returnsort=False,KeepOthers=True, keyfuncdict=None):
"""
Aggregate a tabarray on columns for given functions.
Method wraps::
tabular.spreadsheet.aggregate(self, On, AggFuncDict, AggFu... | [
"Aggregate",
"a",
"tabarray",
"on",
"columns",
"for",
"given",
"functions",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/tab.py#L753-L781 | [
"def",
"aggregate",
"(",
"self",
",",
"On",
"=",
"None",
",",
"AggFuncDict",
"=",
"None",
",",
"AggFunc",
"=",
"None",
",",
"AggList",
"=",
"None",
",",
"returnsort",
"=",
"False",
",",
"KeepOthers",
"=",
"True",
",",
"keyfuncdict",
"=",
"None",
")",
... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | tabarray.aggregate_in | Aggregate a tabarray and include original data in the result.
See the :func:`aggregate` method.
Method wraps::
tabular.summarize.aggregate_in(self, On, AggFuncDict, AggFunc, interspersed) | tabular/tab.py | def aggregate_in(self, On=None, AggFuncDict=None, AggFunc=None,
AggList=None, interspersed=True):
"""
Aggregate a tabarray and include original data in the result.
See the :func:`aggregate` method.
Method wraps::
tabular.summarize.aggregate_in(self, On... | def aggregate_in(self, On=None, AggFuncDict=None, AggFunc=None,
AggList=None, interspersed=True):
"""
Aggregate a tabarray and include original data in the result.
See the :func:`aggregate` method.
Method wraps::
tabular.summarize.aggregate_in(self, On... | [
"Aggregate",
"a",
"tabarray",
"and",
"include",
"original",
"data",
"in",
"the",
"result",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/tab.py#L785-L802 | [
"def",
"aggregate_in",
"(",
"self",
",",
"On",
"=",
"None",
",",
"AggFuncDict",
"=",
"None",
",",
"AggFunc",
"=",
"None",
",",
"AggList",
"=",
"None",
",",
"interspersed",
"=",
"True",
")",
":",
"data",
"=",
"spreadsheet",
".",
"aggregate_in",
"(",
"Da... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | tabarray.pivot | Pivot with `a` as the row axis and `b` values as the column axis.
Method wraps::
tabular.spreadsheet.pivot(X, a, b, Keep) | tabular/tab.py | def pivot(self, a, b, Keep=None, NullVals=None, order = None, prefix='_'):
"""
Pivot with `a` as the row axis and `b` values as the column axis.
Method wraps::
tabular.spreadsheet.pivot(X, a, b, Keep)
"""
[data,coloring] = spreadsheet.pivot(X=self, a=a, b=b, Ke... | def pivot(self, a, b, Keep=None, NullVals=None, order = None, prefix='_'):
"""
Pivot with `a` as the row axis and `b` values as the column axis.
Method wraps::
tabular.spreadsheet.pivot(X, a, b, Keep)
"""
[data,coloring] = spreadsheet.pivot(X=self, a=a, b=b, Ke... | [
"Pivot",
"with",
"a",
"as",
"the",
"row",
"axis",
"and",
"b",
"values",
"as",
"the",
"column",
"axis",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/tab.py#L807-L820 | [
"def",
"pivot",
"(",
"self",
",",
"a",
",",
"b",
",",
"Keep",
"=",
"None",
",",
"NullVals",
"=",
"None",
",",
"order",
"=",
"None",
",",
"prefix",
"=",
"'_'",
")",
":",
"[",
"data",
",",
"coloring",
"]",
"=",
"spreadsheet",
".",
"pivot",
"(",
"... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | tabarray.join | Wrapper for spreadsheet.join, but handles coloring attributes.
The `selfname` argument allows naming of `self` to be used if `ToMerge`
is a dictionary.
**See also:** :func:`tabular.spreadsheet.join`, :func:`tab_join` | tabular/tab.py | def join(self, ToMerge, keycols=None, nullvals=None,
renamer=None, returnrenaming=False, selfname=None, Names=None):
"""
Wrapper for spreadsheet.join, but handles coloring attributes.
The `selfname` argument allows naming of `self` to be used if `ToMerge`
is a dictionary.... | def join(self, ToMerge, keycols=None, nullvals=None,
renamer=None, returnrenaming=False, selfname=None, Names=None):
"""
Wrapper for spreadsheet.join, but handles coloring attributes.
The `selfname` argument allows naming of `self` to be used if `ToMerge`
is a dictionary.... | [
"Wrapper",
"for",
"spreadsheet",
".",
"join",
"but",
"handles",
"coloring",
"attributes",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/tab.py#L839-L867 | [
"def",
"join",
"(",
"self",
",",
"ToMerge",
",",
"keycols",
"=",
"None",
",",
"nullvals",
"=",
"None",
",",
"renamer",
"=",
"None",
",",
"returnrenaming",
"=",
"False",
",",
"selfname",
"=",
"None",
",",
"Names",
"=",
"None",
")",
":",
"if",
"isinsta... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | tabarray.argsort | Returns the indices that would sort an array.
.. note::
This method wraps `numpy.argsort`. This documentation is
modified from that of `numpy.argsort`.
Perform an indirect sort along the given axis using the algorithm
specified by the `kind` keyword. It ret... | tabular/tab.py | def argsort(self, axis=-1, kind='quicksort', order=None):
"""
Returns the indices that would sort an array.
.. note::
This method wraps `numpy.argsort`. This documentation is
modified from that of `numpy.argsort`.
Perform an indirect sort along the gi... | def argsort(self, axis=-1, kind='quicksort', order=None):
"""
Returns the indices that would sort an array.
.. note::
This method wraps `numpy.argsort`. This documentation is
modified from that of `numpy.argsort`.
Perform an indirect sort along the gi... | [
"Returns",
"the",
"indices",
"that",
"would",
"sort",
"an",
"array",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/tab.py#L869-L937 | [
"def",
"argsort",
"(",
"self",
",",
"axis",
"=",
"-",
"1",
",",
"kind",
"=",
"'quicksort'",
",",
"order",
"=",
"None",
")",
":",
"index_array",
"=",
"np",
".",
"core",
".",
"fromnumeric",
".",
"_wrapit",
"(",
"self",
",",
"'argsort'",
",",
"axis",
... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | validate_collection | Takes an `obj` that is a collection object.
`retain_deprecated` if False, then `obj` may be modified to replace
deprecated constructs with new syntax. If it is True, the `obj` will
not be modified.
Returns the pair:
errors, adaptor
`errors` is a simple list of error messages
`ada... | peyotl/collections_store/validation/__init__.py | def validate_collection(obj, retain_deprecated=True, **kwargs):
"""Takes an `obj` that is a collection object.
`retain_deprecated` if False, then `obj` may be modified to replace
deprecated constructs with new syntax. If it is True, the `obj` will
not be modified.
Returns the pair:
e... | def validate_collection(obj, retain_deprecated=True, **kwargs):
"""Takes an `obj` that is a collection object.
`retain_deprecated` if False, then `obj` may be modified to replace
deprecated constructs with new syntax. If it is True, the `obj` will
not be modified.
Returns the pair:
e... | [
"Takes",
"an",
"obj",
"that",
"is",
"a",
"collection",
"object",
".",
"retain_deprecated",
"if",
"False",
"then",
"obj",
"may",
"be",
"modified",
"to",
"replace",
"deprecated",
"constructs",
"with",
"new",
"syntax",
".",
"If",
"it",
"is",
"True",
"the",
"o... | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/collections_store/validation/__init__.py#L7-L22 | [
"def",
"validate_collection",
"(",
"obj",
",",
"retain_deprecated",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"# Gather and report errors in a simple list",
"errors",
"=",
"[",
"]",
"n",
"=",
"create_validation_adaptor",
"(",
"obj",
",",
"errors",
",",
"*"... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | JSGPattern.matches | Determine whether txt matches pattern
:param txt: text to check
:return: True if match | pyjsg/jsglib/jsg_strings.py | def matches(self, txt: str) -> bool:
"""Determine whether txt matches pattern
:param txt: text to check
:return: True if match
"""
# rval = ref.getText()[1:-1].encode('utf-8').decode('unicode-escape')
if r'\\u' in self.pattern_re.pattern:
txt = txt.encode('ut... | def matches(self, txt: str) -> bool:
"""Determine whether txt matches pattern
:param txt: text to check
:return: True if match
"""
# rval = ref.getText()[1:-1].encode('utf-8').decode('unicode-escape')
if r'\\u' in self.pattern_re.pattern:
txt = txt.encode('ut... | [
"Determine",
"whether",
"txt",
"matches",
"pattern"
] | hsolbrig/pyjsg | python | https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/jsglib/jsg_strings.py#L23-L33 | [
"def",
"matches",
"(",
"self",
",",
"txt",
":",
"str",
")",
"->",
"bool",
":",
"# rval = ref.getText()[1:-1].encode('utf-8').decode('unicode-escape')",
"if",
"r'\\\\u'",
"in",
"self",
".",
"pattern_re",
".",
"pattern",
":",
"txt",
"=",
"txt",
".",
"encode",
"(",... | 9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7 |
train | Point2HexColor | Return web-safe hex triplets. | tabular/colors.py | def Point2HexColor(a, lfrac, tfrac):
"""
Return web-safe hex triplets.
"""
[H,S,V] = [math.floor(360 * a), lfrac, tfrac]
RGB = hsvToRGB(H, S, V)
H = [hex(int(math.floor(255 * x))) for x in RGB]
HEX = [a[a.find('x') + 1:] for a in H]
HEX = ['0' + h if len(h) == 1 else h for h in HEX]... | def Point2HexColor(a, lfrac, tfrac):
"""
Return web-safe hex triplets.
"""
[H,S,V] = [math.floor(360 * a), lfrac, tfrac]
RGB = hsvToRGB(H, S, V)
H = [hex(int(math.floor(255 * x))) for x in RGB]
HEX = [a[a.find('x') + 1:] for a in H]
HEX = ['0' + h if len(h) == 1 else h for h in HEX]... | [
"Return",
"web",
"-",
"safe",
"hex",
"triplets",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/colors.py#L13-L28 | [
"def",
"Point2HexColor",
"(",
"a",
",",
"lfrac",
",",
"tfrac",
")",
":",
"[",
"H",
",",
"S",
",",
"V",
"]",
"=",
"[",
"math",
".",
"floor",
"(",
"360",
"*",
"a",
")",
",",
"lfrac",
",",
"tfrac",
"]",
"RGB",
"=",
"hsvToRGB",
"(",
"H",
",",
"... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | hsvToRGB | Convert HSV (hue, saturation, value) color space to RGB (red, green blue)
color space.
**Parameters**
**h** : float
Hue, a number in [0, 360].
**s** : float
Saturation, a number in [0, 1].
**v** : float
Va... | tabular/colors.py | def hsvToRGB(h, s, v):
"""
Convert HSV (hue, saturation, value) color space to RGB (red, green blue)
color space.
**Parameters**
**h** : float
Hue, a number in [0, 360].
**s** : float
Saturation, a number in [0, 1].
**v... | def hsvToRGB(h, s, v):
"""
Convert HSV (hue, saturation, value) color space to RGB (red, green blue)
color space.
**Parameters**
**h** : float
Hue, a number in [0, 360].
**s** : float
Saturation, a number in [0, 1].
**v... | [
"Convert",
"HSV",
"(",
"hue",
"saturation",
"value",
")",
"color",
"space",
"to",
"RGB",
"(",
"red",
"green",
"blue",
")",
"color",
"space",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/colors.py#L30-L73 | [
"def",
"hsvToRGB",
"(",
"h",
",",
"s",
",",
"v",
")",
":",
"hi",
"=",
"math",
".",
"floor",
"(",
"h",
"/",
"60.0",
")",
"%",
"6",
"f",
"=",
"(",
"h",
"/",
"60.0",
")",
"-",
"math",
".",
"floor",
"(",
"h",
"/",
"60.0",
")",
"p",
"=",
"v"... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | get_logger | Returns a logger with name set as given. See _read_logging_config for a description of the env var/config
file cascade that controls configuration of the logger. | peyotl/utility/get_logger.py | def get_logger(name="peyotl"):
"""Returns a logger with name set as given. See _read_logging_config for a description of the env var/config
file cascade that controls configuration of the logger.
"""
logger = logging.getLogger(name)
if len(logger.handlers) == 0:
log_init_warnings = []
... | def get_logger(name="peyotl"):
"""Returns a logger with name set as given. See _read_logging_config for a description of the env var/config
file cascade that controls configuration of the logger.
"""
logger = logging.getLogger(name)
if len(logger.handlers) == 0:
log_init_warnings = []
... | [
"Returns",
"a",
"logger",
"with",
"name",
"set",
"as",
"given",
".",
"See",
"_read_logging_config",
"for",
"a",
"description",
"of",
"the",
"env",
"var",
"/",
"config",
"file",
"cascade",
"that",
"controls",
"configuration",
"of",
"the",
"logger",
"."
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/utility/get_logger.py#L60-L82 | [
"def",
"get_logger",
"(",
"name",
"=",
"\"peyotl\"",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"name",
")",
"if",
"len",
"(",
"logger",
".",
"handlers",
")",
"==",
"0",
":",
"log_init_warnings",
"=",
"[",
"]",
"lc",
"=",
"_read_logging... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | warn_from_util_logger | Only to be used in this file and peyotl.utility.get_config | peyotl/utility/get_logger.py | def warn_from_util_logger(msg):
"""Only to be used in this file and peyotl.utility.get_config"""
global _LOG
# This check is necessary to avoid infinite recursion when called from get_config, because
# the _read_logging_conf can require reading a conf file.
if _LOG is None and _LOGGING_CONF is Non... | def warn_from_util_logger(msg):
"""Only to be used in this file and peyotl.utility.get_config"""
global _LOG
# This check is necessary to avoid infinite recursion when called from get_config, because
# the _read_logging_conf can require reading a conf file.
if _LOG is None and _LOGGING_CONF is Non... | [
"Only",
"to",
"be",
"used",
"in",
"this",
"file",
"and",
"peyotl",
".",
"utility",
".",
"get_config"
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/utility/get_logger.py#L85-L95 | [
"def",
"warn_from_util_logger",
"(",
"msg",
")",
":",
"global",
"_LOG",
"# This check is necessary to avoid infinite recursion when called from get_config, because",
"# the _read_logging_conf can require reading a conf file.",
"if",
"_LOG",
"is",
"None",
"and",
"_LOGGING_CONF",
"is... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | _logging_env_conf_overrides | Returns a dictionary that is empty or has a "logging" key that refers to
the (up to 3) key-value pairs that pertain to logging and are read from the env.
This is mainly a convenience function for ConfigWrapper so that it can accurately
report the source of the logging settings without | peyotl/utility/get_logger.py | def _logging_env_conf_overrides(log_init_warnings=None):
"""Returns a dictionary that is empty or has a "logging" key that refers to
the (up to 3) key-value pairs that pertain to logging and are read from the env.
This is mainly a convenience function for ConfigWrapper so that it can accurately
repo... | def _logging_env_conf_overrides(log_init_warnings=None):
"""Returns a dictionary that is empty or has a "logging" key that refers to
the (up to 3) key-value pairs that pertain to logging and are read from the env.
This is mainly a convenience function for ConfigWrapper so that it can accurately
repo... | [
"Returns",
"a",
"dictionary",
"that",
"is",
"empty",
"or",
"has",
"a",
"logging",
"key",
"that",
"refers",
"to",
"the",
"(",
"up",
"to",
"3",
")",
"key",
"-",
"value",
"pairs",
"that",
"pertain",
"to",
"logging",
"and",
"are",
"read",
"from",
"the",
... | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/utility/get_logger.py#L98-L135 | [
"def",
"_logging_env_conf_overrides",
"(",
"log_init_warnings",
"=",
"None",
")",
":",
"# This is called from a locked section of _read_logging_config, so don't call that function or you'll get deadlock",
"global",
"_LOGGING_ENV_CONF_OVERRIDES",
"if",
"_LOGGING_ENV_CONF_OVERRIDES",
"is",
... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | _read_logging_config | Returns a dictionary (should be treated as immutable) of settings needed to configure a logger.
If PEYOTL_LOGGING_LEVEL, PEYOTL_LOGGING_FORMAT, and PEYOTL_LOG_FILE_PATH are all in the env, then
no config file will be read.
If PEYOTL_LOG_FILE_PATH is set to an empty string, then stderr will be used.
... | peyotl/utility/get_logger.py | def _read_logging_config(log_init_warnings=None):
"""Returns a dictionary (should be treated as immutable) of settings needed to configure a logger.
If PEYOTL_LOGGING_LEVEL, PEYOTL_LOGGING_FORMAT, and PEYOTL_LOG_FILE_PATH are all in the env, then
no config file will be read.
If PEYOTL_LOG_FILE_PATH ... | def _read_logging_config(log_init_warnings=None):
"""Returns a dictionary (should be treated as immutable) of settings needed to configure a logger.
If PEYOTL_LOGGING_LEVEL, PEYOTL_LOGGING_FORMAT, and PEYOTL_LOG_FILE_PATH are all in the env, then
no config file will be read.
If PEYOTL_LOG_FILE_PATH ... | [
"Returns",
"a",
"dictionary",
"(",
"should",
"be",
"treated",
"as",
"immutable",
")",
"of",
"settings",
"needed",
"to",
"configure",
"a",
"logger",
".",
"If",
"PEYOTL_LOGGING_LEVEL",
"PEYOTL_LOGGING_FORMAT",
"and",
"PEYOTL_LOG_FILE_PATH",
"are",
"all",
"in",
"the"... | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/utility/get_logger.py#L138-L204 | [
"def",
"_read_logging_config",
"(",
"log_init_warnings",
"=",
"None",
")",
":",
"global",
"_LOGGING_CONF",
"from",
"peyotl",
".",
"utility",
".",
"get_config",
"import",
"get_config_object",
"if",
"_LOGGING_CONF",
"is",
"not",
"None",
":",
"return",
"_LOGGING_CONF",... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | PIFX.list_lights | Given a selector (defaults to all), return a list of lights.
Without a selector provided, return list of all lights. | pifx/core.py | def list_lights(self, selector='all'):
"""Given a selector (defaults to all), return a list of lights.
Without a selector provided, return list of all lights.
"""
return self.client.perform_request(
method='get', endpoint='lights/{}',
endpoint_args=[selector], pa... | def list_lights(self, selector='all'):
"""Given a selector (defaults to all), return a list of lights.
Without a selector provided, return list of all lights.
"""
return self.client.perform_request(
method='get', endpoint='lights/{}',
endpoint_args=[selector], pa... | [
"Given",
"a",
"selector",
"(",
"defaults",
"to",
"all",
")",
"return",
"a",
"list",
"of",
"lights",
".",
"Without",
"a",
"selector",
"provided",
"return",
"list",
"of",
"all",
"lights",
"."
] | cydrobolt/pifx | python | https://github.com/cydrobolt/pifx/blob/c9de9c2695c3e6e72de4aa0de47b78fc13c457c3/pifx/core.py#L26-L33 | [
"def",
"list_lights",
"(",
"self",
",",
"selector",
"=",
"'all'",
")",
":",
"return",
"self",
".",
"client",
".",
"perform_request",
"(",
"method",
"=",
"'get'",
",",
"endpoint",
"=",
"'lights/{}'",
",",
"endpoint_args",
"=",
"[",
"selector",
"]",
",",
"... | c9de9c2695c3e6e72de4aa0de47b78fc13c457c3 |
train | PIFX.set_state | Given a selector (defaults to all), set the state of a light.
Selector can be based on id, scene_id, group_id, label, etc.
Returns list of lightbulb statuses if successful.
See http://api.developer.lifx.com/v1/docs/selectors
selector: required String
The selector to limit wh... | pifx/core.py | def set_state(self, selector='all',
power=None, color=None, brightness=None, duration=None):
"""Given a selector (defaults to all), set the state of a light.
Selector can be based on id, scene_id, group_id, label, etc.
Returns list of lightbulb statuses if successful.
See http://... | def set_state(self, selector='all',
power=None, color=None, brightness=None, duration=None):
"""Given a selector (defaults to all), set the state of a light.
Selector can be based on id, scene_id, group_id, label, etc.
Returns list of lightbulb statuses if successful.
See http://... | [
"Given",
"a",
"selector",
"(",
"defaults",
"to",
"all",
")",
"set",
"the",
"state",
"of",
"a",
"light",
".",
"Selector",
"can",
"be",
"based",
"on",
"id",
"scene_id",
"group_id",
"label",
"etc",
".",
"Returns",
"list",
"of",
"lightbulb",
"statuses",
"if"... | cydrobolt/pifx | python | https://github.com/cydrobolt/pifx/blob/c9de9c2695c3e6e72de4aa0de47b78fc13c457c3/pifx/core.py#L35-L73 | [
"def",
"set_state",
"(",
"self",
",",
"selector",
"=",
"'all'",
",",
"power",
"=",
"None",
",",
"color",
"=",
"None",
",",
"brightness",
"=",
"None",
",",
"duration",
"=",
"None",
")",
":",
"argument_tuples",
"=",
"[",
"(",
"'power'",
",",
"power",
"... | c9de9c2695c3e6e72de4aa0de47b78fc13c457c3 |
train | PIFX.state_delta | Given a state delta, apply the modifications to lights' state
over a given period of time.
selector: required String
The selector to limit which lights are controlled.
power: String
The power state you want to set on the selector. on or off
duration: Double
... | pifx/core.py | def state_delta(self, selector='all',
power=None, duration=1.0, infrared=None, hue=None,
saturation=None, brightness=None, kelvin=None):
"""Given a state delta, apply the modifications to lights' state
over a given period of time.
selector: required String
The select... | def state_delta(self, selector='all',
power=None, duration=1.0, infrared=None, hue=None,
saturation=None, brightness=None, kelvin=None):
"""Given a state delta, apply the modifications to lights' state
over a given period of time.
selector: required String
The select... | [
"Given",
"a",
"state",
"delta",
"apply",
"the",
"modifications",
"to",
"lights",
"state",
"over",
"a",
"given",
"period",
"of",
"time",
"."
] | cydrobolt/pifx | python | https://github.com/cydrobolt/pifx/blob/c9de9c2695c3e6e72de4aa0de47b78fc13c457c3/pifx/core.py#L75-L122 | [
"def",
"state_delta",
"(",
"self",
",",
"selector",
"=",
"'all'",
",",
"power",
"=",
"None",
",",
"duration",
"=",
"1.0",
",",
"infrared",
"=",
"None",
",",
"hue",
"=",
"None",
",",
"saturation",
"=",
"None",
",",
"brightness",
"=",
"None",
",",
"kel... | c9de9c2695c3e6e72de4aa0de47b78fc13c457c3 |
train | PIFX.toggle_power | Given a selector and transition duration, toggle lights (on/off) | pifx/core.py | def toggle_power(self, selector='all', duration=1.0):
"""Given a selector and transition duration, toggle lights (on/off)"""
argument_tuples = [
("duration", duration)
]
return self.client.perform_request(
method='post', endpoint='lights/{}/toggle',
... | def toggle_power(self, selector='all', duration=1.0):
"""Given a selector and transition duration, toggle lights (on/off)"""
argument_tuples = [
("duration", duration)
]
return self.client.perform_request(
method='post', endpoint='lights/{}/toggle',
... | [
"Given",
"a",
"selector",
"and",
"transition",
"duration",
"toggle",
"lights",
"(",
"on",
"/",
"off",
")"
] | cydrobolt/pifx | python | https://github.com/cydrobolt/pifx/blob/c9de9c2695c3e6e72de4aa0de47b78fc13c457c3/pifx/core.py#L124-L133 | [
"def",
"toggle_power",
"(",
"self",
",",
"selector",
"=",
"'all'",
",",
"duration",
"=",
"1.0",
")",
":",
"argument_tuples",
"=",
"[",
"(",
"\"duration\"",
",",
"duration",
")",
"]",
"return",
"self",
".",
"client",
".",
"perform_request",
"(",
"method",
... | c9de9c2695c3e6e72de4aa0de47b78fc13c457c3 |
train | PIFX.breathe_lights | Perform breathe effect on lights.
selector: String
The selector to limit which lights will run the effect.
default: all
color: required String
Color attributes to use during effect. See set_state for more.
from_color: String
The color to start t... | pifx/core.py | def breathe_lights(self, color, selector='all',
from_color=None, period=1.0, cycles=1.0,
persist=False, power_on=True, peak=0.5):
"""Perform breathe effect on lights.
selector: String
The selector to limit which lights will run the effect.
default: all
c... | def breathe_lights(self, color, selector='all',
from_color=None, period=1.0, cycles=1.0,
persist=False, power_on=True, peak=0.5):
"""Perform breathe effect on lights.
selector: String
The selector to limit which lights will run the effect.
default: all
c... | [
"Perform",
"breathe",
"effect",
"on",
"lights",
"."
] | cydrobolt/pifx | python | https://github.com/cydrobolt/pifx/blob/c9de9c2695c3e6e72de4aa0de47b78fc13c457c3/pifx/core.py#L135-L186 | [
"def",
"breathe_lights",
"(",
"self",
",",
"color",
",",
"selector",
"=",
"'all'",
",",
"from_color",
"=",
"None",
",",
"period",
"=",
"1.0",
",",
"cycles",
"=",
"1.0",
",",
"persist",
"=",
"False",
",",
"power_on",
"=",
"True",
",",
"peak",
"=",
"0.... | c9de9c2695c3e6e72de4aa0de47b78fc13c457c3 |
train | PIFX.cycle_lights | Cycle through list of effects.
Provide array states as a list of dictionaries with set_state arguments.
See http://api.developer.lifx.com/docs/cycle
selector: String
The selector to limit which lights will run the effect.
default: all
states: required List of D... | pifx/core.py | def cycle_lights(self, states,
defaults, direction='forward', selector='all'):
"""Cycle through list of effects.
Provide array states as a list of dictionaries with set_state arguments.
See http://api.developer.lifx.com/docs/cycle
selector: String
The selector to li... | def cycle_lights(self, states,
defaults, direction='forward', selector='all'):
"""Cycle through list of effects.
Provide array states as a list of dictionaries with set_state arguments.
See http://api.developer.lifx.com/docs/cycle
selector: String
The selector to li... | [
"Cycle",
"through",
"list",
"of",
"effects",
"."
] | cydrobolt/pifx | python | https://github.com/cydrobolt/pifx/blob/c9de9c2695c3e6e72de4aa0de47b78fc13c457c3/pifx/core.py#L235-L266 | [
"def",
"cycle_lights",
"(",
"self",
",",
"states",
",",
"defaults",
",",
"direction",
"=",
"'forward'",
",",
"selector",
"=",
"'all'",
")",
":",
"argument_tuples",
"=",
"[",
"(",
"\"states\"",
",",
"states",
")",
",",
"(",
"\"defaults\"",
",",
"defaults",
... | c9de9c2695c3e6e72de4aa0de47b78fc13c457c3 |
train | PIFX.activate_scene | Activate a scene.
See http://api.developer.lifx.com/docs/activate-scene
scene_uuid: required String
The UUID for the scene you wish to activate
duration: Double
The time in seconds to spend performing the scene transition.
default: 1.0 | pifx/core.py | def activate_scene(self, scene_uuid, duration=1.0):
"""Activate a scene.
See http://api.developer.lifx.com/docs/activate-scene
scene_uuid: required String
The UUID for the scene you wish to activate
duration: Double
The time in seconds to spend performing the s... | def activate_scene(self, scene_uuid, duration=1.0):
"""Activate a scene.
See http://api.developer.lifx.com/docs/activate-scene
scene_uuid: required String
The UUID for the scene you wish to activate
duration: Double
The time in seconds to spend performing the s... | [
"Activate",
"a",
"scene",
"."
] | cydrobolt/pifx | python | https://github.com/cydrobolt/pifx/blob/c9de9c2695c3e6e72de4aa0de47b78fc13c457c3/pifx/core.py#L276-L295 | [
"def",
"activate_scene",
"(",
"self",
",",
"scene_uuid",
",",
"duration",
"=",
"1.0",
")",
":",
"argument_tuples",
"=",
"[",
"(",
"\"duration\"",
",",
"duration",
")",
",",
"]",
"return",
"self",
".",
"client",
".",
"perform_request",
"(",
"method",
"=",
... | c9de9c2695c3e6e72de4aa0de47b78fc13c457c3 |
train | JSGBuiltinValueType.visitBuiltinValueType | valueTypeExpr: JSON_STRING | JSON_NUMBER | JSON_INT | JSON_BOOL | JSON_NULL | JSON_ARRAY | JSON_OBJECT | pyjsg/parser_impl/jsg_builtinvaluetype_parser.py | def visitBuiltinValueType(self, ctx: jsgParser.BuiltinValueTypeContext):
""" valueTypeExpr: JSON_STRING | JSON_NUMBER | JSON_INT | JSON_BOOL | JSON_NULL | JSON_ARRAY | JSON_OBJECT """
self._value_type_text = ctx.getText()
self._typeinfo = self.parserTypeToImplClass[self._value_type_text] | def visitBuiltinValueType(self, ctx: jsgParser.BuiltinValueTypeContext):
""" valueTypeExpr: JSON_STRING | JSON_NUMBER | JSON_INT | JSON_BOOL | JSON_NULL | JSON_ARRAY | JSON_OBJECT """
self._value_type_text = ctx.getText()
self._typeinfo = self.parserTypeToImplClass[self._value_type_text] | [
"valueTypeExpr",
":",
"JSON_STRING",
"|",
"JSON_NUMBER",
"|",
"JSON_INT",
"|",
"JSON_BOOL",
"|",
"JSON_NULL",
"|",
"JSON_ARRAY",
"|",
"JSON_OBJECT"
] | hsolbrig/pyjsg | python | https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/parser_impl/jsg_builtinvaluetype_parser.py#L60-L63 | [
"def",
"visitBuiltinValueType",
"(",
"self",
",",
"ctx",
":",
"jsgParser",
".",
"BuiltinValueTypeContext",
")",
":",
"self",
".",
"_value_type_text",
"=",
"ctx",
".",
"getText",
"(",
")",
"self",
".",
"_typeinfo",
"=",
"self",
".",
"parserTypeToImplClass",
"["... | 9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7 |
train | count_num_trees | Returns the number of trees summed across all tree
groups. | peyotl/nexson_syntax/inspect.py | def count_num_trees(nexson, nexson_version=None):
"""Returns the number of trees summed across all tree
groups.
"""
if nexson_version is None:
nexson_version = detect_nexson_version(nexson)
nex = get_nexml_el(nexson)
num_trees_by_group = []
if _is_by_id_hbf(nexson_version):
f... | def count_num_trees(nexson, nexson_version=None):
"""Returns the number of trees summed across all tree
groups.
"""
if nexson_version is None:
nexson_version = detect_nexson_version(nexson)
nex = get_nexml_el(nexson)
num_trees_by_group = []
if _is_by_id_hbf(nexson_version):
f... | [
"Returns",
"the",
"number",
"of",
"trees",
"summed",
"across",
"all",
"tree",
"groups",
"."
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/nexson_syntax/inspect.py#L15-L38 | [
"def",
"count_num_trees",
"(",
"nexson",
",",
"nexson_version",
"=",
"None",
")",
":",
"if",
"nexson_version",
"is",
"None",
":",
"nexson_version",
"=",
"detect_nexson_version",
"(",
"nexson",
")",
"nex",
"=",
"get_nexml_el",
"(",
"nexson",
")",
"num_trees_by_gr... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | TreeCollectionStore | Factory function for a _TreeCollectionStore object.
A wrapper around the _TreeCollectionStore class instantiation for
the most common use case: a singleton _TreeCollectionStore.
If you need distinct _TreeCollectionStore objects, you'll need to
call that class directly. | peyotl/collections_store/collections_umbrella.py | def TreeCollectionStore(repos_dict=None,
repos_par=None,
with_caching=True,
assumed_doc_version=None,
git_ssh=None,
pkey=None,
git_action_class=TreeCollectionsGitAction,
... | def TreeCollectionStore(repos_dict=None,
repos_par=None,
with_caching=True,
assumed_doc_version=None,
git_ssh=None,
pkey=None,
git_action_class=TreeCollectionsGitAction,
... | [
"Factory",
"function",
"for",
"a",
"_TreeCollectionStore",
"object",
"."
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/collections_store/collections_umbrella.py#L287-L314 | [
"def",
"TreeCollectionStore",
"(",
"repos_dict",
"=",
"None",
",",
"repos_par",
"=",
"None",
",",
"with_caching",
"=",
"True",
",",
"assumed_doc_version",
"=",
"None",
",",
"git_ssh",
"=",
"None",
",",
"pkey",
"=",
"None",
",",
"git_action_class",
"=",
"Tree... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | _TreeCollectionStore.add_new_collection | Validate and save this JSON. Ensure (and return) a unique collection id | peyotl/collections_store/collections_umbrella.py | def add_new_collection(self,
owner_id,
json_repr,
auth_info,
collection_id=None,
commit_msg=''):
"""Validate and save this JSON. Ensure (and return) a unique collection id"""
... | def add_new_collection(self,
owner_id,
json_repr,
auth_info,
collection_id=None,
commit_msg=''):
"""Validate and save this JSON. Ensure (and return) a unique collection id"""
... | [
"Validate",
"and",
"save",
"this",
"JSON",
".",
"Ensure",
"(",
"and",
"return",
")",
"a",
"unique",
"collection",
"id"
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/collections_store/collections_umbrella.py#L134-L189 | [
"def",
"add_new_collection",
"(",
"self",
",",
"owner_id",
",",
"json_repr",
",",
"auth_info",
",",
"collection_id",
"=",
"None",
",",
"commit_msg",
"=",
"''",
")",
":",
"collection",
"=",
"self",
".",
"_coerce_json_to_collection",
"(",
"json_repr",
")",
"if",... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | _TreeCollectionStore.update_existing_collection | Validate and save this JSON. Ensure (and return) a unique collection id | peyotl/collections_store/collections_umbrella.py | def update_existing_collection(self,
owner_id,
collection_id=None,
json_repr=None,
auth_info=None,
parent_sha=None,
... | def update_existing_collection(self,
owner_id,
collection_id=None,
json_repr=None,
auth_info=None,
parent_sha=None,
... | [
"Validate",
"and",
"save",
"this",
"JSON",
".",
"Ensure",
"(",
"and",
"return",
")",
"a",
"unique",
"collection",
"id"
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/collections_store/collections_umbrella.py#L191-L228 | [
"def",
"update_existing_collection",
"(",
"self",
",",
"owner_id",
",",
"collection_id",
"=",
"None",
",",
"json_repr",
"=",
"None",
",",
"auth_info",
"=",
"None",
",",
"parent_sha",
"=",
"None",
",",
"merged_sha",
"=",
"None",
",",
"commit_msg",
"=",
"''",
... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | _TreeCollectionStore._slugify_internal_collection_name | Parse the JSON, find its name, return a slug of its name | peyotl/collections_store/collections_umbrella.py | def _slugify_internal_collection_name(self, json_repr):
"""Parse the JSON, find its name, return a slug of its name"""
collection = self._coerce_json_to_collection(json_repr)
if collection is None:
return None
internal_name = collection['name']
return slugify(internal... | def _slugify_internal_collection_name(self, json_repr):
"""Parse the JSON, find its name, return a slug of its name"""
collection = self._coerce_json_to_collection(json_repr)
if collection is None:
return None
internal_name = collection['name']
return slugify(internal... | [
"Parse",
"the",
"JSON",
"find",
"its",
"name",
"return",
"a",
"slug",
"of",
"its",
"name"
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/collections_store/collections_umbrella.py#L238-L244 | [
"def",
"_slugify_internal_collection_name",
"(",
"self",
",",
"json_repr",
")",
":",
"collection",
"=",
"self",
".",
"_coerce_json_to_collection",
"(",
"json_repr",
")",
"if",
"collection",
"is",
"None",
":",
"return",
"None",
"internal_name",
"=",
"collection",
"... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | _TreeCollectionStore._is_valid_collection_json | Call the primary validator for a quick test | peyotl/collections_store/collections_umbrella.py | def _is_valid_collection_json(self, json_repr):
"""Call the primary validator for a quick test"""
collection = self._coerce_json_to_collection(json_repr)
if collection is None:
# invalid JSON, definitely broken
return False
aa = validate_collection(collection)
... | def _is_valid_collection_json(self, json_repr):
"""Call the primary validator for a quick test"""
collection = self._coerce_json_to_collection(json_repr)
if collection is None:
# invalid JSON, definitely broken
return False
aa = validate_collection(collection)
... | [
"Call",
"the",
"primary",
"validator",
"for",
"a",
"quick",
"test"
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/collections_store/collections_umbrella.py#L255-L267 | [
"def",
"_is_valid_collection_json",
"(",
"self",
",",
"json_repr",
")",
":",
"collection",
"=",
"self",
".",
"_coerce_json_to_collection",
"(",
"json_repr",
")",
"if",
"collection",
"is",
"None",
":",
"# invalid JSON, definitely broken",
"return",
"False",
"aa",
"="... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | _TreeCollectionStore._coerce_json_to_collection | Use to ensure that a JSON string (if found) is parsed to the equivalent dict in python.
If the incoming value is already parsed, do nothing. If a string fails to parse, return None. | peyotl/collections_store/collections_umbrella.py | def _coerce_json_to_collection(self, json_repr):
"""Use to ensure that a JSON string (if found) is parsed to the equivalent dict in python.
If the incoming value is already parsed, do nothing. If a string fails to parse, return None."""
if isinstance(json_repr, dict):
collection = js... | def _coerce_json_to_collection(self, json_repr):
"""Use to ensure that a JSON string (if found) is parsed to the equivalent dict in python.
If the incoming value is already parsed, do nothing. If a string fails to parse, return None."""
if isinstance(json_repr, dict):
collection = js... | [
"Use",
"to",
"ensure",
"that",
"a",
"JSON",
"string",
"(",
"if",
"found",
")",
"is",
"parsed",
"to",
"the",
"equivalent",
"dict",
"in",
"python",
".",
"If",
"the",
"incoming",
"value",
"is",
"already",
"parsed",
"do",
"nothing",
".",
"If",
"a",
"string... | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/collections_store/collections_umbrella.py#L269-L280 | [
"def",
"_coerce_json_to_collection",
"(",
"self",
",",
"json_repr",
")",
":",
"if",
"isinstance",
"(",
"json_repr",
",",
"dict",
")",
":",
"collection",
"=",
"json_repr",
"else",
":",
"try",
":",
"collection",
"=",
"anyjson",
".",
"loads",
"(",
"json_repr",
... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | address | HTTP REQUEST
GET https://api.nasa.gov/planetary/earth/temperature/address
QUERY PARAMETERS
Parameter Type Default Description
text string n/a Address string
begin int 1880 beginning year for date range, inclusive
end int 2014 end year for date range, inclusive
api_key string DEMO_KEY api.... | bowshock/temperature_anomalies.py | def address(address=None, begin=None, end=None):
'''
HTTP REQUEST
GET https://api.nasa.gov/planetary/earth/temperature/address
QUERY PARAMETERS
Parameter Type Default Description
text string n/a Address string
begin int 1880 beginning year for date range, inclusive
end int 2014 end ye... | def address(address=None, begin=None, end=None):
'''
HTTP REQUEST
GET https://api.nasa.gov/planetary/earth/temperature/address
QUERY PARAMETERS
Parameter Type Default Description
text string n/a Address string
begin int 1880 beginning year for date range, inclusive
end int 2014 end ye... | [
"HTTP",
"REQUEST"
] | emirozer/bowshock | python | https://github.com/emirozer/bowshock/blob/9f5e053f1d54995b833b83616f37c67178c3e840/bowshock/temperature_anomalies.py#L12-L61 | [
"def",
"address",
"(",
"address",
"=",
"None",
",",
"begin",
"=",
"None",
",",
"end",
"=",
"None",
")",
":",
"base_url",
"=",
"\"https://api.nasa.gov/planetary/earth/temperature/address?\"",
"if",
"not",
"address",
":",
"raise",
"ValueError",
"(",
"\"address is mi... | 9f5e053f1d54995b833b83616f37c67178c3e840 |
train | coordinate | HTTP REQUEST
GET https://api.nasa.gov/planetary/earth/temperature/coords
QUERY PARAMETERS
Parameter Type Default Description
lat float n/a Latitude
lon float n/a Longitude
begin int 1880 beginning year for date range, inclusive
end int 2014 end year for date range, inclusive
api_key s... | bowshock/temperature_anomalies.py | def coordinate(lon=None, lat=None, begin=None, end=None):
'''
HTTP REQUEST
GET https://api.nasa.gov/planetary/earth/temperature/coords
QUERY PARAMETERS
Parameter Type Default Description
lat float n/a Latitude
lon float n/a Longitude
begin int 1880 beginning year for date range, inclu... | def coordinate(lon=None, lat=None, begin=None, end=None):
'''
HTTP REQUEST
GET https://api.nasa.gov/planetary/earth/temperature/coords
QUERY PARAMETERS
Parameter Type Default Description
lat float n/a Latitude
lon float n/a Longitude
begin int 1880 beginning year for date range, inclu... | [
"HTTP",
"REQUEST"
] | emirozer/bowshock | python | https://github.com/emirozer/bowshock/blob/9f5e053f1d54995b833b83616f37c67178c3e840/bowshock/temperature_anomalies.py#L64-L125 | [
"def",
"coordinate",
"(",
"lon",
"=",
"None",
",",
"lat",
"=",
"None",
",",
"begin",
"=",
"None",
",",
"end",
"=",
"None",
")",
":",
"base_url",
"=",
"\"https://api.nasa.gov/planetary/earth/temperature/coords?\"",
"if",
"not",
"lon",
"or",
"not",
"lat",
":",... | 9f5e053f1d54995b833b83616f37c67178c3e840 |
train | discover_roku | Search LAN for available Roku devices. Returns a Roku object. | rokucli/discover.py | def discover_roku():
""" Search LAN for available Roku devices. Returns a Roku object. """
print("Searching for Roku devices within LAN ...")
rokus = Roku.discover()
if not rokus:
print("Unable to discover Roku devices. " +
"Try again, or manually specify the IP address with " +
... | def discover_roku():
""" Search LAN for available Roku devices. Returns a Roku object. """
print("Searching for Roku devices within LAN ...")
rokus = Roku.discover()
if not rokus:
print("Unable to discover Roku devices. " +
"Try again, or manually specify the IP address with " +
... | [
"Search",
"LAN",
"for",
"available",
"Roku",
"devices",
".",
"Returns",
"a",
"Roku",
"object",
"."
] | ncmiller/roku-cli | python | https://github.com/ncmiller/roku-cli/blob/9101952edf9802146c794e63353abf2bf116c052/rokucli/discover.py#L6-L42 | [
"def",
"discover_roku",
"(",
")",
":",
"print",
"(",
"\"Searching for Roku devices within LAN ...\"",
")",
"rokus",
"=",
"Roku",
".",
"discover",
"(",
")",
"if",
"not",
"rokus",
":",
"print",
"(",
"\"Unable to discover Roku devices. \"",
"+",
"\"Try again, or manually... | 9101952edf9802146c794e63353abf2bf116c052 |
train | ot_tnrs_match_names | Uses a peyotl wrapper around an Open Tree web service to get a list of OTT IDs matching
the `name_list`.
The tnrs_wrapper can be None (in which case the default wrapper from peyotl.sugar will be used.
All other arguments correspond to the arguments of the web-service call.
A ValueError will be raised if... | tutorials/ot-info-for-taxon-name.py | def ot_tnrs_match_names(name_list,
context_name=None,
do_approximate_matching=True,
include_dubious=False,
include_deprecated=True,
tnrs_wrapper=None):
"""Uses a peyotl wrapper around an Open Tree... | def ot_tnrs_match_names(name_list,
context_name=None,
do_approximate_matching=True,
include_dubious=False,
include_deprecated=True,
tnrs_wrapper=None):
"""Uses a peyotl wrapper around an Open Tree... | [
"Uses",
"a",
"peyotl",
"wrapper",
"around",
"an",
"Open",
"Tree",
"web",
"service",
"to",
"get",
"a",
"list",
"of",
"OTT",
"IDs",
"matching",
"the",
"name_list",
".",
"The",
"tnrs_wrapper",
"can",
"be",
"None",
"(",
"in",
"which",
"case",
"the",
"default... | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/tutorials/ot-info-for-taxon-name.py#L10-L33 | [
"def",
"ot_tnrs_match_names",
"(",
"name_list",
",",
"context_name",
"=",
"None",
",",
"do_approximate_matching",
"=",
"True",
",",
"include_dubious",
"=",
"False",
",",
"include_deprecated",
"=",
"True",
",",
"tnrs_wrapper",
"=",
"None",
")",
":",
"if",
"tnrs_w... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | write_taxon_info | Writes out data from `taxon` to the `output` stream to demonstrate
the attributes of a taxon object.
(currently some lines are commented out until the web-services call returns more info. See:
https://github.com/OpenTreeOfLife/taxomachine/issues/85
).
If `include_anc` is True, then ancestor info... | tutorials/ot-info-for-taxon-name.py | def write_taxon_info(taxon, include_anc, output):
"""Writes out data from `taxon` to the `output` stream to demonstrate
the attributes of a taxon object.
(currently some lines are commented out until the web-services call returns more info. See:
https://github.com/OpenTreeOfLife/taxomachine/issues/8... | def write_taxon_info(taxon, include_anc, output):
"""Writes out data from `taxon` to the `output` stream to demonstrate
the attributes of a taxon object.
(currently some lines are commented out until the web-services call returns more info. See:
https://github.com/OpenTreeOfLife/taxomachine/issues/8... | [
"Writes",
"out",
"data",
"from",
"taxon",
"to",
"the",
"output",
"stream",
"to",
"demonstrate",
"the",
"attributes",
"of",
"a",
"taxon",
"object",
".",
"(",
"currently",
"some",
"lines",
"are",
"commented",
"out",
"until",
"the",
"web",
"-",
"services",
"c... | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/tutorials/ot-info-for-taxon-name.py#L47-L71 | [
"def",
"write_taxon_info",
"(",
"taxon",
",",
"include_anc",
",",
"output",
")",
":",
"output",
".",
"write",
"(",
"'Taxon info for OTT ID (ot:ottId) = {}\\n'",
".",
"format",
"(",
"taxon",
".",
"ott_id",
")",
")",
"output",
".",
"write",
"(",
"' name (ot:ott... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | match_and_print | Demonstrates how to read the response from a match_names query when peyotl's wrap_response option is
used.
If the context_name is not recognized, the attempt to match_names will generate a ValueError exception.
Here this is caught, and we call the tnrs/contexts web service to get the list of valid context_... | tutorials/ot-info-for-taxon-name.py | def match_and_print(name_list, context_name, do_approximate_matching, include_dubious, include_deprecated,
include_subtree, output):
"""Demonstrates how to read the response from a match_names query when peyotl's wrap_response option is
used.
If the context_name is not recognized, the a... | def match_and_print(name_list, context_name, do_approximate_matching, include_dubious, include_deprecated,
include_subtree, output):
"""Demonstrates how to read the response from a match_names query when peyotl's wrap_response option is
used.
If the context_name is not recognized, the a... | [
"Demonstrates",
"how",
"to",
"read",
"the",
"response",
"from",
"a",
"match_names",
"query",
"when",
"peyotl",
"s",
"wrap_response",
"option",
"is",
"used",
"."
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/tutorials/ot-info-for-taxon-name.py#L74-L160 | [
"def",
"match_and_print",
"(",
"name_list",
",",
"context_name",
",",
"do_approximate_matching",
",",
"include_dubious",
",",
"include_deprecated",
",",
"include_subtree",
",",
"output",
")",
":",
"from",
"peyotl",
".",
"sugar",
"import",
"tnrs",
"try",
":",
"# Pe... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | main | This function sets up a command-line option parser and then calls match_and_print
to do all of the real work. | tutorials/ot-info-for-taxon-name.py | def main(argv):
"""This function sets up a command-line option parser and then calls match_and_print
to do all of the real work.
"""
import argparse
description = 'Uses Open Tree of Life web services to try to find a taxon ID for each name supplied. ' \
'Using a --context-name=NAME... | def main(argv):
"""This function sets up a command-line option parser and then calls match_and_print
to do all of the real work.
"""
import argparse
description = 'Uses Open Tree of Life web services to try to find a taxon ID for each name supplied. ' \
'Using a --context-name=NAME... | [
"This",
"function",
"sets",
"up",
"a",
"command",
"-",
"line",
"option",
"parser",
"and",
"then",
"calls",
"match_and_print",
"to",
"do",
"all",
"of",
"the",
"real",
"work",
"."
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/tutorials/ot-info-for-taxon-name.py#L163-L206 | [
"def",
"main",
"(",
"argv",
")",
":",
"import",
"argparse",
"description",
"=",
"'Uses Open Tree of Life web services to try to find a taxon ID for each name supplied. '",
"'Using a --context-name=NAME to provide a limited taxonomic context and using the '",
"' --prohibit-fuzzy-matching opti... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | _objectify | Make `value` suitable for a binding object.
If `value` is an Entity, call to_obj() on it. Otherwise, pass it
off to the TypedField for an appropriate value. | mixbox/entities.py | def _objectify(field, value, ns_info):
"""Make `value` suitable for a binding object.
If `value` is an Entity, call to_obj() on it. Otherwise, pass it
off to the TypedField for an appropriate value.
"""
if (getattr(field.type_, "_treat_none_as_empty_list", False) and
value is None):
... | def _objectify(field, value, ns_info):
"""Make `value` suitable for a binding object.
If `value` is an Entity, call to_obj() on it. Otherwise, pass it
off to the TypedField for an appropriate value.
"""
if (getattr(field.type_, "_treat_none_as_empty_list", False) and
value is None):
... | [
"Make",
"value",
"suitable",
"for",
"a",
"binding",
"object",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/entities.py#L19-L33 | [
"def",
"_objectify",
"(",
"field",
",",
"value",
",",
"ns_info",
")",
":",
"if",
"(",
"getattr",
"(",
"field",
".",
"type_",
",",
"\"_treat_none_as_empty_list\"",
",",
"False",
")",
"and",
"value",
"is",
"None",
")",
":",
"return",
"[",
"]",
"if",
"val... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | _dictify | Make `value` suitable for a dictionary.
* If `value` is an Entity, call to_dict() on it.
* If value is a timestamp, turn it into a string value.
* If none of the above are satisfied, return the input value | mixbox/entities.py | def _dictify(field, value):
"""Make `value` suitable for a dictionary.
* If `value` is an Entity, call to_dict() on it.
* If value is a timestamp, turn it into a string value.
* If none of the above are satisfied, return the input value
"""
if value is None:
return None
elif field.t... | def _dictify(field, value):
"""Make `value` suitable for a dictionary.
* If `value` is an Entity, call to_dict() on it.
* If value is a timestamp, turn it into a string value.
* If none of the above are satisfied, return the input value
"""
if value is None:
return None
elif field.t... | [
"Make",
"value",
"suitable",
"for",
"a",
"dictionary",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/entities.py#L36-L47 | [
"def",
"_dictify",
"(",
"field",
",",
"value",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"None",
"elif",
"field",
".",
"type_",
":",
"return",
"value",
".",
"to_dict",
"(",
")",
"return",
"field",
".",
"dict_value",
"(",
"value",
")"
] | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | EntityFactory.instance | Create an instance of the class associated with the `key` (xsi:type)
and initialize it with the *args and **kwargs.
Args:
key: A class lookup key (see entity_class()).
Returns:
An instance of the class associated with the `key`. | mixbox/entities.py | def instance(cls, key, *args, **kwargs):
"""Create an instance of the class associated with the `key` (xsi:type)
and initialize it with the *args and **kwargs.
Args:
key: A class lookup key (see entity_class()).
Returns:
An instance of the class associated with ... | def instance(cls, key, *args, **kwargs):
"""Create an instance of the class associated with the `key` (xsi:type)
and initialize it with the *args and **kwargs.
Args:
key: A class lookup key (see entity_class()).
Returns:
An instance of the class associated with ... | [
"Create",
"an",
"instance",
"of",
"the",
"class",
"associated",
"with",
"the",
"key",
"(",
"xsi",
":",
"type",
")",
"and",
"initialize",
"it",
"with",
"the",
"*",
"args",
"and",
"**",
"kwargs",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/entities.py#L92-L103 | [
"def",
"instance",
"(",
"cls",
",",
"key",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"klass",
"=",
"cls",
".",
"entity_class",
"(",
"key",
")",
"return",
"klass",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | EntityFactory.from_dict | Parse the dictionary and return an Entity instance.
This will attempt to extract type information from the input
dictionary and pass it to entity_class to resolve the correct class
for the type.
Args:
cls_dict: A dictionary representation of an Entity object.
fa... | mixbox/entities.py | def from_dict(cls, cls_dict, fallback_xsi_type=None):
"""Parse the dictionary and return an Entity instance.
This will attempt to extract type information from the input
dictionary and pass it to entity_class to resolve the correct class
for the type.
Args:
cls_dict... | def from_dict(cls, cls_dict, fallback_xsi_type=None):
"""Parse the dictionary and return an Entity instance.
This will attempt to extract type information from the input
dictionary and pass it to entity_class to resolve the correct class
for the type.
Args:
cls_dict... | [
"Parse",
"the",
"dictionary",
"and",
"return",
"an",
"Entity",
"instance",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/entities.py#L137-L164 | [
"def",
"from_dict",
"(",
"cls",
",",
"cls_dict",
",",
"fallback_xsi_type",
"=",
"None",
")",
":",
"if",
"not",
"cls_dict",
":",
"return",
"None",
"if",
"isinstance",
"(",
"cls_dict",
",",
"six",
".",
"string_types",
")",
":",
"if",
"not",
"getattr",
"(",... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | EntityFactory.from_obj | Parse the generateDS object and return an Entity instance.
This will attempt to extract type information from the input
object and pass it to entity_class to resolve the correct class
for the type.
Args:
cls_obj: A generateDS object.
Returns:
An Entity ... | mixbox/entities.py | def from_obj(cls, cls_obj):
"""Parse the generateDS object and return an Entity instance.
This will attempt to extract type information from the input
object and pass it to entity_class to resolve the correct class
for the type.
Args:
cls_obj: A generateDS object.
... | def from_obj(cls, cls_obj):
"""Parse the generateDS object and return an Entity instance.
This will attempt to extract type information from the input
object and pass it to entity_class to resolve the correct class
for the type.
Args:
cls_obj: A generateDS object.
... | [
"Parse",
"the",
"generateDS",
"object",
"and",
"return",
"an",
"Entity",
"instance",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/entities.py#L167-L185 | [
"def",
"from_obj",
"(",
"cls",
",",
"cls_obj",
")",
":",
"if",
"not",
"cls_obj",
":",
"return",
"None",
"typekey",
"=",
"cls",
".",
"objkey",
"(",
"cls_obj",
")",
"klass",
"=",
"cls",
".",
"entity_class",
"(",
"typekey",
")",
"return",
"klass",
".",
... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | Entity.typed_fields | Return a tuple of this entity's TypedFields. | mixbox/entities.py | def typed_fields(cls):
"""Return a tuple of this entity's TypedFields."""
# Checking cls._typed_fields could return a superclass _typed_fields
# value. So we check our class __dict__ which does not include
# inherited attributes.
klassdict = cls.__dict__
try:
... | def typed_fields(cls):
"""Return a tuple of this entity's TypedFields."""
# Checking cls._typed_fields could return a superclass _typed_fields
# value. So we check our class __dict__ which does not include
# inherited attributes.
klassdict = cls.__dict__
try:
... | [
"Return",
"a",
"tuple",
"of",
"this",
"entity",
"s",
"TypedFields",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/entities.py#L201-L214 | [
"def",
"typed_fields",
"(",
"cls",
")",
":",
"# Checking cls._typed_fields could return a superclass _typed_fields",
"# value. So we check our class __dict__ which does not include",
"# inherited attributes.",
"klassdict",
"=",
"cls",
".",
"__dict__",
"try",
":",
"return",
"klassdi... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | Entity.typed_fields_with_attrnames | Return a list of (TypedField attribute name, TypedField object)
tuples for this Entity. | mixbox/entities.py | def typed_fields_with_attrnames(cls):
"""Return a list of (TypedField attribute name, TypedField object)
tuples for this Entity.
"""
# Checking cls._typed_fields could return a superclass _typed_fields
# value. So we check our class __dict__ which does not include
# inher... | def typed_fields_with_attrnames(cls):
"""Return a list of (TypedField attribute name, TypedField object)
tuples for this Entity.
"""
# Checking cls._typed_fields could return a superclass _typed_fields
# value. So we check our class __dict__ which does not include
# inher... | [
"Return",
"a",
"list",
"of",
"(",
"TypedField",
"attribute",
"name",
"TypedField",
"object",
")",
"tuples",
"for",
"this",
"Entity",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/entities.py#L217-L234 | [
"def",
"typed_fields_with_attrnames",
"(",
"cls",
")",
":",
"# Checking cls._typed_fields could return a superclass _typed_fields",
"# value. So we check our class __dict__ which does not include",
"# inherited attributes.",
"klassdict",
"=",
"cls",
".",
"__dict__",
"try",
":",
"retu... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | Entity.to_obj | Convert to a GenerateDS binding object.
Subclasses can override this function.
Returns:
An instance of this Entity's ``_binding_class`` with properties
set from this Entity. | mixbox/entities.py | def to_obj(self, ns_info=None):
"""Convert to a GenerateDS binding object.
Subclasses can override this function.
Returns:
An instance of this Entity's ``_binding_class`` with properties
set from this Entity.
"""
if ns_info:
ns_info.collect(s... | def to_obj(self, ns_info=None):
"""Convert to a GenerateDS binding object.
Subclasses can override this function.
Returns:
An instance of this Entity's ``_binding_class`` with properties
set from this Entity.
"""
if ns_info:
ns_info.collect(s... | [
"Convert",
"to",
"a",
"GenerateDS",
"binding",
"object",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/entities.py#L275-L309 | [
"def",
"to_obj",
"(",
"self",
",",
"ns_info",
"=",
"None",
")",
":",
"if",
"ns_info",
":",
"ns_info",
".",
"collect",
"(",
"self",
")",
"# null behavior for classes that inherit from Entity but do not",
"# have _binding_class",
"if",
"not",
"hasattr",
"(",
"self",
... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | Entity.to_dict | Convert to a ``dict``
Subclasses can override this function.
Returns:
Python dict with keys set from this Entity. | mixbox/entities.py | def to_dict(self):
"""Convert to a ``dict``
Subclasses can override this function.
Returns:
Python dict with keys set from this Entity.
"""
entity_dict = {}
for field, val in six.iteritems(self._fields):
if field.multiple:
if val... | def to_dict(self):
"""Convert to a ``dict``
Subclasses can override this function.
Returns:
Python dict with keys set from this Entity.
"""
entity_dict = {}
for field, val in six.iteritems(self._fields):
if field.multiple:
if val... | [
"Convert",
"to",
"a",
"dict"
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/entities.py#L318-L343 | [
"def",
"to_dict",
"(",
"self",
")",
":",
"entity_dict",
"=",
"{",
"}",
"for",
"field",
",",
"val",
"in",
"six",
".",
"iteritems",
"(",
"self",
".",
"_fields",
")",
":",
"if",
"field",
".",
"multiple",
":",
"if",
"val",
":",
"val",
"=",
"[",
"_dic... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | Entity.to_xml | Serializes a :class:`Entity` instance to an XML string.
The default character encoding is ``utf-8`` and can be set via the
`encoding` parameter.
If `encoding` is ``None``, a unicode string is returned. That is, a
:class:`unicode` in Python 2 and a :class:`str` in Python 3.
Not... | mixbox/entities.py | def to_xml(self, include_namespaces=True, namespace_dict=None,
pretty=True, encoding="utf-8"):
"""Serializes a :class:`Entity` instance to an XML string.
The default character encoding is ``utf-8`` and can be set via the
`encoding` parameter.
If `encoding` is ``None``, a... | def to_xml(self, include_namespaces=True, namespace_dict=None,
pretty=True, encoding="utf-8"):
"""Serializes a :class:`Entity` instance to an XML string.
The default character encoding is ``utf-8`` and can be set via the
`encoding` parameter.
If `encoding` is ``None``, a... | [
"Serializes",
"a",
":",
"class",
":",
"Entity",
"instance",
"to",
"an",
"XML",
"string",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/entities.py#L425-L483 | [
"def",
"to_xml",
"(",
"self",
",",
"include_namespaces",
"=",
"True",
",",
"namespace_dict",
"=",
"None",
",",
"pretty",
"=",
"True",
",",
"encoding",
"=",
"\"utf-8\"",
")",
":",
"namespace_def",
"=",
"\"\"",
"ns_collector",
"=",
"NamespaceCollector",
"(",
"... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | Entity.from_json | Parse a JSON string and build an entity. | mixbox/entities.py | def from_json(cls, json_doc):
"""Parse a JSON string and build an entity."""
try:
d = json.load(json_doc)
except AttributeError: # catch the read() error
d = json.loads(json_doc)
return cls.from_dict(d) | def from_json(cls, json_doc):
"""Parse a JSON string and build an entity."""
try:
d = json.load(json_doc)
except AttributeError: # catch the read() error
d = json.loads(json_doc)
return cls.from_dict(d) | [
"Parse",
"a",
"JSON",
"string",
"and",
"build",
"an",
"entity",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/entities.py#L490-L497 | [
"def",
"from_json",
"(",
"cls",
",",
"json_doc",
")",
":",
"try",
":",
"d",
"=",
"json",
".",
"load",
"(",
"json_doc",
")",
"except",
"AttributeError",
":",
"# catch the read() error",
"d",
"=",
"json",
".",
"loads",
"(",
"json_doc",
")",
"return",
"cls"... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | EntityList._multiple_field | Return the "multiple" TypedField associated with this EntityList.
This also lazily sets the ``_entitylist_multiplefield`` value if it
hasn't been set yet. This is set to a tuple containing one item because
if we set the class attribute to the TypedField, we would effectively
add a Typed... | mixbox/entities.py | def _multiple_field(cls):
"""Return the "multiple" TypedField associated with this EntityList.
This also lazily sets the ``_entitylist_multiplefield`` value if it
hasn't been set yet. This is set to a tuple containing one item because
if we set the class attribute to the TypedField, we ... | def _multiple_field(cls):
"""Return the "multiple" TypedField associated with this EntityList.
This also lazily sets the ``_entitylist_multiplefield`` value if it
hasn't been set yet. This is set to a tuple containing one item because
if we set the class attribute to the TypedField, we ... | [
"Return",
"the",
"multiple",
"TypedField",
"associated",
"with",
"this",
"EntityList",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/entities.py#L594-L628 | [
"def",
"_multiple_field",
"(",
"cls",
")",
":",
"klassdict",
"=",
"cls",
".",
"__dict__",
"try",
":",
"# Checking for cls.entitylist_multifield would return any inherited",
"# values, so we check the class __dict__ explicitly.",
"return",
"klassdict",
"[",
"\"_entitylist_multifie... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | NamespaceCollector._fix_example_namespace | Attempts to resolve issues where our samples use
'http://example.com/' for our example namespace but python-stix uses
'http://example.com' by removing the former. | mixbox/entities.py | def _fix_example_namespace(self):
"""Attempts to resolve issues where our samples use
'http://example.com/' for our example namespace but python-stix uses
'http://example.com' by removing the former.
"""
example_prefix = 'example' # Example ns prefix
idgen_prefix = idgen... | def _fix_example_namespace(self):
"""Attempts to resolve issues where our samples use
'http://example.com/' for our example namespace but python-stix uses
'http://example.com' by removing the former.
"""
example_prefix = 'example' # Example ns prefix
idgen_prefix = idgen... | [
"Attempts",
"to",
"resolve",
"issues",
"where",
"our",
"samples",
"use",
"http",
":",
"//",
"example",
".",
"com",
"/",
"for",
"our",
"example",
"namespace",
"but",
"python",
"-",
"stix",
"uses",
"http",
":",
"//",
"example",
".",
"com",
"by",
"removing"... | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/entities.py#L777-L794 | [
"def",
"_fix_example_namespace",
"(",
"self",
")",
":",
"example_prefix",
"=",
"'example'",
"# Example ns prefix",
"idgen_prefix",
"=",
"idgen",
".",
"get_id_namespace_prefix",
"(",
")",
"# If the ID namespace alias doesn't match the example alias, return.",
"if",
"idgen_prefix... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | NamespaceCollector._finalize_namespaces | Returns a dictionary of namespaces to be exported with an XML
document.
This loops over all the namespaces that were discovered and built
during the execution of ``collect()`` and
``_parse_collected_classes()`` and attempts to merge them all.
Raises:
.namespaces.Dup... | mixbox/entities.py | def _finalize_namespaces(self, ns_dict=None):
"""Returns a dictionary of namespaces to be exported with an XML
document.
This loops over all the namespaces that were discovered and built
during the execution of ``collect()`` and
``_parse_collected_classes()`` and attempts to mer... | def _finalize_namespaces(self, ns_dict=None):
"""Returns a dictionary of namespaces to be exported with an XML
document.
This loops over all the namespaces that were discovered and built
during the execution of ``collect()`` and
``_parse_collected_classes()`` and attempts to mer... | [
"Returns",
"a",
"dictionary",
"of",
"namespaces",
"to",
"be",
"exported",
"with",
"an",
"XML",
"document",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/entities.py#L796-L856 | [
"def",
"_finalize_namespaces",
"(",
"self",
",",
"ns_dict",
"=",
"None",
")",
":",
"if",
"ns_dict",
":",
"# Add the user's entries to our set",
"for",
"ns",
",",
"alias",
"in",
"six",
".",
"iteritems",
"(",
"ns_dict",
")",
":",
"self",
".",
"_collected_namespa... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | element_conforms | Determine whether element conforms to etype | pyjsg/jsglib/conformance.py | def element_conforms(element, etype) -> bool:
""" Determine whether element conforms to etype"""
from pyjsg.jsglib import Empty
if isinstance(element, etype):
return True
# This catches the Optional[] idiom
if (element is None or element is Empty) and issubclass(etype, type(None)):
... | def element_conforms(element, etype) -> bool:
""" Determine whether element conforms to etype"""
from pyjsg.jsglib import Empty
if isinstance(element, etype):
return True
# This catches the Optional[] idiom
if (element is None or element is Empty) and issubclass(etype, type(None)):
... | [
"Determine",
"whether",
"element",
"conforms",
"to",
"etype"
] | hsolbrig/pyjsg | python | https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/jsglib/conformance.py#L9-L25 | [
"def",
"element_conforms",
"(",
"element",
",",
"etype",
")",
"->",
"bool",
":",
"from",
"pyjsg",
".",
"jsglib",
"import",
"Empty",
"if",
"isinstance",
"(",
"element",
",",
"etype",
")",
":",
"return",
"True",
"# This catches the Optional[] idiom",
"if",
"(",
... | 9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7 |
train | conforms | Determine whether element conforms to etype
:param element: Element to test for conformance
:param etype: Type to test against
:param namespace: Namespace to use to resolve forward references
:return: | pyjsg/jsglib/conformance.py | def conforms(element, etype, namespace: Dict[str, Any]) -> bool:
""" Determine whether element conforms to etype
:param element: Element to test for conformance
:param etype: Type to test against
:param namespace: Namespace to use to resolve forward references
:return:
"""
etype = proc_forw... | def conforms(element, etype, namespace: Dict[str, Any]) -> bool:
""" Determine whether element conforms to etype
:param element: Element to test for conformance
:param etype: Type to test against
:param namespace: Namespace to use to resolve forward references
:return:
"""
etype = proc_forw... | [
"Determine",
"whether",
"element",
"conforms",
"to",
"etype"
] | hsolbrig/pyjsg | python | https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/jsglib/conformance.py#L28-L40 | [
"def",
"conforms",
"(",
"element",
",",
"etype",
",",
"namespace",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"bool",
":",
"etype",
"=",
"proc_forward",
"(",
"etype",
",",
"namespace",
")",
"if",
"is_union",
"(",
"etype",
")",
":",
"return"... | 9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7 |
train | upgrade | Upgrade database. | invenio_communities/alembic/2d9884d0e3fa_create_community_tables.py | def upgrade():
"""Upgrade database."""
op.create_table(
'communities_community',
sa.Column('created', sa.DateTime(), nullable=False),
sa.Column('updated', sa.DateTime(), nullable=False),
sa.Column('id', sa.String(length=100), nullable=False),
sa.Column('id_user', sa.Integ... | def upgrade():
"""Upgrade database."""
op.create_table(
'communities_community',
sa.Column('created', sa.DateTime(), nullable=False),
sa.Column('updated', sa.DateTime(), nullable=False),
sa.Column('id', sa.String(length=100), nullable=False),
sa.Column('id_user', sa.Integ... | [
"Upgrade",
"database",
"."
] | inveniosoftware/invenio-communities | python | https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/alembic/2d9884d0e3fa_create_community_tables.py#L38-L87 | [
"def",
"upgrade",
"(",
")",
":",
"op",
".",
"create_table",
"(",
"'communities_community'",
",",
"sa",
".",
"Column",
"(",
"'created'",
",",
"sa",
".",
"DateTime",
"(",
")",
",",
"nullable",
"=",
"False",
")",
",",
"sa",
".",
"Column",
"(",
"'updated'"... | 5c4de6783724d276ae1b6dd13a399a9e22fadc7a |
train | CommunitiesResource.get | Get a list of all the communities.
.. http:get:: /communities/(string:id)
Returns a JSON list with all the communities.
**Request**:
.. sourcecode:: http
GET /communities HTTP/1.1
Accept: application/json
Content-Type: applicat... | invenio_communities/views/api.py | def get(self, query, sort, page, size):
"""Get a list of all the communities.
.. http:get:: /communities/(string:id)
Returns a JSON list with all the communities.
**Request**:
.. sourcecode:: http
GET /communities HTTP/1.1
Accept: appl... | def get(self, query, sort, page, size):
"""Get a list of all the communities.
.. http:get:: /communities/(string:id)
Returns a JSON list with all the communities.
**Request**:
.. sourcecode:: http
GET /communities HTTP/1.1
Accept: appl... | [
"Get",
"a",
"list",
"of",
"all",
"the",
"communities",
"."
] | inveniosoftware/invenio-communities | python | https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/views/api.py#L80-L129 | [
"def",
"get",
"(",
"self",
",",
"query",
",",
"sort",
",",
"page",
",",
"size",
")",
":",
"urlkwargs",
"=",
"{",
"'q'",
":",
"query",
",",
"'sort'",
":",
"sort",
",",
"'size'",
":",
"size",
",",
"}",
"communities",
"=",
"Community",
".",
"filter_co... | 5c4de6783724d276ae1b6dd13a399a9e22fadc7a |
train | CommunityDetailsResource.get | Get the details of the specified community.
.. http:get:: /communities/(string:id)
Returns a JSON dictionary with the details of the specified
community.
**Request**:
.. sourcecode:: http
GET /communities/communities/comm1 HTTP/1.1
... | invenio_communities/views/api.py | def get(self, community_id):
"""Get the details of the specified community.
.. http:get:: /communities/(string:id)
Returns a JSON dictionary with the details of the specified
community.
**Request**:
.. sourcecode:: http
GET /communities/co... | def get(self, community_id):
"""Get the details of the specified community.
.. http:get:: /communities/(string:id)
Returns a JSON dictionary with the details of the specified
community.
**Request**:
.. sourcecode:: http
GET /communities/co... | [
"Get",
"the",
"details",
"of",
"the",
"specified",
"community",
"."
] | inveniosoftware/invenio-communities | python | https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/views/api.py#L143-L185 | [
"def",
"get",
"(",
"self",
",",
"community_id",
")",
":",
"community",
"=",
"Community",
".",
"get",
"(",
"community_id",
")",
"if",
"not",
"community",
":",
"abort",
"(",
"404",
")",
"etag",
"=",
"community",
".",
"version_id",
"self",
".",
"check_etag"... | 5c4de6783724d276ae1b6dd13a399a9e22fadc7a |
train | Phylesystem | Factory function for a _Phylesystem object.
A wrapper around the _Phylesystem class instantiation for
the most common use case: a singleton _Phylesystem.
If you need distinct _Phylesystem objects, you'll need to
call that class directly. | peyotl/phylesystem/phylesystem_umbrella.py | def Phylesystem(repos_dict=None,
repos_par=None,
with_caching=True,
repo_nexml2json=None,
git_ssh=None,
pkey=None,
git_action_class=PhylesystemGitAction,
mirror_info=None,
new_study_prefix=Non... | def Phylesystem(repos_dict=None,
repos_par=None,
with_caching=True,
repo_nexml2json=None,
git_ssh=None,
pkey=None,
git_action_class=PhylesystemGitAction,
mirror_info=None,
new_study_prefix=Non... | [
"Factory",
"function",
"for",
"a",
"_Phylesystem",
"object",
"."
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/phylesystem/phylesystem_umbrella.py#L273-L304 | [
"def",
"Phylesystem",
"(",
"repos_dict",
"=",
"None",
",",
"repos_par",
"=",
"None",
",",
"with_caching",
"=",
"True",
",",
"repo_nexml2json",
"=",
"None",
",",
"git_ssh",
"=",
"None",
",",
"pkey",
"=",
"None",
",",
"git_action_class",
"=",
"PhylesystemGitAc... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | _Phylesystem.write_configuration | Type-specific configuration for backward compatibility | peyotl/phylesystem/phylesystem_umbrella.py | def write_configuration(self, out, secret_attrs=False):
"""Type-specific configuration for backward compatibility"""
key_order = ['repo_nexml2json',
'number_of_shards',
'initialization', ]
cd = self.get_configuration_dict(secret_attrs=secret_attrs)
... | def write_configuration(self, out, secret_attrs=False):
"""Type-specific configuration for backward compatibility"""
key_order = ['repo_nexml2json',
'number_of_shards',
'initialization', ]
cd = self.get_configuration_dict(secret_attrs=secret_attrs)
... | [
"Type",
"-",
"specific",
"configuration",
"for",
"backward",
"compatibility"
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/phylesystem/phylesystem_umbrella.py#L245-L256 | [
"def",
"write_configuration",
"(",
"self",
",",
"out",
",",
"secret_attrs",
"=",
"False",
")",
":",
"key_order",
"=",
"[",
"'repo_nexml2json'",
",",
"'number_of_shards'",
",",
"'initialization'",
",",
"]",
"cd",
"=",
"self",
".",
"get_configuration_dict",
"(",
... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | _Phylesystem.get_configuration_dict | Type-specific configuration for backward compatibility | peyotl/phylesystem/phylesystem_umbrella.py | def get_configuration_dict(self, secret_attrs=False):
"""Type-specific configuration for backward compatibility"""
cd = {'repo_nexml2json': self.repo_nexml2json,
'number_of_shards': len(self._shards),
'initialization': self._filepath_args,
'shards': [],
... | def get_configuration_dict(self, secret_attrs=False):
"""Type-specific configuration for backward compatibility"""
cd = {'repo_nexml2json': self.repo_nexml2json,
'number_of_shards': len(self._shards),
'initialization': self._filepath_args,
'shards': [],
... | [
"Type",
"-",
"specific",
"configuration",
"for",
"backward",
"compatibility"
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/phylesystem/phylesystem_umbrella.py#L258-L267 | [
"def",
"get_configuration_dict",
"(",
"self",
",",
"secret_attrs",
"=",
"False",
")",
":",
"cd",
"=",
"{",
"'repo_nexml2json'",
":",
"self",
".",
"repo_nexml2json",
",",
"'number_of_shards'",
":",
"len",
"(",
"self",
".",
"_shards",
")",
",",
"'initialization'... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | convert_html_entities | Converts HTML5 character references within text_string to their corresponding unicode characters
and returns converted string as type str.
Keyword argument:
- text_string: string instance
Exceptions raised:
- InputError: occurs should a non-string argument be passed | preprocessing/text.py | def convert_html_entities(text_string):
'''
Converts HTML5 character references within text_string to their corresponding unicode characters
and returns converted string as type str.
Keyword argument:
- text_string: string instance
Exceptions raised:
- InputError: occurs should a non-str... | def convert_html_entities(text_string):
'''
Converts HTML5 character references within text_string to their corresponding unicode characters
and returns converted string as type str.
Keyword argument:
- text_string: string instance
Exceptions raised:
- InputError: occurs should a non-str... | [
"Converts",
"HTML5",
"character",
"references",
"within",
"text_string",
"to",
"their",
"corresponding",
"unicode",
"characters",
"and",
"returns",
"converted",
"string",
"as",
"type",
"str",
"."
] | SpotlightData/preprocessing | python | https://github.com/SpotlightData/preprocessing/blob/180c6472bc2642afbd7a1ece08d0b0d14968a708/preprocessing/text.py#L33-L51 | [
"def",
"convert_html_entities",
"(",
"text_string",
")",
":",
"if",
"text_string",
"is",
"None",
"or",
"text_string",
"==",
"\"\"",
":",
"return",
"\"\"",
"elif",
"isinstance",
"(",
"text_string",
",",
"str",
")",
":",
"return",
"html",
".",
"unescape",
"(",... | 180c6472bc2642afbd7a1ece08d0b0d14968a708 |
train | convert_ligatures | Coverts Latin character references within text_string to their corresponding unicode characters
and returns converted string as type str.
Keyword argument:
- text_string: string instance
Exceptions raised:
- InputError: occurs should a string or NoneType not be passed as an argument | preprocessing/text.py | def convert_ligatures(text_string):
'''
Coverts Latin character references within text_string to their corresponding unicode characters
and returns converted string as type str.
Keyword argument:
- text_string: string instance
Exceptions raised:
- InputError: occurs should a string or No... | def convert_ligatures(text_string):
'''
Coverts Latin character references within text_string to their corresponding unicode characters
and returns converted string as type str.
Keyword argument:
- text_string: string instance
Exceptions raised:
- InputError: occurs should a string or No... | [
"Coverts",
"Latin",
"character",
"references",
"within",
"text_string",
"to",
"their",
"corresponding",
"unicode",
"characters",
"and",
"returns",
"converted",
"string",
"as",
"type",
"str",
"."
] | SpotlightData/preprocessing | python | https://github.com/SpotlightData/preprocessing/blob/180c6472bc2642afbd7a1ece08d0b0d14968a708/preprocessing/text.py#L53-L73 | [
"def",
"convert_ligatures",
"(",
"text_string",
")",
":",
"if",
"text_string",
"is",
"None",
"or",
"text_string",
"==",
"\"\"",
":",
"return",
"\"\"",
"elif",
"isinstance",
"(",
"text_string",
",",
"str",
")",
":",
"for",
"i",
"in",
"range",
"(",
"0",
",... | 180c6472bc2642afbd7a1ece08d0b0d14968a708 |
train | correct_spelling | Splits string and converts words not found within a pre-built dictionary to their
most likely actual word based on a relative probability dictionary. Returns edited
string as type str.
Keyword argument:
- text_string: string instance
Exceptions raised:
- InputError: occurs should a string or... | preprocessing/text.py | def correct_spelling(text_string):
'''
Splits string and converts words not found within a pre-built dictionary to their
most likely actual word based on a relative probability dictionary. Returns edited
string as type str.
Keyword argument:
- text_string: string instance
Exceptions raise... | def correct_spelling(text_string):
'''
Splits string and converts words not found within a pre-built dictionary to their
most likely actual word based on a relative probability dictionary. Returns edited
string as type str.
Keyword argument:
- text_string: string instance
Exceptions raise... | [
"Splits",
"string",
"and",
"converts",
"words",
"not",
"found",
"within",
"a",
"pre",
"-",
"built",
"dictionary",
"to",
"their",
"most",
"likely",
"actual",
"word",
"based",
"on",
"a",
"relative",
"probability",
"dictionary",
".",
"Returns",
"edited",
"string"... | SpotlightData/preprocessing | python | https://github.com/SpotlightData/preprocessing/blob/180c6472bc2642afbd7a1ece08d0b0d14968a708/preprocessing/text.py#L75-L98 | [
"def",
"correct_spelling",
"(",
"text_string",
")",
":",
"if",
"text_string",
"is",
"None",
"or",
"text_string",
"==",
"\"\"",
":",
"return",
"\"\"",
"elif",
"isinstance",
"(",
"text_string",
",",
"str",
")",
":",
"word_list",
"=",
"text_string",
".",
"split... | 180c6472bc2642afbd7a1ece08d0b0d14968a708 |
train | create_sentence_list | Splits text_string into a list of sentences based on NLTK's english.pickle tokenizer, and
returns said list as type list of str.
Keyword argument:
- text_string: string instance
Exceptions raised:
- InputError: occurs should a non-string argument be passed | preprocessing/text.py | def create_sentence_list(text_string):
'''
Splits text_string into a list of sentences based on NLTK's english.pickle tokenizer, and
returns said list as type list of str.
Keyword argument:
- text_string: string instance
Exceptions raised:
- InputError: occurs should a non-string argumen... | def create_sentence_list(text_string):
'''
Splits text_string into a list of sentences based on NLTK's english.pickle tokenizer, and
returns said list as type list of str.
Keyword argument:
- text_string: string instance
Exceptions raised:
- InputError: occurs should a non-string argumen... | [
"Splits",
"text_string",
"into",
"a",
"list",
"of",
"sentences",
"based",
"on",
"NLTK",
"s",
"english",
".",
"pickle",
"tokenizer",
"and",
"returns",
"said",
"list",
"as",
"type",
"list",
"of",
"str",
"."
] | SpotlightData/preprocessing | python | https://github.com/SpotlightData/preprocessing/blob/180c6472bc2642afbd7a1ece08d0b0d14968a708/preprocessing/text.py#L100-L118 | [
"def",
"create_sentence_list",
"(",
"text_string",
")",
":",
"if",
"text_string",
"is",
"None",
"or",
"text_string",
"==",
"\"\"",
":",
"return",
"[",
"]",
"elif",
"isinstance",
"(",
"text_string",
",",
"str",
")",
":",
"return",
"SENTENCE_TOKENIZER",
".",
"... | 180c6472bc2642afbd7a1ece08d0b0d14968a708 |
train | keyword_tokenize | Extracts keywords from text_string using NLTK's list of English stopwords, ignoring words of a
length smaller than 3, and returns the new string as type str.
Keyword argument:
- text_string: string instance
Exceptions raised:
- InputError: occurs should a non-string argument be passed | preprocessing/text.py | def keyword_tokenize(text_string):
'''
Extracts keywords from text_string using NLTK's list of English stopwords, ignoring words of a
length smaller than 3, and returns the new string as type str.
Keyword argument:
- text_string: string instance
Exceptions raised:
- InputError: occurs sh... | def keyword_tokenize(text_string):
'''
Extracts keywords from text_string using NLTK's list of English stopwords, ignoring words of a
length smaller than 3, and returns the new string as type str.
Keyword argument:
- text_string: string instance
Exceptions raised:
- InputError: occurs sh... | [
"Extracts",
"keywords",
"from",
"text_string",
"using",
"NLTK",
"s",
"list",
"of",
"English",
"stopwords",
"ignoring",
"words",
"of",
"a",
"length",
"smaller",
"than",
"3",
"and",
"returns",
"the",
"new",
"string",
"as",
"type",
"str",
"."
] | SpotlightData/preprocessing | python | https://github.com/SpotlightData/preprocessing/blob/180c6472bc2642afbd7a1ece08d0b0d14968a708/preprocessing/text.py#L120-L138 | [
"def",
"keyword_tokenize",
"(",
"text_string",
")",
":",
"if",
"text_string",
"is",
"None",
"or",
"text_string",
"==",
"\"\"",
":",
"return",
"\"\"",
"elif",
"isinstance",
"(",
"text_string",
",",
"str",
")",
":",
"return",
"\" \"",
".",
"join",
"(",
"[",
... | 180c6472bc2642afbd7a1ece08d0b0d14968a708 |
train | lemmatize | Returns base from of text_string using NLTK's WordNetLemmatizer as type str.
Keyword argument:
- text_string: string instance
Exceptions raised:
- InputError: occurs should a non-string argument be passed | preprocessing/text.py | def lemmatize(text_string):
'''
Returns base from of text_string using NLTK's WordNetLemmatizer as type str.
Keyword argument:
- text_string: string instance
Exceptions raised:
- InputError: occurs should a non-string argument be passed
'''
if text_string is None ... | def lemmatize(text_string):
'''
Returns base from of text_string using NLTK's WordNetLemmatizer as type str.
Keyword argument:
- text_string: string instance
Exceptions raised:
- InputError: occurs should a non-string argument be passed
'''
if text_string is None ... | [
"Returns",
"base",
"from",
"of",
"text_string",
"using",
"NLTK",
"s",
"WordNetLemmatizer",
"as",
"type",
"str",
"."
] | SpotlightData/preprocessing | python | https://github.com/SpotlightData/preprocessing/blob/180c6472bc2642afbd7a1ece08d0b0d14968a708/preprocessing/text.py#L140-L157 | [
"def",
"lemmatize",
"(",
"text_string",
")",
":",
"if",
"text_string",
"is",
"None",
"or",
"text_string",
"==",
"\"\"",
":",
"return",
"\"\"",
"elif",
"isinstance",
"(",
"text_string",
",",
"str",
")",
":",
"return",
"LEMMATIZER",
".",
"lemmatize",
"(",
"t... | 180c6472bc2642afbd7a1ece08d0b0d14968a708 |
train | lowercase | Converts text_string into lowercase and returns the converted string as type str.
Keyword argument:
- text_string: string instance
Exceptions raised:
- InputError: occurs should a non-string argument be passed | preprocessing/text.py | def lowercase(text_string):
'''
Converts text_string into lowercase and returns the converted string as type str.
Keyword argument:
- text_string: string instance
Exceptions raised:
- InputError: occurs should a non-string argument be passed
'''
if text_string is None or text_string ... | def lowercase(text_string):
'''
Converts text_string into lowercase and returns the converted string as type str.
Keyword argument:
- text_string: string instance
Exceptions raised:
- InputError: occurs should a non-string argument be passed
'''
if text_string is None or text_string ... | [
"Converts",
"text_string",
"into",
"lowercase",
"and",
"returns",
"the",
"converted",
"string",
"as",
"type",
"str",
"."
] | SpotlightData/preprocessing | python | https://github.com/SpotlightData/preprocessing/blob/180c6472bc2642afbd7a1ece08d0b0d14968a708/preprocessing/text.py#L159-L176 | [
"def",
"lowercase",
"(",
"text_string",
")",
":",
"if",
"text_string",
"is",
"None",
"or",
"text_string",
"==",
"\"\"",
":",
"return",
"\"\"",
"elif",
"isinstance",
"(",
"text_string",
",",
"str",
")",
":",
"return",
"text_string",
".",
"lower",
"(",
")",
... | 180c6472bc2642afbd7a1ece08d0b0d14968a708 |
train | preprocess_text | Given each function within function_list, applies the order of functions put forward onto
text_string, returning the processed string as type str.
Keyword argument:
- function_list: list of functions available in preprocessing.text
- text_string: string instance
Exceptions raised:
- Func... | preprocessing/text.py | def preprocess_text(text_string, function_list):
'''
Given each function within function_list, applies the order of functions put forward onto
text_string, returning the processed string as type str.
Keyword argument:
- function_list: list of functions available in preprocessing.text
- text_st... | def preprocess_text(text_string, function_list):
'''
Given each function within function_list, applies the order of functions put forward onto
text_string, returning the processed string as type str.
Keyword argument:
- function_list: list of functions available in preprocessing.text
- text_st... | [
"Given",
"each",
"function",
"within",
"function_list",
"applies",
"the",
"order",
"of",
"functions",
"put",
"forward",
"onto",
"text_string",
"returning",
"the",
"processed",
"string",
"as",
"type",
"str",
"."
] | SpotlightData/preprocessing | python | https://github.com/SpotlightData/preprocessing/blob/180c6472bc2642afbd7a1ece08d0b0d14968a708/preprocessing/text.py#L178-L208 | [
"def",
"preprocess_text",
"(",
"text_string",
",",
"function_list",
")",
":",
"if",
"text_string",
"is",
"None",
"or",
"text_string",
"==",
"\"\"",
":",
"return",
"\"\"",
"elif",
"isinstance",
"(",
"text_string",
",",
"str",
")",
":",
"if",
"isinstance",
"("... | 180c6472bc2642afbd7a1ece08d0b0d14968a708 |
train | remove_esc_chars | Removes any escape character within text_string and returns the new string as type str.
Keyword argument:
- text_string: string instance
Exceptions raised:
- InputError: occurs should a non-string argument be passed | preprocessing/text.py | def remove_esc_chars(text_string):
'''
Removes any escape character within text_string and returns the new string as type str.
Keyword argument:
- text_string: string instance
Exceptions raised:
- InputError: occurs should a non-string argument be passed
'''
if text_string is None or... | def remove_esc_chars(text_string):
'''
Removes any escape character within text_string and returns the new string as type str.
Keyword argument:
- text_string: string instance
Exceptions raised:
- InputError: occurs should a non-string argument be passed
'''
if text_string is None or... | [
"Removes",
"any",
"escape",
"character",
"within",
"text_string",
"and",
"returns",
"the",
"new",
"string",
"as",
"type",
"str",
"."
] | SpotlightData/preprocessing | python | https://github.com/SpotlightData/preprocessing/blob/180c6472bc2642afbd7a1ece08d0b0d14968a708/preprocessing/text.py#L210-L227 | [
"def",
"remove_esc_chars",
"(",
"text_string",
")",
":",
"if",
"text_string",
"is",
"None",
"or",
"text_string",
"==",
"\"\"",
":",
"return",
"\"\"",
"elif",
"isinstance",
"(",
"text_string",
",",
"str",
")",
":",
"return",
"\" \"",
".",
"join",
"(",
"re",... | 180c6472bc2642afbd7a1ece08d0b0d14968a708 |
train | remove_numbers | Removes any digit value discovered within text_string and returns the new string as type str.
Keyword argument:
- text_string: string instance
Exceptions raised:
- InputError: occurs should a non-string argument be passed | preprocessing/text.py | def remove_numbers(text_string):
'''
Removes any digit value discovered within text_string and returns the new string as type str.
Keyword argument:
- text_string: string instance
Exceptions raised:
- InputError: occurs should a non-string argument be passed
'''
if text_string is Non... | def remove_numbers(text_string):
'''
Removes any digit value discovered within text_string and returns the new string as type str.
Keyword argument:
- text_string: string instance
Exceptions raised:
- InputError: occurs should a non-string argument be passed
'''
if text_string is Non... | [
"Removes",
"any",
"digit",
"value",
"discovered",
"within",
"text_string",
"and",
"returns",
"the",
"new",
"string",
"as",
"type",
"str",
"."
] | SpotlightData/preprocessing | python | https://github.com/SpotlightData/preprocessing/blob/180c6472bc2642afbd7a1ece08d0b0d14968a708/preprocessing/text.py#L229-L246 | [
"def",
"remove_numbers",
"(",
"text_string",
")",
":",
"if",
"text_string",
"is",
"None",
"or",
"text_string",
"==",
"\"\"",
":",
"return",
"\"\"",
"elif",
"isinstance",
"(",
"text_string",
",",
"str",
")",
":",
"return",
"\" \"",
".",
"join",
"(",
"re",
... | 180c6472bc2642afbd7a1ece08d0b0d14968a708 |
train | remove_number_words | Removes any integer represented as a word within text_string and returns the new string as
type str.
Keyword argument:
- text_string: string instance
Exceptions raised:
- InputError: occurs should a non-string argument be passed | preprocessing/text.py | def remove_number_words(text_string):
'''
Removes any integer represented as a word within text_string and returns the new string as
type str.
Keyword argument:
- text_string: string instance
Exceptions raised:
- InputError: occurs should a non-string argument be passed
'''
if te... | def remove_number_words(text_string):
'''
Removes any integer represented as a word within text_string and returns the new string as
type str.
Keyword argument:
- text_string: string instance
Exceptions raised:
- InputError: occurs should a non-string argument be passed
'''
if te... | [
"Removes",
"any",
"integer",
"represented",
"as",
"a",
"word",
"within",
"text_string",
"and",
"returns",
"the",
"new",
"string",
"as",
"type",
"str",
"."
] | SpotlightData/preprocessing | python | https://github.com/SpotlightData/preprocessing/blob/180c6472bc2642afbd7a1ece08d0b0d14968a708/preprocessing/text.py#L248-L268 | [
"def",
"remove_number_words",
"(",
"text_string",
")",
":",
"if",
"text_string",
"is",
"None",
"or",
"text_string",
"==",
"\"\"",
":",
"return",
"\"\"",
"elif",
"isinstance",
"(",
"text_string",
",",
"str",
")",
":",
"for",
"word",
"in",
"NUMBER_WORDS",
":",... | 180c6472bc2642afbd7a1ece08d0b0d14968a708 |
train | remove_time_words | Removes any word associated to time (day, week, month, etc.) within text_string and returns the
new string as type str.
Keyword argument:
- text_string: string instance
Exceptions raised:
- InputError: occurs should a non-string argument be passed | preprocessing/text.py | def remove_time_words(text_string):
'''
Removes any word associated to time (day, week, month, etc.) within text_string and returns the
new string as type str.
Keyword argument:
- text_string: string instance
Exceptions raised:
- InputError: occurs should a non-string argument be passed
... | def remove_time_words(text_string):
'''
Removes any word associated to time (day, week, month, etc.) within text_string and returns the
new string as type str.
Keyword argument:
- text_string: string instance
Exceptions raised:
- InputError: occurs should a non-string argument be passed
... | [
"Removes",
"any",
"word",
"associated",
"to",
"time",
"(",
"day",
"week",
"month",
"etc",
".",
")",
"within",
"text_string",
"and",
"returns",
"the",
"new",
"string",
"as",
"type",
"str",
"."
] | SpotlightData/preprocessing | python | https://github.com/SpotlightData/preprocessing/blob/180c6472bc2642afbd7a1ece08d0b0d14968a708/preprocessing/text.py#L270-L290 | [
"def",
"remove_time_words",
"(",
"text_string",
")",
":",
"if",
"text_string",
"is",
"None",
"or",
"text_string",
"==",
"\"\"",
":",
"return",
"\"\"",
"elif",
"isinstance",
"(",
"text_string",
",",
"str",
")",
":",
"for",
"word",
"in",
"TIME_WORDS",
":",
"... | 180c6472bc2642afbd7a1ece08d0b0d14968a708 |
train | remove_unbound_punct | Removes all punctuation unattached from a non-whitespace or attached to another punctuation
character unexpectedly (e.g. ".;';") within text_string and returns the new string as type str.
Keyword argument:
- text_string: string instance
Exceptions raised:
- InputError: occurs should a non-string... | preprocessing/text.py | def remove_unbound_punct(text_string):
'''
Removes all punctuation unattached from a non-whitespace or attached to another punctuation
character unexpectedly (e.g. ".;';") within text_string and returns the new string as type str.
Keyword argument:
- text_string: string instance
Exceptions ra... | def remove_unbound_punct(text_string):
'''
Removes all punctuation unattached from a non-whitespace or attached to another punctuation
character unexpectedly (e.g. ".;';") within text_string and returns the new string as type str.
Keyword argument:
- text_string: string instance
Exceptions ra... | [
"Removes",
"all",
"punctuation",
"unattached",
"from",
"a",
"non",
"-",
"whitespace",
"or",
"attached",
"to",
"another",
"punctuation",
"character",
"unexpectedly",
"(",
"e",
".",
"g",
".",
".",
";",
";",
")",
"within",
"text_string",
"and",
"returns",
"the"... | SpotlightData/preprocessing | python | https://github.com/SpotlightData/preprocessing/blob/180c6472bc2642afbd7a1ece08d0b0d14968a708/preprocessing/text.py#L292-L311 | [
"def",
"remove_unbound_punct",
"(",
"text_string",
")",
":",
"if",
"text_string",
"is",
"None",
"or",
"text_string",
"==",
"\"\"",
":",
"return",
"\"\"",
"elif",
"isinstance",
"(",
"text_string",
",",
"str",
")",
":",
"return",
"\" \"",
".",
"join",
"(",
"... | 180c6472bc2642afbd7a1ece08d0b0d14968a708 |
train | remove_urls | Removes all URLs within text_string and returns the new string as type str.
Keyword argument:
- text_string: string instance
Exceptions raised:
- InputError: occurs should a non-string argument be passed | preprocessing/text.py | def remove_urls(text_string):
'''
Removes all URLs within text_string and returns the new string as type str.
Keyword argument:
- text_string: string instance
Exceptions raised:
- InputError: occurs should a non-string argument be passed
'''
if text_string is None or text_string == "... | def remove_urls(text_string):
'''
Removes all URLs within text_string and returns the new string as type str.
Keyword argument:
- text_string: string instance
Exceptions raised:
- InputError: occurs should a non-string argument be passed
'''
if text_string is None or text_string == "... | [
"Removes",
"all",
"URLs",
"within",
"text_string",
"and",
"returns",
"the",
"new",
"string",
"as",
"type",
"str",
"."
] | SpotlightData/preprocessing | python | https://github.com/SpotlightData/preprocessing/blob/180c6472bc2642afbd7a1ece08d0b0d14968a708/preprocessing/text.py#L313-L330 | [
"def",
"remove_urls",
"(",
"text_string",
")",
":",
"if",
"text_string",
"is",
"None",
"or",
"text_string",
"==",
"\"\"",
":",
"return",
"\"\"",
"elif",
"isinstance",
"(",
"text_string",
",",
"str",
")",
":",
"return",
"\" \"",
".",
"join",
"(",
"re",
".... | 180c6472bc2642afbd7a1ece08d0b0d14968a708 |
train | remove_whitespace | Removes all whitespace found within text_string and returns new string as type str.
Keyword argument:
- text_string: string instance
Exceptions raised:
- InputError: occurs should a string or NoneType not be passed as an argument | preprocessing/text.py | def remove_whitespace(text_string):
'''
Removes all whitespace found within text_string and returns new string as type str.
Keyword argument:
- text_string: string instance
Exceptions raised:
- InputError: occurs should a string or NoneType not be passed as an argument
'''
if text_st... | def remove_whitespace(text_string):
'''
Removes all whitespace found within text_string and returns new string as type str.
Keyword argument:
- text_string: string instance
Exceptions raised:
- InputError: occurs should a string or NoneType not be passed as an argument
'''
if text_st... | [
"Removes",
"all",
"whitespace",
"found",
"within",
"text_string",
"and",
"returns",
"new",
"string",
"as",
"type",
"str",
"."
] | SpotlightData/preprocessing | python | https://github.com/SpotlightData/preprocessing/blob/180c6472bc2642afbd7a1ece08d0b0d14968a708/preprocessing/text.py#L332-L349 | [
"def",
"remove_whitespace",
"(",
"text_string",
")",
":",
"if",
"text_string",
"is",
"None",
"or",
"text_string",
"==",
"\"\"",
":",
"return",
"\"\"",
"elif",
"isinstance",
"(",
"text_string",
",",
"str",
")",
":",
"return",
"\" \"",
".",
"join",
"(",
"tex... | 180c6472bc2642afbd7a1ece08d0b0d14968a708 |
train | WrappedLogger.log | This is the primary method to override to ensure logging with extra
options gets correctly specified. | loggingmixin/__init__.py | def log(self, level, message, *args, **kwargs):
"""
This is the primary method to override to ensure logging with extra
options gets correctly specified.
"""
extra = self.extras.copy()
extra.update(kwargs.pop('extra', {}))
kwargs['extra'] = extra
self.log... | def log(self, level, message, *args, **kwargs):
"""
This is the primary method to override to ensure logging with extra
options gets correctly specified.
"""
extra = self.extras.copy()
extra.update(kwargs.pop('extra', {}))
kwargs['extra'] = extra
self.log... | [
"This",
"is",
"the",
"primary",
"method",
"to",
"override",
"to",
"ensure",
"logging",
"with",
"extra",
"options",
"gets",
"correctly",
"specified",
"."
] | romaryd/python-logging-mixin | python | https://github.com/romaryd/python-logging-mixin/blob/8ac77df5731b607e6ff9ef762e71398cb5a892ea/loggingmixin/__init__.py#L90-L99 | [
"def",
"log",
"(",
"self",
",",
"level",
",",
"message",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"extra",
"=",
"self",
".",
"extras",
".",
"copy",
"(",
")",
"extra",
".",
"update",
"(",
"kwargs",
".",
"pop",
"(",
"'extra'",
",",
"{... | 8ac77df5731b607e6ff9ef762e71398cb5a892ea |
train | WrappedLogger.warning | Specialized warnings system. If a warning subclass is passed into
the keyword arguments and raise_warnings is True - the warnning will
be passed to the warnings module. | loggingmixin/__init__.py | def warning(self, message, *args, **kwargs):
"""
Specialized warnings system. If a warning subclass is passed into
the keyword arguments and raise_warnings is True - the warnning will
be passed to the warnings module.
"""
warncls = kwargs.pop('warning', None)
if w... | def warning(self, message, *args, **kwargs):
"""
Specialized warnings system. If a warning subclass is passed into
the keyword arguments and raise_warnings is True - the warnning will
be passed to the warnings module.
"""
warncls = kwargs.pop('warning', None)
if w... | [
"Specialized",
"warnings",
"system",
".",
"If",
"a",
"warning",
"subclass",
"is",
"passed",
"into",
"the",
"keyword",
"arguments",
"and",
"raise_warnings",
"is",
"True",
"-",
"the",
"warnning",
"will",
"be",
"passed",
"to",
"the",
"warnings",
"module",
"."
] | romaryd/python-logging-mixin | python | https://github.com/romaryd/python-logging-mixin/blob/8ac77df5731b607e6ff9ef762e71398cb5a892ea/loggingmixin/__init__.py#L107-L117 | [
"def",
"warning",
"(",
"self",
",",
"message",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"warncls",
"=",
"kwargs",
".",
"pop",
"(",
"'warning'",
",",
"None",
")",
"if",
"warncls",
"and",
"self",
".",
"raise_warnings",
":",
"warnings",
".",... | 8ac77df5731b607e6ff9ef762e71398cb5a892ea |
train | ServiceLogger.log | Provide current user as extra context to the logger | loggingmixin/__init__.py | def log(self, level, message, *args, **kwargs):
"""
Provide current user as extra context to the logger
"""
extra = kwargs.pop('extra', {})
extra.update({
'user': self.user
})
kwargs['extra'] = extra
super(ServiceLogger, self).log(level, messa... | def log(self, level, message, *args, **kwargs):
"""
Provide current user as extra context to the logger
"""
extra = kwargs.pop('extra', {})
extra.update({
'user': self.user
})
kwargs['extra'] = extra
super(ServiceLogger, self).log(level, messa... | [
"Provide",
"current",
"user",
"as",
"extra",
"context",
"to",
"the",
"logger"
] | romaryd/python-logging-mixin | python | https://github.com/romaryd/python-logging-mixin/blob/8ac77df5731b607e6ff9ef762e71398cb5a892ea/loggingmixin/__init__.py#L147-L157 | [
"def",
"log",
"(",
"self",
",",
"level",
",",
"message",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"extra",
"=",
"kwargs",
".",
"pop",
"(",
"'extra'",
",",
"{",
"}",
")",
"extra",
".",
"update",
"(",
"{",
"'user'",
":",
"self",
".",
... | 8ac77df5731b607e6ff9ef762e71398cb5a892ea |
train | LoggingMixin.logger | Instantiates and returns a ServiceLogger instance | loggingmixin/__init__.py | def logger(self):
"""
Instantiates and returns a ServiceLogger instance
"""
if not hasattr(self, '_logger') or not self._logger:
self._logger = ServiceLogger()
return self._logger | def logger(self):
"""
Instantiates and returns a ServiceLogger instance
"""
if not hasattr(self, '_logger') or not self._logger:
self._logger = ServiceLogger()
return self._logger | [
"Instantiates",
"and",
"returns",
"a",
"ServiceLogger",
"instance"
] | romaryd/python-logging-mixin | python | https://github.com/romaryd/python-logging-mixin/blob/8ac77df5731b607e6ff9ef762e71398cb5a892ea/loggingmixin/__init__.py#L166-L172 | [
"def",
"logger",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_logger'",
")",
"or",
"not",
"self",
".",
"_logger",
":",
"self",
".",
"_logger",
"=",
"ServiceLogger",
"(",
")",
"return",
"self",
".",
"_logger"
] | 8ac77df5731b607e6ff9ef762e71398cb5a892ea |
train | ot_find_studies | Uses a peyotl wrapper around an Open Tree web service to get a list of studies
including values `value` for a given property to be searched on `porperty`.
The oti_wrapper can be None (in which case the default wrapper from peyotl.sugar will be used.
All other arguments correspond to the arguments of the we... | tutorials/ot-oti-find-studies.py | def ot_find_studies(arg_dict, exact=True, verbose=False, oti_wrapper=None):
"""Uses a peyotl wrapper around an Open Tree web service to get a list of studies
including values `value` for a given property to be searched on `porperty`.
The oti_wrapper can be None (in which case the default wrapper from peyot... | def ot_find_studies(arg_dict, exact=True, verbose=False, oti_wrapper=None):
"""Uses a peyotl wrapper around an Open Tree web service to get a list of studies
including values `value` for a given property to be searched on `porperty`.
The oti_wrapper can be None (in which case the default wrapper from peyot... | [
"Uses",
"a",
"peyotl",
"wrapper",
"around",
"an",
"Open",
"Tree",
"web",
"service",
"to",
"get",
"a",
"list",
"of",
"studies",
"including",
"values",
"value",
"for",
"a",
"given",
"property",
"to",
"be",
"searched",
"on",
"porperty",
"."
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/tutorials/ot-oti-find-studies.py#L12-L25 | [
"def",
"ot_find_studies",
"(",
"arg_dict",
",",
"exact",
"=",
"True",
",",
"verbose",
"=",
"False",
",",
"oti_wrapper",
"=",
"None",
")",
":",
"if",
"oti_wrapper",
"is",
"None",
":",
"from",
"peyotl",
".",
"sugar",
"import",
"oti",
"oti_wrapper",
"=",
"o... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | main | This function sets up a command-line option parser and then calls print_matching_trees
to do all of the real work. | tutorials/ot-oti-find-studies.py | def main(argv):
"""This function sets up a command-line option parser and then calls print_matching_trees
to do all of the real work.
"""
import argparse
description = 'Uses Open Tree of Life web services to try to find a tree with the value property pair specified. ' \
'setting --... | def main(argv):
"""This function sets up a command-line option parser and then calls print_matching_trees
to do all of the real work.
"""
import argparse
description = 'Uses Open Tree of Life web services to try to find a tree with the value property pair specified. ' \
'setting --... | [
"This",
"function",
"sets",
"up",
"a",
"command",
"-",
"line",
"option",
"parser",
"and",
"then",
"calls",
"print_matching_trees",
"to",
"do",
"all",
"of",
"the",
"real",
"work",
"."
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/tutorials/ot-oti-find-studies.py#L36-L59 | [
"def",
"main",
"(",
"argv",
")",
":",
"import",
"argparse",
"description",
"=",
"'Uses Open Tree of Life web services to try to find a tree with the value property pair specified. '",
"'setting --fuzzy will allow fuzzy matching'",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | main | This function sets up a command-line option parser and then calls
to do all of the real work. | tutorials/ot-taxo-mrca-to-root.py | def main(argv):
"""This function sets up a command-line option parser and then calls
to do all of the real work.
"""
import argparse
import codecs
# have to be ready to deal with utf-8 names
out = codecs.getwriter('utf-8')(sys.stdout)
description = '''Takes a series of at least 2 OTT ids... | def main(argv):
"""This function sets up a command-line option parser and then calls
to do all of the real work.
"""
import argparse
import codecs
# have to be ready to deal with utf-8 names
out = codecs.getwriter('utf-8')(sys.stdout)
description = '''Takes a series of at least 2 OTT ids... | [
"This",
"function",
"sets",
"up",
"a",
"command",
"-",
"line",
"option",
"parser",
"and",
"then",
"calls",
"to",
"do",
"all",
"of",
"the",
"real",
"work",
"."
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/tutorials/ot-taxo-mrca-to-root.py#L23-L46 | [
"def",
"main",
"(",
"argv",
")",
":",
"import",
"argparse",
"import",
"codecs",
"# have to be ready to deal with utf-8 names",
"out",
"=",
"codecs",
".",
"getwriter",
"(",
"'utf-8'",
")",
"(",
"sys",
".",
"stdout",
")",
"description",
"=",
"'''Takes a series of at... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | create_id2collection_info | Searchers for JSON files in this repo and returns
a map of collection id ==> (`tag`, dir, collection filepath)
where `tag` is typically the shard name | peyotl/collections_store/collections_shard.py | def create_id2collection_info(path, tag):
"""Searchers for JSON files in this repo and returns
a map of collection id ==> (`tag`, dir, collection filepath)
where `tag` is typically the shard name
"""
d = {}
for triple in os.walk(path):
root, files = triple[0], triple[2]
for filen... | def create_id2collection_info(path, tag):
"""Searchers for JSON files in this repo and returns
a map of collection id ==> (`tag`, dir, collection filepath)
where `tag` is typically the shard name
"""
d = {}
for triple in os.walk(path):
root, files = triple[0], triple[2]
for filen... | [
"Searchers",
"for",
"JSON",
"files",
"in",
"this",
"repo",
"and",
"returns",
"a",
"map",
"of",
"collection",
"id",
"==",
">",
"(",
"tag",
"dir",
"collection",
"filepath",
")",
"where",
"tag",
"is",
"typically",
"the",
"shard",
"name"
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/collections_store/collections_shard.py#L40-L53 | [
"def",
"create_id2collection_info",
"(",
"path",
",",
"tag",
")",
":",
"d",
"=",
"{",
"}",
"for",
"triple",
"in",
"os",
".",
"walk",
"(",
"path",
")",
":",
"root",
",",
"files",
"=",
"triple",
"[",
"0",
"]",
",",
"triple",
"[",
"2",
"]",
"for",
... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | TreeCollectionsShard.write_configuration | Generic configuration, may be overridden by type-specific version | peyotl/collections_store/collections_shard.py | def write_configuration(self, out, secret_attrs=False):
"""Generic configuration, may be overridden by type-specific version"""
key_order = ['name', 'path', 'git_dir', 'doc_dir', 'assumed_doc_version',
'git_ssh', 'pkey', 'has_aliases', 'number of collections']
cd = self.get_... | def write_configuration(self, out, secret_attrs=False):
"""Generic configuration, may be overridden by type-specific version"""
key_order = ['name', 'path', 'git_dir', 'doc_dir', 'assumed_doc_version',
'git_ssh', 'pkey', 'has_aliases', 'number of collections']
cd = self.get_... | [
"Generic",
"configuration",
"may",
"be",
"overridden",
"by",
"type",
"-",
"specific",
"version"
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/collections_store/collections_shard.py#L105-L115 | [
"def",
"write_configuration",
"(",
"self",
",",
"out",
",",
"secret_attrs",
"=",
"False",
")",
":",
"key_order",
"=",
"[",
"'name'",
",",
"'path'",
",",
"'git_dir'",
",",
"'doc_dir'",
",",
"'assumed_doc_version'",
",",
"'git_ssh'",
",",
"'pkey'",
",",
"'has_... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | TreeCollectionsShard.get_configuration_dict | Overrides superclass method and renames some properties | peyotl/collections_store/collections_shard.py | def get_configuration_dict(self, secret_attrs=False):
"""Overrides superclass method and renames some properties"""
cd = super(TreeCollectionsShard, self).get_configuration_dict(secret_attrs=secret_attrs)
# "rename" some keys in the dict provided
cd['number of collections'] = cd.pop('num... | def get_configuration_dict(self, secret_attrs=False):
"""Overrides superclass method and renames some properties"""
cd = super(TreeCollectionsShard, self).get_configuration_dict(secret_attrs=secret_attrs)
# "rename" some keys in the dict provided
cd['number of collections'] = cd.pop('num... | [
"Overrides",
"superclass",
"method",
"and",
"renames",
"some",
"properties"
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/collections_store/collections_shard.py#L117-L123 | [
"def",
"get_configuration_dict",
"(",
"self",
",",
"secret_attrs",
"=",
"False",
")",
":",
"cd",
"=",
"super",
"(",
"TreeCollectionsShard",
",",
"self",
")",
".",
"get_configuration_dict",
"(",
"secret_attrs",
"=",
"secret_attrs",
")",
"# \"rename\" some keys in the... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | TreeCollectionsShard._diagnose_prefixes | Returns a set of all of the prefixes seen in the main document dir | peyotl/collections_store/collections_shard.py | def _diagnose_prefixes(self):
"""Returns a set of all of the prefixes seen in the main document dir
"""
from peyotl.collections_store import COLLECTION_ID_PATTERN
p = set()
for owner_dirname in os.listdir(self.doc_dir):
example_collection_name = "{n}/xxxxx".format(n=o... | def _diagnose_prefixes(self):
"""Returns a set of all of the prefixes seen in the main document dir
"""
from peyotl.collections_store import COLLECTION_ID_PATTERN
p = set()
for owner_dirname in os.listdir(self.doc_dir):
example_collection_name = "{n}/xxxxx".format(n=o... | [
"Returns",
"a",
"set",
"of",
"all",
"of",
"the",
"prefixes",
"seen",
"in",
"the",
"main",
"document",
"dir"
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/collections_store/collections_shard.py#L125-L134 | [
"def",
"_diagnose_prefixes",
"(",
"self",
")",
":",
"from",
"peyotl",
".",
"collections_store",
"import",
"COLLECTION_ID_PATTERN",
"p",
"=",
"set",
"(",
")",
"for",
"owner_dirname",
"in",
"os",
".",
"listdir",
"(",
"self",
".",
"doc_dir",
")",
":",
"example_... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | TreeCollectionsShard.create_git_action_for_new_collection | Checks out master branch as a side effect | peyotl/collections_store/collections_shard.py | def create_git_action_for_new_collection(self, new_collection_id=None):
"""Checks out master branch as a side effect"""
ga = self.create_git_action()
assert new_collection_id is not None
# id should have been sorted out by the caller
self.register_doc_id(ga, new_collection_id)
... | def create_git_action_for_new_collection(self, new_collection_id=None):
"""Checks out master branch as a side effect"""
ga = self.create_git_action()
assert new_collection_id is not None
# id should have been sorted out by the caller
self.register_doc_id(ga, new_collection_id)
... | [
"Checks",
"out",
"master",
"branch",
"as",
"a",
"side",
"effect"
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/collections_store/collections_shard.py#L136-L142 | [
"def",
"create_git_action_for_new_collection",
"(",
"self",
",",
"new_collection_id",
"=",
"None",
")",
":",
"ga",
"=",
"self",
".",
"create_git_action",
"(",
")",
"assert",
"new_collection_id",
"is",
"not",
"None",
"# id should have been sorted out by the caller",
"sel... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | is_sequence | Determine if a value is a sequence type.
Returns:
``True`` if `value` is a sequence type (e.g., ``list``, or ``tuple``).
String types will return ``False``.
NOTE: On Python 3, strings have the __iter__ defined, so a simple hasattr
check is insufficient. | mixbox/datautils.py | def is_sequence(value):
"""Determine if a value is a sequence type.
Returns:
``True`` if `value` is a sequence type (e.g., ``list``, or ``tuple``).
String types will return ``False``.
NOTE: On Python 3, strings have the __iter__ defined, so a simple hasattr
check is insufficient.
"""
... | def is_sequence(value):
"""Determine if a value is a sequence type.
Returns:
``True`` if `value` is a sequence type (e.g., ``list``, or ``tuple``).
String types will return ``False``.
NOTE: On Python 3, strings have the __iter__ defined, so a simple hasattr
check is insufficient.
"""
... | [
"Determine",
"if",
"a",
"value",
"is",
"a",
"sequence",
"type",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/datautils.py#L12-L23 | [
"def",
"is_sequence",
"(",
"value",
")",
":",
"return",
"(",
"hasattr",
"(",
"value",
",",
"\"__iter__\"",
")",
"and",
"not",
"isinstance",
"(",
"value",
",",
"(",
"six",
".",
"string_types",
",",
"six",
".",
"binary_type",
")",
")",
")"
] | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | import_class | Import the class referred to by the fully qualified class path.
Args:
classpath: A full "foo.bar.MyClass" path to a class definition.
Returns:
The class referred to by the classpath.
Raises:
ImportError: If an error occurs while importing the module.
AttributeError: IF the... | mixbox/datautils.py | def import_class(classpath):
"""Import the class referred to by the fully qualified class path.
Args:
classpath: A full "foo.bar.MyClass" path to a class definition.
Returns:
The class referred to by the classpath.
Raises:
ImportError: If an error occurs while importing the mo... | def import_class(classpath):
"""Import the class referred to by the fully qualified class path.
Args:
classpath: A full "foo.bar.MyClass" path to a class definition.
Returns:
The class referred to by the classpath.
Raises:
ImportError: If an error occurs while importing the mo... | [
"Import",
"the",
"class",
"referred",
"to",
"by",
"the",
"fully",
"qualified",
"class",
"path",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/datautils.py#L26-L42 | [
"def",
"import_class",
"(",
"classpath",
")",
":",
"modname",
",",
"classname",
"=",
"classpath",
".",
"rsplit",
"(",
"\".\"",
",",
"1",
")",
"module",
"=",
"importlib",
".",
"import_module",
"(",
"modname",
")",
"klass",
"=",
"getattr",
"(",
"module",
"... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | resolve_class | Attempt to return a Python class for the input class reference.
If `classref` is a class or None, return it. If `classref` is a
python classpath (e.g., "foo.bar.MyClass") import the class and return
it.
Args:
classref: A fully-qualified Python path to class, or a Python class.
Returns:
... | mixbox/datautils.py | def resolve_class(classref):
"""Attempt to return a Python class for the input class reference.
If `classref` is a class or None, return it. If `classref` is a
python classpath (e.g., "foo.bar.MyClass") import the class and return
it.
Args:
classref: A fully-qualified Python path to class,... | def resolve_class(classref):
"""Attempt to return a Python class for the input class reference.
If `classref` is a class or None, return it. If `classref` is a
python classpath (e.g., "foo.bar.MyClass") import the class and return
it.
Args:
classref: A fully-qualified Python path to class,... | [
"Attempt",
"to",
"return",
"a",
"Python",
"class",
"for",
"the",
"input",
"class",
"reference",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/datautils.py#L45-L65 | [
"def",
"resolve_class",
"(",
"classref",
")",
":",
"if",
"classref",
"is",
"None",
":",
"return",
"None",
"elif",
"isinstance",
"(",
"classref",
",",
"six",
".",
"class_types",
")",
":",
"return",
"classref",
"elif",
"isinstance",
"(",
"classref",
",",
"si... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | needkwargs | Function decorator which checks that the decorated function is called
with a set of required kwargs.
Args:
*argnames: String keyword argument names.
Raises:
ValueError: If a required kwarg is missing in the decorated function
call. | mixbox/datautils.py | def needkwargs(*argnames):
"""Function decorator which checks that the decorated function is called
with a set of required kwargs.
Args:
*argnames: String keyword argument names.
Raises:
ValueError: If a required kwarg is missing in the decorated function
call.
"""
... | def needkwargs(*argnames):
"""Function decorator which checks that the decorated function is called
with a set of required kwargs.
Args:
*argnames: String keyword argument names.
Raises:
ValueError: If a required kwarg is missing in the decorated function
call.
"""
... | [
"Function",
"decorator",
"which",
"checks",
"that",
"the",
"decorated",
"function",
"is",
"called",
"with",
"a",
"set",
"of",
"required",
"kwargs",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/datautils.py#L83-L104 | [
"def",
"needkwargs",
"(",
"*",
"argnames",
")",
":",
"required",
"=",
"set",
"(",
"argnames",
")",
"def",
"decorator",
"(",
"func",
")",
":",
"def",
"inner",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"missing",
"=",
"required",
"-",
"set... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | get | Connect to the APCUPSd NIS and request its status. | apcaccess/status.py | def get(host="localhost", port=3551, timeout=30):
"""
Connect to the APCUPSd NIS and request its status.
"""
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(timeout)
sock.connect((host, port))
sock.send(CMD_STATUS)
buffr = ""
while not buffr.endswith(EOF):
... | def get(host="localhost", port=3551, timeout=30):
"""
Connect to the APCUPSd NIS and request its status.
"""
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(timeout)
sock.connect((host, port))
sock.send(CMD_STATUS)
buffr = ""
while not buffr.endswith(EOF):
... | [
"Connect",
"to",
"the",
"APCUPSd",
"NIS",
"and",
"request",
"its",
"status",
"."
] | flyte/apcaccess | python | https://github.com/flyte/apcaccess/blob/0c8a5d5e4ba1c07110e411b4ffea4ddccef4829a/apcaccess/status.py#L31-L43 | [
"def",
"get",
"(",
"host",
"=",
"\"localhost\"",
",",
"port",
"=",
"3551",
",",
"timeout",
"=",
"30",
")",
":",
"sock",
"=",
"socket",
".",
"socket",
"(",
"socket",
".",
"AF_INET",
",",
"socket",
".",
"SOCK_STREAM",
")",
"sock",
".",
"settimeout",
"(... | 0c8a5d5e4ba1c07110e411b4ffea4ddccef4829a |
train | parse | Split the output from get_status() into lines, clean it up and return it as
an OrderedDict. | apcaccess/status.py | def parse(raw_status, strip_units=False):
"""
Split the output from get_status() into lines, clean it up and return it as
an OrderedDict.
"""
lines = split(raw_status)
if strip_units:
lines = strip_units_from_lines(lines)
# Split each line on the SEP character, strip extraneous white... | def parse(raw_status, strip_units=False):
"""
Split the output from get_status() into lines, clean it up and return it as
an OrderedDict.
"""
lines = split(raw_status)
if strip_units:
lines = strip_units_from_lines(lines)
# Split each line on the SEP character, strip extraneous white... | [
"Split",
"the",
"output",
"from",
"get_status",
"()",
"into",
"lines",
"clean",
"it",
"up",
"and",
"return",
"it",
"as",
"an",
"OrderedDict",
"."
] | flyte/apcaccess | python | https://github.com/flyte/apcaccess/blob/0c8a5d5e4ba1c07110e411b4ffea4ddccef4829a/apcaccess/status.py#L56-L66 | [
"def",
"parse",
"(",
"raw_status",
",",
"strip_units",
"=",
"False",
")",
":",
"lines",
"=",
"split",
"(",
"raw_status",
")",
"if",
"strip_units",
":",
"lines",
"=",
"strip_units_from_lines",
"(",
"lines",
")",
"# Split each line on the SEP character, strip extraneo... | 0c8a5d5e4ba1c07110e411b4ffea4ddccef4829a |
train | strip_units_from_lines | Removes all units from the ends of the lines. | apcaccess/status.py | def strip_units_from_lines(lines):
"""
Removes all units from the ends of the lines.
"""
for line in lines:
for unit in ALL_UNITS:
if line.endswith(" %s" % unit):
line = line[:-1-len(unit)]
yield line | def strip_units_from_lines(lines):
"""
Removes all units from the ends of the lines.
"""
for line in lines:
for unit in ALL_UNITS:
if line.endswith(" %s" % unit):
line = line[:-1-len(unit)]
yield line | [
"Removes",
"all",
"units",
"from",
"the",
"ends",
"of",
"the",
"lines",
"."
] | flyte/apcaccess | python | https://github.com/flyte/apcaccess/blob/0c8a5d5e4ba1c07110e411b4ffea4ddccef4829a/apcaccess/status.py#L69-L77 | [
"def",
"strip_units_from_lines",
"(",
"lines",
")",
":",
"for",
"line",
"in",
"lines",
":",
"for",
"unit",
"in",
"ALL_UNITS",
":",
"if",
"line",
".",
"endswith",
"(",
"\" %s\"",
"%",
"unit",
")",
":",
"line",
"=",
"line",
"[",
":",
"-",
"1",
"-",
"... | 0c8a5d5e4ba1c07110e411b4ffea4ddccef4829a |
train | print_status | Print the status to stdout in the same format as the original apcaccess. | apcaccess/status.py | def print_status(raw_status, strip_units=False):
"""
Print the status to stdout in the same format as the original apcaccess.
"""
lines = split(raw_status)
if strip_units:
lines = strip_units_from_lines(lines)
for line in lines:
print(line) | def print_status(raw_status, strip_units=False):
"""
Print the status to stdout in the same format as the original apcaccess.
"""
lines = split(raw_status)
if strip_units:
lines = strip_units_from_lines(lines)
for line in lines:
print(line) | [
"Print",
"the",
"status",
"to",
"stdout",
"in",
"the",
"same",
"format",
"as",
"the",
"original",
"apcaccess",
"."
] | flyte/apcaccess | python | https://github.com/flyte/apcaccess/blob/0c8a5d5e4ba1c07110e411b4ffea4ddccef4829a/apcaccess/status.py#L80-L88 | [
"def",
"print_status",
"(",
"raw_status",
",",
"strip_units",
"=",
"False",
")",
":",
"lines",
"=",
"split",
"(",
"raw_status",
")",
"if",
"strip_units",
":",
"lines",
"=",
"strip_units_from_lines",
"(",
"lines",
")",
"for",
"line",
"in",
"lines",
":",
"pr... | 0c8a5d5e4ba1c07110e411b4ffea4ddccef4829a |
train | _TaxomachineAPIWrapper.TNRS | Takes a name and optional contextName returns a list of matches.
`wrap_response` can be True to return a TNRSResponse object, None to return
the "raw" response dict, or a function/class that takes (response, query_data=dict)
as its arguments.
Each match is a dict with:
... | peyotl/api/taxomachine.py | def TNRS(self,
names,
context_name=None,
id_list=None,
fuzzy_matching=False,
include_deprecated=False,
include_dubious=False,
do_approximate_matching=None,
wrap_response=None):
"""Takes a name and optional co... | def TNRS(self,
names,
context_name=None,
id_list=None,
fuzzy_matching=False,
include_deprecated=False,
include_dubious=False,
do_approximate_matching=None,
wrap_response=None):
"""Takes a name and optional co... | [
"Takes",
"a",
"name",
"and",
"optional",
"contextName",
"returns",
"a",
"list",
"of",
"matches",
".",
"wrap_response",
"can",
"be",
"True",
"to",
"return",
"a",
"TNRSResponse",
"object",
"None",
"to",
"return",
"the",
"raw",
"response",
"dict",
"or",
"a",
... | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/api/taxomachine.py#L147-L203 | [
"def",
"TNRS",
"(",
"self",
",",
"names",
",",
"context_name",
"=",
"None",
",",
"id_list",
"=",
"None",
",",
"fuzzy_matching",
"=",
"False",
",",
"include_deprecated",
"=",
"False",
",",
"include_dubious",
"=",
"False",
",",
"do_approximate_matching",
"=",
... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | _TaxomachineAPIWrapper.autocomplete | Takes a name and optional context_name returns a list of matches.
Each match is a dict with:
'higher' boolean DEF???
'exact' boolean for exact match
'ottId' int
'name' name (or uniqname???) for the taxon in OTT
'nodeId' int ID of not in the taxomachine db.... | peyotl/api/taxomachine.py | def autocomplete(self, name, context_name=None, include_dubious=False):
"""Takes a name and optional context_name returns a list of matches.
Each match is a dict with:
'higher' boolean DEF???
'exact' boolean for exact match
'ottId' int
'name' name (or uniqnam... | def autocomplete(self, name, context_name=None, include_dubious=False):
"""Takes a name and optional context_name returns a list of matches.
Each match is a dict with:
'higher' boolean DEF???
'exact' boolean for exact match
'ottId' int
'name' name (or uniqnam... | [
"Takes",
"a",
"name",
"and",
"optional",
"context_name",
"returns",
"a",
"list",
"of",
"matches",
".",
"Each",
"match",
"is",
"a",
"dict",
"with",
":",
"higher",
"boolean",
"DEF???",
"exact",
"boolean",
"for",
"exact",
"match",
"ottId",
"int",
"name",
"nam... | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/api/taxomachine.py#L205-L228 | [
"def",
"autocomplete",
"(",
"self",
",",
"name",
",",
"context_name",
"=",
"None",
",",
"include_dubious",
"=",
"False",
")",
":",
"if",
"context_name",
"and",
"context_name",
"not",
"in",
"self",
".",
"valid_contexts",
":",
"raise",
"ValueError",
"(",
"'\"{... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | _TaxomachineAPIWrapper.names_to_ott_ids_perfect | delegates a call to TNRS (same arguments as that function).
Returns a list of (non-dubious) OTT IDs in the same order as the original names.
Raises a ValueError if each name does not have exactly one perfect, non-dubious
(score = 1.0) match in the TNRS results. | peyotl/api/taxomachine.py | def names_to_ott_ids_perfect(self, names, **kwargs):
"""delegates a call to TNRS (same arguments as that function).
Returns a list of (non-dubious) OTT IDs in the same order as the original names.
Raises a ValueError if each name does not have exactly one perfect, non-dubious
(score = 1... | def names_to_ott_ids_perfect(self, names, **kwargs):
"""delegates a call to TNRS (same arguments as that function).
Returns a list of (non-dubious) OTT IDs in the same order as the original names.
Raises a ValueError if each name does not have exactly one perfect, non-dubious
(score = 1... | [
"delegates",
"a",
"call",
"to",
"TNRS",
"(",
"same",
"arguments",
"as",
"that",
"function",
")",
"."
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/api/taxomachine.py#L343-L371 | [
"def",
"names_to_ott_ids_perfect",
"(",
"self",
",",
"names",
",",
"*",
"*",
"kwargs",
")",
":",
"results",
"=",
"self",
".",
"TNRS",
"(",
"names",
",",
"*",
"*",
"kwargs",
")",
"[",
"'results'",
"]",
"d",
"=",
"{",
"}",
"for",
"blob",
"in",
"resul... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | _TaxomachineAPIWrapper.get_cached_parent_for_taxon | If the taxa are being cached, this call will create a the lineage "spike" for taxon child_taxon
Expecting child_taxon to have a non-empty _taxonomic_lineage with response dicts that can create
an ancestral TaxonWrapper. | peyotl/api/taxomachine.py | def get_cached_parent_for_taxon(self, child_taxon):
"""If the taxa are being cached, this call will create a the lineage "spike" for taxon child_taxon
Expecting child_taxon to have a non-empty _taxonomic_lineage with response dicts that can create
an ancestral TaxonWrapper.
"""
... | def get_cached_parent_for_taxon(self, child_taxon):
"""If the taxa are being cached, this call will create a the lineage "spike" for taxon child_taxon
Expecting child_taxon to have a non-empty _taxonomic_lineage with response dicts that can create
an ancestral TaxonWrapper.
"""
... | [
"If",
"the",
"taxa",
"are",
"being",
"cached",
"this",
"call",
"will",
"create",
"a",
"the",
"lineage",
"spike",
"for",
"taxon",
"child_taxon"
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/api/taxomachine.py#L373-L405 | [
"def",
"get_cached_parent_for_taxon",
"(",
"self",
",",
"child_taxon",
")",
":",
"if",
"self",
".",
"_ott_id2taxon",
"is",
"None",
":",
"resp",
"=",
"child_taxon",
".",
"_taxonomic_lineage",
"[",
"0",
"]",
"tl",
"=",
"child_taxon",
".",
"_taxonomic_lineage",
"... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.