text
stringlengths
81
112k
get_pid will return a pid of interest. First we use given variable, then environmental variable PID, and then PID of running process def get_pid(pid=None): '''get_pid will return a pid of interest. First we use given variable, then environmental variable PID, and then PID of running process ''' if ...
get_memory_usage returns a dictionary of resident set size (rss) and virtual memory size (vms) for a process of interest, for as long as the process is running :param pid: the pid to use: :param timeout: the timeout :: notes example: sleep 3 & exec python -m memory "$!" def get_me...
Loads the stored routine into the instance of MySQL. Returns the metadata of the stored routine if the stored routine is loaded successfully. Otherwise returns False. :rtype: dict[str,str]|bool def load_stored_routine(self): """ Loads the stored routine into the instance of My...
Reads the file with the source of the stored routine. def __read_source_file(self): """ Reads the file with the source of the stored routine. """ with open(self._source_filename, 'r', encoding=self._routine_file_encoding) as file: self._routine_source_code = file.read() ...
Saves a copy of the stored routine source with pure SQL (if shadow directory is set). def __save_shadow_copy(self): """ Saves a copy of the stored routine source with pure SQL (if shadow directory is set). """ if not self.shadow_directory: return destination_filenam...
Substitutes all replace pairs in the source of the stored routine. def __substitute_replace_pairs(self): """ Substitutes all replace pairs in the source of the stored routine. """ self._set_magic_constants() routine_source = [] i = 0 for line in self._routine_so...
Logs an exception. :param Exception exception: The exception. :rtype: None def _log_exception(self, exception): """ Logs an exception. :param Exception exception: The exception. :rtype: None """ self._io.error(str(exception).strip().split(os.linesep))
Extracts the placeholders from the stored routine source. def __get_placeholders(self): """ Extracts the placeholders from the stored routine source. """ ret = True pattern = re.compile('(@[A-Za-z0-9_.]+(%(max-)?type)?@)') matches = pattern.findall(self._routine_source_...
Extracts the designation type of the stored routine. def _get_designation_type(self): """ Extracts the designation type of the stored routine. """ positions = self._get_specification_positions() if positions[0] != -1 and positions[1] != -1: pattern = re.compile(r'^\s...
Returns a tuple with the start and end line numbers of the stored routine specification. :rtype: tuple def _get_specification_positions(self): """ Returns a tuple with the start and end line numbers of the stored routine specification. :rtype: tuple """ start = -1 ...
Returns the start and end line of the DOcBlock of the stored routine code. def __get_doc_block_lines(self): """ Returns the start and end line of the DOcBlock of the stored routine code. """ line1 = None line2 = None i = 0 for line in self._routine_source_code_l...
Extracts the DocBlock (in parts) from the source of the stored routine source. def __get_doc_block_parts_source(self): """ Extracts the DocBlock (in parts) from the source of the stored routine source. """ line1, line2 = self.__get_doc_block_lines() if line1 is not None and lin...
Generates the DocBlock parts to be used by the wrapper generator. def __get_doc_block_parts_wrapper(self): """ Generates the DocBlock parts to be used by the wrapper generator. """ self.__get_doc_block_parts_source() helper = self._get_data_type_helper() parameters = l...
Updates the metadata of the stored routine. def _update_metadata(self): """ Updates the metadata of the stored routine. """ self._pystratum_metadata['routine_name'] = self._routine_name self._pystratum_metadata['designation'] = self._designation_type self._pystratum_meta...
Adds magic constants to replace list. def _set_magic_constants(self): """ Adds magic constants to replace list. """ real_path = os.path.realpath(self._source_filename) self._replace['__FILE__'] = "'%s'" % real_path self._replace['__ROUTINE__'] = "'%s'" % self._routine_n...
Removes magic constants from current replace list. def _unset_magic_constants(self): """ Removes magic constants from current replace list. """ if '__FILE__' in self._replace: del self._replace['__FILE__'] if '__ROUTINE__' in self._replace: del self._rep...
Writes a SQL statement with an syntax error to the output. The line where the error occurs is highlighted. :param str sql: The SQL statement. :param int error_line: The line where the error occurs. def _print_sql_with_error(self, sql, error_line): """ Writes a SQL statement with an syn...
Keep in list items according to filter parameters. :param lst: item list :param startswith: keep items starting with :param notstartswith: remove items starting with :return: def list_filter(lst, startswith=None, notstartswith=None, contain=None, notcontain=None): """ Keep in list ...
Split dict into two subdicts based on keys. :param dct: :param keys: :return: dict_in, dict_out def split_dict(dct, keys): """ Split dict into two subdicts based on keys. :param dct: :param keys: :return: dict_in, dict_out """ if type(dct) == collections.OrderedDict: d...
Dict recursive update. Based on Alex Martelli code on stackoverflow http://stackoverflow.com/questions/3232943/update-value-of-a-nested-dictionary-of-varying-depth?answertab=votes#tab-top :param d: dict to update :param u: dict with new data :return: def recursive_update(d, u): """ Dict r...
Flatten dict with defined key join symbol. :param dct: dict to flatten :param join_symbol: default value is " " :return: def flatten_dict_join_keys(dct, join_symbol=" "): """ Flatten dict with defined key join symbol. :param dct: dict to flatten :param join_symbol: default value is " " :r...
Get strings in list which contains substring. def list_contains(list_of_strings, substring, return_true_false_array=False): """ Get strings in list which contains substring. """ key_tf = [keyi.find(substring) != -1 for keyi in list_of_strings] if return_true_false_array: return key_tf keys...
Drop duplicates from dataframe ignore columns with keys containing defined pattern. :param df: :param noinfo_key_pattern: :return: def df_drop_duplicates(df, ignore_key_pattern="time"): """ Drop duplicates from dataframe ignore columns with keys containing defined pattern. :param df: :par...
Change ndarray in structure of lists and dicts into lists. def ndarray_to_list_in_structure(item, squeeze=True): """ Change ndarray in structure of lists and dicts into lists. """ tp = type(item) if tp == np.ndarray: if squeeze: item = item.squeeze() item = item.tolist() ...
Find first suitable key in dict. :param dd: :param value: :return: def dict_find_key(dd, value): """ Find first suitable key in dict. :param dd: :param value: :return: """ key = next(key for key, val in dd.items() if val == value) return key
Sort list of dicts by one or multiple keys. If the key is not available, sort these to the end. :param lst_of_dct: input structure. List of dicts. :param keys: one or more keys in list :param reverse: :param sort_args: :return: def sort_list_of_dicts(lst_of_dct, keys, reverse=False, **sort_ar...
Use dict instead of ordered dict in structure. def ordered_dict_to_dict(config): """ Use dict instead of ordered dict in structure. """ if type(config) == collections.OrderedDict: config = dict(config) if type(config) == list: for i in range(0, len(config)): config[i] =...
:param str config_file: The name of config file. def run_command(self, config_file): """ :param str config_file: The name of config file. """ config = configparser.ConfigParser() config.read(config_file) rdbms = config.get('database', 'rdbms').lower() wrapper =...
Factory for creating a Constants objects (i.e. objects for generating a class with wrapper methods for calling stored routines in a database). :param str rdbms: The target RDBMS (i.e. mysql, mssql or pgsql). :rtype: pystratum.RoutineWrapperGenerator.RoutineWrapperGenerator def create_routine_...
Reads an option for a configuration file. :param configparser.ConfigParser config: The main config file. :param configparser.ConfigParser supplement: The supplement config file. :param str section: The name of the section op the option. :param str option: The name of the option. ...
Checks the supplement file. :param str config_filename: The name of the configuration file. :rtype: (configparser.ConfigParser,configparser.ConfigParser) def _read_configuration(config_filename): """ Checks the supplement file. :param str config_filename: The name of the conf...
a wrapper around generation of an asciinema.api.Api and a custom recorder to pull out the input arguments to the Record from argparse. The function generates a filename in advance and a return code so we can check the final status. def record_asciinema(): '''a wrapper around generation of an ...
Send a wake up package to a device specified by its MAC address. :param str macAddress: MAC address in the form ``38:C9:86:26:7E:38``; be aware that the MAC address might be case sensitive, depending on the router :param int lanInterfaceId: the id of the LAN interface :param float t...
Do a software update of the Fritz Box if available. :param float timeout: the timeout to wait for the action to be executed :return: a list of if an update was available and the update state (bool, str) :rtype: tuple(bool, str) def doUpdate(self, timeout=1): """Do a software update of ...
Return if the Wifi interface is optimized for IP TV :param int wifiInterfaceId: the id of the Wifi interface :param float timeout: the timeout to wait for the action to be executed :return: if the Wifi interface is optimized for IP TV :rtype: bool .. seealso:: :meth:`~simpletr6...
Set if the Wifi interface is optimized for IP TV :param bool status: set if Wifi interface should be optimized :param int wifiInterfaceId: the id of the Wifi interface :param float timeout: the timeout to wait for the action to be executed .. seealso:: :meth:`~simpletr64.actions.Fritz....
Get the list of phone calls made Example of a phone call result: :: [{'Count': None, 'Name': None, 'CalledNumber': '030868709971', 'Numbertype': 'sip', 'Duration': '0:01', 'Caller': '015155255399', 'Called': 'SIP: 030868729971', 'Date': '02.01.14 13:14', 'Device': ...
Adds a unix socket server callback, which will be invoked when values arrive from a connected socket client. The callback must accept two parameters, eg. ``def callback(socket, msg)``. def add_tcp_callback(port, callback, threaded_callback=False): """ Adds a unix socket server callback, which will be i...
Add a callback to be executed when the value on 'gpio_id' changes to the edge specified via the 'edge' parameter (default='both'). `pull_up_down` can be set to `RPIO.PUD_UP`, `RPIO.PUD_DOWN`, and `RPIO.PUD_OFF`. If `threaded_callback` is True, the callback will be started inside a Thread. If ...
Blocking loop to listen for GPIO interrupts and distribute them to associated callbacks. epoll_timeout is an easy way to shutdown the blocking function. Per default the timeout is set to 1 second; if `_is_waiting_for_interrupts` is set to False the loop will exit. If an exception occurs while waiting f...
Builds source with Python 2.7 and 3.2, and tests import def build_gpio(): """ Builds source with Python 2.7 and 3.2, and tests import """ with cd("/tmp/source/c_gpio"): test = "import _GPIO; print(_GPIO.VERSION_GPIO)" run("make gpio2.7 && cp build/_GPIO.so .") run('sudo python2.7 -c "%s...
Builds source with Python 2.7 and 3.2, and tests import def build_pwm(): """ Builds source with Python 2.7 and 3.2, and tests import """ with cd("/tmp/source/c_pwm"): test = "import _PWM; print(_PWM.VERSION)" run("make py2.7") run('sudo python2.7 -c "%s"' % test) run("cp _PWM.so...
Upload sdist and bdist_eggs to pypi def upload_to_pypi(): """ Upload sdist and bdist_eggs to pypi """ # One more safety input and then we are ready to go :) x = prompt("Are you sure to upload the current version to pypi?") if not x or not x.lower() in ["y", "yes"]: return local("rm -rf dis...
Internal wrapper to start a callback in threaded mode. Using the daemon mode to not block the main thread from exiting. def _threaded_callback(callback, *args): """ Internal wrapper to start a callback in threaded mode. Using the daemon mode to not block the main thread from exiting. """ t = Th...
Adds a unix socket server callback, which will be invoked when values arrive from a connected socket client. The callback must accept two parameters, eg. ``def callback(socket, msg)``. def add_tcp_callback(self, port, callback, threaded_callback=False): """ Adds a unix socket server cal...
Add a callback to be executed when the value on 'gpio_id' changes to the edge specified via the 'edge' parameter (default='both'). `pull_up_down` can be set to `RPIO.PUD_UP`, `RPIO.PUD_DOWN`, and `RPIO.PUD_OFF`. If `threaded_callback` is True, the callback will be started insid...
Delete all interrupt callbacks from a certain gpio def del_interrupt_callback(self, gpio_id): """ Delete all interrupt callbacks from a certain gpio """ debug("- removing interrupts on gpio %s" % gpio_id) gpio_id = _GPIO.channel_to_gpio(gpio_id) fileno = self._map_gpioid_to_fileno[gpio_...
Internally distributes interrupts to all attached callbacks def _handle_interrupt(self, fileno, val): """ Internally distributes interrupts to all attached callbacks """ val = int(val) # Filter invalid edge values (sometimes 1 comes in when edge=falling) edge = self._map_fileno_to_opti...
Blocking loop to listen for GPIO interrupts and distribute them to associated callbacks. epoll_timeout is an easy way to shutdown the blocking function. Per default the timeout is set to 1 second; if `_is_waiting_for_interrupts` is set to False the loop will exit. If an exception occurs...
Removes all /sys/class/gpio/gpioN interfaces that this script created, and deletes callback bindings. Should be used after using interrupts. def cleanup_interfaces(self): """ Removes all /sys/class/gpio/gpioN interfaces that this script created, and deletes callback bindings. Should be ...
Closes all TCP connections and then the socket servers def cleanup_tcpsockets(self): """ Closes all TCP connections and then the socket servers """ for fileno in self._tcp_client_sockets.keys(): self.close_tcp_client(fileno) for fileno, items in self._tcp_server_sock...
Add a pulse for a specific GPIO to a dma channel subcycle. `start` and `width` are multiples of the pulse-width increment granularity. def add_channel_pulse(dma_channel, gpio, start, width): """ Add a pulse for a specific GPIO to a dma channel subcycle. `start` and `width` are multiples of the pulse-wi...
Sets a pulse-width on a gpio to repeat every subcycle (by default every 20ms). def set_servo(self, gpio, pulse_width_us): """ Sets a pulse-width on a gpio to repeat every subcycle (by default every 20ms). """ # Make sure we can set the exact pulse_width_us _pulse...
Makes the list have unique items only and maintains the order list(set()) won't provide that :type _list list :rtype: list def unique(_list): """ Makes the list have unique items only and maintains the order list(set()) won't provide that :type _list list :rtype: list """ re...
Perform initial query cleanup :type query str :rtype str def preprocess_query(query): """ Perform initial query cleanup :type query str :rtype str """ # 1. remove aliases # FROM `dimension_wikis` `dw` # INNER JOIN `fact_wam_scores` `fwN` query = re.sub(r'(\s(FROM|JOIN)\s`[...
:type query str :rtype: list[sqlparse.sql.Token] def get_query_tokens(query): """ :type query str :rtype: list[sqlparse.sql.Token] """ query = preprocess_query(query) parsed = sqlparse.parse(query) # handle empty queries (#12) if not parsed: return [] tokens = TokenLis...
:type query str :rtype: list[str] def get_query_columns(query): """ :type query str :rtype: list[str] """ columns = [] last_keyword = None last_token = None # print(preprocess_query(query)) # these keywords should not change the state of a parser # and not "reset" previous...
:type query str :rtype: list[str] def get_query_tables(query): """ :type query str :rtype: list[str] """ tables = [] last_keyword = None last_token = None table_syntax_keywords = [ # SELECT queries 'FROM', 'WHERE', 'JOIN', 'INNER JOIN', 'LEFT JOIN', 'RIGHT JOIN', 'O...
:type query str :rtype: (int, int) def get_query_limit_and_offset(query): """ :type query str :rtype: (int, int) """ limit = None offset = None last_keyword = None last_token = None # print(query) for token in get_query_tokens(query): # print([token, token.ttype, la...
Normalize and wrap LIKE statements :type sql str :rtype: str def normalize_likes(sql): """ Normalize and wrap LIKE statements :type sql str :rtype: str """ sql = sql.replace('%', '') # LIKE '%bot' sql = re.sub(r"LIKE '[^\']+'", 'LIKE X', sql) # or all_groups LIKE X or al...
Removes most variables from an SQL query and replaces them with X or N for numbers. Based on Mediawiki's DatabaseBase::generalizeSQL :type sql str|None :rtype: str def generalize_sql(sql): """ Removes most variables from an SQL query and replaces them with X or N for numbers. Based on Mediaw...
Build deblur command for subprocess. Parameters ---------- params: list of str parameter settings to pass to deblur CLI input_fp : str name of the input fasta file to deblur Returns ------- stdout: string process output directed to standard output stderr: string...
Given a functor, run it and return its result. We can use this with multiprocessing.map and map it over a list of job functors to do them. Handles getting more than multiprocessing's pitiful exception output This function was derived from: http://stackoverflow.com/a/16618842/19741 This code was a...
Dispatch execution over a pool of processors This code was adopted from the American Gut project: https://github.com/biocore/American-Gut/blob/master/americangut/parallel.py Parameters ---------- inputs : iterable of str File paths to input per-sample sequence files params : list of st...
Yield (id, sequence) from an input file Parameters ---------- input_fp : filepath A filepath, which can be any valid fasta or fastq file within the limitations of scikit-bio's IO registry. Notes ----- The use of this method is a stopgap to replicate the existing `parse_fasta` ...
Trim FASTA sequences to specified length. Parameters ---------- input_seqs : iterable of (str, str) The list of input sequences in (label, sequence) format trim_len : int Sequence trimming length. Specify a value of -1 to disable trimming. left_trim_len : int Sequence trimmi...
Dereplicate FASTA sequences and remove singletons using VSEARCH. Parameters ---------- seqs_fp : string filepath to FASTA sequence file output_fp : string file path to dereplicated sequences (FASTA format) min_size : integer, optional discard sequences with an abundance valu...
Build a SortMeRNA index for all reference databases. Parameters ---------- ref_fp: tuple filepaths to FASTA reference databases working_dir: string working directory path where to store the indexed database Returns ------- all_db: tuple filepaths to SortMeRNA indexe...
Filter samples from biom table that have less than minreads reads total Paraneters ---------- table : biom.Table the biom table to filter minreads : int (optional) the minimal number of reads in a sample in order to keep it inplace : bool (optional) if True, filter the b...
Save sequences from a biom table to a fasta file Parameters ---------- table : biom.Table The biom table containing the sequences fasta_file_name : str Name of the fasta output file def fasta_from_biom(table, fasta_file_name): '''Save sequences from a biom table to a fasta file ...
Remove artifacts from a biom table using SortMeRNA Parameters ---------- table : str name of the biom table file fasta_filename : str the fasta file containing all the sequences of the biom table Returns ------- tmp_files : list of str The temp files created during ...
Remove artifacts from FASTA file using SortMeRNA. Parameters ---------- seqs_fp: string file path to FASTA input sequence file ref_fp: tuple file path(s) to FASTA database file working_dir: string working directory path ref_db_fp: tuple file path(s) to indexed FA...
Perform multiple sequence alignment on FASTA file using MAFFT. Parameters ---------- seqs_fp: string filepath to FASTA file for multiple sequence alignment threads: integer, optional number of threads to use. 0 to use all threads Returns ------- msa_fp : str name of...
Remove chimeras de novo using UCHIME (VSEARCH implementation). Parameters ---------- seqs_fp: string file path to FASTA input sequence file output_fp: string file path to store chimera-free results threads : int number of threads (0 for all cores) Returns ------- ...
Split FASTA file on sample IDs. Parameters ---------- seqs: file handler file handler to demultiplexed FASTA file outdir: string dirpath to output split FASTA files def split_sequence_file_on_sample_ids_to_files(seqs, outdir): """Split...
Write BIOM table to file. Parameters ---------- table: biom.table an instance of a BIOM table biom_fp: string filepath to output BIOM table def write_biom_table(table, biom_fp): """Write BIOM table to file. Parameters ---------- table: biom.table an instance of...
Get a list of files to add to the output table Parameters: ----------- input_dir : string name of the directory containing the deblurred fasta files file_end : string the ending of all the fasta files to be added to the table (default '.fasta.trim.derep.no_artifacts.msa.deblur.n...
Create a biom table out of all files in a directory Parameters ---------- output_fp : string filepath to output BIOM table deblurred_list : list of (str, str) list of file names (including path), sampleid of all deblurred fasta files to add to the table outputfasta_fp : str,...
Launch full deblur workflow for a single post split-libraries fasta file Parameters ---------- seqs_fp: string a post split library fasta file for debluring working_dir: string working directory path mean_error: float mean error for original sequence estimate error_dist:...
start the logger for the run Parameters ---------- level : int, optional logging.DEBUG, logging.INFO etc. for the log level (between 0-50). filename : str, optional name of the filename to save the log to or None (default) to use deblur.log.TIMESTAMP def start_log(level=logging.DEB...
Execute the command `cmd` Parameters ---------- cmd : str The string containing the command to be run. stdoutfilename : str Name of the file to save stdout to or None (default) to not save to file stderrfilename : str Name of the file to save stderr to or None ...
Returns a list of Sequences Parameters ---------- input_seqs : iterable of (str, str) The list of input sequences in (label, sequence) format Returns ------- list of Sequence Raises ------ ValueError If no sequences where found in `input_seqs` If all the se...
Deblur the reads Parameters ---------- input_seqs : iterable of (str, str) The list of input sequences in (label, sequence) format. The label should include the sequence count in the 'size=X' format. mean_error : float, optional The mean illumina error, used for original sequenc...
Returns a string with the sequence in fasta format Returns ------- str The FASTA representation of the sequence def to_fasta(self): """Returns a string with the sequence in fasta format Returns ------- str The FASTA representation of the...
Render options for select2. def render_select2_options_code(self, options, id_): """Render options for select2.""" output = [] for key, value in options.items(): if isinstance(value, (dict, list)): value = json.dumps(value) output.append("data-{name}='{va...
Render html container for Select2 widget with options. def render_js_code(self, id_, *args, **kwargs): """Render html container for Select2 widget with options.""" if id_: options = self.render_select2_options_code( dict(self.get_options()), id_) return mark_...
Extend base class's `render` method by appending javascript inline text to html output. def render(self, name, value, attrs=None, **kwargs): """ Extend base class's `render` method by appending javascript inline text to html output. """ output = super(Select2Mixin, self)...
Generate HTML for the console directive. def visit_console_html(self, node): """Generate HTML for the console directive.""" if self.builder.name in ('djangohtml', 'json') and node['win_console_text']: # Put a mark on the document object signaling the fact the directive # has been used on it. ...
Return `Meta` class with Select2-enabled widgets for fields with choices (e.g. ForeignKey, CharField, etc) for use with ModelForm. Arguments: model - a model class to create `Meta` class for. meta_fields - dictionary with `Meta` class fields, for example, {'fields': ['id', 'nam...
Return ModelForm class for model with select2 widgets. Arguments: attrs: select2 widget attributes (width, for example) of type `dict`. form_class: modelform base class, `forms.ModelForm` by default. :: SomeModelForm = select2_modelform(models.SomeModelBanner) is the same like:: ...
Yield (token_type, str_data) tokens. The last token will be (EOF, None) where EOF is the singleton object defined in this module. def lex(self, text): """ Yield (token_type, str_data) tokens. The last token will be (EOF, None) where EOF is the singleton object defined in this ...
Parse a string of SVG transform="" data. def parse(self, text): """ Parse a string of SVG transform="" data. """ gen = self.lexer.lex(text) next_val_fn = partial(next, *(gen,)) commands = [] token = next_val_fn() while token[0] is not EOF: command, t...
Parse a string of SVG <path> data. def parse(self, text): """ Parse a string of SVG <path> data. """ gen = self.lexer.lex(text) next_val_fn = partial(next, *(gen,)) token = next_val_fn() return self.rule_svg_path(next_val_fn, token)
Returns all elements with id attributes def findElementsWithId(node, elems=None): """ Returns all elements with id attributes """ if elems is None: elems = {} id = node.getAttribute('id') if id != '': elems[id] = node if node.hasChildNodes(): for child in node.childN...
Returns IDs of all referenced elements - node is the node at which to start the search. - returns a map which has the id as key and each value is is a list of nodes Currently looks at 'xlink:href' and all attributes in 'referencingProps' def findReferencedElements(node, ids=None): """ Return...
Removes all unreferenced elements except for <svg>, <font>, <metadata>, <title>, and <desc>. Also vacuums the defs of any non-referenced renderable elements. Returns the number of unreferenced elements removed from the document. def removeUnreferencedElements(doc, keepDefs): """ Removes all unreferenc...
Shortens ID names used in the document. ID names referenced the most often are assigned the shortest ID names. If the list unprotectedElements is provided, only IDs from this list will be shortened. Returns the number of bytes saved by shortening ID names in the document. def shortenIDs(doc, prefix, unpro...
Returns the ID name for the given ID number, spreadsheet-style, i.e. from a to z, then from aa to az, ba to bz, etc., until zz. def intToID(idnum, prefix): """ Returns the ID name for the given ID number, spreadsheet-style, i.e. from a to z, then from aa to az, ba to bz, etc., until zz. """ rid...
Changes the ID name from idFrom to idTo, on the declaring element as well as all references in the document doc. Updates identifiedElements and referencedIDs. Does not handle the case where idTo is already the ID name of another element in doc. Returns the number of bytes saved by this replacement...
u"""Returns a list of unprotected IDs within the document doc. def unprotected_ids(doc, options): u"""Returns a list of unprotected IDs within the document doc.""" identifiedElements = findElementsWithId(doc.documentElement) if not (options.protect_ids_noninkscape or options.protect_ids_list or...