Skip to content

oldas.folders

Provides a class for loading up the folders.

Folder dataclass

Folder(id: str, sort_id: str)

Folder information class.

id instance-attribute

id: str

The ID of the folder.

name property

name: str

The name of the folder.

sort_id instance-attribute

sort_id: str

The sort ID of the folder.

from_json classmethod

from_json(data: RawData) -> Folder

Load the folder from JSON data.

Parameters:

Name Type Description Default

data

RawData

The data to load the folder from.

required

Returns:

Type Description
Folder

The folder information.

Folders

Folders(data: Iterable[OldData] | None = None)

Bases: OldList[Folder]

Load the folder list from TheOldReader.

full_id staticmethod

full_id(folder: str | Folder) -> str

Turn something that identifies a folder into a full folder ID.

Parameters:

Name Type Description Default

folder

str | Folder

The folder to get the ID from.

required

Returns:

Type Description
str

The full prefixed folder ID.

load async classmethod

Load the folders.

Parameters:

Name Type Description Default

session

Session

The API session object.

required

Returns:

Type Description
Folders

A list of folders.

remove async classmethod

remove(session: Session, folder: str | Folder) -> bool

Remove the given folder from the server.

Parameters:

Name Type Description Default

session

Session

The API session object.

required

folder

str | Folder

The folder that is to be removed.

required

Returns:

Type Description
bool

True if the folder was removed, False if not.

Notes

folder can have or be missing the prefix Prefix.FOLDER; this method will handle either case and do the right thing.

rename async classmethod

Rename a folder on the server.

Parameters:

Name Type Description Default

session

Session

The API session object.

required

rename_from

str | Folder

The folder that is to be renamed.

required

rename_to

str

The new name for the folder.

required

Returns:

Type Description
bool

True if the rename worked, False if not.

Notes

rename_from and rename_to can have or be missing the prefix Prefix.FOLDER; this method will handle either case and do the right thing.