paralleldomain.utilities.any_path¶
- class AnyPath(path)¶
Implementation of a Path-like object which handles both local and s3 bucket paths.
- glob(pattern)¶
Glob the given relative pattern in the Bucket / key prefix represented by this path, yielding all matching files (of any kind)
- Parameters:
pattern (str) –
- is_absolute()¶
Returns True if the path points to a Bucket or an absolute local path. If path is relative, it returns False
- Return type:
- is_dir()¶
Returns True if the path points to a Bucket or a key prefix, False if it points to a full key path. False is also returned if the path doesn’t exist. Other errors (such as permission errors) are propagated.
- Return type:
- is_fifo()¶
AWS S3 Service doesn’t have fifo feature, There for this method will always return False
- Return type:
- is_file()¶
Returns True if the path points to a Bucket key, False if it points to Bucket or a key prefix. False is also returned if the path doesn’t exist. Other errors (such as permission errors) are propagated.
- Return type:
- is_mount()¶
AWS S3 Service doesn’t have mounting feature, There for this method will always return False
- Return type:
- is_socket()¶
AWS S3 Service doesn’t have sockets feature, There for this method will always return False
- Return type:
- is_symlink()¶
AWS S3 Service doesn’t have symlink feature, There for this method will always return False
- Return type:
- iterdir()¶
When the path points to a Bucket or a key prefix, yield path objects of the directory contents
- mkdir(mode=511, parents=False, exist_ok=False)¶
Create a path bucket. AWS S3 Service doesn’t support folders, therefore the mkdir method will only create the current bucket. If the bucket path already exists, FileExistsError is raised.
If exist_ok is false (the default), FileExistsError is raised if the target Bucket already exists. If exist_ok is true, OSError exceptions will be ignored.
if parents is false (the default), mkdir will create the bucket only if this is a Bucket path. if parents is true, mkdir will create the bucket even if the path have a Key path.
mode argument is ignored.
- open(mode='r', buffering=-1, encoding=None, errors=None, newline=None)¶
Open the file pointed by this path and return a file object, as the built-in open() function does.
- owner()¶
Returns the name of the user owning the Bucket or key. Similarly to boto3’s ObjectSummary owner attribute
- rename(target)¶
Renames this file or Bucket / key prefix / key to the given target. If target exists and is a file, it will be replaced silently if the user has permission. If path is a key prefix, it will replace all the keys with the same prefix to the new target prefix. Target can be either a string or another S3Path object.
- Parameters:
target (str) –
- replace(target)¶
Renames this Bucket / key prefix / key to the given target. If target points to an existing Bucket / key prefix / key, it will be unconditionally replaced.
- rglob(pattern)¶
This is like calling S3Path.glob with ‘**/’ added in front of the given relative pattern
- Parameters:
pattern (str) –
- rm(missing_ok=False)¶
Removes either a Bucket / key prefix or a key, depending on the path.
- Parameters:
missing_ok (bool) –
- rmdir()¶
Removes this Bucket / key prefix. The Bucket / key prefix must be empty
- samefile(other_path)¶
Returns whether this path points to the same Bucket key as other_path, Which can be either a Path object, or a string
- stat()¶
Returns information about this path (similarly to boto3’s ObjectSummary). For compatibility with pathlib, the returned object some similar attributes like os.stat_result. The result is looked up at each call to this method