xmlcoll package
A package of python routines to work with collections of items in XML format.
xmlcoll.base module
Module providing base property functions.
- class xmlcoll.base.Properties[source]
Bases:
objectA class for storing and retrieving properties.
- get_properties()[source]
Method to retrieve the properties.
- Returns:
dict: The dictionary of current properties.
- update_properties(properties)[source]
Method to update the properties.
- Args:
properties(dict): A dictionary of properties. New properties are added. Old properties are updated. The keys for the dictionary entries are name and up to five optional tags labeled tag1, tag2, …, tag5.- Returns:
On successful return, the properties have been updated.
xmlcoll.coll module
Module for XML collections of items.
- class xmlcoll.coll.Collection(items=None)[source]
Bases:
PropertiesA class for storing and retrieving data about data items.
- Args:
items(list, optional): A list of individualxmlcoll.coll.Itemobjects.
- add_item(item)[source]
Method to add a item to a collection.
- Args:
item(xmlcoll.coll.Item) The item to be added.- Return:
On successful return, the item has been added.
- get()[source]
Method to retrieve the item collection as a dictionary.
- Returns:
dict: A dictionary of the items.
- get_dataframe(index_label='name', tag_delimiter='_')[source]
Method to retrieve the collection data as a pandas dataframe.
- Args:
index_label(str, optional): Index label for the dataframe.tag_delimiter(str, optional): Delimiter used to separate tags in combined column names.- Returns:
pandas.DataFrame: A pandas dataframe containing the collection data. Columns are labeled by a string formed by concatenating property names and tags separated by the chosen delimiter.
- remove_item(item)[source]
Method to remove an item from a item collection.
- Args:
item(xmlcoll.coll.Item) The item to be removed.- Return:
On successful return, the item has been removed.
- update_from_dataframe(data_frame, index_label='name', tag_delimiter='_')[source]
Method to update collection data from a pandas dataframe.
- Args:
data_frame(pandas.DataFrame): The pandas dataframe.index_label(str, optional): Index label for the data frame.tag_delimiter(str, optional): Delimiter used to separate tags in combined column names.- Returns:
On successful return, the collection has been updated with the data in the data frame.
- update_item_name(old_name, new_name)[source]
Method to update the name of an item in a collection. This method is necessary (as compared to simply popping the item into a new entry) because the item carries its own name, which must be updated also.
- validate(file)[source]
Method to validate a collection XML file.
- Args:
file(str) The name of the XML file to validate.- Returns:
An error message if invalid and nothing if valid.