repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
NASA-AMMOS/AIT-Core | ait/core/seq.py | SeqMsgLog.location | def location (self, pos):
"""Formats the location of the given SeqPos as:
filename:line:col:
"""
result = ''
if self.filename:
result += self.filename + ':'
if pos:
result += str(pos)
return result | python | def location (self, pos):
"""Formats the location of the given SeqPos as:
filename:line:col:
"""
result = ''
if self.filename:
result += self.filename + ':'
if pos:
result += str(pos)
return result | [
"def",
"location",
"(",
"self",
",",
"pos",
")",
":",
"result",
"=",
"''",
"if",
"self",
".",
"filename",
":",
"result",
"+=",
"self",
".",
"filename",
"+",
"':'",
"if",
"pos",
":",
"result",
"+=",
"str",
"(",
"pos",
")",
"return",
"result"
] | Formats the location of the given SeqPos as:
filename:line:col: | [
"Formats",
"the",
"location",
"of",
"the",
"given",
"SeqPos",
"as",
":"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/seq.py#L720-L730 |
NASA-AMMOS/AIT-Core | ait/core/seq.py | SeqMsgLog.log | def log (self, msg, prefix=None):
"""Logs a message with an optional prefix."""
if prefix:
if not prefix.strip().endswith(':'):
prefix += ': '
msg = prefix + msg
self.messages.append(msg) | python | def log (self, msg, prefix=None):
"""Logs a message with an optional prefix."""
if prefix:
if not prefix.strip().endswith(':'):
prefix += ': '
msg = prefix + msg
self.messages.append(msg) | [
"def",
"log",
"(",
"self",
",",
"msg",
",",
"prefix",
"=",
"None",
")",
":",
"if",
"prefix",
":",
"if",
"not",
"prefix",
".",
"strip",
"(",
")",
".",
"endswith",
"(",
"':'",
")",
":",
"prefix",
"+=",
"': '",
"msg",
"=",
"prefix",
"+",
"msg",
"s... | Logs a message with an optional prefix. | [
"Logs",
"a",
"message",
"with",
"an",
"optional",
"prefix",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/seq.py#L733-L739 |
NASA-AMMOS/AIT-Core | ait/core/seq.py | SeqMsgLog.warning | def warning (self, msg, pos=None):
"""Logs a warning message pertaining to the given SeqAtom."""
self.log(msg, 'warning: ' + self.location(pos)) | python | def warning (self, msg, pos=None):
"""Logs a warning message pertaining to the given SeqAtom."""
self.log(msg, 'warning: ' + self.location(pos)) | [
"def",
"warning",
"(",
"self",
",",
"msg",
",",
"pos",
"=",
"None",
")",
":",
"self",
".",
"log",
"(",
"msg",
",",
"'warning: '",
"+",
"self",
".",
"location",
"(",
"pos",
")",
")"
] | Logs a warning message pertaining to the given SeqAtom. | [
"Logs",
"a",
"warning",
"message",
"pertaining",
"to",
"the",
"given",
"SeqAtom",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/seq.py#L742-L744 |
NASA-AMMOS/AIT-Core | ait/core/cfg.py | expandConfigPaths | def expandConfigPaths (config, prefix=None, datetime=None, pathvars=None, parameter_key='', *keys):
"""Updates all relative configuration paths in dictionary config,
which contain a key in keys, by prepending prefix.
If keys is omitted, it defaults to 'directory', 'file',
'filename', 'path', 'pathname'... | python | def expandConfigPaths (config, prefix=None, datetime=None, pathvars=None, parameter_key='', *keys):
"""Updates all relative configuration paths in dictionary config,
which contain a key in keys, by prepending prefix.
If keys is omitted, it defaults to 'directory', 'file',
'filename', 'path', 'pathname'... | [
"def",
"expandConfigPaths",
"(",
"config",
",",
"prefix",
"=",
"None",
",",
"datetime",
"=",
"None",
",",
"pathvars",
"=",
"None",
",",
"parameter_key",
"=",
"''",
",",
"*",
"keys",
")",
":",
"if",
"len",
"(",
"keys",
")",
"==",
"0",
":",
"keys",
"... | Updates all relative configuration paths in dictionary config,
which contain a key in keys, by prepending prefix.
If keys is omitted, it defaults to 'directory', 'file',
'filename', 'path', 'pathname'.
See util.expandPath(). | [
"Updates",
"all",
"relative",
"configuration",
"paths",
"in",
"dictionary",
"config",
"which",
"contain",
"a",
"key",
"in",
"keys",
"by",
"prepending",
"prefix",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/cfg.py#L42-L68 |
NASA-AMMOS/AIT-Core | ait/core/cfg.py | replaceVariables | def replaceVariables(path, datetime=None, pathvars=None):
"""Return absolute path with path variables replaced as applicable"""
if datetime is None:
datetime = time.gmtime()
# if path variables are not given, set as empty list
if pathvars is None:
pathvars = [ ]
# create an init p... | python | def replaceVariables(path, datetime=None, pathvars=None):
"""Return absolute path with path variables replaced as applicable"""
if datetime is None:
datetime = time.gmtime()
# if path variables are not given, set as empty list
if pathvars is None:
pathvars = [ ]
# create an init p... | [
"def",
"replaceVariables",
"(",
"path",
",",
"datetime",
"=",
"None",
",",
"pathvars",
"=",
"None",
")",
":",
"if",
"datetime",
"is",
"None",
":",
"datetime",
"=",
"time",
".",
"gmtime",
"(",
")",
"# if path variables are not given, set as empty list",
"if",
"... | Return absolute path with path variables replaced as applicable | [
"Return",
"absolute",
"path",
"with",
"path",
"variables",
"replaced",
"as",
"applicable"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/cfg.py#L71-L137 |
NASA-AMMOS/AIT-Core | ait/core/cfg.py | flatten | def flatten (d, *keys):
"""Flattens the dictionary d by merging keys in order such that later
keys take precedence over earlier keys.
"""
flat = { }
for k in keys:
flat = merge(flat, d.pop(k, { }))
return flat | python | def flatten (d, *keys):
"""Flattens the dictionary d by merging keys in order such that later
keys take precedence over earlier keys.
"""
flat = { }
for k in keys:
flat = merge(flat, d.pop(k, { }))
return flat | [
"def",
"flatten",
"(",
"d",
",",
"*",
"keys",
")",
":",
"flat",
"=",
"{",
"}",
"for",
"k",
"in",
"keys",
":",
"flat",
"=",
"merge",
"(",
"flat",
",",
"d",
".",
"pop",
"(",
"k",
",",
"{",
"}",
")",
")",
"return",
"flat"
] | Flattens the dictionary d by merging keys in order such that later
keys take precedence over earlier keys. | [
"Flattens",
"the",
"dictionary",
"d",
"by",
"merging",
"keys",
"in",
"order",
"such",
"that",
"later",
"keys",
"take",
"precedence",
"over",
"earlier",
"keys",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/cfg.py#L140-L150 |
NASA-AMMOS/AIT-Core | ait/core/cfg.py | loadYAML | def loadYAML (filename=None, data=None):
"""Loads either the given YAML configuration file or YAML data.
Returns None if there was an error reading from the configuration
file and logs an error message via ait.core.log.error().
"""
config = None
try:
if filename:
data = ope... | python | def loadYAML (filename=None, data=None):
"""Loads either the given YAML configuration file or YAML data.
Returns None if there was an error reading from the configuration
file and logs an error message via ait.core.log.error().
"""
config = None
try:
if filename:
data = ope... | [
"def",
"loadYAML",
"(",
"filename",
"=",
"None",
",",
"data",
"=",
"None",
")",
":",
"config",
"=",
"None",
"try",
":",
"if",
"filename",
":",
"data",
"=",
"open",
"(",
"filename",
",",
"'rt'",
")",
"config",
"=",
"yaml",
".",
"load",
"(",
"data",
... | Loads either the given YAML configuration file or YAML data.
Returns None if there was an error reading from the configuration
file and logs an error message via ait.core.log.error(). | [
"Loads",
"either",
"the",
"given",
"YAML",
"configuration",
"file",
"or",
"YAML",
"data",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/cfg.py#L153-L173 |
NASA-AMMOS/AIT-Core | ait/core/cfg.py | merge | def merge (d, o):
"""Recursively merges keys from o into d and returns d."""
for k in o.keys():
if type(o[k]) is dict and k in d:
merge(d[k], o[k])
else:
d[k] = o[k]
return d | python | def merge (d, o):
"""Recursively merges keys from o into d and returns d."""
for k in o.keys():
if type(o[k]) is dict and k in d:
merge(d[k], o[k])
else:
d[k] = o[k]
return d | [
"def",
"merge",
"(",
"d",
",",
"o",
")",
":",
"for",
"k",
"in",
"o",
".",
"keys",
"(",
")",
":",
"if",
"type",
"(",
"o",
"[",
"k",
"]",
")",
"is",
"dict",
"and",
"k",
"in",
"d",
":",
"merge",
"(",
"d",
"[",
"k",
"]",
",",
"o",
"[",
"k... | Recursively merges keys from o into d and returns d. | [
"Recursively",
"merges",
"keys",
"from",
"o",
"into",
"d",
"and",
"returns",
"d",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/cfg.py#L176-L183 |
NASA-AMMOS/AIT-Core | ait/core/cfg.py | AitConfig._getattr_ | def _getattr_ (self, name):
"""Internal method. Used by __getattr__() and __getitem__()."""
value = self._config.get(name)
if type(value) is dict:
value = AitConfig(self._filename, config=value)
return value | python | def _getattr_ (self, name):
"""Internal method. Used by __getattr__() and __getitem__()."""
value = self._config.get(name)
if type(value) is dict:
value = AitConfig(self._filename, config=value)
return value | [
"def",
"_getattr_",
"(",
"self",
",",
"name",
")",
":",
"value",
"=",
"self",
".",
"_config",
".",
"get",
"(",
"name",
")",
"if",
"type",
"(",
"value",
")",
"is",
"dict",
":",
"value",
"=",
"AitConfig",
"(",
"self",
".",
"_filename",
",",
"config",... | Internal method. Used by __getattr__() and __getitem__(). | [
"Internal",
"method",
".",
"Used",
"by",
"__getattr__",
"()",
"and",
"__getitem__",
"()",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/cfg.py#L287-L294 |
NASA-AMMOS/AIT-Core | ait/core/cfg.py | AitConfig._directory | def _directory (self):
"""The directory for this AitConfig."""
if self._filename is None:
return os.path.join(self._ROOT_DIR, 'config')
else:
return os.path.dirname(self._filename) | python | def _directory (self):
"""The directory for this AitConfig."""
if self._filename is None:
return os.path.join(self._ROOT_DIR, 'config')
else:
return os.path.dirname(self._filename) | [
"def",
"_directory",
"(",
"self",
")",
":",
"if",
"self",
".",
"_filename",
"is",
"None",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"_ROOT_DIR",
",",
"'config'",
")",
"else",
":",
"return",
"os",
".",
"path",
".",
"dirname",
... | The directory for this AitConfig. | [
"The",
"directory",
"for",
"this",
"AitConfig",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/cfg.py#L297-L302 |
NASA-AMMOS/AIT-Core | ait/core/cfg.py | AitConfig._datapaths | def _datapaths(self):
"""Returns a simple key-value map for easy access to data paths"""
paths = { }
try:
data = self._config['data']
for k in data:
paths[k] = data[k]['path']
except KeyError as e:
raise AitConfigMissing(e.message)
... | python | def _datapaths(self):
"""Returns a simple key-value map for easy access to data paths"""
paths = { }
try:
data = self._config['data']
for k in data:
paths[k] = data[k]['path']
except KeyError as e:
raise AitConfigMissing(e.message)
... | [
"def",
"_datapaths",
"(",
"self",
")",
":",
"paths",
"=",
"{",
"}",
"try",
":",
"data",
"=",
"self",
".",
"_config",
"[",
"'data'",
"]",
"for",
"k",
"in",
"data",
":",
"paths",
"[",
"k",
"]",
"=",
"data",
"[",
"k",
"]",
"[",
"'path'",
"]",
"e... | Returns a simple key-value map for easy access to data paths | [
"Returns",
"a",
"simple",
"key",
"-",
"value",
"map",
"for",
"easy",
"access",
"to",
"data",
"paths"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/cfg.py#L315-L327 |
NASA-AMMOS/AIT-Core | ait/core/cfg.py | AitConfig.reload | def reload (self, filename=None, data=None):
"""Reloads the a AIT configuration.
The AIT configuration is automatically loaded when the AIT
package is first imported. To replace the configuration, call
reload() (defaults to the current config.filename) or
reload(new_filename).
... | python | def reload (self, filename=None, data=None):
"""Reloads the a AIT configuration.
The AIT configuration is automatically loaded when the AIT
package is first imported. To replace the configuration, call
reload() (defaults to the current config.filename) or
reload(new_filename).
... | [
"def",
"reload",
"(",
"self",
",",
"filename",
"=",
"None",
",",
"data",
"=",
"None",
")",
":",
"if",
"data",
"is",
"None",
"and",
"filename",
"is",
"None",
":",
"filename",
"=",
"self",
".",
"_filename",
"self",
".",
"_config",
"=",
"loadYAML",
"(",... | Reloads the a AIT configuration.
The AIT configuration is automatically loaded when the AIT
package is first imported. To replace the configuration, call
reload() (defaults to the current config.filename) or
reload(new_filename). | [
"Reloads",
"the",
"a",
"AIT",
"configuration",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/cfg.py#L329-L359 |
NASA-AMMOS/AIT-Core | ait/core/cfg.py | AitConfig.get | def get (self, name, default=None):
"""Returns the attribute value *AitConfig.name* or *default*
if name does not exist.
The name may be a series of attributes separated periods. For
example, "foo.bar.baz". In that case, lookups are attempted
in the following order until one s... | python | def get (self, name, default=None):
"""Returns the attribute value *AitConfig.name* or *default*
if name does not exist.
The name may be a series of attributes separated periods. For
example, "foo.bar.baz". In that case, lookups are attempted
in the following order until one s... | [
"def",
"get",
"(",
"self",
",",
"name",
",",
"default",
"=",
"None",
")",
":",
"if",
"name",
"in",
"self",
":",
"return",
"self",
"[",
"name",
"]",
"config",
"=",
"self",
"parts",
"=",
"name",
".",
"split",
"(",
"'.'",
")",
"heads",
"=",
"parts",... | Returns the attribute value *AitConfig.name* or *default*
if name does not exist.
The name may be a series of attributes separated periods. For
example, "foo.bar.baz". In that case, lookups are attempted
in the following order until one succeeeds:
1. AitConfig['foo.bar.b... | [
"Returns",
"the",
"attribute",
"value",
"*",
"AitConfig",
".",
"name",
"*",
"or",
"*",
"default",
"*",
"if",
"name",
"does",
"not",
"exist",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/cfg.py#L362-L388 |
NASA-AMMOS/AIT-Core | ait/core/cfg.py | AitConfig.addPathVariables | def addPathVariables(self, pathvars):
""" Adds path variables to the pathvars map property"""
if type(pathvars) is dict:
self._pathvars = merge(self._pathvars, pathvars) | python | def addPathVariables(self, pathvars):
""" Adds path variables to the pathvars map property"""
if type(pathvars) is dict:
self._pathvars = merge(self._pathvars, pathvars) | [
"def",
"addPathVariables",
"(",
"self",
",",
"pathvars",
")",
":",
"if",
"type",
"(",
"pathvars",
")",
"is",
"dict",
":",
"self",
".",
"_pathvars",
"=",
"merge",
"(",
"self",
".",
"_pathvars",
",",
"pathvars",
")"
] | Adds path variables to the pathvars map property | [
"Adds",
"path",
"variables",
"to",
"the",
"pathvars",
"map",
"property"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/cfg.py#L407-L410 |
NASA-AMMOS/AIT-Core | ait/core/dtype.py | getPDT | def getPDT(typename):
"""get(typename) -> PrimitiveType
Returns the PrimitiveType for typename or None.
"""
if typename not in PrimitiveTypeMap and typename.startswith("S"):
PrimitiveTypeMap[typename] = PrimitiveType(typename)
return PrimitiveTypeMap.get(typename, None) | python | def getPDT(typename):
"""get(typename) -> PrimitiveType
Returns the PrimitiveType for typename or None.
"""
if typename not in PrimitiveTypeMap and typename.startswith("S"):
PrimitiveTypeMap[typename] = PrimitiveType(typename)
return PrimitiveTypeMap.get(typename, None) | [
"def",
"getPDT",
"(",
"typename",
")",
":",
"if",
"typename",
"not",
"in",
"PrimitiveTypeMap",
"and",
"typename",
".",
"startswith",
"(",
"\"S\"",
")",
":",
"PrimitiveTypeMap",
"[",
"typename",
"]",
"=",
"PrimitiveType",
"(",
"typename",
")",
"return",
"Prim... | get(typename) -> PrimitiveType
Returns the PrimitiveType for typename or None. | [
"get",
"(",
"typename",
")",
"-",
">",
"PrimitiveType"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/dtype.py#L797-L805 |
NASA-AMMOS/AIT-Core | ait/core/dtype.py | get | def get(typename):
"""get(typename) -> PrimitiveType or ComplexType
Returns the PrimitiveType or ComplexType for typename or None.
"""
dt = getPDT(typename) or getCDT(typename)
if dt is None:
pdt, nelems = ArrayType.parse(typename)
if pdt and nelems:
dt = ArrayType(pdt,... | python | def get(typename):
"""get(typename) -> PrimitiveType or ComplexType
Returns the PrimitiveType or ComplexType for typename or None.
"""
dt = getPDT(typename) or getCDT(typename)
if dt is None:
pdt, nelems = ArrayType.parse(typename)
if pdt and nelems:
dt = ArrayType(pdt,... | [
"def",
"get",
"(",
"typename",
")",
":",
"dt",
"=",
"getPDT",
"(",
"typename",
")",
"or",
"getCDT",
"(",
"typename",
")",
"if",
"dt",
"is",
"None",
":",
"pdt",
",",
"nelems",
"=",
"ArrayType",
".",
"parse",
"(",
"typename",
")",
"if",
"pdt",
"and",... | get(typename) -> PrimitiveType or ComplexType
Returns the PrimitiveType or ComplexType for typename or None. | [
"get",
"(",
"typename",
")",
"-",
">",
"PrimitiveType",
"or",
"ComplexType"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/dtype.py#L816-L828 |
NASA-AMMOS/AIT-Core | ait/core/dtype.py | PrimitiveType.decode | def decode(self, bytes, raw=False):
"""decode(bytearray, raw=False) -> value
Decodes the given bytearray according to this PrimitiveType
definition.
NOTE: The parameter ``raw`` is present to adhere to the
``decode()`` inteface, but has no effect for PrimitiveType
defini... | python | def decode(self, bytes, raw=False):
"""decode(bytearray, raw=False) -> value
Decodes the given bytearray according to this PrimitiveType
definition.
NOTE: The parameter ``raw`` is present to adhere to the
``decode()`` inteface, but has no effect for PrimitiveType
defini... | [
"def",
"decode",
"(",
"self",
",",
"bytes",
",",
"raw",
"=",
"False",
")",
":",
"return",
"struct",
".",
"unpack",
"(",
"self",
".",
"format",
",",
"buffer",
"(",
"bytes",
")",
")",
"[",
"0",
"]"
] | decode(bytearray, raw=False) -> value
Decodes the given bytearray according to this PrimitiveType
definition.
NOTE: The parameter ``raw`` is present to adhere to the
``decode()`` inteface, but has no effect for PrimitiveType
definitions. | [
"decode",
"(",
"bytearray",
"raw",
"=",
"False",
")",
"-",
">",
"value"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/dtype.py#L240-L250 |
NASA-AMMOS/AIT-Core | ait/core/dtype.py | PrimitiveType.validate | def validate(self, value, messages=None, prefix=None):
"""validate(value[, messages[, prefix]]) -> True | False
Validates the given value according to this PrimitiveType
definition. Validation error messages are appended to an optional
messages array, each with the optional message pre... | python | def validate(self, value, messages=None, prefix=None):
"""validate(value[, messages[, prefix]]) -> True | False
Validates the given value according to this PrimitiveType
definition. Validation error messages are appended to an optional
messages array, each with the optional message pre... | [
"def",
"validate",
"(",
"self",
",",
"value",
",",
"messages",
"=",
"None",
",",
"prefix",
"=",
"None",
")",
":",
"valid",
"=",
"False",
"def",
"log",
"(",
"msg",
")",
":",
"if",
"messages",
"is",
"not",
"None",
":",
"if",
"prefix",
"is",
"not",
... | validate(value[, messages[, prefix]]) -> True | False
Validates the given value according to this PrimitiveType
definition. Validation error messages are appended to an optional
messages array, each with the optional message prefix. | [
"validate",
"(",
"value",
"[",
"messages",
"[",
"prefix",
"]]",
")",
"-",
">",
"True",
"|",
"False"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/dtype.py#L256-L288 |
NASA-AMMOS/AIT-Core | ait/core/dtype.py | ArrayType._assertIndex | def _assertIndex(self, index):
"""Raise TypeError or IndexError if index is not an integer or out of
range for the number of elements in this array, respectively.
"""
if type(index) is not int:
raise TypeError('list indices must be integers')
if index < 0 or index >= ... | python | def _assertIndex(self, index):
"""Raise TypeError or IndexError if index is not an integer or out of
range for the number of elements in this array, respectively.
"""
if type(index) is not int:
raise TypeError('list indices must be integers')
if index < 0 or index >= ... | [
"def",
"_assertIndex",
"(",
"self",
",",
"index",
")",
":",
"if",
"type",
"(",
"index",
")",
"is",
"not",
"int",
":",
"raise",
"TypeError",
"(",
"'list indices must be integers'",
")",
"if",
"index",
"<",
"0",
"or",
"index",
">=",
"self",
".",
"nelems",
... | Raise TypeError or IndexError if index is not an integer or out of
range for the number of elements in this array, respectively. | [
"Raise",
"TypeError",
"or",
"IndexError",
"if",
"index",
"is",
"not",
"an",
"integer",
"or",
"out",
"of",
"range",
"for",
"the",
"number",
"of",
"elements",
"in",
"this",
"array",
"respectively",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/dtype.py#L326-L333 |
NASA-AMMOS/AIT-Core | ait/core/dtype.py | ArrayType.decode | def decode(self, bytes, index=None, raw=False):
"""decode(bytes[[, index], raw=False]) -> value1, ..., valueN
Decodes the given sequence of bytes according to this Array's
element type.
If the optional `index` parameter is an integer or slice, then
only the element(s) at the sp... | python | def decode(self, bytes, index=None, raw=False):
"""decode(bytes[[, index], raw=False]) -> value1, ..., valueN
Decodes the given sequence of bytes according to this Array's
element type.
If the optional `index` parameter is an integer or slice, then
only the element(s) at the sp... | [
"def",
"decode",
"(",
"self",
",",
"bytes",
",",
"index",
"=",
"None",
",",
"raw",
"=",
"False",
")",
":",
"if",
"index",
"is",
"None",
":",
"index",
"=",
"slice",
"(",
"0",
",",
"self",
".",
"nelems",
")",
"if",
"type",
"(",
"index",
")",
"is"... | decode(bytes[[, index], raw=False]) -> value1, ..., valueN
Decodes the given sequence of bytes according to this Array's
element type.
If the optional `index` parameter is an integer or slice, then
only the element(s) at the specified position(s) will be
decoded and returned. | [
"decode",
"(",
"bytes",
"[[",
"index",
"]",
"raw",
"=",
"False",
"]",
")",
"-",
">",
"value1",
"...",
"valueN"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/dtype.py#L362-L382 |
NASA-AMMOS/AIT-Core | ait/core/dtype.py | ArrayType.decodeElem | def decodeElem(self, bytes, index, raw=False):
"""Decodes a single element at array[index] from a sequence bytes
that contain data for the entire array.
"""
self._assertIndex(index)
start = index * self.type.nbytes
stop = start + self.type.nbytes
if stop > len(b... | python | def decodeElem(self, bytes, index, raw=False):
"""Decodes a single element at array[index] from a sequence bytes
that contain data for the entire array.
"""
self._assertIndex(index)
start = index * self.type.nbytes
stop = start + self.type.nbytes
if stop > len(b... | [
"def",
"decodeElem",
"(",
"self",
",",
"bytes",
",",
"index",
",",
"raw",
"=",
"False",
")",
":",
"self",
".",
"_assertIndex",
"(",
"index",
")",
"start",
"=",
"index",
"*",
"self",
".",
"type",
".",
"nbytes",
"stop",
"=",
"start",
"+",
"self",
"."... | Decodes a single element at array[index] from a sequence bytes
that contain data for the entire array. | [
"Decodes",
"a",
"single",
"element",
"at",
"array",
"[",
"index",
"]",
"from",
"a",
"sequence",
"bytes",
"that",
"contain",
"data",
"for",
"the",
"entire",
"array",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/dtype.py#L385-L398 |
NASA-AMMOS/AIT-Core | ait/core/dtype.py | ArrayType.encode | def encode(self, *args):
"""encode(value1[, ...]) -> bytes
Encodes the given values to a sequence of bytes according to this
Array's underlying element type
"""
if len(args) != self.nelems:
msg = 'ArrayType %s encode() requires %d values, but received %d.'
... | python | def encode(self, *args):
"""encode(value1[, ...]) -> bytes
Encodes the given values to a sequence of bytes according to this
Array's underlying element type
"""
if len(args) != self.nelems:
msg = 'ArrayType %s encode() requires %d values, but received %d.'
... | [
"def",
"encode",
"(",
"self",
",",
"*",
"args",
")",
":",
"if",
"len",
"(",
"args",
")",
"!=",
"self",
".",
"nelems",
":",
"msg",
"=",
"'ArrayType %s encode() requires %d values, but received %d.'",
"raise",
"ValueError",
"(",
"msg",
"%",
"(",
"self",
".",
... | encode(value1[, ...]) -> bytes
Encodes the given values to a sequence of bytes according to this
Array's underlying element type | [
"encode",
"(",
"value1",
"[",
"...",
"]",
")",
"-",
">",
"bytes"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/dtype.py#L401-L411 |
NASA-AMMOS/AIT-Core | ait/core/dtype.py | ArrayType.parse | def parse (name):
"""parse(name) -> [typename | None, nelems | None]
Parses an ArrayType name to return the element type name and
number of elements, e.g.:
>>> ArrayType.parse('MSB_U16[32]')
['MSB_U16', 32]
If typename cannot be determined, None is returned.
... | python | def parse (name):
"""parse(name) -> [typename | None, nelems | None]
Parses an ArrayType name to return the element type name and
number of elements, e.g.:
>>> ArrayType.parse('MSB_U16[32]')
['MSB_U16', 32]
If typename cannot be determined, None is returned.
... | [
"def",
"parse",
"(",
"name",
")",
":",
"parts",
"=",
"[",
"None",
",",
"None",
"]",
"start",
"=",
"name",
".",
"find",
"(",
"'['",
")",
"if",
"start",
"!=",
"-",
"1",
":",
"stop",
"=",
"name",
".",
"find",
"(",
"']'",
",",
"start",
")",
"if",... | parse(name) -> [typename | None, nelems | None]
Parses an ArrayType name to return the element type name and
number of elements, e.g.:
>>> ArrayType.parse('MSB_U16[32]')
['MSB_U16', 32]
If typename cannot be determined, None is returned.
Similarly, if nelems is... | [
"parse",
"(",
"name",
")",
"-",
">",
"[",
"typename",
"|",
"None",
"nelems",
"|",
"None",
"]"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/dtype.py#L415-L444 |
NASA-AMMOS/AIT-Core | ait/core/dtype.py | CmdType.cmddict | def cmddict(self):
"""PrimitiveType base for the ComplexType"""
if self._cmddict is None:
self._cmddict = cmd.getDefaultDict()
return self._cmddict | python | def cmddict(self):
"""PrimitiveType base for the ComplexType"""
if self._cmddict is None:
self._cmddict = cmd.getDefaultDict()
return self._cmddict | [
"def",
"cmddict",
"(",
"self",
")",
":",
"if",
"self",
".",
"_cmddict",
"is",
"None",
":",
"self",
".",
"_cmddict",
"=",
"cmd",
".",
"getDefaultDict",
"(",
")",
"return",
"self",
".",
"_cmddict"
] | PrimitiveType base for the ComplexType | [
"PrimitiveType",
"base",
"for",
"the",
"ComplexType"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/dtype.py#L468-L473 |
NASA-AMMOS/AIT-Core | ait/core/dtype.py | CmdType.encode | def encode(self, value):
"""encode(value) -> bytearray
Encodes the given value to a bytearray according to this
PrimitiveType definition.
"""
opcode = self.cmddict[value].opcode
return super(CmdType, self).encode(opcode) | python | def encode(self, value):
"""encode(value) -> bytearray
Encodes the given value to a bytearray according to this
PrimitiveType definition.
"""
opcode = self.cmddict[value].opcode
return super(CmdType, self).encode(opcode) | [
"def",
"encode",
"(",
"self",
",",
"value",
")",
":",
"opcode",
"=",
"self",
".",
"cmddict",
"[",
"value",
"]",
".",
"opcode",
"return",
"super",
"(",
"CmdType",
",",
"self",
")",
".",
"encode",
"(",
"opcode",
")"
] | encode(value) -> bytearray
Encodes the given value to a bytearray according to this
PrimitiveType definition. | [
"encode",
"(",
"value",
")",
"-",
">",
"bytearray"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/dtype.py#L480-L487 |
NASA-AMMOS/AIT-Core | ait/core/dtype.py | CmdType.decode | def decode(self, bytes, raw=False):
"""decode(bytearray, raw=False) -> value
Decodes the given bytearray and returns the corresponding
Command Definition (:class:`CmdDefn`) for the underlying
'MSB_U16' command opcode.
If the optional parameter ``raw`` is ``True``, the command
... | python | def decode(self, bytes, raw=False):
"""decode(bytearray, raw=False) -> value
Decodes the given bytearray and returns the corresponding
Command Definition (:class:`CmdDefn`) for the underlying
'MSB_U16' command opcode.
If the optional parameter ``raw`` is ``True``, the command
... | [
"def",
"decode",
"(",
"self",
",",
"bytes",
",",
"raw",
"=",
"False",
")",
":",
"opcode",
"=",
"super",
"(",
"CmdType",
",",
"self",
")",
".",
"decode",
"(",
"bytes",
")",
"result",
"=",
"None",
"if",
"raw",
":",
"result",
"=",
"opcode",
"elif",
... | decode(bytearray, raw=False) -> value
Decodes the given bytearray and returns the corresponding
Command Definition (:class:`CmdDefn`) for the underlying
'MSB_U16' command opcode.
If the optional parameter ``raw`` is ``True``, the command
opcode itself will be returned instead o... | [
"decode",
"(",
"bytearray",
"raw",
"=",
"False",
")",
"-",
">",
"value"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/dtype.py#L489-L510 |
NASA-AMMOS/AIT-Core | ait/core/dtype.py | EVRType.evrs | def evrs(self):
"""Getter EVRs dictionary"""
if self._evrs is None:
import ait.core.evr as evr
self._evrs = evr.getDefaultDict()
return self._evrs | python | def evrs(self):
"""Getter EVRs dictionary"""
if self._evrs is None:
import ait.core.evr as evr
self._evrs = evr.getDefaultDict()
return self._evrs | [
"def",
"evrs",
"(",
"self",
")",
":",
"if",
"self",
".",
"_evrs",
"is",
"None",
":",
"import",
"ait",
".",
"core",
".",
"evr",
"as",
"evr",
"self",
".",
"_evrs",
"=",
"evr",
".",
"getDefaultDict",
"(",
")",
"return",
"self",
".",
"_evrs"
] | Getter EVRs dictionary | [
"Getter",
"EVRs",
"dictionary"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/dtype.py#L535-L541 |
NASA-AMMOS/AIT-Core | ait/core/dtype.py | EVRType.encode | def encode(self, value):
"""encode(value) -> bytearray
Encodes the given value to a bytearray according to this
Complex Type definition.
"""
e = self.evrs.get(value, None)
if not e:
log.error(str(value) + " not found as EVR. Cannot encode.")
retur... | python | def encode(self, value):
"""encode(value) -> bytearray
Encodes the given value to a bytearray according to this
Complex Type definition.
"""
e = self.evrs.get(value, None)
if not e:
log.error(str(value) + " not found as EVR. Cannot encode.")
retur... | [
"def",
"encode",
"(",
"self",
",",
"value",
")",
":",
"e",
"=",
"self",
".",
"evrs",
".",
"get",
"(",
"value",
",",
"None",
")",
"if",
"not",
"e",
":",
"log",
".",
"error",
"(",
"str",
"(",
"value",
")",
"+",
"\" not found as EVR. Cannot encode.\"",
... | encode(value) -> bytearray
Encodes the given value to a bytearray according to this
Complex Type definition. | [
"encode",
"(",
"value",
")",
"-",
">",
"bytearray"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/dtype.py#L548-L559 |
NASA-AMMOS/AIT-Core | ait/core/dtype.py | EVRType.decode | def decode(self, bytes, raw=False):
"""decode(bytearray, raw=False) -> value
Decodes the given bytearray according the corresponding
EVR Definition (:class:`EVRDefn`) for the underlying
'MSB_U16' EVR code.
If the optional parameter ``raw`` is ``True``, the EVR code
itse... | python | def decode(self, bytes, raw=False):
"""decode(bytearray, raw=False) -> value
Decodes the given bytearray according the corresponding
EVR Definition (:class:`EVRDefn`) for the underlying
'MSB_U16' EVR code.
If the optional parameter ``raw`` is ``True``, the EVR code
itse... | [
"def",
"decode",
"(",
"self",
",",
"bytes",
",",
"raw",
"=",
"False",
")",
":",
"code",
"=",
"super",
"(",
"EVRType",
",",
"self",
")",
".",
"decode",
"(",
"bytes",
")",
"result",
"=",
"None",
"if",
"raw",
":",
"result",
"=",
"code",
"elif",
"cod... | decode(bytearray, raw=False) -> value
Decodes the given bytearray according the corresponding
EVR Definition (:class:`EVRDefn`) for the underlying
'MSB_U16' EVR code.
If the optional parameter ``raw`` is ``True``, the EVR code
itself will be returned instead of the EVR Definiti... | [
"decode",
"(",
"bytearray",
"raw",
"=",
"False",
")",
"-",
">",
"value"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/dtype.py#L561-L583 |
NASA-AMMOS/AIT-Core | ait/core/dtype.py | Time8Type.decode | def decode(self, bytes, raw=False):
"""decode(bytearray, raw=False) -> value
Decodes the given bytearray and returns the number of
(fractional) seconds.
If the optional parameter ``raw`` is ``True``, the byte (U8)
itself will be returned.
"""
result = super(Tim... | python | def decode(self, bytes, raw=False):
"""decode(bytearray, raw=False) -> value
Decodes the given bytearray and returns the number of
(fractional) seconds.
If the optional parameter ``raw`` is ``True``, the byte (U8)
itself will be returned.
"""
result = super(Tim... | [
"def",
"decode",
"(",
"self",
",",
"bytes",
",",
"raw",
"=",
"False",
")",
":",
"result",
"=",
"super",
"(",
"Time8Type",
",",
"self",
")",
".",
"decode",
"(",
"bytes",
")",
"if",
"not",
"raw",
":",
"result",
"/=",
"256.0",
"return",
"result"
] | decode(bytearray, raw=False) -> value
Decodes the given bytearray and returns the number of
(fractional) seconds.
If the optional parameter ``raw`` is ``True``, the byte (U8)
itself will be returned. | [
"decode",
"(",
"bytearray",
"raw",
"=",
"False",
")",
"-",
">",
"value"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/dtype.py#L613-L628 |
NASA-AMMOS/AIT-Core | ait/core/dtype.py | Time32Type.encode | def encode(self, value):
"""encode(value) -> bytearray
Encodes the given value to a bytearray according to this
ComplexType definition.
"""
if type(value) is not datetime.datetime:
raise TypeError('encode() argument must be a Python datetime')
return super(T... | python | def encode(self, value):
"""encode(value) -> bytearray
Encodes the given value to a bytearray according to this
ComplexType definition.
"""
if type(value) is not datetime.datetime:
raise TypeError('encode() argument must be a Python datetime')
return super(T... | [
"def",
"encode",
"(",
"self",
",",
"value",
")",
":",
"if",
"type",
"(",
"value",
")",
"is",
"not",
"datetime",
".",
"datetime",
":",
"raise",
"TypeError",
"(",
"'encode() argument must be a Python datetime'",
")",
"return",
"super",
"(",
"Time32Type",
",",
... | encode(value) -> bytearray
Encodes the given value to a bytearray according to this
ComplexType definition. | [
"encode",
"(",
"value",
")",
"-",
">",
"bytearray"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/dtype.py#L648-L657 |
NASA-AMMOS/AIT-Core | ait/core/dtype.py | Time32Type.decode | def decode(self, bytes, raw=False):
"""decode(bytearray, raw=False) -> value
Decodes the given bytearray containing the elapsed time in
seconds since the GPS epoch and returns the corresponding
Python :class:`datetime`.
If the optional parameter ``raw`` is ``True``, the integra... | python | def decode(self, bytes, raw=False):
"""decode(bytearray, raw=False) -> value
Decodes the given bytearray containing the elapsed time in
seconds since the GPS epoch and returns the corresponding
Python :class:`datetime`.
If the optional parameter ``raw`` is ``True``, the integra... | [
"def",
"decode",
"(",
"self",
",",
"bytes",
",",
"raw",
"=",
"False",
")",
":",
"sec",
"=",
"super",
"(",
"Time32Type",
",",
"self",
")",
".",
"decode",
"(",
"bytes",
")",
"return",
"sec",
"if",
"raw",
"else",
"dmc",
".",
"toLocalTime",
"(",
"sec",... | decode(bytearray, raw=False) -> value
Decodes the given bytearray containing the elapsed time in
seconds since the GPS epoch and returns the corresponding
Python :class:`datetime`.
If the optional parameter ``raw`` is ``True``, the integral
number of seconds will be returned in... | [
"decode",
"(",
"bytearray",
"raw",
"=",
"False",
")",
"-",
">",
"value"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/dtype.py#L659-L670 |
NASA-AMMOS/AIT-Core | ait/core/dtype.py | Time40Type.encode | def encode(self, value):
"""encode(value) -> bytearray
Encodes the given value to a bytearray according to this
ComplexType definition.
"""
if type(value) is not datetime.datetime:
raise TypeError('encode() argument must be a Python datetime')
coarse = Time3... | python | def encode(self, value):
"""encode(value) -> bytearray
Encodes the given value to a bytearray according to this
ComplexType definition.
"""
if type(value) is not datetime.datetime:
raise TypeError('encode() argument must be a Python datetime')
coarse = Time3... | [
"def",
"encode",
"(",
"self",
",",
"value",
")",
":",
"if",
"type",
"(",
"value",
")",
"is",
"not",
"datetime",
".",
"datetime",
":",
"raise",
"TypeError",
"(",
"'encode() argument must be a Python datetime'",
")",
"coarse",
"=",
"Time32Type",
"(",
")",
".",... | encode(value) -> bytearray
Encodes the given value to a bytearray according to this
ComplexType definition. | [
"encode",
"(",
"value",
")",
"-",
">",
"bytearray"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/dtype.py#L694-L706 |
NASA-AMMOS/AIT-Core | ait/core/dtype.py | Time40Type.decode | def decode(self, bytes, raw=False):
"""decode(bytearray, raw=False) -> value
Decodes the given bytearray containing the elapsed time in
seconds plus 1/256 subseconds since the GPS epoch returns the
corresponding Python :class:`datetime`.
If the optional parameter ``raw`` is ``T... | python | def decode(self, bytes, raw=False):
"""decode(bytearray, raw=False) -> value
Decodes the given bytearray containing the elapsed time in
seconds plus 1/256 subseconds since the GPS epoch returns the
corresponding Python :class:`datetime`.
If the optional parameter ``raw`` is ``T... | [
"def",
"decode",
"(",
"self",
",",
"bytes",
",",
"raw",
"=",
"False",
")",
":",
"coarse",
"=",
"Time32Type",
"(",
")",
".",
"decode",
"(",
"bytes",
"[",
":",
"4",
"]",
",",
"raw",
")",
"fine",
"=",
"Time8Type",
"(",
")",
".",
"decode",
"(",
"by... | decode(bytearray, raw=False) -> value
Decodes the given bytearray containing the elapsed time in
seconds plus 1/256 subseconds since the GPS epoch returns the
corresponding Python :class:`datetime`.
If the optional parameter ``raw`` is ``True``, the number of
seconds and subsec... | [
"decode",
"(",
"bytearray",
"raw",
"=",
"False",
")",
"-",
">",
"value"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/dtype.py#L708-L725 |
NASA-AMMOS/AIT-Core | ait/core/val.py | YAMLProcessor.load | def load(self, ymlfile=None):
"""Load and process the YAML file"""
if ymlfile is not None:
self.ymlfile = ymlfile
try:
# If yaml should be 'cleaned' of document references
if self._clean:
self.data = self.process(self.ymlfile)
else... | python | def load(self, ymlfile=None):
"""Load and process the YAML file"""
if ymlfile is not None:
self.ymlfile = ymlfile
try:
# If yaml should be 'cleaned' of document references
if self._clean:
self.data = self.process(self.ymlfile)
else... | [
"def",
"load",
"(",
"self",
",",
"ymlfile",
"=",
"None",
")",
":",
"if",
"ymlfile",
"is",
"not",
"None",
":",
"self",
".",
"ymlfile",
"=",
"ymlfile",
"try",
":",
"# If yaml should be 'cleaned' of document references",
"if",
"self",
".",
"_clean",
":",
"self"... | Load and process the YAML file | [
"Load",
"and",
"process",
"the",
"YAML",
"file"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/val.py#L60-L77 |
NASA-AMMOS/AIT-Core | ait/core/val.py | YAMLProcessor.process | def process(self, ymlfile):
"""Cleans out all document tags from the YAML file to make it
JSON-friendly to work with the JSON Schema.
"""
output = ""
try:
# Need a list of line numbers where the documents resides
# Used for finding/displaying errors
... | python | def process(self, ymlfile):
"""Cleans out all document tags from the YAML file to make it
JSON-friendly to work with the JSON Schema.
"""
output = ""
try:
# Need a list of line numbers where the documents resides
# Used for finding/displaying errors
... | [
"def",
"process",
"(",
"self",
",",
"ymlfile",
")",
":",
"output",
"=",
"\"\"",
"try",
":",
"# Need a list of line numbers where the documents resides",
"# Used for finding/displaying errors",
"self",
".",
"doclines",
"=",
"[",
"]",
"linenum",
"=",
"None",
"with",
"... | Cleans out all document tags from the YAML file to make it
JSON-friendly to work with the JSON Schema. | [
"Cleans",
"out",
"all",
"document",
"tags",
"from",
"the",
"YAML",
"file",
"to",
"make",
"it",
"JSON",
"-",
"friendly",
"to",
"work",
"with",
"the",
"JSON",
"Schema",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/val.py#L79-L119 |
NASA-AMMOS/AIT-Core | ait/core/val.py | SchemaProcessor.load | def load(self, schemafile=None):
"""Load and process the schema file"""
if schemafile is not None:
self._schemafile = schemafile
try:
self.data = json.load(open(self._schemafile))
except (IOError, ValueError), e:
msg = "Could not load schema file '" +... | python | def load(self, schemafile=None):
"""Load and process the schema file"""
if schemafile is not None:
self._schemafile = schemafile
try:
self.data = json.load(open(self._schemafile))
except (IOError, ValueError), e:
msg = "Could not load schema file '" +... | [
"def",
"load",
"(",
"self",
",",
"schemafile",
"=",
"None",
")",
":",
"if",
"schemafile",
"is",
"not",
"None",
":",
"self",
".",
"_schemafile",
"=",
"schemafile",
"try",
":",
"self",
".",
"data",
"=",
"json",
".",
"load",
"(",
"open",
"(",
"self",
... | Load and process the schema file | [
"Load",
"and",
"process",
"the",
"schema",
"file"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/val.py#L150-L161 |
NASA-AMMOS/AIT-Core | ait/core/val.py | ErrorHandler.pretty | def pretty(self, start, end, e, messages=None):
"""Pretties up the output error message so it is readable
and designates where the error came from"""
log.debug("Displaying document from lines '%i' to '%i'", start, end)
errorlist = []
if len(e.context) > 0:
errorlist... | python | def pretty(self, start, end, e, messages=None):
"""Pretties up the output error message so it is readable
and designates where the error came from"""
log.debug("Displaying document from lines '%i' to '%i'", start, end)
errorlist = []
if len(e.context) > 0:
errorlist... | [
"def",
"pretty",
"(",
"self",
",",
"start",
",",
"end",
",",
"e",
",",
"messages",
"=",
"None",
")",
":",
"log",
".",
"debug",
"(",
"\"Displaying document from lines '%i' to '%i'\"",
",",
"start",
",",
"end",
")",
"errorlist",
"=",
"[",
"]",
"if",
"len",... | Pretties up the output error message so it is readable
and designates where the error came from | [
"Pretties",
"up",
"the",
"output",
"error",
"message",
"so",
"it",
"is",
"readable",
"and",
"designates",
"where",
"the",
"error",
"came",
"from"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/val.py#L196-L340 |
NASA-AMMOS/AIT-Core | ait/core/val.py | Validator.schema_val | def schema_val(self, messages=None):
"Perform validation with processed YAML and Schema"
self._ymlproc = YAMLProcessor(self._ymlfile)
self._schemaproc = SchemaProcessor(self._schemafile)
valid = True
log.debug("BEGIN: Schema-based validation for YAML '%s' with schema '%s'", self... | python | def schema_val(self, messages=None):
"Perform validation with processed YAML and Schema"
self._ymlproc = YAMLProcessor(self._ymlfile)
self._schemaproc = SchemaProcessor(self._schemafile)
valid = True
log.debug("BEGIN: Schema-based validation for YAML '%s' with schema '%s'", self... | [
"def",
"schema_val",
"(",
"self",
",",
"messages",
"=",
"None",
")",
":",
"self",
".",
"_ymlproc",
"=",
"YAMLProcessor",
"(",
"self",
".",
"_ymlfile",
")",
"self",
".",
"_schemaproc",
"=",
"SchemaProcessor",
"(",
"self",
".",
"_schemafile",
")",
"valid",
... | Perform validation with processed YAML and Schema | [
"Perform",
"validation",
"with",
"processed",
"YAML",
"and",
"Schema"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/val.py#L367-L405 |
NASA-AMMOS/AIT-Core | ait/core/val.py | CmdValidator.content_val | def content_val(self, ymldata=None, messages=None):
"""Validates the Command Dictionary to ensure the contents for each of the fields
meets specific criteria regarding the expected types, byte ranges, etc."""
self._ymlproc = YAMLProcessor(self._ymlfile, False)
# Turn off the YAML Proce... | python | def content_val(self, ymldata=None, messages=None):
"""Validates the Command Dictionary to ensure the contents for each of the fields
meets specific criteria regarding the expected types, byte ranges, etc."""
self._ymlproc = YAMLProcessor(self._ymlfile, False)
# Turn off the YAML Proce... | [
"def",
"content_val",
"(",
"self",
",",
"ymldata",
"=",
"None",
",",
"messages",
"=",
"None",
")",
":",
"self",
".",
"_ymlproc",
"=",
"YAMLProcessor",
"(",
"self",
".",
"_ymlfile",
",",
"False",
")",
"# Turn off the YAML Processor",
"log",
".",
"debug",
"(... | Validates the Command Dictionary to ensure the contents for each of the fields
meets specific criteria regarding the expected types, byte ranges, etc. | [
"Validates",
"the",
"Command",
"Dictionary",
"to",
"ensure",
"the",
"contents",
"for",
"each",
"of",
"the",
"fields",
"meets",
"specific",
"criteria",
"regarding",
"the",
"expected",
"types",
"byte",
"ranges",
"etc",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/val.py#L420-L507 |
NASA-AMMOS/AIT-Core | ait/core/val.py | TlmValidator.validate | def validate(self, ymldata=None, messages=None):
"""Validates the Telemetry Dictionary definitions"""
schema_val = self.schema_val(messages)
if len(messages) == 0:
content_val = self.content_val(ymldata, messages)
return schema_val and content_val | python | def validate(self, ymldata=None, messages=None):
"""Validates the Telemetry Dictionary definitions"""
schema_val = self.schema_val(messages)
if len(messages) == 0:
content_val = self.content_val(ymldata, messages)
return schema_val and content_val | [
"def",
"validate",
"(",
"self",
",",
"ymldata",
"=",
"None",
",",
"messages",
"=",
"None",
")",
":",
"schema_val",
"=",
"self",
".",
"schema_val",
"(",
"messages",
")",
"if",
"len",
"(",
"messages",
")",
"==",
"0",
":",
"content_val",
"=",
"self",
".... | Validates the Telemetry Dictionary definitions | [
"Validates",
"the",
"Telemetry",
"Dictionary",
"definitions"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/val.py#L514-L520 |
NASA-AMMOS/AIT-Core | ait/core/val.py | TlmValidator.content_val | def content_val(self, ymldata=None, messages=None):
"""Validates the Telemetry Dictionary to ensure the contents for each of the fields
meets specific criteria regarding the expected types, byte ranges, etc."""
# Turn off the YAML Processor
log.debug("BEGIN: Content-based validation of ... | python | def content_val(self, ymldata=None, messages=None):
"""Validates the Telemetry Dictionary to ensure the contents for each of the fields
meets specific criteria regarding the expected types, byte ranges, etc."""
# Turn off the YAML Processor
log.debug("BEGIN: Content-based validation of ... | [
"def",
"content_val",
"(",
"self",
",",
"ymldata",
"=",
"None",
",",
"messages",
"=",
"None",
")",
":",
"# Turn off the YAML Processor",
"log",
".",
"debug",
"(",
"\"BEGIN: Content-based validation of Telemetry dictionary\"",
")",
"if",
"ymldata",
"is",
"not",
"None... | Validates the Telemetry Dictionary to ensure the contents for each of the fields
meets specific criteria regarding the expected types, byte ranges, etc. | [
"Validates",
"the",
"Telemetry",
"Dictionary",
"to",
"ensure",
"the",
"contents",
"for",
"each",
"of",
"the",
"fields",
"meets",
"specific",
"criteria",
"regarding",
"the",
"expected",
"types",
"byte",
"ranges",
"etc",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/val.py#L522-L601 |
NASA-AMMOS/AIT-Core | ait/core/val.py | UniquenessRule.check | def check(self, defn):
"""Performs the uniqueness check against the value list
maintained in this rule objects
"""
val = getattr(defn, self.attr)
if val is not None and val in self.val_list:
self.messages.append(self.msg % str(val))
# TODO self.messages.ap... | python | def check(self, defn):
"""Performs the uniqueness check against the value list
maintained in this rule objects
"""
val = getattr(defn, self.attr)
if val is not None and val in self.val_list:
self.messages.append(self.msg % str(val))
# TODO self.messages.ap... | [
"def",
"check",
"(",
"self",
",",
"defn",
")",
":",
"val",
"=",
"getattr",
"(",
"defn",
",",
"self",
".",
"attr",
")",
"if",
"val",
"is",
"not",
"None",
"and",
"val",
"in",
"self",
".",
"val_list",
":",
"self",
".",
"messages",
".",
"append",
"("... | Performs the uniqueness check against the value list
maintained in this rule objects | [
"Performs",
"the",
"uniqueness",
"check",
"against",
"the",
"value",
"list",
"maintained",
"in",
"this",
"rule",
"objects"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/val.py#L622-L633 |
NASA-AMMOS/AIT-Core | ait/core/val.py | TypeRule.check | def check(self, defn):
"""Performs isinstance check for the definitions data type.
Assumes the defn has 'type' and 'name' attributes
"""
allowedTypes = dtype.PrimitiveType, dtype.ArrayType
if not isinstance(defn.type, allowedTypes):
self.messages.append(self.msg % st... | python | def check(self, defn):
"""Performs isinstance check for the definitions data type.
Assumes the defn has 'type' and 'name' attributes
"""
allowedTypes = dtype.PrimitiveType, dtype.ArrayType
if not isinstance(defn.type, allowedTypes):
self.messages.append(self.msg % st... | [
"def",
"check",
"(",
"self",
",",
"defn",
")",
":",
"allowedTypes",
"=",
"dtype",
".",
"PrimitiveType",
",",
"dtype",
".",
"ArrayType",
"if",
"not",
"isinstance",
"(",
"defn",
".",
"type",
",",
"allowedTypes",
")",
":",
"self",
".",
"messages",
".",
"a... | Performs isinstance check for the definitions data type.
Assumes the defn has 'type' and 'name' attributes | [
"Performs",
"isinstance",
"check",
"for",
"the",
"definitions",
"data",
"type",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/val.py#L645-L654 |
NASA-AMMOS/AIT-Core | ait/core/val.py | TypeSizeRule.check | def check(self, defn, msg=None):
"""Uses the byte range in the object definition to determine
the number of bytes and compares to the size defined in the type.
Assumes the defn has 'type' and 'name' attributes, and a slice() method
"""
if isinstance(defn.type, dtype.PrimitiveTyp... | python | def check(self, defn, msg=None):
"""Uses the byte range in the object definition to determine
the number of bytes and compares to the size defined in the type.
Assumes the defn has 'type' and 'name' attributes, and a slice() method
"""
if isinstance(defn.type, dtype.PrimitiveTyp... | [
"def",
"check",
"(",
"self",
",",
"defn",
",",
"msg",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"defn",
".",
"type",
",",
"dtype",
".",
"PrimitiveType",
")",
":",
"# Check the nbytes designated in the YAML match the PDT",
"nbytes",
"=",
"defn",
".",
"t... | Uses the byte range in the object definition to determine
the number of bytes and compares to the size defined in the type.
Assumes the defn has 'type' and 'name' attributes, and a slice() method | [
"Uses",
"the",
"byte",
"range",
"in",
"the",
"object",
"definition",
"to",
"determine",
"the",
"number",
"of",
"bytes",
"and",
"compares",
"to",
"the",
"size",
"defined",
"in",
"the",
"type",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/val.py#L666-L683 |
NASA-AMMOS/AIT-Core | ait/core/val.py | ByteOrderRule.check | def check(self, defn, msg=None):
"""Uses the definitions slice() method to determine its start/stop
range.
"""
# Check enum does not contain boolean keys
if (defn.slice().start != self.prevstop):
self.messages.append(self.msg % str(defn.name))
# TODO self.... | python | def check(self, defn, msg=None):
"""Uses the definitions slice() method to determine its start/stop
range.
"""
# Check enum does not contain boolean keys
if (defn.slice().start != self.prevstop):
self.messages.append(self.msg % str(defn.name))
# TODO self.... | [
"def",
"check",
"(",
"self",
",",
"defn",
",",
"msg",
"=",
"None",
")",
":",
"# Check enum does not contain boolean keys",
"if",
"(",
"defn",
".",
"slice",
"(",
")",
".",
"start",
"!=",
"self",
".",
"prevstop",
")",
":",
"self",
".",
"messages",
".",
"... | Uses the definitions slice() method to determine its start/stop
range. | [
"Uses",
"the",
"definitions",
"slice",
"()",
"method",
"to",
"determine",
"its",
"start",
"/",
"stop",
"range",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/val.py#L723-L733 |
NASA-AMMOS/AIT-Core | ait/core/api.py | wait | def wait (cond, msg=None, _timeout=10, _raiseException=True):
"""Waits either a specified number of seconds, e.g.:
.. code-block:: python
wait(1.2)
or for a given condition to be True. Conditions may be take
several forms: Python string expression, lambda, or function,
e.g.:
.. code... | python | def wait (cond, msg=None, _timeout=10, _raiseException=True):
"""Waits either a specified number of seconds, e.g.:
.. code-block:: python
wait(1.2)
or for a given condition to be True. Conditions may be take
several forms: Python string expression, lambda, or function,
e.g.:
.. code... | [
"def",
"wait",
"(",
"cond",
",",
"msg",
"=",
"None",
",",
"_timeout",
"=",
"10",
",",
"_raiseException",
"=",
"True",
")",
":",
"status",
"=",
"False",
"delay",
"=",
"0.25",
"elapsed",
"=",
"0",
"if",
"msg",
"is",
"None",
"and",
"type",
"(",
"cond"... | Waits either a specified number of seconds, e.g.:
.. code-block:: python
wait(1.2)
or for a given condition to be True. Conditions may be take
several forms: Python string expression, lambda, or function,
e.g.:
.. code-block:: python
wait('instrument_mode == "SAFE"')
wa... | [
"Waits",
"either",
"a",
"specified",
"number",
"of",
"seconds",
"e",
".",
"g",
".",
":"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/api.py#L494-L573 |
NASA-AMMOS/AIT-Core | ait/core/api.py | CmdAPI.send | def send (self, command, *args, **kwargs):
"""Creates, validates, and sends the given command as a UDP
packet to the destination (host, port) specified when this
CmdAPI was created.
Returns True if the command was created, valid, and sent,
False otherwise.
"""
st... | python | def send (self, command, *args, **kwargs):
"""Creates, validates, and sends the given command as a UDP
packet to the destination (host, port) specified when this
CmdAPI was created.
Returns True if the command was created, valid, and sent,
False otherwise.
"""
st... | [
"def",
"send",
"(",
"self",
",",
"command",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"status",
"=",
"False",
"cmdobj",
"=",
"self",
".",
"_cmddict",
".",
"create",
"(",
"command",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"messa... | Creates, validates, and sends the given command as a UDP
packet to the destination (host, port) specified when this
CmdAPI was created.
Returns True if the command was created, valid, and sent,
False otherwise. | [
"Creates",
"validates",
"and",
"sends",
"the",
"given",
"command",
"as",
"a",
"UDP",
"packet",
"to",
"the",
"destination",
"(",
"host",
"port",
")",
"specified",
"when",
"this",
"CmdAPI",
"was",
"created",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/api.py#L124-L160 |
NASA-AMMOS/AIT-Core | ait/core/api.py | GeventDeque._pop | def _pop(self, block=True, timeout=None, left=False):
"""Removes and returns the an item from this GeventDeque.
This is an internal method, called by the public methods
pop() and popleft().
"""
item = None
timer = None
deque = self._deque
empty = IndexEr... | python | def _pop(self, block=True, timeout=None, left=False):
"""Removes and returns the an item from this GeventDeque.
This is an internal method, called by the public methods
pop() and popleft().
"""
item = None
timer = None
deque = self._deque
empty = IndexEr... | [
"def",
"_pop",
"(",
"self",
",",
"block",
"=",
"True",
",",
"timeout",
"=",
"None",
",",
"left",
"=",
"False",
")",
":",
"item",
"=",
"None",
"timer",
"=",
"None",
"deque",
"=",
"self",
".",
"_deque",
"empty",
"=",
"IndexError",
"(",
"'pop from an em... | Removes and returns the an item from this GeventDeque.
This is an internal method, called by the public methods
pop() and popleft(). | [
"Removes",
"and",
"returns",
"the",
"an",
"item",
"from",
"this",
"GeventDeque",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/api.py#L207-L241 |
NASA-AMMOS/AIT-Core | ait/core/api.py | GeventDeque.append | def append(self, item):
"""Add item to the right side of the GeventDeque.
This method does not block. Either the GeventDeque grows to
consume available memory, or if this GeventDeque has and is at
maxlen, the leftmost item is removed.
"""
self._deque.append(item)
... | python | def append(self, item):
"""Add item to the right side of the GeventDeque.
This method does not block. Either the GeventDeque grows to
consume available memory, or if this GeventDeque has and is at
maxlen, the leftmost item is removed.
"""
self._deque.append(item)
... | [
"def",
"append",
"(",
"self",
",",
"item",
")",
":",
"self",
".",
"_deque",
".",
"append",
"(",
"item",
")",
"self",
".",
"notEmpty",
".",
"set",
"(",
")"
] | Add item to the right side of the GeventDeque.
This method does not block. Either the GeventDeque grows to
consume available memory, or if this GeventDeque has and is at
maxlen, the leftmost item is removed. | [
"Add",
"item",
"to",
"the",
"right",
"side",
"of",
"the",
"GeventDeque",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/api.py#L268-L276 |
NASA-AMMOS/AIT-Core | ait/core/api.py | GeventDeque.appendleft | def appendleft(self, item):
"""Add item to the left side of the GeventDeque.
This method does not block. Either the GeventDeque grows to
consume available memory, or if this GeventDeque has and is at
maxlen, the rightmost item is removed.
"""
self._deque.appendleft(item... | python | def appendleft(self, item):
"""Add item to the left side of the GeventDeque.
This method does not block. Either the GeventDeque grows to
consume available memory, or if this GeventDeque has and is at
maxlen, the rightmost item is removed.
"""
self._deque.appendleft(item... | [
"def",
"appendleft",
"(",
"self",
",",
"item",
")",
":",
"self",
".",
"_deque",
".",
"appendleft",
"(",
"item",
")",
"self",
".",
"notEmpty",
".",
"set",
"(",
")"
] | Add item to the left side of the GeventDeque.
This method does not block. Either the GeventDeque grows to
consume available memory, or if this GeventDeque has and is at
maxlen, the rightmost item is removed. | [
"Add",
"item",
"to",
"the",
"left",
"side",
"of",
"the",
"GeventDeque",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/api.py#L278-L286 |
NASA-AMMOS/AIT-Core | ait/core/api.py | GeventDeque.extend | def extend(self, iterable):
"""Extend the right side of this GeventDeque by appending
elements from the iterable argument.
"""
self._deque.extend(iterable)
if len(self._deque) > 0:
self.notEmpty.set() | python | def extend(self, iterable):
"""Extend the right side of this GeventDeque by appending
elements from the iterable argument.
"""
self._deque.extend(iterable)
if len(self._deque) > 0:
self.notEmpty.set() | [
"def",
"extend",
"(",
"self",
",",
"iterable",
")",
":",
"self",
".",
"_deque",
".",
"extend",
"(",
"iterable",
")",
"if",
"len",
"(",
"self",
".",
"_deque",
")",
">",
"0",
":",
"self",
".",
"notEmpty",
".",
"set",
"(",
")"
] | Extend the right side of this GeventDeque by appending
elements from the iterable argument. | [
"Extend",
"the",
"right",
"side",
"of",
"this",
"GeventDeque",
"by",
"appending",
"elements",
"from",
"the",
"iterable",
"argument",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/api.py#L299-L305 |
NASA-AMMOS/AIT-Core | ait/core/api.py | GeventDeque.extendleft | def extendleft(self, iterable):
"""Extend the left side of this GeventDeque by appending
elements from the iterable argument. Note, the series of left
appends results in reversing the order of elements in the
iterable argument.
"""
self._deque.extendleft(iterable)
... | python | def extendleft(self, iterable):
"""Extend the left side of this GeventDeque by appending
elements from the iterable argument. Note, the series of left
appends results in reversing the order of elements in the
iterable argument.
"""
self._deque.extendleft(iterable)
... | [
"def",
"extendleft",
"(",
"self",
",",
"iterable",
")",
":",
"self",
".",
"_deque",
".",
"extendleft",
"(",
"iterable",
")",
"if",
"len",
"(",
"self",
".",
"_deque",
")",
">",
"0",
":",
"self",
".",
"notEmpty",
".",
"set",
"(",
")"
] | Extend the left side of this GeventDeque by appending
elements from the iterable argument. Note, the series of left
appends results in reversing the order of elements in the
iterable argument. | [
"Extend",
"the",
"left",
"side",
"of",
"this",
"GeventDeque",
"by",
"appending",
"elements",
"from",
"the",
"iterable",
"argument",
".",
"Note",
"the",
"series",
"of",
"left",
"appends",
"results",
"in",
"reversing",
"the",
"order",
"of",
"elements",
"in",
"... | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/api.py#L307-L315 |
NASA-AMMOS/AIT-Core | ait/core/api.py | GeventDeque.popleft | def popleft(self, block=True, timeout=None):
"""Remove and return an item from the right side of the
GeventDeque. If no elements are present, raises an IndexError.
If optional args *block* is True and *timeout* is ``None``
(the default), block if necessary until an item is
avail... | python | def popleft(self, block=True, timeout=None):
"""Remove and return an item from the right side of the
GeventDeque. If no elements are present, raises an IndexError.
If optional args *block* is True and *timeout* is ``None``
(the default), block if necessary until an item is
avail... | [
"def",
"popleft",
"(",
"self",
",",
"block",
"=",
"True",
",",
"timeout",
"=",
"None",
")",
":",
"return",
"self",
".",
"_pop",
"(",
"block",
",",
"timeout",
",",
"left",
"=",
"True",
")"
] | Remove and return an item from the right side of the
GeventDeque. If no elements are present, raises an IndexError.
If optional args *block* is True and *timeout* is ``None``
(the default), block if necessary until an item is
available. If *timeout* is a positive number, it blocks at
... | [
"Remove",
"and",
"return",
"an",
"item",
"from",
"the",
"right",
"side",
"of",
"the",
"GeventDeque",
".",
"If",
"no",
"elements",
"are",
"present",
"raises",
"an",
"IndexError",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/api.py#L332-L345 |
NASA-AMMOS/AIT-Core | ait/core/api.py | UdpTelemetryServer.start | def start (self):
"""Starts this UdpTelemetryServer."""
values = self._defn.name, self.server_host, self.server_port
log.info('Listening for %s telemetry on %s:%d (UDP)' % values)
super(UdpTelemetryServer, self).start() | python | def start (self):
"""Starts this UdpTelemetryServer."""
values = self._defn.name, self.server_host, self.server_port
log.info('Listening for %s telemetry on %s:%d (UDP)' % values)
super(UdpTelemetryServer, self).start() | [
"def",
"start",
"(",
"self",
")",
":",
"values",
"=",
"self",
".",
"_defn",
".",
"name",
",",
"self",
".",
"server_host",
",",
"self",
".",
"server_port",
"log",
".",
"info",
"(",
"'Listening for %s telemetry on %s:%d (UDP)'",
"%",
"values",
")",
"super",
... | Starts this UdpTelemetryServer. | [
"Starts",
"this",
"UdpTelemetryServer",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/api.py#L455-L459 |
NASA-AMMOS/AIT-Core | ait/core/api.py | UIAPI.confirm | def confirm(self, msg, _timeout=-1):
''' Send a confirm prompt to the GUI
Arguments:
msg (string):
The message to display to the user.
_timeout (int):
The optional amount of time for which the prompt
should be displayed to... | python | def confirm(self, msg, _timeout=-1):
''' Send a confirm prompt to the GUI
Arguments:
msg (string):
The message to display to the user.
_timeout (int):
The optional amount of time for which the prompt
should be displayed to... | [
"def",
"confirm",
"(",
"self",
",",
"msg",
",",
"_timeout",
"=",
"-",
"1",
")",
":",
"return",
"self",
".",
"msgBox",
"(",
"'confirm'",
",",
"_timeout",
"=",
"_timeout",
",",
"msg",
"=",
"msg",
")"
] | Send a confirm prompt to the GUI
Arguments:
msg (string):
The message to display to the user.
_timeout (int):
The optional amount of time for which the prompt
should be displayed to the user before a timeout occurs.
... | [
"Send",
"a",
"confirm",
"prompt",
"to",
"the",
"GUI",
"Arguments",
":",
"msg",
"(",
"string",
")",
":",
"The",
"message",
"to",
"display",
"to",
"the",
"user",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/api.py#L577-L589 |
NASA-AMMOS/AIT-Core | ait/core/api.py | UIAPI.msgBox | def msgBox(self, promptType, _timeout=-1, **options):
''' Send a user prompt request to the GUI
Arguments:
promptType (string):
The prompt type to send to the GUI. Currently
the only type supported is 'confirm'.
_timeout (int):
Th... | python | def msgBox(self, promptType, _timeout=-1, **options):
''' Send a user prompt request to the GUI
Arguments:
promptType (string):
The prompt type to send to the GUI. Currently
the only type supported is 'confirm'.
_timeout (int):
Th... | [
"def",
"msgBox",
"(",
"self",
",",
"promptType",
",",
"_timeout",
"=",
"-",
"1",
",",
"*",
"*",
"options",
")",
":",
"if",
"promptType",
"==",
"'confirm'",
":",
"return",
"self",
".",
"_sendConfirmPrompt",
"(",
"_timeout",
",",
"options",
")",
"else",
... | Send a user prompt request to the GUI
Arguments:
promptType (string):
The prompt type to send to the GUI. Currently
the only type supported is 'confirm'.
_timeout (int):
The optional amount of time for which the prompt
sho... | [
"Send",
"a",
"user",
"prompt",
"request",
"to",
"the",
"GUI"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/api.py#L591-L636 |
NASA-AMMOS/AIT-Core | ait/core/server/broker.py | Broker._subscribe_all | def _subscribe_all(self):
"""
Subscribes all streams to their input.
Subscribes all plugins to all their inputs.
Subscribes all plugin outputs to the plugin.
"""
for stream in (self.inbound_streams + self.outbound_streams):
for input_ in stream.inputs:
... | python | def _subscribe_all(self):
"""
Subscribes all streams to their input.
Subscribes all plugins to all their inputs.
Subscribes all plugin outputs to the plugin.
"""
for stream in (self.inbound_streams + self.outbound_streams):
for input_ in stream.inputs:
... | [
"def",
"_subscribe_all",
"(",
"self",
")",
":",
"for",
"stream",
"in",
"(",
"self",
".",
"inbound_streams",
"+",
"self",
".",
"outbound_streams",
")",
":",
"for",
"input_",
"in",
"stream",
".",
"inputs",
":",
"if",
"not",
"type",
"(",
"input_",
")",
"i... | Subscribes all streams to their input.
Subscribes all plugins to all their inputs.
Subscribes all plugin outputs to the plugin. | [
"Subscribes",
"all",
"streams",
"to",
"their",
"input",
".",
"Subscribes",
"all",
"plugins",
"to",
"all",
"their",
"inputs",
".",
"Subscribes",
"all",
"plugin",
"outputs",
"to",
"the",
"plugin",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/server/broker.py#L58-L82 |
NASA-AMMOS/AIT-Core | ait/core/log.py | addLocalHandlers | def addLocalHandlers (logger):
"""Adds logging handlers to logger to log to the following local
resources:
1. The terminal
2. localhost:514 (i.e. syslogd)
3. localhost:2514 (i.e. the AIT GUI syslog-like handler)
"""
termlog = logging.StreamHandler()
termlog.setFormatter(... | python | def addLocalHandlers (logger):
"""Adds logging handlers to logger to log to the following local
resources:
1. The terminal
2. localhost:514 (i.e. syslogd)
3. localhost:2514 (i.e. the AIT GUI syslog-like handler)
"""
termlog = logging.StreamHandler()
termlog.setFormatter(... | [
"def",
"addLocalHandlers",
"(",
"logger",
")",
":",
"termlog",
"=",
"logging",
".",
"StreamHandler",
"(",
")",
"termlog",
".",
"setFormatter",
"(",
"LogFormatter",
"(",
")",
")",
"logger",
".",
"addHandler",
"(",
"termlog",
")",
"logger",
".",
"addHandler",
... | Adds logging handlers to logger to log to the following local
resources:
1. The terminal
2. localhost:514 (i.e. syslogd)
3. localhost:2514 (i.e. the AIT GUI syslog-like handler) | [
"Adds",
"logging",
"handlers",
"to",
"logger",
"to",
"log",
"to",
"the",
"following",
"local",
"resources",
":"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/log.py#L166-L179 |
NASA-AMMOS/AIT-Core | ait/core/log.py | addRemoteHandlers | def addRemoteHandlers (logger):
"""Adds logging handlers to logger to remotely log to:
ait.config.logging.hostname:514 (i.e. syslogd)
If not set or hostname cannot be resolved, this method has no
effect.
"""
try:
hostname = ait.config.logging.hostname
# Do not "remote" lo... | python | def addRemoteHandlers (logger):
"""Adds logging handlers to logger to remotely log to:
ait.config.logging.hostname:514 (i.e. syslogd)
If not set or hostname cannot be resolved, this method has no
effect.
"""
try:
hostname = ait.config.logging.hostname
# Do not "remote" lo... | [
"def",
"addRemoteHandlers",
"(",
"logger",
")",
":",
"try",
":",
"hostname",
"=",
"ait",
".",
"config",
".",
"logging",
".",
"hostname",
"# Do not \"remote\" log to this host, as that's already covered",
"# by addLocalHandlers().",
"if",
"socket",
".",
"getfqdn",
"(",
... | Adds logging handlers to logger to remotely log to:
ait.config.logging.hostname:514 (i.e. syslogd)
If not set or hostname cannot be resolved, this method has no
effect. | [
"Adds",
"logging",
"handlers",
"to",
"logger",
"to",
"remotely",
"log",
"to",
":"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/log.py#L182-L203 |
NASA-AMMOS/AIT-Core | ait/core/log.py | parseSyslog | def parseSyslog(msg):
"""Parses Syslog messages (RFC 5424)
The `Syslog Message Format (RFC 5424)
<https://tools.ietf.org/html/rfc5424#section-6>`_ can be parsed with
simple whitespace tokenization::
SYSLOG-MSG = HEADER SP STRUCTURED-DATA [SP MSG]
HEADER = PRI VERSION SP TIMESTAMP S... | python | def parseSyslog(msg):
"""Parses Syslog messages (RFC 5424)
The `Syslog Message Format (RFC 5424)
<https://tools.ietf.org/html/rfc5424#section-6>`_ can be parsed with
simple whitespace tokenization::
SYSLOG-MSG = HEADER SP STRUCTURED-DATA [SP MSG]
HEADER = PRI VERSION SP TIMESTAMP S... | [
"def",
"parseSyslog",
"(",
"msg",
")",
":",
"tokens",
"=",
"msg",
".",
"split",
"(",
"' '",
",",
"6",
")",
"result",
"=",
"{",
"}",
"if",
"len",
"(",
"tokens",
")",
">",
"0",
":",
"pri",
"=",
"tokens",
"[",
"0",
"]",
"start",
"=",
"pri",
".",... | Parses Syslog messages (RFC 5424)
The `Syslog Message Format (RFC 5424)
<https://tools.ietf.org/html/rfc5424#section-6>`_ can be parsed with
simple whitespace tokenization::
SYSLOG-MSG = HEADER SP STRUCTURED-DATA [SP MSG]
HEADER = PRI VERSION SP TIMESTAMP SP HOSTNAME
... | [
"Parses",
"Syslog",
"messages",
"(",
"RFC",
"5424",
")"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/log.py#L233-L290 |
NASA-AMMOS/AIT-Core | ait/core/log.py | LogFormatter.formatTime | def formatTime (self, record, datefmt=None):
"""Return the creation time of the specified LogRecord as formatted
text."""
if datefmt is None:
datefmt = '%Y-%m-%d %H:%M:%S'
ct = self.converter(record.created)
t = time.strftime(datefmt, ct)
s = '%s.%03d' % (t... | python | def formatTime (self, record, datefmt=None):
"""Return the creation time of the specified LogRecord as formatted
text."""
if datefmt is None:
datefmt = '%Y-%m-%d %H:%M:%S'
ct = self.converter(record.created)
t = time.strftime(datefmt, ct)
s = '%s.%03d' % (t... | [
"def",
"formatTime",
"(",
"self",
",",
"record",
",",
"datefmt",
"=",
"None",
")",
":",
"if",
"datefmt",
"is",
"None",
":",
"datefmt",
"=",
"'%Y-%m-%d %H:%M:%S'",
"ct",
"=",
"self",
".",
"converter",
"(",
"record",
".",
"created",
")",
"t",
"=",
"time"... | Return the creation time of the specified LogRecord as formatted
text. | [
"Return",
"the",
"creation",
"time",
"of",
"the",
"specified",
"LogRecord",
"as",
"formatted",
"text",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/log.py#L66-L76 |
NASA-AMMOS/AIT-Core | ait/core/log.py | SysLogFormatter.format | def format (self, record):
"""Returns the given LogRecord as formatted text."""
record.hostname = self.hostname
return logging.Formatter.format(self, record) | python | def format (self, record):
"""Returns the given LogRecord as formatted text."""
record.hostname = self.hostname
return logging.Formatter.format(self, record) | [
"def",
"format",
"(",
"self",
",",
"record",
")",
":",
"record",
".",
"hostname",
"=",
"self",
".",
"hostname",
"return",
"logging",
".",
"Formatter",
".",
"format",
"(",
"self",
",",
"record",
")"
] | Returns the given LogRecord as formatted text. | [
"Returns",
"the",
"given",
"LogRecord",
"as",
"formatted",
"text",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/log.py#L117-L120 |
NASA-AMMOS/AIT-Core | ait/core/log.py | SysLogFormatter.formatTime | def formatTime (self, record, datefmt=None):
"""Returns the creation time of the given LogRecord as formatted text.
NOTE: The datefmt parameter and self.converter (the time
conversion method) are ignored. BSD Syslog Protocol messages
always use local time, and by our convention, Syslog... | python | def formatTime (self, record, datefmt=None):
"""Returns the creation time of the given LogRecord as formatted text.
NOTE: The datefmt parameter and self.converter (the time
conversion method) are ignored. BSD Syslog Protocol messages
always use local time, and by our convention, Syslog... | [
"def",
"formatTime",
"(",
"self",
",",
"record",
",",
"datefmt",
"=",
"None",
")",
":",
"if",
"self",
".",
"bsd",
":",
"lt_ts",
"=",
"datetime",
".",
"datetime",
".",
"fromtimestamp",
"(",
"record",
".",
"created",
")",
"ts",
"=",
"lt_ts",
".",
"strf... | Returns the creation time of the given LogRecord as formatted text.
NOTE: The datefmt parameter and self.converter (the time
conversion method) are ignored. BSD Syslog Protocol messages
always use local time, and by our convention, Syslog Protocol
messages use UTC. | [
"Returns",
"the",
"creation",
"time",
"of",
"the",
"given",
"LogRecord",
"as",
"formatted",
"text",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/log.py#L123-L139 |
NASA-AMMOS/AIT-Core | ait/core/pcap.py | open | def open (filename, mode='r', **options):
"""Returns an instance of a :class:`PCapStream` class which contains
the ``read()``, ``write()``, and ``close()`` methods. Binary mode
is assumed for this module, so the "b" is not required when
calling ``open()``.
If the optiontal ``rollover`` parameter i... | python | def open (filename, mode='r', **options):
"""Returns an instance of a :class:`PCapStream` class which contains
the ``read()``, ``write()``, and ``close()`` methods. Binary mode
is assumed for this module, so the "b" is not required when
calling ``open()``.
If the optiontal ``rollover`` parameter i... | [
"def",
"open",
"(",
"filename",
",",
"mode",
"=",
"'r'",
",",
"*",
"*",
"options",
")",
":",
"mode",
"=",
"mode",
".",
"replace",
"(",
"'b'",
",",
"''",
")",
"+",
"'b'",
"if",
"options",
".",
"get",
"(",
"'rollover'",
",",
"False",
")",
":",
"s... | Returns an instance of a :class:`PCapStream` class which contains
the ``read()``, ``write()``, and ``close()`` methods. Binary mode
is assumed for this module, so the "b" is not required when
calling ``open()``.
If the optiontal ``rollover`` parameter is True, a
:class:`PCapRolloverStream` is crea... | [
"Returns",
"an",
"instance",
"of",
"a",
":",
"class",
":",
"PCapStream",
"class",
"which",
"contains",
"the",
"read",
"()",
"write",
"()",
"and",
"close",
"()",
"methods",
".",
"Binary",
"mode",
"is",
"assumed",
"for",
"this",
"module",
"so",
"the",
"b",... | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/pcap.py#L436-L464 |
NASA-AMMOS/AIT-Core | ait/core/pcap.py | query | def query(starttime, endtime, output=None, *filenames):
'''Given a time range and input file, query creates a new file with only
that subset of data. If no outfile name is given, the new file name is the
old file name with the time range appended.
Args:
starttime:
The datetime of th... | python | def query(starttime, endtime, output=None, *filenames):
'''Given a time range and input file, query creates a new file with only
that subset of data. If no outfile name is given, the new file name is the
old file name with the time range appended.
Args:
starttime:
The datetime of th... | [
"def",
"query",
"(",
"starttime",
",",
"endtime",
",",
"output",
"=",
"None",
",",
"*",
"filenames",
")",
":",
"if",
"not",
"output",
":",
"output",
"=",
"(",
"filenames",
"[",
"0",
"]",
".",
"replace",
"(",
"'.pcap'",
",",
"''",
")",
"+",
"startti... | Given a time range and input file, query creates a new file with only
that subset of data. If no outfile name is given, the new file name is the
old file name with the time range appended.
Args:
starttime:
The datetime of the beginning time range to be extracted from the files.
... | [
"Given",
"a",
"time",
"range",
"and",
"input",
"file",
"query",
"creates",
"a",
"new",
"file",
"with",
"only",
"that",
"subset",
"of",
"data",
".",
"If",
"no",
"outfile",
"name",
"is",
"given",
"the",
"new",
"file",
"name",
"is",
"the",
"old",
"file",
... | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/pcap.py#L467-L496 |
NASA-AMMOS/AIT-Core | ait/core/pcap.py | segment | def segment(filenames, format, **options):
"""Segment the given pcap file(s) by one or more thresholds
(``nbytes``, ``npackets``, ``nseconds``). New segment filenames
are determined based on the ``strftime(3)`` ``format`` string
and the timestamp of the first packet in the file.
:param filenames: ... | python | def segment(filenames, format, **options):
"""Segment the given pcap file(s) by one or more thresholds
(``nbytes``, ``npackets``, ``nseconds``). New segment filenames
are determined based on the ``strftime(3)`` ``format`` string
and the timestamp of the first packet in the file.
:param filenames: ... | [
"def",
"segment",
"(",
"filenames",
",",
"format",
",",
"*",
"*",
"options",
")",
":",
"output",
"=",
"open",
"(",
"format",
",",
"rollover",
"=",
"True",
",",
"*",
"*",
"options",
")",
"if",
"isinstance",
"(",
"filenames",
",",
"str",
")",
":",
"f... | Segment the given pcap file(s) by one or more thresholds
(``nbytes``, ``npackets``, ``nseconds``). New segment filenames
are determined based on the ``strftime(3)`` ``format`` string
and the timestamp of the first packet in the file.
:param filenames: Single filename (string) or list of filenames
... | [
"Segment",
"the",
"given",
"pcap",
"file",
"(",
"s",
")",
"by",
"one",
"or",
"more",
"thresholds",
"(",
"nbytes",
"npackets",
"nseconds",
")",
".",
"New",
"segment",
"filenames",
"are",
"determined",
"based",
"on",
"the",
"strftime",
"(",
"3",
")",
"form... | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/pcap.py#L499-L523 |
NASA-AMMOS/AIT-Core | ait/core/pcap.py | times | def times(filenames, tolerance=2):
"""For the given file(s), return the time ranges available. Tolerance
sets the number of seconds between time ranges. Any gaps larger
than tolerance seconds will result in a new time range.
:param filenames: Single filename (string) or list of filenames
:param t... | python | def times(filenames, tolerance=2):
"""For the given file(s), return the time ranges available. Tolerance
sets the number of seconds between time ranges. Any gaps larger
than tolerance seconds will result in a new time range.
:param filenames: Single filename (string) or list of filenames
:param t... | [
"def",
"times",
"(",
"filenames",
",",
"tolerance",
"=",
"2",
")",
":",
"times",
"=",
"{",
"}",
"delta",
"=",
"datetime",
".",
"timedelta",
"(",
"seconds",
"=",
"tolerance",
")",
"if",
"isinstance",
"(",
"filenames",
",",
"str",
")",
":",
"filenames",
... | For the given file(s), return the time ranges available. Tolerance
sets the number of seconds between time ranges. Any gaps larger
than tolerance seconds will result in a new time range.
:param filenames: Single filename (string) or list of filenames
:param tolerance: Maximum seconds between contiguo... | [
"For",
"the",
"given",
"file",
"(",
"s",
")",
"return",
"the",
"time",
"ranges",
"available",
".",
"Tolerance",
"sets",
"the",
"number",
"of",
"seconds",
"between",
"time",
"ranges",
".",
"Any",
"gaps",
"larger",
"than",
"tolerance",
"seconds",
"will",
"re... | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/pcap.py#L526-L557 |
NASA-AMMOS/AIT-Core | ait/core/pcap.py | PCapGlobalHeader.read | def read (self, stream):
"""Reads PCapGlobalHeader data from the given stream."""
self._data = stream.read(self._size)
if len(self._data) >= self._size:
values = struct.unpack(self._format, self._data)
else:
values = None, None, None, None, None, None, None
... | python | def read (self, stream):
"""Reads PCapGlobalHeader data from the given stream."""
self._data = stream.read(self._size)
if len(self._data) >= self._size:
values = struct.unpack(self._format, self._data)
else:
values = None, None, None, None, None, None, None
... | [
"def",
"read",
"(",
"self",
",",
"stream",
")",
":",
"self",
".",
"_data",
"=",
"stream",
".",
"read",
"(",
"self",
".",
"_size",
")",
"if",
"len",
"(",
"self",
".",
"_data",
")",
">=",
"self",
".",
"_size",
":",
"values",
"=",
"struct",
".",
"... | Reads PCapGlobalHeader data from the given stream. | [
"Reads",
"PCapGlobalHeader",
"data",
"from",
"the",
"given",
"stream",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/pcap.py#L100-L123 |
NASA-AMMOS/AIT-Core | ait/core/pcap.py | PCapPacketHeader.read | def read (self, stream):
"""Reads PCapPacketHeader data from the given stream."""
self._data = stream.read(self._size)
if len(self._data) >= self._size:
values = struct.unpack(self._swap + self._format, self._data)
else:
values = None, None, None, None
self.ts_sec =... | python | def read (self, stream):
"""Reads PCapPacketHeader data from the given stream."""
self._data = stream.read(self._size)
if len(self._data) >= self._size:
values = struct.unpack(self._swap + self._format, self._data)
else:
values = None, None, None, None
self.ts_sec =... | [
"def",
"read",
"(",
"self",
",",
"stream",
")",
":",
"self",
".",
"_data",
"=",
"stream",
".",
"read",
"(",
"self",
".",
"_size",
")",
"if",
"len",
"(",
"self",
".",
"_data",
")",
">=",
"self",
".",
"_size",
":",
"values",
"=",
"struct",
".",
"... | Reads PCapPacketHeader data from the given stream. | [
"Reads",
"PCapPacketHeader",
"data",
"from",
"the",
"given",
"stream",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/pcap.py#L186-L198 |
NASA-AMMOS/AIT-Core | ait/core/pcap.py | PCapRolloverStream.rollover | def rollover (self):
"""Indicates whether or not its time to rollover to a new file."""
rollover = False
if not rollover and self._threshold.nbytes is not None:
rollover = self._total.nbytes >= self._threshold.nbytes
if not rollover and self._threshold.npackets is not None:... | python | def rollover (self):
"""Indicates whether or not its time to rollover to a new file."""
rollover = False
if not rollover and self._threshold.nbytes is not None:
rollover = self._total.nbytes >= self._threshold.nbytes
if not rollover and self._threshold.npackets is not None:... | [
"def",
"rollover",
"(",
"self",
")",
":",
"rollover",
"=",
"False",
"if",
"not",
"rollover",
"and",
"self",
".",
"_threshold",
".",
"nbytes",
"is",
"not",
"None",
":",
"rollover",
"=",
"self",
".",
"_total",
".",
"nbytes",
">=",
"self",
".",
"_threshol... | Indicates whether or not its time to rollover to a new file. | [
"Indicates",
"whether",
"or",
"not",
"its",
"time",
"to",
"rollover",
"to",
"a",
"new",
"file",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/pcap.py#L255-L269 |
NASA-AMMOS/AIT-Core | ait/core/pcap.py | PCapRolloverStream.write | def write (self, bytes, header=None):
"""Writes packet ``bytes`` and the optional pcap packet ``header``.
If the pcap packet ``header`` is not specified, one will be
generated based on the number of packet ``bytes`` and current
time.
"""
if header is None:
he... | python | def write (self, bytes, header=None):
"""Writes packet ``bytes`` and the optional pcap packet ``header``.
If the pcap packet ``header`` is not specified, one will be
generated based on the number of packet ``bytes`` and current
time.
"""
if header is None:
he... | [
"def",
"write",
"(",
"self",
",",
"bytes",
",",
"header",
"=",
"None",
")",
":",
"if",
"header",
"is",
"None",
":",
"header",
"=",
"PCapPacketHeader",
"(",
"orig_len",
"=",
"len",
"(",
"bytes",
")",
")",
"if",
"self",
".",
"_stream",
"is",
"None",
... | Writes packet ``bytes`` and the optional pcap packet ``header``.
If the pcap packet ``header`` is not specified, one will be
generated based on the number of packet ``bytes`` and current
time. | [
"Writes",
"packet",
"bytes",
"and",
"the",
"optional",
"pcap",
"packet",
"header",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/pcap.py#L272-L313 |
NASA-AMMOS/AIT-Core | ait/core/pcap.py | PCapRolloverStream.close | def close (self):
"""Closes this :class:``PCapStream`` by closing the underlying Python
stream."""
if self._stream:
values = ( self._total.nbytes,
self._total.npackets,
int( math.ceil(self._total.nseconds) ),
self._... | python | def close (self):
"""Closes this :class:``PCapStream`` by closing the underlying Python
stream."""
if self._stream:
values = ( self._total.nbytes,
self._total.npackets,
int( math.ceil(self._total.nseconds) ),
self._... | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"_stream",
":",
"values",
"=",
"(",
"self",
".",
"_total",
".",
"nbytes",
",",
"self",
".",
"_total",
".",
"npackets",
",",
"int",
"(",
"math",
".",
"ceil",
"(",
"self",
".",
"_total",
"."... | Closes this :class:``PCapStream`` by closing the underlying Python
stream. | [
"Closes",
"this",
":",
"class",
":",
"PCapStream",
"by",
"closing",
"the",
"underlying",
"Python",
"stream",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/pcap.py#L316-L336 |
NASA-AMMOS/AIT-Core | ait/core/pcap.py | PCapStream.next | def next (self):
"""Returns the next header and packet from this
PCapStream. See read().
"""
header, packet = self.read()
if packet is None:
raise StopIteration
return header, packet | python | def next (self):
"""Returns the next header and packet from this
PCapStream. See read().
"""
header, packet = self.read()
if packet is None:
raise StopIteration
return header, packet | [
"def",
"next",
"(",
"self",
")",
":",
"header",
",",
"packet",
"=",
"self",
".",
"read",
"(",
")",
"if",
"packet",
"is",
"None",
":",
"raise",
"StopIteration",
"return",
"header",
",",
"packet"
] | Returns the next header and packet from this
PCapStream. See read(). | [
"Returns",
"the",
"next",
"header",
"and",
"packet",
"from",
"this",
"PCapStream",
".",
"See",
"read",
"()",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/pcap.py#L384-L393 |
NASA-AMMOS/AIT-Core | ait/core/pcap.py | PCapStream.read | def read (self):
"""Reads a single packet from the this pcap stream, returning a
tuple (PCapPacketHeader, packet)
"""
header = PCapPacketHeader(self._stream, self.header._swap)
packet = None
if not header.incomplete():
packet = self._stream.read(header.incl_l... | python | def read (self):
"""Reads a single packet from the this pcap stream, returning a
tuple (PCapPacketHeader, packet)
"""
header = PCapPacketHeader(self._stream, self.header._swap)
packet = None
if not header.incomplete():
packet = self._stream.read(header.incl_l... | [
"def",
"read",
"(",
"self",
")",
":",
"header",
"=",
"PCapPacketHeader",
"(",
"self",
".",
"_stream",
",",
"self",
".",
"header",
".",
"_swap",
")",
"packet",
"=",
"None",
"if",
"not",
"header",
".",
"incomplete",
"(",
")",
":",
"packet",
"=",
"self"... | Reads a single packet from the this pcap stream, returning a
tuple (PCapPacketHeader, packet) | [
"Reads",
"a",
"single",
"packet",
"from",
"the",
"this",
"pcap",
"stream",
"returning",
"a",
"tuple",
"(",
"PCapPacketHeader",
"packet",
")"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/pcap.py#L396-L406 |
NASA-AMMOS/AIT-Core | ait/core/pcap.py | PCapStream.write | def write (self, bytes, header=None):
"""write() is meant to work like the normal file write(). It takes
two arguments, a byte array to write to the file as a single
PCAP packet, and an optional header if one already exists.
The length of the byte array should be less than 65535 bytes.
... | python | def write (self, bytes, header=None):
"""write() is meant to work like the normal file write(). It takes
two arguments, a byte array to write to the file as a single
PCAP packet, and an optional header if one already exists.
The length of the byte array should be less than 65535 bytes.
... | [
"def",
"write",
"(",
"self",
",",
"bytes",
",",
"header",
"=",
"None",
")",
":",
"if",
"type",
"(",
"bytes",
")",
"is",
"str",
":",
"bytes",
"=",
"bytearray",
"(",
"bytes",
")",
"if",
"not",
"isinstance",
"(",
"header",
",",
"PCapPacketHeader",
")",
... | write() is meant to work like the normal file write(). It takes
two arguments, a byte array to write to the file as a single
PCAP packet, and an optional header if one already exists.
The length of the byte array should be less than 65535 bytes.
write() returns the number of bytes actua... | [
"write",
"()",
"is",
"meant",
"to",
"work",
"like",
"the",
"normal",
"file",
"write",
"()",
".",
"It",
"takes",
"two",
"arguments",
"a",
"byte",
"array",
"to",
"write",
"to",
"the",
"file",
"as",
"a",
"single",
"PCAP",
"packet",
"and",
"an",
"optional"... | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/pcap.py#L409-L428 |
NASA-AMMOS/AIT-Core | ait/core/table.py | hash_file | def hash_file(filename):
""""This function returns the SHA-1 hash
of the file passed into it"""
# make a hash object
h = hashlib.sha1()
# open file for reading in binary mode
with open(filename,'rb') as file:
# loop till the end of the file
chunk = 0
while chunk != b'':
... | python | def hash_file(filename):
""""This function returns the SHA-1 hash
of the file passed into it"""
# make a hash object
h = hashlib.sha1()
# open file for reading in binary mode
with open(filename,'rb') as file:
# loop till the end of the file
chunk = 0
while chunk != b'':
... | [
"def",
"hash_file",
"(",
"filename",
")",
":",
"# make a hash object",
"h",
"=",
"hashlib",
".",
"sha1",
"(",
")",
"# open file for reading in binary mode",
"with",
"open",
"(",
"filename",
",",
"'rb'",
")",
"as",
"file",
":",
"# loop till the end of the file",
"c... | This function returns the SHA-1 hash
of the file passed into it | [
"This",
"function",
"returns",
"the",
"SHA",
"-",
"1",
"hash",
"of",
"the",
"file",
"passed",
"into",
"it"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/table.py#L156-L174 |
NASA-AMMOS/AIT-Core | ait/core/table.py | FSWTabDict.add | def add (self, defn):
"""Adds the given Command Definition to this Command Dictionary."""
self[defn.name] = defn
self.colnames[defn.name] = defn | python | def add (self, defn):
"""Adds the given Command Definition to this Command Dictionary."""
self[defn.name] = defn
self.colnames[defn.name] = defn | [
"def",
"add",
"(",
"self",
",",
"defn",
")",
":",
"self",
"[",
"defn",
".",
"name",
"]",
"=",
"defn",
"self",
".",
"colnames",
"[",
"defn",
".",
"name",
"]",
"=",
"defn"
] | Adds the given Command Definition to this Command Dictionary. | [
"Adds",
"the",
"given",
"Command",
"Definition",
"to",
"this",
"Command",
"Dictionary",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/table.py#L593-L596 |
NASA-AMMOS/AIT-Core | ait/core/table.py | FSWTabDict.create | def create (self, name, *args):
"""Creates a new command with the given arguments."""
tab = None
defn = self.get(name, None)
if defn:
tab = FSWTab(defn, *args)
return tab | python | def create (self, name, *args):
"""Creates a new command with the given arguments."""
tab = None
defn = self.get(name, None)
if defn:
tab = FSWTab(defn, *args)
return tab | [
"def",
"create",
"(",
"self",
",",
"name",
",",
"*",
"args",
")",
":",
"tab",
"=",
"None",
"defn",
"=",
"self",
".",
"get",
"(",
"name",
",",
"None",
")",
"if",
"defn",
":",
"tab",
"=",
"FSWTab",
"(",
"defn",
",",
"*",
"args",
")",
"return",
... | Creates a new command with the given arguments. | [
"Creates",
"a",
"new",
"command",
"with",
"the",
"given",
"arguments",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/table.py#L598-L604 |
NASA-AMMOS/AIT-Core | ait/core/table.py | FSWTabDict.load | def load (self, filename):
"""Loads Command Definitions from the given YAML file into this
Command Dictionary.
"""
if self.filename is None:
self.filename = filename
stream = open(self.filename, "rb")
for doc in yaml.load_all(stream):
for table in... | python | def load (self, filename):
"""Loads Command Definitions from the given YAML file into this
Command Dictionary.
"""
if self.filename is None:
self.filename = filename
stream = open(self.filename, "rb")
for doc in yaml.load_all(stream):
for table in... | [
"def",
"load",
"(",
"self",
",",
"filename",
")",
":",
"if",
"self",
".",
"filename",
"is",
"None",
":",
"self",
".",
"filename",
"=",
"filename",
"stream",
"=",
"open",
"(",
"self",
".",
"filename",
",",
"\"rb\"",
")",
"for",
"doc",
"in",
"yaml",
... | Loads Command Definitions from the given YAML file into this
Command Dictionary. | [
"Loads",
"Command",
"Definitions",
"from",
"the",
"given",
"YAML",
"file",
"into",
"this",
"Command",
"Dictionary",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/table.py#L606-L617 |
NASA-AMMOS/AIT-Core | ait/core/server/client.py | ZMQClient.publish | def publish(self, msg):
"""
Publishes input message with client name as topic.
"""
self.pub.send("{} {}".format(self.name, msg))
log.debug('Published message from {}'.format(self)) | python | def publish(self, msg):
"""
Publishes input message with client name as topic.
"""
self.pub.send("{} {}".format(self.name, msg))
log.debug('Published message from {}'.format(self)) | [
"def",
"publish",
"(",
"self",
",",
"msg",
")",
":",
"self",
".",
"pub",
".",
"send",
"(",
"\"{} {}\"",
".",
"format",
"(",
"self",
".",
"name",
",",
"msg",
")",
")",
"log",
".",
"debug",
"(",
"'Published message from {}'",
".",
"format",
"(",
"self"... | Publishes input message with client name as topic. | [
"Publishes",
"input",
"message",
"with",
"client",
"name",
"as",
"topic",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/server/client.py#L34-L39 |
NASA-AMMOS/AIT-Core | ait/core/db.py | create | def create(database, tlmdict=None):
"""Creates a new database for the given Telemetry Dictionary and
returns a connection to it.
"""
if tlmdict is None:
tlmdict = tlm.getDefaultDict()
dbconn = connect(database)
for name, defn in tlmdict.items():
createTable(dbconn, defn)
... | python | def create(database, tlmdict=None):
"""Creates a new database for the given Telemetry Dictionary and
returns a connection to it.
"""
if tlmdict is None:
tlmdict = tlm.getDefaultDict()
dbconn = connect(database)
for name, defn in tlmdict.items():
createTable(dbconn, defn)
... | [
"def",
"create",
"(",
"database",
",",
"tlmdict",
"=",
"None",
")",
":",
"if",
"tlmdict",
"is",
"None",
":",
"tlmdict",
"=",
"tlm",
".",
"getDefaultDict",
"(",
")",
"dbconn",
"=",
"connect",
"(",
"database",
")",
"for",
"name",
",",
"defn",
"in",
"tl... | Creates a new database for the given Telemetry Dictionary and
returns a connection to it. | [
"Creates",
"a",
"new",
"database",
"for",
"the",
"given",
"Telemetry",
"Dictionary",
"and",
"returns",
"a",
"connection",
"to",
"it",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/db.py#L45-L57 |
NASA-AMMOS/AIT-Core | ait/core/db.py | createTable | def createTable(dbconn, pd):
"""Creates a database table for the given PacketDefinition."""
cols = ('%s %s' % (defn.name, getTypename(defn)) for defn in pd.fields)
sql = 'CREATE TABLE IF NOT EXISTS %s (%s)' % (pd.name, ', '.join(cols))
dbconn.execute(sql)
dbconn.commit() | python | def createTable(dbconn, pd):
"""Creates a database table for the given PacketDefinition."""
cols = ('%s %s' % (defn.name, getTypename(defn)) for defn in pd.fields)
sql = 'CREATE TABLE IF NOT EXISTS %s (%s)' % (pd.name, ', '.join(cols))
dbconn.execute(sql)
dbconn.commit() | [
"def",
"createTable",
"(",
"dbconn",
",",
"pd",
")",
":",
"cols",
"=",
"(",
"'%s %s'",
"%",
"(",
"defn",
".",
"name",
",",
"getTypename",
"(",
"defn",
")",
")",
"for",
"defn",
"in",
"pd",
".",
"fields",
")",
"sql",
"=",
"'CREATE TABLE IF NOT EXISTS %s ... | Creates a database table for the given PacketDefinition. | [
"Creates",
"a",
"database",
"table",
"for",
"the",
"given",
"PacketDefinition",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/db.py#L61-L67 |
NASA-AMMOS/AIT-Core | ait/core/db.py | insert | def insert(dbconn, packet):
"""Inserts the given packet into the connected database."""
values = [ ]
pd = packet._defn
for defn in pd.fields:
if defn.enum:
val = getattr(packet.raw, defn.name)
else:
val = getattr(packet, defn.name)
if val is None and... | python | def insert(dbconn, packet):
"""Inserts the given packet into the connected database."""
values = [ ]
pd = packet._defn
for defn in pd.fields:
if defn.enum:
val = getattr(packet.raw, defn.name)
else:
val = getattr(packet, defn.name)
if val is None and... | [
"def",
"insert",
"(",
"dbconn",
",",
"packet",
")",
":",
"values",
"=",
"[",
"]",
"pd",
"=",
"packet",
".",
"_defn",
"for",
"defn",
"in",
"pd",
".",
"fields",
":",
"if",
"defn",
".",
"enum",
":",
"val",
"=",
"getattr",
"(",
"packet",
".",
"raw",
... | Inserts the given packet into the connected database. | [
"Inserts",
"the",
"given",
"packet",
"into",
"the",
"connected",
"database",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/db.py#L78-L97 |
NASA-AMMOS/AIT-Core | ait/core/db.py | use | def use(backend):
"""Use the given database backend, e.g. 'MySQLdb', 'psycopg2',
'MySQLdb', etc.
"""
global Backend
try:
Backend = importlib.import_module(backend)
except ImportError:
msg = 'Could not import (load) database.backend: %s' % backend
raise cfg.AitConfigError... | python | def use(backend):
"""Use the given database backend, e.g. 'MySQLdb', 'psycopg2',
'MySQLdb', etc.
"""
global Backend
try:
Backend = importlib.import_module(backend)
except ImportError:
msg = 'Could not import (load) database.backend: %s' % backend
raise cfg.AitConfigError... | [
"def",
"use",
"(",
"backend",
")",
":",
"global",
"Backend",
"try",
":",
"Backend",
"=",
"importlib",
".",
"import_module",
"(",
"backend",
")",
"except",
"ImportError",
":",
"msg",
"=",
"'Could not import (load) database.backend: %s'",
"%",
"backend",
"raise",
... | Use the given database backend, e.g. 'MySQLdb', 'psycopg2',
'MySQLdb', etc. | [
"Use",
"the",
"given",
"database",
"backend",
"e",
".",
"g",
".",
"MySQLdb",
"psycopg2",
"MySQLdb",
"etc",
"."
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/db.py#L101-L111 |
NASA-AMMOS/AIT-Core | ait/core/db.py | InfluxDBBackend.connect | def connect(self, **kwargs):
''' Connect to an InfluxDB instance
Connects to an InfluxDB instance and switches to a given database.
If the database doesn't exist it is created first via :func:`create`.
**Configuration Parameters**
host
The host for the connection. Pa... | python | def connect(self, **kwargs):
''' Connect to an InfluxDB instance
Connects to an InfluxDB instance and switches to a given database.
If the database doesn't exist it is created first via :func:`create`.
**Configuration Parameters**
host
The host for the connection. Pa... | [
"def",
"connect",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"host",
"=",
"ait",
".",
"config",
".",
"get",
"(",
"'database.host'",
",",
"kwargs",
".",
"get",
"(",
"'host'",
",",
"'localhost'",
")",
")",
"port",
"=",
"ait",
".",
"config",
".",... | Connect to an InfluxDB instance
Connects to an InfluxDB instance and switches to a given database.
If the database doesn't exist it is created first via :func:`create`.
**Configuration Parameters**
host
The host for the connection. Passed as either the config key
*... | [
"Connect",
"to",
"an",
"InfluxDB",
"instance"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/db.py#L221-L265 |
NASA-AMMOS/AIT-Core | ait/core/db.py | InfluxDBBackend.create | def create(self, **kwargs):
''' Create a database in a connected InfluxDB instance
**Configuration Parameters**
database name
The database name to create. Passed as either the config
key **database.dbname** or the kwargs argument
**database**. Defaults to **ait**.... | python | def create(self, **kwargs):
''' Create a database in a connected InfluxDB instance
**Configuration Parameters**
database name
The database name to create. Passed as either the config
key **database.dbname** or the kwargs argument
**database**. Defaults to **ait**.... | [
"def",
"create",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"dbname",
"=",
"ait",
".",
"config",
".",
"get",
"(",
"'database.dbname'",
",",
"kwargs",
".",
"get",
"(",
"'database'",
",",
"'ait'",
")",
")",
"if",
"self",
".",
"_conn",
"is",
"Non... | Create a database in a connected InfluxDB instance
**Configuration Parameters**
database name
The database name to create. Passed as either the config
key **database.dbname** or the kwargs argument
**database**. Defaults to **ait**.
Raises:
At... | [
"Create",
"a",
"database",
"in",
"a",
"connected",
"InfluxDB",
"instance"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/db.py#L267-L287 |
NASA-AMMOS/AIT-Core | ait/core/db.py | InfluxDBBackend.insert | def insert(self, packet, time=None, **kwargs):
''' Insert a packet into the database
Arguments
packet
The :class:`ait.core.tlm.Packet` instance to insert into
the database
time
Optional parameter specifying the time value to use w... | python | def insert(self, packet, time=None, **kwargs):
''' Insert a packet into the database
Arguments
packet
The :class:`ait.core.tlm.Packet` instance to insert into
the database
time
Optional parameter specifying the time value to use w... | [
"def",
"insert",
"(",
"self",
",",
"packet",
",",
"time",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"fields",
"=",
"{",
"}",
"pd",
"=",
"packet",
".",
"_defn",
"for",
"defn",
"in",
"pd",
".",
"fields",
":",
"val",
"=",
"getattr",
"(",
"pa... | Insert a packet into the database
Arguments
packet
The :class:`ait.core.tlm.Packet` instance to insert into
the database
time
Optional parameter specifying the time value to use when inserting
the record into the database.... | [
"Insert",
"a",
"packet",
"into",
"the",
"database"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/db.py#L289-L338 |
NASA-AMMOS/AIT-Core | ait/core/db.py | InfluxDBBackend.create_packets_from_results | def create_packets_from_results(self, packet_name, result_set):
''' Generate AIT Packets from a InfluxDB query ResultSet
Extract Influx DB query results into one packet per result entry. This
assumes that telemetry data was inserted in the format generated by
:func:`InfluxDBBackend.inse... | python | def create_packets_from_results(self, packet_name, result_set):
''' Generate AIT Packets from a InfluxDB query ResultSet
Extract Influx DB query results into one packet per result entry. This
assumes that telemetry data was inserted in the format generated by
:func:`InfluxDBBackend.inse... | [
"def",
"create_packets_from_results",
"(",
"self",
",",
"packet_name",
",",
"result_set",
")",
":",
"try",
":",
"pkt_defn",
"=",
"tlm",
".",
"getDefaultDict",
"(",
")",
"[",
"packet_name",
"]",
"except",
"KeyError",
":",
"log",
".",
"error",
"(",
"'Unknown p... | Generate AIT Packets from a InfluxDB query ResultSet
Extract Influx DB query results into one packet per result entry. This
assumes that telemetry data was inserted in the format generated by
:func:`InfluxDBBackend.insert`. Complex types such as CMD16 and EVR16 are
evaluated if they can... | [
"Generate",
"AIT",
"Packets",
"from",
"a",
"InfluxDB",
"query",
"ResultSet"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/db.py#L359-L423 |
NASA-AMMOS/AIT-Core | ait/core/db.py | SQLiteBackend.connect | def connect(self, **kwargs):
''' Connect to a SQLite instance
**Configuration Parameters**
database
The database name or file to "connect" to. Defaults to **ait**.
'''
if 'database' not in kwargs:
kwargs['database'] = 'ait'
self._conn = ... | python | def connect(self, **kwargs):
''' Connect to a SQLite instance
**Configuration Parameters**
database
The database name or file to "connect" to. Defaults to **ait**.
'''
if 'database' not in kwargs:
kwargs['database'] = 'ait'
self._conn = ... | [
"def",
"connect",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'database'",
"not",
"in",
"kwargs",
":",
"kwargs",
"[",
"'database'",
"]",
"=",
"'ait'",
"self",
".",
"_conn",
"=",
"self",
".",
"_backend",
".",
"connect",
"(",
"kwargs",
"[",
... | Connect to a SQLite instance
**Configuration Parameters**
database
The database name or file to "connect" to. Defaults to **ait**. | [
"Connect",
"to",
"a",
"SQLite",
"instance",
"**",
"Configuration",
"Parameters",
"**"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/db.py#L434-L445 |
NASA-AMMOS/AIT-Core | ait/core/db.py | SQLiteBackend.create | def create(self, **kwargs):
''' Create a database for the current telemetry dictionary
Connects to a SQLite instance via :func:`connect` and creates a
skeleton database for future data inserts.
**Configuration Parameters**
tlmdict
The :class:`ait.core.tlm.TlmDict`... | python | def create(self, **kwargs):
''' Create a database for the current telemetry dictionary
Connects to a SQLite instance via :func:`connect` and creates a
skeleton database for future data inserts.
**Configuration Parameters**
tlmdict
The :class:`ait.core.tlm.TlmDict`... | [
"def",
"create",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"tlmdict",
"=",
"kwargs",
".",
"get",
"(",
"'tlmdict'",
",",
"tlm",
".",
"getDefaultDict",
"(",
")",
")",
"self",
".",
"connect",
"(",
"*",
"*",
"kwargs",
")",
"for",
"name",
",",
"... | Create a database for the current telemetry dictionary
Connects to a SQLite instance via :func:`connect` and creates a
skeleton database for future data inserts.
**Configuration Parameters**
tlmdict
The :class:`ait.core.tlm.TlmDict` instance to use. Defaults to
... | [
"Create",
"a",
"database",
"for",
"the",
"current",
"telemetry",
"dictionary"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/db.py#L447-L465 |
NASA-AMMOS/AIT-Core | ait/core/db.py | SQLiteBackend._create_table | def _create_table(self, packet_defn):
''' Creates a database table for the given PacketDefinition
Arguments
packet_defn
The :class:`ait.core.tlm.PacketDefinition` instance for which a table entry
should be made.
'''
cols = ('%s %s' % (defn.nam... | python | def _create_table(self, packet_defn):
''' Creates a database table for the given PacketDefinition
Arguments
packet_defn
The :class:`ait.core.tlm.PacketDefinition` instance for which a table entry
should be made.
'''
cols = ('%s %s' % (defn.nam... | [
"def",
"_create_table",
"(",
"self",
",",
"packet_defn",
")",
":",
"cols",
"=",
"(",
"'%s %s'",
"%",
"(",
"defn",
".",
"name",
",",
"self",
".",
"_getTypename",
"(",
"defn",
")",
")",
"for",
"defn",
"in",
"packet_defn",
".",
"fields",
")",
"sql",
"="... | Creates a database table for the given PacketDefinition
Arguments
packet_defn
The :class:`ait.core.tlm.PacketDefinition` instance for which a table entry
should be made. | [
"Creates",
"a",
"database",
"table",
"for",
"the",
"given",
"PacketDefinition"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/db.py#L467-L479 |
NASA-AMMOS/AIT-Core | ait/core/db.py | SQLiteBackend.insert | def insert(self, packet, **kwargs):
''' Insert a packet into the database
Arguments
packet
The :class:`ait.core.tlm.Packet` instance to insert into
the database
'''
values = [ ]
pd = packet._defn
for defn in pd.fields:
... | python | def insert(self, packet, **kwargs):
''' Insert a packet into the database
Arguments
packet
The :class:`ait.core.tlm.Packet` instance to insert into
the database
'''
values = [ ]
pd = packet._defn
for defn in pd.fields:
... | [
"def",
"insert",
"(",
"self",
",",
"packet",
",",
"*",
"*",
"kwargs",
")",
":",
"values",
"=",
"[",
"]",
"pd",
"=",
"packet",
".",
"_defn",
"for",
"defn",
"in",
"pd",
".",
"fields",
":",
"val",
"=",
"getattr",
"(",
"packet",
".",
"raw",
",",
"d... | Insert a packet into the database
Arguments
packet
The :class:`ait.core.tlm.Packet` instance to insert into
the database | [
"Insert",
"a",
"packet",
"into",
"the",
"database"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/db.py#L481-L505 |
NASA-AMMOS/AIT-Core | ait/core/db.py | SQLiteBackend._getTypename | def _getTypename(self, defn):
""" Returns the SQL typename required to store the given FieldDefinition """
return 'REAL' if defn.type.float or 'TIME' in defn.type.name or defn.dntoeu else 'INTEGER' | python | def _getTypename(self, defn):
""" Returns the SQL typename required to store the given FieldDefinition """
return 'REAL' if defn.type.float or 'TIME' in defn.type.name or defn.dntoeu else 'INTEGER' | [
"def",
"_getTypename",
"(",
"self",
",",
"defn",
")",
":",
"return",
"'REAL'",
"if",
"defn",
".",
"type",
".",
"float",
"or",
"'TIME'",
"in",
"defn",
".",
"type",
".",
"name",
"or",
"defn",
".",
"dntoeu",
"else",
"'INTEGER'"
] | Returns the SQL typename required to store the given FieldDefinition | [
"Returns",
"the",
"SQL",
"typename",
"required",
"to",
"store",
"the",
"given",
"FieldDefinition"
] | train | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/db.py#L523-L525 |
ManiacalLabs/BiblioPixelAnimations | BiblioPixelAnimations/cube/bloom.py | genCubeVector | def genCubeVector(x, y, z, x_mult=1, y_mult=1, z_mult=1):
"""Generates a map of vector lengths from the center point to each coordinate
x - width of matrix to generate
y - height of matrix to generate
z - depth of matrix to generate
x_mult - value to scale x-axis by
y_mult - value to sca... | python | def genCubeVector(x, y, z, x_mult=1, y_mult=1, z_mult=1):
"""Generates a map of vector lengths from the center point to each coordinate
x - width of matrix to generate
y - height of matrix to generate
z - depth of matrix to generate
x_mult - value to scale x-axis by
y_mult - value to sca... | [
"def",
"genCubeVector",
"(",
"x",
",",
"y",
",",
"z",
",",
"x_mult",
"=",
"1",
",",
"y_mult",
"=",
"1",
",",
"z_mult",
"=",
"1",
")",
":",
"cX",
"=",
"(",
"x",
"-",
"1",
")",
"/",
"2.0",
"cY",
"=",
"(",
"y",
"-",
"1",
")",
"/",
"2.0",
"... | Generates a map of vector lengths from the center point to each coordinate
x - width of matrix to generate
y - height of matrix to generate
z - depth of matrix to generate
x_mult - value to scale x-axis by
y_mult - value to scale y-axis by
z_mult - value to scale z-axis by | [
"Generates",
"a",
"map",
"of",
"vector",
"lengths",
"from",
"the",
"center",
"point",
"to",
"each",
"coordinate",
"x",
"-",
"width",
"of",
"matrix",
"to",
"generate",
"y",
"-",
"height",
"of",
"matrix",
"to",
"generate",
"z",
"-",
"depth",
"of",
"matrix"... | train | https://github.com/ManiacalLabs/BiblioPixelAnimations/blob/fba81f6b94f5265272a53f462ef013df1ccdb426/BiblioPixelAnimations/cube/bloom.py#L5-L24 |
brosner/django-timezones | timezones/utils.py | adjust_datetime_to_timezone | def adjust_datetime_to_timezone(value, from_tz, to_tz=None):
"""
Given a ``datetime`` object adjust it according to the from_tz timezone
string into the to_tz timezone string.
"""
if to_tz is None:
to_tz = settings.TIME_ZONE
if value.tzinfo is None:
if not hasattr(from_tz, "local... | python | def adjust_datetime_to_timezone(value, from_tz, to_tz=None):
"""
Given a ``datetime`` object adjust it according to the from_tz timezone
string into the to_tz timezone string.
"""
if to_tz is None:
to_tz = settings.TIME_ZONE
if value.tzinfo is None:
if not hasattr(from_tz, "local... | [
"def",
"adjust_datetime_to_timezone",
"(",
"value",
",",
"from_tz",
",",
"to_tz",
"=",
"None",
")",
":",
"if",
"to_tz",
"is",
"None",
":",
"to_tz",
"=",
"settings",
".",
"TIME_ZONE",
"if",
"value",
".",
"tzinfo",
"is",
"None",
":",
"if",
"not",
"hasattr"... | Given a ``datetime`` object adjust it according to the from_tz timezone
string into the to_tz timezone string. | [
"Given",
"a",
"datetime",
"object",
"adjust",
"it",
"according",
"to",
"the",
"from_tz",
"timezone",
"string",
"into",
"the",
"to_tz",
"timezone",
"string",
"."
] | train | https://github.com/brosner/django-timezones/blob/43b437c39533e1832562a2c69247b89ae1af169e/timezones/utils.py#L16-L27 |
brosner/django-timezones | timezones/fields.py | LocalizedDateTimeField.get_db_prep_save | def get_db_prep_save(self, value, connection=None):
"""
Returns field's value prepared for saving into a database.
"""
## convert to settings.TIME_ZONE
if value is not None:
if value.tzinfo is None:
value = default_tz.localize(value)
else:
... | python | def get_db_prep_save(self, value, connection=None):
"""
Returns field's value prepared for saving into a database.
"""
## convert to settings.TIME_ZONE
if value is not None:
if value.tzinfo is None:
value = default_tz.localize(value)
else:
... | [
"def",
"get_db_prep_save",
"(",
"self",
",",
"value",
",",
"connection",
"=",
"None",
")",
":",
"## convert to settings.TIME_ZONE",
"if",
"value",
"is",
"not",
"None",
":",
"if",
"value",
".",
"tzinfo",
"is",
"None",
":",
"value",
"=",
"default_tz",
".",
"... | Returns field's value prepared for saving into a database. | [
"Returns",
"field",
"s",
"value",
"prepared",
"for",
"saving",
"into",
"a",
"database",
"."
] | train | https://github.com/brosner/django-timezones/blob/43b437c39533e1832562a2c69247b89ae1af169e/timezones/fields.py#L86-L96 |
brosner/django-timezones | timezones/fields.py | LocalizedDateTimeField.get_db_prep_lookup | def get_db_prep_lookup(self, lookup_type, value, connection=None, prepared=None):
"""
Returns field's value prepared for database lookup.
"""
## convert to settings.TIME_ZONE
if value.tzinfo is None:
value = default_tz.localize(value)
else:
value =... | python | def get_db_prep_lookup(self, lookup_type, value, connection=None, prepared=None):
"""
Returns field's value prepared for database lookup.
"""
## convert to settings.TIME_ZONE
if value.tzinfo is None:
value = default_tz.localize(value)
else:
value =... | [
"def",
"get_db_prep_lookup",
"(",
"self",
",",
"lookup_type",
",",
"value",
",",
"connection",
"=",
"None",
",",
"prepared",
"=",
"None",
")",
":",
"## convert to settings.TIME_ZONE",
"if",
"value",
".",
"tzinfo",
"is",
"None",
":",
"value",
"=",
"default_tz",... | Returns field's value prepared for database lookup. | [
"Returns",
"field",
"s",
"value",
"prepared",
"for",
"database",
"lookup",
"."
] | train | https://github.com/brosner/django-timezones/blob/43b437c39533e1832562a2c69247b89ae1af169e/timezones/fields.py#L98-L107 |
ManiacalLabs/BiblioPixelAnimations | BiblioPixelAnimations/cube/GameOfLife.py | Table.liveNeighbours | def liveNeighbours(self, z, y, x):
"""Returns the number of live neighbours."""
count = 0
for oz, oy, ox in self.offsets:
cz, cy, cx = z + oz, y + oy, x + ox
if cz >= self.depth:
cz = 0
if cy >= self.height:
cy = 0
... | python | def liveNeighbours(self, z, y, x):
"""Returns the number of live neighbours."""
count = 0
for oz, oy, ox in self.offsets:
cz, cy, cx = z + oz, y + oy, x + ox
if cz >= self.depth:
cz = 0
if cy >= self.height:
cy = 0
... | [
"def",
"liveNeighbours",
"(",
"self",
",",
"z",
",",
"y",
",",
"x",
")",
":",
"count",
"=",
"0",
"for",
"oz",
",",
"oy",
",",
"ox",
"in",
"self",
".",
"offsets",
":",
"cz",
",",
"cy",
",",
"cx",
"=",
"z",
"+",
"oz",
",",
"y",
"+",
"oy",
"... | Returns the number of live neighbours. | [
"Returns",
"the",
"number",
"of",
"live",
"neighbours",
"."
] | train | https://github.com/ManiacalLabs/BiblioPixelAnimations/blob/fba81f6b94f5265272a53f462ef013df1ccdb426/BiblioPixelAnimations/cube/GameOfLife.py#L48-L76 |
ManiacalLabs/BiblioPixelAnimations | BiblioPixelAnimations/cube/GameOfLife.py | Table.turn | def turn(self):
"""Turn"""
r = (4, 5, 5, 5)
nt = copy.deepcopy(self.table)
for z in range(self.depth):
for y in range(self.height):
for x in range(self.width):
neighbours = self.liveNeighbours(z, y, x)
if self.ta... | python | def turn(self):
"""Turn"""
r = (4, 5, 5, 5)
nt = copy.deepcopy(self.table)
for z in range(self.depth):
for y in range(self.height):
for x in range(self.width):
neighbours = self.liveNeighbours(z, y, x)
if self.ta... | [
"def",
"turn",
"(",
"self",
")",
":",
"r",
"=",
"(",
"4",
",",
"5",
",",
"5",
",",
"5",
")",
"nt",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
".",
"table",
")",
"for",
"z",
"in",
"range",
"(",
"self",
".",
"depth",
")",
":",
"for",
"y",
"... | Turn | [
"Turn"
] | train | https://github.com/ManiacalLabs/BiblioPixelAnimations/blob/fba81f6b94f5265272a53f462ef013df1ccdb426/BiblioPixelAnimations/cube/GameOfLife.py#L78-L95 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.