backshift_file_mod module

An abstract representation of a file of various kinds, including directories.

Used as a bridge between stat-data and the repo, or the repo and tar output.

class backshift_file_mod.Backshift_file(repo, file_, filename, verbose=False)[source]

Bases: object

An abstract representation of a file of various kinds, including directories.

Used as a bridge between stat-data and the repo, or the repo and tar output.

as_string()[source]

Format this file’s metadata as a string for storage in some sort of database.

get_groupname()[source]

If the group exists, return the group - otherwise return gid.

get_real_length()[source]

Compute the real length of the file (as opposed to what’s in st_size, by adding up the hash keys’ lengths.

get_username()[source]

If the user exists, return the username - otherwise return uid.

init_from_lstat_result(lstat_result, can_do_device_files=True)[source]

Save a file in the repository.

init_from_string(file_)[source]

Construct (initialize, really) a Backshift file from the file like object we get from reading a file’s metadata.

init_string_set_type()[source]

Just set the type - for when constructing from init_from_string.

kind_dict = {b'block_device': 'b', b'character_device': 'c', b'directory': 'd', b'fifo': 'p', b'hardlink': 'h', b'regular_file': '-', b'symlink': 'l'}
max_digits = 1
process_from_lstat(lstat_result)[source]

Deal with the metadata fields.

tail_special(list_, derived_type, prior_filename)[source]

Deal with some special cases near the end of a tvf line.

to_tar_tf()[source]

Generate a “tar tf”-like description of this file - That is, just list the filename.

to_tar_tvf(hardlink_data)[source]

Generate a “tar tvf”-like description of this file.

exception backshift_file_mod.Benign_skipped[source]

Bases: backshift_file_mod.Skipped

An exception to raise when we we skip something unimportant, like a unix domain socket.

exception backshift_file_mod.Problematic_skipped[source]

Bases: backshift_file_mod.Skipped

An exception to raise when we we skip something we know is important.

exception backshift_file_mod.Skipped[source]

Bases: Exception

An exception to raise when we are passed a file of an invalid (unknown) type, including unix domain sockets.

exception backshift_file_mod.Unknown_skipped[source]

Bases: backshift_file_mod.Skipped

An exception to raise when we skip something that could conceivably be important - IOW, an unknown file type.

backshift_file_mod.get_can_do_device_files()[source]

Return True iff it looks like the Python interpreter has the necessary support to backup device files.

backshift_file_mod.make_used(var)[source]

Persuade linters that var is ‘used’.

backshift_file_mod.perms_string(bits, weird_x=None)[source]

Convert a 3 bit quantity to a more human-readable description - EG, ‘rwx’.

backshift_file_mod.weird_bit(mode, bit, character)[source]

Deal with sticky, setgid and setuid bits.