tethne.utilities package¶
Module contents¶
Helper functions.
- tethne.utilities.attribs_to_string(attrib_dict, keys)[source]¶
A more specific version of the subdict utility aimed at handling node and edge attribute dictionaries for NetworkX file formats such as gexf (which does not allow attributes to have a list type) by making them writable in those formats
- tethne.utilities.concat_list(listA, listB, delim=' ')[source]¶
Concatenate list elements pair-wise with the delim character Returns the concatenated list Raises index error if lists are not parallel
- tethne.utilities.contains(l, f)[source]¶
Searches list l for a pattern specified in a lambda function f.
- tethne.utilities.dict_from_node(node, recursive=False)[source]¶
Converts ElementTree node to a dictionary.
Parameters: node : ElementTree node
recursive : boolean
If recursive=False, the value of any field with children will be the number of children.
Returns: dict : nested dictionary.
Tags as keys and values as values. Sub-elements that occur multiple times in an element are contained in a list.
- tethne.utilities.strip_non_ascii(s)[source]¶
Returns the string without non-ASCII characters.
Parameters: string : string
A string that may contain non-ASCII characters.
Returns: clean_string : string
A string that does not contain non-ASCII characters.