Login
Back to bricks list
Introduction Version

Folder

RESOURCE
Typing name :  RESOURCE.gws_core.Folder Brick :  gws_core
Parent :
Fs node

Resource that represents a folder in the system.

Technical notes:

/!\ The class that extend folder can only have a path and file_store_id attributes. Other attributes will not be provided when creating the resource.

Views

VIEW FOLDER CONTENTDefault view
View the sub files and folders
VIEW FOLDER CONTENT
View the sub files and folders

Attributes

file_store_id: stris_symbolic_link: boolname: strpath: strstyle: TypingStyletags: TagListtechnical_info: TechnicalInfoDictuid: str

Functions

__INIT__

Create a new FSNode

Parameters:
NameTypeDefault valueDescription
pathstr '' Absolute path to the file, defaults to "" , optional
ADD_TECHNICAL_INFO

Add technical information on the resource. Technical info are useful to set additional information on the resource.

Parameters:
NameTypeDefault valueDescription
technical_infoTechnicalInfo Technical information to add (key, value)
CHECK_RESOURCE

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

Return type:
Optional
CLONE

Clone the resource to create a new instance with a new id. It copies the RFields.

Return type:
ResourceType
COPY_TO_DIRECTORY

Copy the node to the directory and keep the same base name

Parameters:
NameTypeDefault valueDescription
destinationstr The destination directory
Return type:
str
COPY_TO_PATH

Copy the folder to the destination and rename the base name

Parameters:
NameTypeDefault valueDescription
destinationstr Complete path to the destination
Return type:
str
CREATE_DIR_IF_NOT_EXIST

Create a directory inside this folder if it does not exist. Creates intermediate directories if needed.

Parameters:
NameTypeDefault valueDescription
dir_pathstr
Return type:
Path
CREATE_EMPTY_FILE_IF_NOT_EXIST

Create an empty file inside this folder if it does not exist. Creates intermediate directories if needed.

Parameters:
NameTypeDefault valueDescription
file_pathstr Relative path of the file
Return type:
Path
EXISTS
GET_BASE_NAME

Get the name of the folder without the path

Return type:
str
GET_DEFAULT_NAME

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

Return type:
str
GET_SIZE
Return type:
int
GET_SUB_NODE

Get the sub node (file or folder) at the given path as a FSNode

:raises BadRequestException: If the sub node does not exist

Parameters:
NameTypeDefault valueDescription
sub_node_pathstr Relative path of the sub node
Return type:
FSNode
GET_SUB_PATH

Get the absolute path of the sub node

Parameters:
NameTypeDefault valueDescription
sub_node_pathstr Relative path of the sub node
Return type:
str
GET_TECHNICAL_INFO

Get the technical information of the resource

Parameters:
NameTypeDefault valueDescription
keystr Key of the technical information
Return type:
TechnicalInfo
HAS_NODE

Check if the sub node exists

Parameters:
NameTypeDefault valueDescription
sub_node_pathstr Relative path of the sub node
Return type:
bool
INIT

This can be overwritten to perform custom initialization of the resource. This method is called just after the init (constructor) of the resource. The default values of RFields are set before this method is called.

LIST_DIR

List the files and directories inside this folder (not recursive)

Return type:
List
LIST_DIR_PATH

List the files and directories absolute path inside this folder (not recursive)

Return type:
List
CLASSNAME - @classmethod

Returns the name of the class

Parameters:
NameTypeDefault valueDescription
slugifybool False True to slugify the class name if true, defaults to false , optional
snakefybool False True to snakefy the class name if true, defaults to false , optional
replace_uppercasebool False Replace upper cases by "-" if true, defaults to false , optional
Return type:
str
COPY_STYLE - @classmethod

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.

Parameters:
NameTypeDefault valueDescription
icon_technical_namestr Technical name of the icon if provided, the icon_type must also be provided, defaults to none , optional
icon_typeTypingIconType Type of the icon if provided, the icon_technical_name must also be provided, defaults to none , optional
background_colorstr Background color, defaults to none , optional
icon_colorTypingIconColor Icon color, defaults to none , optional
Return type:
TypingStyle
DECORATED_METHOD_NAMES - @classmethod
Parameters:
NameTypeDefault valueDescription
decorator_nameAny
FULL_CLASSNAME - @classmethod

Returns the full name of the class

Parameters:
NameTypeDefault valueDescription
slugifybool False Slugify the returned class name if true, defaults to false , optional
snakefybool False Snakefy the returned class name if true, defaults to false ``
Return type:
str
INHERITORS - @classmethod

Get all the classes that inherit this class

Return type:
List
METHOD_NAMES - @classmethod

Returns the list of the methods

Return type:
List
MODULE_NAME - @classmethod

Returns the module name of the class

Return type:
str
PROPERTY_METHOD_NAMES - @classmethod
PROPERTY_NAMES - @classmethod

Retrieves the property names

Parameters:
NameTypeDefault valueDescription
instancetype The s of the properties to retrieve. set `none` to retrieve all. `type` or `union[type]`
excludetype
Return type:
List