atfile#
File info object used by python_aternos.atfm
AternosFile
#
File class which contains info about its path, type and size
__init__(atserv, path, rmable, dlable, editable, ftype=FileType.file, size=0)
#
File class which contains info about its path, type and size
Parameters:
Name | Type | Description | Default |
---|---|---|---|
atserv |
python_aternos.atserver.AternosServer
|
atserver.AternosServer instance |
required |
path |
str
|
Absolute path to the file |
required |
rmable |
bool
|
Is the file deleteable (removeable) |
required |
dlable |
bool
|
Is the file downloadable |
required |
ftype |
python_aternos.atfile.FileType
|
File or directory |
FileType.file
|
size |
Union[int, float]
|
File size |
0
|
create(name, ftype=FileType.file)
#
Creates a file or a directory inside this one
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
Filename |
required |
ftype |
FileType
|
File type |
FileType.file
|
Raises:
Type | Description |
---|---|
RuntimeWarning
|
Messages about probabilty of FileError
(if |
FileError
|
If Aternos denied file creation |
delete()
#
Deletes the file
Raises:
Type | Description |
---|---|
RuntimeWarning
|
Message about probability of FileError |
FileError
|
If deleting this file is disallowed by Aternos |
deleteable()
property
#
True if the file can be deleted, otherwise False
Returns:
Type | Description |
---|---|
bool
|
Can the file be deleted |
dirname()
property
#
Full path to the directory
which contains the file
without leading slash.
Empty path means root (/
)
Returns:
Type | Description |
---|---|
str
|
Path to the directory |
downloadable()
property
#
True if the file can be downloaded, otherwise False
Returns:
Type | Description |
---|---|
bool
|
Can the file be downloaded |
editable()
property
#
True if the file can be opened in Aternos editor, otherwise False
Returns:
Type | Description |
---|---|
bool
|
Can the file be edited |
get_content()
#
Requests file content in bytes (downloads it)
Raises:
Type | Description |
---|---|
RuntimeWarning
|
Message about probability of FileError |
FileError
|
If downloading this file is disallowed by Aternos |
Returns:
Type | Description |
---|---|
bytes
|
File content |
get_text()
#
Requests editing the file as a text
Raises:
Type | Description |
---|---|
RuntimeWarning
|
Message about probability of FileError |
FileError
|
If unable to parse text from response |
Returns:
Type | Description |
---|---|
str
|
File text content |
is_dir()
property
#
Check if the file object is a directory
Returns:
Type | Description |
---|---|
bool
|
True if it is a directory, otherwise False |
is_file()
property
#
Check if the file object is not a directory
Returns:
Type | Description |
---|---|
bool
|
True if it is a file, otherwise False |
name()
property
#
Filename with extension
Returns:
Type | Description |
---|---|
str
|
Filename |
path()
property
#
Abslute path to the file without leading slash including filename
Returns:
Type | Description |
---|---|
str
|
Full path to the file |
set_content(value)
#
Modifies file content
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value |
bytes
|
New content |
required |
Raises:
Type | Description |
---|---|
FileError
|
If Aternos denied file saving |
set_text(value)
#
Modifies the file content,
but unlike set_content
takes
a string as an argument
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value |
str
|
New content |
required |
size()
property
#
File size in bytes
Returns:
Type | Description |
---|---|
float
|
File size |
FileType
#
Bases: enum.IntEnum
File or dierctory