duplicity.path module
Wrapper class around a file like “/usr/bin/env”
This class makes certain file operations more convenient and
associates stat information with filenames
-
class
duplicity.path.
DupPath
(base, index=(), parseresults=None)[source]
Bases: duplicity.path.Path
Represent duplicity data files
Based on the file name, files that are compressed or encrypted
will have different open() methods.
-
filtered_open
(mode='rb', gpg_profile=None)[source]
Return fileobj with appropriate encryption/compression
If encryption is specified but no gpg_profile, use
globals.default_profile.
-
class
duplicity.path.
Path
(base, index=())[source]
Bases: duplicity.path.ROPath
Path class - wrapper around ordinary local files
Besides caching stat() results, this class organizes various file
code.
-
append
(ext)[source]
Return new Path with ext added to index
-
chmod
(mode)[source]
Change permissions of the path
-
compare_recursive
(other, verbose=None)[source]
Compare self to other Path, descending down directories
-
delete
()[source]
Remove this file
-
deltree
()[source]
Remove self by recursively deleting files under it
-
get_canonical
()[source]
Return string of canonical version of path
Remove ”.”, and trailing slashes where possible. Note that
it’s harder to remove ”..”, as “foo/bar/..” is not necessarily
“foo”, so we can’t use path.normpath()
-
get_filename
()[source]
Return filename of last component
-
get_parent_dir
()[source]
Return directory that self is in
-
get_temp_in_same_dir
()[source]
Return temp non existent path in same directory as self
-
isemptydir
()[source]
Return true if path is a directory and is empty
-
listdir
()[source]
Return list generated by os.listdir
-
makedev
(type, major, minor)[source]
Make a device file with specified type, major/minor nums
-
mkdir
()[source]
Make directory(s) at specified path
-
move
(new_path)[source]
Like rename but destination may be on different file system
-
new_index
(index)[source]
Return new Path with index index
-
open
(mode='rb')[source]
Return fileobj associated with self
Usually this is just the file data on disk, but can be
replaced with arbitrary data using the setfileobj method.
-
patch_with_attribs
(diff_ropath)[source]
Patch self with diff and then copy attributes over
-
quote
(s=None)[source]
Return quoted version of s (defaults to self.name)
The output is meant to be interpreted with shells, so can be
used with os.system.
-
regex_chars_to_quote
= <_sre.SRE_Pattern object>
-
rename
(new_path)[source]
Rename file at current path to new_path.
-
rename_index
(index)[source]
-
setdata
()[source]
Refresh stat cache
-
touch
()[source]
Open the file, write 0 bytes, close
-
unquote
(s)[source]
Return unquoted version of string s, as quoted by above quote()
-
writefileobj
(fin)[source]
Copy file object fin to self. Close both when done.
-
class
duplicity.path.
PathDeleter
[source]
Bases: duplicity.lazy.ITRBranch
Delete a directory. Called by Path.deltree
-
can_fast_process
(index, path)[source]
-
end_process
()[source]
-
fast_process
(index, path)[source]
-
start_process
(index, path)[source]
-
exception
duplicity.path.
PathException
[source]
Bases: exceptions.Exception
-
class
duplicity.path.
ROPath
(index, stat=None)[source]
Read only Path
Objects of this class doesn’t represent real files, so they don’t
have a name. They are required to be indexed though.
-
blank
()[source]
Black out self - set type and stat to None
-
compare_data
(other)[source]
Compare data from two regular files, return true if same
-
compare_verbose
(other, include_data=0)[source]
Compare ROPaths like __eq__, but log reason if different
This is placed in a separate function from __eq__ because
__eq__ should be very time sensitive, and logging statements
would slow it down. Used when verifying.
Only run if include_data is true.
-
copy
(other)[source]
Copy self to other. Also copies data. Other must be Path
-
copy_attribs
(other)[source]
Only copy attributes from self to other
-
exists
()[source]
True if corresponding file exists
-
get_data
()[source]
Return contents of associated fileobj in string
-
get_relative_path
()[source]
Return relative path, created from index
-
get_ropath
()[source]
Return ropath copy of self
-
get_tarinfo
()[source]
Generate a tarfile.TarInfo object based on self
Doesn’t set size based on stat, because we may want to replace
data wiht other stream. Size should be set separately by
calling function.
-
getdevloc
()[source]
Return device number path resides on
-
getmtime
()[source]
Return mod time of path in seconds
-
getperms
()[source]
Return permissions mode, owner and group
-
getsize
()[source]
Return length in bytes from stat object
-
init_from_tarinfo
(tarinfo)[source]
Set data from tarinfo object (part of tarfile module)
-
isdev
()[source]
True is self is a device file
-
isdir
()[source]
True if self is dir
-
isfifo
()[source]
True if self is fifo
-
isreg
()[source]
True if self corresponds to regular file
-
issock
()[source]
True is self is socket
-
issym
()[source]
True if self is sym
-
open
(mode)[source]
Return fileobj associated with self
-
perms_equal
(other)[source]
True if self and other have same permissions and ownership
-
set_from_stat
()[source]
Set the value of self.type, self.mode from self.stat
-
setfileobj
(fileobj)[source]
Set file object returned by open()
-
class
duplicity.path.
StatResult
[source]
Used to emulate the output of os.stat() and related
-
st_mode
= 0