partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
valid | Uploader.__expect | will wait for exp to be returned from nodemcu or timeout | nodemcu_uploader/uploader.py | def __expect(self, exp='> ', timeout=None):
"""will wait for exp to be returned from nodemcu or timeout"""
timeout_before = self._port.timeout
timeout = timeout or self._timeout
#do NOT set timeout on Windows
if SYSTEM != 'Windows':
# Checking for new data every 100us... | def __expect(self, exp='> ', timeout=None):
"""will wait for exp to be returned from nodemcu or timeout"""
timeout_before = self._port.timeout
timeout = timeout or self._timeout
#do NOT set timeout on Windows
if SYSTEM != 'Windows':
# Checking for new data every 100us... | [
"will",
"wait",
"for",
"exp",
"to",
"be",
"returned",
"from",
"nodemcu",
"or",
"timeout"
] | kmpm/nodemcu-uploader | python | https://github.com/kmpm/nodemcu-uploader/blob/557a25f37b1fb4e31a745719e237e42fff192834/nodemcu_uploader/uploader.py#L121-L148 | [
"def",
"__expect",
"(",
"self",
",",
"exp",
"=",
"'> '",
",",
"timeout",
"=",
"None",
")",
":",
"timeout_before",
"=",
"self",
".",
"_port",
".",
"timeout",
"timeout",
"=",
"timeout",
"or",
"self",
".",
"_timeout",
"#do NOT set timeout on Windows",
"if",
"... | 557a25f37b1fb4e31a745719e237e42fff192834 |
valid | Uploader.__write | write data on the nodemcu port. If 'binary' is True the debug log
will show the intended output as hex, otherwise as string | nodemcu_uploader/uploader.py | def __write(self, output, binary=False):
"""write data on the nodemcu port. If 'binary' is True the debug log
will show the intended output as hex, otherwise as string"""
if not binary:
log.debug('write: %s', output)
else:
log.debug('write binary: %s', hexify(outp... | def __write(self, output, binary=False):
"""write data on the nodemcu port. If 'binary' is True the debug log
will show the intended output as hex, otherwise as string"""
if not binary:
log.debug('write: %s', output)
else:
log.debug('write binary: %s', hexify(outp... | [
"write",
"data",
"on",
"the",
"nodemcu",
"port",
".",
"If",
"binary",
"is",
"True",
"the",
"debug",
"log",
"will",
"show",
"the",
"intended",
"output",
"as",
"hex",
"otherwise",
"as",
"string"
] | kmpm/nodemcu-uploader | python | https://github.com/kmpm/nodemcu-uploader/blob/557a25f37b1fb4e31a745719e237e42fff192834/nodemcu_uploader/uploader.py#L150-L158 | [
"def",
"__write",
"(",
"self",
",",
"output",
",",
"binary",
"=",
"False",
")",
":",
"if",
"not",
"binary",
":",
"log",
".",
"debug",
"(",
"'write: %s'",
",",
"output",
")",
"else",
":",
"log",
".",
"debug",
"(",
"'write binary: %s'",
",",
"hexify",
... | 557a25f37b1fb4e31a745719e237e42fff192834 |
valid | Uploader.__exchange | Write output to the port and wait for response | nodemcu_uploader/uploader.py | def __exchange(self, output, timeout=None):
"""Write output to the port and wait for response"""
self.__writeln(output)
self._port.flush()
return self.__expect(timeout=timeout or self._timeout) | def __exchange(self, output, timeout=None):
"""Write output to the port and wait for response"""
self.__writeln(output)
self._port.flush()
return self.__expect(timeout=timeout or self._timeout) | [
"Write",
"output",
"to",
"the",
"port",
"and",
"wait",
"for",
"response"
] | kmpm/nodemcu-uploader | python | https://github.com/kmpm/nodemcu-uploader/blob/557a25f37b1fb4e31a745719e237e42fff192834/nodemcu_uploader/uploader.py#L165-L169 | [
"def",
"__exchange",
"(",
"self",
",",
"output",
",",
"timeout",
"=",
"None",
")",
":",
"self",
".",
"__writeln",
"(",
"output",
")",
"self",
".",
"_port",
".",
"flush",
"(",
")",
"return",
"self",
".",
"__expect",
"(",
"timeout",
"=",
"timeout",
"or... | 557a25f37b1fb4e31a745719e237e42fff192834 |
valid | Uploader.close | restores the nodemcu to default baudrate and then closes the port | nodemcu_uploader/uploader.py | def close(self):
"""restores the nodemcu to default baudrate and then closes the port"""
try:
if self.baud != self.start_baud:
self.__set_baudrate(self.start_baud)
self._port.flush()
self.__clear_buffers()
except serial.serialutil.SerialExcepti... | def close(self):
"""restores the nodemcu to default baudrate and then closes the port"""
try:
if self.baud != self.start_baud:
self.__set_baudrate(self.start_baud)
self._port.flush()
self.__clear_buffers()
except serial.serialutil.SerialExcepti... | [
"restores",
"the",
"nodemcu",
"to",
"default",
"baudrate",
"and",
"then",
"closes",
"the",
"port"
] | kmpm/nodemcu-uploader | python | https://github.com/kmpm/nodemcu-uploader/blob/557a25f37b1fb4e31a745719e237e42fff192834/nodemcu_uploader/uploader.py#L172-L182 | [
"def",
"close",
"(",
"self",
")",
":",
"try",
":",
"if",
"self",
".",
"baud",
"!=",
"self",
".",
"start_baud",
":",
"self",
".",
"__set_baudrate",
"(",
"self",
".",
"start_baud",
")",
"self",
".",
"_port",
".",
"flush",
"(",
")",
"self",
".",
"__cl... | 557a25f37b1fb4e31a745719e237e42fff192834 |
valid | Uploader.prepare | This uploads the protocol functions nessecary to do binary
chunked transfer | nodemcu_uploader/uploader.py | def prepare(self):
"""
This uploads the protocol functions nessecary to do binary
chunked transfer
"""
log.info('Preparing esp for transfer.')
for func in LUA_FUNCTIONS:
detected = self.__exchange('print({0})'.format(func))
if detected.find('funct... | def prepare(self):
"""
This uploads the protocol functions nessecary to do binary
chunked transfer
"""
log.info('Preparing esp for transfer.')
for func in LUA_FUNCTIONS:
detected = self.__exchange('print({0})'.format(func))
if detected.find('funct... | [
"This",
"uploads",
"the",
"protocol",
"functions",
"nessecary",
"to",
"do",
"binary",
"chunked",
"transfer"
] | kmpm/nodemcu-uploader | python | https://github.com/kmpm/nodemcu-uploader/blob/557a25f37b1fb4e31a745719e237e42fff192834/nodemcu_uploader/uploader.py#L185-L216 | [
"def",
"prepare",
"(",
"self",
")",
":",
"log",
".",
"info",
"(",
"'Preparing esp for transfer.'",
")",
"for",
"func",
"in",
"LUA_FUNCTIONS",
":",
"detected",
"=",
"self",
".",
"__exchange",
"(",
"'print({0})'",
".",
"format",
"(",
"func",
")",
")",
"if",
... | 557a25f37b1fb4e31a745719e237e42fff192834 |
valid | Uploader.download_file | Download a file from device to local filesystem | nodemcu_uploader/uploader.py | def download_file(self, filename):
"""Download a file from device to local filesystem"""
res = self.__exchange('send("{filename}")'.format(filename=filename))
if ('unexpected' in res) or ('stdin' in res):
log.error('Unexpected error downloading file: %s', res)
raise Excep... | def download_file(self, filename):
"""Download a file from device to local filesystem"""
res = self.__exchange('send("{filename}")'.format(filename=filename))
if ('unexpected' in res) or ('stdin' in res):
log.error('Unexpected error downloading file: %s', res)
raise Excep... | [
"Download",
"a",
"file",
"from",
"device",
"to",
"local",
"filesystem"
] | kmpm/nodemcu-uploader | python | https://github.com/kmpm/nodemcu-uploader/blob/557a25f37b1fb4e31a745719e237e42fff192834/nodemcu_uploader/uploader.py#L218-L242 | [
"def",
"download_file",
"(",
"self",
",",
"filename",
")",
":",
"res",
"=",
"self",
".",
"__exchange",
"(",
"'send(\"{filename}\")'",
".",
"format",
"(",
"filename",
"=",
"filename",
")",
")",
"if",
"(",
"'unexpected'",
"in",
"res",
")",
"or",
"(",
"'std... | 557a25f37b1fb4e31a745719e237e42fff192834 |
valid | Uploader.read_file | reading data from device into local file | nodemcu_uploader/uploader.py | def read_file(self, filename, destination=''):
"""reading data from device into local file"""
if not destination:
destination = filename
log.info('Transferring %s to %s', filename, destination)
data = self.download_file(filename)
# Just in case, the filename may cont... | def read_file(self, filename, destination=''):
"""reading data from device into local file"""
if not destination:
destination = filename
log.info('Transferring %s to %s', filename, destination)
data = self.download_file(filename)
# Just in case, the filename may cont... | [
"reading",
"data",
"from",
"device",
"into",
"local",
"file"
] | kmpm/nodemcu-uploader | python | https://github.com/kmpm/nodemcu-uploader/blob/557a25f37b1fb4e31a745719e237e42fff192834/nodemcu_uploader/uploader.py#L244-L260 | [
"def",
"read_file",
"(",
"self",
",",
"filename",
",",
"destination",
"=",
"''",
")",
":",
"if",
"not",
"destination",
":",
"destination",
"=",
"filename",
"log",
".",
"info",
"(",
"'Transferring %s to %s'",
",",
"filename",
",",
"destination",
")",
"data",
... | 557a25f37b1fb4e31a745719e237e42fff192834 |
valid | Uploader.write_file | sends a file to the device using the transfer protocol | nodemcu_uploader/uploader.py | def write_file(self, path, destination='', verify='none'):
"""sends a file to the device using the transfer protocol"""
filename = os.path.basename(path)
if not destination:
destination = filename
log.info('Transferring %s as %s', path, destination)
self.__writeln("r... | def write_file(self, path, destination='', verify='none'):
"""sends a file to the device using the transfer protocol"""
filename = os.path.basename(path)
if not destination:
destination = filename
log.info('Transferring %s as %s', path, destination)
self.__writeln("r... | [
"sends",
"a",
"file",
"to",
"the",
"device",
"using",
"the",
"transfer",
"protocol"
] | kmpm/nodemcu-uploader | python | https://github.com/kmpm/nodemcu-uploader/blob/557a25f37b1fb4e31a745719e237e42fff192834/nodemcu_uploader/uploader.py#L262-L304 | [
"def",
"write_file",
"(",
"self",
",",
"path",
",",
"destination",
"=",
"''",
",",
"verify",
"=",
"'none'",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"path",
")",
"if",
"not",
"destination",
":",
"destination",
"=",
"filename"... | 557a25f37b1fb4e31a745719e237e42fff192834 |
valid | Uploader.verify_file | Tries to verify if path has same checksum as destination.
Valid options for verify is 'raw', 'sha1' or 'none' | nodemcu_uploader/uploader.py | def verify_file(self, path, destination, verify='none'):
"""Tries to verify if path has same checksum as destination.
Valid options for verify is 'raw', 'sha1' or 'none'
"""
content = from_file(path)
log.info('Verifying using %s...' % verify)
if verify == 'raw':
... | def verify_file(self, path, destination, verify='none'):
"""Tries to verify if path has same checksum as destination.
Valid options for verify is 'raw', 'sha1' or 'none'
"""
content = from_file(path)
log.info('Verifying using %s...' % verify)
if verify == 'raw':
... | [
"Tries",
"to",
"verify",
"if",
"path",
"has",
"same",
"checksum",
"as",
"destination",
".",
"Valid",
"options",
"for",
"verify",
"is",
"raw",
"sha1",
"or",
"none"
] | kmpm/nodemcu-uploader | python | https://github.com/kmpm/nodemcu-uploader/blob/557a25f37b1fb4e31a745719e237e42fff192834/nodemcu_uploader/uploader.py#L306-L335 | [
"def",
"verify_file",
"(",
"self",
",",
"path",
",",
"destination",
",",
"verify",
"=",
"'none'",
")",
":",
"content",
"=",
"from_file",
"(",
"path",
")",
"log",
".",
"info",
"(",
"'Verifying using %s...'",
"%",
"verify",
")",
"if",
"verify",
"==",
"'raw... | 557a25f37b1fb4e31a745719e237e42fff192834 |
valid | Uploader.exec_file | execute the lines in the local file 'path | nodemcu_uploader/uploader.py | def exec_file(self, path):
"""execute the lines in the local file 'path'"""
filename = os.path.basename(path)
log.info('Execute %s', filename)
content = from_file(path).replace('\r', '').split('\n')
res = '> '
for line in content:
line = line.rstrip('\n')
... | def exec_file(self, path):
"""execute the lines in the local file 'path'"""
filename = os.path.basename(path)
log.info('Execute %s', filename)
content = from_file(path).replace('\r', '').split('\n')
res = '> '
for line in content:
line = line.rstrip('\n')
... | [
"execute",
"the",
"lines",
"in",
"the",
"local",
"file",
"path"
] | kmpm/nodemcu-uploader | python | https://github.com/kmpm/nodemcu-uploader/blob/557a25f37b1fb4e31a745719e237e42fff192834/nodemcu_uploader/uploader.py#L337-L353 | [
"def",
"exec_file",
"(",
"self",
",",
"path",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"path",
")",
"log",
".",
"info",
"(",
"'Execute %s'",
",",
"filename",
")",
"content",
"=",
"from_file",
"(",
"path",
")",
".",
"replace... | 557a25f37b1fb4e31a745719e237e42fff192834 |
valid | Uploader.__got_ack | Returns true if ACK is received | nodemcu_uploader/uploader.py | def __got_ack(self):
"""Returns true if ACK is received"""
log.debug('waiting for ack')
res = self._port.read(1)
log.debug('ack read %s', hexify(res))
return res == ACK | def __got_ack(self):
"""Returns true if ACK is received"""
log.debug('waiting for ack')
res = self._port.read(1)
log.debug('ack read %s', hexify(res))
return res == ACK | [
"Returns",
"true",
"if",
"ACK",
"is",
"received"
] | kmpm/nodemcu-uploader | python | https://github.com/kmpm/nodemcu-uploader/blob/557a25f37b1fb4e31a745719e237e42fff192834/nodemcu_uploader/uploader.py#L355-L360 | [
"def",
"__got_ack",
"(",
"self",
")",
":",
"log",
".",
"debug",
"(",
"'waiting for ack'",
")",
"res",
"=",
"self",
".",
"_port",
".",
"read",
"(",
"1",
")",
"log",
".",
"debug",
"(",
"'ack read %s'",
",",
"hexify",
"(",
"res",
")",
")",
"return",
"... | 557a25f37b1fb4e31a745719e237e42fff192834 |
valid | Uploader.write_lines | write lines, one by one, separated by \n to device | nodemcu_uploader/uploader.py | def write_lines(self, data):
"""write lines, one by one, separated by \n to device"""
lines = data.replace('\r', '').split('\n')
for line in lines:
self.__exchange(line) | def write_lines(self, data):
"""write lines, one by one, separated by \n to device"""
lines = data.replace('\r', '').split('\n')
for line in lines:
self.__exchange(line) | [
"write",
"lines",
"one",
"by",
"one",
"separated",
"by",
"\\",
"n",
"to",
"device"
] | kmpm/nodemcu-uploader | python | https://github.com/kmpm/nodemcu-uploader/blob/557a25f37b1fb4e31a745719e237e42fff192834/nodemcu_uploader/uploader.py#L362-L366 | [
"def",
"write_lines",
"(",
"self",
",",
"data",
")",
":",
"lines",
"=",
"data",
".",
"replace",
"(",
"'\\r'",
",",
"''",
")",
".",
"split",
"(",
"'\\n'",
")",
"for",
"line",
"in",
"lines",
":",
"self",
".",
"__exchange",
"(",
"line",
")"
] | 557a25f37b1fb4e31a745719e237e42fff192834 |
valid | Uploader.__write_chunk | formats and sends a chunk of data to the device according
to transfer protocol | nodemcu_uploader/uploader.py | def __write_chunk(self, chunk):
"""formats and sends a chunk of data to the device according
to transfer protocol"""
log.debug('writing %d bytes chunk', len(chunk))
data = BLOCK_START + chr(len(chunk)) + chunk
if len(chunk) < 128:
padding = 128 - len(chunk)
... | def __write_chunk(self, chunk):
"""formats and sends a chunk of data to the device according
to transfer protocol"""
log.debug('writing %d bytes chunk', len(chunk))
data = BLOCK_START + chr(len(chunk)) + chunk
if len(chunk) < 128:
padding = 128 - len(chunk)
... | [
"formats",
"and",
"sends",
"a",
"chunk",
"of",
"data",
"to",
"the",
"device",
"according",
"to",
"transfer",
"protocol"
] | kmpm/nodemcu-uploader | python | https://github.com/kmpm/nodemcu-uploader/blob/557a25f37b1fb4e31a745719e237e42fff192834/nodemcu_uploader/uploader.py#L368-L380 | [
"def",
"__write_chunk",
"(",
"self",
",",
"chunk",
")",
":",
"log",
".",
"debug",
"(",
"'writing %d bytes chunk'",
",",
"len",
"(",
"chunk",
")",
")",
"data",
"=",
"BLOCK_START",
"+",
"chr",
"(",
"len",
"(",
"chunk",
")",
")",
"+",
"chunk",
"if",
"le... | 557a25f37b1fb4e31a745719e237e42fff192834 |
valid | Uploader.__read_chunk | Read a chunk of data | nodemcu_uploader/uploader.py | def __read_chunk(self, buf):
"""Read a chunk of data"""
log.debug('reading chunk')
timeout_before = self._port.timeout
if SYSTEM != 'Windows':
# Checking for new data every 100us is fast enough
if self._port.timeout != MINIMAL_TIMEOUT:
self._port.t... | def __read_chunk(self, buf):
"""Read a chunk of data"""
log.debug('reading chunk')
timeout_before = self._port.timeout
if SYSTEM != 'Windows':
# Checking for new data every 100us is fast enough
if self._port.timeout != MINIMAL_TIMEOUT:
self._port.t... | [
"Read",
"a",
"chunk",
"of",
"data"
] | kmpm/nodemcu-uploader | python | https://github.com/kmpm/nodemcu-uploader/blob/557a25f37b1fb4e31a745719e237e42fff192834/nodemcu_uploader/uploader.py#L382-L406 | [
"def",
"__read_chunk",
"(",
"self",
",",
"buf",
")",
":",
"log",
".",
"debug",
"(",
"'reading chunk'",
")",
"timeout_before",
"=",
"self",
".",
"_port",
".",
"timeout",
"if",
"SYSTEM",
"!=",
"'Windows'",
":",
"# Checking for new data every 100us is fast enough",
... | 557a25f37b1fb4e31a745719e237e42fff192834 |
valid | Uploader.file_list | list files on the device | nodemcu_uploader/uploader.py | def file_list(self):
"""list files on the device"""
log.info('Listing files')
res = self.__exchange(LIST_FILES)
res = res.split('\r\n')
# skip first and last lines
res = res[1:-1]
files = []
for line in res:
files.append(line.split('\t'))
... | def file_list(self):
"""list files on the device"""
log.info('Listing files')
res = self.__exchange(LIST_FILES)
res = res.split('\r\n')
# skip first and last lines
res = res[1:-1]
files = []
for line in res:
files.append(line.split('\t'))
... | [
"list",
"files",
"on",
"the",
"device"
] | kmpm/nodemcu-uploader | python | https://github.com/kmpm/nodemcu-uploader/blob/557a25f37b1fb4e31a745719e237e42fff192834/nodemcu_uploader/uploader.py#L408-L418 | [
"def",
"file_list",
"(",
"self",
")",
":",
"log",
".",
"info",
"(",
"'Listing files'",
")",
"res",
"=",
"self",
".",
"__exchange",
"(",
"LIST_FILES",
")",
"res",
"=",
"res",
".",
"split",
"(",
"'\\r\\n'",
")",
"# skip first and last lines",
"res",
"=",
"... | 557a25f37b1fb4e31a745719e237e42fff192834 |
valid | Uploader.file_do | Execute a file on the device using 'do | nodemcu_uploader/uploader.py | def file_do(self, filename):
"""Execute a file on the device using 'do'"""
log.info('Executing '+filename)
res = self.__exchange('dofile("'+filename+'")')
log.info(res)
return res | def file_do(self, filename):
"""Execute a file on the device using 'do'"""
log.info('Executing '+filename)
res = self.__exchange('dofile("'+filename+'")')
log.info(res)
return res | [
"Execute",
"a",
"file",
"on",
"the",
"device",
"using",
"do"
] | kmpm/nodemcu-uploader | python | https://github.com/kmpm/nodemcu-uploader/blob/557a25f37b1fb4e31a745719e237e42fff192834/nodemcu_uploader/uploader.py#L420-L425 | [
"def",
"file_do",
"(",
"self",
",",
"filename",
")",
":",
"log",
".",
"info",
"(",
"'Executing '",
"+",
"filename",
")",
"res",
"=",
"self",
".",
"__exchange",
"(",
"'dofile(\"'",
"+",
"filename",
"+",
"'\")'",
")",
"log",
".",
"info",
"(",
"res",
")... | 557a25f37b1fb4e31a745719e237e42fff192834 |
valid | Uploader.file_format | Formats device filesystem | nodemcu_uploader/uploader.py | def file_format(self):
"""Formats device filesystem"""
log.info('Formating, can take minutes depending on flash size...')
res = self.__exchange('file.format()', timeout=300)
if 'format done' not in res:
log.error(res)
else:
log.info(res)
return res | def file_format(self):
"""Formats device filesystem"""
log.info('Formating, can take minutes depending on flash size...')
res = self.__exchange('file.format()', timeout=300)
if 'format done' not in res:
log.error(res)
else:
log.info(res)
return res | [
"Formats",
"device",
"filesystem"
] | kmpm/nodemcu-uploader | python | https://github.com/kmpm/nodemcu-uploader/blob/557a25f37b1fb4e31a745719e237e42fff192834/nodemcu_uploader/uploader.py#L427-L435 | [
"def",
"file_format",
"(",
"self",
")",
":",
"log",
".",
"info",
"(",
"'Formating, can take minutes depending on flash size...'",
")",
"res",
"=",
"self",
".",
"__exchange",
"(",
"'file.format()'",
",",
"timeout",
"=",
"300",
")",
"if",
"'format done'",
"not",
"... | 557a25f37b1fb4e31a745719e237e42fff192834 |
valid | Uploader.file_print | Prints a file on the device to console | nodemcu_uploader/uploader.py | def file_print(self, filename):
"""Prints a file on the device to console"""
log.info('Printing ' + filename)
res = self.__exchange(PRINT_FILE.format(filename=filename))
log.info(res)
return res | def file_print(self, filename):
"""Prints a file on the device to console"""
log.info('Printing ' + filename)
res = self.__exchange(PRINT_FILE.format(filename=filename))
log.info(res)
return res | [
"Prints",
"a",
"file",
"on",
"the",
"device",
"to",
"console"
] | kmpm/nodemcu-uploader | python | https://github.com/kmpm/nodemcu-uploader/blob/557a25f37b1fb4e31a745719e237e42fff192834/nodemcu_uploader/uploader.py#L437-L442 | [
"def",
"file_print",
"(",
"self",
",",
"filename",
")",
":",
"log",
".",
"info",
"(",
"'Printing '",
"+",
"filename",
")",
"res",
"=",
"self",
".",
"__exchange",
"(",
"PRINT_FILE",
".",
"format",
"(",
"filename",
"=",
"filename",
")",
")",
"log",
".",
... | 557a25f37b1fb4e31a745719e237e42fff192834 |
valid | Uploader.node_heap | Show device heap size | nodemcu_uploader/uploader.py | def node_heap(self):
"""Show device heap size"""
log.info('Heap')
res = self.__exchange('print(node.heap())')
log.info(res)
return int(res.split('\r\n')[1]) | def node_heap(self):
"""Show device heap size"""
log.info('Heap')
res = self.__exchange('print(node.heap())')
log.info(res)
return int(res.split('\r\n')[1]) | [
"Show",
"device",
"heap",
"size"
] | kmpm/nodemcu-uploader | python | https://github.com/kmpm/nodemcu-uploader/blob/557a25f37b1fb4e31a745719e237e42fff192834/nodemcu_uploader/uploader.py#L444-L449 | [
"def",
"node_heap",
"(",
"self",
")",
":",
"log",
".",
"info",
"(",
"'Heap'",
")",
"res",
"=",
"self",
".",
"__exchange",
"(",
"'print(node.heap())'",
")",
"log",
".",
"info",
"(",
"res",
")",
"return",
"int",
"(",
"res",
".",
"split",
"(",
"'\\r\\n'... | 557a25f37b1fb4e31a745719e237e42fff192834 |
valid | Uploader.node_restart | Restarts device | nodemcu_uploader/uploader.py | def node_restart(self):
"""Restarts device"""
log.info('Restart')
res = self.__exchange('node.restart()')
log.info(res)
return res | def node_restart(self):
"""Restarts device"""
log.info('Restart')
res = self.__exchange('node.restart()')
log.info(res)
return res | [
"Restarts",
"device"
] | kmpm/nodemcu-uploader | python | https://github.com/kmpm/nodemcu-uploader/blob/557a25f37b1fb4e31a745719e237e42fff192834/nodemcu_uploader/uploader.py#L451-L456 | [
"def",
"node_restart",
"(",
"self",
")",
":",
"log",
".",
"info",
"(",
"'Restart'",
")",
"res",
"=",
"self",
".",
"__exchange",
"(",
"'node.restart()'",
")",
"log",
".",
"info",
"(",
"res",
")",
"return",
"res"
] | 557a25f37b1fb4e31a745719e237e42fff192834 |
valid | Uploader.file_compile | Compiles a file specified by path on the device | nodemcu_uploader/uploader.py | def file_compile(self, path):
"""Compiles a file specified by path on the device"""
log.info('Compile '+path)
cmd = 'node.compile("%s")' % path
res = self.__exchange(cmd)
log.info(res)
return res | def file_compile(self, path):
"""Compiles a file specified by path on the device"""
log.info('Compile '+path)
cmd = 'node.compile("%s")' % path
res = self.__exchange(cmd)
log.info(res)
return res | [
"Compiles",
"a",
"file",
"specified",
"by",
"path",
"on",
"the",
"device"
] | kmpm/nodemcu-uploader | python | https://github.com/kmpm/nodemcu-uploader/blob/557a25f37b1fb4e31a745719e237e42fff192834/nodemcu_uploader/uploader.py#L458-L464 | [
"def",
"file_compile",
"(",
"self",
",",
"path",
")",
":",
"log",
".",
"info",
"(",
"'Compile '",
"+",
"path",
")",
"cmd",
"=",
"'node.compile(\"%s\")'",
"%",
"path",
"res",
"=",
"self",
".",
"__exchange",
"(",
"cmd",
")",
"log",
".",
"info",
"(",
"r... | 557a25f37b1fb4e31a745719e237e42fff192834 |
valid | Uploader.file_remove | Removes a file on the device | nodemcu_uploader/uploader.py | def file_remove(self, path):
"""Removes a file on the device"""
log.info('Remove '+path)
cmd = 'file.remove("%s")' % path
res = self.__exchange(cmd)
log.info(res)
return res | def file_remove(self, path):
"""Removes a file on the device"""
log.info('Remove '+path)
cmd = 'file.remove("%s")' % path
res = self.__exchange(cmd)
log.info(res)
return res | [
"Removes",
"a",
"file",
"on",
"the",
"device"
] | kmpm/nodemcu-uploader | python | https://github.com/kmpm/nodemcu-uploader/blob/557a25f37b1fb4e31a745719e237e42fff192834/nodemcu_uploader/uploader.py#L466-L472 | [
"def",
"file_remove",
"(",
"self",
",",
"path",
")",
":",
"log",
".",
"info",
"(",
"'Remove '",
"+",
"path",
")",
"cmd",
"=",
"'file.remove(\"%s\")'",
"%",
"path",
"res",
"=",
"self",
".",
"__exchange",
"(",
"cmd",
")",
"log",
".",
"info",
"(",
"res"... | 557a25f37b1fb4e31a745719e237e42fff192834 |
valid | Uploader.backup | Backup all files from the device | nodemcu_uploader/uploader.py | def backup(self, path):
"""Backup all files from the device"""
log.info('Backing up in '+path)
# List file to backup
files = self.file_list()
# then download each of then
self.prepare()
for f in files:
self.read_file(f[0], os.path.join(path, f[0])) | def backup(self, path):
"""Backup all files from the device"""
log.info('Backing up in '+path)
# List file to backup
files = self.file_list()
# then download each of then
self.prepare()
for f in files:
self.read_file(f[0], os.path.join(path, f[0])) | [
"Backup",
"all",
"files",
"from",
"the",
"device"
] | kmpm/nodemcu-uploader | python | https://github.com/kmpm/nodemcu-uploader/blob/557a25f37b1fb4e31a745719e237e42fff192834/nodemcu_uploader/uploader.py#L474-L482 | [
"def",
"backup",
"(",
"self",
",",
"path",
")",
":",
"log",
".",
"info",
"(",
"'Backing up in '",
"+",
"path",
")",
"# List file to backup",
"files",
"=",
"self",
".",
"file_list",
"(",
")",
"# then download each of then",
"self",
".",
"prepare",
"(",
")",
... | 557a25f37b1fb4e31a745719e237e42fff192834 |
valid | destination_from_source | Split each of the sources in the array on ':'
First part will be source, second will be destination.
Modifies the the original array to contain only sources
and returns an array of destinations. | nodemcu_uploader/main.py | def destination_from_source(sources, use_glob=True):
"""
Split each of the sources in the array on ':'
First part will be source, second will be destination.
Modifies the the original array to contain only sources
and returns an array of destinations.
"""
destinations = []
newsources = [... | def destination_from_source(sources, use_glob=True):
"""
Split each of the sources in the array on ':'
First part will be source, second will be destination.
Modifies the the original array to contain only sources
and returns an array of destinations.
"""
destinations = []
newsources = [... | [
"Split",
"each",
"of",
"the",
"sources",
"in",
"the",
"array",
"on",
":",
"First",
"part",
"will",
"be",
"source",
"second",
"will",
"be",
"destination",
".",
"Modifies",
"the",
"the",
"original",
"array",
"to",
"contain",
"only",
"sources",
"and",
"return... | kmpm/nodemcu-uploader | python | https://github.com/kmpm/nodemcu-uploader/blob/557a25f37b1fb4e31a745719e237e42fff192834/nodemcu_uploader/main.py#L20-L45 | [
"def",
"destination_from_source",
"(",
"sources",
",",
"use_glob",
"=",
"True",
")",
":",
"destinations",
"=",
"[",
"]",
"newsources",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"sources",
")",
")",
":",
"srcdst",
"=",
"sour... | 557a25f37b1fb4e31a745719e237e42fff192834 |
valid | operation_upload | The upload operation | nodemcu_uploader/main.py | def operation_upload(uploader, sources, verify, do_compile, do_file, do_restart):
"""The upload operation"""
sources, destinations = destination_from_source(sources)
if len(destinations) == len(sources):
if uploader.prepare():
for filename, dst in zip(sources, destinations):
... | def operation_upload(uploader, sources, verify, do_compile, do_file, do_restart):
"""The upload operation"""
sources, destinations = destination_from_source(sources)
if len(destinations) == len(sources):
if uploader.prepare():
for filename, dst in zip(sources, destinations):
... | [
"The",
"upload",
"operation"
] | kmpm/nodemcu-uploader | python | https://github.com/kmpm/nodemcu-uploader/blob/557a25f37b1fb4e31a745719e237e42fff192834/nodemcu_uploader/main.py#L48-L72 | [
"def",
"operation_upload",
"(",
"uploader",
",",
"sources",
",",
"verify",
",",
"do_compile",
",",
"do_file",
",",
"do_restart",
")",
":",
"sources",
",",
"destinations",
"=",
"destination_from_source",
"(",
"sources",
")",
"if",
"len",
"(",
"destinations",
")... | 557a25f37b1fb4e31a745719e237e42fff192834 |
valid | operation_download | The download operation | nodemcu_uploader/main.py | def operation_download(uploader, sources):
"""The download operation"""
sources, destinations = destination_from_source(sources, False)
print('sources', sources)
print('destinations', destinations)
if len(destinations) == len(sources):
if uploader.prepare():
for filename, dst in ... | def operation_download(uploader, sources):
"""The download operation"""
sources, destinations = destination_from_source(sources, False)
print('sources', sources)
print('destinations', destinations)
if len(destinations) == len(sources):
if uploader.prepare():
for filename, dst in ... | [
"The",
"download",
"operation"
] | kmpm/nodemcu-uploader | python | https://github.com/kmpm/nodemcu-uploader/blob/557a25f37b1fb4e31a745719e237e42fff192834/nodemcu_uploader/main.py#L75-L86 | [
"def",
"operation_download",
"(",
"uploader",
",",
"sources",
")",
":",
"sources",
",",
"destinations",
"=",
"destination_from_source",
"(",
"sources",
",",
"False",
")",
"print",
"(",
"'sources'",
",",
"sources",
")",
"print",
"(",
"'destinations'",
",",
"des... | 557a25f37b1fb4e31a745719e237e42fff192834 |
valid | operation_list | List file on target | nodemcu_uploader/main.py | def operation_list(uploader):
"""List file on target"""
files = uploader.file_list()
for f in files:
log.info("{file:30s} {size}".format(file=f[0], size=f[1])) | def operation_list(uploader):
"""List file on target"""
files = uploader.file_list()
for f in files:
log.info("{file:30s} {size}".format(file=f[0], size=f[1])) | [
"List",
"file",
"on",
"target"
] | kmpm/nodemcu-uploader | python | https://github.com/kmpm/nodemcu-uploader/blob/557a25f37b1fb4e31a745719e237e42fff192834/nodemcu_uploader/main.py#L88-L92 | [
"def",
"operation_list",
"(",
"uploader",
")",
":",
"files",
"=",
"uploader",
".",
"file_list",
"(",
")",
"for",
"f",
"in",
"files",
":",
"log",
".",
"info",
"(",
"\"{file:30s} {size}\"",
".",
"format",
"(",
"file",
"=",
"f",
"[",
"0",
"]",
",",
"siz... | 557a25f37b1fb4e31a745719e237e42fff192834 |
valid | operation_file | File operations | nodemcu_uploader/main.py | def operation_file(uploader, cmd, filename=''):
"""File operations"""
if cmd == 'list':
operation_list(uploader)
if cmd == 'do':
for path in filename:
uploader.file_do(path)
elif cmd == 'format':
uploader.file_format()
elif cmd == 'remove':
for path in fil... | def operation_file(uploader, cmd, filename=''):
"""File operations"""
if cmd == 'list':
operation_list(uploader)
if cmd == 'do':
for path in filename:
uploader.file_do(path)
elif cmd == 'format':
uploader.file_format()
elif cmd == 'remove':
for path in fil... | [
"File",
"operations"
] | kmpm/nodemcu-uploader | python | https://github.com/kmpm/nodemcu-uploader/blob/557a25f37b1fb4e31a745719e237e42fff192834/nodemcu_uploader/main.py#L94-L108 | [
"def",
"operation_file",
"(",
"uploader",
",",
"cmd",
",",
"filename",
"=",
"''",
")",
":",
"if",
"cmd",
"==",
"'list'",
":",
"operation_list",
"(",
"uploader",
")",
"if",
"cmd",
"==",
"'do'",
":",
"for",
"path",
"in",
"filename",
":",
"uploader",
".",... | 557a25f37b1fb4e31a745719e237e42fff192834 |
valid | main_func | Main function for cli | nodemcu_uploader/main.py | def main_func():
"""Main function for cli"""
parser = argparse.ArgumentParser(
description='NodeMCU Lua file uploader',
prog='nodemcu-uploader'
)
parser.add_argument(
'--verbose',
help='verbose output',
action='store_true',
default=False)
parser.... | def main_func():
"""Main function for cli"""
parser = argparse.ArgumentParser(
description='NodeMCU Lua file uploader',
prog='nodemcu-uploader'
)
parser.add_argument(
'--verbose',
help='verbose output',
action='store_true',
default=False)
parser.... | [
"Main",
"function",
"for",
"cli"
] | kmpm/nodemcu-uploader | python | https://github.com/kmpm/nodemcu-uploader/blob/557a25f37b1fb4e31a745719e237e42fff192834/nodemcu_uploader/main.py#L117-L301 | [
"def",
"main_func",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'NodeMCU Lua file uploader'",
",",
"prog",
"=",
"'nodemcu-uploader'",
")",
"parser",
".",
"add_argument",
"(",
"'--verbose'",
",",
"help",
"=",
"'verbo... | 557a25f37b1fb4e31a745719e237e42fff192834 |
valid | display | Display a widget, text or other media in a notebook without the need to import IPython at the top level.
Also handles wrapping GenePattern Python Library content in widgets.
:param content:
:return: | genepattern/remote_widgets.py | def display(content):
"""
Display a widget, text or other media in a notebook without the need to import IPython at the top level.
Also handles wrapping GenePattern Python Library content in widgets.
:param content:
:return:
"""
if isinstance(content, gp.GPServer):
IPython.display.d... | def display(content):
"""
Display a widget, text or other media in a notebook without the need to import IPython at the top level.
Also handles wrapping GenePattern Python Library content in widgets.
:param content:
:return:
"""
if isinstance(content, gp.GPServer):
IPython.display.d... | [
"Display",
"a",
"widget",
"text",
"or",
"other",
"media",
"in",
"a",
"notebook",
"without",
"the",
"need",
"to",
"import",
"IPython",
"at",
"the",
"top",
"level",
"."
] | genepattern/genepattern-notebook | python | https://github.com/genepattern/genepattern-notebook/blob/953168bd08c5332412438cbc5bb59993a07a6911/genepattern/remote_widgets.py#L185-L200 | [
"def",
"display",
"(",
"content",
")",
":",
"if",
"isinstance",
"(",
"content",
",",
"gp",
".",
"GPServer",
")",
":",
"IPython",
".",
"display",
".",
"display",
"(",
"GPAuthWidget",
"(",
"content",
")",
")",
"elif",
"isinstance",
"(",
"content",
",",
"... | 953168bd08c5332412438cbc5bb59993a07a6911 |
valid | SessionList.register | Register a new GenePattern server session for the provided
server, username and password. Return the session.
:param server:
:param username:
:param password:
:return: | genepattern/remote_widgets.py | def register(self, server, username, password):
"""
Register a new GenePattern server session for the provided
server, username and password. Return the session.
:param server:
:param username:
:param password:
:return:
"""
# Create the session
... | def register(self, server, username, password):
"""
Register a new GenePattern server session for the provided
server, username and password. Return the session.
:param server:
:param username:
:param password:
:return:
"""
# Create the session
... | [
"Register",
"a",
"new",
"GenePattern",
"server",
"session",
"for",
"the",
"provided",
"server",
"username",
"and",
"password",
".",
"Return",
"the",
"session",
".",
":",
"param",
"server",
":",
":",
"param",
"username",
":",
":",
"param",
"password",
":",
... | genepattern/genepattern-notebook | python | https://github.com/genepattern/genepattern-notebook/blob/953168bd08c5332412438cbc5bb59993a07a6911/genepattern/remote_widgets.py#L23-L51 | [
"def",
"register",
"(",
"self",
",",
"server",
",",
"username",
",",
"password",
")",
":",
"# Create the session",
"session",
"=",
"gp",
".",
"GPServer",
"(",
"server",
",",
"username",
",",
"password",
")",
"# Validate username if not empty",
"valid_username",
... | 953168bd08c5332412438cbc5bb59993a07a6911 |
valid | SessionList.get | Returns a registered GPServer object with a matching GenePattern server url or index
Returns None if no matching result was found
:param server:
:return: | genepattern/remote_widgets.py | def get(self, server):
"""
Returns a registered GPServer object with a matching GenePattern server url or index
Returns None if no matching result was found
:param server:
:return:
"""
# Handle indexes
if isinstance(server, int):
if server >= ... | def get(self, server):
"""
Returns a registered GPServer object with a matching GenePattern server url or index
Returns None if no matching result was found
:param server:
:return:
"""
# Handle indexes
if isinstance(server, int):
if server >= ... | [
"Returns",
"a",
"registered",
"GPServer",
"object",
"with",
"a",
"matching",
"GenePattern",
"server",
"url",
"or",
"index",
"Returns",
"None",
"if",
"no",
"matching",
"result",
"was",
"found",
":",
"param",
"server",
":",
":",
"return",
":"
] | genepattern/genepattern-notebook | python | https://github.com/genepattern/genepattern-notebook/blob/953168bd08c5332412438cbc5bb59993a07a6911/genepattern/remote_widgets.py#L53-L73 | [
"def",
"get",
"(",
"self",
",",
"server",
")",
":",
"# Handle indexes",
"if",
"isinstance",
"(",
"server",
",",
"int",
")",
":",
"if",
"server",
">=",
"len",
"(",
"self",
".",
"sessions",
")",
":",
"return",
"None",
"else",
":",
"return",
"self",
"."... | 953168bd08c5332412438cbc5bb59993a07a6911 |
valid | SessionList._get_index | Returns a registered GPServer object with a matching GenePattern server url
Returns -1 if no matching result was found
:param server_url:
:return: | genepattern/remote_widgets.py | def _get_index(self, server_url):
"""
Returns a registered GPServer object with a matching GenePattern server url
Returns -1 if no matching result was found
:param server_url:
:return:
"""
for i in range(len(self.sessions)):
session = self.sessions[i]
... | def _get_index(self, server_url):
"""
Returns a registered GPServer object with a matching GenePattern server url
Returns -1 if no matching result was found
:param server_url:
:return:
"""
for i in range(len(self.sessions)):
session = self.sessions[i]
... | [
"Returns",
"a",
"registered",
"GPServer",
"object",
"with",
"a",
"matching",
"GenePattern",
"server",
"url",
"Returns",
"-",
"1",
"if",
"no",
"matching",
"result",
"was",
"found",
":",
"param",
"server_url",
":",
":",
"return",
":"
] | genepattern/genepattern-notebook | python | https://github.com/genepattern/genepattern-notebook/blob/953168bd08c5332412438cbc5bb59993a07a6911/genepattern/remote_widgets.py#L82-L93 | [
"def",
"_get_index",
"(",
"self",
",",
"server_url",
")",
":",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"sessions",
")",
")",
":",
"session",
"=",
"self",
".",
"sessions",
"[",
"i",
"]",
"if",
"session",
".",
"url",
"==",
"server_ur... | 953168bd08c5332412438cbc5bb59993a07a6911 |
valid | Timer._accept | Accept None or ∞ or datetime or numeric for target | tempora/timing.py | def _accept(self, target):
"Accept None or ∞ or datetime or numeric for target"
if isinstance(target, datetime.timedelta):
target = target.total_seconds()
if target is None:
# treat None as infinite target
target = float('Inf')
return target | def _accept(self, target):
"Accept None or ∞ or datetime or numeric for target"
if isinstance(target, datetime.timedelta):
target = target.total_seconds()
if target is None:
# treat None as infinite target
target = float('Inf')
return target | [
"Accept",
"None",
"or",
"∞",
"or",
"datetime",
"or",
"numeric",
"for",
"target"
] | jaraco/tempora | python | https://github.com/jaraco/tempora/blob/f0a9ab636103fe829aa9b495c93f5249aac5f2b8/tempora/timing.py#L122-L131 | [
"def",
"_accept",
"(",
"self",
",",
"target",
")",
":",
"if",
"isinstance",
"(",
"target",
",",
"datetime",
".",
"timedelta",
")",
":",
"target",
"=",
"target",
".",
"total_seconds",
"(",
")",
"if",
"target",
"is",
"None",
":",
"# treat None as infinite ta... | f0a9ab636103fe829aa9b495c93f5249aac5f2b8 |
valid | from_timestamp | Convert a numeric timestamp to a timezone-aware datetime.
A client may override this function to change the default behavior,
such as to use local time or timezone-naïve times. | tempora/schedule.py | def from_timestamp(ts):
"""
Convert a numeric timestamp to a timezone-aware datetime.
A client may override this function to change the default behavior,
such as to use local time or timezone-naïve times.
"""
return datetime.datetime.utcfromtimestamp(ts).replace(tzinfo=pytz.utc) | def from_timestamp(ts):
"""
Convert a numeric timestamp to a timezone-aware datetime.
A client may override this function to change the default behavior,
such as to use local time or timezone-naïve times.
"""
return datetime.datetime.utcfromtimestamp(ts).replace(tzinfo=pytz.utc) | [
"Convert",
"a",
"numeric",
"timestamp",
"to",
"a",
"timezone",
"-",
"aware",
"datetime",
"."
] | jaraco/tempora | python | https://github.com/jaraco/tempora/blob/f0a9ab636103fe829aa9b495c93f5249aac5f2b8/tempora/schedule.py#L29-L36 | [
"def",
"from_timestamp",
"(",
"ts",
")",
":",
"return",
"datetime",
".",
"datetime",
".",
"utcfromtimestamp",
"(",
"ts",
")",
".",
"replace",
"(",
"tzinfo",
"=",
"pytz",
".",
"utc",
")"
] | f0a9ab636103fe829aa9b495c93f5249aac5f2b8 |
valid | DelayedCommand.at_time | Construct a DelayedCommand to come due at `at`, where `at` may be
a datetime or timestamp. | tempora/schedule.py | def at_time(cls, at, target):
"""
Construct a DelayedCommand to come due at `at`, where `at` may be
a datetime or timestamp.
"""
at = cls._from_timestamp(at)
cmd = cls.from_datetime(at)
cmd.delay = at - now()
cmd.target = target
return cmd | def at_time(cls, at, target):
"""
Construct a DelayedCommand to come due at `at`, where `at` may be
a datetime or timestamp.
"""
at = cls._from_timestamp(at)
cmd = cls.from_datetime(at)
cmd.delay = at - now()
cmd.target = target
return cmd | [
"Construct",
"a",
"DelayedCommand",
"to",
"come",
"due",
"at",
"at",
"where",
"at",
"may",
"be",
"a",
"datetime",
"or",
"timestamp",
"."
] | jaraco/tempora | python | https://github.com/jaraco/tempora/blob/f0a9ab636103fe829aa9b495c93f5249aac5f2b8/tempora/schedule.py#L74-L83 | [
"def",
"at_time",
"(",
"cls",
",",
"at",
",",
"target",
")",
":",
"at",
"=",
"cls",
".",
"_from_timestamp",
"(",
"at",
")",
"cmd",
"=",
"cls",
".",
"from_datetime",
"(",
"at",
")",
"cmd",
".",
"delay",
"=",
"at",
"-",
"now",
"(",
")",
"cmd",
".... | f0a9ab636103fe829aa9b495c93f5249aac5f2b8 |
valid | PeriodicCommand._localize | Rely on pytz.localize to ensure new result honors DST. | tempora/schedule.py | def _localize(dt):
"""
Rely on pytz.localize to ensure new result honors DST.
"""
try:
tz = dt.tzinfo
return tz.localize(dt.replace(tzinfo=None))
except AttributeError:
return dt | def _localize(dt):
"""
Rely on pytz.localize to ensure new result honors DST.
"""
try:
tz = dt.tzinfo
return tz.localize(dt.replace(tzinfo=None))
except AttributeError:
return dt | [
"Rely",
"on",
"pytz",
".",
"localize",
"to",
"ensure",
"new",
"result",
"honors",
"DST",
"."
] | jaraco/tempora | python | https://github.com/jaraco/tempora/blob/f0a9ab636103fe829aa9b495c93f5249aac5f2b8/tempora/schedule.py#L101-L109 | [
"def",
"_localize",
"(",
"dt",
")",
":",
"try",
":",
"tz",
"=",
"dt",
".",
"tzinfo",
"return",
"tz",
".",
"localize",
"(",
"dt",
".",
"replace",
"(",
"tzinfo",
"=",
"None",
")",
")",
"except",
"AttributeError",
":",
"return",
"dt"
] | f0a9ab636103fe829aa9b495c93f5249aac5f2b8 |
valid | PeriodicCommandFixedDelay.daily_at | Schedule a command to run at a specific time each day. | tempora/schedule.py | def daily_at(cls, at, target):
"""
Schedule a command to run at a specific time each day.
"""
daily = datetime.timedelta(days=1)
# convert when to the next datetime matching this time
when = datetime.datetime.combine(datetime.date.today(), at)
if when < now():
... | def daily_at(cls, at, target):
"""
Schedule a command to run at a specific time each day.
"""
daily = datetime.timedelta(days=1)
# convert when to the next datetime matching this time
when = datetime.datetime.combine(datetime.date.today(), at)
if when < now():
... | [
"Schedule",
"a",
"command",
"to",
"run",
"at",
"a",
"specific",
"time",
"each",
"day",
"."
] | jaraco/tempora | python | https://github.com/jaraco/tempora/blob/f0a9ab636103fe829aa9b495c93f5249aac5f2b8/tempora/schedule.py#L144-L153 | [
"def",
"daily_at",
"(",
"cls",
",",
"at",
",",
"target",
")",
":",
"daily",
"=",
"datetime",
".",
"timedelta",
"(",
"days",
"=",
"1",
")",
"# convert when to the next datetime matching this time",
"when",
"=",
"datetime",
".",
"datetime",
".",
"combine",
"(",
... | f0a9ab636103fe829aa9b495c93f5249aac5f2b8 |
valid | strftime | A class to replace the strftime in datetime package or time module.
Identical to strftime behavior in those modules except supports any
year.
Also supports datetime.datetime times.
Also supports milliseconds using %s
Also supports microseconds using %u | tempora/__init__.py | def strftime(fmt, t):
"""A class to replace the strftime in datetime package or time module.
Identical to strftime behavior in those modules except supports any
year.
Also supports datetime.datetime times.
Also supports milliseconds using %s
Also supports microseconds using %u"""
if isinstance(t, (time.struct_ti... | def strftime(fmt, t):
"""A class to replace the strftime in datetime package or time module.
Identical to strftime behavior in those modules except supports any
year.
Also supports datetime.datetime times.
Also supports milliseconds using %s
Also supports microseconds using %u"""
if isinstance(t, (time.struct_ti... | [
"A",
"class",
"to",
"replace",
"the",
"strftime",
"in",
"datetime",
"package",
"or",
"time",
"module",
".",
"Identical",
"to",
"strftime",
"behavior",
"in",
"those",
"modules",
"except",
"supports",
"any",
"year",
".",
"Also",
"supports",
"datetime",
".",
"d... | jaraco/tempora | python | https://github.com/jaraco/tempora/blob/f0a9ab636103fe829aa9b495c93f5249aac5f2b8/tempora/__init__.py#L97-L127 | [
"def",
"strftime",
"(",
"fmt",
",",
"t",
")",
":",
"if",
"isinstance",
"(",
"t",
",",
"(",
"time",
".",
"struct_time",
",",
"tuple",
")",
")",
":",
"t",
"=",
"datetime",
".",
"datetime",
"(",
"*",
"t",
"[",
":",
"6",
"]",
")",
"assert",
"isinst... | f0a9ab636103fe829aa9b495c93f5249aac5f2b8 |
valid | strptime | A function to replace strptime in the time module. Should behave
identically to the strptime function except it returns a datetime.datetime
object instead of a time.struct_time object.
Also takes an optional tzinfo parameter which is a time zone info object. | tempora/__init__.py | def strptime(s, fmt, tzinfo=None):
"""
A function to replace strptime in the time module. Should behave
identically to the strptime function except it returns a datetime.datetime
object instead of a time.struct_time object.
Also takes an optional tzinfo parameter which is a time zone info object.
"""
res = time... | def strptime(s, fmt, tzinfo=None):
"""
A function to replace strptime in the time module. Should behave
identically to the strptime function except it returns a datetime.datetime
object instead of a time.struct_time object.
Also takes an optional tzinfo parameter which is a time zone info object.
"""
res = time... | [
"A",
"function",
"to",
"replace",
"strptime",
"in",
"the",
"time",
"module",
".",
"Should",
"behave",
"identically",
"to",
"the",
"strptime",
"function",
"except",
"it",
"returns",
"a",
"datetime",
".",
"datetime",
"object",
"instead",
"of",
"a",
"time",
"."... | jaraco/tempora | python | https://github.com/jaraco/tempora/blob/f0a9ab636103fe829aa9b495c93f5249aac5f2b8/tempora/__init__.py#L130-L138 | [
"def",
"strptime",
"(",
"s",
",",
"fmt",
",",
"tzinfo",
"=",
"None",
")",
":",
"res",
"=",
"time",
".",
"strptime",
"(",
"s",
",",
"fmt",
")",
"return",
"datetime",
".",
"datetime",
"(",
"tzinfo",
"=",
"tzinfo",
",",
"*",
"res",
"[",
":",
"6",
... | f0a9ab636103fe829aa9b495c93f5249aac5f2b8 |
valid | datetime_mod | Find the time which is the specified date/time truncated to the time delta
relative to the start date/time.
By default, the start time is midnight of the same day as the specified
date/time.
>>> datetime_mod(datetime.datetime(2004, 1, 2, 3),
... datetime.timedelta(days = 1.5),
... start = datetime.dateti... | tempora/__init__.py | def datetime_mod(dt, period, start=None):
"""
Find the time which is the specified date/time truncated to the time delta
relative to the start date/time.
By default, the start time is midnight of the same day as the specified
date/time.
>>> datetime_mod(datetime.datetime(2004, 1, 2, 3),
... datetime.timedel... | def datetime_mod(dt, period, start=None):
"""
Find the time which is the specified date/time truncated to the time delta
relative to the start date/time.
By default, the start time is midnight of the same day as the specified
date/time.
>>> datetime_mod(datetime.datetime(2004, 1, 2, 3),
... datetime.timedel... | [
"Find",
"the",
"time",
"which",
"is",
"the",
"specified",
"date",
"/",
"time",
"truncated",
"to",
"the",
"time",
"delta",
"relative",
"to",
"the",
"start",
"date",
"/",
"time",
".",
"By",
"default",
"the",
"start",
"time",
"is",
"midnight",
"of",
"the",
... | jaraco/tempora | python | https://github.com/jaraco/tempora/blob/f0a9ab636103fe829aa9b495c93f5249aac5f2b8/tempora/__init__.py#L219-L259 | [
"def",
"datetime_mod",
"(",
"dt",
",",
"period",
",",
"start",
"=",
"None",
")",
":",
"if",
"start",
"is",
"None",
":",
"# use midnight of the same day",
"start",
"=",
"datetime",
".",
"datetime",
".",
"combine",
"(",
"dt",
".",
"date",
"(",
")",
",",
... | f0a9ab636103fe829aa9b495c93f5249aac5f2b8 |
valid | datetime_round | Find the nearest even period for the specified date/time.
>>> datetime_round(datetime.datetime(2004, 11, 13, 8, 11, 13),
... datetime.timedelta(hours = 1))
datetime.datetime(2004, 11, 13, 8, 0)
>>> datetime_round(datetime.datetime(2004, 11, 13, 8, 31, 13),
... datetime.timedelta(hours = 1))
datetime.date... | tempora/__init__.py | def datetime_round(dt, period, start=None):
"""
Find the nearest even period for the specified date/time.
>>> datetime_round(datetime.datetime(2004, 11, 13, 8, 11, 13),
... datetime.timedelta(hours = 1))
datetime.datetime(2004, 11, 13, 8, 0)
>>> datetime_round(datetime.datetime(2004, 11, 13, 8, 31, 13),
...... | def datetime_round(dt, period, start=None):
"""
Find the nearest even period for the specified date/time.
>>> datetime_round(datetime.datetime(2004, 11, 13, 8, 11, 13),
... datetime.timedelta(hours = 1))
datetime.datetime(2004, 11, 13, 8, 0)
>>> datetime_round(datetime.datetime(2004, 11, 13, 8, 31, 13),
...... | [
"Find",
"the",
"nearest",
"even",
"period",
"for",
"the",
"specified",
"date",
"/",
"time",
"."
] | jaraco/tempora | python | https://github.com/jaraco/tempora/blob/f0a9ab636103fe829aa9b495c93f5249aac5f2b8/tempora/__init__.py#L262-L279 | [
"def",
"datetime_round",
"(",
"dt",
",",
"period",
",",
"start",
"=",
"None",
")",
":",
"result",
"=",
"datetime_mod",
"(",
"dt",
",",
"period",
",",
"start",
")",
"if",
"abs",
"(",
"dt",
"-",
"result",
")",
">=",
"period",
"//",
"2",
":",
"result"... | f0a9ab636103fe829aa9b495c93f5249aac5f2b8 |
valid | get_nearest_year_for_day | Returns the nearest year to now inferred from a Julian date. | tempora/__init__.py | def get_nearest_year_for_day(day):
"""
Returns the nearest year to now inferred from a Julian date.
"""
now = time.gmtime()
result = now.tm_year
# if the day is far greater than today, it must be from last year
if day - now.tm_yday > 365 // 2:
result -= 1
# if the day is far less than today, it must be for ne... | def get_nearest_year_for_day(day):
"""
Returns the nearest year to now inferred from a Julian date.
"""
now = time.gmtime()
result = now.tm_year
# if the day is far greater than today, it must be from last year
if day - now.tm_yday > 365 // 2:
result -= 1
# if the day is far less than today, it must be for ne... | [
"Returns",
"the",
"nearest",
"year",
"to",
"now",
"inferred",
"from",
"a",
"Julian",
"date",
"."
] | jaraco/tempora | python | https://github.com/jaraco/tempora/blob/f0a9ab636103fe829aa9b495c93f5249aac5f2b8/tempora/__init__.py#L282-L294 | [
"def",
"get_nearest_year_for_day",
"(",
"day",
")",
":",
"now",
"=",
"time",
".",
"gmtime",
"(",
")",
"result",
"=",
"now",
".",
"tm_year",
"# if the day is far greater than today, it must be from last year",
"if",
"day",
"-",
"now",
".",
"tm_yday",
">",
"365",
... | f0a9ab636103fe829aa9b495c93f5249aac5f2b8 |
valid | gregorian_date | Gregorian Date is defined as a year and a julian day (1-based
index into the days of the year).
>>> gregorian_date(2007, 15)
datetime.date(2007, 1, 15) | tempora/__init__.py | def gregorian_date(year, julian_day):
"""
Gregorian Date is defined as a year and a julian day (1-based
index into the days of the year).
>>> gregorian_date(2007, 15)
datetime.date(2007, 1, 15)
"""
result = datetime.date(year, 1, 1)
result += datetime.timedelta(days=julian_day - 1)
return result | def gregorian_date(year, julian_day):
"""
Gregorian Date is defined as a year and a julian day (1-based
index into the days of the year).
>>> gregorian_date(2007, 15)
datetime.date(2007, 1, 15)
"""
result = datetime.date(year, 1, 1)
result += datetime.timedelta(days=julian_day - 1)
return result | [
"Gregorian",
"Date",
"is",
"defined",
"as",
"a",
"year",
"and",
"a",
"julian",
"day",
"(",
"1",
"-",
"based",
"index",
"into",
"the",
"days",
"of",
"the",
"year",
")",
"."
] | jaraco/tempora | python | https://github.com/jaraco/tempora/blob/f0a9ab636103fe829aa9b495c93f5249aac5f2b8/tempora/__init__.py#L297-L307 | [
"def",
"gregorian_date",
"(",
"year",
",",
"julian_day",
")",
":",
"result",
"=",
"datetime",
".",
"date",
"(",
"year",
",",
"1",
",",
"1",
")",
"result",
"+=",
"datetime",
".",
"timedelta",
"(",
"days",
"=",
"julian_day",
"-",
"1",
")",
"return",
"r... | f0a9ab636103fe829aa9b495c93f5249aac5f2b8 |
valid | get_period_seconds | return the number of seconds in the specified period
>>> get_period_seconds('day')
86400
>>> get_period_seconds(86400)
86400
>>> get_period_seconds(datetime.timedelta(hours=24))
86400
>>> get_period_seconds('day + os.system("rm -Rf *")')
Traceback (most recent call last):
...
ValueError: period not in (secon... | tempora/__init__.py | def get_period_seconds(period):
"""
return the number of seconds in the specified period
>>> get_period_seconds('day')
86400
>>> get_period_seconds(86400)
86400
>>> get_period_seconds(datetime.timedelta(hours=24))
86400
>>> get_period_seconds('day + os.system("rm -Rf *")')
Traceback (most recent call last):
... | def get_period_seconds(period):
"""
return the number of seconds in the specified period
>>> get_period_seconds('day')
86400
>>> get_period_seconds(86400)
86400
>>> get_period_seconds(datetime.timedelta(hours=24))
86400
>>> get_period_seconds('day + os.system("rm -Rf *")')
Traceback (most recent call last):
... | [
"return",
"the",
"number",
"of",
"seconds",
"in",
"the",
"specified",
"period"
] | jaraco/tempora | python | https://github.com/jaraco/tempora/blob/f0a9ab636103fe829aa9b495c93f5249aac5f2b8/tempora/__init__.py#L310-L338 | [
"def",
"get_period_seconds",
"(",
"period",
")",
":",
"if",
"isinstance",
"(",
"period",
",",
"six",
".",
"string_types",
")",
":",
"try",
":",
"name",
"=",
"'seconds_per_'",
"+",
"period",
".",
"lower",
"(",
")",
"result",
"=",
"globals",
"(",
")",
"[... | f0a9ab636103fe829aa9b495c93f5249aac5f2b8 |
valid | get_date_format_string | For a given period (e.g. 'month', 'day', or some numeric interval
such as 3600 (in secs)), return the format string that can be
used with strftime to format that time to specify the times
across that interval, but no more detailed.
For example,
>>> get_date_format_string('month')
'%Y-%m'
>>> get_date_format_str... | tempora/__init__.py | def get_date_format_string(period):
"""
For a given period (e.g. 'month', 'day', or some numeric interval
such as 3600 (in secs)), return the format string that can be
used with strftime to format that time to specify the times
across that interval, but no more detailed.
For example,
>>> get_date_format_string(... | def get_date_format_string(period):
"""
For a given period (e.g. 'month', 'day', or some numeric interval
such as 3600 (in secs)), return the format string that can be
used with strftime to format that time to specify the times
across that interval, but no more detailed.
For example,
>>> get_date_format_string(... | [
"For",
"a",
"given",
"period",
"(",
"e",
".",
"g",
".",
"month",
"day",
"or",
"some",
"numeric",
"interval",
"such",
"as",
"3600",
"(",
"in",
"secs",
"))",
"return",
"the",
"format",
"string",
"that",
"can",
"be",
"used",
"with",
"strftime",
"to",
"f... | jaraco/tempora | python | https://github.com/jaraco/tempora/blob/f0a9ab636103fe829aa9b495c93f5249aac5f2b8/tempora/__init__.py#L341-L380 | [
"def",
"get_date_format_string",
"(",
"period",
")",
":",
"# handle the special case of 'month' which doesn't have",
"# a static interval in seconds",
"if",
"isinstance",
"(",
"period",
",",
"six",
".",
"string_types",
")",
"and",
"period",
".",
"lower",
"(",
")",
"=="... | f0a9ab636103fe829aa9b495c93f5249aac5f2b8 |
valid | divide_timedelta_float | Divide a timedelta by a float value
>>> one_day = datetime.timedelta(days=1)
>>> half_day = datetime.timedelta(days=.5)
>>> divide_timedelta_float(one_day, 2.0) == half_day
True
>>> divide_timedelta_float(one_day, 2) == half_day
True | tempora/__init__.py | def divide_timedelta_float(td, divisor):
"""
Divide a timedelta by a float value
>>> one_day = datetime.timedelta(days=1)
>>> half_day = datetime.timedelta(days=.5)
>>> divide_timedelta_float(one_day, 2.0) == half_day
True
>>> divide_timedelta_float(one_day, 2) == half_day
True
"""
# td is comprised of days,... | def divide_timedelta_float(td, divisor):
"""
Divide a timedelta by a float value
>>> one_day = datetime.timedelta(days=1)
>>> half_day = datetime.timedelta(days=.5)
>>> divide_timedelta_float(one_day, 2.0) == half_day
True
>>> divide_timedelta_float(one_day, 2) == half_day
True
"""
# td is comprised of days,... | [
"Divide",
"a",
"timedelta",
"by",
"a",
"float",
"value"
] | jaraco/tempora | python | https://github.com/jaraco/tempora/blob/f0a9ab636103fe829aa9b495c93f5249aac5f2b8/tempora/__init__.py#L383-L397 | [
"def",
"divide_timedelta_float",
"(",
"td",
",",
"divisor",
")",
":",
"# td is comprised of days, seconds, microseconds",
"dsm",
"=",
"[",
"getattr",
"(",
"td",
",",
"attr",
")",
"for",
"attr",
"in",
"(",
"'days'",
",",
"'seconds'",
",",
"'microseconds'",
")",
... | f0a9ab636103fe829aa9b495c93f5249aac5f2b8 |
valid | calculate_prorated_values | A utility function to prompt for a rate (a string in units per
unit time), and return that same rate for various time periods. | tempora/__init__.py | def calculate_prorated_values():
"""
A utility function to prompt for a rate (a string in units per
unit time), and return that same rate for various time periods.
"""
rate = six.moves.input("Enter the rate (3/hour, 50/month)> ")
res = re.match(r'(?P<value>[\d.]+)/(?P<period>\w+)$', rate).groupdict()
value = flo... | def calculate_prorated_values():
"""
A utility function to prompt for a rate (a string in units per
unit time), and return that same rate for various time periods.
"""
rate = six.moves.input("Enter the rate (3/hour, 50/month)> ")
res = re.match(r'(?P<value>[\d.]+)/(?P<period>\w+)$', rate).groupdict()
value = flo... | [
"A",
"utility",
"function",
"to",
"prompt",
"for",
"a",
"rate",
"(",
"a",
"string",
"in",
"units",
"per",
"unit",
"time",
")",
"and",
"return",
"that",
"same",
"rate",
"for",
"various",
"time",
"periods",
"."
] | jaraco/tempora | python | https://github.com/jaraco/tempora/blob/f0a9ab636103fe829aa9b495c93f5249aac5f2b8/tempora/__init__.py#L400-L411 | [
"def",
"calculate_prorated_values",
"(",
")",
":",
"rate",
"=",
"six",
".",
"moves",
".",
"input",
"(",
"\"Enter the rate (3/hour, 50/month)> \"",
")",
"res",
"=",
"re",
".",
"match",
"(",
"r'(?P<value>[\\d.]+)/(?P<period>\\w+)$'",
",",
"rate",
")",
".",
"groupdic... | f0a9ab636103fe829aa9b495c93f5249aac5f2b8 |
valid | parse_timedelta | Take a string representing a span of time and parse it to a time delta.
Accepts any string of comma-separated numbers each with a unit indicator.
>>> parse_timedelta('1 day')
datetime.timedelta(days=1)
>>> parse_timedelta('1 day, 30 seconds')
datetime.timedelta(days=1, seconds=30)
>>> parse_timedelta('47.32 da... | tempora/__init__.py | def parse_timedelta(str):
"""
Take a string representing a span of time and parse it to a time delta.
Accepts any string of comma-separated numbers each with a unit indicator.
>>> parse_timedelta('1 day')
datetime.timedelta(days=1)
>>> parse_timedelta('1 day, 30 seconds')
datetime.timedelta(days=1, seconds=30)... | def parse_timedelta(str):
"""
Take a string representing a span of time and parse it to a time delta.
Accepts any string of comma-separated numbers each with a unit indicator.
>>> parse_timedelta('1 day')
datetime.timedelta(days=1)
>>> parse_timedelta('1 day, 30 seconds')
datetime.timedelta(days=1, seconds=30)... | [
"Take",
"a",
"string",
"representing",
"a",
"span",
"of",
"time",
"and",
"parse",
"it",
"to",
"a",
"time",
"delta",
".",
"Accepts",
"any",
"string",
"of",
"comma",
"-",
"separated",
"numbers",
"each",
"with",
"a",
"unit",
"indicator",
"."
] | jaraco/tempora | python | https://github.com/jaraco/tempora/blob/f0a9ab636103fe829aa9b495c93f5249aac5f2b8/tempora/__init__.py#L414-L446 | [
"def",
"parse_timedelta",
"(",
"str",
")",
":",
"deltas",
"=",
"(",
"_parse_timedelta_part",
"(",
"part",
".",
"strip",
"(",
")",
")",
"for",
"part",
"in",
"str",
".",
"split",
"(",
"','",
")",
")",
"return",
"sum",
"(",
"deltas",
",",
"datetime",
".... | f0a9ab636103fe829aa9b495c93f5249aac5f2b8 |
valid | divide_timedelta | Get the ratio of two timedeltas
>>> one_day = datetime.timedelta(days=1)
>>> one_hour = datetime.timedelta(hours=1)
>>> divide_timedelta(one_hour, one_day) == 1 / 24
True | tempora/__init__.py | def divide_timedelta(td1, td2):
"""
Get the ratio of two timedeltas
>>> one_day = datetime.timedelta(days=1)
>>> one_hour = datetime.timedelta(hours=1)
>>> divide_timedelta(one_hour, one_day) == 1 / 24
True
"""
try:
return td1 / td2
except TypeError:
# Python 3.2 gets division
# http://bugs.python.org/i... | def divide_timedelta(td1, td2):
"""
Get the ratio of two timedeltas
>>> one_day = datetime.timedelta(days=1)
>>> one_hour = datetime.timedelta(hours=1)
>>> divide_timedelta(one_hour, one_day) == 1 / 24
True
"""
try:
return td1 / td2
except TypeError:
# Python 3.2 gets division
# http://bugs.python.org/i... | [
"Get",
"the",
"ratio",
"of",
"two",
"timedeltas"
] | jaraco/tempora | python | https://github.com/jaraco/tempora/blob/f0a9ab636103fe829aa9b495c93f5249aac5f2b8/tempora/__init__.py#L467-L481 | [
"def",
"divide_timedelta",
"(",
"td1",
",",
"td2",
")",
":",
"try",
":",
"return",
"td1",
"/",
"td2",
"except",
"TypeError",
":",
"# Python 3.2 gets division",
"# http://bugs.python.org/issue2706",
"return",
"td1",
".",
"total_seconds",
"(",
")",
"/",
"td2",
"."... | f0a9ab636103fe829aa9b495c93f5249aac5f2b8 |
valid | date_range | Much like the built-in function range, but works with dates
>>> range_items = date_range(
... datetime.datetime(2005,12,21),
... datetime.datetime(2005,12,25),
... )
>>> my_range = tuple(range_items)
>>> datetime.datetime(2005,12,21) in my_range
True
>>> datetime.datetime(2005,12,22) in my_range
True
... | tempora/__init__.py | def date_range(start=None, stop=None, step=None):
"""
Much like the built-in function range, but works with dates
>>> range_items = date_range(
... datetime.datetime(2005,12,21),
... datetime.datetime(2005,12,25),
... )
>>> my_range = tuple(range_items)
>>> datetime.datetime(2005,12,21) in my_range
Tr... | def date_range(start=None, stop=None, step=None):
"""
Much like the built-in function range, but works with dates
>>> range_items = date_range(
... datetime.datetime(2005,12,21),
... datetime.datetime(2005,12,25),
... )
>>> my_range = tuple(range_items)
>>> datetime.datetime(2005,12,21) in my_range
Tr... | [
"Much",
"like",
"the",
"built",
"-",
"in",
"function",
"range",
"but",
"works",
"with",
"dates"
] | jaraco/tempora | python | https://github.com/jaraco/tempora/blob/f0a9ab636103fe829aa9b495c93f5249aac5f2b8/tempora/__init__.py#L484-L506 | [
"def",
"date_range",
"(",
"start",
"=",
"None",
",",
"stop",
"=",
"None",
",",
"step",
"=",
"None",
")",
":",
"if",
"step",
"is",
"None",
":",
"step",
"=",
"datetime",
".",
"timedelta",
"(",
"days",
"=",
"1",
")",
"if",
"start",
"is",
"None",
":"... | f0a9ab636103fe829aa9b495c93f5249aac5f2b8 |
valid | DatetimeConstructor.construct_datetime | Construct a datetime.datetime from a number of different time
types found in python and pythonwin | tempora/__init__.py | def construct_datetime(cls, *args, **kwargs):
"""Construct a datetime.datetime from a number of different time
types found in python and pythonwin"""
if len(args) == 1:
arg = args[0]
method = cls.__get_dt_constructor(
type(arg).__module__,
type(arg).__name__,
)
result = method(arg)
try:
... | def construct_datetime(cls, *args, **kwargs):
"""Construct a datetime.datetime from a number of different time
types found in python and pythonwin"""
if len(args) == 1:
arg = args[0]
method = cls.__get_dt_constructor(
type(arg).__module__,
type(arg).__name__,
)
result = method(arg)
try:
... | [
"Construct",
"a",
"datetime",
".",
"datetime",
"from",
"a",
"number",
"of",
"different",
"time",
"types",
"found",
"in",
"python",
"and",
"pythonwin"
] | jaraco/tempora | python | https://github.com/jaraco/tempora/blob/f0a9ab636103fe829aa9b495c93f5249aac5f2b8/tempora/__init__.py#L148-L171 | [
"def",
"construct_datetime",
"(",
"cls",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"len",
"(",
"args",
")",
"==",
"1",
":",
"arg",
"=",
"args",
"[",
"0",
"]",
"method",
"=",
"cls",
".",
"__get_dt_constructor",
"(",
"type",
"(",
"... | f0a9ab636103fe829aa9b495c93f5249aac5f2b8 |
valid | __common_triplet | __common_triplet(input_string, consonants, vowels) -> string | codicefiscale.py | def __common_triplet(input_string, consonants, vowels):
"""__common_triplet(input_string, consonants, vowels) -> string"""
output = consonants
while len(output) < 3:
try:
output += vowels.pop(0)
except IndexError:
# If there are less wovels than needed to fill the tr... | def __common_triplet(input_string, consonants, vowels):
"""__common_triplet(input_string, consonants, vowels) -> string"""
output = consonants
while len(output) < 3:
try:
output += vowels.pop(0)
except IndexError:
# If there are less wovels than needed to fill the tr... | [
"__common_triplet",
"(",
"input_string",
"consonants",
"vowels",
")",
"-",
">",
"string"
] | ema/pycodicefiscale | python | https://github.com/ema/pycodicefiscale/blob/4d06a145cdcffe7ee576f2fedaf40e2c6f7692a4/codicefiscale.py#L59-L72 | [
"def",
"__common_triplet",
"(",
"input_string",
",",
"consonants",
",",
"vowels",
")",
":",
"output",
"=",
"consonants",
"while",
"len",
"(",
"output",
")",
"<",
"3",
":",
"try",
":",
"output",
"+=",
"vowels",
".",
"pop",
"(",
"0",
")",
"except",
"Inde... | 4d06a145cdcffe7ee576f2fedaf40e2c6f7692a4 |
valid | __consonants_and_vowels | __consonants_and_vowels(input_string) -> (string, list)
Get the consonants as a string and the vowels as a list. | codicefiscale.py | def __consonants_and_vowels(input_string):
"""__consonants_and_vowels(input_string) -> (string, list)
Get the consonants as a string and the vowels as a list.
"""
input_string = input_string.upper().replace(' ', '')
consonants = [ char for char in input_string if char in __CONSONANTS ]
vowels ... | def __consonants_and_vowels(input_string):
"""__consonants_and_vowels(input_string) -> (string, list)
Get the consonants as a string and the vowels as a list.
"""
input_string = input_string.upper().replace(' ', '')
consonants = [ char for char in input_string if char in __CONSONANTS ]
vowels ... | [
"__consonants_and_vowels",
"(",
"input_string",
")",
"-",
">",
"(",
"string",
"list",
")"
] | ema/pycodicefiscale | python | https://github.com/ema/pycodicefiscale/blob/4d06a145cdcffe7ee576f2fedaf40e2c6f7692a4/codicefiscale.py#L74-L84 | [
"def",
"__consonants_and_vowels",
"(",
"input_string",
")",
":",
"input_string",
"=",
"input_string",
".",
"upper",
"(",
")",
".",
"replace",
"(",
"' '",
",",
"''",
")",
"consonants",
"=",
"[",
"char",
"for",
"char",
"in",
"input_string",
"if",
"char",
"in... | 4d06a145cdcffe7ee576f2fedaf40e2c6f7692a4 |
valid | __surname_triplet | __surname_triplet(input_string) -> string | codicefiscale.py | def __surname_triplet(input_string):
"""__surname_triplet(input_string) -> string"""
consonants, vowels = __consonants_and_vowels(input_string)
return __common_triplet(input_string, consonants, vowels) | def __surname_triplet(input_string):
"""__surname_triplet(input_string) -> string"""
consonants, vowels = __consonants_and_vowels(input_string)
return __common_triplet(input_string, consonants, vowels) | [
"__surname_triplet",
"(",
"input_string",
")",
"-",
">",
"string"
] | ema/pycodicefiscale | python | https://github.com/ema/pycodicefiscale/blob/4d06a145cdcffe7ee576f2fedaf40e2c6f7692a4/codicefiscale.py#L86-L90 | [
"def",
"__surname_triplet",
"(",
"input_string",
")",
":",
"consonants",
",",
"vowels",
"=",
"__consonants_and_vowels",
"(",
"input_string",
")",
"return",
"__common_triplet",
"(",
"input_string",
",",
"consonants",
",",
"vowels",
")"
] | 4d06a145cdcffe7ee576f2fedaf40e2c6f7692a4 |
valid | __name_triplet | __name_triplet(input_string) -> string | codicefiscale.py | def __name_triplet(input_string):
"""__name_triplet(input_string) -> string"""
if input_string == '':
# highly unlikely: no first name, like for instance some Indian persons
# with only one name on the passport
# pylint: disable=W0511
return 'XXX'
consonants, vowels = __con... | def __name_triplet(input_string):
"""__name_triplet(input_string) -> string"""
if input_string == '':
# highly unlikely: no first name, like for instance some Indian persons
# with only one name on the passport
# pylint: disable=W0511
return 'XXX'
consonants, vowels = __con... | [
"__name_triplet",
"(",
"input_string",
")",
"-",
">",
"string"
] | ema/pycodicefiscale | python | https://github.com/ema/pycodicefiscale/blob/4d06a145cdcffe7ee576f2fedaf40e2c6f7692a4/codicefiscale.py#L92-L105 | [
"def",
"__name_triplet",
"(",
"input_string",
")",
":",
"if",
"input_string",
"==",
"''",
":",
"# highly unlikely: no first name, like for instance some Indian persons",
"# with only one name on the passport",
"# pylint: disable=W0511",
"return",
"'XXX'",
"consonants",
",",
"vowe... | 4d06a145cdcffe7ee576f2fedaf40e2c6f7692a4 |
valid | control_code | ``control_code(input_string) -> int``
Computes the control code for the given input_string string. The expected
input_string is the first 15 characters of a fiscal code.
eg: control_code('RCCMNL83S18D969') -> 'H' | codicefiscale.py | def control_code(input_string):
"""``control_code(input_string) -> int``
Computes the control code for the given input_string string. The expected
input_string is the first 15 characters of a fiscal code.
eg: control_code('RCCMNL83S18D969') -> 'H'
"""
assert len(input_string) == 15
# buil... | def control_code(input_string):
"""``control_code(input_string) -> int``
Computes the control code for the given input_string string. The expected
input_string is the first 15 characters of a fiscal code.
eg: control_code('RCCMNL83S18D969') -> 'H'
"""
assert len(input_string) == 15
# buil... | [
"control_code",
"(",
"input_string",
")",
"-",
">",
"int"
] | ema/pycodicefiscale | python | https://github.com/ema/pycodicefiscale/blob/4d06a145cdcffe7ee576f2fedaf40e2c6f7692a4/codicefiscale.py#L107-L145 | [
"def",
"control_code",
"(",
"input_string",
")",
":",
"assert",
"len",
"(",
"input_string",
")",
"==",
"15",
"# building conversion tables for even and odd characters positions",
"even_controlcode",
"=",
"{",
"}",
"for",
"idx",
",",
"char",
"in",
"enumerate",
"(",
"... | 4d06a145cdcffe7ee576f2fedaf40e2c6f7692a4 |
valid | build | ``build(surname, name, birthday, sex, municipality) -> string``
Computes the fiscal code for the given person data.
eg: build('Rocca', 'Emanuele', datetime.datetime(1983, 11, 18), 'M', 'D969')
-> RCCMNL83S18D969H | codicefiscale.py | def build(surname, name, birthday, sex, municipality):
"""``build(surname, name, birthday, sex, municipality) -> string``
Computes the fiscal code for the given person data.
eg: build('Rocca', 'Emanuele', datetime.datetime(1983, 11, 18), 'M', 'D969')
-> RCCMNL83S18D969H
"""
# RCCMNL
... | def build(surname, name, birthday, sex, municipality):
"""``build(surname, name, birthday, sex, municipality) -> string``
Computes the fiscal code for the given person data.
eg: build('Rocca', 'Emanuele', datetime.datetime(1983, 11, 18), 'M', 'D969')
-> RCCMNL83S18D969H
"""
# RCCMNL
... | [
"build",
"(",
"surname",
"name",
"birthday",
"sex",
"municipality",
")",
"-",
">",
"string"
] | ema/pycodicefiscale | python | https://github.com/ema/pycodicefiscale/blob/4d06a145cdcffe7ee576f2fedaf40e2c6f7692a4/codicefiscale.py#L147-L176 | [
"def",
"build",
"(",
"surname",
",",
"name",
",",
"birthday",
",",
"sex",
",",
"municipality",
")",
":",
"# RCCMNL",
"output",
"=",
"__surname_triplet",
"(",
"surname",
")",
"+",
"__name_triplet",
"(",
"name",
")",
"# RCCMNL83",
"output",
"+=",
"str",
"(",... | 4d06a145cdcffe7ee576f2fedaf40e2c6f7692a4 |
valid | get_birthday | ``get_birthday(code) -> string``
Birthday of the person whose fiscal code is 'code', in the format DD-MM-YY.
Unfortunately it's not possible to guess the four digit birth year, given
that the Italian fiscal code uses only the last two digits (1983 -> 83).
Therefore, this function returns a string and... | codicefiscale.py | def get_birthday(code):
"""``get_birthday(code) -> string``
Birthday of the person whose fiscal code is 'code', in the format DD-MM-YY.
Unfortunately it's not possible to guess the four digit birth year, given
that the Italian fiscal code uses only the last two digits (1983 -> 83).
Therefore, thi... | def get_birthday(code):
"""``get_birthday(code) -> string``
Birthday of the person whose fiscal code is 'code', in the format DD-MM-YY.
Unfortunately it's not possible to guess the four digit birth year, given
that the Italian fiscal code uses only the last two digits (1983 -> 83).
Therefore, thi... | [
"get_birthday",
"(",
"code",
")",
"-",
">",
"string"
] | ema/pycodicefiscale | python | https://github.com/ema/pycodicefiscale/blob/4d06a145cdcffe7ee576f2fedaf40e2c6f7692a4/codicefiscale.py#L179-L198 | [
"def",
"get_birthday",
"(",
"code",
")",
":",
"assert",
"isvalid",
"(",
"code",
")",
"day",
"=",
"int",
"(",
"code",
"[",
"9",
":",
"11",
"]",
")",
"day",
"=",
"day",
"<",
"32",
"and",
"day",
"or",
"day",
"-",
"40",
"month",
"=",
"MONTHSCODE",
... | 4d06a145cdcffe7ee576f2fedaf40e2c6f7692a4 |
valid | API.get | Pass in an Overpass query in Overpass QL. | overpass/api.py | def get(self, query, responseformat="geojson", verbosity="body", build=True):
"""Pass in an Overpass query in Overpass QL."""
# Construct full Overpass query
if build:
full_query = self._construct_ql_query(
query, responseformat=responseformat, verbosity=verbosity
... | def get(self, query, responseformat="geojson", verbosity="body", build=True):
"""Pass in an Overpass query in Overpass QL."""
# Construct full Overpass query
if build:
full_query = self._construct_ql_query(
query, responseformat=responseformat, verbosity=verbosity
... | [
"Pass",
"in",
"an",
"Overpass",
"query",
"in",
"Overpass",
"QL",
"."
] | mvexel/overpass-api-python-wrapper | python | https://github.com/mvexel/overpass-api-python-wrapper/blob/4eea38224bc9259fd017b38ad8683f3fa3777175/overpass/api.py#L62-L109 | [
"def",
"get",
"(",
"self",
",",
"query",
",",
"responseformat",
"=",
"\"geojson\"",
",",
"verbosity",
"=",
"\"body\"",
",",
"build",
"=",
"True",
")",
":",
"# Construct full Overpass query",
"if",
"build",
":",
"full_query",
"=",
"self",
".",
"_construct_ql_qu... | 4eea38224bc9259fd017b38ad8683f3fa3777175 |
valid | GeniaTagger.parse | Arguments:
- `self`:
- `text`: | geniatagger.py | def parse(self, text):
"""
Arguments:
- `self`:
- `text`:
"""
results = list()
for oneline in text.split('\n'):
self._tagger.stdin.write(oneline+'\n')
while True:
r = self._tagger.stdout.readline()[:-1]
... | def parse(self, text):
"""
Arguments:
- `self`:
- `text`:
"""
results = list()
for oneline in text.split('\n'):
self._tagger.stdin.write(oneline+'\n')
while True:
r = self._tagger.stdout.readline()[:-1]
... | [
"Arguments",
":",
"-",
"self",
":",
"-",
"text",
":"
] | informationsea/geniatagger-python | python | https://github.com/informationsea/geniatagger-python/blob/0a9d0a0e4ffca22d564950fc46e1f0002eafcf86/geniatagger.py#L25-L42 | [
"def",
"parse",
"(",
"self",
",",
"text",
")",
":",
"results",
"=",
"list",
"(",
")",
"for",
"oneline",
"in",
"text",
".",
"split",
"(",
"'\\n'",
")",
":",
"self",
".",
"_tagger",
".",
"stdin",
".",
"write",
"(",
"oneline",
"+",
"'\\n'",
")",
"wh... | 0a9d0a0e4ffca22d564950fc46e1f0002eafcf86 |
valid | create_port | Create a port
Create a port which is a connection point of a device (e.g., a VM
NIC) to attach to a L2 Neutron network.
: param context: neutron api request context
: param port: dictionary describing the port, with keys
as listed in the RESOURCE_ATTRIBUTE_MAP object in
neutron/api/v2/a... | quark/plugin_modules/ports.py | def create_port(context, port):
"""Create a port
Create a port which is a connection point of a device (e.g., a VM
NIC) to attach to a L2 Neutron network.
: param context: neutron api request context
: param port: dictionary describing the port, with keys
as listed in the RESOURCE_ATTRIBUTE... | def create_port(context, port):
"""Create a port
Create a port which is a connection point of a device (e.g., a VM
NIC) to attach to a L2 Neutron network.
: param context: neutron api request context
: param port: dictionary describing the port, with keys
as listed in the RESOURCE_ATTRIBUTE... | [
"Create",
"a",
"port"
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/ports.py#L134-L353 | [
"def",
"create_port",
"(",
"context",
",",
"port",
")",
":",
"LOG",
".",
"info",
"(",
"\"create_port for tenant %s\"",
"%",
"context",
".",
"tenant_id",
")",
"port_attrs",
"=",
"port",
"[",
"\"port\"",
"]",
"admin_only",
"=",
"[",
"\"mac_address\"",
",",
"\"... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | update_port | Update values of a port.
: param context: neutron api request context
: param id: UUID representing the port to update.
: param port: dictionary with keys indicating fields to update.
valid keys are those that have a value of True for 'allow_put'
as listed in the RESOURCE_ATTRIBUTE_MAP obje... | quark/plugin_modules/ports.py | def update_port(context, id, port):
"""Update values of a port.
: param context: neutron api request context
: param id: UUID representing the port to update.
: param port: dictionary with keys indicating fields to update.
valid keys are those that have a value of True for 'allow_put'
a... | def update_port(context, id, port):
"""Update values of a port.
: param context: neutron api request context
: param id: UUID representing the port to update.
: param port: dictionary with keys indicating fields to update.
valid keys are those that have a value of True for 'allow_put'
a... | [
"Update",
"values",
"of",
"a",
"port",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/ports.py#L357-L505 | [
"def",
"update_port",
"(",
"context",
",",
"id",
",",
"port",
")",
":",
"LOG",
".",
"info",
"(",
"\"update_port %s for tenant %s\"",
"%",
"(",
"id",
",",
"context",
".",
"tenant_id",
")",
")",
"port_db",
"=",
"db_api",
".",
"port_find",
"(",
"context",
"... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | get_port | Retrieve a port.
: param context: neutron api request context
: param id: UUID representing the port to fetch.
: param fields: a list of strings that are valid keys in a
port dictionary as listed in the RESOURCE_ATTRIBUTE_MAP
object in neutron/api/v2/attributes.py. Only these fields
... | quark/plugin_modules/ports.py | def get_port(context, id, fields=None):
"""Retrieve a port.
: param context: neutron api request context
: param id: UUID representing the port to fetch.
: param fields: a list of strings that are valid keys in a
port dictionary as listed in the RESOURCE_ATTRIBUTE_MAP
object in neutron/... | def get_port(context, id, fields=None):
"""Retrieve a port.
: param context: neutron api request context
: param id: UUID representing the port to fetch.
: param fields: a list of strings that are valid keys in a
port dictionary as listed in the RESOURCE_ATTRIBUTE_MAP
object in neutron/... | [
"Retrieve",
"a",
"port",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/ports.py#L509-L527 | [
"def",
"get_port",
"(",
"context",
",",
"id",
",",
"fields",
"=",
"None",
")",
":",
"LOG",
".",
"info",
"(",
"\"get_port %s for tenant %s fields %s\"",
"%",
"(",
"id",
",",
"context",
".",
"tenant_id",
",",
"fields",
")",
")",
"results",
"=",
"db_api",
"... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | get_ports | Retrieve a list of ports.
The contents of the list depends on the identity of the user
making the request (as indicated by the context) as well as any
filters.
: param context: neutron api request context
: param filters: a dictionary with keys that are valid keys for
a port as listed in th... | quark/plugin_modules/ports.py | def get_ports(context, limit=None, sorts=['id'], marker=None,
page_reverse=False, filters=None, fields=None):
"""Retrieve a list of ports.
The contents of the list depends on the identity of the user
making the request (as indicated by the context) as well as any
filters.
: param cont... | def get_ports(context, limit=None, sorts=['id'], marker=None,
page_reverse=False, filters=None, fields=None):
"""Retrieve a list of ports.
The contents of the list depends on the identity of the user
making the request (as indicated by the context) as well as any
filters.
: param cont... | [
"Retrieve",
"a",
"list",
"of",
"ports",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/ports.py#L531-L574 | [
"def",
"get_ports",
"(",
"context",
",",
"limit",
"=",
"None",
",",
"sorts",
"=",
"[",
"'id'",
"]",
",",
"marker",
"=",
"None",
",",
"page_reverse",
"=",
"False",
",",
"filters",
"=",
"None",
",",
"fields",
"=",
"None",
")",
":",
"LOG",
".",
"info"... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | get_ports_count | Return the number of ports.
The result depends on the identity of the user making the request
(as indicated by the context) as well as any filters.
: param context: neutron api request context
: param filters: a dictionary with keys that are valid keys for
a port as listed in the RESOURCE_ATTRI... | quark/plugin_modules/ports.py | def get_ports_count(context, filters=None):
"""Return the number of ports.
The result depends on the identity of the user making the request
(as indicated by the context) as well as any filters.
: param context: neutron api request context
: param filters: a dictionary with keys that are valid keys... | def get_ports_count(context, filters=None):
"""Return the number of ports.
The result depends on the identity of the user making the request
(as indicated by the context) as well as any filters.
: param context: neutron api request context
: param filters: a dictionary with keys that are valid keys... | [
"Return",
"the",
"number",
"of",
"ports",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/ports.py#L578-L597 | [
"def",
"get_ports_count",
"(",
"context",
",",
"filters",
"=",
"None",
")",
":",
"LOG",
".",
"info",
"(",
"\"get_ports_count for tenant %s filters %s\"",
"%",
"(",
"context",
".",
"tenant_id",
",",
"filters",
")",
")",
"return",
"db_api",
".",
"port_count_all",
... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | delete_port | Delete a port.
: param context: neutron api request context
: param id: UUID representing the port to delete. | quark/plugin_modules/ports.py | def delete_port(context, id):
"""Delete a port.
: param context: neutron api request context
: param id: UUID representing the port to delete.
"""
LOG.info("delete_port %s for tenant %s" % (id, context.tenant_id))
port = db_api.port_find(context, id=id, scope=db_api.ONE)
if not port:
... | def delete_port(context, id):
"""Delete a port.
: param context: neutron api request context
: param id: UUID representing the port to delete.
"""
LOG.info("delete_port %s for tenant %s" % (id, context.tenant_id))
port = db_api.port_find(context, id=id, scope=db_api.ONE)
if not port:
... | [
"Delete",
"a",
"port",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/ports.py#L601-L631 | [
"def",
"delete_port",
"(",
"context",
",",
"id",
")",
":",
"LOG",
".",
"info",
"(",
"\"delete_port %s for tenant %s\"",
"%",
"(",
"id",
",",
"context",
".",
"tenant_id",
")",
")",
"port",
"=",
"db_api",
".",
"port_find",
"(",
"context",
",",
"id",
"=",
... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | Segment_allocation_ranges.get_resources | Returns Ext Resources. | quark/api/extensions/segment_allocation_ranges.py | def get_resources(cls):
"""Returns Ext Resources."""
plugin = directory.get_plugin()
controller = SegmentAllocationRangesController(plugin)
return [extensions.ResourceExtension(
Segment_allocation_ranges.get_alias(),
controller)] | def get_resources(cls):
"""Returns Ext Resources."""
plugin = directory.get_plugin()
controller = SegmentAllocationRangesController(plugin)
return [extensions.ResourceExtension(
Segment_allocation_ranges.get_alias(),
controller)] | [
"Returns",
"Ext",
"Resources",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/api/extensions/segment_allocation_ranges.py#L100-L106 | [
"def",
"get_resources",
"(",
"cls",
")",
":",
"plugin",
"=",
"directory",
".",
"get_plugin",
"(",
")",
"controller",
"=",
"SegmentAllocationRangesController",
"(",
"plugin",
")",
"return",
"[",
"extensions",
".",
"ResourceExtension",
"(",
"Segment_allocation_ranges"... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | Ip_availability.get_resources | Returns Ext Resources. | quark/api/extensions/ip_availability.py | def get_resources(cls):
"""Returns Ext Resources."""
plugin = directory.get_plugin()
controller = IPAvailabilityController(plugin)
return [extensions.ResourceExtension(Ip_availability.get_alias(),
controller)] | def get_resources(cls):
"""Returns Ext Resources."""
plugin = directory.get_plugin()
controller = IPAvailabilityController(plugin)
return [extensions.ResourceExtension(Ip_availability.get_alias(),
controller)] | [
"Returns",
"Ext",
"Resources",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/api/extensions/ip_availability.py#L79-L84 | [
"def",
"get_resources",
"(",
"cls",
")",
":",
"plugin",
"=",
"directory",
".",
"get_plugin",
"(",
")",
"controller",
"=",
"IPAvailabilityController",
"(",
"plugin",
")",
"return",
"[",
"extensions",
".",
"ResourceExtension",
"(",
"Ip_availability",
".",
"get_ali... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | QuarkIpam._allocate_from_v6_subnet | This attempts to allocate v6 addresses as per RFC2462 and RFC3041.
To accomodate this, we effectively treat all v6 assignment as a
first time allocation utilizing the MAC address of the VIF. Because
we recycle MACs, we will eventually attempt to recreate a previously
generated v6 addres... | quark/ipam.py | def _allocate_from_v6_subnet(self, context, net_id, subnet,
port_id, reuse_after, ip_address=None,
**kwargs):
"""This attempts to allocate v6 addresses as per RFC2462 and RFC3041.
To accomodate this, we effectively treat all v6 assignmen... | def _allocate_from_v6_subnet(self, context, net_id, subnet,
port_id, reuse_after, ip_address=None,
**kwargs):
"""This attempts to allocate v6 addresses as per RFC2462 and RFC3041.
To accomodate this, we effectively treat all v6 assignmen... | [
"This",
"attempts",
"to",
"allocate",
"v6",
"addresses",
"as",
"per",
"RFC2462",
"and",
"RFC3041",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/ipam.py#L495-L567 | [
"def",
"_allocate_from_v6_subnet",
"(",
"self",
",",
"context",
",",
"net_id",
",",
"subnet",
",",
"port_id",
",",
"reuse_after",
",",
"ip_address",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"LOG",
".",
"info",
"(",
"\"Attempting to allocate a v6 address... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | _create_flip | Associates the flip with ports and creates it with the flip driver
:param context: neutron api request context.
:param flip: quark.db.models.IPAddress object representing a floating IP
:param port_fixed_ips: dictionary of the structure:
{"<id of port>": {"port": <quark.db.models.Port>,
"fixed_ip":... | quark/plugin_modules/floating_ips.py | def _create_flip(context, flip, port_fixed_ips):
"""Associates the flip with ports and creates it with the flip driver
:param context: neutron api request context.
:param flip: quark.db.models.IPAddress object representing a floating IP
:param port_fixed_ips: dictionary of the structure:
{"<id of p... | def _create_flip(context, flip, port_fixed_ips):
"""Associates the flip with ports and creates it with the flip driver
:param context: neutron api request context.
:param flip: quark.db.models.IPAddress object representing a floating IP
:param port_fixed_ips: dictionary of the structure:
{"<id of p... | [
"Associates",
"the",
"flip",
"with",
"ports",
"and",
"creates",
"it",
"with",
"the",
"flip",
"driver"
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/floating_ips.py#L139-L170 | [
"def",
"_create_flip",
"(",
"context",
",",
"flip",
",",
"port_fixed_ips",
")",
":",
"if",
"port_fixed_ips",
":",
"context",
".",
"session",
".",
"begin",
"(",
")",
"try",
":",
"ports",
"=",
"[",
"val",
"[",
"'port'",
"]",
"for",
"val",
"in",
"port_fix... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | _update_flip | Update a flip based IPAddress
:param context: neutron api request context.
:param flip_id: id of the flip or scip
:param ip_type: ip_types.FLOATING | ip_types.SCALING
:param requested_ports: dictionary of the structure:
{"port_id": "<id of port>", "fixed_ip": "<fixed ip address>"}
:return: quar... | quark/plugin_modules/floating_ips.py | def _update_flip(context, flip_id, ip_type, requested_ports):
"""Update a flip based IPAddress
:param context: neutron api request context.
:param flip_id: id of the flip or scip
:param ip_type: ip_types.FLOATING | ip_types.SCALING
:param requested_ports: dictionary of the structure:
{"port_id"... | def _update_flip(context, flip_id, ip_type, requested_ports):
"""Update a flip based IPAddress
:param context: neutron api request context.
:param flip_id: id of the flip or scip
:param ip_type: ip_types.FLOATING | ip_types.SCALING
:param requested_ports: dictionary of the structure:
{"port_id"... | [
"Update",
"a",
"flip",
"based",
"IPAddress"
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/floating_ips.py#L179-L311 | [
"def",
"_update_flip",
"(",
"context",
",",
"flip_id",
",",
"ip_type",
",",
"requested_ports",
")",
":",
"# This list will hold flips that require notifications.",
"# Using sets to avoid dups, if any.",
"notifications",
"=",
"{",
"billing",
".",
"IP_ASSOC",
":",
"set",
"(... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | create_floatingip | Allocate or reallocate a floating IP.
:param context: neutron api request context.
:param content: dictionary describing the floating ip, with keys
as listed in the RESOURCE_ATTRIBUTE_MAP object in
neutron/api/v2/attributes.py. All keys will be populated.
:returns: Dictionary containing d... | quark/plugin_modules/floating_ips.py | def create_floatingip(context, content):
"""Allocate or reallocate a floating IP.
:param context: neutron api request context.
:param content: dictionary describing the floating ip, with keys
as listed in the RESOURCE_ATTRIBUTE_MAP object in
neutron/api/v2/attributes.py. All keys will be p... | def create_floatingip(context, content):
"""Allocate or reallocate a floating IP.
:param context: neutron api request context.
:param content: dictionary describing the floating ip, with keys
as listed in the RESOURCE_ATTRIBUTE_MAP object in
neutron/api/v2/attributes.py. All keys will be p... | [
"Allocate",
"or",
"reallocate",
"a",
"floating",
"IP",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/floating_ips.py#L358-L391 | [
"def",
"create_floatingip",
"(",
"context",
",",
"content",
")",
":",
"LOG",
".",
"info",
"(",
"'create_floatingip %s for tenant %s and body %s'",
"%",
"(",
"id",
",",
"context",
".",
"tenant_id",
",",
"content",
")",
")",
"network_id",
"=",
"content",
".",
"g... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | update_floatingip | Update an existing floating IP.
:param context: neutron api request context.
:param id: id of the floating ip
:param content: dictionary with keys indicating fields to update.
valid keys are those that have a value of True for 'allow_put'
as listed in the RESOURCE_ATTRIBUTE_MAP object in
... | quark/plugin_modules/floating_ips.py | def update_floatingip(context, id, content):
"""Update an existing floating IP.
:param context: neutron api request context.
:param id: id of the floating ip
:param content: dictionary with keys indicating fields to update.
valid keys are those that have a value of True for 'allow_put'
... | def update_floatingip(context, id, content):
"""Update an existing floating IP.
:param context: neutron api request context.
:param id: id of the floating ip
:param content: dictionary with keys indicating fields to update.
valid keys are those that have a value of True for 'allow_put'
... | [
"Update",
"an",
"existing",
"floating",
"IP",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/floating_ips.py#L394-L420 | [
"def",
"update_floatingip",
"(",
"context",
",",
"id",
",",
"content",
")",
":",
"LOG",
".",
"info",
"(",
"'update_floatingip %s for tenant %s and body %s'",
"%",
"(",
"id",
",",
"context",
".",
"tenant_id",
",",
"content",
")",
")",
"if",
"'port_id'",
"not",
... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | delete_floatingip | deallocate a floating IP.
:param context: neutron api request context.
:param id: id of the floating ip | quark/plugin_modules/floating_ips.py | def delete_floatingip(context, id):
"""deallocate a floating IP.
:param context: neutron api request context.
:param id: id of the floating ip
"""
LOG.info('delete_floatingip %s for tenant %s' % (id, context.tenant_id))
_delete_flip(context, id, ip_types.FLOATING) | def delete_floatingip(context, id):
"""deallocate a floating IP.
:param context: neutron api request context.
:param id: id of the floating ip
"""
LOG.info('delete_floatingip %s for tenant %s' % (id, context.tenant_id))
_delete_flip(context, id, ip_types.FLOATING) | [
"deallocate",
"a",
"floating",
"IP",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/floating_ips.py#L423-L432 | [
"def",
"delete_floatingip",
"(",
"context",
",",
"id",
")",
":",
"LOG",
".",
"info",
"(",
"'delete_floatingip %s for tenant %s'",
"%",
"(",
"id",
",",
"context",
".",
"tenant_id",
")",
")",
"_delete_flip",
"(",
"context",
",",
"id",
",",
"ip_types",
".",
"... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | get_floatingip | Retrieve a floating IP.
:param context: neutron api request context.
:param id: The UUID of the floating IP.
:param fields: a list of strings that are valid keys in a
floating IP dictionary as listed in the RESOURCE_ATTRIBUTE_MAP
object in neutron/api/v2/attributes.py. Only these fields
... | quark/plugin_modules/floating_ips.py | def get_floatingip(context, id, fields=None):
"""Retrieve a floating IP.
:param context: neutron api request context.
:param id: The UUID of the floating IP.
:param fields: a list of strings that are valid keys in a
floating IP dictionary as listed in the RESOURCE_ATTRIBUTE_MAP
object i... | def get_floatingip(context, id, fields=None):
"""Retrieve a floating IP.
:param context: neutron api request context.
:param id: The UUID of the floating IP.
:param fields: a list of strings that are valid keys in a
floating IP dictionary as listed in the RESOURCE_ATTRIBUTE_MAP
object i... | [
"Retrieve",
"a",
"floating",
"IP",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/floating_ips.py#L435-L459 | [
"def",
"get_floatingip",
"(",
"context",
",",
"id",
",",
"fields",
"=",
"None",
")",
":",
"LOG",
".",
"info",
"(",
"'get_floatingip %s for tenant %s'",
"%",
"(",
"id",
",",
"context",
".",
"tenant_id",
")",
")",
"filters",
"=",
"{",
"'address_type'",
":",
... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | get_floatingips | Retrieve a list of floating ips.
:param context: neutron api request context.
:param filters: a dictionary with keys that are valid keys for
a floating ip as listed in the RESOURCE_ATTRIBUTE_MAP object
in neutron/api/v2/attributes.py. Values in this dictionary
are an iterable containin... | quark/plugin_modules/floating_ips.py | def get_floatingips(context, filters=None, fields=None, sorts=['id'],
limit=None, marker=None, page_reverse=False):
"""Retrieve a list of floating ips.
:param context: neutron api request context.
:param filters: a dictionary with keys that are valid keys for
a floating ip as li... | def get_floatingips(context, filters=None, fields=None, sorts=['id'],
limit=None, marker=None, page_reverse=False):
"""Retrieve a list of floating ips.
:param context: neutron api request context.
:param filters: a dictionary with keys that are valid keys for
a floating ip as li... | [
"Retrieve",
"a",
"list",
"of",
"floating",
"ips",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/floating_ips.py#L462-L489 | [
"def",
"get_floatingips",
"(",
"context",
",",
"filters",
"=",
"None",
",",
"fields",
"=",
"None",
",",
"sorts",
"=",
"[",
"'id'",
"]",
",",
"limit",
"=",
"None",
",",
"marker",
"=",
"None",
",",
"page_reverse",
"=",
"False",
")",
":",
"LOG",
".",
... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | get_floatingips_count | Return the number of floating IPs.
:param context: neutron api request context
:param filters: a dictionary with keys that are valid keys for
a floating IP as listed in the RESOURCE_ATTRIBUTE_MAP object
in neutron/api/v2/attributes.py. Values in this dictionary
are an iterable containi... | quark/plugin_modules/floating_ips.py | def get_floatingips_count(context, filters=None):
"""Return the number of floating IPs.
:param context: neutron api request context
:param filters: a dictionary with keys that are valid keys for
a floating IP as listed in the RESOURCE_ATTRIBUTE_MAP object
in neutron/api/v2/attributes.py. V... | def get_floatingips_count(context, filters=None):
"""Return the number of floating IPs.
:param context: neutron api request context
:param filters: a dictionary with keys that are valid keys for
a floating IP as listed in the RESOURCE_ATTRIBUTE_MAP object
in neutron/api/v2/attributes.py. V... | [
"Return",
"the",
"number",
"of",
"floating",
"IPs",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/floating_ips.py#L492-L523 | [
"def",
"get_floatingips_count",
"(",
"context",
",",
"filters",
"=",
"None",
")",
":",
"LOG",
".",
"info",
"(",
"'get_floatingips_count for tenant %s filters %s'",
"%",
"(",
"context",
".",
"tenant_id",
",",
"filters",
")",
")",
"if",
"filters",
"is",
"None",
... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | create_scalingip | Allocate or reallocate a scaling IP.
:param context: neutron api request context.
:param content: dictionary describing the scaling ip, with keys
as listed in the RESOURCE_ATTRIBUTE_MAP object in
neutron/api/v2/attributes.py. All keys will be populated.
:returns: Dictionary containing det... | quark/plugin_modules/floating_ips.py | def create_scalingip(context, content):
"""Allocate or reallocate a scaling IP.
:param context: neutron api request context.
:param content: dictionary describing the scaling ip, with keys
as listed in the RESOURCE_ATTRIBUTE_MAP object in
neutron/api/v2/attributes.py. All keys will be popu... | def create_scalingip(context, content):
"""Allocate or reallocate a scaling IP.
:param context: neutron api request context.
:param content: dictionary describing the scaling ip, with keys
as listed in the RESOURCE_ATTRIBUTE_MAP object in
neutron/api/v2/attributes.py. All keys will be popu... | [
"Allocate",
"or",
"reallocate",
"a",
"scaling",
"IP",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/floating_ips.py#L526-L553 | [
"def",
"create_scalingip",
"(",
"context",
",",
"content",
")",
":",
"LOG",
".",
"info",
"(",
"'create_scalingip for tenant %s and body %s'",
",",
"context",
".",
"tenant_id",
",",
"content",
")",
"network_id",
"=",
"content",
".",
"get",
"(",
"'scaling_network_id... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | update_scalingip | Update an existing scaling IP.
:param context: neutron api request context.
:param id: id of the scaling ip
:param content: dictionary with keys indicating fields to update.
valid keys are those that have a value of True for 'allow_put'
as listed in the RESOURCE_ATTRIBUTE_MAP object in
... | quark/plugin_modules/floating_ips.py | def update_scalingip(context, id, content):
"""Update an existing scaling IP.
:param context: neutron api request context.
:param id: id of the scaling ip
:param content: dictionary with keys indicating fields to update.
valid keys are those that have a value of True for 'allow_put'
as ... | def update_scalingip(context, id, content):
"""Update an existing scaling IP.
:param context: neutron api request context.
:param id: id of the scaling ip
:param content: dictionary with keys indicating fields to update.
valid keys are those that have a value of True for 'allow_put'
as ... | [
"Update",
"an",
"existing",
"scaling",
"IP",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/floating_ips.py#L556-L574 | [
"def",
"update_scalingip",
"(",
"context",
",",
"id",
",",
"content",
")",
":",
"LOG",
".",
"info",
"(",
"'update_scalingip %s for tenant %s and body %s'",
"%",
"(",
"id",
",",
"context",
".",
"tenant_id",
",",
"content",
")",
")",
"requested_ports",
"=",
"con... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | delete_scalingip | Deallocate a scaling IP.
:param context: neutron api request context.
:param id: id of the scaling ip | quark/plugin_modules/floating_ips.py | def delete_scalingip(context, id):
"""Deallocate a scaling IP.
:param context: neutron api request context.
:param id: id of the scaling ip
"""
LOG.info('delete_scalingip %s for tenant %s' % (id, context.tenant_id))
_delete_flip(context, id, ip_types.SCALING) | def delete_scalingip(context, id):
"""Deallocate a scaling IP.
:param context: neutron api request context.
:param id: id of the scaling ip
"""
LOG.info('delete_scalingip %s for tenant %s' % (id, context.tenant_id))
_delete_flip(context, id, ip_types.SCALING) | [
"Deallocate",
"a",
"scaling",
"IP",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/floating_ips.py#L577-L584 | [
"def",
"delete_scalingip",
"(",
"context",
",",
"id",
")",
":",
"LOG",
".",
"info",
"(",
"'delete_scalingip %s for tenant %s'",
"%",
"(",
"id",
",",
"context",
".",
"tenant_id",
")",
")",
"_delete_flip",
"(",
"context",
",",
"id",
",",
"ip_types",
".",
"SC... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | get_scalingip | Retrieve a scaling IP.
:param context: neutron api request context.
:param id: The UUID of the scaling IP.
:param fields: a list of strings that are valid keys in a
scaling IP dictionary as listed in the RESOURCE_ATTRIBUTE_MAP
object in neutron/api/v2/attributes.py. Only these fields
... | quark/plugin_modules/floating_ips.py | def get_scalingip(context, id, fields=None):
"""Retrieve a scaling IP.
:param context: neutron api request context.
:param id: The UUID of the scaling IP.
:param fields: a list of strings that are valid keys in a
scaling IP dictionary as listed in the RESOURCE_ATTRIBUTE_MAP
object in ne... | def get_scalingip(context, id, fields=None):
"""Retrieve a scaling IP.
:param context: neutron api request context.
:param id: The UUID of the scaling IP.
:param fields: a list of strings that are valid keys in a
scaling IP dictionary as listed in the RESOURCE_ATTRIBUTE_MAP
object in ne... | [
"Retrieve",
"a",
"scaling",
"IP",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/floating_ips.py#L587-L607 | [
"def",
"get_scalingip",
"(",
"context",
",",
"id",
",",
"fields",
"=",
"None",
")",
":",
"LOG",
".",
"info",
"(",
"'get_scalingip %s for tenant %s'",
"%",
"(",
"id",
",",
"context",
".",
"tenant_id",
")",
")",
"filters",
"=",
"{",
"'address_type'",
":",
... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | get_scalingips | Retrieve a list of scaling ips.
:param context: neutron api request context.
:param filters: a dictionary with keys that are valid keys for
a scaling ip as listed in the RESOURCE_ATTRIBUTE_MAP object
in neutron/api/v2/attributes.py. Values in this dictionary
are an iterable containing ... | quark/plugin_modules/floating_ips.py | def get_scalingips(context, filters=None, fields=None, sorts=['id'],
limit=None, marker=None, page_reverse=False):
"""Retrieve a list of scaling ips.
:param context: neutron api request context.
:param filters: a dictionary with keys that are valid keys for
a scaling ip as listed... | def get_scalingips(context, filters=None, fields=None, sorts=['id'],
limit=None, marker=None, page_reverse=False):
"""Retrieve a list of scaling ips.
:param context: neutron api request context.
:param filters: a dictionary with keys that are valid keys for
a scaling ip as listed... | [
"Retrieve",
"a",
"list",
"of",
"scaling",
"ips",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/floating_ips.py#L610-L635 | [
"def",
"get_scalingips",
"(",
"context",
",",
"filters",
"=",
"None",
",",
"fields",
"=",
"None",
",",
"sorts",
"=",
"[",
"'id'",
"]",
",",
"limit",
"=",
"None",
",",
"marker",
"=",
"None",
",",
"page_reverse",
"=",
"False",
")",
":",
"LOG",
".",
"... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | update_ip_address | Due to NCP-1592 ensure that address_type cannot change after update. | quark/plugin_modules/ip_addresses.py | def update_ip_address(context, id, ip_address):
"""Due to NCP-1592 ensure that address_type cannot change after update."""
LOG.info("update_ip_address %s for tenant %s" % (id, context.tenant_id))
ports = []
if 'ip_address' not in ip_address:
raise n_exc.BadRequest(resource="ip_addresses",
... | def update_ip_address(context, id, ip_address):
"""Due to NCP-1592 ensure that address_type cannot change after update."""
LOG.info("update_ip_address %s for tenant %s" % (id, context.tenant_id))
ports = []
if 'ip_address' not in ip_address:
raise n_exc.BadRequest(resource="ip_addresses",
... | [
"Due",
"to",
"NCP",
"-",
"1592",
"ensure",
"that",
"address_type",
"cannot",
"change",
"after",
"update",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/ip_addresses.py#L281-L369 | [
"def",
"update_ip_address",
"(",
"context",
",",
"id",
",",
"ip_address",
")",
":",
"LOG",
".",
"info",
"(",
"\"update_ip_address %s for tenant %s\"",
"%",
"(",
"id",
",",
"context",
".",
"tenant_id",
")",
")",
"ports",
"=",
"[",
"]",
"if",
"'ip_address'",
... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | delete_ip_address | Delete an ip address.
: param context: neutron api request context
: param id: UUID representing the ip address to delete. | quark/plugin_modules/ip_addresses.py | def delete_ip_address(context, id):
"""Delete an ip address.
: param context: neutron api request context
: param id: UUID representing the ip address to delete.
"""
LOG.info("delete_ip_address %s for tenant %s" % (id, context.tenant_id))
with context.session.begin():
ip_address = db_ap... | def delete_ip_address(context, id):
"""Delete an ip address.
: param context: neutron api request context
: param id: UUID representing the ip address to delete.
"""
LOG.info("delete_ip_address %s for tenant %s" % (id, context.tenant_id))
with context.session.begin():
ip_address = db_ap... | [
"Delete",
"an",
"ip",
"address",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/ip_addresses.py#L372-L396 | [
"def",
"delete_ip_address",
"(",
"context",
",",
"id",
")",
":",
"LOG",
".",
"info",
"(",
"\"delete_ip_address %s for tenant %s\"",
"%",
"(",
"id",
",",
"context",
".",
"tenant_id",
")",
")",
"with",
"context",
".",
"session",
".",
"begin",
"(",
")",
":",
... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | get_ports_for_ip_address | Retrieve a list of ports.
The contents of the list depends on the identity of the user
making the request (as indicated by the context) as well as any
filters.
: param context: neutron api request context
: param filters: a dictionary with keys that are valid keys for
a port as listed in th... | quark/plugin_modules/ip_addresses.py | def get_ports_for_ip_address(context, ip_id, limit=None, sorts=['id'],
marker=None, page_reverse=False, filters=None,
fields=None):
"""Retrieve a list of ports.
The contents of the list depends on the identity of the user
making the request (as indi... | def get_ports_for_ip_address(context, ip_id, limit=None, sorts=['id'],
marker=None, page_reverse=False, filters=None,
fields=None):
"""Retrieve a list of ports.
The contents of the list depends on the identity of the user
making the request (as indi... | [
"Retrieve",
"a",
"list",
"of",
"ports",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/ip_addresses.py#L399-L434 | [
"def",
"get_ports_for_ip_address",
"(",
"context",
",",
"ip_id",
",",
"limit",
"=",
"None",
",",
"sorts",
"=",
"[",
"'id'",
"]",
",",
"marker",
"=",
"None",
",",
"page_reverse",
"=",
"False",
",",
"filters",
"=",
"None",
",",
"fields",
"=",
"None",
")"... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | get_port_for_ip_address | Retrieve a port.
: param context: neutron api request context
: param id: UUID representing the port to fetch.
: param fields: a list of strings that are valid keys in a
port dictionary as listed in the RESOURCE_ATTRIBUTE_MAP
object in neutron/api/v2/attributes.py. Only these fields
... | quark/plugin_modules/ip_addresses.py | def get_port_for_ip_address(context, ip_id, id, fields=None):
"""Retrieve a port.
: param context: neutron api request context
: param id: UUID representing the port to fetch.
: param fields: a list of strings that are valid keys in a
port dictionary as listed in the RESOURCE_ATTRIBUTE_MAP
... | def get_port_for_ip_address(context, ip_id, id, fields=None):
"""Retrieve a port.
: param context: neutron api request context
: param id: UUID representing the port to fetch.
: param fields: a list of strings that are valid keys in a
port dictionary as listed in the RESOURCE_ATTRIBUTE_MAP
... | [
"Retrieve",
"a",
"port",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/ip_addresses.py#L437-L460 | [
"def",
"get_port_for_ip_address",
"(",
"context",
",",
"ip_id",
",",
"id",
",",
"fields",
"=",
"None",
")",
":",
"LOG",
".",
"info",
"(",
"\"get_port %s for tenant %s fields %s\"",
"%",
"(",
"id",
",",
"context",
".",
"tenant_id",
",",
"fields",
")",
")",
... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | update_port_for_ip_address | Update values of a port.
: param context: neutron api request context
: param ip_id: UUID representing the ip associated with port to update
: param id: UUID representing the port to update.
: param port: dictionary with keys indicating fields to update.
valid keys are those that have a value o... | quark/plugin_modules/ip_addresses.py | def update_port_for_ip_address(context, ip_id, id, port):
"""Update values of a port.
: param context: neutron api request context
: param ip_id: UUID representing the ip associated with port to update
: param id: UUID representing the port to update.
: param port: dictionary with keys indicating f... | def update_port_for_ip_address(context, ip_id, id, port):
"""Update values of a port.
: param context: neutron api request context
: param ip_id: UUID representing the ip associated with port to update
: param id: UUID representing the port to update.
: param port: dictionary with keys indicating f... | [
"Update",
"values",
"of",
"a",
"port",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/ip_addresses.py#L463-L492 | [
"def",
"update_port_for_ip_address",
"(",
"context",
",",
"ip_id",
",",
"id",
",",
"port",
")",
":",
"LOG",
".",
"info",
"(",
"\"update_port %s for tenant %s\"",
"%",
"(",
"id",
",",
"context",
".",
"tenant_id",
")",
")",
"sanitize_list",
"=",
"[",
"'service... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | is_isonet_vif | Determine if a vif is on isonet
Returns True if a vif belongs to an isolated network by checking
for a nicira interface id. | quark/agent/agent.py | def is_isonet_vif(vif):
"""Determine if a vif is on isonet
Returns True if a vif belongs to an isolated network by checking
for a nicira interface id.
"""
nicira_iface_id = vif.record.get('other_config').get('nicira-iface-id')
if nicira_iface_id:
return True
return False | def is_isonet_vif(vif):
"""Determine if a vif is on isonet
Returns True if a vif belongs to an isolated network by checking
for a nicira interface id.
"""
nicira_iface_id = vif.record.get('other_config').get('nicira-iface-id')
if nicira_iface_id:
return True
return False | [
"Determine",
"if",
"a",
"vif",
"is",
"on",
"isonet"
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/agent/agent.py#L48-L59 | [
"def",
"is_isonet_vif",
"(",
"vif",
")",
":",
"nicira_iface_id",
"=",
"vif",
".",
"record",
".",
"get",
"(",
"'other_config'",
")",
".",
"get",
"(",
"'nicira-iface-id'",
")",
"if",
"nicira_iface_id",
":",
"return",
"True",
"return",
"False"
] | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | partition_vifs | Splits VIFs into three explicit categories and one implicit
Added - Groups exist in Redis that have not been ack'd and the VIF
is not tagged.
Action: Tag the VIF and apply flows
Updated - Groups exist in Redis that have not been ack'd and the VIF
is already tagged
... | quark/agent/agent.py | def partition_vifs(xapi_client, interfaces, security_group_states):
"""Splits VIFs into three explicit categories and one implicit
Added - Groups exist in Redis that have not been ack'd and the VIF
is not tagged.
Action: Tag the VIF and apply flows
Updated - Groups exist in Redis th... | def partition_vifs(xapi_client, interfaces, security_group_states):
"""Splits VIFs into three explicit categories and one implicit
Added - Groups exist in Redis that have not been ack'd and the VIF
is not tagged.
Action: Tag the VIF and apply flows
Updated - Groups exist in Redis th... | [
"Splits",
"VIFs",
"into",
"three",
"explicit",
"categories",
"and",
"one",
"implicit"
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/agent/agent.py#L62-L107 | [
"def",
"partition_vifs",
"(",
"xapi_client",
",",
"interfaces",
",",
"security_group_states",
")",
":",
"added",
"=",
"[",
"]",
"updated",
"=",
"[",
"]",
"removed",
"=",
"[",
"]",
"for",
"vif",
"in",
"interfaces",
":",
"# Quark should not action on isonet vifs i... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | get_groups_to_ack | Compares initial security group rules with current sg rules.
Given the groups that were successfully returned from
xapi_client.update_interfaces call, compare initial and current
security group rules to determine if an update occurred during
the window that the xapi_client.update_interfaces... | quark/agent/agent.py | def get_groups_to_ack(groups_to_ack, init_sg_states, curr_sg_states):
"""Compares initial security group rules with current sg rules.
Given the groups that were successfully returned from
xapi_client.update_interfaces call, compare initial and current
security group rules to determine if an upd... | def get_groups_to_ack(groups_to_ack, init_sg_states, curr_sg_states):
"""Compares initial security group rules with current sg rules.
Given the groups that were successfully returned from
xapi_client.update_interfaces call, compare initial and current
security group rules to determine if an upd... | [
"Compares",
"initial",
"security",
"group",
"rules",
"with",
"current",
"sg",
"rules",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/agent/agent.py#L115-L149 | [
"def",
"get_groups_to_ack",
"(",
"groups_to_ack",
",",
"init_sg_states",
",",
"curr_sg_states",
")",
":",
"security_groups_changed",
"=",
"[",
"]",
"# Compare current security group rules with initial rules.",
"for",
"vif",
"in",
"groups_to_ack",
":",
"initial_state",
"=",
... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | run | Fetches changes and applies them to VIFs periodically
Process as of RM11449:
* Get all groups from redis
* Fetch ALL VIFs from Xen
* Walk ALL VIFs and partition them into added, updated and removed
* Walk the final "modified" VIFs list and apply flows to each | quark/agent/agent.py | def run():
"""Fetches changes and applies them to VIFs periodically
Process as of RM11449:
* Get all groups from redis
* Fetch ALL VIFs from Xen
* Walk ALL VIFs and partition them into added, updated and removed
* Walk the final "modified" VIFs list and apply flows to each
"""
groups_cl... | def run():
"""Fetches changes and applies them to VIFs periodically
Process as of RM11449:
* Get all groups from redis
* Fetch ALL VIFs from Xen
* Walk ALL VIFs and partition them into added, updated and removed
* Walk the final "modified" VIFs list and apply flows to each
"""
groups_cl... | [
"Fetches",
"changes",
"and",
"applies",
"them",
"to",
"VIFs",
"periodically"
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/agent/agent.py#L152-L198 | [
"def",
"run",
"(",
")",
":",
"groups_client",
"=",
"sg_cli",
".",
"SecurityGroupsClient",
"(",
")",
"xapi_client",
"=",
"xapi",
".",
"XapiClient",
"(",
")",
"interfaces",
"=",
"set",
"(",
")",
"while",
"True",
":",
"try",
":",
"interfaces",
"=",
"xapi_cl... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | QuarkQuotaDriver.delete_tenant_quota | Delete the quota entries for a given tenant_id.
Atfer deletion, this tenant will use default quota values in conf. | quark/quota_driver.py | def delete_tenant_quota(context, tenant_id):
"""Delete the quota entries for a given tenant_id.
Atfer deletion, this tenant will use default quota values in conf.
"""
tenant_quotas = context.session.query(Quota)
tenant_quotas = tenant_quotas.filter_by(tenant_id=tenant_id)
... | def delete_tenant_quota(context, tenant_id):
"""Delete the quota entries for a given tenant_id.
Atfer deletion, this tenant will use default quota values in conf.
"""
tenant_quotas = context.session.query(Quota)
tenant_quotas = tenant_quotas.filter_by(tenant_id=tenant_id)
... | [
"Delete",
"the",
"quota",
"entries",
"for",
"a",
"given",
"tenant_id",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/quota_driver.py#L29-L37 | [
"def",
"delete_tenant_quota",
"(",
"context",
",",
"tenant_id",
")",
":",
"tenant_quotas",
"=",
"context",
".",
"session",
".",
"query",
"(",
"Quota",
")",
"tenant_quotas",
"=",
"tenant_quotas",
".",
"filter_by",
"(",
"tenant_id",
"=",
"tenant_id",
")",
"tenan... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | Ip_addresses.get_resources | Returns Ext Resources. | quark/api/extensions/ip_addresses.py | def get_resources(cls):
"""Returns Ext Resources."""
ip_controller = IpAddressesController(
directory.get_plugin())
ip_port_controller = IpAddressPortController(
directory.get_plugin())
resources = []
resources.append(extensions.ResourceExtension(
... | def get_resources(cls):
"""Returns Ext Resources."""
ip_controller = IpAddressesController(
directory.get_plugin())
ip_port_controller = IpAddressPortController(
directory.get_plugin())
resources = []
resources.append(extensions.ResourceExtension(
... | [
"Returns",
"Ext",
"Resources",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/api/extensions/ip_addresses.py#L153-L167 | [
"def",
"get_resources",
"(",
"cls",
")",
":",
"ip_controller",
"=",
"IpAddressesController",
"(",
"directory",
".",
"get_plugin",
"(",
")",
")",
"ip_port_controller",
"=",
"IpAddressPortController",
"(",
"directory",
".",
"get_plugin",
"(",
")",
")",
"resources",
... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | _validate_subnet_cidr | Validate the CIDR for a subnet.
Verifies the specified CIDR does not overlap with the ones defined
for the other subnets specified for this network, or with any other
CIDR if overlapping IPs are disabled. | quark/plugin_modules/subnets.py | def _validate_subnet_cidr(context, network_id, new_subnet_cidr):
"""Validate the CIDR for a subnet.
Verifies the specified CIDR does not overlap with the ones defined
for the other subnets specified for this network, or with any other
CIDR if overlapping IPs are disabled.
"""
if neutron_cfg.cf... | def _validate_subnet_cidr(context, network_id, new_subnet_cidr):
"""Validate the CIDR for a subnet.
Verifies the specified CIDR does not overlap with the ones defined
for the other subnets specified for this network, or with any other
CIDR if overlapping IPs are disabled.
"""
if neutron_cfg.cf... | [
"Validate",
"the",
"CIDR",
"for",
"a",
"subnet",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/subnets.py#L55-L94 | [
"def",
"_validate_subnet_cidr",
"(",
"context",
",",
"network_id",
",",
"new_subnet_cidr",
")",
":",
"if",
"neutron_cfg",
".",
"cfg",
".",
"CONF",
".",
"allow_overlapping_ips",
":",
"return",
"try",
":",
"new_subnet_ipset",
"=",
"netaddr",
".",
"IPSet",
"(",
"... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | create_subnet | Create a subnet.
Create a subnet which represents a range of IP addresses
that can be allocated to devices
: param context: neutron api request context
: param subnet: dictionary describing the subnet, with keys
as listed in the RESOURCE_ATTRIBUTE_MAP object in
neutron/api/v2/attribute... | quark/plugin_modules/subnets.py | def create_subnet(context, subnet):
"""Create a subnet.
Create a subnet which represents a range of IP addresses
that can be allocated to devices
: param context: neutron api request context
: param subnet: dictionary describing the subnet, with keys
as listed in the RESOURCE_ATTRIBUTE_MAP... | def create_subnet(context, subnet):
"""Create a subnet.
Create a subnet which represents a range of IP addresses
that can be allocated to devices
: param context: neutron api request context
: param subnet: dictionary describing the subnet, with keys
as listed in the RESOURCE_ATTRIBUTE_MAP... | [
"Create",
"a",
"subnet",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/subnets.py#L97-L231 | [
"def",
"create_subnet",
"(",
"context",
",",
"subnet",
")",
":",
"LOG",
".",
"info",
"(",
"\"create_subnet for tenant %s\"",
"%",
"context",
".",
"tenant_id",
")",
"net_id",
"=",
"subnet",
"[",
"\"subnet\"",
"]",
"[",
"\"network_id\"",
"]",
"with",
"context",
... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | update_subnet | Update values of a subnet.
: param context: neutron api request context
: param id: UUID representing the subnet to update.
: param subnet: dictionary with keys indicating fields to update.
valid keys are those that have a value of True for 'allow_put'
as listed in the RESOURCE_ATTRIBUTE_MA... | quark/plugin_modules/subnets.py | def update_subnet(context, id, subnet):
"""Update values of a subnet.
: param context: neutron api request context
: param id: UUID representing the subnet to update.
: param subnet: dictionary with keys indicating fields to update.
valid keys are those that have a value of True for 'allow_put'... | def update_subnet(context, id, subnet):
"""Update values of a subnet.
: param context: neutron api request context
: param id: UUID representing the subnet to update.
: param subnet: dictionary with keys indicating fields to update.
valid keys are those that have a value of True for 'allow_put'... | [
"Update",
"values",
"of",
"a",
"subnet",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/subnets.py#L249-L361 | [
"def",
"update_subnet",
"(",
"context",
",",
"id",
",",
"subnet",
")",
":",
"LOG",
".",
"info",
"(",
"\"update_subnet %s for tenant %s\"",
"%",
"(",
"id",
",",
"context",
".",
"tenant_id",
")",
")",
"with",
"context",
".",
"session",
".",
"begin",
"(",
"... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | get_subnet | Retrieve a subnet.
: param context: neutron api request context
: param id: UUID representing the subnet to fetch.
: param fields: a list of strings that are valid keys in a
subnet dictionary as listed in the RESOURCE_ATTRIBUTE_MAP
object in neutron/api/v2/attributes.py. Only these fields
... | quark/plugin_modules/subnets.py | def get_subnet(context, id, fields=None):
"""Retrieve a subnet.
: param context: neutron api request context
: param id: UUID representing the subnet to fetch.
: param fields: a list of strings that are valid keys in a
subnet dictionary as listed in the RESOURCE_ATTRIBUTE_MAP
object in ... | def get_subnet(context, id, fields=None):
"""Retrieve a subnet.
: param context: neutron api request context
: param id: UUID representing the subnet to fetch.
: param fields: a list of strings that are valid keys in a
subnet dictionary as listed in the RESOURCE_ATTRIBUTE_MAP
object in ... | [
"Retrieve",
"a",
"subnet",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/subnets.py#L364-L388 | [
"def",
"get_subnet",
"(",
"context",
",",
"id",
",",
"fields",
"=",
"None",
")",
":",
"LOG",
".",
"info",
"(",
"\"get_subnet %s for tenant %s with fields %s\"",
"%",
"(",
"id",
",",
"context",
".",
"tenant_id",
",",
"fields",
")",
")",
"subnet",
"=",
"db_a... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | get_subnets | Retrieve a list of subnets.
The contents of the list depends on the identity of the user
making the request (as indicated by the context) as well as any
filters.
: param context: neutron api request context
: param filters: a dictionary with keys that are valid keys for
a subnet as listed i... | quark/plugin_modules/subnets.py | def get_subnets(context, limit=None, page_reverse=False, sorts=['id'],
marker=None, filters=None, fields=None):
"""Retrieve a list of subnets.
The contents of the list depends on the identity of the user
making the request (as indicated by the context) as well as any
filters.
: para... | def get_subnets(context, limit=None, page_reverse=False, sorts=['id'],
marker=None, filters=None, fields=None):
"""Retrieve a list of subnets.
The contents of the list depends on the identity of the user
making the request (as indicated by the context) as well as any
filters.
: para... | [
"Retrieve",
"a",
"list",
"of",
"subnets",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/subnets.py#L391-L423 | [
"def",
"get_subnets",
"(",
"context",
",",
"limit",
"=",
"None",
",",
"page_reverse",
"=",
"False",
",",
"sorts",
"=",
"[",
"'id'",
"]",
",",
"marker",
"=",
"None",
",",
"filters",
"=",
"None",
",",
"fields",
"=",
"None",
")",
":",
"LOG",
".",
"inf... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | get_subnets_count | Return the number of subnets.
The result depends on the identity of the user making the request
(as indicated by the context) as well as any filters.
: param context: neutron api request context
: param filters: a dictionary with keys that are valid keys for
a network as listed in the RESOURCE_... | quark/plugin_modules/subnets.py | def get_subnets_count(context, filters=None):
"""Return the number of subnets.
The result depends on the identity of the user making the request
(as indicated by the context) as well as any filters.
: param context: neutron api request context
: param filters: a dictionary with keys that are valid ... | def get_subnets_count(context, filters=None):
"""Return the number of subnets.
The result depends on the identity of the user making the request
(as indicated by the context) as well as any filters.
: param context: neutron api request context
: param filters: a dictionary with keys that are valid ... | [
"Return",
"the",
"number",
"of",
"subnets",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/subnets.py#L426-L445 | [
"def",
"get_subnets_count",
"(",
"context",
",",
"filters",
"=",
"None",
")",
":",
"LOG",
".",
"info",
"(",
"\"get_subnets_count for tenant %s with filters %s\"",
"%",
"(",
"context",
".",
"tenant_id",
",",
"filters",
")",
")",
"return",
"db_api",
".",
"subnet_c... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.