norfs.fs package

Submodules

norfs.fs.base module

class norfs.fs.base.BaseFileSystem[source]

Bases: object

ERROR_MESSAGE = 'BaseFileSystem: operation not implemented'
dir_list(path: norfs.fs.base.Path) → Iterable[norfs.fs.base.FSObjectPath][source]
dir_remove(path: norfs.fs.base.Path) → None[source]
file_read(path: norfs.fs.base.Path) → bytes[source]
file_remove(path: norfs.fs.base.Path) → None[source]
file_set_perms(path: norfs.fs.base.Path, policies: List[norfs.permissions.Policy]) → None[source]
file_set_properties(path: norfs.fs.base.Path, content_type: Optional[str] = None, tags: Optional[Dict[str, str]] = None, metadata: Optional[Dict[str, str]] = None) → None[source]
file_write(path: norfs.fs.base.Path, content: bytes) → None[source]
parse_path(path: str)norfs.fs.base.Path[source]
path_exists(path: norfs.fs.base.Path) → bool[source]
path_to_string(path: norfs.fs.base.Path) → str[source]
path_to_uri(path: norfs.fs.base.Path) → str[source]
class norfs.fs.base.FSObjectPath(type: norfs.fs.base.FSObjectType, path: norfs.fs.base.Path)[source]

Bases: object

property path
property type
class norfs.fs.base.FSObjectType(value)[source]

Bases: enum.Enum

An enumeration.

DIR = 2
FILE = 1
OTHER = 3
exception norfs.fs.base.FileSystemOperationError[source]

Bases: Exception

exception norfs.fs.base.NotAFileError[source]

Bases: Exception

class norfs.fs.base.Path(drive: str, *tail: str)[source]

Bases: object

property basename
child(name: str)norfs.fs.base.Path[source]
property drive
property parent
property tail

norfs.fs.local module

class norfs.fs.local.LocalFileSystem[source]

Bases: norfs.fs.base.BaseFileSystem

dir_list(path: norfs.fs.base.Path) → Iterable[norfs.fs.base.FSObjectPath][source]
dir_remove(path: norfs.fs.base.Path) → None[source]
file_read(path: norfs.fs.base.Path) → bytes[source]
file_remove(path: norfs.fs.base.Path) → None[source]
file_set_perms(path: norfs.fs.base.Path, policies: List[norfs.permissions.Policy]) → None[source]

Set permissions for a file.

This works as expected on a unix file system. Perm.WRITE_PERMS and Perm.READ_PERMS are ignored.

file_set_properties(path: norfs.fs.base.Path, content_type: Optional[str] = None, tags: Optional[Dict[str, str]] = None, metadata: Optional[Dict[str, str]] = None) → None[source]

Has no effect.

file_write(path: norfs.fs.base.Path, content: bytes) → None[source]
parse_path(path: str)norfs.fs.base.Path[source]
path_exists(path: norfs.fs.base.Path) → bool[source]
path_to_string(path: norfs.fs.base.Path) → str[source]
path_to_uri(path: norfs.fs.base.Path) → str[source]

norfs.fs.memory module

class norfs.fs.memory.MemoryDirectory[source]

Bases: object

get_dir(name: str)norfs.fs.memory.MemoryDirectory[source]
get_file(name: str)norfs.fs.memory.MemoryFile[source]
list_dirs() → List[str][source]
list_files() → List[str][source]
put_dir(name: str, dir_: norfs.fs.memory.MemoryDirectory) → None[source]
put_file(name: str, file_: norfs.fs.memory.MemoryFile) → None[source]
remove_dir(name: str) → None[source]
remove_file(name: str) → None[source]
class norfs.fs.memory.MemoryFile(contents: bytes)[source]

Bases: object

property contents
class norfs.fs.memory.MemoryFileSystem(root: norfs.fs.memory.MemoryDirectory, *, separator: str = '/')[source]

Bases: norfs.fs.base.BaseFileSystem

dir_list(path: norfs.fs.base.Path) → Iterable[norfs.fs.base.FSObjectPath][source]
dir_remove(path: norfs.fs.base.Path) → None[source]
file_read(path: norfs.fs.base.Path) → bytes[source]
file_remove(path: norfs.fs.base.Path) → None[source]
file_set_perms(path: norfs.fs.base.Path, policies: List[norfs.permissions.Policy]) → None[source]

Has no effect. MemoryFileSystem has no concept of permissions.

file_set_properties(path: norfs.fs.base.Path, content_type: Optional[str] = None, tags: Optional[Dict[str, str]] = None, metadata: Optional[Dict[str, str]] = None) → None[source]

Has no effect.

file_write(path: norfs.fs.base.Path, content: bytes) → None[source]
parse_path(path: str)norfs.fs.base.Path[source]
path_exists(path: norfs.fs.base.Path) → bool[source]
path_to_string(path: norfs.fs.base.Path) → str[source]
path_to_uri(path: norfs.fs.base.Path) → str[source]

norfs.fs.s3 module

class norfs.fs.s3.CannedPerms[source]

Bases: object

PRIVATE = [<norfs.permissions.Policy object>]
PUBLIC_READ = [<norfs.permissions.Policy object>, <norfs.permissions.Policy object>, <norfs.permissions.Policy object>]
class norfs.fs.s3.S3FileSystem(s3_client: Any, *, uri_protocol: str = 's3', separator: str = '/')[source]

Bases: norfs.fs.base.BaseFileSystem

dir_list(path: norfs.fs.base.Path) → Iterable[norfs.fs.base.FSObjectPath][source]
dir_remove(path: norfs.fs.base.Path) → None[source]
file_read(path: norfs.fs.base.Path) → bytes[source]
file_remove(path: norfs.fs.base.Path) → None[source]
file_set_perms(path: norfs.fs.base.Path, policies: List[norfs.permissions.Policy]) → None[source]

Set ACL policies for the object.

Check norfs.fs.s3.s3_scopes and norfs.fs.s3.s3_perms to understand how norfs.permissions.Scope and norfs.permissions.Perm map to S3 Grantees and Permissions.

file_set_properties(path: norfs.fs.base.Path, content_type: Optional[str] = None, tags: Optional[Dict[str, str]] = None, metadata: Optional[Dict[str, str]] = None) → None[source]

Set properties for the object.

file_write(path: norfs.fs.base.Path, content: bytes) → None[source]
parse_path(path: str)norfs.fs.base.Path[source]
path_exists(path: norfs.fs.base.Path) → bool[source]
path_to_string(path: norfs.fs.base.Path) → str[source]
path_to_uri(path: norfs.fs.base.Path) → str[source]
norfs.fs.s3.s3_perms = {<Perm.READ: 1>: 'READ', <Perm.WRITE: 2>: 'WRITE', <Perm.READ_PERMS: 4>: 'READ_ACP', <Perm.WRITE_PERMS: 5>: 'WRITE_ACP'}

Permission mapping for S3

norfs.fs.s3.s3_scopes = {<Scope.GROUP: 2>: {'Type': 'Group', 'URI': 'http://acs.amazonaws.com/groups/global/AuthenticatedUsers'}, <Scope.OTHERS: 3>: {'Type': 'Group', 'URI': 'http://acs.amazonaws.com/groups/global/AllUsers'}}

Permission scope mapping for S3

Module contents