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_documentation_string
stringlengths
1
47.2k
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...
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...
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, ...
Handles <get_scanner_details> command. @return: Response string for <get_scanner_details> command.
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,...
Handles <get_version> command. @return: Response string for <get_version> command.
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...
Handles an osp command in a string. @return: OSP Response to command.
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 =...
Starts the Daemon, handling commands until interrupted. @return False if error. Runs indefinitely otherwise.
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) ...
Creates a new scan. @target: Target to scan. @options: Miscellaneous scan options. @return: New scan's ID.
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)
Sets a scan's option to a provided value.
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...
Check the scan's process, and terminate the scan if not alive.
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)
Adds a log result to scan_id scan.
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)
Adds an error result to scan_id scan.
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)
Adds a host detail result to scan_id scan.
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...
Adds an alarm result to scan_id scan.
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...
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...
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...
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.
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...
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...
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...
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
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: ...
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.
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...
A platform independent version of inet_pton
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...
A platform independent version of inet_ntop
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...
Return a list of IPv4 entries from start_packed to end_packed.
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...
Attempt to return a IPv4 short range list from a target string.
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...
Attempt to return a IPv4 CIDR list from a target string.
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...
Attempt to return a IPv6 CIDR list from a target string.
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]) ...
Attempt to return a IPv4 long-range list from a target string.
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 ...
Return a list of IPv6 entries from start_packed to end_packed.
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...
Attempt to return a IPv6 short-range list from a target string.
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]...
Attempt to return a IPv6 long-range list from a target string.
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]
Attempt to return a single hostname list from a target string.
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: ...
Attempt to return a list of single hosts from a target string.
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) ...
Parses a targets string into a list of individual targets.
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...
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]
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[...
Gives a str in the format (always tcp listed first). T:<tcp ports/portrange comma separated>U:<udp ports comma separated>
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(':')...
Check if the port string is well formed. Return True if fail, False other case.
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...
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.
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...
Compress a port list and return a string.
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
Check if value is a valid UUID.
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...
Create a command-line arguments parser for OSPD.
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')
Daemonize the running process.
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 ...
Return list of OSPD common command-line arguments from parser, after validating provided values or setting default ones.
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(...
Prints the server version and license information.
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'], ...
OSPD Main function.
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...
Add a result to a scan in the table.
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())
Sets scan_id scan's progress.
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...
Sets scan_id scan's progress.
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
Add the host in a list of finished hosts
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']: ...
Get a list of finished hosts.
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...
Returns an iterator over scan_id scan's results. If pop_res is True, it removed the fetched results from the list.
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...
Remove results from the result table for those host
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...
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...
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...
Creates a new scan with provided scan information.
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
Set a scan_id scan's name option to value.
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']...
Get a target's current progress value. The value is calculated with the progress of each single host in the target.
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
Get a scan's target list.
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...
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.
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]: ...
Get a scan's credential list. It return dictionary with the corresponding credential for a given target.
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 ...
Delete a scan if fully finished.
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 == ...
Return string name of a result type.
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 ==...
Return string name of a result type.
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 ...
Valid types are: - objects of float type - Strings that can be converted to float. For example '1e-06'
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)
Yaml either have automatically converted it to a datetime object or it is a string that will be validated later.
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":...
Init logging settings with default set to INFO
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'), ...
Returns a list of all keywords that this rule object has defined. A keyword is considered defined if the value it returns != None.
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...
All supported keywords: - allowempty_map - assertion - class - date - default - desc - enum - example - extensions - func - ident - include_name - map_regex_rule - mapping - matching ...
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...
Load all extension files into the namespace pykwalify.ext
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: ...
Helper function that should check if func is specified for this rule and then handle it for all cases in a generic way.
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...
Validate that value is within range values.
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 ...] ...
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
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']...
Split the functionality into 2 methods. One for parsing the cli and one that runs the application.
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 ...
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...
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...
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...
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 ...
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 ------...
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...
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
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...
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.
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 ...
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...
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 ...
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...
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...
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.
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...
Write out the children records of the exon given by the ID (not including the exon record itself).
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...
Close the stream. Assumes stream has 'close' method.
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...
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. '...
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 ...
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...
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...
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.
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. ""...
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.
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...
Returns a feature, adding additional database-specific defaults
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...
Returns the database schema as a string.
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 ...
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* ...
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} ""...
Returns an iterator of :class:`gffutils.Feature` objects. Parameters ---------- {_method_doc}
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...
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...
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...
Iterate over feature types found in the database. Returns ------- A generator object that yields featuretypes (as strings)
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...
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 -...
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...
Return parents of feature `id`. {_relation_docstring}
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...
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 ------- ...
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 ---------...
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, ...
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...
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...
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 ...
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...
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...
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 ...
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 ...
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 ...
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...
Insert a feature into the database.
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...
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 ...
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...
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 ...
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 ...
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...
https://github.com/daler/gffutils/blob/6f7f547cad898738a1bd0a999fd68ba68db2c524/gffutils/interface.py#L1114-L1152