Filesystems
Filesystem
Bases: ABC
, BaseModel
Source code in lume_services/services/files/filesystems/filesystem.py
7 8 9 10 11 12 13 14 15 16 17 18 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 |
|
create_dir(dir)
abstractmethod
Create a directory on the filesystem.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dir
|
str
|
Directory path to create |
required |
Source code in lume_services/services/files/filesystems/filesystem.py
36 37 38 39 40 41 42 43 44 |
|
dir_exists(dir, create_dir=False)
abstractmethod
Check that a directory exists
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dir
|
str
|
Path of directory |
required |
create_dir
|
bool
|
Whether to create directory if it does not exist |
False
|
Returns:
Type | Description |
---|---|
bool
|
bool |
Source code in lume_services/services/files/filesystems/filesystem.py
10 11 12 13 14 15 16 17 18 19 20 21 |
|
file_exists(filepath)
abstractmethod
Check that a file exists
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath
|
str
|
Path to file |
required |
Returns:
Type | Description |
---|---|
bool
|
bool |
Source code in lume_services/services/files/filesystems/filesystem.py
23 24 25 26 27 28 29 30 31 32 33 34 |
|
read(filepath, serializer)
abstractmethod
Read file from the filesystem.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath
|
str
|
Path of file to read |
required |
serializer
|
SerializerBase
|
Implementation of lume-base SerializerBase abstract base class |
required |
Source code in lume_services/services/files/filesystems/filesystem.py
46 47 48 49 50 51 52 53 54 55 56 |
|
write(filepath, object, serializer, create_dir=False)
abstractmethod
Write a file to the filesystem.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath
|
str
|
|
required |
object
|
Any
|
Object to serialize |
required |
serializer
|
SerializerBase
|
Implementation of lume-base SerializerBase abstract base class |
required |
create_dir
|
bool
|
Whether to create directory in case not implemented |
False
|
Source code in lume_services/services/files/filesystems/filesystem.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
|
LocalFilesystem
Bases: Filesystem
Handler for local filesystem.
Source code in lume_services/services/files/filesystems/local.py
11 12 13 14 15 16 17 18 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 |
|
create_dir(dir)
Create a directory on the local filesystem.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dir
|
str
|
Directory path to create |
required |
Source code in lume_services/services/files/filesystems/local.py
60 61 62 63 64 65 66 67 68 69 70 71 |
|
dir_exists(dir, create_dir=False)
Check that a directory exists on the local filesystem.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dir
|
str
|
Path of directory |
required |
create_dir
|
bool
|
Whether to create directory if it does not exist |
False
|
Returns:
Type | Description |
---|---|
bool
|
bool |
Source code in lume_services/services/files/filesystems/local.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
|
file_exists(filepath)
Check that a file exists on the local filesystem.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath
|
str
|
Path to file |
required |
Returns:
Type | Description |
---|---|
bool
|
bool |
Source code in lume_services/services/files/filesystems/local.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
|
read(filepath, serializer)
Read file from the local filesystem.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath
|
str
|
Path of file to read. |
required |
serializer
|
SerializerBase
|
Implementation of lume-base SerializerBase abstract base class. |
required |
Source code in lume_services/services/files/filesystems/local.py
73 74 75 76 77 78 79 80 81 82 83 84 |
|
write(filepath, object, serializer, create_dir=False)
Write a file to the local filesystem.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath
|
str
|
|
required |
object
|
Any
|
Object to serialize |
required |
serializer
|
SerializerBase
|
Implementation of lume-base SerializerBase abstract base class |
required |
create_dir
|
bool
|
Whether to create directory in case not implemented |
False
|
Source code in lume_services/services/files/filesystems/local.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
|
MountedFilesystem
Bases: LocalFilesystem
Handler for mounted filesystem. Modifies the LocalFilesystem to implements checks for mount path modifications. Container and container orchestration tools often allow the ability to provide an alias for a mounted directory. This handler accounts for the mount base and verifies that the file is within the path.
Source code in lume_services/services/files/filesystems/mounted.py
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 129 130 131 132 133 134 135 136 |
|
create_dir(dir)
Create a directory on the mounted filesystem.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dir
|
str
|
Directory path to create |
required |
Source code in lume_services/services/files/filesystems/mounted.py
74 75 76 77 78 79 80 81 82 |
|
dir_exists(dir, create_dir=False)
Check that a directory exists on the mounted filesystem.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dir
|
str
|
Path of directory |
required |
create_dir
|
bool
|
Whether to create directory if it does not exist |
False
|
Returns:
Type | Description |
---|---|
bool
|
bool |
Source code in lume_services/services/files/filesystems/mounted.py
46 47 48 49 50 51 52 53 54 55 56 57 58 |
|
file_exists(filepath)
Check that a file exists on the mounted filesystem.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath
|
str
|
Path to file |
required |
Returns:
Type | Description |
---|---|
bool
|
bool |
Source code in lume_services/services/files/filesystems/mounted.py
60 61 62 63 64 65 66 67 68 69 70 71 72 |
|
read(filepath, serializer)
Read file from the mounted filesystem.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath
|
str
|
Path of file to read |
required |
serializer
|
SerializerBase
|
Implementation of lume-base SerializerBase abstract base class |
required |
Source code in lume_services/services/files/filesystems/mounted.py
84 85 86 87 88 89 90 91 92 93 94 |
|
write(filepath, object, serializer, create_dir=False)
Write a file to the mounted filesystem.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath
|
str
|
|
required |
object
|
Any
|
Object to serialize |
required |
serializer
|
SerializerBase
|
Implementation of lume-base SerializerBase abstract base class |
required |
create_dir
|
bool
|
Whether to create directory in case not implemented |
False
|
Source code in lume_services/services/files/filesystems/mounted.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
|