A dictionary with error handling and an id string.
Record is the base class of the all objects in metaknowledge that contain information as key-value pairs, these are the grants and the records from different sources.
The error handling of the
Record is done with the
bad attribute. If there is some issue with the data bad should be
True and error given an
Exception that was caused by or explains the error.
Record is a subclass of
abc.collections.Mapping which means it has almost all the methods a dictionary does, the missing ones are those that modify entries. So to access the value of the key
'title' from a
R, you would use either the square brace notation
t = R['title'] or the
t = R.get('title') just like a dictionary. The other methods like
copy() also work.
In addition to being a mapping
Records are also hashable with their hashes being based on a unique id string they are given on creation, usually some kind of accession number the source gives them. The two optional arguments sFile and sLine, which should be given the name of the file the records came from and the line it started on respectively, are used to make the errors more useful.
fieldDict is the dictionary the
Record will use and idValue is the unique identifier of the
A dictionary that maps from strings to values
A unique identifier string for the
True if there are issues with the
Exception that caused whatever error made the record be marked as bad or
A string that gives the source file of the original records
The first line the original record is found on in the source file
The Record class has the following methods:
Records using their hashes if their hashes are the same then
True is returned.
Record to be compared against
records are the same then
True is returned
Makes a string with the title of the file as given by self.title, if there is not one it returns “Untitled record”
The title of the
Makes a string with the id of the file and its type
The representation of the
Correctly copies the
A completely decoupled copy of the original
Gives a hash of the id or if
bad returns a hash of the fields combined with the error messages, either of these could be blank
bad Records are more likely to cause hash collisions due to their lack of entropy when created.
A hopefully unique random number
If you find bugs, or have questions, please write to:
Reid McIlroy-Young email@example.com
John McLevey firstname.lastname@example.org
metaknowledge is free and open source software, distributed under the GPL License.