cterasdk.lib.filesystem module#
- class cterasdk.lib.filesystem.FileSystem#
Bases:
object
- async static async_write(p, handle)#
- static compute_zip_file_name(cloud_directory, files)#
Compute zip file name.
- downloads_directory()#
Get downloads directory.
- Returns:
Directory Path
- Return type:
str
- static exists(p)#
Check if a file or a directory exists
- Parameters:
p (str) – Path
- Returns:
True
if exists,False
otherwise.- Return type:
bool
- static expanduser(p)#
Return a new path with expanded ~ and ~user constructs
- Parameters:
p (str) – Path
- Returns:
Absolute Path.
- Return type:
str
- static file_version(filename, version)#
Append version number to file name.
- Parameters:
filename (str) – File name
version (int) – File version
- Returns:
File name appended with a version number
- Return type:
str
- generate_file_location(location=None, default_filename=None)#
Compute destination file path.
- Parameters:
location (str) – Path to a file or a folder
default_filename (str) – Default file name, unless
location
already specifies a file path
- Returns:
Tuple including the destination directory and file name
- Return type:
tuple(str, str)
- static instance()#
- is_dir(p)#
Check is a directory.
- Parameters:
p (str) – Path
- Returns:
True
if a directory,False
otherwise.- Return type:
bool
- static join(*paths)#
- properties(location)#
Get file properties.
- Parameters:
location (str) – Path
- Returns:
File name, size and type
- Return type:
dict
- rename(parent, source, destination)#
Rename a file or a directory.
- Parameters:
parent (str) – Parent directory
source (str) – Source file or directory name
destination (str) – Destination file or directory name
- Returns:
Parent directory, and file or directory name
- Return type:
tuple(str, str)
- save(directory, filename, handle)#
Save file.
- Parameters:
parent (str) – Directory path.
filename (str) – File name.
handle (object) – File handle.
- Returns:
File path
- Return type:
str
- split_file_directory(location)#
Split file and directory.
- Parameters:
path (str) – Path
Returns: 1. (parent directory, file name), if a file exists 2. (parent directory, file name), if a directory exists 3. (parent directory, file name), if the parent directory exists 4. Raises
FileNotFoundError
if neither the object nor the parent directory exist
- static write(p, handle)#