repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
greenbone/ospd
ospd/ospd.py
OSPDaemon.get_vts_xml
def get_vts_xml(self, vt_id=None, filtered_vts=None): """ Gets collection of vulnerability test information in XML format. If vt_id is specified, the collection will contain only this vt, if found. If no vt_id is specified, the collection will contain all vts or those passed in f...
python
def get_vts_xml(self, vt_id=None, filtered_vts=None): """ Gets collection of vulnerability test information in XML format. If vt_id is specified, the collection will contain only this vt, if found. If no vt_id is specified, the collection will contain all vts or those passed in f...
[ "def", "get_vts_xml", "(", "self", ",", "vt_id", "=", "None", ",", "filtered_vts", "=", "None", ")", ":", "vts_xml", "=", "Element", "(", "'vts'", ")", "if", "vt_id", ":", "vts_xml", ".", "append", "(", "self", ".", "get_vt_xml", "(", "vt_id", ")", "...
Gets collection of vulnerability test information in XML format. If vt_id is specified, the collection will contain only this vt, if found. If no vt_id is specified, the collection will contain all vts or those passed in filtered_vts. Arguments: vt_id (vt_id, optiona...
[ "Gets", "collection", "of", "vulnerability", "test", "information", "in", "XML", "format", ".", "If", "vt_id", "is", "specified", "the", "collection", "will", "contain", "only", "this", "vt", "if", "found", ".", "If", "no", "vt_id", "is", "specified", "the",...
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/ospd.py#L1415-L1442
greenbone/ospd
ospd/ospd.py
OSPDaemon.handle_get_scanner_details
def handle_get_scanner_details(self): """ Handles <get_scanner_details> command. @return: Response string for <get_scanner_details> command. """ desc_xml = Element('description') desc_xml.text = self.get_scanner_description() details = [ desc_xml, ...
python
def handle_get_scanner_details(self): """ Handles <get_scanner_details> command. @return: Response string for <get_scanner_details> command. """ desc_xml = Element('description') desc_xml.text = self.get_scanner_description() details = [ desc_xml, ...
[ "def", "handle_get_scanner_details", "(", "self", ")", ":", "desc_xml", "=", "Element", "(", "'description'", ")", "desc_xml", ".", "text", "=", "self", ".", "get_scanner_description", "(", ")", "details", "=", "[", "desc_xml", ",", "self", ".", "get_scanner_p...
Handles <get_scanner_details> command. @return: Response string for <get_scanner_details> command.
[ "Handles", "<get_scanner_details", ">", "command", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/ospd.py#L1444-L1455
greenbone/ospd
ospd/ospd.py
OSPDaemon.handle_get_version_command
def handle_get_version_command(self): """ Handles <get_version> command. @return: Response string for <get_version> command. """ protocol = Element('protocol') for name, value in [('name', 'OSP'), ('version', self.get_protocol_version())]: elem = SubElement(protocol,...
python
def handle_get_version_command(self): """ Handles <get_version> command. @return: Response string for <get_version> command. """ protocol = Element('protocol') for name, value in [('name', 'OSP'), ('version', self.get_protocol_version())]: elem = SubElement(protocol,...
[ "def", "handle_get_version_command", "(", "self", ")", ":", "protocol", "=", "Element", "(", "'protocol'", ")", "for", "name", ",", "value", "in", "[", "(", "'name'", ",", "'OSP'", ")", ",", "(", "'version'", ",", "self", ".", "get_protocol_version", "(", ...
Handles <get_version> command. @return: Response string for <get_version> command.
[ "Handles", "<get_version", ">", "command", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/ospd.py#L1457-L1485
greenbone/ospd
ospd/ospd.py
OSPDaemon.handle_command
def handle_command(self, command): """ Handles an osp command in a string. @return: OSP Response to command. """ try: tree = secET.fromstring(command) except secET.ParseError: logger.debug("Erroneous client input: %s", command) raise OSPDError...
python
def handle_command(self, command): """ Handles an osp command in a string. @return: OSP Response to command. """ try: tree = secET.fromstring(command) except secET.ParseError: logger.debug("Erroneous client input: %s", command) raise OSPDError...
[ "def", "handle_command", "(", "self", ",", "command", ")", ":", "try", ":", "tree", "=", "secET", ".", "fromstring", "(", "command", ")", "except", "secET", ".", "ParseError", ":", "logger", ".", "debug", "(", "\"Erroneous client input: %s\"", ",", "command"...
Handles an osp command in a string. @return: OSP Response to command.
[ "Handles", "an", "osp", "command", "in", "a", "string", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/ospd.py#L1487-L1518
greenbone/ospd
ospd/ospd.py
OSPDaemon.run
def run(self, address, port, unix_path): """ Starts the Daemon, handling commands until interrupted. @return False if error. Runs indefinitely otherwise. """ assert address or unix_path if unix_path: sock = bind_unix_socket(unix_path) else: sock =...
python
def run(self, address, port, unix_path): """ Starts the Daemon, handling commands until interrupted. @return False if error. Runs indefinitely otherwise. """ assert address or unix_path if unix_path: sock = bind_unix_socket(unix_path) else: sock =...
[ "def", "run", "(", "self", ",", "address", ",", "port", ",", "unix_path", ")", ":", "assert", "address", "or", "unix_path", "if", "unix_path", ":", "sock", "=", "bind_unix_socket", "(", "unix_path", ")", "else", ":", "sock", "=", "bind_socket", "(", "add...
Starts the Daemon, handling commands until interrupted. @return False if error. Runs indefinitely otherwise.
[ "Starts", "the", "Daemon", "handling", "commands", "until", "interrupted", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/ospd.py#L1524-L1560
greenbone/ospd
ospd/ospd.py
OSPDaemon.create_scan
def create_scan(self, scan_id, targets, options, vts): """ Creates a new scan. @target: Target to scan. @options: Miscellaneous scan options. @return: New scan's ID. """ if self.scan_exists(scan_id): logger.info("Scan %s exists. Resuming scan.", scan_id) ...
python
def create_scan(self, scan_id, targets, options, vts): """ Creates a new scan. @target: Target to scan. @options: Miscellaneous scan options. @return: New scan's ID. """ if self.scan_exists(scan_id): logger.info("Scan %s exists. Resuming scan.", scan_id) ...
[ "def", "create_scan", "(", "self", ",", "scan_id", ",", "targets", ",", "options", ",", "vts", ")", ":", "if", "self", ".", "scan_exists", "(", "scan_id", ")", ":", "logger", ".", "info", "(", "\"Scan %s exists. Resuming scan.\"", ",", "scan_id", ")", "ret...
Creates a new scan. @target: Target to scan. @options: Miscellaneous scan options. @return: New scan's ID.
[ "Creates", "a", "new", "scan", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/ospd.py#L1566-L1577
greenbone/ospd
ospd/ospd.py
OSPDaemon.set_scan_option
def set_scan_option(self, scan_id, name, value): """ Sets a scan's option to a provided value. """ return self.scan_collection.set_option(scan_id, name, value)
python
def set_scan_option(self, scan_id, name, value): """ Sets a scan's option to a provided value. """ return self.scan_collection.set_option(scan_id, name, value)
[ "def", "set_scan_option", "(", "self", ",", "scan_id", ",", "name", ",", "value", ")", ":", "return", "self", ".", "scan_collection", ".", "set_option", "(", "scan_id", ",", "name", ",", "value", ")" ]
Sets a scan's option to a provided value.
[ "Sets", "a", "scan", "s", "option", "to", "a", "provided", "value", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/ospd.py#L1583-L1585
greenbone/ospd
ospd/ospd.py
OSPDaemon.check_scan_process
def check_scan_process(self, scan_id): """ Check the scan's process, and terminate the scan if not alive. """ scan_process = self.scan_processes[scan_id] progress = self.get_scan_progress(scan_id) if progress < 100 and not scan_process.is_alive(): self.set_scan_status(scan_id...
python
def check_scan_process(self, scan_id): """ Check the scan's process, and terminate the scan if not alive. """ scan_process = self.scan_processes[scan_id] progress = self.get_scan_progress(scan_id) if progress < 100 and not scan_process.is_alive(): self.set_scan_status(scan_id...
[ "def", "check_scan_process", "(", "self", ",", "scan_id", ")", ":", "scan_process", "=", "self", ".", "scan_processes", "[", "scan_id", "]", "progress", "=", "self", ".", "get_scan_progress", "(", "scan_id", ")", "if", "progress", "<", "100", "and", "not", ...
Check the scan's process, and terminate the scan if not alive.
[ "Check", "the", "scan", "s", "process", "and", "terminate", "the", "scan", "if", "not", "alive", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/ospd.py#L1587-L1597
greenbone/ospd
ospd/ospd.py
OSPDaemon.add_scan_log
def add_scan_log(self, scan_id, host='', name='', value='', port='', test_id='', qod=''): """ Adds a log result to scan_id scan. """ self.scan_collection.add_result(scan_id, ResultType.LOG, host, name, value, port, test_id, 0.0, qod)
python
def add_scan_log(self, scan_id, host='', name='', value='', port='', test_id='', qod=''): """ Adds a log result to scan_id scan. """ self.scan_collection.add_result(scan_id, ResultType.LOG, host, name, value, port, test_id, 0.0, qod)
[ "def", "add_scan_log", "(", "self", ",", "scan_id", ",", "host", "=", "''", ",", "name", "=", "''", ",", "value", "=", "''", ",", "port", "=", "''", ",", "test_id", "=", "''", ",", "qod", "=", "''", ")", ":", "self", ".", "scan_collection", ".", ...
Adds a log result to scan_id scan.
[ "Adds", "a", "log", "result", "to", "scan_id", "scan", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/ospd.py#L1632-L1636
greenbone/ospd
ospd/ospd.py
OSPDaemon.add_scan_error
def add_scan_error(self, scan_id, host='', name='', value='', port=''): """ Adds an error result to scan_id scan. """ self.scan_collection.add_result(scan_id, ResultType.ERROR, host, name, value, port)
python
def add_scan_error(self, scan_id, host='', name='', value='', port=''): """ Adds an error result to scan_id scan. """ self.scan_collection.add_result(scan_id, ResultType.ERROR, host, name, value, port)
[ "def", "add_scan_error", "(", "self", ",", "scan_id", ",", "host", "=", "''", ",", "name", "=", "''", ",", "value", "=", "''", ",", "port", "=", "''", ")", ":", "self", ".", "scan_collection", ".", "add_result", "(", "scan_id", ",", "ResultType", "."...
Adds an error result to scan_id scan.
[ "Adds", "an", "error", "result", "to", "scan_id", "scan", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/ospd.py#L1638-L1641
greenbone/ospd
ospd/ospd.py
OSPDaemon.add_scan_host_detail
def add_scan_host_detail(self, scan_id, host='', name='', value=''): """ Adds a host detail result to scan_id scan. """ self.scan_collection.add_result(scan_id, ResultType.HOST_DETAIL, host, name, value)
python
def add_scan_host_detail(self, scan_id, host='', name='', value=''): """ Adds a host detail result to scan_id scan. """ self.scan_collection.add_result(scan_id, ResultType.HOST_DETAIL, host, name, value)
[ "def", "add_scan_host_detail", "(", "self", ",", "scan_id", ",", "host", "=", "''", ",", "name", "=", "''", ",", "value", "=", "''", ")", ":", "self", ".", "scan_collection", ".", "add_result", "(", "scan_id", ",", "ResultType", ".", "HOST_DETAIL", ",", ...
Adds a host detail result to scan_id scan.
[ "Adds", "a", "host", "detail", "result", "to", "scan_id", "scan", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/ospd.py#L1643-L1646
greenbone/ospd
ospd/ospd.py
OSPDaemon.add_scan_alarm
def add_scan_alarm(self, scan_id, host='', name='', value='', port='', test_id='', severity='', qod=''): """ Adds an alarm result to scan_id scan. """ self.scan_collection.add_result(scan_id, ResultType.ALARM, host, name, value, port, test_i...
python
def add_scan_alarm(self, scan_id, host='', name='', value='', port='', test_id='', severity='', qod=''): """ Adds an alarm result to scan_id scan. """ self.scan_collection.add_result(scan_id, ResultType.ALARM, host, name, value, port, test_i...
[ "def", "add_scan_alarm", "(", "self", ",", "scan_id", ",", "host", "=", "''", ",", "name", "=", "''", ",", "value", "=", "''", ",", "port", "=", "''", ",", "test_id", "=", "''", ",", "severity", "=", "''", ",", "qod", "=", "''", ")", ":", "self...
Adds an alarm result to scan_id scan.
[ "Adds", "an", "alarm", "result", "to", "scan_id", "scan", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/ospd.py#L1648-L1652
greenbone/ospd
ospd/vtfilter.py
VtsFilter.parse_filters
def parse_filters(self, vt_filter): """ Parse a string containing one or more filters and return a list of filters Arguments: vt_filter (string): String containing filters separated with semicolon. Return: List with filters. Each filters is a list...
python
def parse_filters(self, vt_filter): """ Parse a string containing one or more filters and return a list of filters Arguments: vt_filter (string): String containing filters separated with semicolon. Return: List with filters. Each filters is a list...
[ "def", "parse_filters", "(", "self", ",", "vt_filter", ")", ":", "filter_list", "=", "vt_filter", ".", "split", "(", "';'", ")", "filters", "=", "list", "(", ")", "for", "single_filter", "in", "filter_list", ":", "filter_aux", "=", "re", ".", "split", "(...
Parse a string containing one or more filters and return a list of filters Arguments: vt_filter (string): String containing filters separated with semicolon. Return: List with filters. Each filters is a list with 3 elements e.g. [arg, operator...
[ "Parse", "a", "string", "containing", "one", "or", "more", "filters", "and", "return", "a", "list", "of", "filters" ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/vtfilter.py#L41-L67
greenbone/ospd
ospd/vtfilter.py
VtsFilter.format_filter_value
def format_filter_value(self, element, value): """ Calls the specific function to format value, depending on the given element. Arguments: element (string): The element of the VT to be formatted. value (dictionary): The element value. Returns: Return...
python
def format_filter_value(self, element, value): """ Calls the specific function to format value, depending on the given element. Arguments: element (string): The element of the VT to be formatted. value (dictionary): The element value. Returns: Return...
[ "def", "format_filter_value", "(", "self", ",", "element", ",", "value", ")", ":", "format_func", "=", "self", ".", "allowed_filter", ".", "get", "(", "element", ")", "return", "format_func", "(", "value", ")" ]
Calls the specific function to format value, depending on the given element. Arguments: element (string): The element of the VT to be formatted. value (dictionary): The element value. Returns: Returns a formatted value.
[ "Calls", "the", "specific", "function", "to", "format", "value", "depending", "on", "the", "given", "element", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/vtfilter.py#L81-L94
greenbone/ospd
ospd/vtfilter.py
VtsFilter.get_filtered_vts_list
def get_filtered_vts_list(self, vts, vt_filter): """ Gets a collection of vulnerability test from the vts dictionary, which match the filter. Arguments: vt_filter (string): Filter to apply to the vts collection. vts (dictionary): The complete vts collection. Ret...
python
def get_filtered_vts_list(self, vts, vt_filter): """ Gets a collection of vulnerability test from the vts dictionary, which match the filter. Arguments: vt_filter (string): Filter to apply to the vts collection. vts (dictionary): The complete vts collection. Ret...
[ "def", "get_filtered_vts_list", "(", "self", ",", "vts", ",", "vt_filter", ")", ":", "if", "not", "vt_filter", ":", "raise", "RequiredArgument", "(", "'vt_filter: A valid filter is required.'", ")", "filters", "=", "self", ".", "parse_filters", "(", "vt_filter", "...
Gets a collection of vulnerability test from the vts dictionary, which match the filter. Arguments: vt_filter (string): Filter to apply to the vts collection. vts (dictionary): The complete vts collection. Returns: Dictionary with filtered vulnerability test...
[ "Gets", "a", "collection", "of", "vulnerability", "test", "from", "the", "vts", "dictionary", "which", "match", "the", "filter", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/vtfilter.py#L96-L127
greenbone/ospd
ospd/cvss.py
CVSS.cvss_base_v2_value
def cvss_base_v2_value(cls, cvss_base_vector): """ Calculate the cvss base score from a cvss base vector for cvss version 2. Arguments: cvss_base_vector (str) Cvss base vector v2. Return the calculated score """ if not cvss_base_vector: return Non...
python
def cvss_base_v2_value(cls, cvss_base_vector): """ Calculate the cvss base score from a cvss base vector for cvss version 2. Arguments: cvss_base_vector (str) Cvss base vector v2. Return the calculated score """ if not cvss_base_vector: return Non...
[ "def", "cvss_base_v2_value", "(", "cls", ",", "cvss_base_vector", ")", ":", "if", "not", "cvss_base_vector", ":", "return", "None", "_av", ",", "_ac", ",", "_au", ",", "_c", ",", "_i", ",", "_a", "=", "cls", ".", "_parse_cvss_base_vector", "(", "cvss_base_...
Calculate the cvss base score from a cvss base vector for cvss version 2. Arguments: cvss_base_vector (str) Cvss base vector v2. Return the calculated score
[ "Calculate", "the", "cvss", "base", "score", "from", "a", "cvss", "base", "vector", "for", "cvss", "version", "2", ".", "Arguments", ":", "cvss_base_vector", "(", "str", ")", "Cvss", "base", "vector", "v2", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/cvss.py#L65-L91
greenbone/ospd
ospd/cvss.py
CVSS.cvss_base_v3_value
def cvss_base_v3_value(cls, cvss_base_vector): """ Calculate the cvss base score from a cvss base vector for cvss version 3. Arguments: cvss_base_vector (str) Cvss base vector v3. Return the calculated score, None on fail. """ if not cvss_base_vector: ...
python
def cvss_base_v3_value(cls, cvss_base_vector): """ Calculate the cvss base score from a cvss base vector for cvss version 3. Arguments: cvss_base_vector (str) Cvss base vector v3. Return the calculated score, None on fail. """ if not cvss_base_vector: ...
[ "def", "cvss_base_v3_value", "(", "cls", ",", "cvss_base_vector", ")", ":", "if", "not", "cvss_base_vector", ":", "return", "None", "_ver", ",", "_av", ",", "_ac", ",", "_pr", ",", "_ui", ",", "_s", ",", "_c", ",", "_i", ",", "_a", "=", "cls", ".", ...
Calculate the cvss base score from a cvss base vector for cvss version 3. Arguments: cvss_base_vector (str) Cvss base vector v3. Return the calculated score, None on fail.
[ "Calculate", "the", "cvss", "base", "score", "from", "a", "cvss", "base", "vector", "for", "cvss", "version", "3", ".", "Arguments", ":", "cvss_base_vector", "(", "str", ")", "Cvss", "base", "vector", "v3", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/cvss.py#L94-L139
greenbone/ospd
ospd/misc.py
inet_pton
def inet_pton(address_family, ip_string): """ A platform independent version of inet_pton """ global __inet_pton if __inet_pton is None: if hasattr(socket, 'inet_pton'): __inet_pton = socket.inet_pton else: from ospd import win_socket __inet_pton = win_soc...
python
def inet_pton(address_family, ip_string): """ A platform independent version of inet_pton """ global __inet_pton if __inet_pton is None: if hasattr(socket, 'inet_pton'): __inet_pton = socket.inet_pton else: from ospd import win_socket __inet_pton = win_soc...
[ "def", "inet_pton", "(", "address_family", ",", "ip_string", ")", ":", "global", "__inet_pton", "if", "__inet_pton", "is", "None", ":", "if", "hasattr", "(", "socket", ",", "'inet_pton'", ")", ":", "__inet_pton", "=", "socket", ".", "inet_pton", "else", ":",...
A platform independent version of inet_pton
[ "A", "platform", "independent", "version", "of", "inet_pton" ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/misc.py#L365-L375
greenbone/ospd
ospd/misc.py
inet_ntop
def inet_ntop(address_family, packed_ip): """ A platform independent version of inet_ntop """ global __inet_ntop if __inet_ntop is None: if hasattr(socket, 'inet_ntop'): __inet_ntop = socket.inet_ntop else: from ospd import win_socket __inet_ntop = win_soc...
python
def inet_ntop(address_family, packed_ip): """ A platform independent version of inet_ntop """ global __inet_ntop if __inet_ntop is None: if hasattr(socket, 'inet_ntop'): __inet_ntop = socket.inet_ntop else: from ospd import win_socket __inet_ntop = win_soc...
[ "def", "inet_ntop", "(", "address_family", ",", "packed_ip", ")", ":", "global", "__inet_ntop", "if", "__inet_ntop", "is", "None", ":", "if", "hasattr", "(", "socket", ",", "'inet_ntop'", ")", ":", "__inet_ntop", "=", "socket", ".", "inet_ntop", "else", ":",...
A platform independent version of inet_ntop
[ "A", "platform", "independent", "version", "of", "inet_ntop" ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/misc.py#L381-L391
greenbone/ospd
ospd/misc.py
ipv4_range_to_list
def ipv4_range_to_list(start_packed, end_packed): """ Return a list of IPv4 entries from start_packed to end_packed. """ new_list = list() start = struct.unpack('!L', start_packed)[0] end = struct.unpack('!L', end_packed)[0] for value in range(start, end + 1): new_ip = socket.inet_ntoa(stru...
python
def ipv4_range_to_list(start_packed, end_packed): """ Return a list of IPv4 entries from start_packed to end_packed. """ new_list = list() start = struct.unpack('!L', start_packed)[0] end = struct.unpack('!L', end_packed)[0] for value in range(start, end + 1): new_ip = socket.inet_ntoa(stru...
[ "def", "ipv4_range_to_list", "(", "start_packed", ",", "end_packed", ")", ":", "new_list", "=", "list", "(", ")", "start", "=", "struct", ".", "unpack", "(", "'!L'", ",", "start_packed", ")", "[", "0", "]", "end", "=", "struct", ".", "unpack", "(", "'!...
Return a list of IPv4 entries from start_packed to end_packed.
[ "Return", "a", "list", "of", "IPv4", "entries", "from", "start_packed", "to", "end_packed", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/misc.py#L414-L423
greenbone/ospd
ospd/misc.py
target_to_ipv4_short
def target_to_ipv4_short(target): """ Attempt to return a IPv4 short range list from a target string. """ splitted = target.split('-') if len(splitted) != 2: return None try: start_packed = inet_pton(socket.AF_INET, splitted[0]) end_value = int(splitted[1]) except (socket.er...
python
def target_to_ipv4_short(target): """ Attempt to return a IPv4 short range list from a target string. """ splitted = target.split('-') if len(splitted) != 2: return None try: start_packed = inet_pton(socket.AF_INET, splitted[0]) end_value = int(splitted[1]) except (socket.er...
[ "def", "target_to_ipv4_short", "(", "target", ")", ":", "splitted", "=", "target", ".", "split", "(", "'-'", ")", "if", "len", "(", "splitted", ")", "!=", "2", ":", "return", "None", "try", ":", "start_packed", "=", "inet_pton", "(", "socket", ".", "AF...
Attempt to return a IPv4 short range list from a target string.
[ "Attempt", "to", "return", "a", "IPv4", "short", "range", "list", "from", "a", "target", "string", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/misc.py#L426-L441
greenbone/ospd
ospd/misc.py
target_to_ipv4_cidr
def target_to_ipv4_cidr(target): """ Attempt to return a IPv4 CIDR list from a target string. """ splitted = target.split('/') if len(splitted) != 2: return None try: start_packed = inet_pton(socket.AF_INET, splitted[0]) block = int(splitted[1]) except (socket.error, ValueEr...
python
def target_to_ipv4_cidr(target): """ Attempt to return a IPv4 CIDR list from a target string. """ splitted = target.split('/') if len(splitted) != 2: return None try: start_packed = inet_pton(socket.AF_INET, splitted[0]) block = int(splitted[1]) except (socket.error, ValueEr...
[ "def", "target_to_ipv4_cidr", "(", "target", ")", ":", "splitted", "=", "target", ".", "split", "(", "'/'", ")", "if", "len", "(", "splitted", ")", "!=", "2", ":", "return", "None", "try", ":", "start_packed", "=", "inet_pton", "(", "socket", ".", "AF_...
Attempt to return a IPv4 CIDR list from a target string.
[ "Attempt", "to", "return", "a", "IPv4", "CIDR", "list", "from", "a", "target", "string", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/misc.py#L444-L462
greenbone/ospd
ospd/misc.py
target_to_ipv6_cidr
def target_to_ipv6_cidr(target): """ Attempt to return a IPv6 CIDR list from a target string. """ splitted = target.split('/') if len(splitted) != 2: return None try: start_packed = inet_pton(socket.AF_INET6, splitted[0]) block = int(splitted[1]) except (socket.error, ValueE...
python
def target_to_ipv6_cidr(target): """ Attempt to return a IPv6 CIDR list from a target string. """ splitted = target.split('/') if len(splitted) != 2: return None try: start_packed = inet_pton(socket.AF_INET6, splitted[0]) block = int(splitted[1]) except (socket.error, ValueE...
[ "def", "target_to_ipv6_cidr", "(", "target", ")", ":", "splitted", "=", "target", ".", "split", "(", "'/'", ")", "if", "len", "(", "splitted", ")", "!=", "2", ":", "return", "None", "try", ":", "start_packed", "=", "inet_pton", "(", "socket", ".", "AF_...
Attempt to return a IPv6 CIDR list from a target string.
[ "Attempt", "to", "return", "a", "IPv6", "CIDR", "list", "from", "a", "target", "string", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/misc.py#L465-L487
greenbone/ospd
ospd/misc.py
target_to_ipv4_long
def target_to_ipv4_long(target): """ Attempt to return a IPv4 long-range list from a target string. """ splitted = target.split('-') if len(splitted) != 2: return None try: start_packed = inet_pton(socket.AF_INET, splitted[0]) end_packed = inet_pton(socket.AF_INET, splitted[1]) ...
python
def target_to_ipv4_long(target): """ Attempt to return a IPv4 long-range list from a target string. """ splitted = target.split('-') if len(splitted) != 2: return None try: start_packed = inet_pton(socket.AF_INET, splitted[0]) end_packed = inet_pton(socket.AF_INET, splitted[1]) ...
[ "def", "target_to_ipv4_long", "(", "target", ")", ":", "splitted", "=", "target", ".", "split", "(", "'-'", ")", "if", "len", "(", "splitted", ")", "!=", "2", ":", "return", "None", "try", ":", "start_packed", "=", "inet_pton", "(", "socket", ".", "AF_...
Attempt to return a IPv4 long-range list from a target string.
[ "Attempt", "to", "return", "a", "IPv4", "long", "-", "range", "list", "from", "a", "target", "string", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/misc.py#L490-L503
greenbone/ospd
ospd/misc.py
ipv6_range_to_list
def ipv6_range_to_list(start_packed, end_packed): """ Return a list of IPv6 entries from start_packed to end_packed. """ new_list = list() start = int(binascii.hexlify(start_packed), 16) end = int(binascii.hexlify(end_packed), 16) for value in range(start, end + 1): high = value >> 64 ...
python
def ipv6_range_to_list(start_packed, end_packed): """ Return a list of IPv6 entries from start_packed to end_packed. """ new_list = list() start = int(binascii.hexlify(start_packed), 16) end = int(binascii.hexlify(end_packed), 16) for value in range(start, end + 1): high = value >> 64 ...
[ "def", "ipv6_range_to_list", "(", "start_packed", ",", "end_packed", ")", ":", "new_list", "=", "list", "(", ")", "start", "=", "int", "(", "binascii", ".", "hexlify", "(", "start_packed", ")", ",", "16", ")", "end", "=", "int", "(", "binascii", ".", "...
Return a list of IPv6 entries from start_packed to end_packed.
[ "Return", "a", "list", "of", "IPv6", "entries", "from", "start_packed", "to", "end_packed", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/misc.py#L506-L518
greenbone/ospd
ospd/misc.py
target_to_ipv6_short
def target_to_ipv6_short(target): """ Attempt to return a IPv6 short-range list from a target string. """ splitted = target.split('-') if len(splitted) != 2: return None try: start_packed = inet_pton(socket.AF_INET6, splitted[0]) end_value = int(splitted[1], 16) except (sock...
python
def target_to_ipv6_short(target): """ Attempt to return a IPv6 short-range list from a target string. """ splitted = target.split('-') if len(splitted) != 2: return None try: start_packed = inet_pton(socket.AF_INET6, splitted[0]) end_value = int(splitted[1], 16) except (sock...
[ "def", "target_to_ipv6_short", "(", "target", ")", ":", "splitted", "=", "target", ".", "split", "(", "'-'", ")", "if", "len", "(", "splitted", ")", "!=", "2", ":", "return", "None", "try", ":", "start_packed", "=", "inet_pton", "(", "socket", ".", "AF...
Attempt to return a IPv6 short-range list from a target string.
[ "Attempt", "to", "return", "a", "IPv6", "short", "-", "range", "list", "from", "a", "target", "string", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/misc.py#L521-L536
greenbone/ospd
ospd/misc.py
target_to_ipv6_long
def target_to_ipv6_long(target): """ Attempt to return a IPv6 long-range list from a target string. """ splitted = target.split('-') if len(splitted) != 2: return None try: start_packed = inet_pton(socket.AF_INET6, splitted[0]) end_packed = inet_pton(socket.AF_INET6, splitted[1]...
python
def target_to_ipv6_long(target): """ Attempt to return a IPv6 long-range list from a target string. """ splitted = target.split('-') if len(splitted) != 2: return None try: start_packed = inet_pton(socket.AF_INET6, splitted[0]) end_packed = inet_pton(socket.AF_INET6, splitted[1]...
[ "def", "target_to_ipv6_long", "(", "target", ")", ":", "splitted", "=", "target", ".", "split", "(", "'-'", ")", "if", "len", "(", "splitted", ")", "!=", "2", ":", "return", "None", "try", ":", "start_packed", "=", "inet_pton", "(", "socket", ".", "AF_...
Attempt to return a IPv6 long-range list from a target string.
[ "Attempt", "to", "return", "a", "IPv6", "long", "-", "range", "list", "from", "a", "target", "string", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/misc.py#L539-L552
greenbone/ospd
ospd/misc.py
target_to_hostname
def target_to_hostname(target): """ Attempt to return a single hostname list from a target string. """ if len(target) == 0 or len(target) > 255: return None if not re.match(r'^[\w.-]+$', target): return None return [target]
python
def target_to_hostname(target): """ Attempt to return a single hostname list from a target string. """ if len(target) == 0 or len(target) > 255: return None if not re.match(r'^[\w.-]+$', target): return None return [target]
[ "def", "target_to_hostname", "(", "target", ")", ":", "if", "len", "(", "target", ")", "==", "0", "or", "len", "(", "target", ")", ">", "255", ":", "return", "None", "if", "not", "re", ".", "match", "(", "r'^[\\w.-]+$'", ",", "target", ")", ":", "r...
Attempt to return a single hostname list from a target string.
[ "Attempt", "to", "return", "a", "single", "hostname", "list", "from", "a", "target", "string", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/misc.py#L555-L562
greenbone/ospd
ospd/misc.py
target_to_list
def target_to_list(target): """ Attempt to return a list of single hosts from a target string. """ # Is it an IPv4 address ? new_list = target_to_ipv4(target) # Is it an IPv6 address ? if not new_list: new_list = target_to_ipv6(target) # Is it an IPv4 CIDR ? if not new_list: ...
python
def target_to_list(target): """ Attempt to return a list of single hosts from a target string. """ # Is it an IPv4 address ? new_list = target_to_ipv4(target) # Is it an IPv6 address ? if not new_list: new_list = target_to_ipv6(target) # Is it an IPv4 CIDR ? if not new_list: ...
[ "def", "target_to_list", "(", "target", ")", ":", "# Is it an IPv4 address ?", "new_list", "=", "target_to_ipv4", "(", "target", ")", "# Is it an IPv6 address ?", "if", "not", "new_list", ":", "new_list", "=", "target_to_ipv6", "(", "target", ")", "# Is it an IPv4 CID...
Attempt to return a list of single hosts from a target string.
[ "Attempt", "to", "return", "a", "list", "of", "single", "hosts", "from", "a", "target", "string", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/misc.py#L565-L594
greenbone/ospd
ospd/misc.py
target_str_to_list
def target_str_to_list(target_str): """ Parses a targets string into a list of individual targets. """ new_list = list() for target in target_str.split(','): target = target.strip() target_list = target_to_list(target) if target_list: new_list.extend(target_list) ...
python
def target_str_to_list(target_str): """ Parses a targets string into a list of individual targets. """ new_list = list() for target in target_str.split(','): target = target.strip() target_list = target_to_list(target) if target_list: new_list.extend(target_list) ...
[ "def", "target_str_to_list", "(", "target_str", ")", ":", "new_list", "=", "list", "(", ")", "for", "target", "in", "target_str", ".", "split", "(", "','", ")", ":", "target", "=", "target", ".", "strip", "(", ")", "target_list", "=", "target_to_list", "...
Parses a targets string into a list of individual targets.
[ "Parses", "a", "targets", "string", "into", "a", "list", "of", "individual", "targets", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/misc.py#L597-L608
greenbone/ospd
ospd/misc.py
port_range_expand
def port_range_expand(portrange): """ Receive a port range and expands it in individual ports. @input Port range. e.g. "4-8" @return List of integers. e.g. [4, 5, 6, 7, 8] """ if not portrange or '-' not in portrange: LOGGER.info("Invalid port range format") return None...
python
def port_range_expand(portrange): """ Receive a port range and expands it in individual ports. @input Port range. e.g. "4-8" @return List of integers. e.g. [4, 5, 6, 7, 8] """ if not portrange or '-' not in portrange: LOGGER.info("Invalid port range format") return None...
[ "def", "port_range_expand", "(", "portrange", ")", ":", "if", "not", "portrange", "or", "'-'", "not", "in", "portrange", ":", "LOGGER", ".", "info", "(", "\"Invalid port range format\"", ")", "return", "None", "port_list", "=", "list", "(", ")", "for", "sing...
Receive a port range and expands it in individual ports. @input Port range. e.g. "4-8" @return List of integers. e.g. [4, 5, 6, 7, 8]
[ "Receive", "a", "port", "range", "and", "expands", "it", "in", "individual", "ports", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/misc.py#L621-L638
greenbone/ospd
ospd/misc.py
port_str_arrange
def port_str_arrange(ports): """ Gives a str in the format (always tcp listed first). T:<tcp ports/portrange comma separated>U:<udp ports comma separated> """ b_tcp = ports.find("T") b_udp = ports.find("U") if (b_udp != -1 and b_tcp != -1) and b_udp < b_tcp: return ports[b_tcp:] + ports[...
python
def port_str_arrange(ports): """ Gives a str in the format (always tcp listed first). T:<tcp ports/portrange comma separated>U:<udp ports comma separated> """ b_tcp = ports.find("T") b_udp = ports.find("U") if (b_udp != -1 and b_tcp != -1) and b_udp < b_tcp: return ports[b_tcp:] + ports[...
[ "def", "port_str_arrange", "(", "ports", ")", ":", "b_tcp", "=", "ports", ".", "find", "(", "\"T\"", ")", "b_udp", "=", "ports", ".", "find", "(", "\"U\"", ")", "if", "(", "b_udp", "!=", "-", "1", "and", "b_tcp", "!=", "-", "1", ")", "and", "b_ud...
Gives a str in the format (always tcp listed first). T:<tcp ports/portrange comma separated>U:<udp ports comma separated>
[ "Gives", "a", "str", "in", "the", "format", "(", "always", "tcp", "listed", "first", ")", ".", "T", ":", "<tcp", "ports", "/", "portrange", "comma", "separated", ">", "U", ":", "<udp", "ports", "comma", "separated", ">" ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/misc.py#L641-L650
greenbone/ospd
ospd/misc.py
ports_str_check_failed
def ports_str_check_failed(port_str): """ Check if the port string is well formed. Return True if fail, False other case. """ pattern = r'[^TU:0-9, \-]' if ( re.search(pattern, port_str) or port_str.count('T') > 1 or port_str.count('U') > 1 or port_str.count(':')...
python
def ports_str_check_failed(port_str): """ Check if the port string is well formed. Return True if fail, False other case. """ pattern = r'[^TU:0-9, \-]' if ( re.search(pattern, port_str) or port_str.count('T') > 1 or port_str.count('U') > 1 or port_str.count(':')...
[ "def", "ports_str_check_failed", "(", "port_str", ")", ":", "pattern", "=", "r'[^TU:0-9, \\-]'", "if", "(", "re", ".", "search", "(", "pattern", ",", "port_str", ")", "or", "port_str", ".", "count", "(", "'T'", ")", ">", "1", "or", "port_str", ".", "coun...
Check if the port string is well formed. Return True if fail, False other case.
[ "Check", "if", "the", "port", "string", "is", "well", "formed", ".", "Return", "True", "if", "fail", "False", "other", "case", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/misc.py#L653-L667
greenbone/ospd
ospd/misc.py
ports_as_list
def ports_as_list(port_str): """ Parses a ports string into two list of individual tcp and udp ports. @input string containing a port list e.g. T:1,2,3,5-8 U:22,80,600-1024 @return two list of sorted integers, for tcp and udp ports respectively. """ if not port_str: LOGGER.info("In...
python
def ports_as_list(port_str): """ Parses a ports string into two list of individual tcp and udp ports. @input string containing a port list e.g. T:1,2,3,5-8 U:22,80,600-1024 @return two list of sorted integers, for tcp and udp ports respectively. """ if not port_str: LOGGER.info("In...
[ "def", "ports_as_list", "(", "port_str", ")", ":", "if", "not", "port_str", ":", "LOGGER", ".", "info", "(", "\"Invalid port value\"", ")", "return", "[", "None", ",", "None", "]", "if", "ports_str_check_failed", "(", "port_str", ")", ":", "LOGGER", ".", "...
Parses a ports string into two list of individual tcp and udp ports. @input string containing a port list e.g. T:1,2,3,5-8 U:22,80,600-1024 @return two list of sorted integers, for tcp and udp ports respectively.
[ "Parses", "a", "ports", "string", "into", "two", "list", "of", "individual", "tcp", "and", "udp", "ports", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/misc.py#L670-L729
greenbone/ospd
ospd/misc.py
port_list_compress
def port_list_compress(port_list): """ Compress a port list and return a string. """ if not port_list or len(port_list) == 0: LOGGER.info("Invalid or empty port list.") return '' port_list = sorted(set(port_list)) compressed_list = [] for key, group in itertools.groupby(enumerate(p...
python
def port_list_compress(port_list): """ Compress a port list and return a string. """ if not port_list or len(port_list) == 0: LOGGER.info("Invalid or empty port list.") return '' port_list = sorted(set(port_list)) compressed_list = [] for key, group in itertools.groupby(enumerate(p...
[ "def", "port_list_compress", "(", "port_list", ")", ":", "if", "not", "port_list", "or", "len", "(", "port_list", ")", "==", "0", ":", "LOGGER", ".", "info", "(", "\"Invalid or empty port list.\"", ")", "return", "''", "port_list", "=", "sorted", "(", "set",...
Compress a port list and return a string.
[ "Compress", "a", "port", "list", "and", "return", "a", "string", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/misc.py#L742-L759
greenbone/ospd
ospd/misc.py
valid_uuid
def valid_uuid(value): """ Check if value is a valid UUID. """ try: uuid.UUID(value, version=4) return True except (TypeError, ValueError, AttributeError): return False
python
def valid_uuid(value): """ Check if value is a valid UUID. """ try: uuid.UUID(value, version=4) return True except (TypeError, ValueError, AttributeError): return False
[ "def", "valid_uuid", "(", "value", ")", ":", "try", ":", "uuid", ".", "UUID", "(", "value", ",", "version", "=", "4", ")", "return", "True", "except", "(", "TypeError", ",", "ValueError", ",", "AttributeError", ")", ":", "return", "False" ]
Check if value is a valid UUID.
[ "Check", "if", "value", "is", "a", "valid", "UUID", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/misc.py#L762-L769
greenbone/ospd
ospd/misc.py
create_args_parser
def create_args_parser(description): """ Create a command-line arguments parser for OSPD. """ parser = argparse.ArgumentParser(description=description) def network_port(string): """ Check if provided string is a valid network port. """ value = int(string) if not 0 < value <= 65535...
python
def create_args_parser(description): """ Create a command-line arguments parser for OSPD. """ parser = argparse.ArgumentParser(description=description) def network_port(string): """ Check if provided string is a valid network port. """ value = int(string) if not 0 < value <= 65535...
[ "def", "create_args_parser", "(", "description", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "description", ")", "def", "network_port", "(", "string", ")", ":", "\"\"\" Check if provided string is a valid network port. \"\"\"", "...
Create a command-line arguments parser for OSPD.
[ "Create", "a", "command", "-", "line", "arguments", "parser", "for", "OSPD", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/misc.py#L772-L846
greenbone/ospd
ospd/misc.py
go_to_background
def go_to_background(): """ Daemonize the running process. """ try: if os.fork(): sys.exit() except OSError as errmsg: LOGGER.error('Fork failed: {0}'.format(errmsg)) sys.exit('Fork failed')
python
def go_to_background(): """ Daemonize the running process. """ try: if os.fork(): sys.exit() except OSError as errmsg: LOGGER.error('Fork failed: {0}'.format(errmsg)) sys.exit('Fork failed')
[ "def", "go_to_background", "(", ")", ":", "try", ":", "if", "os", ".", "fork", "(", ")", ":", "sys", ".", "exit", "(", ")", "except", "OSError", "as", "errmsg", ":", "LOGGER", ".", "error", "(", "'Fork failed: {0}'", ".", "format", "(", "errmsg", ")"...
Daemonize the running process.
[ "Daemonize", "the", "running", "process", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/misc.py#L849-L856
greenbone/ospd
ospd/misc.py
get_common_args
def get_common_args(parser, args=None): """ Return list of OSPD common command-line arguments from parser, after validating provided values or setting default ones. """ options = parser.parse_args(args) # TCP Port to listen on. port = options.port # Network address to bind listener to ...
python
def get_common_args(parser, args=None): """ Return list of OSPD common command-line arguments from parser, after validating provided values or setting default ones. """ options = parser.parse_args(args) # TCP Port to listen on. port = options.port # Network address to bind listener to ...
[ "def", "get_common_args", "(", "parser", ",", "args", "=", "None", ")", ":", "options", "=", "parser", ".", "parse_args", "(", "args", ")", "# TCP Port to listen on.", "port", "=", "options", ".", "port", "# Network address to bind listener to", "address", "=", ...
Return list of OSPD common command-line arguments from parser, after validating provided values or setting default ones.
[ "Return", "list", "of", "OSPD", "common", "command", "-", "line", "arguments", "from", "parser", "after", "validating", "provided", "values", "or", "setting", "default", "ones", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/misc.py#L859-L899
greenbone/ospd
ospd/misc.py
print_version
def print_version(wrapper): """ Prints the server version and license information.""" scanner_name = wrapper.get_scanner_name() server_version = wrapper.get_server_version() print("OSP Server for {0} version {1}".format(scanner_name, server_version)) protocol_version = wrapper.get_protocol_version(...
python
def print_version(wrapper): """ Prints the server version and license information.""" scanner_name = wrapper.get_scanner_name() server_version = wrapper.get_server_version() print("OSP Server for {0} version {1}".format(scanner_name, server_version)) protocol_version = wrapper.get_protocol_version(...
[ "def", "print_version", "(", "wrapper", ")", ":", "scanner_name", "=", "wrapper", ".", "get_scanner_name", "(", ")", "server_version", "=", "wrapper", ".", "get_server_version", "(", ")", "print", "(", "\"OSP Server for {0} version {1}\"", ".", "format", "(", "sca...
Prints the server version and license information.
[ "Prints", "the", "server", "version", "and", "license", "information", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/misc.py#L902-L917
greenbone/ospd
ospd/misc.py
main
def main(name, klass): """ OSPD Main function. """ # Common args parser. parser = create_args_parser(name) # Common args cargs = get_common_args(parser) logging.getLogger().setLevel(cargs['log_level']) wrapper = klass(certfile=cargs['certfile'], keyfile=cargs['keyfile'], ...
python
def main(name, klass): """ OSPD Main function. """ # Common args parser. parser = create_args_parser(name) # Common args cargs = get_common_args(parser) logging.getLogger().setLevel(cargs['log_level']) wrapper = klass(certfile=cargs['certfile'], keyfile=cargs['keyfile'], ...
[ "def", "main", "(", "name", ",", "klass", ")", ":", "# Common args parser.", "parser", "=", "create_args_parser", "(", "name", ")", "# Common args", "cargs", "=", "get_common_args", "(", "parser", ")", "logging", ".", "getLogger", "(", ")", ".", "setLevel", ...
OSPD Main function.
[ "OSPD", "Main", "function", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/misc.py#L920-L962
greenbone/ospd
ospd/misc.py
ScanCollection.add_result
def add_result(self, scan_id, result_type, host='', name='', value='', port='', test_id='', severity='', qod=''): """ Add a result to a scan in the table. """ assert scan_id assert len(name) or len(value) result = dict() result['type'] = result_type re...
python
def add_result(self, scan_id, result_type, host='', name='', value='', port='', test_id='', severity='', qod=''): """ Add a result to a scan in the table. """ assert scan_id assert len(name) or len(value) result = dict() result['type'] = result_type re...
[ "def", "add_result", "(", "self", ",", "scan_id", ",", "result_type", ",", "host", "=", "''", ",", "name", "=", "''", ",", "value", "=", "''", ",", "port", "=", "''", ",", "test_id", "=", "''", ",", "severity", "=", "''", ",", "qod", "=", "''", ...
Add a result to a scan in the table.
[ "Add", "a", "result", "to", "a", "scan", "in", "the", "table", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/misc.py#L87-L105
greenbone/ospd
ospd/misc.py
ScanCollection.set_progress
def set_progress(self, scan_id, progress): """ Sets scan_id scan's progress. """ if progress > 0 and progress <= 100: self.scans_table[scan_id]['progress'] = progress if progress == 100: self.scans_table[scan_id]['end_time'] = int(time.time())
python
def set_progress(self, scan_id, progress): """ Sets scan_id scan's progress. """ if progress > 0 and progress <= 100: self.scans_table[scan_id]['progress'] = progress if progress == 100: self.scans_table[scan_id]['end_time'] = int(time.time())
[ "def", "set_progress", "(", "self", ",", "scan_id", ",", "progress", ")", ":", "if", "progress", ">", "0", "and", "progress", "<=", "100", ":", "self", ".", "scans_table", "[", "scan_id", "]", "[", "'progress'", "]", "=", "progress", "if", "progress", ...
Sets scan_id scan's progress.
[ "Sets", "scan_id", "scan", "s", "progress", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/misc.py#L107-L113
greenbone/ospd
ospd/misc.py
ScanCollection.set_target_progress
def set_target_progress(self, scan_id, target, host, progress): """ Sets scan_id scan's progress. """ if progress > 0 and progress <= 100: targets = self.scans_table[scan_id]['target_progress'] targets[target][host] = progress # Set scan_info's target_progress to pro...
python
def set_target_progress(self, scan_id, target, host, progress): """ Sets scan_id scan's progress. """ if progress > 0 and progress <= 100: targets = self.scans_table[scan_id]['target_progress'] targets[target][host] = progress # Set scan_info's target_progress to pro...
[ "def", "set_target_progress", "(", "self", ",", "scan_id", ",", "target", ",", "host", ",", "progress", ")", ":", "if", "progress", ">", "0", "and", "progress", "<=", "100", ":", "targets", "=", "self", ".", "scans_table", "[", "scan_id", "]", "[", "'t...
Sets scan_id scan's progress.
[ "Sets", "scan_id", "scan", "s", "progress", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/misc.py#L115-L122
greenbone/ospd
ospd/misc.py
ScanCollection.set_host_finished
def set_host_finished(self, scan_id, target, host): """ Add the host in a list of finished hosts """ finished_hosts = self.scans_table[scan_id]['finished_hosts'] finished_hosts[target].extend(host) self.scans_table[scan_id]['finished_hosts'] = finished_hosts
python
def set_host_finished(self, scan_id, target, host): """ Add the host in a list of finished hosts """ finished_hosts = self.scans_table[scan_id]['finished_hosts'] finished_hosts[target].extend(host) self.scans_table[scan_id]['finished_hosts'] = finished_hosts
[ "def", "set_host_finished", "(", "self", ",", "scan_id", ",", "target", ",", "host", ")", ":", "finished_hosts", "=", "self", ".", "scans_table", "[", "scan_id", "]", "[", "'finished_hosts'", "]", "finished_hosts", "[", "target", "]", ".", "extend", "(", "...
Add the host in a list of finished hosts
[ "Add", "the", "host", "in", "a", "list", "of", "finished", "hosts" ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/misc.py#L124-L128
greenbone/ospd
ospd/misc.py
ScanCollection.get_hosts_unfinished
def get_hosts_unfinished(self, scan_id): """ Get a list of finished hosts.""" unfinished_hosts = list() for target in self.scans_table[scan_id]['finished_hosts']: unfinished_hosts.extend(target_str_to_list(target)) for target in self.scans_table[scan_id]['finished_hosts']: ...
python
def get_hosts_unfinished(self, scan_id): """ Get a list of finished hosts.""" unfinished_hosts = list() for target in self.scans_table[scan_id]['finished_hosts']: unfinished_hosts.extend(target_str_to_list(target)) for target in self.scans_table[scan_id]['finished_hosts']: ...
[ "def", "get_hosts_unfinished", "(", "self", ",", "scan_id", ")", ":", "unfinished_hosts", "=", "list", "(", ")", "for", "target", "in", "self", ".", "scans_table", "[", "scan_id", "]", "[", "'finished_hosts'", "]", ":", "unfinished_hosts", ".", "extend", "("...
Get a list of finished hosts.
[ "Get", "a", "list", "of", "finished", "hosts", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/misc.py#L130-L140
greenbone/ospd
ospd/misc.py
ScanCollection.results_iterator
def results_iterator(self, scan_id, pop_res): """ Returns an iterator over scan_id scan's results. If pop_res is True, it removed the fetched results from the list. """ if pop_res: result_aux = self.scans_table[scan_id]['results'] self.scans_table[scan_id]['result...
python
def results_iterator(self, scan_id, pop_res): """ Returns an iterator over scan_id scan's results. If pop_res is True, it removed the fetched results from the list. """ if pop_res: result_aux = self.scans_table[scan_id]['results'] self.scans_table[scan_id]['result...
[ "def", "results_iterator", "(", "self", ",", "scan_id", ",", "pop_res", ")", ":", "if", "pop_res", ":", "result_aux", "=", "self", ".", "scans_table", "[", "scan_id", "]", "[", "'results'", "]", "self", ".", "scans_table", "[", "scan_id", "]", "[", "'res...
Returns an iterator over scan_id scan's results. If pop_res is True, it removed the fetched results from the list.
[ "Returns", "an", "iterator", "over", "scan_id", "scan", "s", "results", ".", "If", "pop_res", "is", "True", "it", "removed", "the", "fetched", "results", "from", "the", "list", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/misc.py#L142-L151
greenbone/ospd
ospd/misc.py
ScanCollection.del_results_for_stopped_hosts
def del_results_for_stopped_hosts(self, scan_id): """ Remove results from the result table for those host """ unfinished_hosts = self.get_hosts_unfinished(scan_id) for result in self.results_iterator(scan_id, False): if result['host'] in unfinished_hosts: self...
python
def del_results_for_stopped_hosts(self, scan_id): """ Remove results from the result table for those host """ unfinished_hosts = self.get_hosts_unfinished(scan_id) for result in self.results_iterator(scan_id, False): if result['host'] in unfinished_hosts: self...
[ "def", "del_results_for_stopped_hosts", "(", "self", ",", "scan_id", ")", ":", "unfinished_hosts", "=", "self", ".", "get_hosts_unfinished", "(", "scan_id", ")", "for", "result", "in", "self", ".", "results_iterator", "(", "scan_id", ",", "False", ")", ":", "i...
Remove results from the result table for those host
[ "Remove", "results", "from", "the", "result", "table", "for", "those", "host" ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/misc.py#L162-L168
greenbone/ospd
ospd/misc.py
ScanCollection.resume_scan
def resume_scan(self, scan_id, options): """ Reset the scan status in the scan_table to INIT. Also, overwrite the options, because a resume task cmd can add some new option. E.g. exclude hosts list. Parameters: scan_id (uuid): Scan ID to identify the scan process to be resume...
python
def resume_scan(self, scan_id, options): """ Reset the scan status in the scan_table to INIT. Also, overwrite the options, because a resume task cmd can add some new option. E.g. exclude hosts list. Parameters: scan_id (uuid): Scan ID to identify the scan process to be resume...
[ "def", "resume_scan", "(", "self", ",", "scan_id", ",", "options", ")", ":", "self", ".", "scans_table", "[", "scan_id", "]", "[", "'status'", "]", "=", "ScanStatus", ".", "INIT", "if", "options", ":", "self", ".", "scans_table", "[", "scan_id", "]", "...
Reset the scan status in the scan_table to INIT. Also, overwrite the options, because a resume task cmd can add some new option. E.g. exclude hosts list. Parameters: scan_id (uuid): Scan ID to identify the scan process to be resumed. options (dict): Options for the scan t...
[ "Reset", "the", "scan", "status", "in", "the", "scan_table", "to", "INIT", ".", "Also", "overwrite", "the", "options", "because", "a", "resume", "task", "cmd", "can", "add", "some", "new", "option", ".", "E", ".", "g", ".", "exclude", "hosts", "list", ...
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/misc.py#L170-L189
greenbone/ospd
ospd/misc.py
ScanCollection.create_scan
def create_scan(self, scan_id='', targets='', options=None, vts=''): """ Creates a new scan with provided scan information. """ if self.data_manager is None: self.data_manager = multiprocessing.Manager() # Check if it is possible to resume task. To avoid to resume, the # sc...
python
def create_scan(self, scan_id='', targets='', options=None, vts=''): """ Creates a new scan with provided scan information. """ if self.data_manager is None: self.data_manager = multiprocessing.Manager() # Check if it is possible to resume task. To avoid to resume, the # sc...
[ "def", "create_scan", "(", "self", ",", "scan_id", "=", "''", ",", "targets", "=", "''", ",", "options", "=", "None", ",", "vts", "=", "''", ")", ":", "if", "self", ".", "data_manager", "is", "None", ":", "self", ".", "data_manager", "=", "multiproce...
Creates a new scan with provided scan information.
[ "Creates", "a", "new", "scan", "with", "provided", "scan", "information", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/misc.py#L191-L222
greenbone/ospd
ospd/misc.py
ScanCollection.set_option
def set_option(self, scan_id, name, value): """ Set a scan_id scan's name option to value. """ self.scans_table[scan_id]['options'][name] = value
python
def set_option(self, scan_id, name, value): """ Set a scan_id scan's name option to value. """ self.scans_table[scan_id]['options'][name] = value
[ "def", "set_option", "(", "self", ",", "scan_id", ",", "name", ",", "value", ")", ":", "self", ".", "scans_table", "[", "scan_id", "]", "[", "'options'", "]", "[", "name", "]", "=", "value" ]
Set a scan_id scan's name option to value.
[ "Set", "a", "scan_id", "scan", "s", "name", "option", "to", "value", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/misc.py#L238-L241
greenbone/ospd
ospd/misc.py
ScanCollection.get_target_progress
def get_target_progress(self, scan_id, target): """ Get a target's current progress value. The value is calculated with the progress of each single host in the target.""" total_hosts = len(target_str_to_list(target)) host_progresses = self.scans_table[scan_id]['target_progress']...
python
def get_target_progress(self, scan_id, target): """ Get a target's current progress value. The value is calculated with the progress of each single host in the target.""" total_hosts = len(target_str_to_list(target)) host_progresses = self.scans_table[scan_id]['target_progress']...
[ "def", "get_target_progress", "(", "self", ",", "scan_id", ",", "target", ")", ":", "total_hosts", "=", "len", "(", "target_str_to_list", "(", "target", ")", ")", "host_progresses", "=", "self", ".", "scans_table", "[", "scan_id", "]", "[", "'target_progress'"...
Get a target's current progress value. The value is calculated with the progress of each single host in the target.
[ "Get", "a", "target", "s", "current", "progress", "value", ".", "The", "value", "is", "calculated", "with", "the", "progress", "of", "each", "single", "host", "in", "the", "target", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/misc.py#L248-L260
greenbone/ospd
ospd/misc.py
ScanCollection.get_target_list
def get_target_list(self, scan_id): """ Get a scan's target list. """ target_list = [] for target, _, _ in self.scans_table[scan_id]['targets']: target_list.append(target) return target_list
python
def get_target_list(self, scan_id): """ Get a scan's target list. """ target_list = [] for target, _, _ in self.scans_table[scan_id]['targets']: target_list.append(target) return target_list
[ "def", "get_target_list", "(", "self", ",", "scan_id", ")", ":", "target_list", "=", "[", "]", "for", "target", ",", "_", ",", "_", "in", "self", ".", "scans_table", "[", "scan_id", "]", "[", "'targets'", "]", ":", "target_list", ".", "append", "(", ...
Get a scan's target list.
[ "Get", "a", "scan", "s", "target", "list", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/misc.py#L272-L278
greenbone/ospd
ospd/misc.py
ScanCollection.get_ports
def get_ports(self, scan_id, target): """ Get a scan's ports list. If a target is specified it will return the corresponding port for it. If not, it returns the port item of the first nested list in the target's list. """ if target: for item in self.scans_tabl...
python
def get_ports(self, scan_id, target): """ Get a scan's ports list. If a target is specified it will return the corresponding port for it. If not, it returns the port item of the first nested list in the target's list. """ if target: for item in self.scans_tabl...
[ "def", "get_ports", "(", "self", ",", "scan_id", ",", "target", ")", ":", "if", "target", ":", "for", "item", "in", "self", ".", "scans_table", "[", "scan_id", "]", "[", "'targets'", "]", ":", "if", "target", "==", "item", "[", "0", "]", ":", "retu...
Get a scan's ports list. If a target is specified it will return the corresponding port for it. If not, it returns the port item of the first nested list in the target's list.
[ "Get", "a", "scan", "s", "ports", "list", ".", "If", "a", "target", "is", "specified", "it", "will", "return", "the", "corresponding", "port", "for", "it", ".", "If", "not", "it", "returns", "the", "port", "item", "of", "the", "first", "nested", "list"...
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/misc.py#L280-L291
greenbone/ospd
ospd/misc.py
ScanCollection.get_credentials
def get_credentials(self, scan_id, target): """ Get a scan's credential list. It return dictionary with the corresponding credential for a given target. """ if target: for item in self.scans_table[scan_id]['targets']: if target == item[0]: ...
python
def get_credentials(self, scan_id, target): """ Get a scan's credential list. It return dictionary with the corresponding credential for a given target. """ if target: for item in self.scans_table[scan_id]['targets']: if target == item[0]: ...
[ "def", "get_credentials", "(", "self", ",", "scan_id", ",", "target", ")", ":", "if", "target", ":", "for", "item", "in", "self", ".", "scans_table", "[", "scan_id", "]", "[", "'targets'", "]", ":", "if", "target", "==", "item", "[", "0", "]", ":", ...
Get a scan's credential list. It return dictionary with the corresponding credential for a given target.
[ "Get", "a", "scan", "s", "credential", "list", ".", "It", "return", "dictionary", "with", "the", "corresponding", "credential", "for", "a", "given", "target", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/misc.py#L293-L300
greenbone/ospd
ospd/misc.py
ScanCollection.delete_scan
def delete_scan(self, scan_id): """ Delete a scan if fully finished. """ if self.get_status(scan_id) == ScanStatus.RUNNING: return False self.scans_table.pop(scan_id) if len(self.scans_table) == 0: del self.data_manager self.data_manager = None ...
python
def delete_scan(self, scan_id): """ Delete a scan if fully finished. """ if self.get_status(scan_id) == ScanStatus.RUNNING: return False self.scans_table.pop(scan_id) if len(self.scans_table) == 0: del self.data_manager self.data_manager = None ...
[ "def", "delete_scan", "(", "self", ",", "scan_id", ")", ":", "if", "self", ".", "get_status", "(", "scan_id", ")", "==", "ScanStatus", ".", "RUNNING", ":", "return", "False", "self", ".", "scans_table", ".", "pop", "(", "scan_id", ")", "if", "len", "("...
Delete a scan if fully finished.
[ "Delete", "a", "scan", "if", "fully", "finished", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/misc.py#L312-L321
greenbone/ospd
ospd/misc.py
ResultType.get_str
def get_str(cls, result_type): """ Return string name of a result type. """ if result_type == cls.ALARM: return "Alarm" elif result_type == cls.LOG: return "Log Message" elif result_type == cls.ERROR: return "Error Message" elif result_type == ...
python
def get_str(cls, result_type): """ Return string name of a result type. """ if result_type == cls.ALARM: return "Alarm" elif result_type == cls.LOG: return "Log Message" elif result_type == cls.ERROR: return "Error Message" elif result_type == ...
[ "def", "get_str", "(", "cls", ",", "result_type", ")", ":", "if", "result_type", "==", "cls", ".", "ALARM", ":", "return", "\"Alarm\"", "elif", "result_type", "==", "cls", ".", "LOG", ":", "return", "\"Log Message\"", "elif", "result_type", "==", "cls", "....
Return string name of a result type.
[ "Return", "string", "name", "of", "a", "result", "type", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/misc.py#L334-L345
greenbone/ospd
ospd/misc.py
ResultType.get_type
def get_type(cls, result_name): """ Return string name of a result type. """ if result_name == "Alarm": return cls.ALARM elif result_name == "Log Message": return cls.LOG elif result_name == "Error Message": return cls.ERROR elif result_name ==...
python
def get_type(cls, result_name): """ Return string name of a result type. """ if result_name == "Alarm": return cls.ALARM elif result_name == "Log Message": return cls.LOG elif result_name == "Error Message": return cls.ERROR elif result_name ==...
[ "def", "get_type", "(", "cls", ",", "result_name", ")", ":", "if", "result_name", "==", "\"Alarm\"", ":", "return", "cls", ".", "ALARM", "elif", "result_name", "==", "\"Log Message\"", ":", "return", "cls", ".", "LOG", "elif", "result_name", "==", "\"Error M...
Return string name of a result type.
[ "Return", "string", "name", "of", "a", "result", "type", "." ]
train
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/misc.py#L348-L359
Grokzen/pykwalify
pykwalify/types.py
is_float
def is_float(obj): """ Valid types are: - objects of float type - Strings that can be converted to float. For example '1e-06' """ is_f = isinstance(obj, float) if not is_f: try: float(obj) is_f = True except (ValueError, TypeError): is_f ...
python
def is_float(obj): """ Valid types are: - objects of float type - Strings that can be converted to float. For example '1e-06' """ is_f = isinstance(obj, float) if not is_f: try: float(obj) is_f = True except (ValueError, TypeError): is_f ...
[ "def", "is_float", "(", "obj", ")", ":", "is_f", "=", "isinstance", "(", "obj", ",", "float", ")", "if", "not", "is_f", ":", "try", ":", "float", "(", "obj", ")", "is_f", "=", "True", "except", "(", "ValueError", ",", "TypeError", ")", ":", "is_f",...
Valid types are: - objects of float type - Strings that can be converted to float. For example '1e-06'
[ "Valid", "types", "are", ":", "-", "objects", "of", "float", "type", "-", "Strings", "that", "can", "be", "converted", "to", "float", ".", "For", "example", "1e", "-", "06" ]
train
https://github.com/Grokzen/pykwalify/blob/02b7e21eafb97926f17b7c33e2ee7b3ea67c3ef7/pykwalify/types.py#L87-L100
Grokzen/pykwalify
pykwalify/types.py
is_timestamp
def is_timestamp(obj): """ Yaml either have automatically converted it to a datetime object or it is a string that will be validated later. """ return isinstance(obj, datetime.datetime) or is_string(obj) or is_int(obj) or is_float(obj)
python
def is_timestamp(obj): """ Yaml either have automatically converted it to a datetime object or it is a string that will be validated later. """ return isinstance(obj, datetime.datetime) or is_string(obj) or is_int(obj) or is_float(obj)
[ "def", "is_timestamp", "(", "obj", ")", ":", "return", "isinstance", "(", "obj", ",", "datetime", ".", "datetime", ")", "or", "is_string", "(", "obj", ")", "or", "is_int", "(", "obj", ")", "or", "is_float", "(", "obj", ")" ]
Yaml either have automatically converted it to a datetime object or it is a string that will be validated later.
[ "Yaml", "either", "have", "automatically", "converted", "it", "to", "a", "datetime", "object", "or", "it", "is", "a", "string", "that", "will", "be", "validated", "later", "." ]
train
https://github.com/Grokzen/pykwalify/blob/02b7e21eafb97926f17b7c33e2ee7b3ea67c3ef7/pykwalify/types.py#L131-L136
Grokzen/pykwalify
pykwalify/__init__.py
init_logging
def init_logging(log_level): """ Init logging settings with default set to INFO """ log_level = log_level_to_string_map[min(log_level, 5)] msg = "%(levelname)s - %(name)s:%(lineno)s - %(message)s" if log_level in os.environ else "%(levelname)s - %(message)s" logging_conf = { "version":...
python
def init_logging(log_level): """ Init logging settings with default set to INFO """ log_level = log_level_to_string_map[min(log_level, 5)] msg = "%(levelname)s - %(name)s:%(lineno)s - %(message)s" if log_level in os.environ else "%(levelname)s - %(message)s" logging_conf = { "version":...
[ "def", "init_logging", "(", "log_level", ")", ":", "log_level", "=", "log_level_to_string_map", "[", "min", "(", "log_level", ",", "5", ")", "]", "msg", "=", "\"%(levelname)s - %(name)s:%(lineno)s - %(message)s\"", "if", "log_level", "in", "os", ".", "environ", "e...
Init logging settings with default set to INFO
[ "Init", "logging", "settings", "with", "default", "set", "to", "INFO" ]
train
https://github.com/Grokzen/pykwalify/blob/02b7e21eafb97926f17b7c33e2ee7b3ea67c3ef7/pykwalify/__init__.py#L25-L54
Grokzen/pykwalify
pykwalify/rule.py
Rule.keywords
def keywords(self): """ Returns a list of all keywords that this rule object has defined. A keyword is considered defined if the value it returns != None. """ defined_keywords = [ ('allowempty_map', 'allowempty_map'), ('assertion', 'assertion'), ...
python
def keywords(self): """ Returns a list of all keywords that this rule object has defined. A keyword is considered defined if the value it returns != None. """ defined_keywords = [ ('allowempty_map', 'allowempty_map'), ('assertion', 'assertion'), ...
[ "def", "keywords", "(", "self", ")", ":", "defined_keywords", "=", "[", "(", "'allowempty_map'", ",", "'allowempty_map'", ")", ",", "(", "'assertion'", ",", "'assertion'", ")", ",", "(", "'default'", ",", "'default'", ")", ",", "(", "'class'", ",", "'class...
Returns a list of all keywords that this rule object has defined. A keyword is considered defined if the value it returns != None.
[ "Returns", "a", "list", "of", "all", "keywords", "that", "this", "rule", "object", "has", "defined", ".", "A", "keyword", "is", "considered", "defined", "if", "the", "value", "it", "returns", "!", "=", "None", "." ]
train
https://github.com/Grokzen/pykwalify/blob/02b7e21eafb97926f17b7c33e2ee7b3ea67c3ef7/pykwalify/rule.py#L319-L364
Grokzen/pykwalify
pykwalify/rule.py
Rule.check_type_keywords
def check_type_keywords(self, schema, rule, path): """ All supported keywords: - allowempty_map - assertion - class - date - default - desc - enum - example - extensions - func - ident - include_n...
python
def check_type_keywords(self, schema, rule, path): """ All supported keywords: - allowempty_map - assertion - class - date - default - desc - enum - example - extensions - func - ident - include_n...
[ "def", "check_type_keywords", "(", "self", ",", "schema", ",", "rule", ",", "path", ")", ":", "if", "not", "self", ".", "strict_rule_validation", ":", "return", "global_keywords", "=", "[", "'type'", ",", "'desc'", ",", "'example'", ",", "'extensions'", ",",...
All supported keywords: - allowempty_map - assertion - class - date - default - desc - enum - example - extensions - func - ident - include_name - map_regex_rule - mapping - matching ...
[ "All", "supported", "keywords", ":", "-", "allowempty_map", "-", "assertion", "-", "class", "-", "date", "-", "default", "-", "desc", "-", "enum", "-", "example", "-", "extensions", "-", "func", "-", "ident", "-", "include_name", "-", "map_regex_rule", "-"...
train
https://github.com/Grokzen/pykwalify/blob/02b7e21eafb97926f17b7c33e2ee7b3ea67c3ef7/pykwalify/rule.py#L1212-L1282
Grokzen/pykwalify
pykwalify/core.py
Core._load_extensions
def _load_extensions(self): """ Load all extension files into the namespace pykwalify.ext """ log.debug(u"loading all extensions : %s", self.extensions) self.loaded_extensions = [] for f in self.extensions: if not os.path.isabs(f): f = os.pat...
python
def _load_extensions(self): """ Load all extension files into the namespace pykwalify.ext """ log.debug(u"loading all extensions : %s", self.extensions) self.loaded_extensions = [] for f in self.extensions: if not os.path.isabs(f): f = os.pat...
[ "def", "_load_extensions", "(", "self", ")", ":", "log", ".", "debug", "(", "u\"loading all extensions : %s\"", ",", "self", ".", "extensions", ")", "self", ".", "loaded_extensions", "=", "[", "]", "for", "f", "in", "self", ".", "extensions", ":", "if", "n...
Load all extension files into the namespace pykwalify.ext
[ "Load", "all", "extension", "files", "into", "the", "namespace", "pykwalify", ".", "ext" ]
train
https://github.com/Grokzen/pykwalify/blob/02b7e21eafb97926f17b7c33e2ee7b3ea67c3ef7/pykwalify/core.py#L131-L149
Grokzen/pykwalify
pykwalify/core.py
Core._handle_func
def _handle_func(self, value, rule, path, done=None): """ Helper function that should check if func is specified for this rule and then handle it for all cases in a generic way. """ func = rule.func # func keyword is not defined so nothing to do if not func: ...
python
def _handle_func(self, value, rule, path, done=None): """ Helper function that should check if func is specified for this rule and then handle it for all cases in a generic way. """ func = rule.func # func keyword is not defined so nothing to do if not func: ...
[ "def", "_handle_func", "(", "self", ",", "value", ",", "rule", ",", "path", ",", "done", "=", "None", ")", ":", "func", "=", "rule", ".", "func", "# func keyword is not defined so nothing to do", "if", "not", "func", ":", "return", "found_method", "=", "Fals...
Helper function that should check if func is specified for this rule and then handle it for all cases in a generic way.
[ "Helper", "function", "that", "should", "check", "if", "func", "is", "specified", "for", "this", "rule", "and", "then", "handle", "it", "for", "all", "cases", "in", "a", "generic", "way", "." ]
train
https://github.com/Grokzen/pykwalify/blob/02b7e21eafb97926f17b7c33e2ee7b3ea67c3ef7/pykwalify/core.py#L241-L277
Grokzen/pykwalify
pykwalify/core.py
Core._validate_range
def _validate_range(self, max_, min_, max_ex, min_ex, value, path, prefix): """ Validate that value is within range values. """ if not isinstance(value, int) and not isinstance(value, float): raise CoreError("Value must be a integer type") log.debug( u"Va...
python
def _validate_range(self, max_, min_, max_ex, min_ex, value, path, prefix): """ Validate that value is within range values. """ if not isinstance(value, int) and not isinstance(value, float): raise CoreError("Value must be a integer type") log.debug( u"Va...
[ "def", "_validate_range", "(", "self", ",", "max_", ",", "min_", ",", "max_ex", ",", "min_ex", ",", "value", ",", "path", ",", "prefix", ")", ":", "if", "not", "isinstance", "(", "value", ",", "int", ")", "and", "not", "isinstance", "(", "value", ","...
Validate that value is within range values.
[ "Validate", "that", "value", "is", "within", "range", "values", "." ]
train
https://github.com/Grokzen/pykwalify/blob/02b7e21eafb97926f17b7c33e2ee7b3ea67c3ef7/pykwalify/core.py#L919-L966
Grokzen/pykwalify
pykwalify/cli.py
parse_cli
def parse_cli(): """ The outline of this function needs to be like this: 1. parse arguments 2. validate arguments only, dont go into other logic/code 3. run application logic """ # # 1. parse cli arguments # __docopt__ = """ usage: pykwalify -d FILE -s FILE ... [-e FILE ...] ...
python
def parse_cli(): """ The outline of this function needs to be like this: 1. parse arguments 2. validate arguments only, dont go into other logic/code 3. run application logic """ # # 1. parse cli arguments # __docopt__ = """ usage: pykwalify -d FILE -s FILE ... [-e FILE ...] ...
[ "def", "parse_cli", "(", ")", ":", "#", "# 1. parse cli arguments", "#", "__docopt__", "=", "\"\"\"\nusage: pykwalify -d FILE -s FILE ... [-e FILE ...]\n [--strict-rule-validation] [--fix-ruby-style-regex] [--allow-assertions] [--encoding ENCODING]\n [-v ...] [-q]\n\noptional argumen...
The outline of this function needs to be like this: 1. parse arguments 2. validate arguments only, dont go into other logic/code 3. run application logic
[ "The", "outline", "of", "this", "function", "needs", "to", "be", "like", "this", ":" ]
train
https://github.com/Grokzen/pykwalify/blob/02b7e21eafb97926f17b7c33e2ee7b3ea67c3ef7/pykwalify/cli.py#L14-L65
Grokzen/pykwalify
pykwalify/cli.py
run
def run(cli_args): """ Split the functionality into 2 methods. One for parsing the cli and one that runs the application. """ from .core import Core c = Core( source_file=cli_args["--data-file"], schema_files=cli_args["--schema-file"], extensions=cli_args['--extension']...
python
def run(cli_args): """ Split the functionality into 2 methods. One for parsing the cli and one that runs the application. """ from .core import Core c = Core( source_file=cli_args["--data-file"], schema_files=cli_args["--schema-file"], extensions=cli_args['--extension']...
[ "def", "run", "(", "cli_args", ")", ":", "from", ".", "core", "import", "Core", "c", "=", "Core", "(", "source_file", "=", "cli_args", "[", "\"--data-file\"", "]", ",", "schema_files", "=", "cli_args", "[", "\"--schema-file\"", "]", ",", "extensions", "=",...
Split the functionality into 2 methods. One for parsing the cli and one that runs the application.
[ "Split", "the", "functionality", "into", "2", "methods", "." ]
train
https://github.com/Grokzen/pykwalify/blob/02b7e21eafb97926f17b7c33e2ee7b3ea67c3ef7/pykwalify/cli.py#L68-L86
tisimst/pyDOE
pyDOE/doe_plackett_burman.py
pbdesign
def pbdesign(n): """ Generate a Plackett-Burman design Parameter --------- n : int The number of factors to create a matrix for. Returns ------- H : 2d-array An orthogonal design matrix with n columns, one for each factor, and the number of ...
python
def pbdesign(n): """ Generate a Plackett-Burman design Parameter --------- n : int The number of factors to create a matrix for. Returns ------- H : 2d-array An orthogonal design matrix with n columns, one for each factor, and the number of ...
[ "def", "pbdesign", "(", "n", ")", ":", "assert", "n", ">", "0", ",", "'Number of factors must be a positive integer'", "keep", "=", "int", "(", "n", ")", "n", "=", "4", "*", "(", "int", "(", "n", "/", "4", ")", "+", "1", ")", "# calculate the correct n...
Generate a Plackett-Burman design Parameter --------- n : int The number of factors to create a matrix for. Returns ------- H : 2d-array An orthogonal design matrix with n columns, one for each factor, and the number of rows being the next multiple of...
[ "Generate", "a", "Plackett", "-", "Burman", "design", "Parameter", "---------", "n", ":", "int", "The", "number", "of", "factors", "to", "create", "a", "matrix", "for", ".", "Returns", "-------", "H", ":", "2d", "-", "array", "An", "orthogonal", "design", ...
train
https://github.com/tisimst/pyDOE/blob/436143702507a5c8ff87b361223eee8171d6a1d7/pyDOE/doe_plackett_burman.py#L22-L94
tisimst/pyDOE
pyDOE/doe_star.py
star
def star(n, alpha='faced', center=(1, 1)): """ Create the star points of various design matrices Parameters ---------- n : int The number of variables in the design Optional -------- alpha : str Available values are 'faced' (default), 'orthogonal', o...
python
def star(n, alpha='faced', center=(1, 1)): """ Create the star points of various design matrices Parameters ---------- n : int The number of variables in the design Optional -------- alpha : str Available values are 'faced' (default), 'orthogonal', o...
[ "def", "star", "(", "n", ",", "alpha", "=", "'faced'", ",", "center", "=", "(", "1", ",", "1", ")", ")", ":", "# Star points at the center of each face of the factorial\r", "if", "alpha", "==", "'faced'", ":", "a", "=", "1", "elif", "alpha", "==", "'orthog...
Create the star points of various design matrices Parameters ---------- n : int The number of variables in the design Optional -------- alpha : str Available values are 'faced' (default), 'orthogonal', or 'rotatable' center : array A 1-by-2 array...
[ "Create", "the", "star", "points", "of", "various", "design", "matrices", "Parameters", "----------", "n", ":", "int", "The", "number", "of", "variables", "in", "the", "design", "Optional", "--------", "alpha", ":", "str", "Available", "values", "are", "faced"...
train
https://github.com/tisimst/pyDOE/blob/436143702507a5c8ff87b361223eee8171d6a1d7/pyDOE/doe_star.py#L18-L79
tisimst/pyDOE
pyDOE/doe_fold.py
fold
def fold(H, columns=None): """ Fold a design to reduce confounding effects. Parameters ---------- H : 2d-array The design matrix to be folded. columns : array Indices of of columns to fold (Default: None). If ``columns=None`` is used, then all columns will ...
python
def fold(H, columns=None): """ Fold a design to reduce confounding effects. Parameters ---------- H : 2d-array The design matrix to be folded. columns : array Indices of of columns to fold (Default: None). If ``columns=None`` is used, then all columns will ...
[ "def", "fold", "(", "H", ",", "columns", "=", "None", ")", ":", "H", "=", "np", ".", "array", "(", "H", ")", "assert", "len", "(", "H", ".", "shape", ")", "==", "2", ",", "'Input design matrix must be 2d.'", "if", "columns", "is", "None", ":", "col...
Fold a design to reduce confounding effects. Parameters ---------- H : 2d-array The design matrix to be folded. columns : array Indices of of columns to fold (Default: None). If ``columns=None`` is used, then all columns will be folded. Returns ------...
[ "Fold", "a", "design", "to", "reduce", "confounding", "effects", ".", "Parameters", "----------", "H", ":", "2d", "-", "array", "The", "design", "matrix", "to", "be", "folded", ".", "columns", ":", "array", "Indices", "of", "of", "columns", "to", "fold", ...
train
https://github.com/tisimst/pyDOE/blob/436143702507a5c8ff87b361223eee8171d6a1d7/pyDOE/doe_fold.py#L20-L59
tisimst/pyDOE
pyDOE/build_regression_matrix.py
build_regression_matrix
def build_regression_matrix(H, model, build=None): """ Build a regression matrix using a DOE matrix and a list of monomials. Parameters ---------- H : 2d-array model : str build : bool-array Returns ------- R : 2d-array """ ListOfTokens = mod...
python
def build_regression_matrix(H, model, build=None): """ Build a regression matrix using a DOE matrix and a list of monomials. Parameters ---------- H : 2d-array model : str build : bool-array Returns ------- R : 2d-array """ ListOfTokens = mod...
[ "def", "build_regression_matrix", "(", "H", ",", "model", ",", "build", "=", "None", ")", ":", "ListOfTokens", "=", "model", ".", "split", "(", "' '", ")", "if", "H", ".", "shape", "[", "1", "]", "==", "1", ":", "size_index", "=", "len", "(", "str"...
Build a regression matrix using a DOE matrix and a list of monomials. Parameters ---------- H : 2d-array model : str build : bool-array Returns ------- R : 2d-array
[ "Build", "a", "regression", "matrix", "using", "a", "DOE", "matrix", "and", "a", "list", "of", "monomials", ".", "Parameters", "----------", "H", ":", "2d", "-", "array", "model", ":", "str", "build", ":", "bool", "-", "array", "Returns", "-------", "R",...
train
https://github.com/tisimst/pyDOE/blob/436143702507a5c8ff87b361223eee8171d6a1d7/pyDOE/build_regression_matrix.py#L27-L95
daler/gffutils
gffutils/pybedtools_integration.py
to_bedtool
def to_bedtool(iterator): """ Convert any iterator into a pybedtools.BedTool object. Note that the supplied iterator is not consumed by this function. To save to a temp file or to a known location, use the `.saveas()` method of the returned BedTool object. """ def gen(): for i in it...
python
def to_bedtool(iterator): """ Convert any iterator into a pybedtools.BedTool object. Note that the supplied iterator is not consumed by this function. To save to a temp file or to a known location, use the `.saveas()` method of the returned BedTool object. """ def gen(): for i in it...
[ "def", "to_bedtool", "(", "iterator", ")", ":", "def", "gen", "(", ")", ":", "for", "i", "in", "iterator", ":", "yield", "helpers", ".", "asinterval", "(", "i", ")", "return", "pybedtools", ".", "BedTool", "(", "gen", "(", ")", ")" ]
Convert any iterator into a pybedtools.BedTool object. Note that the supplied iterator is not consumed by this function. To save to a temp file or to a known location, use the `.saveas()` method of the returned BedTool object.
[ "Convert", "any", "iterator", "into", "a", "pybedtools", ".", "BedTool", "object", "." ]
train
https://github.com/daler/gffutils/blob/6f7f547cad898738a1bd0a999fd68ba68db2c524/gffutils/pybedtools_integration.py#L12-L23
daler/gffutils
gffutils/pybedtools_integration.py
tsses
def tsses(db, merge_overlapping=False, attrs=None, attrs_sep=":", merge_kwargs=None, as_bed6=False, bedtools_227_or_later=True): """ Create 1-bp transcription start sites for all transcripts in the database and return as a sorted pybedtools.BedTool object pointing to a temporary file. To ...
python
def tsses(db, merge_overlapping=False, attrs=None, attrs_sep=":", merge_kwargs=None, as_bed6=False, bedtools_227_or_later=True): """ Create 1-bp transcription start sites for all transcripts in the database and return as a sorted pybedtools.BedTool object pointing to a temporary file. To ...
[ "def", "tsses", "(", "db", ",", "merge_overlapping", "=", "False", ",", "attrs", "=", "None", ",", "attrs_sep", "=", "\":\"", ",", "merge_kwargs", "=", "None", ",", "as_bed6", "=", "False", ",", "bedtools_227_or_later", "=", "True", ")", ":", "_override", ...
Create 1-bp transcription start sites for all transcripts in the database and return as a sorted pybedtools.BedTool object pointing to a temporary file. To save the file to a known location, use the `.moveto()` method on the resulting `pybedtools.BedTool` object. To extend regions upstream/downstr...
[ "Create", "1", "-", "bp", "transcription", "start", "sites", "for", "all", "transcripts", "in", "the", "database", "and", "return", "as", "a", "sorted", "pybedtools", ".", "BedTool", "object", "pointing", "to", "a", "temporary", "file", "." ]
train
https://github.com/daler/gffutils/blob/6f7f547cad898738a1bd0a999fd68ba68db2c524/gffutils/pybedtools_integration.py#L26-L237
daler/gffutils
gffutils/gffwriter.py
GFFWriter.write_gene_recs
def write_gene_recs(self, db, gene_id): """ NOTE: The goal of this function is to have a canonical ordering when outputting a gene and all of its records to a file. The order is intended to be: gene # mRNAs sorted by length, with longest mRNA first mRNA_1 ...
python
def write_gene_recs(self, db, gene_id): """ NOTE: The goal of this function is to have a canonical ordering when outputting a gene and all of its records to a file. The order is intended to be: gene # mRNAs sorted by length, with longest mRNA first mRNA_1 ...
[ "def", "write_gene_recs", "(", "self", ",", "db", ",", "gene_id", ")", ":", "gene_rec", "=", "db", "[", "gene_id", "]", "# Output gene record", "self", ".", "write_rec", "(", "gene_rec", ")", "# Get each mRNA's lengths", "mRNA_lens", "=", "{", "}", "c", "=",...
NOTE: The goal of this function is to have a canonical ordering when outputting a gene and all of its records to a file. The order is intended to be: gene # mRNAs sorted by length, with longest mRNA first mRNA_1 # Exons of mRNA, sorted by start position (ascendi...
[ "NOTE", ":", "The", "goal", "of", "this", "function", "is", "to", "have", "a", "canonical", "ordering", "when", "outputting", "a", "gene", "and", "all", "of", "its", "records", "to", "a", "file", ".", "The", "order", "is", "intended", "to", "be", ":" ]
train
https://github.com/daler/gffutils/blob/6f7f547cad898738a1bd0a999fd68ba68db2c524/gffutils/gffwriter.py#L79-L134
daler/gffutils
gffutils/gffwriter.py
GFFWriter.write_mRNA_children
def write_mRNA_children(self, db, mRNA_id): """ Write out the children records of the mRNA given by the ID (not including the mRNA record itself) in a canonical order, where exons are sorted by start position and given first. """ mRNA_children = db.children(mRNA_i...
python
def write_mRNA_children(self, db, mRNA_id): """ Write out the children records of the mRNA given by the ID (not including the mRNA record itself) in a canonical order, where exons are sorted by start position and given first. """ mRNA_children = db.children(mRNA_i...
[ "def", "write_mRNA_children", "(", "self", ",", "db", ",", "mRNA_id", ")", ":", "mRNA_children", "=", "db", ".", "children", "(", "mRNA_id", ",", "order_by", "=", "'start'", ")", "nonexonic_children", "=", "[", "]", "for", "child_rec", "in", "mRNA_children",...
Write out the children records of the mRNA given by the ID (not including the mRNA record itself) in a canonical order, where exons are sorted by start position and given first.
[ "Write", "out", "the", "children", "records", "of", "the", "mRNA", "given", "by", "the", "ID", "(", "not", "including", "the", "mRNA", "record", "itself", ")", "in", "a", "canonical", "order", "where", "exons", "are", "sorted", "by", "start", "position", ...
train
https://github.com/daler/gffutils/blob/6f7f547cad898738a1bd0a999fd68ba68db2c524/gffutils/gffwriter.py#L136-L151
daler/gffutils
gffutils/gffwriter.py
GFFWriter.write_exon_children
def write_exon_children(self, db, exon_id): """ Write out the children records of the exon given by the ID (not including the exon record itself). """ exon_children = db.children(exon_id, order_by='start') for exon_child in exon_children: self.write_rec(exon_c...
python
def write_exon_children(self, db, exon_id): """ Write out the children records of the exon given by the ID (not including the exon record itself). """ exon_children = db.children(exon_id, order_by='start') for exon_child in exon_children: self.write_rec(exon_c...
[ "def", "write_exon_children", "(", "self", ",", "db", ",", "exon_id", ")", ":", "exon_children", "=", "db", ".", "children", "(", "exon_id", ",", "order_by", "=", "'start'", ")", "for", "exon_child", "in", "exon_children", ":", "self", ".", "write_rec", "(...
Write out the children records of the exon given by the ID (not including the exon record itself).
[ "Write", "out", "the", "children", "records", "of", "the", "exon", "given", "by", "the", "ID", "(", "not", "including", "the", "exon", "record", "itself", ")", "." ]
train
https://github.com/daler/gffutils/blob/6f7f547cad898738a1bd0a999fd68ba68db2c524/gffutils/gffwriter.py#L153-L160
daler/gffutils
gffutils/gffwriter.py
GFFWriter.close
def close(self): """ Close the stream. Assumes stream has 'close' method. """ self.out_stream.close() # If we're asked to write in place, substitute the named # temporary file for the current file if self.in_place: shutil.move(self.temp_file.name, self...
python
def close(self): """ Close the stream. Assumes stream has 'close' method. """ self.out_stream.close() # If we're asked to write in place, substitute the named # temporary file for the current file if self.in_place: shutil.move(self.temp_file.name, self...
[ "def", "close", "(", "self", ")", ":", "self", ".", "out_stream", ".", "close", "(", ")", "# If we're asked to write in place, substitute the named", "# temporary file for the current file", "if", "self", ".", "in_place", ":", "shutil", ".", "move", "(", "self", "."...
Close the stream. Assumes stream has 'close' method.
[ "Close", "the", "stream", ".", "Assumes", "stream", "has", "close", "method", "." ]
train
https://github.com/daler/gffutils/blob/6f7f547cad898738a1bd0a999fd68ba68db2c524/gffutils/gffwriter.py#L162-L170
tisimst/pyDOE
pyDOE/var_regression_matrix.py
var_regression_matrix
def var_regression_matrix(H, x, model, sigma=1): """ Compute the variance of the 'regression error'. Parameters ---------- H : 2d-array The regression matrix x : 2d-array The coordinates to calculate the regression error variance at. model : str A stri...
python
def var_regression_matrix(H, x, model, sigma=1): """ Compute the variance of the 'regression error'. Parameters ---------- H : 2d-array The regression matrix x : 2d-array The coordinates to calculate the regression error variance at. model : str A stri...
[ "def", "var_regression_matrix", "(", "H", ",", "x", ",", "model", ",", "sigma", "=", "1", ")", ":", "x", "=", "np", ".", "atleast_2d", "(", "x", ")", "H", "=", "np", ".", "atleast_2d", "(", "H", ")", "if", "x", ".", "shape", "[", "0", "]", "=...
Compute the variance of the 'regression error'. Parameters ---------- H : 2d-array The regression matrix x : 2d-array The coordinates to calculate the regression error variance at. model : str A string of tokens that define the regression model (e.g. '...
[ "Compute", "the", "variance", "of", "the", "regression", "error", ".", "Parameters", "----------", "H", ":", "2d", "-", "array", "The", "regression", "matrix", "x", ":", "2d", "-", "array", "The", "coordinates", "to", "calculate", "the", "regression", "error...
train
https://github.com/tisimst/pyDOE/blob/436143702507a5c8ff87b361223eee8171d6a1d7/pyDOE/var_regression_matrix.py#L18-L51
daler/gffutils
gffutils/biopython_integration.py
to_seqfeature
def to_seqfeature(feature): """ Converts a gffutils.Feature object to a Bio.SeqFeature object. The GFF fields `source`, `score`, `seqid`, and `frame` are stored as qualifiers. GFF `attributes` are also stored as qualifiers. Parameters ---------- feature : Feature object, or string ...
python
def to_seqfeature(feature): """ Converts a gffutils.Feature object to a Bio.SeqFeature object. The GFF fields `source`, `score`, `seqid`, and `frame` are stored as qualifiers. GFF `attributes` are also stored as qualifiers. Parameters ---------- feature : Feature object, or string ...
[ "def", "to_seqfeature", "(", "feature", ")", ":", "if", "isinstance", "(", "feature", ",", "six", ".", "string_types", ")", ":", "feature", "=", "feature_from_line", "(", "feature", ")", "qualifiers", "=", "{", "'source'", ":", "[", "feature", ".", "source...
Converts a gffutils.Feature object to a Bio.SeqFeature object. The GFF fields `source`, `score`, `seqid`, and `frame` are stored as qualifiers. GFF `attributes` are also stored as qualifiers. Parameters ---------- feature : Feature object, or string If string, assume it is a GFF or GTF-fo...
[ "Converts", "a", "gffutils", ".", "Feature", "object", "to", "a", "Bio", ".", "SeqFeature", "object", "." ]
train
https://github.com/daler/gffutils/blob/6f7f547cad898738a1bd0a999fd68ba68db2c524/gffutils/biopython_integration.py#L21-L52
daler/gffutils
gffutils/biopython_integration.py
from_seqfeature
def from_seqfeature(s, **kwargs): """ Converts a Bio.SeqFeature object to a gffutils.Feature object. The GFF fields `source`, `score`, `seqid`, and `frame` are assumed to be stored as qualifiers. Any other qualifiers will be assumed to be GFF attributes. """ source = s.qualifiers.get('sour...
python
def from_seqfeature(s, **kwargs): """ Converts a Bio.SeqFeature object to a gffutils.Feature object. The GFF fields `source`, `score`, `seqid`, and `frame` are assumed to be stored as qualifiers. Any other qualifiers will be assumed to be GFF attributes. """ source = s.qualifiers.get('sour...
[ "def", "from_seqfeature", "(", "s", ",", "*", "*", "kwargs", ")", ":", "source", "=", "s", ".", "qualifiers", ".", "get", "(", "'source'", ",", "'.'", ")", "[", "0", "]", "score", "=", "s", ".", "qualifiers", ".", "get", "(", "'score'", ",", "'.'...
Converts a Bio.SeqFeature object to a gffutils.Feature object. The GFF fields `source`, `score`, `seqid`, and `frame` are assumed to be stored as qualifiers. Any other qualifiers will be assumed to be GFF attributes.
[ "Converts", "a", "Bio", ".", "SeqFeature", "object", "to", "a", "gffutils", ".", "Feature", "object", "." ]
train
https://github.com/daler/gffutils/blob/6f7f547cad898738a1bd0a999fd68ba68db2c524/gffutils/biopython_integration.py#L55-L81
daler/gffutils
gffutils/interface.py
FeatureDB.set_pragmas
def set_pragmas(self, pragmas): """ Set pragmas for the current database connection. Parameters ---------- pragmas : dict Dictionary of pragmas; see constants.default_pragmas for a template and http://www.sqlite.org/pragma.html for a full list. ""...
python
def set_pragmas(self, pragmas): """ Set pragmas for the current database connection. Parameters ---------- pragmas : dict Dictionary of pragmas; see constants.default_pragmas for a template and http://www.sqlite.org/pragma.html for a full list. ""...
[ "def", "set_pragmas", "(", "self", ",", "pragmas", ")", ":", "self", ".", "pragmas", "=", "pragmas", "c", "=", "self", ".", "conn", ".", "cursor", "(", ")", "c", ".", "executescript", "(", "';\\n'", ".", "join", "(", "[", "'PRAGMA %s=%s'", "%", "i", ...
Set pragmas for the current database connection. Parameters ---------- pragmas : dict Dictionary of pragmas; see constants.default_pragmas for a template and http://www.sqlite.org/pragma.html for a full list.
[ "Set", "pragmas", "for", "the", "current", "database", "connection", "." ]
train
https://github.com/daler/gffutils/blob/6f7f547cad898738a1bd0a999fd68ba68db2c524/gffutils/interface.py#L163-L180
daler/gffutils
gffutils/interface.py
FeatureDB._feature_returner
def _feature_returner(self, **kwargs): """ Returns a feature, adding additional database-specific defaults """ kwargs.setdefault('dialect', self.dialect) kwargs.setdefault('keep_order', self.keep_order) kwargs.setdefault('sort_attribute_values', self.sort_attribute_values...
python
def _feature_returner(self, **kwargs): """ Returns a feature, adding additional database-specific defaults """ kwargs.setdefault('dialect', self.dialect) kwargs.setdefault('keep_order', self.keep_order) kwargs.setdefault('sort_attribute_values', self.sort_attribute_values...
[ "def", "_feature_returner", "(", "self", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "setdefault", "(", "'dialect'", ",", "self", ".", "dialect", ")", "kwargs", ".", "setdefault", "(", "'keep_order'", ",", "self", ".", "keep_order", ")", "kwargs", ...
Returns a feature, adding additional database-specific defaults
[ "Returns", "a", "feature", "adding", "additional", "database", "-", "specific", "defaults" ]
train
https://github.com/daler/gffutils/blob/6f7f547cad898738a1bd0a999fd68ba68db2c524/gffutils/interface.py#L182-L189
daler/gffutils
gffutils/interface.py
FeatureDB.schema
def schema(self): """ Returns the database schema as a string. """ c = self.conn.cursor() c.execute( ''' SELECT sql FROM sqlite_master ''') results = [] for i, in c: if i is not None: results.append(i...
python
def schema(self): """ Returns the database schema as a string. """ c = self.conn.cursor() c.execute( ''' SELECT sql FROM sqlite_master ''') results = [] for i, in c: if i is not None: results.append(i...
[ "def", "schema", "(", "self", ")", ":", "c", "=", "self", ".", "conn", ".", "cursor", "(", ")", "c", ".", "execute", "(", "'''\n SELECT sql FROM sqlite_master\n '''", ")", "results", "=", "[", "]", "for", "i", ",", "in", "c", ":", "...
Returns the database schema as a string.
[ "Returns", "the", "database", "schema", "as", "a", "string", "." ]
train
https://github.com/daler/gffutils/blob/6f7f547cad898738a1bd0a999fd68ba68db2c524/gffutils/interface.py#L199-L212
daler/gffutils
gffutils/interface.py
FeatureDB.count_features_of_type
def count_features_of_type(self, featuretype=None): """ Simple count of features. Can be faster than "grep", and is faster than checking the length of results from :meth:`gffutils.FeatureDB.features_of_type`. Parameters ---------- featuretype : string ...
python
def count_features_of_type(self, featuretype=None): """ Simple count of features. Can be faster than "grep", and is faster than checking the length of results from :meth:`gffutils.FeatureDB.features_of_type`. Parameters ---------- featuretype : string ...
[ "def", "count_features_of_type", "(", "self", ",", "featuretype", "=", "None", ")", ":", "c", "=", "self", ".", "conn", ".", "cursor", "(", ")", "if", "featuretype", "is", "not", "None", ":", "c", ".", "execute", "(", "'''\n SELECT count() FRO...
Simple count of features. Can be faster than "grep", and is faster than checking the length of results from :meth:`gffutils.FeatureDB.features_of_type`. Parameters ---------- featuretype : string Feature type (e.g., "gene") to count. If None, then count *all* ...
[ "Simple", "count", "of", "features", "." ]
train
https://github.com/daler/gffutils/blob/6f7f547cad898738a1bd0a999fd68ba68db2c524/gffutils/interface.py#L230-L266
daler/gffutils
gffutils/interface.py
FeatureDB.features_of_type
def features_of_type(self, featuretype, limit=None, strand=None, order_by=None, reverse=False, completely_within=False): """ Returns an iterator of :class:`gffutils.Feature` objects. Parameters ---------- {_method_doc} ""...
python
def features_of_type(self, featuretype, limit=None, strand=None, order_by=None, reverse=False, completely_within=False): """ Returns an iterator of :class:`gffutils.Feature` objects. Parameters ---------- {_method_doc} ""...
[ "def", "features_of_type", "(", "self", ",", "featuretype", ",", "limit", "=", "None", ",", "strand", "=", "None", ",", "order_by", "=", "None", ",", "reverse", "=", "False", ",", "completely_within", "=", "False", ")", ":", "query", ",", "args", "=", ...
Returns an iterator of :class:`gffutils.Feature` objects. Parameters ---------- {_method_doc}
[ "Returns", "an", "iterator", "of", ":", "class", ":", "gffutils", ".", "Feature", "objects", "." ]
train
https://github.com/daler/gffutils/blob/6f7f547cad898738a1bd0a999fd68ba68db2c524/gffutils/interface.py#L268-L289
daler/gffutils
gffutils/interface.py
FeatureDB.iter_by_parent_childs
def iter_by_parent_childs(self, featuretype="gene", level=None, order_by=None, reverse=False, completely_within=False): """ For each parent of type `featuretype`, yield a list L of that parent and all of its children (`[parent] + list(c...
python
def iter_by_parent_childs(self, featuretype="gene", level=None, order_by=None, reverse=False, completely_within=False): """ For each parent of type `featuretype`, yield a list L of that parent and all of its children (`[parent] + list(c...
[ "def", "iter_by_parent_childs", "(", "self", ",", "featuretype", "=", "\"gene\"", ",", "level", "=", "None", ",", "order_by", "=", "None", ",", "reverse", "=", "False", ",", "completely_within", "=", "False", ")", ":", "# Get all the parent records of the requeste...
For each parent of type `featuretype`, yield a list L of that parent and all of its children (`[parent] + list(children)`). The parent will always be L[0]. This is useful for "sanitizing" a GFF file for downstream tools. Additional kwargs are passed to :meth:`FeatureDB.children`, and w...
[ "For", "each", "parent", "of", "type", "featuretype", "yield", "a", "list", "L", "of", "that", "parent", "and", "all", "of", "its", "children", "(", "[", "parent", "]", "+", "list", "(", "children", ")", ")", ".", "The", "parent", "will", "always", "...
train
https://github.com/daler/gffutils/blob/6f7f547cad898738a1bd0a999fd68ba68db2c524/gffutils/interface.py#L292-L312
daler/gffutils
gffutils/interface.py
FeatureDB.featuretypes
def featuretypes(self): """ Iterate over feature types found in the database. Returns ------- A generator object that yields featuretypes (as strings) """ c = self.conn.cursor() c.execute( ''' SELECT DISTINCT featuretype from featu...
python
def featuretypes(self): """ Iterate over feature types found in the database. Returns ------- A generator object that yields featuretypes (as strings) """ c = self.conn.cursor() c.execute( ''' SELECT DISTINCT featuretype from featu...
[ "def", "featuretypes", "(", "self", ")", ":", "c", "=", "self", ".", "conn", ".", "cursor", "(", ")", "c", ".", "execute", "(", "'''\n SELECT DISTINCT featuretype from features\n '''", ")", "for", "i", ",", "in", "c", ":", "yield", "i" ]
Iterate over feature types found in the database. Returns ------- A generator object that yields featuretypes (as strings)
[ "Iterate", "over", "feature", "types", "found", "in", "the", "database", "." ]
train
https://github.com/daler/gffutils/blob/6f7f547cad898738a1bd0a999fd68ba68db2c524/gffutils/interface.py#L339-L353
daler/gffutils
gffutils/interface.py
FeatureDB._relation
def _relation(self, id, join_on, join_to, level=None, featuretype=None, order_by=None, reverse=False, completely_within=False, limit=None): # The following docstring will be included in the parents() and # children() docstrings to maintain consistency, since they bot...
python
def _relation(self, id, join_on, join_to, level=None, featuretype=None, order_by=None, reverse=False, completely_within=False, limit=None): # The following docstring will be included in the parents() and # children() docstrings to maintain consistency, since they bot...
[ "def", "_relation", "(", "self", ",", "id", ",", "join_on", ",", "join_to", ",", "level", "=", "None", ",", "featuretype", "=", "None", ",", "order_by", "=", "None", ",", "reverse", "=", "False", ",", "completely_within", "=", "False", ",", "limit", "=...
Parameters ---------- id : string or a Feature object level : None or int If `level=None` (default), then return all children regardless of level. If `level` is an integer, then constrain to just that level. {_method_doc} Returns -...
[ "Parameters", "----------" ]
train
https://github.com/daler/gffutils/blob/6f7f547cad898738a1bd0a999fd68ba68db2c524/gffutils/interface.py#L355-L409
daler/gffutils
gffutils/interface.py
FeatureDB.parents
def parents(self, id, level=None, featuretype=None, order_by=None, reverse=False, completely_within=False, limit=None): """ Return parents of feature `id`. {_relation_docstring} """ return self._relation( id, join_on='parent', join_to='child', level=le...
python
def parents(self, id, level=None, featuretype=None, order_by=None, reverse=False, completely_within=False, limit=None): """ Return parents of feature `id`. {_relation_docstring} """ return self._relation( id, join_on='parent', join_to='child', level=le...
[ "def", "parents", "(", "self", ",", "id", ",", "level", "=", "None", ",", "featuretype", "=", "None", ",", "order_by", "=", "None", ",", "reverse", "=", "False", ",", "completely_within", "=", "False", ",", "limit", "=", "None", ")", ":", "return", "...
Return parents of feature `id`. {_relation_docstring}
[ "Return", "parents", "of", "feature", "id", ".", "{", "_relation_docstring", "}" ]
train
https://github.com/daler/gffutils/blob/6f7f547cad898738a1bd0a999fd68ba68db2c524/gffutils/interface.py#L422-L431
daler/gffutils
gffutils/interface.py
FeatureDB.execute
def execute(self, query): """ Execute arbitrary queries on the db. .. seealso:: :class:`FeatureDB.schema` may be helpful when writing your own queries. Parameters ---------- query : str Query to execute -- trailing ";" opti...
python
def execute(self, query): """ Execute arbitrary queries on the db. .. seealso:: :class:`FeatureDB.schema` may be helpful when writing your own queries. Parameters ---------- query : str Query to execute -- trailing ";" opti...
[ "def", "execute", "(", "self", ",", "query", ")", ":", "c", "=", "self", ".", "conn", ".", "cursor", "(", ")", "return", "c", ".", "execute", "(", "query", ")" ]
Execute arbitrary queries on the db. .. seealso:: :class:`FeatureDB.schema` may be helpful when writing your own queries. Parameters ---------- query : str Query to execute -- trailing ";" optional. Returns ------- ...
[ "Execute", "arbitrary", "queries", "on", "the", "db", "." ]
train
https://github.com/daler/gffutils/blob/6f7f547cad898738a1bd0a999fd68ba68db2c524/gffutils/interface.py#L440-L461
daler/gffutils
gffutils/interface.py
FeatureDB.region
def region(self, region=None, seqid=None, start=None, end=None, strand=None, featuretype=None, completely_within=False): """ Return features within specified genomic coordinates. Specifying genomic coordinates can be done in a flexible manner Parameters ---------...
python
def region(self, region=None, seqid=None, start=None, end=None, strand=None, featuretype=None, completely_within=False): """ Return features within specified genomic coordinates. Specifying genomic coordinates can be done in a flexible manner Parameters ---------...
[ "def", "region", "(", "self", ",", "region", "=", "None", ",", "seqid", "=", "None", ",", "start", "=", "None", ",", "end", "=", "None", ",", "strand", "=", "None", ",", "featuretype", "=", "None", ",", "completely_within", "=", "False", ")", ":", ...
Return features within specified genomic coordinates. Specifying genomic coordinates can be done in a flexible manner Parameters ---------- region : string, tuple, or Feature instance If string, then of the form "seqid:start-end". If tuple, then (seqid, start, ...
[ "Return", "features", "within", "specified", "genomic", "coordinates", "." ]
train
https://github.com/daler/gffutils/blob/6f7f547cad898738a1bd0a999fd68ba68db2c524/gffutils/interface.py#L471-L648
daler/gffutils
gffutils/interface.py
FeatureDB.interfeatures
def interfeatures(self, features, new_featuretype=None, merge_attributes=True, dialect=None, attribute_func=None, update_attributes=None): """ Construct new features representing the space between features. For example, if `features` is a list of exon...
python
def interfeatures(self, features, new_featuretype=None, merge_attributes=True, dialect=None, attribute_func=None, update_attributes=None): """ Construct new features representing the space between features. For example, if `features` is a list of exon...
[ "def", "interfeatures", "(", "self", ",", "features", ",", "new_featuretype", "=", "None", ",", "merge_attributes", "=", "True", ",", "dialect", "=", "None", ",", "attribute_func", "=", "None", ",", "update_attributes", "=", "None", ")", ":", "for", "i", "...
Construct new features representing the space between features. For example, if `features` is a list of exons, then this method will return the introns. If `features` is a list of genes, then this method will return the intergenic regions. Providing N features will return N - 1 new fe...
[ "Construct", "new", "features", "representing", "the", "space", "between", "features", "." ]
train
https://github.com/daler/gffutils/blob/6f7f547cad898738a1bd0a999fd68ba68db2c524/gffutils/interface.py#L650-L766
daler/gffutils
gffutils/interface.py
FeatureDB.delete
def delete(self, features, make_backup=True, **kwargs): """ Delete features from database. features : str, iterable, FeatureDB instance If FeatureDB, all features will be used. If string, assume it's the ID of the feature to remove. Otherwise, assume it's an iterable of ...
python
def delete(self, features, make_backup=True, **kwargs): """ Delete features from database. features : str, iterable, FeatureDB instance If FeatureDB, all features will be used. If string, assume it's the ID of the feature to remove. Otherwise, assume it's an iterable of ...
[ "def", "delete", "(", "self", ",", "features", ",", "make_backup", "=", "True", ",", "*", "*", "kwargs", ")", ":", "if", "make_backup", ":", "if", "isinstance", "(", "self", ".", "dbfn", ",", "six", ".", "string_types", ")", ":", "shutil", ".", "copy...
Delete features from database. features : str, iterable, FeatureDB instance If FeatureDB, all features will be used. If string, assume it's the ID of the feature to remove. Otherwise, assume it's an iterable of Feature objects. The classes in gffutils.iterators may be helpfu...
[ "Delete", "features", "from", "database", "." ]
train
https://github.com/daler/gffutils/blob/6f7f547cad898738a1bd0a999fd68ba68db2c524/gffutils/interface.py#L768-L812
daler/gffutils
gffutils/interface.py
FeatureDB.update
def update(self, data, make_backup=True, **kwargs): """ Update database with features in `data`. data : str, iterable, FeatureDB instance If FeatureDB, all data will be used. If string, assume it's a filename of a GFF or GTF file. Otherwise, assume it's an i...
python
def update(self, data, make_backup=True, **kwargs): """ Update database with features in `data`. data : str, iterable, FeatureDB instance If FeatureDB, all data will be used. If string, assume it's a filename of a GFF or GTF file. Otherwise, assume it's an i...
[ "def", "update", "(", "self", ",", "data", ",", "make_backup", "=", "True", ",", "*", "*", "kwargs", ")", ":", "from", "gffutils", "import", "create", "from", "gffutils", "import", "iterators", "if", "make_backup", ":", "if", "isinstance", "(", "self", "...
Update database with features in `data`. data : str, iterable, FeatureDB instance If FeatureDB, all data will be used. If string, assume it's a filename of a GFF or GTF file. Otherwise, assume it's an iterable of Feature objects. The classes in gffutils.iterators may ...
[ "Update", "database", "with", "features", "in", "data", "." ]
train
https://github.com/daler/gffutils/blob/6f7f547cad898738a1bd0a999fd68ba68db2c524/gffutils/interface.py#L814-L871
daler/gffutils
gffutils/interface.py
FeatureDB.add_relation
def add_relation(self, parent, child, level, parent_func=None, child_func=None): """ Manually add relations to the database. Parameters ---------- parent : str or Feature instance Parent feature to add. child : str or Feature instance ...
python
def add_relation(self, parent, child, level, parent_func=None, child_func=None): """ Manually add relations to the database. Parameters ---------- parent : str or Feature instance Parent feature to add. child : str or Feature instance ...
[ "def", "add_relation", "(", "self", ",", "parent", ",", "child", ",", "level", ",", "parent_func", "=", "None", ",", "child_func", "=", "None", ")", ":", "if", "isinstance", "(", "parent", ",", "six", ".", "string_types", ")", ":", "parent", "=", "self...
Manually add relations to the database. Parameters ---------- parent : str or Feature instance Parent feature to add. child : str or Feature instance Child feature to add level : int Level of the relation. For example, if parent is a gene ...
[ "Manually", "add", "relations", "to", "the", "database", "." ]
train
https://github.com/daler/gffutils/blob/6f7f547cad898738a1bd0a999fd68ba68db2c524/gffutils/interface.py#L873-L928
daler/gffutils
gffutils/interface.py
FeatureDB._insert
def _insert(self, feature, cursor): """ Insert a feature into the database. """ try: cursor.execute(constants._INSERT, feature.astuple()) except sqlite3.ProgrammingError: cursor.execute( constants._INSERT, feature.astuple(self.default_encod...
python
def _insert(self, feature, cursor): """ Insert a feature into the database. """ try: cursor.execute(constants._INSERT, feature.astuple()) except sqlite3.ProgrammingError: cursor.execute( constants._INSERT, feature.astuple(self.default_encod...
[ "def", "_insert", "(", "self", ",", "feature", ",", "cursor", ")", ":", "try", ":", "cursor", ".", "execute", "(", "constants", ".", "_INSERT", ",", "feature", ".", "astuple", "(", ")", ")", "except", "sqlite3", ".", "ProgrammingError", ":", "cursor", ...
Insert a feature into the database.
[ "Insert", "a", "feature", "into", "the", "database", "." ]
train
https://github.com/daler/gffutils/blob/6f7f547cad898738a1bd0a999fd68ba68db2c524/gffutils/interface.py#L935-L943
daler/gffutils
gffutils/interface.py
FeatureDB.create_introns
def create_introns(self, exon_featuretype='exon', grandparent_featuretype='gene', parent_featuretype=None, new_featuretype='intron', merge_attributes=True): """ Create introns from existing annotations. Parameters ---------- exon_fe...
python
def create_introns(self, exon_featuretype='exon', grandparent_featuretype='gene', parent_featuretype=None, new_featuretype='intron', merge_attributes=True): """ Create introns from existing annotations. Parameters ---------- exon_fe...
[ "def", "create_introns", "(", "self", ",", "exon_featuretype", "=", "'exon'", ",", "grandparent_featuretype", "=", "'gene'", ",", "parent_featuretype", "=", "None", ",", "new_featuretype", "=", "'intron'", ",", "merge_attributes", "=", "True", ")", ":", "if", "(...
Create introns from existing annotations. Parameters ---------- exon_featuretype : string Feature type to use in order to infer introns. Typically `"exon"`. grandparent_featuretype : string If `grandparent_featuretype` is not None, then group exons by ...
[ "Create", "introns", "from", "existing", "annotations", "." ]
train
https://github.com/daler/gffutils/blob/6f7f547cad898738a1bd0a999fd68ba68db2c524/gffutils/interface.py#L945-L1017
daler/gffutils
gffutils/interface.py
FeatureDB.merge
def merge(self, features, ignore_strand=False): """ Merge overlapping features together. Parameters ---------- features : iterator of Feature instances ignore_strand : bool If True, features on multiple strands will be merged, and the final stra...
python
def merge(self, features, ignore_strand=False): """ Merge overlapping features together. Parameters ---------- features : iterator of Feature instances ignore_strand : bool If True, features on multiple strands will be merged, and the final stra...
[ "def", "merge", "(", "self", ",", "features", ",", "ignore_strand", "=", "False", ")", ":", "# Consume iterator up front...", "features", "=", "list", "(", "features", ")", "if", "len", "(", "features", ")", "==", "0", ":", "raise", "StopIteration", "# Eithe...
Merge overlapping features together. Parameters ---------- features : iterator of Feature instances ignore_strand : bool If True, features on multiple strands will be merged, and the final strand will be set to '.'. Otherwise, ValueError will be raised if ...
[ "Merge", "overlapping", "features", "together", "." ]
train
https://github.com/daler/gffutils/blob/6f7f547cad898738a1bd0a999fd68ba68db2c524/gffutils/interface.py#L1019-L1112
daler/gffutils
gffutils/interface.py
FeatureDB.children_bp
def children_bp(self, feature, child_featuretype='exon', merge=False, ignore_strand=False): """ Total bp of all children of a featuretype. Useful for getting the exonic bp of an mRNA. Parameters ---------- feature : str or Feature instance ...
python
def children_bp(self, feature, child_featuretype='exon', merge=False, ignore_strand=False): """ Total bp of all children of a featuretype. Useful for getting the exonic bp of an mRNA. Parameters ---------- feature : str or Feature instance ...
[ "def", "children_bp", "(", "self", ",", "feature", ",", "child_featuretype", "=", "'exon'", ",", "merge", "=", "False", ",", "ignore_strand", "=", "False", ")", ":", "children", "=", "self", ".", "children", "(", "feature", ",", "featuretype", "=", "child_...
Total bp of all children of a featuretype. Useful for getting the exonic bp of an mRNA. Parameters ---------- feature : str or Feature instance child_featuretype : str Which featuretype to consider. For example, to get exonic bp of an mRNA, use `child...
[ "Total", "bp", "of", "all", "children", "of", "a", "featuretype", "." ]
train
https://github.com/daler/gffutils/blob/6f7f547cad898738a1bd0a999fd68ba68db2c524/gffutils/interface.py#L1114-L1152