repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
swift-nav/libsbp
generator/sbpg/targets/latex.py
render_source
def render_source(output_dir, package_specs, version): """ Render and output """ destination_filename = "%s/sbp_out.tex" % output_dir py_template = JENV.get_template(TEMPLATE_NAME) stable_msgs = [] unstable_msgs = [] prims = [] for p in sorted(package_specs, key=attrgetter('identifier')): pkg_name...
python
def render_source(output_dir, package_specs, version): """ Render and output """ destination_filename = "%s/sbp_out.tex" % output_dir py_template = JENV.get_template(TEMPLATE_NAME) stable_msgs = [] unstable_msgs = [] prims = [] for p in sorted(package_specs, key=attrgetter('identifier')): pkg_name...
[ "def", "render_source", "(", "output_dir", ",", "package_specs", ",", "version", ")", ":", "destination_filename", "=", "\"%s/sbp_out.tex\"", "%", "output_dir", "py_template", "=", "JENV", ".", "get_template", "(", "TEMPLATE_NAME", ")", "stable_msgs", "=", "[", "]...
Render and output
[ "Render", "and", "output" ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/generator/sbpg/targets/latex.py#L255-L311
swift-nav/libsbp
python/sbp/client/examples/udp.py
get_args
def get_args(): """ Get and parse arguments. """ import argparse parser = argparse.ArgumentParser( description="Swift Navigation SBP Example.") parser.add_argument( "-s", "--serial-port", default=[DEFAULT_SERIAL_PORT], nargs=1, help="specify the se...
python
def get_args(): """ Get and parse arguments. """ import argparse parser = argparse.ArgumentParser( description="Swift Navigation SBP Example.") parser.add_argument( "-s", "--serial-port", default=[DEFAULT_SERIAL_PORT], nargs=1, help="specify the se...
[ "def", "get_args", "(", ")", ":", "import", "argparse", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "\"Swift Navigation SBP Example.\"", ")", "parser", ".", "add_argument", "(", "\"-s\"", ",", "\"--serial-port\"", ",", "default", "="...
Get and parse arguments.
[ "Get", "and", "parse", "arguments", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/python/sbp/client/examples/udp.py#L31-L62
swift-nav/libsbp
generator/sbpg/targets/c.py
commentify
def commentify(value): """ Builds a comment. """ value = markdown_links(value) if value is None: return if len(value.split('\n')) == 1: return "* " + value else: return '\n'.join([' * ' + l for l in value.split('\n')[:-1]])
python
def commentify(value): """ Builds a comment. """ value = markdown_links(value) if value is None: return if len(value.split('\n')) == 1: return "* " + value else: return '\n'.join([' * ' + l for l in value.split('\n')[:-1]])
[ "def", "commentify", "(", "value", ")", ":", "value", "=", "markdown_links", "(", "value", ")", "if", "value", "is", "None", ":", "return", "if", "len", "(", "value", ".", "split", "(", "'\\n'", ")", ")", "==", "1", ":", "return", "\"* \"", "+", "v...
Builds a comment.
[ "Builds", "a", "comment", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/generator/sbpg/targets/c.py#L22-L32
swift-nav/libsbp
generator/sbpg/targets/c.py
convert
def convert(value): """Converts to a C language appropriate identifier format. """ s0 = "Sbp" + value if value in COLLISIONS else value s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', s0) return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower() + "_t"
python
def convert(value): """Converts to a C language appropriate identifier format. """ s0 = "Sbp" + value if value in COLLISIONS else value s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', s0) return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower() + "_t"
[ "def", "convert", "(", "value", ")", ":", "s0", "=", "\"Sbp\"", "+", "value", "if", "value", "in", "COLLISIONS", "else", "value", "s1", "=", "re", ".", "sub", "(", "'(.)([A-Z][a-z]+)'", ",", "r'\\1_\\2'", ",", "s0", ")", "return", "re", ".", "sub", "...
Converts to a C language appropriate identifier format.
[ "Converts", "to", "a", "C", "language", "appropriate", "identifier", "format", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/generator/sbpg/targets/c.py#L47-L53
swift-nav/libsbp
generator/sbpg/targets/c.py
mk_id
def mk_id(field): """Builds an identifier from a field. """ name = field.type_id if name == "string": return "%s" % ("char") elif name == "array" and field.size: if field.options['fill'].value not in CONSTRUCT_CODE: return "%s" % convert(field.options['fill'].value) else: return "%s" %...
python
def mk_id(field): """Builds an identifier from a field. """ name = field.type_id if name == "string": return "%s" % ("char") elif name == "array" and field.size: if field.options['fill'].value not in CONSTRUCT_CODE: return "%s" % convert(field.options['fill'].value) else: return "%s" %...
[ "def", "mk_id", "(", "field", ")", ":", "name", "=", "field", ".", "type_id", "if", "name", "==", "\"string\"", ":", "return", "\"%s\"", "%", "(", "\"char\"", ")", "elif", "name", "==", "\"array\"", "and", "field", ".", "size", ":", "if", "field", "....
Builds an identifier from a field.
[ "Builds", "an", "identifier", "from", "a", "field", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/generator/sbpg/targets/c.py#L55-L71
swift-nav/libsbp
generator/sbpg/targets/c.py
mk_size
def mk_size(field): """Builds an identifier for a container type. """ name = field.type_id if name == "string" and field.options.get('size', None): return "%s[%d];" % (field.identifier, field.options.get('size').value) elif name == "string": return "%s[0];" % field.identifier elif name == "array" an...
python
def mk_size(field): """Builds an identifier for a container type. """ name = field.type_id if name == "string" and field.options.get('size', None): return "%s[%d];" % (field.identifier, field.options.get('size').value) elif name == "string": return "%s[0];" % field.identifier elif name == "array" an...
[ "def", "mk_size", "(", "field", ")", ":", "name", "=", "field", ".", "type_id", "if", "name", "==", "\"string\"", "and", "field", ".", "options", ".", "get", "(", "'size'", ",", "None", ")", ":", "return", "\"%s[%d];\"", "%", "(", "field", ".", "iden...
Builds an identifier for a container type.
[ "Builds", "an", "identifier", "for", "a", "container", "type", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/generator/sbpg/targets/c.py#L73-L86
swift-nav/libsbp
generator/sbpg/targets/c.py
render_source
def render_source(output_dir, package_spec): """ Render and output to a directory given a package specification. """ path, name = package_spec.filepath destination_filename = "%s/%s.h" % (output_dir, name) py_template = JENV.get_template(MESSAGES_TEMPLATE_NAME) with open(destination_filename, 'w') as f: ...
python
def render_source(output_dir, package_spec): """ Render and output to a directory given a package specification. """ path, name = package_spec.filepath destination_filename = "%s/%s.h" % (output_dir, name) py_template = JENV.get_template(MESSAGES_TEMPLATE_NAME) with open(destination_filename, 'w') as f: ...
[ "def", "render_source", "(", "output_dir", ",", "package_spec", ")", ":", "path", ",", "name", "=", "package_spec", ".", "filepath", "destination_filename", "=", "\"%s/%s.h\"", "%", "(", "output_dir", ",", "name", ")", "py_template", "=", "JENV", ".", "get_tem...
Render and output to a directory given a package specification.
[ "Render", "and", "output", "to", "a", "directory", "given", "a", "package", "specification", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/generator/sbpg/targets/c.py#L93-L107
swift-nav/libsbp
python/sbp/msg.py
crc16jit
def crc16jit(buf, offset, crc, length): """CRC16 implementation acording to CCITT standards.""" for index in range(offset, offset + length): data = buf[index] lookup = crc16_tab[((nb.u2(crc) >> 8) & nb.u2(0xFF)) ^ (data & nb.u2(0xFF))] crc = ((nb.u2(crc) << nb.u2(8)) & nb.u2(0xFFFF)) ^ lookup crc = ...
python
def crc16jit(buf, offset, crc, length): """CRC16 implementation acording to CCITT standards.""" for index in range(offset, offset + length): data = buf[index] lookup = crc16_tab[((nb.u2(crc) >> 8) & nb.u2(0xFF)) ^ (data & nb.u2(0xFF))] crc = ((nb.u2(crc) << nb.u2(8)) & nb.u2(0xFFFF)) ^ lookup crc = ...
[ "def", "crc16jit", "(", "buf", ",", "offset", ",", "crc", ",", "length", ")", ":", "for", "index", "in", "range", "(", "offset", ",", "offset", "+", "length", ")", ":", "data", "=", "buf", "[", "index", "]", "lookup", "=", "crc16_tab", "[", "(", ...
CRC16 implementation acording to CCITT standards.
[ "CRC16", "implementation", "acording", "to", "CCITT", "standards", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/python/sbp/msg.py#L66-L73
swift-nav/libsbp
python/sbp/msg.py
crc16_nojit
def crc16_nojit(s, crc=0): """CRC16 implementation acording to CCITT standards.""" for ch in bytearray(s): # bytearray's elements are integers in both python 2 and 3 crc = ((crc << 8) & 0xFFFF) ^ _crc16_tab[((crc >> 8) & 0xFF) ^ (ch & 0xFF)] crc &= 0xFFFF return crc
python
def crc16_nojit(s, crc=0): """CRC16 implementation acording to CCITT standards.""" for ch in bytearray(s): # bytearray's elements are integers in both python 2 and 3 crc = ((crc << 8) & 0xFFFF) ^ _crc16_tab[((crc >> 8) & 0xFF) ^ (ch & 0xFF)] crc &= 0xFFFF return crc
[ "def", "crc16_nojit", "(", "s", ",", "crc", "=", "0", ")", ":", "for", "ch", "in", "bytearray", "(", "s", ")", ":", "# bytearray's elements are integers in both python 2 and 3", "crc", "=", "(", "(", "crc", "<<", "8", ")", "&", "0xFFFF", ")", "^", "_crc1...
CRC16 implementation acording to CCITT standards.
[ "CRC16", "implementation", "acording", "to", "CCITT", "standards", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/python/sbp/msg.py#L84-L89
swift-nav/libsbp
python/sbp/msg.py
SBP._get_framed
def _get_framed(self, buf, offset, insert_payload): """Returns the framed message and updates the CRC. """ header_offset = offset + self._header_len self.length = insert_payload(buf, header_offset, self.payload) struct.pack_into(self._header_fmt, buf, offse...
python
def _get_framed(self, buf, offset, insert_payload): """Returns the framed message and updates the CRC. """ header_offset = offset + self._header_len self.length = insert_payload(buf, header_offset, self.payload) struct.pack_into(self._header_fmt, buf, offse...
[ "def", "_get_framed", "(", "self", ",", "buf", ",", "offset", ",", "insert_payload", ")", ":", "header_offset", "=", "offset", "+", "self", ".", "_header_len", "self", ".", "length", "=", "insert_payload", "(", "buf", ",", "header_offset", ",", "self", "."...
Returns the framed message and updates the CRC.
[ "Returns", "the", "framed", "message", "and", "updates", "the", "CRC", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/python/sbp/msg.py#L172-L191
swift-nav/libsbp
python/sbp/msg.py
SBP.pack
def pack(self): """Pack to framed binary message. """ buf = np.zeros(512, dtype=np.uint8) packed_len = self._get_framed(buf, 0, self._copy_payload) d = buf[:packed_len] return d.tobytes()
python
def pack(self): """Pack to framed binary message. """ buf = np.zeros(512, dtype=np.uint8) packed_len = self._get_framed(buf, 0, self._copy_payload) d = buf[:packed_len] return d.tobytes()
[ "def", "pack", "(", "self", ")", ":", "buf", "=", "np", ".", "zeros", "(", "512", ",", "dtype", "=", "np", ".", "uint8", ")", "packed_len", "=", "self", ".", "_get_framed", "(", "buf", ",", "0", ",", "self", ".", "_copy_payload", ")", "d", "=", ...
Pack to framed binary message.
[ "Pack", "to", "framed", "binary", "message", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/python/sbp/msg.py#L193-L200
swift-nav/libsbp
python/sbp/msg.py
SBP.pack_into
def pack_into(self, buf, offset, write_payload): """Pack to framed binary message. """ return self._get_framed(buf, offset, write_payload)
python
def pack_into(self, buf, offset, write_payload): """Pack to framed binary message. """ return self._get_framed(buf, offset, write_payload)
[ "def", "pack_into", "(", "self", ",", "buf", ",", "offset", ",", "write_payload", ")", ":", "return", "self", ".", "_get_framed", "(", "buf", ",", "offset", ",", "write_payload", ")" ]
Pack to framed binary message.
[ "Pack", "to", "framed", "binary", "message", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/python/sbp/msg.py#L202-L206
swift-nav/libsbp
python/sbp/msg.py
SBP.unpack
def unpack(d): """Unpack and return a framed binary message. """ p = SBP._parser.parse(d) assert p.preamble == SBP_PREAMBLE, "Invalid preamble 0x%x." % p.preamble return SBP(p.msg_type, p.sender, p.length, p.payload, p.crc)
python
def unpack(d): """Unpack and return a framed binary message. """ p = SBP._parser.parse(d) assert p.preamble == SBP_PREAMBLE, "Invalid preamble 0x%x." % p.preamble return SBP(p.msg_type, p.sender, p.length, p.payload, p.crc)
[ "def", "unpack", "(", "d", ")", ":", "p", "=", "SBP", ".", "_parser", ".", "parse", "(", "d", ")", "assert", "p", ".", "preamble", "==", "SBP_PREAMBLE", ",", "\"Invalid preamble 0x%x.\"", "%", "p", ".", "preamble", "return", "SBP", "(", "p", ".", "ms...
Unpack and return a framed binary message.
[ "Unpack", "and", "return", "a", "framed", "binary", "message", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/python/sbp/msg.py#L209-L215
swift-nav/libsbp
python/sbp/msg.py
SBP.to_json
def to_json(self, sort_keys=False): """Produce a JSON-encoded SBP message. """ d = self.to_json_dict() return json.dumps(d, sort_keys=sort_keys)
python
def to_json(self, sort_keys=False): """Produce a JSON-encoded SBP message. """ d = self.to_json_dict() return json.dumps(d, sort_keys=sort_keys)
[ "def", "to_json", "(", "self", ",", "sort_keys", "=", "False", ")", ":", "d", "=", "self", ".", "to_json_dict", "(", ")", "return", "json", ".", "dumps", "(", "d", ",", "sort_keys", "=", "sort_keys", ")" ]
Produce a JSON-encoded SBP message.
[ "Produce", "a", "JSON", "-", "encoded", "SBP", "message", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/python/sbp/msg.py#L234-L239
swift-nav/libsbp
python/sbp/msg.py
SBP.from_json
def from_json(s): """Given a JSON-encoded message, build an object. """ d = json.loads(s) sbp = SBP.from_json_dict(d) return sbp
python
def from_json(s): """Given a JSON-encoded message, build an object. """ d = json.loads(s) sbp = SBP.from_json_dict(d) return sbp
[ "def", "from_json", "(", "s", ")", ":", "d", "=", "json", ".", "loads", "(", "s", ")", "sbp", "=", "SBP", ".", "from_json_dict", "(", "d", ")", "return", "sbp" ]
Given a JSON-encoded message, build an object.
[ "Given", "a", "JSON", "-", "encoded", "message", "build", "an", "object", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/python/sbp/msg.py#L242-L248
swift-nav/libsbp
python/sbp/client/drivers/pyserial_driver.py
PySerialDriver.read
def read(self, size): """ Read wrapper. Parameters ---------- size : int Number of bytes to read. """ try: return self.handle.read(size) except (OSError, serial.SerialException): print() print("Piksi disconnec...
python
def read(self, size): """ Read wrapper. Parameters ---------- size : int Number of bytes to read. """ try: return self.handle.read(size) except (OSError, serial.SerialException): print() print("Piksi disconnec...
[ "def", "read", "(", "self", ",", "size", ")", ":", "try", ":", "return", "self", ".", "handle", ".", "read", "(", "size", ")", "except", "(", "OSError", ",", "serial", ".", "SerialException", ")", ":", "print", "(", ")", "print", "(", "\"Piksi discon...
Read wrapper. Parameters ---------- size : int Number of bytes to read.
[ "Read", "wrapper", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/python/sbp/client/drivers/pyserial_driver.py#L69-L85
swift-nav/libsbp
python/sbp/client/drivers/pyserial_driver.py
PySerialDriver.write
def write(self, s): """ Write wrapper. Parameters ---------- s : bytes Bytes to write """ try: return self.handle.write(s) except (OSError, serial.SerialException, serial.writeTimeoutError) as e: if e == s...
python
def write(self, s): """ Write wrapper. Parameters ---------- s : bytes Bytes to write """ try: return self.handle.write(s) except (OSError, serial.SerialException, serial.writeTimeoutError) as e: if e == s...
[ "def", "write", "(", "self", ",", "s", ")", ":", "try", ":", "return", "self", ".", "handle", ".", "write", "(", "s", ")", "except", "(", "OSError", ",", "serial", ".", "SerialException", ",", "serial", ".", "writeTimeoutError", ")", "as", "e", ":", ...
Write wrapper. Parameters ---------- s : bytes Bytes to write
[ "Write", "wrapper", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/python/sbp/client/drivers/pyserial_driver.py#L87-L108
swift-nav/libsbp
generator/sbpg/targets/java.py
commentify
def commentify(value): """ Builds a comment. """ value = comment_links(value) if value is None: return if len(value.split('\n')) == 1: return "* " + value else: return '\n'.join([' * ' + l for l in value.split('\n')[:-1]])
python
def commentify(value): """ Builds a comment. """ value = comment_links(value) if value is None: return if len(value.split('\n')) == 1: return "* " + value else: return '\n'.join([' * ' + l for l in value.split('\n')[:-1]])
[ "def", "commentify", "(", "value", ")", ":", "value", "=", "comment_links", "(", "value", ")", "if", "value", "is", "None", ":", "return", "if", "len", "(", "value", ".", "split", "(", "'\\n'", ")", ")", "==", "1", ":", "return", "\"* \"", "+", "va...
Builds a comment.
[ "Builds", "a", "comment", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/generator/sbpg/targets/java.py#L60-L70
swift-nav/libsbp
generator/sbpg/targets/java.py
parse_type
def parse_type(field): """ Function to pull a type from the binary payload. """ if field.type_id == 'string': if 'size' in field.options: return "parser.getString(%d)" % field.options['size'].value else: return "parser.getString()" elif field.type_id in JAVA_TYPE_MAP: # Primitive java ...
python
def parse_type(field): """ Function to pull a type from the binary payload. """ if field.type_id == 'string': if 'size' in field.options: return "parser.getString(%d)" % field.options['size'].value else: return "parser.getString()" elif field.type_id in JAVA_TYPE_MAP: # Primitive java ...
[ "def", "parse_type", "(", "field", ")", ":", "if", "field", ".", "type_id", "==", "'string'", ":", "if", "'size'", "in", "field", ".", "options", ":", "return", "\"parser.getString(%d)\"", "%", "field", ".", "options", "[", "'size'", "]", ".", "value", "...
Function to pull a type from the binary payload.
[ "Function", "to", "pull", "a", "type", "from", "the", "binary", "payload", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/generator/sbpg/targets/java.py#L81-L108
swift-nav/libsbp
generator/sbpg/targets/java.py
build_type
def build_type(field): """ Function to pack a type into the binary payload. """ if field.type_id == 'string': if 'size' in field.options: return "builder.putString(%s, %d)" % (field.identifier, field.options['size'].value) else: return "builder.putString(%s)" % field.identifier elif field....
python
def build_type(field): """ Function to pack a type into the binary payload. """ if field.type_id == 'string': if 'size' in field.options: return "builder.putString(%s, %d)" % (field.identifier, field.options['size'].value) else: return "builder.putString(%s)" % field.identifier elif field....
[ "def", "build_type", "(", "field", ")", ":", "if", "field", ".", "type_id", "==", "'string'", ":", "if", "'size'", "in", "field", ".", "options", ":", "return", "\"builder.putString(%s, %d)\"", "%", "(", "field", ".", "identifier", ",", "field", ".", "opti...
Function to pack a type into the binary payload.
[ "Function", "to", "pack", "a", "type", "into", "the", "binary", "payload", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/generator/sbpg/targets/java.py#L110-L138
swift-nav/libsbp
generator/sbpg/targets/java.py
render_source
def render_source(output_dir, package_spec, jenv=JENV): """ Render and output """ path, module_name = package_spec.filepath java_template = jenv.get_template(TEMPLATE_NAME) module_path = "com." + package_spec.identifier yaml_filepath = "/".join(package_spec.filepath) + ".yaml" includes = [".".join(i.spl...
python
def render_source(output_dir, package_spec, jenv=JENV): """ Render and output """ path, module_name = package_spec.filepath java_template = jenv.get_template(TEMPLATE_NAME) module_path = "com." + package_spec.identifier yaml_filepath = "/".join(package_spec.filepath) + ".yaml" includes = [".".join(i.spl...
[ "def", "render_source", "(", "output_dir", ",", "package_spec", ",", "jenv", "=", "JENV", ")", ":", "path", ",", "module_name", "=", "package_spec", ".", "filepath", "java_template", "=", "jenv", ".", "get_template", "(", "TEMPLATE_NAME", ")", "module_path", "...
Render and output
[ "Render", "and", "output" ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/generator/sbpg/targets/java.py#L158-L183
swift-nav/libsbp
generator/sbpg/targets/java.py
render_table
def render_table(output_dir, packages, jenv=JENV): """ Render and output dispatch table """ destination_filename = output_dir + "/com/swiftnav/sbp/client/MessageTable.java" with open(destination_filename, 'w+') as f: print(destination_filename) f.write(jenv.get_template(TEMPLATE_TABLE_NAME).render...
python
def render_table(output_dir, packages, jenv=JENV): """ Render and output dispatch table """ destination_filename = output_dir + "/com/swiftnav/sbp/client/MessageTable.java" with open(destination_filename, 'w+') as f: print(destination_filename) f.write(jenv.get_template(TEMPLATE_TABLE_NAME).render...
[ "def", "render_table", "(", "output_dir", ",", "packages", ",", "jenv", "=", "JENV", ")", ":", "destination_filename", "=", "output_dir", "+", "\"/com/swiftnav/sbp/client/MessageTable.java\"", "with", "open", "(", "destination_filename", ",", "'w+'", ")", "as", "f",...
Render and output dispatch table
[ "Render", "and", "output", "dispatch", "table" ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/generator/sbpg/targets/java.py#L185-L192
swift-nav/libsbp
generator/sbpg/targets/javascript.py
construct_format
def construct_format(f, type_map=CONSTRUCT_CODE): """ Formats for binary-parser library. """ formatted = "" if type_map.get(f.type_id, None): return "%s('%s')" % (type_map.get(f.type_id), f.identifier) elif f.type_id == 'string' and f.options.get('size', None): return "string('%s', { length: %d })" ...
python
def construct_format(f, type_map=CONSTRUCT_CODE): """ Formats for binary-parser library. """ formatted = "" if type_map.get(f.type_id, None): return "%s('%s')" % (type_map.get(f.type_id), f.identifier) elif f.type_id == 'string' and f.options.get('size', None): return "string('%s', { length: %d })" ...
[ "def", "construct_format", "(", "f", ",", "type_map", "=", "CONSTRUCT_CODE", ")", ":", "formatted", "=", "\"\"", "if", "type_map", ".", "get", "(", "f", ".", "type_id", ",", "None", ")", ":", "return", "\"%s('%s')\"", "%", "(", "type_map", ".", "get", ...
Formats for binary-parser library.
[ "Formats", "for", "binary", "-", "parser", "library", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/generator/sbpg/targets/javascript.py#L120-L153
swift-nav/libsbp
generator/sbpg/targets/javascript.py
js_classnameify
def js_classnameify(s): """ Makes a classname. """ if not '_' in s: return s return ''.join(w[0].upper() + w[1:].lower() for w in s.split('_'))
python
def js_classnameify(s): """ Makes a classname. """ if not '_' in s: return s return ''.join(w[0].upper() + w[1:].lower() for w in s.split('_'))
[ "def", "js_classnameify", "(", "s", ")", ":", "if", "not", "'_'", "in", "s", ":", "return", "s", "return", "''", ".", "join", "(", "w", "[", "0", "]", ".", "upper", "(", ")", "+", "w", "[", "1", ":", "]", ".", "lower", "(", ")", "for", "w",...
Makes a classname.
[ "Makes", "a", "classname", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/generator/sbpg/targets/javascript.py#L156-L162
swift-nav/libsbp
python/sbp/observation.py
MsgEphemerisGPSDepF.from_binary
def from_binary(self, d): """Given a binary payload d, update the appropriate payload fields of the message. """ p = MsgEphemerisGPSDepF._parser.parse(d) for n in self.__class__.__slots__: setattr(self, n, getattr(p, n))
python
def from_binary(self, d): """Given a binary payload d, update the appropriate payload fields of the message. """ p = MsgEphemerisGPSDepF._parser.parse(d) for n in self.__class__.__slots__: setattr(self, n, getattr(p, n))
[ "def", "from_binary", "(", "self", ",", "d", ")", ":", "p", "=", "MsgEphemerisGPSDepF", ".", "_parser", ".", "parse", "(", "d", ")", "for", "n", "in", "self", ".", "__class__", ".", "__slots__", ":", "setattr", "(", "self", ",", "n", ",", "getattr", ...
Given a binary payload d, update the appropriate payload fields of the message.
[ "Given", "a", "binary", "payload", "d", "update", "the", "appropriate", "payload", "fields", "of", "the", "message", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/python/sbp/observation.py#L1715-L1722
swift-nav/libsbp
python/sbp/observation.py
MsgEphemerisGPSDepF.to_binary
def to_binary(self): """Produce a framed/packed SBP message. """ c = containerize(exclude_fields(self)) self.payload = MsgEphemerisGPSDepF._parser.build(c) return self.pack()
python
def to_binary(self): """Produce a framed/packed SBP message. """ c = containerize(exclude_fields(self)) self.payload = MsgEphemerisGPSDepF._parser.build(c) return self.pack()
[ "def", "to_binary", "(", "self", ")", ":", "c", "=", "containerize", "(", "exclude_fields", "(", "self", ")", ")", "self", ".", "payload", "=", "MsgEphemerisGPSDepF", ".", "_parser", ".", "build", "(", "c", ")", "return", "self", ".", "pack", "(", ")" ...
Produce a framed/packed SBP message.
[ "Produce", "a", "framed", "/", "packed", "SBP", "message", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/python/sbp/observation.py#L1724-L1730
swift-nav/libsbp
python/sbp/observation.py
MsgEphemerisGPSDepF.into_buffer
def into_buffer(self, buf, offset): """Produce a framed/packed SBP message into the provided buffer and offset. """ self.payload = containerize(exclude_fields(self)) self.parser = MsgEphemerisGPSDepF._parser self.stream_payload.reset(buf, offset) return self.pack_into(buf, offset, self._build_p...
python
def into_buffer(self, buf, offset): """Produce a framed/packed SBP message into the provided buffer and offset. """ self.payload = containerize(exclude_fields(self)) self.parser = MsgEphemerisGPSDepF._parser self.stream_payload.reset(buf, offset) return self.pack_into(buf, offset, self._build_p...
[ "def", "into_buffer", "(", "self", ",", "buf", ",", "offset", ")", ":", "self", ".", "payload", "=", "containerize", "(", "exclude_fields", "(", "self", ")", ")", "self", ".", "parser", "=", "MsgEphemerisGPSDepF", ".", "_parser", "self", ".", "stream_paylo...
Produce a framed/packed SBP message into the provided buffer and offset.
[ "Produce", "a", "framed", "/", "packed", "SBP", "message", "into", "the", "provided", "buffer", "and", "offset", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/python/sbp/observation.py#L1732-L1739
swift-nav/libsbp
python/sbp/client/framer.py
Framer._readall
def _readall(self, size): """ Read until all bytes are collected. Parameters ---------- size : int Number of bytes to read. """ data = b"" while len(data) < size: d = self._read(size - len(data)) if self._broken: ...
python
def _readall(self, size): """ Read until all bytes are collected. Parameters ---------- size : int Number of bytes to read. """ data = b"" while len(data) < size: d = self._read(size - len(data)) if self._broken: ...
[ "def", "_readall", "(", "self", ",", "size", ")", ":", "data", "=", "b\"\"", "while", "len", "(", "data", ")", "<", "size", ":", "d", "=", "self", ".", "_read", "(", "size", "-", "len", "(", "data", ")", ")", "if", "self", ".", "_broken", ":", ...
Read until all bytes are collected. Parameters ---------- size : int Number of bytes to read.
[ "Read", "until", "all", "bytes", "are", "collected", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/python/sbp/client/framer.py#L94-L115
swift-nav/libsbp
python/sbp/client/framer.py
Framer._receive
def _receive(self): """ Read and build SBP message. """ # preamble - not readall(1) to allow breaking before messages, # empty input preamble = self._read(1) if not preamble: return None elif ord(preamble) != SBP_PREAMBLE: if self._...
python
def _receive(self): """ Read and build SBP message. """ # preamble - not readall(1) to allow breaking before messages, # empty input preamble = self._read(1) if not preamble: return None elif ord(preamble) != SBP_PREAMBLE: if self._...
[ "def", "_receive", "(", "self", ")", ":", "# preamble - not readall(1) to allow breaking before messages,", "# empty input", "preamble", "=", "self", ".", "_read", "(", "1", ")", "if", "not", "preamble", ":", "return", "None", "elif", "ord", "(", "preamble", ")", ...
Read and build SBP message.
[ "Read", "and", "build", "SBP", "message", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/python/sbp/client/framer.py#L117-L149
swift-nav/libsbp
python/sbp/table.py
dispatch
def dispatch(msg, table=_SBP_TABLE): """ Dispatch an SBP message type based on its `msg_type` and parse its payload. Parameters ---------- driver : :class:`SBP` A parsed SBP object. table : dict Any table mapping unique SBP message type IDs to SBP message constructors. Returns ----------...
python
def dispatch(msg, table=_SBP_TABLE): """ Dispatch an SBP message type based on its `msg_type` and parse its payload. Parameters ---------- driver : :class:`SBP` A parsed SBP object. table : dict Any table mapping unique SBP message type IDs to SBP message constructors. Returns ----------...
[ "def", "dispatch", "(", "msg", ",", "table", "=", "_SBP_TABLE", ")", ":", "try", ":", "return", "table", "[", "msg", ".", "msg_type", "]", "(", "msg", ")", "except", "KeyError", ":", "warn", "=", "\"No message found for msg_type id %d for msg %s.\"", "%", "(...
Dispatch an SBP message type based on its `msg_type` and parse its payload. Parameters ---------- driver : :class:`SBP` A parsed SBP object. table : dict Any table mapping unique SBP message type IDs to SBP message constructors. Returns ---------- SBP message with a parsed payload.
[ "Dispatch", "an", "SBP", "message", "type", "based", "on", "its", "msg_type", "and", "parse", "its", "payload", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/python/sbp/table.py#L70-L98
swift-nav/libsbp
python/sbp/client/handler.py
Handler._recv_thread
def _recv_thread(self): """ Internal thread to iterate over source messages and dispatch callbacks. """ for msg, metadata in self._source: if msg.msg_type: self._call(msg, **metadata) # Break any upstream iterators for sink in self._sinks: ...
python
def _recv_thread(self): """ Internal thread to iterate over source messages and dispatch callbacks. """ for msg, metadata in self._source: if msg.msg_type: self._call(msg, **metadata) # Break any upstream iterators for sink in self._sinks: ...
[ "def", "_recv_thread", "(", "self", ")", ":", "for", "msg", ",", "metadata", "in", "self", ".", "_source", ":", "if", "msg", ".", "msg_type", ":", "self", ".", "_call", "(", "msg", ",", "*", "*", "metadata", ")", "# Break any upstream iterators", "for", ...
Internal thread to iterate over source messages and dispatch callbacks.
[ "Internal", "thread", "to", "iterate", "over", "source", "messages", "and", "dispatch", "callbacks", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/python/sbp/client/handler.py#L52-L64
swift-nav/libsbp
python/sbp/client/handler.py
Handler.filter
def filter(self, msg_type=None, maxsize=0): """ Get a filtered iterator of messages for synchronous, blocking use in another thread. """ if self._dead: return iter(()) iterator = Handler._SBPQueueIterator(maxsize) # We use a weakref so that the iterato...
python
def filter(self, msg_type=None, maxsize=0): """ Get a filtered iterator of messages for synchronous, blocking use in another thread. """ if self._dead: return iter(()) iterator = Handler._SBPQueueIterator(maxsize) # We use a weakref so that the iterato...
[ "def", "filter", "(", "self", ",", "msg_type", "=", "None", ",", "maxsize", "=", "0", ")", ":", "if", "self", ".", "_dead", ":", "return", "iter", "(", "(", ")", ")", "iterator", "=", "Handler", ".", "_SBPQueueIterator", "(", "maxsize", ")", "# We us...
Get a filtered iterator of messages for synchronous, blocking use in another thread.
[ "Get", "a", "filtered", "iterator", "of", "messages", "for", "synchronous", "blocking", "use", "in", "another", "thread", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/python/sbp/client/handler.py#L79-L100
swift-nav/libsbp
python/sbp/client/handler.py
Handler.add_callback
def add_callback(self, callback, msg_type=None): """ Add per message type or global callback. Parameters ---------- callback : fn Callback function msg_type : int | iterable Message type to register callback against. Default `None` means global callba...
python
def add_callback(self, callback, msg_type=None): """ Add per message type or global callback. Parameters ---------- callback : fn Callback function msg_type : int | iterable Message type to register callback against. Default `None` means global callba...
[ "def", "add_callback", "(", "self", ",", "callback", ",", "msg_type", "=", "None", ")", ":", "cb_keys", "=", "self", ".", "_to_iter", "(", "msg_type", ")", "if", "cb_keys", "is", "not", "None", ":", "for", "msg_type_", "in", "cb_keys", ":", "self", "."...
Add per message type or global callback. Parameters ---------- callback : fn Callback function msg_type : int | iterable Message type to register callback against. Default `None` means global callback. Iterable type adds the callback to all the message type...
[ "Add", "per", "message", "type", "or", "global", "callback", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/python/sbp/client/handler.py#L115-L132
swift-nav/libsbp
python/sbp/client/handler.py
Handler.remove_callback
def remove_callback(self, callback, msg_type=None): """ Remove per message type of global callback. Parameters ---------- callback : fn Callback function msg_type : int | iterable Message type to remove callback from. Default `None` means global callb...
python
def remove_callback(self, callback, msg_type=None): """ Remove per message type of global callback. Parameters ---------- callback : fn Callback function msg_type : int | iterable Message type to remove callback from. Default `None` means global callb...
[ "def", "remove_callback", "(", "self", ",", "callback", ",", "msg_type", "=", "None", ")", ":", "if", "msg_type", "is", "None", ":", "msg_type", "=", "self", ".", "_callbacks", ".", "keys", "(", ")", "cb_keys", "=", "self", ".", "_to_iter", "(", "msg_t...
Remove per message type of global callback. Parameters ---------- callback : fn Callback function msg_type : int | iterable Message type to remove callback from. Default `None` means global callback. Iterable type removes the callback from all the message t...
[ "Remove", "per", "message", "type", "of", "global", "callback", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/python/sbp/client/handler.py#L134-L156
swift-nav/libsbp
python/sbp/client/handler.py
Handler._gc_dead_sinks
def _gc_dead_sinks(self): """ Remove any dead weakrefs. """ deadsinks = [] for i in self._sinks: if i() is None: deadsinks.append(i) for i in deadsinks: self._sinks.remove(i)
python
def _gc_dead_sinks(self): """ Remove any dead weakrefs. """ deadsinks = [] for i in self._sinks: if i() is None: deadsinks.append(i) for i in deadsinks: self._sinks.remove(i)
[ "def", "_gc_dead_sinks", "(", "self", ")", ":", "deadsinks", "=", "[", "]", "for", "i", "in", "self", ".", "_sinks", ":", "if", "i", "(", ")", "is", "None", ":", "deadsinks", ".", "append", "(", "i", ")", "for", "i", "in", "deadsinks", ":", "self...
Remove any dead weakrefs.
[ "Remove", "any", "dead", "weakrefs", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/python/sbp/client/handler.py#L158-L167
swift-nav/libsbp
python/sbp/client/handler.py
Handler._call
def _call(self, msg, **metadata): """ Process message with all callbacks (global and per message type). """ if msg.msg_type: for callback in self._get_callbacks(msg.msg_type): try: callback(msg, **metadata) except Handler._D...
python
def _call(self, msg, **metadata): """ Process message with all callbacks (global and per message type). """ if msg.msg_type: for callback in self._get_callbacks(msg.msg_type): try: callback(msg, **metadata) except Handler._D...
[ "def", "_call", "(", "self", ",", "msg", ",", "*", "*", "metadata", ")", ":", "if", "msg", ".", "msg_type", ":", "for", "callback", "in", "self", ".", "_get_callbacks", "(", "msg", ".", "msg_type", ")", ":", "try", ":", "callback", "(", "msg", ",",...
Process message with all callbacks (global and per message type).
[ "Process", "message", "with", "all", "callbacks", "(", "global", "and", "per", "message", "type", ")", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/python/sbp/client/handler.py#L180-L197
swift-nav/libsbp
python/sbp/client/handler.py
Handler.wait
def wait(self, msg_type, timeout=1.0): """ Wait for a SBP message. Parameters ---------- msg_type : int SBP message type. timeout : float Waiting period """ event = threading.Event() payload = {'data': None} def cb(sbp...
python
def wait(self, msg_type, timeout=1.0): """ Wait for a SBP message. Parameters ---------- msg_type : int SBP message type. timeout : float Waiting period """ event = threading.Event() payload = {'data': None} def cb(sbp...
[ "def", "wait", "(", "self", ",", "msg_type", ",", "timeout", "=", "1.0", ")", ":", "event", "=", "threading", ".", "Event", "(", ")", "payload", "=", "{", "'data'", ":", "None", "}", "def", "cb", "(", "sbp_msg", ",", "*", "*", "metadata", ")", ":...
Wait for a SBP message. Parameters ---------- msg_type : int SBP message type. timeout : float Waiting period
[ "Wait", "for", "a", "SBP", "message", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/python/sbp/client/handler.py#L221-L242
swift-nav/libsbp
python/sbp/client/handler.py
Handler.wait_callback
def wait_callback(self, callback, msg_type=None, timeout=1.0): """ Wait for a SBP message with a callback. Parameters ---------- callback : fn Callback function msg_type : int | iterable Message type to register callback against. Default `None` means ...
python
def wait_callback(self, callback, msg_type=None, timeout=1.0): """ Wait for a SBP message with a callback. Parameters ---------- callback : fn Callback function msg_type : int | iterable Message type to register callback against. Default `None` means ...
[ "def", "wait_callback", "(", "self", ",", "callback", ",", "msg_type", "=", "None", ",", "timeout", "=", "1.0", ")", ":", "event", "=", "threading", ".", "Event", "(", ")", "def", "cb", "(", "msg", ",", "*", "*", "metadata", ")", ":", "callback", "...
Wait for a SBP message with a callback. Parameters ---------- callback : fn Callback function msg_type : int | iterable Message type to register callback against. Default `None` means global callback. Iterable type adds the callback to all the message types...
[ "Wait", "for", "a", "SBP", "message", "with", "a", "callback", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/python/sbp/client/handler.py#L244-L266
swift-nav/libsbp
python/sbp/client/drivers/cdc_driver.py
CdcDriver.read
def read(self, size): """ Read wrapper. Parameters ---------- size : int Number of bytes to read. """ try: return_val = self.handle.read(size) if return_val == '': print() print("Piksi disconnected...
python
def read(self, size): """ Read wrapper. Parameters ---------- size : int Number of bytes to read. """ try: return_val = self.handle.read(size) if return_val == '': print() print("Piksi disconnected...
[ "def", "read", "(", "self", ",", "size", ")", ":", "try", ":", "return_val", "=", "self", ".", "handle", ".", "read", "(", "size", ")", "if", "return_val", "==", "''", ":", "print", "(", ")", "print", "(", "\"Piksi disconnected\"", ")", "print", "(",...
Read wrapper. Parameters ---------- size : int Number of bytes to read.
[ "Read", "wrapper", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/python/sbp/client/drivers/cdc_driver.py#L27-L48
swift-nav/libsbp
python/sbp/client/drivers/cdc_driver.py
CdcDriver.write
def write(self, s): """ Write wrapper. Parameters ---------- s : bytes Bytes to write """ try: return self.handle.write(s) except OSError: print() print("Piksi disconnected") print() ra...
python
def write(self, s): """ Write wrapper. Parameters ---------- s : bytes Bytes to write """ try: return self.handle.write(s) except OSError: print() print("Piksi disconnected") print() ra...
[ "def", "write", "(", "self", ",", "s", ")", ":", "try", ":", "return", "self", ".", "handle", ".", "write", "(", "s", ")", "except", "OSError", ":", "print", "(", ")", "print", "(", "\"Piksi disconnected\"", ")", "print", "(", ")", "raise", "IOError"...
Write wrapper. Parameters ---------- s : bytes Bytes to write
[ "Write", "wrapper", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/python/sbp/client/drivers/cdc_driver.py#L50-L65
swift-nav/libsbp
generator/sbpg/utils.py
fmt_repr
def fmt_repr(obj): """ Return pretty printed string representation of an object. """ items = {k: v for k, v in list(obj.__dict__.items())} return "<%s: {%s}>" % (obj.__class__.__name__, pprint.pformat(items, width=1))
python
def fmt_repr(obj): """ Return pretty printed string representation of an object. """ items = {k: v for k, v in list(obj.__dict__.items())} return "<%s: {%s}>" % (obj.__class__.__name__, pprint.pformat(items, width=1))
[ "def", "fmt_repr", "(", "obj", ")", ":", "items", "=", "{", "k", ":", "v", "for", "k", ",", "v", "in", "list", "(", "obj", ".", "__dict__", ".", "items", "(", ")", ")", "}", "return", "\"<%s: {%s}>\"", "%", "(", "obj", ".", "__class__", ".", "_...
Return pretty printed string representation of an object.
[ "Return", "pretty", "printed", "string", "representation", "of", "an", "object", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/generator/sbpg/utils.py#L14-L20
swift-nav/libsbp
python/sbp/client/util/settingmonitor.py
SettingMonitor.capture_setting
def capture_setting(self, sbp_msg, **metadata): """Callback to extract and store setting values from SBP_MSG_SETTINGS_READ_RESP Messages of any type other than SBP_MSG_SETTINGS_READ_RESP are ignored """ if sbp_msg.msg_type == SBP_MSG_SETTINGS_READ_RESP: section, sett...
python
def capture_setting(self, sbp_msg, **metadata): """Callback to extract and store setting values from SBP_MSG_SETTINGS_READ_RESP Messages of any type other than SBP_MSG_SETTINGS_READ_RESP are ignored """ if sbp_msg.msg_type == SBP_MSG_SETTINGS_READ_RESP: section, sett...
[ "def", "capture_setting", "(", "self", ",", "sbp_msg", ",", "*", "*", "metadata", ")", ":", "if", "sbp_msg", ".", "msg_type", "==", "SBP_MSG_SETTINGS_READ_RESP", ":", "section", ",", "setting", ",", "value", "=", "sbp_msg", ".", "payload", ".", "split", "(...
Callback to extract and store setting values from SBP_MSG_SETTINGS_READ_RESP Messages of any type other than SBP_MSG_SETTINGS_READ_RESP are ignored
[ "Callback", "to", "extract", "and", "store", "setting", "values", "from", "SBP_MSG_SETTINGS_READ_RESP" ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/python/sbp/client/util/settingmonitor.py#L32-L40
swift-nav/libsbp
python/sbp/client/util/settingmonitor.py
SettingMonitor.wait_for_setting_value
def wait_for_setting_value(self, section, setting, value, wait_time=5.0): """Function to wait wait_time seconds to see a SBP_MSG_SETTINGS_READ_RESP message with a user-specified value """ expire = time.time() + wait_time ok = False while not ok and time.time() < expire: ...
python
def wait_for_setting_value(self, section, setting, value, wait_time=5.0): """Function to wait wait_time seconds to see a SBP_MSG_SETTINGS_READ_RESP message with a user-specified value """ expire = time.time() + wait_time ok = False while not ok and time.time() < expire: ...
[ "def", "wait_for_setting_value", "(", "self", ",", "section", ",", "setting", ",", "value", ",", "wait_time", "=", "5.0", ")", ":", "expire", "=", "time", ".", "time", "(", ")", "+", "wait_time", "ok", "=", "False", "while", "not", "ok", "and", "time",...
Function to wait wait_time seconds to see a SBP_MSG_SETTINGS_READ_RESP message with a user-specified value
[ "Function", "to", "wait", "wait_time", "seconds", "to", "see", "a", "SBP_MSG_SETTINGS_READ_RESP", "message", "with", "a", "user", "-", "specified", "value" ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/python/sbp/client/util/settingmonitor.py#L42-L55
swift-nav/libsbp
python/sbp/client/util/settingmonitor.py
SettingMonitor.clear
def clear(self, section=None, setting=None, value=None): """Clear settings""" match = [all((section is None or x_y_z[0] == section, setting is None or x_y_z[1] == setting, value is None or x_y_z[2] == value)) for x_y_z in self.settings] keep = [settin...
python
def clear(self, section=None, setting=None, value=None): """Clear settings""" match = [all((section is None or x_y_z[0] == section, setting is None or x_y_z[1] == setting, value is None or x_y_z[2] == value)) for x_y_z in self.settings] keep = [settin...
[ "def", "clear", "(", "self", ",", "section", "=", "None", ",", "setting", "=", "None", ",", "value", "=", "None", ")", ":", "match", "=", "[", "all", "(", "(", "section", "is", "None", "or", "x_y_z", "[", "0", "]", "==", "section", ",", "setting"...
Clear settings
[ "Clear", "settings" ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/python/sbp/client/util/settingmonitor.py#L57-L65
swift-nav/libsbp
generator/sbpg/targets/python.py
construct_format
def construct_format(f, type_map=CONSTRUCT_CODE): """ Formats for Construct. """ formatted = "" if type_map.get(f.type_id, None): return "'{identifier}' / {type_id}".format(type_id=type_map.get(f.type_id), identifier=f.identifier) elif f.type_id == 'string' a...
python
def construct_format(f, type_map=CONSTRUCT_CODE): """ Formats for Construct. """ formatted = "" if type_map.get(f.type_id, None): return "'{identifier}' / {type_id}".format(type_id=type_map.get(f.type_id), identifier=f.identifier) elif f.type_id == 'string' a...
[ "def", "construct_format", "(", "f", ",", "type_map", "=", "CONSTRUCT_CODE", ")", ":", "formatted", "=", "\"\"", "if", "type_map", ".", "get", "(", "f", ".", "type_id", ",", "None", ")", ":", "return", "\"'{identifier}' / {type_id}\"", ".", "format", "(", ...
Formats for Construct.
[ "Formats", "for", "Construct", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/generator/sbpg/targets/python.py#L57-L83
swift-nav/libsbp
generator/sbpg/targets/python.py
render_source
def render_source(output_dir, package_spec, jenv=JENV): """ Render and output """ path, name = package_spec.filepath directory = output_dir destination_filename = "%s/%s.py" % (directory, name) py_template = jenv.get_template(TEMPLATE_NAME) module_path = ".".join(package_spec.identifier.split(".")[1:-1]...
python
def render_source(output_dir, package_spec, jenv=JENV): """ Render and output """ path, name = package_spec.filepath directory = output_dir destination_filename = "%s/%s.py" % (directory, name) py_template = jenv.get_template(TEMPLATE_NAME) module_path = ".".join(package_spec.identifier.split(".")[1:-1]...
[ "def", "render_source", "(", "output_dir", ",", "package_spec", ",", "jenv", "=", "JENV", ")", ":", "path", ",", "name", "=", "package_spec", ".", "filepath", "directory", "=", "output_dir", "destination_filename", "=", "\"%s/%s.py\"", "%", "(", "directory", "...
Render and output
[ "Render", "and", "output" ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/generator/sbpg/targets/python.py#L105-L123
swift-nav/libsbp
python/sbp/client/drivers/network_drivers.py
TCPDriver.read
def read(self, size): """ Read wrapper. Parameters ---------- size : int Number of bytes to read """ data = None while True: try: data = self.handle.recv(size) except socket.timeout as socket_error: ...
python
def read(self, size): """ Read wrapper. Parameters ---------- size : int Number of bytes to read """ data = None while True: try: data = self.handle.recv(size) except socket.timeout as socket_error: ...
[ "def", "read", "(", "self", ",", "size", ")", ":", "data", "=", "None", "while", "True", ":", "try", ":", "data", "=", "self", ".", "handle", ".", "recv", "(", "size", ")", "except", "socket", ".", "timeout", "as", "socket_error", ":", "self", ".",...
Read wrapper. Parameters ---------- size : int Number of bytes to read
[ "Read", "wrapper", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/python/sbp/client/drivers/network_drivers.py#L81-L104
swift-nav/libsbp
python/sbp/client/drivers/network_drivers.py
TCPDriver.write
def write(self, s): """ Write wrapper. Parameters ---------- s : bytes Bytes to write """ try: self._write_lock.acquire() self.handle.sendall(s) except socket.timeout: self._connect() except socket.err...
python
def write(self, s): """ Write wrapper. Parameters ---------- s : bytes Bytes to write """ try: self._write_lock.acquire() self.handle.sendall(s) except socket.timeout: self._connect() except socket.err...
[ "def", "write", "(", "self", ",", "s", ")", ":", "try", ":", "self", ".", "_write_lock", ".", "acquire", "(", ")", "self", ".", "handle", ".", "sendall", "(", "s", ")", "except", "socket", ".", "timeout", ":", "self", ".", "_connect", "(", ")", "...
Write wrapper. Parameters ---------- s : bytes Bytes to write
[ "Write", "wrapper", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/python/sbp/client/drivers/network_drivers.py#L109-L126
swift-nav/libsbp
python/sbp/utils.py
exclude_fields
def exclude_fields(obj, exclude=EXCLUDE): """ Return dict of object without parent attrs. """ return dict([(k, getattr(obj, k)) for k in obj.__slots__ if k not in exclude])
python
def exclude_fields(obj, exclude=EXCLUDE): """ Return dict of object without parent attrs. """ return dict([(k, getattr(obj, k)) for k in obj.__slots__ if k not in exclude])
[ "def", "exclude_fields", "(", "obj", ",", "exclude", "=", "EXCLUDE", ")", ":", "return", "dict", "(", "[", "(", "k", ",", "getattr", "(", "obj", ",", "k", ")", ")", "for", "k", "in", "obj", ".", "__slots__", "if", "k", "not", "in", "exclude", "]"...
Return dict of object without parent attrs.
[ "Return", "dict", "of", "object", "without", "parent", "attrs", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/python/sbp/utils.py#L21-L25
swift-nav/libsbp
python/sbp/utils.py
walk_json_dict
def walk_json_dict(coll): """ Flatten a parsed SBP object into a dicts and lists, which are compatible for JSON output. Parameters ---------- coll : dict """ if isinstance(coll, dict): return dict((k, walk_json_dict(v)) for (k, v) in iter(coll.items())) elif isinstance(coll, bytes): return c...
python
def walk_json_dict(coll): """ Flatten a parsed SBP object into a dicts and lists, which are compatible for JSON output. Parameters ---------- coll : dict """ if isinstance(coll, dict): return dict((k, walk_json_dict(v)) for (k, v) in iter(coll.items())) elif isinstance(coll, bytes): return c...
[ "def", "walk_json_dict", "(", "coll", ")", ":", "if", "isinstance", "(", "coll", ",", "dict", ")", ":", "return", "dict", "(", "(", "k", ",", "walk_json_dict", "(", "v", ")", ")", "for", "(", "k", ",", "v", ")", "in", "iter", "(", "coll", ".", ...
Flatten a parsed SBP object into a dicts and lists, which are compatible for JSON output. Parameters ---------- coll : dict
[ "Flatten", "a", "parsed", "SBP", "object", "into", "a", "dicts", "and", "lists", "which", "are", "compatible", "for", "JSON", "output", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/python/sbp/utils.py#L28-L45
swift-nav/libsbp
python/sbp/utils.py
containerize
def containerize(coll): """Walk attribute fields passed from an SBP message and convert to Containers where appropriate. Needed for Construct proper serialization. Parameters ---------- coll : dict """ if isinstance(coll, Container): [setattr(coll, k, containerize(v)) for (k, v) in coll.items()] ...
python
def containerize(coll): """Walk attribute fields passed from an SBP message and convert to Containers where appropriate. Needed for Construct proper serialization. Parameters ---------- coll : dict """ if isinstance(coll, Container): [setattr(coll, k, containerize(v)) for (k, v) in coll.items()] ...
[ "def", "containerize", "(", "coll", ")", ":", "if", "isinstance", "(", "coll", ",", "Container", ")", ":", "[", "setattr", "(", "coll", ",", "k", ",", "containerize", "(", "v", ")", ")", "for", "(", "k", ",", "v", ")", "in", "coll", ".", "items",...
Walk attribute fields passed from an SBP message and convert to Containers where appropriate. Needed for Construct proper serialization. Parameters ---------- coll : dict
[ "Walk", "attribute", "fields", "passed", "from", "an", "SBP", "message", "and", "convert", "to", "Containers", "where", "appropriate", ".", "Needed", "for", "Construct", "proper", "serialization", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/python/sbp/utils.py#L48-L69
swift-nav/libsbp
python/sbp/utils.py
fmt_repr
def fmt_repr(obj): """Print a orphaned string representation of an object without the clutter of its parent object. """ items = ["%s = %r" % (k, v) for k, v in list(exclude_fields(obj).items())] return "<%s: {%s}>" % (obj.__class__.__name__, ', '.join(items))
python
def fmt_repr(obj): """Print a orphaned string representation of an object without the clutter of its parent object. """ items = ["%s = %r" % (k, v) for k, v in list(exclude_fields(obj).items())] return "<%s: {%s}>" % (obj.__class__.__name__, ', '.join(items))
[ "def", "fmt_repr", "(", "obj", ")", ":", "items", "=", "[", "\"%s = %r\"", "%", "(", "k", ",", "v", ")", "for", "k", ",", "v", "in", "list", "(", "exclude_fields", "(", "obj", ")", ".", "items", "(", ")", ")", "]", "return", "\"<%s: {%s}>\"", "%"...
Print a orphaned string representation of an object without the clutter of its parent object.
[ "Print", "a", "orphaned", "string", "representation", "of", "an", "object", "without", "the", "clutter", "of", "its", "parent", "object", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/python/sbp/utils.py#L72-L78
swift-nav/libsbp
generator/sbpg/specs/yaml2.py
read_spec
def read_spec(filename, verbose=False): """ Read an SBP specification. Parameters ---------- filename : str Local filename for specification. verbose : bool Print out some debugging info Returns ---------- Raises ---------- Exception On empty file. yaml.YAMLError On Yaml parsi...
python
def read_spec(filename, verbose=False): """ Read an SBP specification. Parameters ---------- filename : str Local filename for specification. verbose : bool Print out some debugging info Returns ---------- Raises ---------- Exception On empty file. yaml.YAMLError On Yaml parsi...
[ "def", "read_spec", "(", "filename", ",", "verbose", "=", "False", ")", ":", "contents", "=", "None", "with", "open", "(", "filename", ",", "'r'", ")", "as", "f", ":", "contents", "=", "yaml", ".", "load", "(", "f", ")", "if", "contents", "is", "No...
Read an SBP specification. Parameters ---------- filename : str Local filename for specification. verbose : bool Print out some debugging info Returns ---------- Raises ---------- Exception On empty file. yaml.YAMLError On Yaml parsing error voluptuous.Invalid On invalid SBP...
[ "Read", "an", "SBP", "specification", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/generator/sbpg/specs/yaml2.py#L32-L65
swift-nav/libsbp
generator/sbpg/specs/yaml2.py
get_files
def get_files(input_file): """ Initializes an index of files to generate, returns the base directory and index. """ file_index = {} base_dir = None if os.path.isfile(input_file): file_index[input_file] = None base_dir = os.path.dirname(input_file) elif os.path.isdir(input_file): base_dir = ...
python
def get_files(input_file): """ Initializes an index of files to generate, returns the base directory and index. """ file_index = {} base_dir = None if os.path.isfile(input_file): file_index[input_file] = None base_dir = os.path.dirname(input_file) elif os.path.isdir(input_file): base_dir = ...
[ "def", "get_files", "(", "input_file", ")", ":", "file_index", "=", "{", "}", "base_dir", "=", "None", "if", "os", ".", "path", ".", "isfile", "(", "input_file", ")", ":", "file_index", "[", "input_file", "]", "=", "None", "base_dir", "=", "os", ".", ...
Initializes an index of files to generate, returns the base directory and index.
[ "Initializes", "an", "index", "of", "files", "to", "generate", "returns", "the", "base", "directory", "and", "index", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/generator/sbpg/specs/yaml2.py#L102-L122
swift-nav/libsbp
generator/sbpg/specs/yaml2.py
resolve_deps
def resolve_deps(base_dir, file_index): """ Given a base directory and an initial set of files, retrieves dependencies and adds them to the file_index. """ def flatten(tree, index = {}): for include in tree.get('include', []): fname = base_dir + "/" + include assert os.path.exists(fname), "Fi...
python
def resolve_deps(base_dir, file_index): """ Given a base directory and an initial set of files, retrieves dependencies and adds them to the file_index. """ def flatten(tree, index = {}): for include in tree.get('include', []): fname = base_dir + "/" + include assert os.path.exists(fname), "Fi...
[ "def", "resolve_deps", "(", "base_dir", ",", "file_index", ")", ":", "def", "flatten", "(", "tree", ",", "index", "=", "{", "}", ")", ":", "for", "include", "in", "tree", ".", "get", "(", "'include'", ",", "[", "]", ")", ":", "fname", "=", "base_di...
Given a base directory and an initial set of files, retrieves dependencies and adds them to the file_index.
[ "Given", "a", "base", "directory", "and", "an", "initial", "set", "of", "files", "retrieves", "dependencies", "and", "adds", "them", "to", "the", "file_index", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/generator/sbpg/specs/yaml2.py#L146-L163
swift-nav/libsbp
generator/sbpg/specs/yaml2.py
mk_package
def mk_package(contents): """Instantiates a package specification from a parsed "AST" of a package. Parameters ---------- contents : dict Returns ---------- PackageSpecification """ package = contents.get('package', None) description = contents.get('description', None) include = contents.get(...
python
def mk_package(contents): """Instantiates a package specification from a parsed "AST" of a package. Parameters ---------- contents : dict Returns ---------- PackageSpecification """ package = contents.get('package', None) description = contents.get('description', None) include = contents.get(...
[ "def", "mk_package", "(", "contents", ")", ":", "package", "=", "contents", ".", "get", "(", "'package'", ",", "None", ")", "description", "=", "contents", ".", "get", "(", "'description'", ",", "None", ")", "include", "=", "contents", ".", "get", "(", ...
Instantiates a package specification from a parsed "AST" of a package. Parameters ---------- contents : dict Returns ---------- PackageSpecification
[ "Instantiates", "a", "package", "specification", "from", "a", "parsed", "AST", "of", "a", "package", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/generator/sbpg/specs/yaml2.py#L216-L240
swift-nav/libsbp
generator/sbpg/specs/yaml2.py
mk_definition
def mk_definition(defn): """Instantiates a struct or SBP message specification from a parsed "AST" of a struct or message. Parameters ---------- defn : dict Returns ---------- A Definition or a specialization of a definition, like a Struct """ assert len(defn) == 1 identifier, contents = next(i...
python
def mk_definition(defn): """Instantiates a struct or SBP message specification from a parsed "AST" of a struct or message. Parameters ---------- defn : dict Returns ---------- A Definition or a specialization of a definition, like a Struct """ assert len(defn) == 1 identifier, contents = next(i...
[ "def", "mk_definition", "(", "defn", ")", ":", "assert", "len", "(", "defn", ")", "==", "1", "identifier", ",", "contents", "=", "next", "(", "iter", "(", "defn", ".", "items", "(", ")", ")", ")", "fs", "=", "[", "mk_field", "(", "f", ")", "for",...
Instantiates a struct or SBP message specification from a parsed "AST" of a struct or message. Parameters ---------- defn : dict Returns ---------- A Definition or a specialization of a definition, like a Struct
[ "Instantiates", "a", "struct", "or", "SBP", "message", "specification", "from", "a", "parsed", "AST", "of", "a", "struct", "or", "message", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/generator/sbpg/specs/yaml2.py#L241-L263
swift-nav/libsbp
generator/sbpg/specs/yaml2.py
mk_field
def mk_field(field): """Instantiates a field specification from a parsed "AST" of a field. Parameters ---------- field : dict Returns ---------- A Field or a specialization of a field, like a bitfield. """ assert len(field) == 1 identifier, contents = next(iter(field.items())) contents = dict...
python
def mk_field(field): """Instantiates a field specification from a parsed "AST" of a field. Parameters ---------- field : dict Returns ---------- A Field or a specialization of a field, like a bitfield. """ assert len(field) == 1 identifier, contents = next(iter(field.items())) contents = dict...
[ "def", "mk_field", "(", "field", ")", ":", "assert", "len", "(", "field", ")", "==", "1", "identifier", ",", "contents", "=", "next", "(", "iter", "(", "field", ".", "items", "(", ")", ")", ")", "contents", "=", "dict", "(", "list", "(", "{", "'u...
Instantiates a field specification from a parsed "AST" of a field. Parameters ---------- field : dict Returns ---------- A Field or a specialization of a field, like a bitfield.
[ "Instantiates", "a", "field", "specification", "from", "a", "parsed", "AST", "of", "a", "field", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/generator/sbpg/specs/yaml2.py#L265-L283
swift-nav/libsbp
generator/sbpg/targets/haskell.py
to_global
def to_global(s): """ Format a global variable name. """ if s.startswith('GPSTime'): s = 'Gps' + s[3:] if '_' in s: s = "".join([i.capitalize() for i in s.split("_")]) return s[0].lower() + s[1:]
python
def to_global(s): """ Format a global variable name. """ if s.startswith('GPSTime'): s = 'Gps' + s[3:] if '_' in s: s = "".join([i.capitalize() for i in s.split("_")]) return s[0].lower() + s[1:]
[ "def", "to_global", "(", "s", ")", ":", "if", "s", ".", "startswith", "(", "'GPSTime'", ")", ":", "s", "=", "'Gps'", "+", "s", "[", "3", ":", "]", "if", "'_'", "in", "s", ":", "s", "=", "\"\"", ".", "join", "(", "[", "i", ".", "capitalize", ...
Format a global variable name.
[ "Format", "a", "global", "variable", "name", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/generator/sbpg/targets/haskell.py#L73-L82
swift-nav/libsbp
generator/sbpg/targets/haskell.py
to_data
def to_data(s): """ Format a data variable name. """ if s.startswith('GPSTime'): s = 'Gps' + s[3:] if '_' in s: return "".join([i.capitalize() for i in s.split("_")]) return s
python
def to_data(s): """ Format a data variable name. """ if s.startswith('GPSTime'): s = 'Gps' + s[3:] if '_' in s: return "".join([i.capitalize() for i in s.split("_")]) return s
[ "def", "to_data", "(", "s", ")", ":", "if", "s", ".", "startswith", "(", "'GPSTime'", ")", ":", "s", "=", "'Gps'", "+", "s", "[", "3", ":", "]", "if", "'_'", "in", "s", ":", "return", "\"\"", ".", "join", "(", "[", "i", ".", "capitalize", "("...
Format a data variable name.
[ "Format", "a", "data", "variable", "name", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/generator/sbpg/targets/haskell.py#L84-L93
swift-nav/libsbp
generator/sbpg/targets/haskell.py
to_type
def to_type(f, type_map=CONSTRUCT_CODE): """ Format a the proper type. """ name = f.type_id if name.startswith('GPSTime'): name = 'Gps' + name[3:] if type_map.get(name, None): return type_map.get(name, None) elif name == 'array': fill = f.options['fill'].value f_ = copy.copy(f) f_.type...
python
def to_type(f, type_map=CONSTRUCT_CODE): """ Format a the proper type. """ name = f.type_id if name.startswith('GPSTime'): name = 'Gps' + name[3:] if type_map.get(name, None): return type_map.get(name, None) elif name == 'array': fill = f.options['fill'].value f_ = copy.copy(f) f_.type...
[ "def", "to_type", "(", "f", ",", "type_map", "=", "CONSTRUCT_CODE", ")", ":", "name", "=", "f", ".", "type_id", "if", "name", ".", "startswith", "(", "'GPSTime'", ")", ":", "name", "=", "'Gps'", "+", "name", "[", "3", ":", "]", "if", "type_map", "....
Format a the proper type.
[ "Format", "a", "the", "proper", "type", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/generator/sbpg/targets/haskell.py#L95-L109
swift-nav/libsbp
generator/sbpg/targets/haskell.py
render_source
def render_source(output_dir, package_spec): """ Render and output to a directory given a package specification. """ path, name = package_spec.filepath module_prefix = "SwiftNav.SBP" module_name = camel_case(name) full_module_name = ".".join([module_prefix, module_name]) destination_filename = "%s/src/S...
python
def render_source(output_dir, package_spec): """ Render and output to a directory given a package specification. """ path, name = package_spec.filepath module_prefix = "SwiftNav.SBP" module_name = camel_case(name) full_module_name = ".".join([module_prefix, module_name]) destination_filename = "%s/src/S...
[ "def", "render_source", "(", "output_dir", ",", "package_spec", ")", ":", "path", ",", "name", "=", "package_spec", ".", "filepath", "module_prefix", "=", "\"SwiftNav.SBP\"", "module_name", "=", "camel_case", "(", "name", ")", "full_module_name", "=", "\".\"", "...
Render and output to a directory given a package specification.
[ "Render", "and", "output", "to", "a", "directory", "given", "a", "package", "specification", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/generator/sbpg/targets/haskell.py#L164-L181
swift-nav/libsbp
generator/sbpg/targets/protobuf.py
to_comment
def to_comment(value): """ Builds a comment. """ if value is None: return if len(value.split('\n')) == 1: return "* " + value else: return '\n'.join([' * ' + l for l in value.split('\n')[:-1]])
python
def to_comment(value): """ Builds a comment. """ if value is None: return if len(value.split('\n')) == 1: return "* " + value else: return '\n'.join([' * ' + l for l in value.split('\n')[:-1]])
[ "def", "to_comment", "(", "value", ")", ":", "if", "value", "is", "None", ":", "return", "if", "len", "(", "value", ".", "split", "(", "'\\n'", ")", ")", "==", "1", ":", "return", "\"* \"", "+", "value", "else", ":", "return", "'\\n'", ".", "join",...
Builds a comment.
[ "Builds", "a", "comment", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/generator/sbpg/targets/protobuf.py#L39-L48
swift-nav/libsbp
generator/sbpg/targets/protobuf.py
to_identifier
def to_identifier(s): """ Convert snake_case to camel_case. """ if s.startswith('GPS'): s = 'Gps' + s[3:] return ''.join([i.capitalize() for i in s.split('_')]) if '_' in s else s
python
def to_identifier(s): """ Convert snake_case to camel_case. """ if s.startswith('GPS'): s = 'Gps' + s[3:] return ''.join([i.capitalize() for i in s.split('_')]) if '_' in s else s
[ "def", "to_identifier", "(", "s", ")", ":", "if", "s", ".", "startswith", "(", "'GPS'", ")", ":", "s", "=", "'Gps'", "+", "s", "[", "3", ":", "]", "return", "''", ".", "join", "(", "[", "i", ".", "capitalize", "(", ")", "for", "i", "in", "s",...
Convert snake_case to camel_case.
[ "Convert", "snake_case", "to", "camel_case", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/generator/sbpg/targets/protobuf.py#L50-L56
swift-nav/libsbp
generator/sbpg/targets/protobuf.py
render_source
def render_source(output_dir, package_spec): """ Render and output to a directory given a package specification. """ path, name = package_spec.filepath destination_filename = '%s/%s.proto' % (output_dir, name) pb_template = JENV.get_template(MESSAGES_TEMPLATE_NAME) includes = [include[:-5] i...
python
def render_source(output_dir, package_spec): """ Render and output to a directory given a package specification. """ path, name = package_spec.filepath destination_filename = '%s/%s.proto' % (output_dir, name) pb_template = JENV.get_template(MESSAGES_TEMPLATE_NAME) includes = [include[:-5] i...
[ "def", "render_source", "(", "output_dir", ",", "package_spec", ")", ":", "path", ",", "name", "=", "package_spec", ".", "filepath", "destination_filename", "=", "'%s/%s.proto'", "%", "(", "output_dir", ",", "name", ")", "pb_template", "=", "JENV", ".", "get_t...
Render and output to a directory given a package specification.
[ "Render", "and", "output", "to", "a", "directory", "given", "a", "package", "specification", "." ]
train
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/generator/sbpg/targets/protobuf.py#L81-L98
dnanexus/dx-toolkit
src/python/dxpy/bindings/dxapp_container_functions.py
load_app_resource
def load_app_resource(**kwargs): ''' :param kwargs: keyword args for :func:`~dxpy.bindings.search.find_one_data_object`, with the exception of "project" :raises: :exc:`~dxpy.exceptions.DXError` if "project" is given, if this is called with dxpy.JOB_ID not set, or if "DX_RESOURCES_ID" or "DX_PROJECT_CONTEXT_...
python
def load_app_resource(**kwargs): ''' :param kwargs: keyword args for :func:`~dxpy.bindings.search.find_one_data_object`, with the exception of "project" :raises: :exc:`~dxpy.exceptions.DXError` if "project" is given, if this is called with dxpy.JOB_ID not set, or if "DX_RESOURCES_ID" or "DX_PROJECT_CONTEXT_...
[ "def", "load_app_resource", "(", "*", "*", "kwargs", ")", ":", "if", "'project'", "in", "kwargs", ":", "raise", "DXError", "(", "'Unexpected kwarg: \"project\"'", ")", "if", "dxpy", ".", "JOB_ID", "is", "None", ":", "raise", "DXError", "(", "'Not called by a j...
:param kwargs: keyword args for :func:`~dxpy.bindings.search.find_one_data_object`, with the exception of "project" :raises: :exc:`~dxpy.exceptions.DXError` if "project" is given, if this is called with dxpy.JOB_ID not set, or if "DX_RESOURCES_ID" or "DX_PROJECT_CONTEXT_ID" is not found in the environment variables...
[ ":", "param", "kwargs", ":", "keyword", "args", "for", ":", "func", ":", "~dxpy", ".", "bindings", ".", "search", ".", "find_one_data_object", "with", "the", "exception", "of", "project", ":", "raises", ":", ":", "exc", ":", "~dxpy", ".", "exceptions", "...
train
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/bindings/dxapp_container_functions.py#L34-L62
dnanexus/dx-toolkit
src/python/dxpy/bindings/dxapp_container_functions.py
load_from_cache
def load_from_cache(**kwargs): ''' :param kwargs: keyword args for :func:`~dxpy.bindings.search.find_one_data_object`, with the exception of "project" :raises: :exc:`~dxpy.exceptions.DXError` if "project" is given, if this is called with dxpy.JOB_ID not set, or if "DX_PROJECT_CACHE_ID" is not found in the e...
python
def load_from_cache(**kwargs): ''' :param kwargs: keyword args for :func:`~dxpy.bindings.search.find_one_data_object`, with the exception of "project" :raises: :exc:`~dxpy.exceptions.DXError` if "project" is given, if this is called with dxpy.JOB_ID not set, or if "DX_PROJECT_CACHE_ID" is not found in the e...
[ "def", "load_from_cache", "(", "*", "*", "kwargs", ")", ":", "if", "'project'", "in", "kwargs", ":", "raise", "DXError", "(", "'Unexpected kwarg: \"project\"'", ")", "if", "dxpy", ".", "JOB_ID", "is", "None", ":", "raise", "DXError", "(", "'Not called by a job...
:param kwargs: keyword args for :func:`~dxpy.bindings.search.find_one_data_object`, with the exception of "project" :raises: :exc:`~dxpy.exceptions.DXError` if "project" is given, if this is called with dxpy.JOB_ID not set, or if "DX_PROJECT_CACHE_ID" is not found in the environment variables :returns: None if ...
[ ":", "param", "kwargs", ":", "keyword", "args", "for", ":", "func", ":", "~dxpy", ".", "bindings", ".", "search", ".", "find_one_data_object", "with", "the", "exception", "of", "project", ":", "raises", ":", ":", "exc", ":", "~dxpy", ".", "exceptions", "...
train
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/bindings/dxapp_container_functions.py#L64-L100
dnanexus/dx-toolkit
src/python/dxpy/bindings/dxapp_container_functions.py
save_to_cache
def save_to_cache(dxobject): ''' :param dxobject: a dxpy object handler for an object to save to the cache :raises: :exc:`~dxpy.exceptions.DXError` if this is called with dxpy.JOB_ID not set, or if "DX_PROJECT_CACHE_ID" is not found in the environment variables Clones the given object to the project ca...
python
def save_to_cache(dxobject): ''' :param dxobject: a dxpy object handler for an object to save to the cache :raises: :exc:`~dxpy.exceptions.DXError` if this is called with dxpy.JOB_ID not set, or if "DX_PROJECT_CACHE_ID" is not found in the environment variables Clones the given object to the project ca...
[ "def", "save_to_cache", "(", "dxobject", ")", ":", "if", "dxpy", ".", "JOB_ID", "is", "None", ":", "raise", "DXError", "(", "'Not called by a job'", ")", "if", "'DX_PROJECT_CACHE_ID'", "not", "in", "os", ".", "environ", ":", "raise", "DXError", "(", "'Projec...
:param dxobject: a dxpy object handler for an object to save to the cache :raises: :exc:`~dxpy.exceptions.DXError` if this is called with dxpy.JOB_ID not set, or if "DX_PROJECT_CACHE_ID" is not found in the environment variables Clones the given object to the project cache. Example:: @dxpy.entry_...
[ ":", "param", "dxobject", ":", "a", "dxpy", "object", "handler", "for", "an", "object", "to", "save", "to", "the", "cache", ":", "raises", ":", ":", "exc", ":", "~dxpy", ".", "exceptions", ".", "DXError", "if", "this", "is", "called", "with", "dxpy", ...
train
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/bindings/dxapp_container_functions.py#L103-L125
dnanexus/dx-toolkit
src/python/dxpy/bindings/dxapplet.py
DXExecutable._get_run_input_common_fields
def _get_run_input_common_fields(executable_input, **kwargs): ''' Takes the same arguments as the run method. Creates an input hash for the /executable-xxxx/run method, translating ONLY the fields that can be handled uniformly across all executables: project, folder, name, tags, properti...
python
def _get_run_input_common_fields(executable_input, **kwargs): ''' Takes the same arguments as the run method. Creates an input hash for the /executable-xxxx/run method, translating ONLY the fields that can be handled uniformly across all executables: project, folder, name, tags, properti...
[ "def", "_get_run_input_common_fields", "(", "executable_input", ",", "*", "*", "kwargs", ")", ":", "project", "=", "kwargs", ".", "get", "(", "'project'", ")", "or", "dxpy", ".", "WORKSPACE_ID", "run_input", "=", "{", "\"input\"", ":", "executable_input", "}",...
Takes the same arguments as the run method. Creates an input hash for the /executable-xxxx/run method, translating ONLY the fields that can be handled uniformly across all executables: project, folder, name, tags, properties, details, depends_on, allow_ssh, debug, delay_workspace_destruction, ignore_reu...
[ "Takes", "the", "same", "arguments", "as", "the", "run", "method", ".", "Creates", "an", "input", "hash", "for", "the", "/", "executable", "-", "xxxx", "/", "run", "method", "translating", "ONLY", "the", "fields", "that", "can", "be", "handled", "uniformly...
train
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/bindings/dxapplet.py#L46-L100
dnanexus/dx-toolkit
src/python/dxpy/bindings/dxapplet.py
DXExecutable._get_run_input_fields_for_applet
def _get_run_input_fields_for_applet(executable_input, **kwargs): ''' Takes the same arguments as the run method. Creates an input hash for the /applet-xxxx/run method. ''' # Although it says "for_applet", this is factored out of # DXApplet because apps currently use the ...
python
def _get_run_input_fields_for_applet(executable_input, **kwargs): ''' Takes the same arguments as the run method. Creates an input hash for the /applet-xxxx/run method. ''' # Although it says "for_applet", this is factored out of # DXApplet because apps currently use the ...
[ "def", "_get_run_input_fields_for_applet", "(", "executable_input", ",", "*", "*", "kwargs", ")", ":", "# Although it says \"for_applet\", this is factored out of", "# DXApplet because apps currently use the same mechanism", "for", "unsupported_arg", "in", "[", "'stage_instance_types...
Takes the same arguments as the run method. Creates an input hash for the /applet-xxxx/run method.
[ "Takes", "the", "same", "arguments", "as", "the", "run", "method", ".", "Creates", "an", "input", "hash", "for", "the", "/", "applet", "-", "xxxx", "/", "run", "method", "." ]
train
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/bindings/dxapplet.py#L103-L114
dnanexus/dx-toolkit
src/python/dxpy/bindings/dxapplet.py
DXExecutable.run
def run(self, executable_input, project=None, folder=None, name=None, tags=None, properties=None, details=None, instance_type=None, stage_instance_types=None, stage_folders=None, rerun_stages=None, cluster_spec=None, depends_on=None, allow_ssh=None, debug=None, delay_workspace_destruction=None, ...
python
def run(self, executable_input, project=None, folder=None, name=None, tags=None, properties=None, details=None, instance_type=None, stage_instance_types=None, stage_folders=None, rerun_stages=None, cluster_spec=None, depends_on=None, allow_ssh=None, debug=None, delay_workspace_destruction=None, ...
[ "def", "run", "(", "self", ",", "executable_input", ",", "project", "=", "None", ",", "folder", "=", "None", ",", "name", "=", "None", ",", "tags", "=", "None", ",", "properties", "=", "None", ",", "details", "=", "None", ",", "instance_type", "=", "...
:param executable_input: Hash of the executable's input arguments :type executable_input: dict :param project: Project ID of the project context :type project: string :param folder: Folder in which executable's outputs will be placed in *project* :type folder: string :par...
[ ":", "param", "executable_input", ":", "Hash", "of", "the", "executable", "s", "input", "arguments", ":", "type", "executable_input", ":", "dict", ":", "param", "project", ":", "Project", "ID", "of", "the", "project", "context", ":", "type", "project", ":", ...
train
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/bindings/dxapplet.py#L158-L227
dnanexus/dx-toolkit
src/python/dxpy/bindings/dxapplet.py
DXApplet._new
def _new(self, dx_hash, **kwargs): ''' :param dx_hash: Standard hash populated in :func:`dxpy.bindings.DXDataObject.new()` containing attributes common to all data object classes. :type dx_hash: dict :param runSpec: Run specification :type runSpec: dict :param dxapi: API ...
python
def _new(self, dx_hash, **kwargs): ''' :param dx_hash: Standard hash populated in :func:`dxpy.bindings.DXDataObject.new()` containing attributes common to all data object classes. :type dx_hash: dict :param runSpec: Run specification :type runSpec: dict :param dxapi: API ...
[ "def", "_new", "(", "self", ",", "dx_hash", ",", "*", "*", "kwargs", ")", ":", "for", "field", "in", "'runSpec'", ",", "'dxapi'", ":", "if", "field", "not", "in", "kwargs", ":", "raise", "DXError", "(", "\"%s: Keyword argument %s is required\"", "%", "(", ...
:param dx_hash: Standard hash populated in :func:`dxpy.bindings.DXDataObject.new()` containing attributes common to all data object classes. :type dx_hash: dict :param runSpec: Run specification :type runSpec: dict :param dxapi: API version string :type dxapi: string :par...
[ ":", "param", "dx_hash", ":", "Standard", "hash", "populated", "in", ":", "func", ":", "dxpy", ".", "bindings", ".", "DXDataObject", ".", "new", "()", "containing", "attributes", "common", "to", "all", "data", "object", "classes", ".", ":", "type", "dx_has...
train
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/bindings/dxapplet.py#L307-L351
dnanexus/dx-toolkit
src/python/dxpy/bindings/dxapplet.py
DXApplet.run
def run(self, applet_input, *args, **kwargs): """ Creates a new job that executes the function "main" of this applet with the given input *applet_input*. See :meth:`dxpy.bindings.dxapplet.DXExecutable.run` for the available args. """ # Rename applet_input arg to ...
python
def run(self, applet_input, *args, **kwargs): """ Creates a new job that executes the function "main" of this applet with the given input *applet_input*. See :meth:`dxpy.bindings.dxapplet.DXExecutable.run` for the available args. """ # Rename applet_input arg to ...
[ "def", "run", "(", "self", ",", "applet_input", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Rename applet_input arg to preserve API compatibility when calling", "# DXApplet.run(applet_input=...)", "return", "super", "(", "DXApplet", ",", "self", ")", ".", ...
Creates a new job that executes the function "main" of this applet with the given input *applet_input*. See :meth:`dxpy.bindings.dxapplet.DXExecutable.run` for the available args.
[ "Creates", "a", "new", "job", "that", "executes", "the", "function", "main", "of", "this", "applet", "with", "the", "given", "input", "*", "applet_input", "*", "." ]
train
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/bindings/dxapplet.py#L384-L394
dnanexus/dx-toolkit
src/python/dxpy/cli/parsers.py
set_env_from_args
def set_env_from_args(args): ''' Sets the environment variables for this process from arguments (argparse.Namespace) and calls dxpy._initialize() to reset any values that it has already set. ''' args = vars(args) if args.get('apiserver_host') is not None: config['DX_APISERVER_HOST'] = args[...
python
def set_env_from_args(args): ''' Sets the environment variables for this process from arguments (argparse.Namespace) and calls dxpy._initialize() to reset any values that it has already set. ''' args = vars(args) if args.get('apiserver_host') is not None: config['DX_APISERVER_HOST'] = args[...
[ "def", "set_env_from_args", "(", "args", ")", ":", "args", "=", "vars", "(", "args", ")", "if", "args", ".", "get", "(", "'apiserver_host'", ")", "is", "not", "None", ":", "config", "[", "'DX_APISERVER_HOST'", "]", "=", "args", "[", "'apiserver_host'", "...
Sets the environment variables for this process from arguments (argparse.Namespace) and calls dxpy._initialize() to reset any values that it has already set.
[ "Sets", "the", "environment", "variables", "for", "this", "process", "from", "arguments", "(", "argparse", ".", "Namespace", ")", "and", "calls", "dxpy", ".", "_initialize", "()", "to", "reset", "any", "values", "that", "it", "has", "already", "set", "." ]
train
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/cli/parsers.py#L186-L208
dnanexus/dx-toolkit
src/python/dxpy/asset_builder.py
validate_conf
def validate_conf(asset_conf): """ Validates the contents of the conf file and makes sure that the required information is provided. { "name": "asset_library_name", "title": "A human readable name", "description": " A detailed description abput the asset", ...
python
def validate_conf(asset_conf): """ Validates the contents of the conf file and makes sure that the required information is provided. { "name": "asset_library_name", "title": "A human readable name", "description": " A detailed description abput the asset", ...
[ "def", "validate_conf", "(", "asset_conf", ")", ":", "if", "'name'", "not", "in", "asset_conf", ":", "raise", "AssetBuilderException", "(", "'The asset configuration does not contain the required field \"name\".'", ")", "# TODO: this default is not a good idea, and we will have to ...
Validates the contents of the conf file and makes sure that the required information is provided. { "name": "asset_library_name", "title": "A human readable name", "description": " A detailed description abput the asset", "version": "0.0.1", "distr...
[ "Validates", "the", "contents", "of", "the", "conf", "file", "and", "makes", "sure", "that", "the", "required", "information", "is", "provided", ".", "{", "name", ":", "asset_library_name", "title", ":", "A", "human", "readable", "name", "description", ":", ...
train
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/asset_builder.py#L59-L97
dnanexus/dx-toolkit
src/python/dxpy/asset_builder.py
get_asset_tarball
def get_asset_tarball(asset_name, src_dir, dest_project, dest_folder, json_out): """ If the src_dir contains a "resources" directory its contents are archived and the archived file is uploaded to the platform """ if os.path.isdir(os.path.join(src_dir, "resources")): temp_dir = tempfile.mkdte...
python
def get_asset_tarball(asset_name, src_dir, dest_project, dest_folder, json_out): """ If the src_dir contains a "resources" directory its contents are archived and the archived file is uploaded to the platform """ if os.path.isdir(os.path.join(src_dir, "resources")): temp_dir = tempfile.mkdte...
[ "def", "get_asset_tarball", "(", "asset_name", ",", "src_dir", ",", "dest_project", ",", "dest_folder", ",", "json_out", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "os", ".", "path", ".", "join", "(", "src_dir", ",", "\"resources\"", ")", ")",...
If the src_dir contains a "resources" directory its contents are archived and the archived file is uploaded to the platform
[ "If", "the", "src_dir", "contains", "a", "resources", "directory", "its", "contents", "are", "archived", "and", "the", "archived", "file", "is", "uploaded", "to", "the", "platform" ]
train
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/asset_builder.py#L145-L159
dnanexus/dx-toolkit
src/python/dxpy/utils/resolver.py
pick
def pick(choices, default=None, str_choices=None, prompt=None, allow_mult=False, more_choices=False): ''' :param choices: Strings between which the user will make a choice :type choices: list of strings :param default: Number the index to be used as the default :type default: int or None :param ...
python
def pick(choices, default=None, str_choices=None, prompt=None, allow_mult=False, more_choices=False): ''' :param choices: Strings between which the user will make a choice :type choices: list of strings :param default: Number the index to be used as the default :type default: int or None :param ...
[ "def", "pick", "(", "choices", ",", "default", "=", "None", ",", "str_choices", "=", "None", ",", "prompt", "=", "None", ",", "allow_mult", "=", "False", ",", "more_choices", "=", "False", ")", ":", "for", "i", "in", "range", "(", "len", "(", "choice...
:param choices: Strings between which the user will make a choice :type choices: list of strings :param default: Number the index to be used as the default :type default: int or None :param str_choices: Strings to be used as aliases for the choices; must be of the same length as choices and each string ...
[ ":", "param", "choices", ":", "Strings", "between", "which", "the", "user", "will", "make", "a", "choice", ":", "type", "choices", ":", "list", "of", "strings", ":", "param", "default", ":", "Number", "the", "index", "to", "be", "used", "as", "the", "d...
train
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/utils/resolver.py#L36-L99
dnanexus/dx-toolkit
src/python/dxpy/utils/resolver.py
object_exists_in_project
def object_exists_in_project(obj_id, proj_id): ''' :param obj_id: object ID :type obj_id: str :param proj_id: project ID :type proj_id: str Returns True if the specified data object can be found in the specified project. ''' if obj_id is None: raise ValueError("Expected obj_...
python
def object_exists_in_project(obj_id, proj_id): ''' :param obj_id: object ID :type obj_id: str :param proj_id: project ID :type proj_id: str Returns True if the specified data object can be found in the specified project. ''' if obj_id is None: raise ValueError("Expected obj_...
[ "def", "object_exists_in_project", "(", "obj_id", ",", "proj_id", ")", ":", "if", "obj_id", "is", "None", ":", "raise", "ValueError", "(", "\"Expected obj_id to be a string\"", ")", "if", "proj_id", "is", "None", ":", "raise", "ValueError", "(", "\"Expected proj_i...
:param obj_id: object ID :type obj_id: str :param proj_id: project ID :type proj_id: str Returns True if the specified data object can be found in the specified project.
[ ":", "param", "obj_id", ":", "object", "ID", ":", "type", "obj_id", ":", "str", ":", "param", "proj_id", ":", "project", "ID", ":", "type", "proj_id", ":", "str" ]
train
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/utils/resolver.py#L195-L211
dnanexus/dx-toolkit
src/python/dxpy/utils/resolver.py
get_last_pos_of_char
def get_last_pos_of_char(char, string): ''' :param char: The character to find :type char: string :param string: The string in which to search for *char* :type string: string :returns: Index in *string* where *char* last appears (unescaped by a preceding "\\"), -1 if not found :rtype: int ...
python
def get_last_pos_of_char(char, string): ''' :param char: The character to find :type char: string :param string: The string in which to search for *char* :type string: string :returns: Index in *string* where *char* last appears (unescaped by a preceding "\\"), -1 if not found :rtype: int ...
[ "def", "get_last_pos_of_char", "(", "char", ",", "string", ")", ":", "pos", "=", "len", "(", "string", ")", "while", "pos", ">", "0", ":", "pos", "=", "string", "[", ":", "pos", "]", ".", "rfind", "(", "char", ")", "if", "pos", "==", "-", "1", ...
:param char: The character to find :type char: string :param string: The string in which to search for *char* :type string: string :returns: Index in *string* where *char* last appears (unescaped by a preceding "\\"), -1 if not found :rtype: int Finds the last occurrence of *char* in *string* i...
[ ":", "param", "char", ":", "The", "character", "to", "find", ":", "type", "char", ":", "string", ":", "param", "string", ":", "The", "string", "in", "which", "to", "search", "for", "*", "char", "*", ":", "type", "string", ":", "string", ":", "returns...
train
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/utils/resolver.py#L233-L258
dnanexus/dx-toolkit
src/python/dxpy/utils/resolver.py
get_first_pos_of_char
def get_first_pos_of_char(char, string): ''' :param char: The character to find :type char: string :param string: The string in which to search for *char* :type string: string :returns: Index in *string* where *char* last appears (unescaped by a preceding "\\"), -1 if not found :rtype: int ...
python
def get_first_pos_of_char(char, string): ''' :param char: The character to find :type char: string :param string: The string in which to search for *char* :type string: string :returns: Index in *string* where *char* last appears (unescaped by a preceding "\\"), -1 if not found :rtype: int ...
[ "def", "get_first_pos_of_char", "(", "char", ",", "string", ")", ":", "first_pos", "=", "-", "1", "pos", "=", "len", "(", "string", ")", "while", "pos", ">", "0", ":", "pos", "=", "string", "[", ":", "pos", "]", ".", "rfind", "(", "char", ")", "i...
:param char: The character to find :type char: string :param string: The string in which to search for *char* :type string: string :returns: Index in *string* where *char* last appears (unescaped by a preceding "\\"), -1 if not found :rtype: int Finds the first occurrence of *char* in *string* ...
[ ":", "param", "char", ":", "The", "character", "to", "find", ":", "type", "char", ":", "string", ":", "param", "string", ":", "The", "string", "in", "which", "to", "search", "for", "*", "char", "*", ":", "type", "string", ":", "string", ":", "returns...
train
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/utils/resolver.py#L260-L286
dnanexus/dx-toolkit
src/python/dxpy/utils/resolver.py
split_unescaped
def split_unescaped(char, string, include_empty_strings=False): ''' :param char: The character on which to split the string :type char: string :param string: The string to split :type string: string :returns: List of substrings of *string* :rtype: list of strings Splits *string* wheneve...
python
def split_unescaped(char, string, include_empty_strings=False): ''' :param char: The character on which to split the string :type char: string :param string: The string to split :type string: string :returns: List of substrings of *string* :rtype: list of strings Splits *string* wheneve...
[ "def", "split_unescaped", "(", "char", ",", "string", ",", "include_empty_strings", "=", "False", ")", ":", "words", "=", "[", "]", "pos", "=", "len", "(", "string", ")", "lastpos", "=", "pos", "while", "pos", ">=", "0", ":", "pos", "=", "get_last_pos_...
:param char: The character on which to split the string :type char: string :param string: The string to split :type string: string :returns: List of substrings of *string* :rtype: list of strings Splits *string* whenever *char* appears without an odd number of backslashes ('\\') preceding i...
[ ":", "param", "char", ":", "The", "character", "on", "which", "to", "split", "the", "string", ":", "type", "char", ":", "string", ":", "param", "string", ":", "The", "string", "to", "split", ":", "type", "string", ":", "string", ":", "returns", ":", ...
train
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/utils/resolver.py#L288-L314
dnanexus/dx-toolkit
src/python/dxpy/utils/resolver.py
clean_folder_path
def clean_folder_path(path, expected=None): ''' :param path: A folder path to sanitize and parse :type path: string :param expected: Whether a folder ("folder"), a data object ("entity"), or either (None) is expected :type expected: string or None :returns: *folderpath*, *name* Unescape and...
python
def clean_folder_path(path, expected=None): ''' :param path: A folder path to sanitize and parse :type path: string :param expected: Whether a folder ("folder"), a data object ("entity"), or either (None) is expected :type expected: string or None :returns: *folderpath*, *name* Unescape and...
[ "def", "clean_folder_path", "(", "path", ",", "expected", "=", "None", ")", ":", "folders", "=", "split_unescaped", "(", "'/'", ",", "path", ")", "if", "len", "(", "folders", ")", "==", "0", ":", "return", "'/'", ",", "None", "if", "expected", "==", ...
:param path: A folder path to sanitize and parse :type path: string :param expected: Whether a folder ("folder"), a data object ("entity"), or either (None) is expected :type expected: string or None :returns: *folderpath*, *name* Unescape and parse *path* as a folder path to possibly an entity ...
[ ":", "param", "path", ":", "A", "folder", "path", "to", "sanitize", "and", "parse", ":", "type", "path", ":", "string", ":", "param", "expected", ":", "Whether", "a", "folder", "(", "folder", ")", "a", "data", "object", "(", "entity", ")", "or", "eit...
train
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/utils/resolver.py#L317-L354
dnanexus/dx-toolkit
src/python/dxpy/utils/resolver.py
resolve_container_id_or_name
def resolve_container_id_or_name(raw_string, is_error=False, multi=False): ''' :param raw_string: A potential project or container ID or name :type raw_string: string :param is_error: Whether to raise an exception if the project or container ID cannot be resolved :type is_error: boolean ...
python
def resolve_container_id_or_name(raw_string, is_error=False, multi=False): ''' :param raw_string: A potential project or container ID or name :type raw_string: string :param is_error: Whether to raise an exception if the project or container ID cannot be resolved :type is_error: boolean ...
[ "def", "resolve_container_id_or_name", "(", "raw_string", ",", "is_error", "=", "False", ",", "multi", "=", "False", ")", ":", "string", "=", "unescape_name_str", "(", "raw_string", ")", "if", "is_container_id", "(", "string", ")", ":", "return", "(", "[", "...
:param raw_string: A potential project or container ID or name :type raw_string: string :param is_error: Whether to raise an exception if the project or container ID cannot be resolved :type is_error: boolean :returns: Project or container ID if found or else None :rtype: string or None ...
[ ":", "param", "raw_string", ":", "A", "potential", "project", "or", "container", "ID", "or", "name", ":", "type", "raw_string", ":", "string", ":", "param", "is_error", ":", "Whether", "to", "raise", "an", "exception", "if", "the", "project", "or", "contai...
train
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/utils/resolver.py#L357-L402
dnanexus/dx-toolkit
src/python/dxpy/utils/resolver.py
resolve_path
def resolve_path(path, expected=None, multi_projects=False, allow_empty_string=True): ''' :param path: A path to a data object to attempt to resolve :type path: string :param expected: one of the following: "folder", "entity", or None to indicate whether the expected path is a folder, a data...
python
def resolve_path(path, expected=None, multi_projects=False, allow_empty_string=True): ''' :param path: A path to a data object to attempt to resolve :type path: string :param expected: one of the following: "folder", "entity", or None to indicate whether the expected path is a folder, a data...
[ "def", "resolve_path", "(", "path", ",", "expected", "=", "None", ",", "multi_projects", "=", "False", ",", "allow_empty_string", "=", "True", ")", ":", "# TODO: callers that intend to obtain a data object probably won't be happy", "# with an app or execution ID. Callers should...
:param path: A path to a data object to attempt to resolve :type path: string :param expected: one of the following: "folder", "entity", or None to indicate whether the expected path is a folder, a data object, or either :type expected: string or None :returns: A tuple of 3 value...
[ ":", "param", "path", ":", "A", "path", "to", "a", "data", "object", "to", "attempt", "to", "resolve", ":", "type", "path", ":", "string", ":", "param", "expected", ":", "one", "of", "the", "following", ":", "folder", "entity", "or", "None", "to", "i...
train
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/utils/resolver.py#L420-L557
dnanexus/dx-toolkit
src/python/dxpy/utils/resolver.py
_check_resolution_needed
def _check_resolution_needed(path, project, folderpath, entity_name, expected_classes=None, describe=True, enclose_in_list=False): """ :param path: Path to the object that required resolution; propagated from command-line :type path: string :param project: T...
python
def _check_resolution_needed(path, project, folderpath, entity_name, expected_classes=None, describe=True, enclose_in_list=False): """ :param path: Path to the object that required resolution; propagated from command-line :type path: string :param project: T...
[ "def", "_check_resolution_needed", "(", "path", ",", "project", ",", "folderpath", ",", "entity_name", ",", "expected_classes", "=", "None", ",", "describe", "=", "True", ",", "enclose_in_list", "=", "False", ")", ":", "if", "entity_name", "is", "None", ":", ...
:param path: Path to the object that required resolution; propagated from command-line :type path: string :param project: The potential project the entity belongs to :type project: string :param folderpath: Path to the entity :type folderpath: string :param entity_name: The name...
[ ":", "param", "path", ":", "Path", "to", "the", "object", "that", "required", "resolution", ";", "propagated", "from", "command", "-", "line", ":", "type", "path", ":", "string", ":", "param", "project", ":", "The", "potential", "project", "the", "entity",...
train
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/utils/resolver.py#L615-L718
dnanexus/dx-toolkit
src/python/dxpy/utils/resolver.py
_resolve_folder
def _resolve_folder(project, parent_folder, folder_name): """ :param project: The project that the folder belongs to :type project: string :param parent_folder: Full path to the parent folder that contains folder_name :type parent_folder: string :param folder_name: Name ...
python
def _resolve_folder(project, parent_folder, folder_name): """ :param project: The project that the folder belongs to :type project: string :param parent_folder: Full path to the parent folder that contains folder_name :type parent_folder: string :param folder_name: Name ...
[ "def", "_resolve_folder", "(", "project", ",", "parent_folder", ",", "folder_name", ")", ":", "if", "'/'", "in", "folder_name", ":", "# Then there's no way it's supposed to be a folder", "raise", "ResolutionError", "(", "'Object of name '", "+", "str", "(", "folder_name...
:param project: The project that the folder belongs to :type project: string :param parent_folder: Full path to the parent folder that contains folder_name :type parent_folder: string :param folder_name: Name of the folder :type folder_name: string :returns: The path to ...
[ ":", "param", "project", ":", "The", "project", "that", "the", "folder", "belongs", "to", ":", "type", "project", ":", "string", ":", "param", "parent_folder", ":", "Full", "path", "to", "the", "parent", "folder", "that", "contains", "folder_name", ":", "t...
train
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/utils/resolver.py#L721-L747
dnanexus/dx-toolkit
src/python/dxpy/utils/resolver.py
_validate_resolution_output_length
def _validate_resolution_output_length(path, entity_name, results, allow_mult=False, all_mult=False, ask_to_resolve=True): """ :param path: Path to the object that required resolution; propagated from command-line :type path: string :param entity_n...
python
def _validate_resolution_output_length(path, entity_name, results, allow_mult=False, all_mult=False, ask_to_resolve=True): """ :param path: Path to the object that required resolution; propagated from command-line :type path: string :param entity_n...
[ "def", "_validate_resolution_output_length", "(", "path", ",", "entity_name", ",", "results", ",", "allow_mult", "=", "False", ",", "all_mult", "=", "False", ",", "ask_to_resolve", "=", "True", ")", ":", "if", "len", "(", "results", ")", "==", "0", ":", "r...
:param path: Path to the object that required resolution; propagated from command-line :type path: string :param entity_name: Name of the object :type entity_name: string :param results: Result of resolution; non-empty list of object specifications (each specificatio...
[ ":", "param", "path", ":", "Path", "to", "the", "object", "that", "required", "resolution", ";", "propagated", "from", "command", "-", "line", ":", "type", "path", ":", "string", ":", "param", "entity_name", ":", "Name", "of", "the", "object", ":", "type...
train
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/utils/resolver.py#L750-L828
dnanexus/dx-toolkit
src/python/dxpy/utils/resolver.py
_resolve_global_entity
def _resolve_global_entity(project_or_job_id, folderpath, entity_name, describe=True, visibility="either"): """ :param project_or_job_id: The project ID to which the entity belongs (then the entity is an existing data object), or the job ID to which th...
python
def _resolve_global_entity(project_or_job_id, folderpath, entity_name, describe=True, visibility="either"): """ :param project_or_job_id: The project ID to which the entity belongs (then the entity is an existing data object), or the job ID to which th...
[ "def", "_resolve_global_entity", "(", "project_or_job_id", ",", "folderpath", ",", "entity_name", ",", "describe", "=", "True", ",", "visibility", "=", "\"either\"", ")", ":", "if", "is_job_id", "(", "project_or_job_id", ")", ":", "if", "describe", "is", "True",...
:param project_or_job_id: The project ID to which the entity belongs (then the entity is an existing data object), or the job ID to which the entity belongs (then the entity is a job-based object refe...
[ ":", "param", "project_or_job_id", ":", "The", "project", "ID", "to", "which", "the", "entity", "belongs", "(", "then", "the", "entity", "is", "an", "existing", "data", "object", ")", "or", "the", "job", "ID", "to", "which", "the", "entity", "belongs", "...
train
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/utils/resolver.py#L831-L888
dnanexus/dx-toolkit
src/python/dxpy/utils/resolver.py
_format_resolution_output
def _format_resolution_output(path, project, folderpath, entity_name, result): """ :param path: Path to the object that required resolution; propagated from command-line :type path: string :param project: The potential project the entity belongs to :type project: string :param f...
python
def _format_resolution_output(path, project, folderpath, entity_name, result): """ :param path: Path to the object that required resolution; propagated from command-line :type path: string :param project: The potential project the entity belongs to :type project: string :param f...
[ "def", "_format_resolution_output", "(", "path", ",", "project", ",", "folderpath", ",", "entity_name", ",", "result", ")", ":", "try", ":", "if", "len", "(", "result", ")", "==", "0", ":", "folder", "=", "_resolve_folder", "(", "project", ",", "folderpath...
:param path: Path to the object that required resolution; propagated from command-line :type path: string :param project: The potential project the entity belongs to :type project: string :param folderpath: Path to the entity :type folderpath: string :param entity_name: The name...
[ ":", "param", "path", ":", "Path", "to", "the", "object", "that", "required", "resolution", ";", "propagated", "from", "command", "-", "line", ":", "type", "path", ":", "string", ":", "param", "project", ":", "The", "potential", "project", "the", "entity",...
train
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/utils/resolver.py#L891-L933
dnanexus/dx-toolkit
src/python/dxpy/utils/resolver.py
resolve_multiple_existing_paths
def resolve_multiple_existing_paths(paths): """ :param paths: A list of paths to items that need to be resolved :type paths: list :returns: A dictionary mapping a specified path to either its resolved object or Nones, if the object could not be resolved :rtype: dict For each input...
python
def resolve_multiple_existing_paths(paths): """ :param paths: A list of paths to items that need to be resolved :type paths: list :returns: A dictionary mapping a specified path to either its resolved object or Nones, if the object could not be resolved :rtype: dict For each input...
[ "def", "resolve_multiple_existing_paths", "(", "paths", ")", ":", "done_objects", "=", "{", "}", "# Return value", "to_resolve_in_batch_paths", "=", "[", "]", "# Paths to resolve", "to_resolve_in_batch_inputs", "=", "[", "]", "# Project, folderpath, and entity name", "for",...
:param paths: A list of paths to items that need to be resolved :type paths: list :returns: A dictionary mapping a specified path to either its resolved object or Nones, if the object could not be resolved :rtype: dict For each input given in paths, attempts to resolve the path, and retur...
[ ":", "param", "paths", ":", "A", "list", "of", "paths", "to", "items", "that", "need", "to", "be", "resolved", ":", "type", "paths", ":", "list", ":", "returns", ":", "A", "dictionary", "mapping", "a", "specified", "path", "to", "either", "its", "resol...
train
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/utils/resolver.py#L936-L1012
dnanexus/dx-toolkit
src/python/dxpy/utils/resolver.py
resolve_existing_path
def resolve_existing_path(path, expected=None, ask_to_resolve=True, expected_classes=None, allow_mult=False, describe=True, all_mult=False, allow_empty_string=True, visibility="either"): ''' :param expected: one of the following: "folder", "entity", or None to indicate ...
python
def resolve_existing_path(path, expected=None, ask_to_resolve=True, expected_classes=None, allow_mult=False, describe=True, all_mult=False, allow_empty_string=True, visibility="either"): ''' :param expected: one of the following: "folder", "entity", or None to indicate ...
[ "def", "resolve_existing_path", "(", "path", ",", "expected", "=", "None", ",", "ask_to_resolve", "=", "True", ",", "expected_classes", "=", "None", ",", "allow_mult", "=", "False", ",", "describe", "=", "True", ",", "all_mult", "=", "False", ",", "allow_emp...
:param expected: one of the following: "folder", "entity", or None to indicate whether the expected path is a folder, a data object, or either :type expected: string or None :param ask_to_resolve: Whether picking may be necessary (if true, a list is returned; if false, only one result is re...
[ ":", "param", "expected", ":", "one", "of", "the", "following", ":", "folder", "entity", "or", "None", "to", "indicate", "whether", "the", "expected", "path", "is", "a", "folder", "a", "data", "object", "or", "either", ":", "type", "expected", ":", "stri...
train
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/utils/resolver.py#L1015-L1084
dnanexus/dx-toolkit
src/python/dxpy/utils/resolver.py
check_folder_exists
def check_folder_exists(project, path, folder_name): ''' :param project: project id :type project: string :param path: path to where we should look for the folder in question :type path: string :param folder_name: name of the folder in question :type folder_name: string :returns: A boole...
python
def check_folder_exists(project, path, folder_name): ''' :param project: project id :type project: string :param path: path to where we should look for the folder in question :type path: string :param folder_name: name of the folder in question :type folder_name: string :returns: A boole...
[ "def", "check_folder_exists", "(", "project", ",", "path", ",", "folder_name", ")", ":", "if", "folder_name", "is", "None", "or", "path", "is", "None", ":", "return", "False", "try", ":", "folder_list", "=", "dxpy", ".", "api", ".", "container_list_folder", ...
:param project: project id :type project: string :param path: path to where we should look for the folder in question :type path: string :param folder_name: name of the folder in question :type folder_name: string :returns: A boolean True or False whether the folder exists at the specified path ...
[ ":", "param", "project", ":", "project", "id", ":", "type", "project", ":", "string", ":", "param", "path", ":", "path", "to", "where", "we", "should", "look", "for", "the", "folder", "in", "question", ":", "type", "path", ":", "string", ":", "param", ...
train
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/utils/resolver.py#L1087-L1118
dnanexus/dx-toolkit
src/python/dxpy/utils/resolver.py
get_app_from_path
def get_app_from_path(path): ''' :param path: A string to attempt to resolve to an app object :type path: string :returns: The describe hash of the app object if found, or None otherwise :rtype: dict or None This method parses a string that is expected to perhaps refer to an app object. If...
python
def get_app_from_path(path): ''' :param path: A string to attempt to resolve to an app object :type path: string :returns: The describe hash of the app object if found, or None otherwise :rtype: dict or None This method parses a string that is expected to perhaps refer to an app object. If...
[ "def", "get_app_from_path", "(", "path", ")", ":", "alias", "=", "None", "if", "not", "path", ".", "startswith", "(", "'app-'", ")", ":", "path", "=", "'app-'", "+", "path", "if", "'/'", "in", "path", ":", "alias", "=", "path", "[", "path", ".", "f...
:param path: A string to attempt to resolve to an app object :type path: string :returns: The describe hash of the app object if found, or None otherwise :rtype: dict or None This method parses a string that is expected to perhaps refer to an app object. If found, its describe hash will be returne...
[ ":", "param", "path", ":", "A", "string", "to", "attempt", "to", "resolve", "to", "an", "app", "object", ":", "type", "path", ":", "string", ":", "returns", ":", "The", "describe", "hash", "of", "the", "app", "object", "if", "found", "or", "None", "o...
train
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/utils/resolver.py#L1120-L1142
dnanexus/dx-toolkit
src/python/dxpy/utils/resolver.py
get_global_workflow_from_path
def get_global_workflow_from_path(path): ''' :param path: A string to attempt to resolve to a global workflow object :type path: string :returns: The describe hash of the global workflow object if found, or None otherwise :rtype: dict or None This method parses a string that is expected to perh...
python
def get_global_workflow_from_path(path): ''' :param path: A string to attempt to resolve to a global workflow object :type path: string :returns: The describe hash of the global workflow object if found, or None otherwise :rtype: dict or None This method parses a string that is expected to perh...
[ "def", "get_global_workflow_from_path", "(", "path", ")", ":", "alias", "=", "None", "if", "not", "path", ".", "startswith", "(", "'globalworkflow-'", ")", ":", "path", "=", "'globalworkflow-'", "+", "path", "if", "'/'", "in", "path", ":", "alias", "=", "p...
:param path: A string to attempt to resolve to a global workflow object :type path: string :returns: The describe hash of the global workflow object if found, or None otherwise :rtype: dict or None This method parses a string that is expected to perhaps refer to a global workflow object. If found,...
[ ":", "param", "path", ":", "A", "string", "to", "attempt", "to", "resolve", "to", "a", "global", "workflow", "object", ":", "type", "path", ":", "string", ":", "returns", ":", "The", "describe", "hash", "of", "the", "global", "workflow", "object", "if", ...
train
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/utils/resolver.py#L1144-L1167
dnanexus/dx-toolkit
src/python/dxpy/utils/resolver.py
resolve_global_executable
def resolve_global_executable(path, is_version_required=False): """ :param path: A string which is supposed to identify a global executable (app or workflow) :type path: string :param is_version_required: If set to True, the path has to specify a specific version/alias, e.g. "myapp/1.0.0" :type is_v...
python
def resolve_global_executable(path, is_version_required=False): """ :param path: A string which is supposed to identify a global executable (app or workflow) :type path: string :param is_version_required: If set to True, the path has to specify a specific version/alias, e.g. "myapp/1.0.0" :type is_v...
[ "def", "resolve_global_executable", "(", "path", ",", "is_version_required", "=", "False", ")", ":", "if", "not", "is_hashid", "(", "path", ")", "and", "is_version_required", "and", "\"/\"", "not", "in", "path", ":", "raise", "ResolutionError", "(", "'Version is...
:param path: A string which is supposed to identify a global executable (app or workflow) :type path: string :param is_version_required: If set to True, the path has to specify a specific version/alias, e.g. "myapp/1.0.0" :type is_version_required: boolean :returns: The describe hash of the global execu...
[ ":", "param", "path", ":", "A", "string", "which", "is", "supposed", "to", "identify", "a", "global", "executable", "(", "app", "or", "workflow", ")", ":", "type", "path", ":", "string", ":", "param", "is_version_required", ":", "If", "set", "to", "True"...
train
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/utils/resolver.py#L1220-L1253
dnanexus/dx-toolkit
src/python/dxpy/utils/resolver.py
resolve_to_objects_or_project
def resolve_to_objects_or_project(path, all_matching_results=False): ''' :param path: Path to resolve :type path: string :param all_matching_results: Whether to return a list of all matching results :type all_matching_results: boolean A thin wrapper over :meth:`resolve_existing_path` which thro...
python
def resolve_to_objects_or_project(path, all_matching_results=False): ''' :param path: Path to resolve :type path: string :param all_matching_results: Whether to return a list of all matching results :type all_matching_results: boolean A thin wrapper over :meth:`resolve_existing_path` which thro...
[ "def", "resolve_to_objects_or_project", "(", "path", ",", "all_matching_results", "=", "False", ")", ":", "# Attempt to resolve name", "project", ",", "folderpath", ",", "entity_results", "=", "resolve_existing_path", "(", "path", ",", "expected", "=", "'entity'", ","...
:param path: Path to resolve :type path: string :param all_matching_results: Whether to return a list of all matching results :type all_matching_results: boolean A thin wrapper over :meth:`resolve_existing_path` which throws an error if the path does not look like a project and doesn't match a ...
[ ":", "param", "path", ":", "Path", "to", "resolve", ":", "type", "path", ":", "string", ":", "param", "all_matching_results", ":", "Whether", "to", "return", "a", "list", "of", "all", "matching", "results", ":", "type", "all_matching_results", ":", "boolean"...
train
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/utils/resolver.py#L1320-L1346
dnanexus/dx-toolkit
src/python/dxpy/bindings/dxjob.py
new_dxjob
def new_dxjob(fn_input, fn_name, name=None, tags=None, properties=None, details=None, instance_type=None, depends_on=None, **kwargs): ''' :param fn_input: Function input :type fn_input: dict :param fn_name: Name of the function to be called :type fn_name: string :para...
python
def new_dxjob(fn_input, fn_name, name=None, tags=None, properties=None, details=None, instance_type=None, depends_on=None, **kwargs): ''' :param fn_input: Function input :type fn_input: dict :param fn_name: Name of the function to be called :type fn_name: string :para...
[ "def", "new_dxjob", "(", "fn_input", ",", "fn_name", ",", "name", "=", "None", ",", "tags", "=", "None", ",", "properties", "=", "None", ",", "details", "=", "None", ",", "instance_type", "=", "None", ",", "depends_on", "=", "None", ",", "*", "*", "k...
:param fn_input: Function input :type fn_input: dict :param fn_name: Name of the function to be called :type fn_name: string :param name: Name for the new job (default is "<parent job name>:<fn_name>") :type name: string :param tags: Tags to associate with the job :type tags: list of strings...
[ ":", "param", "fn_input", ":", "Function", "input", ":", "type", "fn_input", ":", "dict", ":", "param", "fn_name", ":", "Name", "of", "the", "function", "to", "be", "called", ":", "type", "fn_name", ":", "string", ":", "param", "name", ":", "Name", "fo...
train
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/bindings/dxjob.py#L45-L90
dnanexus/dx-toolkit
src/python/dxpy/bindings/dxjob.py
DXJob.new
def new(self, fn_input, fn_name, name=None, tags=None, properties=None, details=None, instance_type=None, depends_on=None, **kwargs): ''' :param fn_input: Function input :type fn_input: dict :param fn_name: Name of the function to be called :type fn_name: ...
python
def new(self, fn_input, fn_name, name=None, tags=None, properties=None, details=None, instance_type=None, depends_on=None, **kwargs): ''' :param fn_input: Function input :type fn_input: dict :param fn_name: Name of the function to be called :type fn_name: ...
[ "def", "new", "(", "self", ",", "fn_input", ",", "fn_name", ",", "name", "=", "None", ",", "tags", "=", "None", ",", "properties", "=", "None", ",", "details", "=", "None", ",", "instance_type", "=", "None", ",", "depends_on", "=", "None", ",", "*", ...
:param fn_input: Function input :type fn_input: dict :param fn_name: Name of the function to be called :type fn_name: string :param name: Name for the new job (default is "<parent job name>:<fn_name>") :type name: string :param tags: Tags to associate with the job ...
[ ":", "param", "fn_input", ":", "Function", "input", ":", "type", "fn_input", ":", "dict", ":", "param", "fn_name", ":", "Name", "of", "the", "function", "to", "be", "called", ":", "type", "fn_name", ":", "string", ":", "param", "name", ":", "Name", "fo...
train
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/bindings/dxjob.py#L104-L173
dnanexus/dx-toolkit
src/python/dxpy/bindings/dxjob.py
DXJob.set_id
def set_id(self, dxid): ''' :param dxid: New job ID to be associated with the handler (localjob IDs also accepted for local runs) :type dxid: string Discards the currently stored ID and associates the handler with *dxid* ''' if dxid is not None: if not (isins...
python
def set_id(self, dxid): ''' :param dxid: New job ID to be associated with the handler (localjob IDs also accepted for local runs) :type dxid: string Discards the currently stored ID and associates the handler with *dxid* ''' if dxid is not None: if not (isins...
[ "def", "set_id", "(", "self", ",", "dxid", ")", ":", "if", "dxid", "is", "not", "None", ":", "if", "not", "(", "isinstance", "(", "dxid", ",", "basestring", ")", "and", "dxid", ".", "startswith", "(", "'localjob-'", ")", ")", ":", "# localjob IDs (whic...
:param dxid: New job ID to be associated with the handler (localjob IDs also accepted for local runs) :type dxid: string Discards the currently stored ID and associates the handler with *dxid*
[ ":", "param", "dxid", ":", "New", "job", "ID", "to", "be", "associated", "with", "the", "handler", "(", "localjob", "IDs", "also", "accepted", "for", "local", "runs", ")", ":", "type", "dxid", ":", "string" ]
train
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/bindings/dxjob.py#L175-L188
dnanexus/dx-toolkit
src/python/dxpy/bindings/dxjob.py
DXJob.describe
def describe(self, fields=None, io=None, **kwargs): """ :param fields: dict where the keys are field names that should be returned, and values should be set to True (by default, all fields are returned) :type fields: dict :param io: Include input and output fields...
python
def describe(self, fields=None, io=None, **kwargs): """ :param fields: dict where the keys are field names that should be returned, and values should be set to True (by default, all fields are returned) :type fields: dict :param io: Include input and output fields...
[ "def", "describe", "(", "self", ",", "fields", "=", "None", ",", "io", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "fields", "is", "not", "None", "and", "io", "is", "not", "None", ":", "raise", "DXError", "(", "'DXJob.describe: cannot provide...
:param fields: dict where the keys are field names that should be returned, and values should be set to True (by default, all fields are returned) :type fields: dict :param io: Include input and output fields in description; cannot be provided with *fields*; default i...
[ ":", "param", "fields", ":", "dict", "where", "the", "keys", "are", "field", "names", "that", "should", "be", "returned", "and", "values", "should", "be", "set", "to", "True", "(", "by", "default", "all", "fields", "are", "returned", ")", ":", "type", ...
train
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/bindings/dxjob.py#L190-L219