b.t.p.PathFilteringTransport(Transport) : class documentation

Part of bzrlib.transport.pathfilter View In Hierarchy

Known subclasses: bzrlib.transport.chroot.ChrootTransport

A PathFilteringTransport.

Please see PathFilteringServer for details.

Method __init__ Undocumented
Method abspath Return the full url to the given relative path.
Method append_file Append bytes from a file-like object to a file at relpath.
Method clone Return a new Transport object, cloned from the current location,
Method delete Delete the item at relpath
Method delete_tree Delete an entire tree. This may require a listable transport.
Method external_url See bzrlib.transport.Transport.external_url.
Method get Get the file at the given relative path.
Method has Does the file relpath exist?
Method is_readonly Return true if this connection cannot be written to.
Method iter_files_recursive Iter the relative paths of files in the transports sub-tree.
Method listable Return True if this store supports listing.
Method list_dir Return a list of all files at the given location.
Method lock_read Lock the given file for shared (read) access.
Method lock_write Lock the given file for exclusive (write) access.
Method mkdir Create a directory at the given path.
Method open_write_stream Open a writable file stream at relpath.
Method put_file Copy the file-like object into the location.
Method rename Rename a file or directory.
Method rmdir Remove a directory at the given path.
Method stat Return the stat information for a file.
Method _relpath_from_server_root Undocumented
Method _filter Undocumented
Method _call Helper for Transport methods of the form:
Method _can_roundtrip_unix_modebits Return true if this transport can store and retrieve unix modebits.

Inherited from Transport:

Method create_prefix Create all the directories leading down to self.base.
Method ensure_base Ensure that the directory this transport references exists.
Method get_segment_parameters Return the segment parameters for the top segment of the URL.
Method recommended_page_size Return the recommended page size for this transport.
Method relpath Return the local path portion from a given absolute path.
Method local_abspath Return the absolute path on the local filesystem.
Method has_multi Return True/False for each entry in relpaths
Method has_any Return True if any of the paths exist.
Method get_bytes Get a raw string of the bytes for a file at the given location.
Method get_smart_medium Return a smart client medium for this transport if possible.
Method readv Get parts of the file at the given relative path.
Method get_multi Get a list of file-like objects, one for each entry in relpaths.
Method put_bytes Atomically put the supplied bytes into the given location.
Method put_bytes_non_atomic Copy the string into the target location.
Method put_file_non_atomic Copy the file-like object into the target location.
Method mkdir_multi Create a group of directories
Method append_bytes Append bytes to a file at relpath.
Method append_multi Append the text in each file-like or string object to
Method copy Copy the item at rel_from to the location at rel_to.
Method copy_multi Copy a bunch of entries.
Method copy_to Copy a set of entries from self into another Transport.
Method copy_tree Copy a subtree from one relpath to another.
Method copy_tree_to_transport Copy a subtree from one transport to another.
Method move Move the item at rel_from to the location at rel_to.
Method move_multi Move a bunch of entries.
Method move_multi_to Move a bunch of entries to a single location.
Method delete_multi Queue up a bunch of deletes to be done.
Method __repr__ Undocumented
Method stat_multi Stat multiple files and return the information.
Method readlink Return a string representing the path to which the symbolic link points.
Method hardlink Create a hardlink pointing to source named link_name.
Method symlink Create a symlink pointing to source named link_name.
Method disconnect Undocumented
Method _translate_error Translate an IOError or OSError into an appropriate bzr error.
Method _pump Most children will need to copy from one file-like
Method _get_total Try to figure out how many entries are in multi,
Method _report_activity Notify that this transport has activity.
Method _update_pb Update the progress bar based on the current count
Method _iterate_over Iterate over all entries in multi, passing them to func,
Method _readv Get parts of the file at the given relative path.
Method _seek_and_read An implementation of readv that uses fp.seek and fp.read.
Method _sort_expand_and_combine Helper for readv.
Static Method _coalesce_offsets Yield coalesced offsets.
Method _reuse_for Undocumented
Method _redirected_to Returns a transport suitable to re-issue a redirected request.
def __init__(self, server, base):
Undocumented
def _relpath_from_server_root(self, relpath):
Undocumented
def _filter(self, relpath):
Undocumented
def _call(self, methodname, relpath, *args):
Helper for Transport methods of the form: operation(path, [other args ...])
def abspath(self, relpath):
Return the full url to the given relative path.
Parametersrelpatha string of a relative path
def append_file(self, relpath, f, mode=None):
Append bytes from a file-like object to a file at relpath.

The file is created if it does not already exist.

