eric7.RemoteServerInterface.EricServerFileSystemInterface
Module implementing the file system interface to the eric-ide server.
Global Attributes
Classes
Functions
EricServerFileSystemInterface
Class implementing the file system interface to the eric-ide server.
Derived from
QObject
Class Attributes
NotConnectedMessage |
_MagicCheck |
Class Methods
Methods
EricServerFileSystemInterface |
Constructor |
__connectionStateChanged |
Private slot handling a change of the server connection state. |
__getPathSep |
Private method to get the path separator of the connected server. |
__hasMagic |
Private method to check, if a given path contains glob style magic characters. |
abspath |
Public method to convert the given path to an absolute path. |
access |
Public method to test the given access rights to a file or directory. |
basename |
Public method to extract the final component of a path name. |
callback |
Function to handle the server reply |
chdir |
Public method to change the current working directory of the eric-ide server. |
compactPath |
Public method to return a compacted path fitting inside the given width. |
direntries |
Public method to get a list of all files and directories of a given directory. |
dirname |
Public method to extract the directory component of a path name. |
exists |
Public method the existence of a file or directory. |
expanduser |
Public method to expand an initial '~' or '~user' component. |
fromNativeSeparators |
Public method to convert a path using server native separator characters to use "/" separator characters. |
getcwd |
Public method to get the current working directory of the eric-ide server. |
glob |
Public method to get a list of of all files matching a given pattern like 'glob.glob()'. |
isabs |
Public method to chack a path for being an absolute path. |
isdir |
Public method to check, if the given name is a directory. |
isfile |
Public method to check, if the given name is a regular file. |
join |
Public method to join two or more path name components using the path separator of the server side. |
listdir |
Public method to get a directory listing. |
makedirs |
Public method to create a new directory on the eric-ide serverincluding all intermediate-level directories. |
mkdir |
Public method to create a new directory on the eric-ide server. |
populateFsCache |
Public method to populate the remote file system cache for a given directory. |
readEncodedFile |
Public method to read a file and decode its contents into proper text. |
readEncodedFileWithEncoding |
Public method to read a file and decode its contents into proper text. |
readFile |
Public method to read a file from the eric-ide server. |
remove |
Public method to delete a file on the eric-ide server. |
removeFromFsCache |
Public method to remove a given directory from the remote file system cache. |
replace |
Public method to rename a file or directory. |
rmdir |
Public method to delete a directory on the eric-ide server. |
separator |
Public method to return the server side path separator string. |
shutilCopy |
Public method to copy a source file to a given destination file or directory. |
shutilRmtree |
Public method to delete an entire directory tree. |
split |
Public method to split a path name. |
splitdrive |
Public method to split a path into drive and path. |
splitext |
Public method to split a path name into a root part and an extension. |
stat |
Public method to get the status of a file. |
toNativeSeparators |
Public method to convert a path to use server native separator characters. |
writeEncodedFile |
Public method to write a file with properly encoded text. |
writeFile |
Public method to write the data to a file on the eric-ide server. |
Static Methods
EricServerFileSystemInterface (Constructor)
EricServerFileSystemInterface(serverInterface)
Constructor
- serverInterface (EricServerInterface)
-
reference to the eric-ide server interface
EricServerFileSystemInterface.__connectionStateChanged
__connectionStateChanged(connected)
Private slot handling a change of the server connection state.
- connected (bool)
-
flag indicating a connected state
EricServerFileSystemInterface.__getPathSep
__getPathSep()
Private method to get the path separator of the connected server.
- Return:
-
path separator character of the server
- Return Type:
-
str
EricServerFileSystemInterface.__hasMagic
__hasMagic(pathname)
Private method to check, if a given path contains glob style magic characters.
Note: This was taken from 'glob.glob'.
- pathname (str)
-
path name to be checked
- Return:
-
flag indicating the presence of magic characters
- Return Type:
-
bool
EricServerFileSystemInterface.abspath
abspath(p)
Public method to convert the given path to an absolute path.
- p (str)
-
path to be converted
- Return:
-
absolute path
- Return Type:
-
str
EricServerFileSystemInterface.access
access(name, modes)
Public method to test the given access rights to a file or directory.
The modes to check for are 'read', 'write' or 'execute' or any combination.
- name (str)
-
name of the file or directory
- modes (str or list of str)
-
list of modes to check for
- Return:
-
flag indicating the user has the asked for permissions
- Return Type:
-
bool
- Raises ValueError:
-
raised for an illegal modes list
EricServerFileSystemInterface.basename
basename(p)
Public method to extract the final component of a path name.
- p (str)
-
path name
- Return:
-
final component
- Return Type:
-
str
EricServerFileSystemInterface.callback
callback(params)
Function to handle the server reply
- reply (str)
-
name of the server reply
- params (dict)
-
dictionary containing the reply data
EricServerFileSystemInterface.chdir
chdir(directory)
Public method to change the current working directory of the eric-ide server.
- directory (str)
-
absolute path of the working directory to change to
- Return:
-
tuple containing an OK flag and an error string in case of an issue
- Return Type:
-
tuple of (bool, str)
EricServerFileSystemInterface.compactPath
compactPath(longPath, width, measure=len)
Public method to return a compacted path fitting inside the given width.
- longPath (str)
-
path to be compacted
- width (int)
-
width for the compacted path
- measure (function (optional))
-
reference to a function used to measure the length of the
string (defaults to len)
- Return:
-
compacted path
- Return Type:
-
str
EricServerFileSystemInterface.direntries
direntries(directory, filesonly=False, pattern=None, followsymlinks=True, ignore=None, recursive=True, dirsonly=False, )
Public method to get a list of all files and directories of a given directory.
- directory (str)
-
root of the tree to check
- filesonly (bool (optional))
-
flag indicating that only files are wanted (defaults to False)
- pattern (str or list of str (optional))
-
a filename pattern or list of filename patterns to check
against (defaults to None)
- followsymlinks (bool (optional))
-
flag indicating whether symbolic links should be
followed (defaults to True)
- ignore (list of str (optional))
-
list of entries to be ignored (defaults to None)
- recursive (bool (optional))
-
flag indicating a recursive search (defaults to True)
- dirsonly (bool)
-
flag indicating to return only directories. When True it has
precedence over the 'filesonly' parameter (defaults to False)
- Return:
-
list of all files and directories in the tree rooted at path.
The names are expanded to start with the given directory name.
- Return Type:
-
list of str
- Raises OSError:
-
raised in case the server reported an issue
EricServerFileSystemInterface.dirname
dirname(p)
Public method to extract the directory component of a path name.
- p (str)
-
path name
- Return:
-
directory component
- Return Type:
-
str
EricServerFileSystemInterface.exists
exists(name)
Public method the existence of a file or directory.
- name (str)
-
name of the file or directory
- Return:
-
flag indicating the file existence
- Return Type:
-
bool
EricServerFileSystemInterface.expanduser
expanduser(name)
Public method to expand an initial '~' or '~user' component.
- name (str)
-
path name to be expanded
- Return:
-
expanded path name
- Return Type:
-
str
EricServerFileSystemInterface.fromNativeSeparators
fromNativeSeparators(p)
Public method to convert a path using server native separator characters to
use "/" separator characters.
- p (str)
-
path name to be converted
- Return:
-
path name with converted separator characters
- Return Type:
-
str
EricServerFileSystemInterface.getcwd
getcwd()
Public method to get the current working directory of the eric-ide server.
- Return:
-
current working directory of the eric-ide server
- Return Type:
-
str
EricServerFileSystemInterface.glob
glob(pathname, recursive=False, includeHidden=False)
Public method to get a list of of all files matching a given pattern
like 'glob.glob()'.
- pathname (str)
-
path name pattern with simple shell-style wildcards
- recursive (bool (optional))
-
flag indicating a recursive list (defaults to False)
- includeHidden (bool (optional))
-
flag indicating to include hidden files (defaults to False)
- Return:
-
list of all files matching the pattern
- Return Type:
-
list of str
EricServerFileSystemInterface.isabs
isabs(p)
Public method to chack a path for being an absolute path.
- p (str)
-
path to be checked
- Return:
-
flag indicating an absolute path
- Return Type:
-
bool
EricServerFileSystemInterface.isdir
isdir(name)
Public method to check, if the given name is a directory.
- name (str)
-
name to be checked
- Return:
-
flag indicating a directory
- Return Type:
-
bool
EricServerFileSystemInterface.isfile
isfile(name)
Public method to check, if the given name is a regular file.
- name (str)
-
name to be checked
- Return:
-
flag indicating a regular file
- Return Type:
-
bool
EricServerFileSystemInterface.join
join(a, *p)
Public method to join two or more path name components using the path separator
of the server side.
- a (str)
-
first path component
- *p (list of str)
-
list of additional path components
- Return:
-
joined path name
- Return Type:
-
str
EricServerFileSystemInterface.listdir
listdir(directory="", recursive=False)
Public method to get a directory listing.
- directory (str (optional))
-
directory to be listed. An empty directory means to list
the eric-ide server current directory. (defaults to "")
- recursive (bool (optional))
-
flag indicating a recursive listing (defaults to False)
- Return:
-
tuple containing the listed directory, the path separator and the
directory listing. Each directory listing entry contains a dictionary
with the relevant data.
- Return Type:
-
tuple of (str, str, dict)
- Raises OSError:
-
raised in case the server reported an issue
EricServerFileSystemInterface.makedirs
makedirs(directory, exist_ok=False)
Public method to create a new directory on the eric-ide serverincluding all
intermediate-level directories.
- directory (str)
-
absolute path of the new directory
- exist_ok (bool (optional))
-
flag indicating that the existence of the directory is
acceptable (defaults to False)
- Return:
-
tuple containing an OK flag and an error string in case of an issue
- Return Type:
-
tuple of (bool, str)
EricServerFileSystemInterface.mkdir
mkdir(directory)
Public method to create a new directory on the eric-ide server.
- directory (str)
-
absolute path of the new directory
- Return:
-
tuple containing an OK flag and an error string in case of an issue
- Return Type:
-
tuple of (bool, str)
EricServerFileSystemInterface.populateFsCache
populateFsCache(directory)
Public method to populate the remote file system cache for a given directory.
- directory (str)
-
remote directory to be cached
- Raises ValueError:
-
raised to indicate an empty directory
EricServerFileSystemInterface.readEncodedFile
readEncodedFile(filename, create=False)
Public method to read a file and decode its contents into proper text.
- filename (str)
-
name of the file to read
- create (bool (optional))
-
flag indicating to create an empty file, if it does not exist
(defaults to False)
- Return:
-
tuple of decoded text and encoding
- Return Type:
-
tuple of (str, str)
EricServerFileSystemInterface.readEncodedFileWithEncoding
readEncodedFileWithEncoding(filename, encoding, create=False)
Public method to read a file and decode its contents into proper text.
- filename (str)
-
name of the file to read
- encoding (str)
-
encoding to be used to read the file
- create (bool (optional))
-
flag indicating to create an empty file, if it does not exist
(defaults to False)
- Return:
-
tuple of decoded text and encoding
- Return Type:
-
tuple of (str, str)
EricServerFileSystemInterface.readFile
readFile(filename, create=False, newline=None)
Public method to read a file from the eric-ide server.
- filename (str)
-
name of the file to read
- create (bool (optional))
-
flag indicating to create an empty file, if it does not exist
(defaults to False)
- newline (str (optional))
-
determines how to parse newline characters from the stream
(defaults to None)
- Return:
-
bytes data read from the eric-ide server
- Return Type:
-
bytes
- Raises EricServerNotConnectedError:
-
raised to indicate a missing server
connection
- Raises OSError:
-
raised in case the server reported an issue
EricServerFileSystemInterface.remove
remove(filename)
Public method to delete a file on the eric-ide server.
- filename (str)
-
absolute path of the file
- Return:
-
tuple containing an OK flag and an error string in case of an issue
- Return Type:
-
tuple of (bool, str)
EricServerFileSystemInterface.removeFromFsCache
removeFromFsCache(directory)
Public method to remove a given directory from the remote file system cache.
- directory (str)
-
remote directory to be removed
EricServerFileSystemInterface.replace
replace(oldName, newName)
Public method to rename a file or directory.
- oldName (str)
-
current name of the file or directory
- newName (str)
-
new name for the file or directory
- Return:
-
tuple containing an OK flag and an error string in case of an issue
- Return Type:
-
tuple of (bool, str)
EricServerFileSystemInterface.rmdir
rmdir(directory)
Public method to delete a directory on the eric-ide server.
- directory (str)
-
absolute path of the directory
- Return:
-
tuple containing an OK flag and an error string in case of an issue
- Return Type:
-
tuple of (bool, str)
EricServerFileSystemInterface.separator
separator()
Public method to return the server side path separator string.
- Return:
-
path separator
- Return Type:
-
str
EricServerFileSystemInterface.shutilCopy
shutilCopy(srcName, dstName)
Public method to copy a source file to a given destination file or directory.
- srcName (str)
-
name of the source file
- dstName (str)
-
name of the destination file or directory
- Return:
-
name of the destination file
- Return Type:
-
str
- Raises EricServerNotConnectedError:
-
raised to indicate a missing server
connection
- Raises OSError:
-
raised to indicate an issue
EricServerFileSystemInterface.shutilRmtree
shutilRmtree(pathname, ignore_errors=False)
Public method to delete an entire directory tree.
- pathname (str)
-
name of the directory to be deleted
- ignore_errors (bool (optional))
-
flag indicating to ignore error resulting from failed
removals (defaults to False)
- Raises EricServerNotConnectedError:
-
raised to indicate a missing server
connection
- Raises OSError:
-
raised to indicate an issue
EricServerFileSystemInterface.split
split(p)
Public method to split a path name.
- p (str)
-
path name to be split
- Return:
-
tuple containing head and tail, where tail is everything after the last
path separator.
- Return Type:
-
tuple of (str, str)
EricServerFileSystemInterface.splitdrive
splitdrive(p)
Public method to split a path into drive and path.
- p (str)
-
path name to be split
- Return:
-
tuple containing the drive letter (incl. colon) and the path
- Return Type:
-
tuple of (str, str)
EricServerFileSystemInterface.splitext
splitext(p)
Public method to split a path name into a root part and an extension.
- p (str)
-
path name to be split
- Return:
-
tuple containing the root part and the extension
- Return Type:
-
tuple of (str, str)
EricServerFileSystemInterface.stat
stat(filename, stNames)
Public method to get the status of a file.
- filename (str)
-
name of the file
- stNames (list of str)
-
list of 'stat_result' members to retrieve
- Return:
-
dictionary containing the requested status data
- Return Type:
-
dict
- Raises OSError:
-
raised in case the server reported an issue
EricServerFileSystemInterface.toNativeSeparators
toNativeSeparators(p)
Public method to convert a path to use server native separator characters.
- p (str)
-
path name to be converted
- Return:
-
path name with converted separator characters
- Return Type:
-
str
EricServerFileSystemInterface.writeEncodedFile
writeEncodedFile(filename, text, origEncoding, forcedEncoding="", withBackup=False)
Public method to write a file with properly encoded text.
- filename (str)
-
name of the file to read
- text (str)
-
text to be written
- origEncoding (str)
-
type of the original encoding
- forcedEncoding (str (optional))
-
encoding to be used for writing, if no coding
line is present (defaults to "")
- withBackup (bool (optional))
-
flag indicating to create a backup file first
(defaults to False)
- Return:
-
encoding used for writing the file
- Return Type:
-
str
EricServerFileSystemInterface.writeFile
writeFile(filename, data, withBackup=False, newline=None)
Public method to write the data to a file on the eric-ide server.
- filename (str)
-
name of the file to write
- data (bytes or QByteArray)
-
data to be written
- withBackup (bool (optional))
-
flag indicating to create a backup file first
(defaults to False)
- newline (str (optional))
-
determines how to parse newline characters from the stream
(defaults to None)
- Raises EricServerNotConnectedError:
-
raised to indicate a missing server
connection
- Raises OSError:
-
raised in case the server reported an issue
EricServerNotConnectedError
Class defining a special OSError indicating a missing server connection.
Derived from
OSError
Class Attributes
Class Methods
Methods
Static Methods
EricServerNotConnectedError (Constructor)
EricServerNotConnectedError()
Constructor