metadata_mod module

Describes and converts various metadata and metadata representations.

class metadata_mod.File_attributes[source]

Bases: object

Contains the various metadata attributes a file might have - as class variables.

cmc

alias of constants_mod.Constants

dict_ = {b'block_device': <metadata_mod.Metadata object>, b'block_major': <metadata_mod.Metadata object>, b'block_minor': <metadata_mod.Metadata object>, b'character_device': <metadata_mod.Metadata object>, b'character_major': <metadata_mod.Metadata object>, b'character_minor': <metadata_mod.Metadata object>, b'directory': <metadata_mod.Metadata object>, b'fifo': <metadata_mod.Metadata object>, b'group': <metadata_mod.Metadata object>, b'hash': <metadata_mod.Metadata object>, b'link_target': <metadata_mod.Metadata object>, b'owner': <metadata_mod.Metadata object>, b'regular_file': <metadata_mod.Metadata object>, b'st_atime': <metadata_mod.Metadata object>, b'st_ctime': <metadata_mod.Metadata object>, b'st_dev': <metadata_mod.Metadata object>, b'st_gid': <metadata_mod.Metadata object>, b'st_ino': <metadata_mod.Metadata object>, b'st_mode': <metadata_mod.Metadata object>, b'st_mtime': <metadata_mod.Metadata object>, b'st_size': <metadata_mod.Metadata object>, b'st_uid': <metadata_mod.Metadata object>, b'symlink': <metadata_mod.Metadata object>}
class metadata_mod.File_types[source]

Bases: object

Just hold the different file types, their metadata fields, and how to convert each type of attribute.

cmc

alias of constants_mod.Constants

dict_ = {b'block_device': [<metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>], b'character_device': [<metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>], b'directory': [<metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>], b'fifo': [<metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>], b'regular_file': [<metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>], b'symlink': [<metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>, <metadata_mod.Metadata object>]}
class metadata_mod.Metadata(field, get_from_stat, get_from_fields)[source]

Bases: object

Contains one metadata attribute of a file.

metadata_mod.always_true(filename, stat_buf, field)[source]

Just always return True, for things that are single-field like directory or regular_file.

metadata_mod.get_bool_from_fields(fields)[source]

Extract a boolean from a list of fields.

metadata_mod.get_escaped_string_from_fields(fields)[source]

Extract a string field from a repo line.

metadata_mod.get_field_on_stat(filename, stat_buf, field)[source]

Just pull out a field - not much to do with types here, because stat returns things reasonably to begin with.

metadata_mod.get_float_from_fields(fields)[source]

Extract a floating point field from a repo line.

metadata_mod.get_group_on_stat(filename, stat_buf, field)[source]

Look up the group name (not just the gid) - if none, return #gid.

metadata_mod.get_hashes_from_fields(fields)[source]

Get the hashes from a fields line - actually, we get the hashes and the lengths of the chunks they’re hashes of.

metadata_mod.get_int_from_fields(fields)[source]

Extract an integer field from a repo line.

Return the link target of the file in question, encoded in base64 so we needn’t worry about whitespace issues.

metadata_mod.get_major_on_stat(filename, stat_buf, field)[source]

Get the major device number for a device.

metadata_mod.get_minor_on_stat(filename, stat_buf, field)[source]

Get the minor device number for a device.

metadata_mod.get_owner_on_stat(filename, stat_buf, field)[source]

Look up the username (not just the uid) - if none, return #uid.

metadata_mod.get_st_rdev(stat_buf)[source]

Extract st_rdev (st_dev doesn’t count) from an os.stat return.

metadata_mod.get_string_from_fields(fields)[source]

Extract a string field from a repo line.

metadata_mod.init_hashes_on_stat(filename, stat_buf, field)[source]

Just give an initial empty list for the hashes - we’ll handle them separately/specially.

metadata_mod.undefined(stat_buf, field)[source]

Extract an undefined field from a stat - used for derived fields.