Parametersfa file-like object of the bytes to append.
modeUnix mode for newly created files. This is not used for existing files.
Returnsthe length of relpath before the content was written to it.
def _can_roundtrip_unix_modebits(self):
Return true if this transport can store and retrieve unix modebits.

(For example, 0700 to make a directory owner-private.)

Note: most callers will not want to switch on this, but should rather just try and set permissions and let them be either stored or not. This is intended mainly for the use of the test suite.

Warning: this is not guaranteed to be accurate as sometimes we can't be sure: for example with vfat mounted on unix, or a windows sftp server.

def clone(self, relpath):
Return a new Transport object, cloned from the current location, using a subdirectory or parent directory. This allows connections to be pooled, rather than a new one needed for each subdir.
def delete(self, relpath):
Delete the item at relpath
def delete_tree(self, relpath):
Delete an entire tree. This may require a listable transport.
def external_url(self):
See bzrlib.transport.Transport.external_url.
def get(self, relpath):
Get the file at the given relative path.

This may fail in a number of ways:
  • HTTP servers may return content for a directory. (unexpected content failure)
  • FTP servers may indicate NoSuchFile for a directory.
  • SFTP servers may give a file handle for a directory that will fail on read().

For correct use of the interface, be sure to catch errors.PathError when calling it and catch errors.ReadError when reading from the returned object.

ParametersrelpathThe relative path to the file
Returns (type: File-like object.)
def has(self, relpath):
Does the file relpath exist?

Note that some transports MAY allow querying on directories, but this is not part of the protocol. In other words, the results of t.has("a_directory_name") are undefined.

Returns (type: bool)
def is_readonly(self):
Return true if this connection cannot be written to.
def iter_files_recursive(self):
Iter the relative paths of files in the transports sub-tree.

NOTE: This only lists files, not subdirectories!

As with other listing functions, only some transports implement this,. you may check via listable() to determine if it will.

def listable(self):
Return True if this store supports listing.
def list_dir(self, relpath):
Return a list of all files at the given location. WARNING: many transports do not support this, so trying avoid using it if at all possible.
def lock_read(self, relpath):
Lock the given file for shared (read) access.

WARNING: many transports do not support this, so trying avoid using it. These methods may be removed in the future.

Transports may raise TransportNotPossible if OS-level locks cannot be taken over this transport.

ReturnsA lock object, which should contain an unlock() function.
def lock_write(self, relpath):
Lock the given file for exclusive (write) access.

WARNING: many transports do not support this, so trying avoid using it. These methods may be removed in the future.

Transports may raise TransportNotPossible if OS-level locks cannot be taken over this transport.

ReturnsA lock object, which should contain an unlock() function.
def mkdir(self, relpath, mode=None):
Create a directory at the given path.
def open_write_stream(self, relpath, mode=None):
Open a writable file stream at relpath.

A file stream is a file like object with a write() method that accepts bytes to write.. Buffering may occur internally until the stream is closed with stream.close(). Calls to readv or the get_* methods will be synchronised with any internal buffering that may be present.

ParametersrelpathThe relative path to the file.
modeThe mode for the newly created file, None means just use the default
ReturnsA FileStream. FileStream objects have two methods, write() and close(). There is no guarantee that data is committed to the file if close() has not been called (even if get() is called on the same path).
def put_file(self, relpath, f, mode=None):
Copy the file-like object into the location.
ParametersrelpathLocation to put the contents, relative to base.
fFile-like object.
modeThe mode for the newly created file, None means just use the default.
ReturnsThe length of the file that was written.
def rename(self, rel_from, rel_to):
Rename a file or directory.

This must fail if the destination is a nonempty directory - it must not automatically remove it. It should raise DirectoryNotEmpty, or some other PathError if the case can't be specifically detected.

If the destination is an empty directory or a file this function may either fail or succeed, depending on the underlying transport. It should not attempt to remove the destination if overwriting is not the native transport behaviour. If at all possible the transport should ensure that the rename either completes or not, without leaving the destination deleted and the new file not moved in place.

This is intended mainly for use in implementing LockDir.

def rmdir(self, relpath):
Remove a directory at the given path.
def stat(self, relpath):
Return the stat information for a file. WARNING: This may not be implementable for all protocols, so use sparingly. NOTE: This returns an object with fields such as 'st_size'. It MAY or MAY NOT return the literal result of an os.stat() call, so all access should be via named fields. ALSO NOTE: Stats of directories may not be supported on some transports.
API Documentation for Bazaar, generated by pydoctor at 2019-10-19 00:33:24.