Resource that represents a file in the system.
Technical notes:
/!\ The class that extend file can only have a path and file_store_id attributes. Other attributes will not be provided when creating the resource.
Views
Attributes
file_store_id: str
is_symbolic_link: bool
name: str
path: str
style: TypingStyle
tags: TagList
technical_info: TechnicalInfoDict
uid: str
Functions
Create a new FSNode
Name | Type | Default value | Description |
---|---|---|---|
path | str | '' | Absolute path to the file, defaults to "" , optional |
Add technical information on the resource. Technical info are useful to set additional information on the resource.
Name | Type | Default value | Description |
---|---|---|---|
technical_info | TechnicalInfo | Technical information to add (key, value) |
You can redefine this method to define custom logic to check this resource. If there is a problem with the resource, return a string that define the error, otherwise return None This method is called on output resources of a task. If there is an error returned, the task will be set to error and next proceses will not be run. It is also call when uploading a resource (usually for files or folder), if there is an error returned, the resource will not be uploaded
Optional |
Clone the resource to create a new instance with a new id. It copies the RFields.
ResourceType |
Copy the node to the directory and keep the same base name
Name | Type | Default value | Description |
---|---|---|---|
destination | str | The destination directory |
str |
Copy the file or folder to the destination and rename the base name
Name | Type | Default value | Description |
---|---|---|---|
destination | str | Complete path to the destination |
str |
Detect the encoding of the file using charset-normalizer
Name | Type | Default value | Description |
---|---|---|---|
default_encoding | str | utf-8 | Default encoding to use if the encoding is not detected, defaults to 'utf-8' , optional |
str |
bool |
Get the name of the file or folder without the path
str |
You can redefine this method to set a name of the resource. When saving the resource the name will be saved automatically This can be useful to distinguish this resource from another one or to search for the resource
str |
Get the default view of the file.
Name | Type | Default value | Description |
---|---|---|---|
page | int | 1 | Page number, defaults to 1 , optional |
View |
Get the id of the resource model in the database. It is provided by the system for input resources of a task.
str |
str |
Get the name of the resource or the default name if the name is None
str |
int |
Get the technical information of the resource
Name | Type | Default value | Description |
---|---|---|---|
key | str | Key of the technical information |
TechnicalInfo |
Name | Type | Default value | Description |
---|---|---|---|
start_line | int | 1 |
SimpleTextView |
This can be overwritten to perform custom initialization of the resource. This method is called after the init (constructor) of the resource. The values of RFields are set when this method is called.
bool |
bool |
Open the file
Name | Type | Default value | Description |
---|---|---|---|
mode | str | Mode of the file | |
encoding | str | Encoding used to open the file. if none the encoding is automatically detected with charset-normalizer, defaults to none , optional |
Any |
Read the file
Name | Type | Default value | Description |
---|---|---|---|
size | int | -1 | Size of the file to read, defaults to -1 , optional |
encoding | str | Encoding used to read the file. if none the encoding is automatically detected with charset-normalizer, defaults to none , optional | |
mode | str | r+t | Mode of the file, defaults to 'r+t' , optional |
AnyStr |
Read a part of the file
Name | Type | Default value | Description |
---|---|---|---|
from_line | int | 0 | Start line, defaults to 0 , optional |
to_line | int | 10 | End line (excluded), defaults to 10 , optional |
encoding | str | Encoding used to read the file. if none the encoding is automatically detected with charset-normalizer, defaults to none , optional | |
mode | str | r+t | Mode of the file, defaults to 'r+t' , optional |
str |
Write data to the file
Name | Type | Default value | Description |
---|---|---|---|
data | str | Data to write | |
encoding | str | Encoding used to write the file. if none the encoding is automatically detected with charset-normalizer, defaults to none , optional | |
mode | str | a+t | Mode of the file, defaults to 'a+t' , optional |
Returns the name of the class
Name | Type | Default value | Description |
---|---|---|---|
slugify | bool | False | True to slugify the class name if true, defaults to false , optional |
snakefy | bool | False | True to snakefy the class name if true, defaults to false , optional |
replace_uppercase | bool | False | Replace upper cases by "-" if true, defaults to false , optional |
str |
Copy the style of the resource with the possibility to override some properties. Useful when settings the style for a task based on the resource style.
Name | Type | Default value | Description |
---|---|---|---|
icon_technical_name | str | Technical name of the icon if provided, the icon_type must also be provided, defaults to none , optional | |
icon_type | TypingIconType | Type of the icon if provided, the icon_technical_name must also be provided, defaults to none , optional | |
background_color | str | Background color, defaults to none , optional | |
icon_color | TypingIconColor | Icon color, defaults to none , optional |
TypingStyle |
Name | Type | Default value | Description |
---|---|---|---|
decorator_name | Any |
Returns the full name of the class
Name | Type | Default value | Description |
---|---|---|---|
slugify | bool | False | Slugify the returned class name if true, defaults to false , optional |
snakefy | bool | False | Snakefy the returned class name if true, defaults to false `` |
str |
Get the human name of the resource
str |
Get the short description of the resource
str |
Get the typing name of the resource
str |
Get all the classes that inherit this class
List |
Returns the list of the methods
List |
Returns the module name of the class
str |
Retrieves the property names
Name | Type | Default value | Description |
---|---|---|---|
instance | type | The s of the properties to retrieve. set `none` to retrieve all. `type` or `union[type]` | |
exclude | type |
List |