file_reference
numerous.collections.file_reference
Class for working with numerous files.
FileReference
dataclass
Represents a file in a collection.
Source code in numerous/collections/file_reference.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |
exists: bool
property
Indicate whether the file exists.
Returns:
| Type | Description |
|---|---|
bool
|
True if the file exists; False otherwise. |
tags: dict[str, str]
property
Return the tags associated with the file.
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
A dictionary of tag key-value pairs. |
delete()
Delete the file from the server.
Source code in numerous/collections/file_reference.py
102 103 104 | |
open()
Open the file for reading in binary mode.
Returns:
| Type | Description |
|---|---|
BinaryIO
|
A binary file-like object for reading the file. |
Source code in numerous/collections/file_reference.py
72 73 74 75 76 77 78 79 80 | |
read_bytes()
Read the file's content as bytes.
Returns:
| Type | Description |
|---|---|
bytes
|
The byte content of the file. |
Source code in numerous/collections/file_reference.py
62 63 64 65 66 67 68 69 70 | |
read_text()
Read the file's content as text.
Returns:
| Type | Description |
|---|---|
str
|
The text content of the file. |
Source code in numerous/collections/file_reference.py
52 53 54 55 56 57 58 59 60 | |
save(data)
Upload and saves data to the file on the server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
bytes | str
|
The content to save to the file, either as bytes or string. |
required |
Source code in numerous/collections/file_reference.py
82 83 84 85 86 87 88 89 90 | |
save_file(data)
Upload and saves a text file to the server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
TextIOWrapper
|
A file-like object containing the text content to upload. |
required |
Source code in numerous/collections/file_reference.py
92 93 94 95 96 97 98 99 100 | |
tag(key, value)
Add a tag to the file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The tag key. |
required |
value
|
str
|
The tag value. |
required |
Source code in numerous/collections/file_reference.py
106 107 108 109 110 111 112 113 114 115 | |
tag_delete(tag_key)
Delete a tag from the file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag_key
|
str
|
The key of the tag to delete. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the file does not exist. |
Source code in numerous/collections/file_reference.py
117 118 119 120 121 122 123 124 125 126 127 128 | |