# Pathy: a Path interface for local and cloud bucket storage
[![Build](https://github.com/justindujardin/pathy/actions/workflows/python-package.yml/badge.svg)](https://github.com/justindujardin/pathy/actions/workflows/python-package.yml)
[![codecov](https://codecov.io/gh/justindujardin/pathy/branch/master/graph/badge.svg)](https://codecov.io/gh/justindujardin/pathy)
[![Pypi version](https://badgen.net/pypi/v/pathy)](https://pypi.org/project/pathy/)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)
Pathy is a python package (_with type annotations_) for working with Cloud Bucket storage providers using a pathlib interface. It provides an easy-to-use API bundled with a CLI app for basic file operations between local files and remote buckets. It enables a smooth developer experience by letting developers work against the local file system during development and only switch over to live APIs for deployment. It also makes converting bucket blobs into local files a snap with optional local file caching.
## π Quickstart
You can install `pathy` from pip:
```bash
pip install pathy
```
The package exports the `Pathy` class and utilities for configuring the bucket storage provider to use.
```python
from pathy import Pathy, use_fs
# Use the local file-system for quicker development
use_fs()
# Create a bucket
Pathy("gs://my_bucket").mkdir(exist_ok=True)
# An excellent blob
greeting = Pathy(f"gs://my_bucket/greeting.txt")
# But it doesn't exist yet
assert not greeting.exists()
# Create it by writing some text
greeting.write_text("Hello World!")
# Now it exists
assert greeting.exists()
# Delete it
greeting.unlink()
# Now it doesn't
assert not greeting.exists()
```
## Supported Clouds
The table below details the supported cloud provider APIs.
| Cloud Service | Support | Install Extras |
| :------------------- | :-----: | :------------------------: |
| Google Cloud Storage | β
| `pip install pathy[gcs]` |
| Amazon S3 | β
| `pip install pathy[s3]` |
| Azure | β
| `pip install pathy[azure]` |
### Google Cloud Storage
Google recommends using a JSON credentials file, which you can specify by path:
```python
from google.oauth2 import service_account
from pathy import set_client_params
credentials = service_account.Credentials.from_service_account_file("./my-creds.json")
set_client_params("gs", credentials=credentials)
```
### Amazon S3
S3 uses a JSON credentials file, which you can specify by path:
```python
from pathy import set_client_params
set_client_params("s3", key_id="YOUR_ACCESS_KEY_ID", key_secret="YOUR_ACCESS_SECRET")
```
### Azure
Azure blob storage can be passed a `connection_string`:
```python
from pathy import set_client_params
set_client_params("azure", connection_string="YOUR_CONNECTION_STRING")
```
or a `BlobServiceClient` instance:
```python
from azure.storage.blob import BlobServiceClient
from pathy import set_client_params
service: BlobServiceClient = BlobServiceClient.from_connection_string(
"YOUR_CONNECTION_STRING"
)
set_client_params("azure", service=service)
```
## Semantic Versioning
Before Pathy reaches v1.0 the project is not guaranteed to have a consistent API, which means that types and classes may move around or be removed. That said, we try to be predictable when it comes to breaking changes, so the project uses semantic versioning to help users avoid breakage.
Specifically, new releases increase the `patch` semver component for new features and fixes, and the `minor` component when there are breaking changes. If you don't know much about semver strings, they're usually formatted `{major}.{minor}.{patch}` so increasing the `patch` component means incrementing the last number.
Consider a few examples:
| From Version | To Version | Changes are Breaking |
| :----------: | :--------: | :------------------: |
| 0.2.0 | 0.2.1 | No |
| 0.3.2 | 0.3.6 | No |
| 0.3.1 | 0.3.17 | No |
| 0.2.2 | 0.3.0 | Yes |
If you are concerned about breaking changes, you can pin the version in your requirements so that it does not go beyond the current semver `minor` component, for example if the current version was `0.1.37`:
```
pathy>=0.1.37,<0.2.0
```
## π API
<!-- NOTE: The below code is auto-generated. Update source files to change API documentation. -->
<!-- AUTO_DOCZ_START -->
# Pathy <kbd>class</kbd>
```python (doc)
Pathy(self, args, kwargs)
```
Subclass of `pathlib.Path` that works with bucket APIs.
## exists <kbd>method</kbd>
```python (doc)
Pathy.exists(self) -> bool
```
Returns True if the path points to an existing bucket, blob, or prefix.
## fluid <kbd>classmethod</kbd>
```python (doc)
Pathy.fluid(
path_candidate: Union[str, Pathy, BasePath],
) -> Union[Pathy, BasePath]
```
Infer either a Pathy or pathlib.Path from an input path or string.
The returned type is a union of the potential `FluidPath` types and will
type-check correctly against the minimum overlapping APIs of all the input
types.
If you need to use specific implementation details of a type, "narrow" the
return of this function to the desired type, e.g.
```python
from pathy import FluidPath, Pathy
fluid_path: FluidPath = Pathy.fluid("gs://my_bucket/foo.txt")
# Narrow the type to a specific class
assert isinstance(fluid_path, Pathy), "must be Pathy"
# Use a member specific to that class
assert fluid_path.prefix == "foo.txt/"
```
## from_bucket <kbd>classmethod</kbd>
```python (doc)
Pathy.from_bucket(bucket_name: str, scheme: str = 'gs') -> 'Pathy'
```
Initialize a Pathy from a bucket name. This helper adds a trailing slash and
the appropriate prefix.
```python
from pathy import Pathy
assert str(Pathy.from_bucket("one")) == "gs://one/"
assert str(Pathy.from_bucket("two")) == "gs://two/"
```
## glob <kbd>method</kbd>
```python (doc)
Pathy.glob(
self: 'Pathy',
pattern: str,
) -> Generator[Pathy, NoneType, NoneType]
```
Perform a glob match relative to this Pathy instance, yielding all matched
blobs.
## is_dir <kbd>method</kbd>
```python (doc)
Pathy.is_dir(self: 'Pathy') -> bool
```
Determine if the path points to a bucket or a prefix of a given blob
in the bucket.
Returns True if the path points to a bucket or a blob prefix.
Returns False if it points to a blob or the path doesn't exist.
## is_file <kbd>method</kbd>
```python (doc)
Pathy.is_file(self: 'Pathy') -> bool
```
Determine if the path points to a blob in the bucket.
Returns True if the path points to a blob.
Returns False if it points to a bucket or blob prefix, or if the path doesnβt
exist.
## iterdir <kbd>method</kbd>
```python (doc)
Pathy.iterdir(
self: 'Pathy',
) -> Generator[Pathy, NoneType, NoneType]
```
Iterate over the blobs found in the given bucket or blob prefix path.
## ls <kbd>method</kbd>
```python (doc)
Pathy.ls(self: 'Pathy') -> Generator[BlobStat, NoneType, NoneType]
```
List blob names with stat information under the given path.
This is considerably faster than using iterdir if you also need
the stat information for the enumerated blobs.
Yields BlobStat objects for each found blob.
## mkdir <kbd>method</kbd>
```python (doc)
Pathy.mkdir(
self,
mode: int = 511,
parents: bool = False,
exist_ok: bool = False,
) -> None
```
Create a bucket from the given path. Since bucket APIs only have implicit
folder structures (determined by the existence of a blob with an overlapping
prefix) this does nothing other than create buckets.
If parents is False, the bucket will only be created if the path points to
exactly the bucket and nothing else. If parents is true the bucket will be
created even if the path points to a specific blob.
The mode param is ignored.
Raises FileExistsError if exist_ok is false and the bucket already exists.
## open <kbd>method</kbd>
```python (doc)
Pathy.open(
self: 'Pathy',
mode: str = 'r',
buffering: int = 8192,
encoding: Optional[str] = None,
errors: Optional[str] = None,
newline: Optional[str] = None,
) -> IO[Any]
```
Open the given blob for streaming. This delegates to the `smart_open`
library that handles large file streaming for a number of bucket API
providers.
## owner <kbd>method</kbd>
```python (doc)
Pathy.owner(self: 'Pathy') -> Optional[str]
```
Returns the name of the user that owns the bucket or blob
this path points to. Returns None if the owner is unknown or
not supported by the bucket API provider.
## rename <kbd>method</kbd>
```python (doc)
Pathy.rename(self: 'Pathy', target: Union[str, pathlib.PurePath]) -> 'Pathy'
```
Rename this path to the given target.
If the target exists and is a file, it will be replaced silently if the user
has permission.
If path is a blob prefix, it will replace all the blobs with the same prefix
to match the target prefix.
## replace <kbd>method</kbd>
```python (doc)
Pathy.replace(self: 'Pathy', target: Union[str, pathlib.PurePath]) -> 'Pathy'
```
Renames this path to the given target.
If target points to an existing path, it will be replaced.
## resolve <kbd>method</kbd>
```python (doc)
Pathy.resolve(self, strict: bool = False) -> 'Pathy'
```
Resolve the given path to remove any relative path specifiers.
```python
from pathy import Pathy
path = Pathy("gs://my_bucket/folder/../blob")
assert path.resolve() == Pathy("gs://my_bucket/blob")
```
## rglob <kbd>method</kbd>
```python (doc)
Pathy.rglob(
self: 'Pathy',
pattern: str,
) -> Generator[Pathy, NoneType, NoneType]
```
Perform a recursive glob match relative to this Pathy instance, yielding
all matched blobs. Imagine adding "\*\*/" before a call to glob.
## rmdir <kbd>method</kbd>
```python (doc)
Pathy.rmdir(self: 'Pathy') -> None
```
Removes this bucket or blob prefix. It must be empty.
## samefile <kbd>method</kbd>
```python (doc)
Pathy.samefile(
self: 'Pathy',
other_path: Union[str, bytes, int, pathlib.Path],
) -> bool
```
Determine if this path points to the same location as other_path.
## stat <kbd>method</kbd>
```python (doc)
Pathy.stat(self: 'Pathy') -> pathy.BlobStat
```
Returns information about this bucket path.
## to_local <kbd>classmethod</kbd>
```python (doc)
Pathy.to_local(
blob_path: Union[Pathy, str],
recurse: bool = True,
) -> pathlib.Path
```
Download and cache either a blob or a set of blobs matching a prefix.
The cache is sensitive to the file updated time, and downloads new blobs
as their updated timestamps change.
## touch <kbd>method</kbd>
```python (doc)
Pathy.touch(self: 'Pathy', mode: int = 438, exist_ok: bool = True) -> None
```
Create a blob at this path.
If the blob already exists, the function succeeds if exist_ok is true
(and its modification time is updated to the current time), otherwise
FileExistsError is raised.
# BlobStat <kbd>dataclass</kbd>
```python (doc)
BlobStat(
self,
name: str,
size: Optional[int],
last_modified: Optional[int],
) -> None
```
Stat for a bucket item
# use_fs <kbd>function</kbd>
```python (doc)
use_fs(
root: Optional[str, pathlib.Path, bool] = None,
) -> Optional[pathy.BucketClientFS]
```
Use a path in the local file-system to store blobs and buckets.
This is useful for development and testing situations, and for embedded
applications.
# get_fs_client <kbd>function</kbd>
```python (doc)
get_fs_client() -> Optional[pathy.BucketClientFS]
```
Get the file-system client (or None)
# use_fs_cache <kbd>function</kbd>
```python (doc)
use_fs_cache(
root: Optional[str, pathlib.Path, bool] = None,
) -> Optional[pathlib.Path]
```
Use a path in the local file-system to cache blobs and buckets.
This is useful for when you want to avoid fetching large blobs multiple
times, or need to pass a local file path to a third-party library.
# get_fs_cache <kbd>function</kbd>
```python (doc)
get_fs_cache() -> Optional[pathlib.Path]
```
Get the folder that holds file-system cached blobs and timestamps.
# set_client_params <kbd>function</kbd>
```python (doc)
set_client_params(scheme: str, kwargs: Any) -> None
```
Specify args to pass when instantiating a service-specific Client
object. This allows for passing credentials in whatever way your underlying
client library prefers.
# CLI
Pathy command line interface. (v0.5.2)
**Usage**:
```console
$ [OPTIONS] COMMAND [ARGS]...
```
**Options**:
- `--install-completion`: Install completion for the current shell.
- `--show-completion`: Show completion for the current shell, to copy it or customize the installation.
- `--help`: Show this message and exit.
**Commands**:
- `cp`: Copy a blob or folder of blobs from one...
- `ls`: List the blobs that exist at a given...
- `mv`: Move a blob or folder of blobs from one path...
- `rm`: Remove a blob or folder of blobs from a given...
## `cp`
Copy a blob or folder of blobs from one bucket to another.
**Usage**:
```console
$ cp [OPTIONS] FROM_LOCATION TO_LOCATION
```
**Arguments**:
- `FROM_LOCATION`: [required]
- `TO_LOCATION`: [required]
**Options**:
- `--help`: Show this message and exit.
## `ls`
List the blobs that exist at a given location.
**Usage**:
```console
$ ls [OPTIONS] LOCATION
```
**Arguments**:
- `LOCATION`: [required]
**Options**:
- `-l, --long`: Print long style entries with updated time and size shown. [default: False]
- `--help`: Show this message and exit.
## `mv`
Move a blob or folder of blobs from one path to another.
**Usage**:
```console
$ mv [OPTIONS] FROM_LOCATION TO_LOCATION
```
**Arguments**:
- `FROM_LOCATION`: [required]
- `TO_LOCATION`: [required]
**Options**:
- `--help`: Show this message and exit.
## `rm`
Remove a blob or folder of blobs from a given location.
**Usage**:
```console
$ rm [OPTIONS] LOCATION
```
**Arguments**:
- `LOCATION`: [required]
**Options**:
- `-r, --recursive`: Recursively remove files and folders. [default: False]
- `-v, --verbose`: Print removed files and folders. [default: False]
- `--help`: Show this message and exit.
<!-- AUTO_DOCZ_END -->
# Credits
Pathy is originally based on the [S3Path](https://github.com/liormizr/s3path) project, which provides a Path interface for S3 buckets.
Raw data
{
"_id": null,
"home_page": "https://github.com/justindujardin/pathy",
"name": "pathy",
"maintainer": "",
"docs_url": null,
"requires_python": ">= 3.8",
"maintainer_email": "",
"keywords": "",
"author": "Justin DuJardin",
"author_email": "justin@dujardinconsulting.com",
"download_url": "https://files.pythonhosted.org/packages/13/33/990b4c1a5192797d0d83875a8d9eb4e602d619286decf043f3b1add6554a/pathy-0.11.0.tar.gz",
"platform": null,
"description": "# Pathy: a Path interface for local and cloud bucket storage\n\n[![Build](https://github.com/justindujardin/pathy/actions/workflows/python-package.yml/badge.svg)](https://github.com/justindujardin/pathy/actions/workflows/python-package.yml)\n[![codecov](https://codecov.io/gh/justindujardin/pathy/branch/master/graph/badge.svg)](https://codecov.io/gh/justindujardin/pathy)\n[![Pypi version](https://badgen.net/pypi/v/pathy)](https://pypi.org/project/pathy/)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)\n\nPathy is a python package (_with type annotations_) for working with Cloud Bucket storage providers using a pathlib interface. It provides an easy-to-use API bundled with a CLI app for basic file operations between local files and remote buckets. It enables a smooth developer experience by letting developers work against the local file system during development and only switch over to live APIs for deployment. It also makes converting bucket blobs into local files a snap with optional local file caching.\n\n## \ud83d\ude80 Quickstart\n\nYou can install `pathy` from pip:\n\n```bash\npip install pathy\n```\n\nThe package exports the `Pathy` class and utilities for configuring the bucket storage provider to use.\n\n```python\nfrom pathy import Pathy, use_fs\n# Use the local file-system for quicker development\nuse_fs()\n# Create a bucket\nPathy(\"gs://my_bucket\").mkdir(exist_ok=True)\n# An excellent blob\ngreeting = Pathy(f\"gs://my_bucket/greeting.txt\")\n# But it doesn't exist yet\nassert not greeting.exists()\n# Create it by writing some text\ngreeting.write_text(\"Hello World!\")\n# Now it exists\nassert greeting.exists()\n# Delete it\ngreeting.unlink()\n# Now it doesn't\nassert not greeting.exists()\n```\n\n## Supported Clouds\n\nThe table below details the supported cloud provider APIs.\n\n| Cloud Service | Support | Install Extras |\n| :------------------- | :-----: | :------------------------: |\n| Google Cloud Storage | \u2705 | `pip install pathy[gcs]` |\n| Amazon S3 | \u2705 | `pip install pathy[s3]` |\n| Azure | \u2705 | `pip install pathy[azure]` |\n\n### Google Cloud Storage\n\nGoogle recommends using a JSON credentials file, which you can specify by path:\n\n```python\nfrom google.oauth2 import service_account\nfrom pathy import set_client_params\n\ncredentials = service_account.Credentials.from_service_account_file(\"./my-creds.json\")\nset_client_params(\"gs\", credentials=credentials)\n```\n\n### Amazon S3\n\nS3 uses a JSON credentials file, which you can specify by path:\n\n```python\nfrom pathy import set_client_params\n\nset_client_params(\"s3\", key_id=\"YOUR_ACCESS_KEY_ID\", key_secret=\"YOUR_ACCESS_SECRET\")\n```\n\n### Azure\n\nAzure blob storage can be passed a `connection_string`:\n\n```python\nfrom pathy import set_client_params\n\nset_client_params(\"azure\", connection_string=\"YOUR_CONNECTION_STRING\")\n```\n\nor a `BlobServiceClient` instance:\n\n```python\nfrom azure.storage.blob import BlobServiceClient\nfrom pathy import set_client_params\n\nservice: BlobServiceClient = BlobServiceClient.from_connection_string(\n \"YOUR_CONNECTION_STRING\"\n)\nset_client_params(\"azure\", service=service)\n```\n\n## Semantic Versioning\n\nBefore Pathy reaches v1.0 the project is not guaranteed to have a consistent API, which means that types and classes may move around or be removed. That said, we try to be predictable when it comes to breaking changes, so the project uses semantic versioning to help users avoid breakage.\n\nSpecifically, new releases increase the `patch` semver component for new features and fixes, and the `minor` component when there are breaking changes. If you don't know much about semver strings, they're usually formatted `{major}.{minor}.{patch}` so increasing the `patch` component means incrementing the last number.\n\nConsider a few examples:\n\n| From Version | To Version | Changes are Breaking |\n| :----------: | :--------: | :------------------: |\n| 0.2.0 | 0.2.1 | No |\n| 0.3.2 | 0.3.6 | No |\n| 0.3.1 | 0.3.17 | No |\n| 0.2.2 | 0.3.0 | Yes |\n\nIf you are concerned about breaking changes, you can pin the version in your requirements so that it does not go beyond the current semver `minor` component, for example if the current version was `0.1.37`:\n\n```\npathy>=0.1.37,<0.2.0\n```\n\n## \ud83c\udf9b API\n\n<!-- NOTE: The below code is auto-generated. Update source files to change API documentation. -->\n<!-- AUTO_DOCZ_START -->\n\n# Pathy <kbd>class</kbd>\n\n```python (doc)\nPathy(self, args, kwargs)\n```\n\nSubclass of `pathlib.Path` that works with bucket APIs.\n\n## exists <kbd>method</kbd>\n\n```python (doc)\nPathy.exists(self) -> bool\n```\n\nReturns True if the path points to an existing bucket, blob, or prefix.\n\n## fluid <kbd>classmethod</kbd>\n\n```python (doc)\nPathy.fluid(\n path_candidate: Union[str, Pathy, BasePath],\n) -> Union[Pathy, BasePath]\n```\n\nInfer either a Pathy or pathlib.Path from an input path or string.\n\nThe returned type is a union of the potential `FluidPath` types and will\ntype-check correctly against the minimum overlapping APIs of all the input\ntypes.\n\nIf you need to use specific implementation details of a type, \"narrow\" the\nreturn of this function to the desired type, e.g.\n\n```python\nfrom pathy import FluidPath, Pathy\n\nfluid_path: FluidPath = Pathy.fluid(\"gs://my_bucket/foo.txt\")\n# Narrow the type to a specific class\nassert isinstance(fluid_path, Pathy), \"must be Pathy\"\n# Use a member specific to that class\nassert fluid_path.prefix == \"foo.txt/\"\n```\n\n## from_bucket <kbd>classmethod</kbd>\n\n```python (doc)\nPathy.from_bucket(bucket_name: str, scheme: str = 'gs') -> 'Pathy'\n```\n\nInitialize a Pathy from a bucket name. This helper adds a trailing slash and\nthe appropriate prefix.\n\n```python\nfrom pathy import Pathy\n\nassert str(Pathy.from_bucket(\"one\")) == \"gs://one/\"\nassert str(Pathy.from_bucket(\"two\")) == \"gs://two/\"\n```\n\n## glob <kbd>method</kbd>\n\n```python (doc)\nPathy.glob(\n self: 'Pathy',\n pattern: str,\n) -> Generator[Pathy, NoneType, NoneType]\n```\n\nPerform a glob match relative to this Pathy instance, yielding all matched\nblobs.\n\n## is_dir <kbd>method</kbd>\n\n```python (doc)\nPathy.is_dir(self: 'Pathy') -> bool\n```\n\nDetermine if the path points to a bucket or a prefix of a given blob\nin the bucket.\n\nReturns True if the path points to a bucket or a blob prefix.\nReturns False if it points to a blob or the path doesn't exist.\n\n## is_file <kbd>method</kbd>\n\n```python (doc)\nPathy.is_file(self: 'Pathy') -> bool\n```\n\nDetermine if the path points to a blob in the bucket.\n\nReturns True if the path points to a blob.\nReturns False if it points to a bucket or blob prefix, or if the path doesn\u2019t\nexist.\n\n## iterdir <kbd>method</kbd>\n\n```python (doc)\nPathy.iterdir(\n self: 'Pathy',\n) -> Generator[Pathy, NoneType, NoneType]\n```\n\nIterate over the blobs found in the given bucket or blob prefix path.\n\n## ls <kbd>method</kbd>\n\n```python (doc)\nPathy.ls(self: 'Pathy') -> Generator[BlobStat, NoneType, NoneType]\n```\n\nList blob names with stat information under the given path.\n\nThis is considerably faster than using iterdir if you also need\nthe stat information for the enumerated blobs.\n\nYields BlobStat objects for each found blob.\n\n## mkdir <kbd>method</kbd>\n\n```python (doc)\nPathy.mkdir(\n self,\n mode: int = 511,\n parents: bool = False,\n exist_ok: bool = False,\n) -> None\n```\n\nCreate a bucket from the given path. Since bucket APIs only have implicit\nfolder structures (determined by the existence of a blob with an overlapping\nprefix) this does nothing other than create buckets.\n\nIf parents is False, the bucket will only be created if the path points to\nexactly the bucket and nothing else. If parents is true the bucket will be\ncreated even if the path points to a specific blob.\n\nThe mode param is ignored.\n\nRaises FileExistsError if exist_ok is false and the bucket already exists.\n\n## open <kbd>method</kbd>\n\n```python (doc)\nPathy.open(\n self: 'Pathy',\n mode: str = 'r',\n buffering: int = 8192,\n encoding: Optional[str] = None,\n errors: Optional[str] = None,\n newline: Optional[str] = None,\n) -> IO[Any]\n```\n\nOpen the given blob for streaming. This delegates to the `smart_open`\nlibrary that handles large file streaming for a number of bucket API\nproviders.\n\n## owner <kbd>method</kbd>\n\n```python (doc)\nPathy.owner(self: 'Pathy') -> Optional[str]\n```\n\nReturns the name of the user that owns the bucket or blob\nthis path points to. Returns None if the owner is unknown or\nnot supported by the bucket API provider.\n\n## rename <kbd>method</kbd>\n\n```python (doc)\nPathy.rename(self: 'Pathy', target: Union[str, pathlib.PurePath]) -> 'Pathy'\n```\n\nRename this path to the given target.\n\nIf the target exists and is a file, it will be replaced silently if the user\nhas permission.\n\nIf path is a blob prefix, it will replace all the blobs with the same prefix\nto match the target prefix.\n\n## replace <kbd>method</kbd>\n\n```python (doc)\nPathy.replace(self: 'Pathy', target: Union[str, pathlib.PurePath]) -> 'Pathy'\n```\n\nRenames this path to the given target.\n\nIf target points to an existing path, it will be replaced.\n\n## resolve <kbd>method</kbd>\n\n```python (doc)\nPathy.resolve(self, strict: bool = False) -> 'Pathy'\n```\n\nResolve the given path to remove any relative path specifiers.\n\n```python\nfrom pathy import Pathy\n\npath = Pathy(\"gs://my_bucket/folder/../blob\")\nassert path.resolve() == Pathy(\"gs://my_bucket/blob\")\n```\n\n## rglob <kbd>method</kbd>\n\n```python (doc)\nPathy.rglob(\n self: 'Pathy',\n pattern: str,\n) -> Generator[Pathy, NoneType, NoneType]\n```\n\nPerform a recursive glob match relative to this Pathy instance, yielding\nall matched blobs. Imagine adding \"\\*\\*/\" before a call to glob.\n\n## rmdir <kbd>method</kbd>\n\n```python (doc)\nPathy.rmdir(self: 'Pathy') -> None\n```\n\nRemoves this bucket or blob prefix. It must be empty.\n\n## samefile <kbd>method</kbd>\n\n```python (doc)\nPathy.samefile(\n self: 'Pathy',\n other_path: Union[str, bytes, int, pathlib.Path],\n) -> bool\n```\n\nDetermine if this path points to the same location as other_path.\n\n## stat <kbd>method</kbd>\n\n```python (doc)\nPathy.stat(self: 'Pathy') -> pathy.BlobStat\n```\n\nReturns information about this bucket path.\n\n## to_local <kbd>classmethod</kbd>\n\n```python (doc)\nPathy.to_local(\n blob_path: Union[Pathy, str],\n recurse: bool = True,\n) -> pathlib.Path\n```\n\nDownload and cache either a blob or a set of blobs matching a prefix.\n\nThe cache is sensitive to the file updated time, and downloads new blobs\nas their updated timestamps change.\n\n## touch <kbd>method</kbd>\n\n```python (doc)\nPathy.touch(self: 'Pathy', mode: int = 438, exist_ok: bool = True) -> None\n```\n\nCreate a blob at this path.\n\nIf the blob already exists, the function succeeds if exist_ok is true\n(and its modification time is updated to the current time), otherwise\nFileExistsError is raised.\n\n# BlobStat <kbd>dataclass</kbd>\n\n```python (doc)\nBlobStat(\n self,\n name: str,\n size: Optional[int],\n last_modified: Optional[int],\n) -> None\n```\n\nStat for a bucket item\n\n# use_fs <kbd>function</kbd>\n\n```python (doc)\nuse_fs(\n root: Optional[str, pathlib.Path, bool] = None,\n) -> Optional[pathy.BucketClientFS]\n```\n\nUse a path in the local file-system to store blobs and buckets.\n\nThis is useful for development and testing situations, and for embedded\napplications.\n\n# get_fs_client <kbd>function</kbd>\n\n```python (doc)\nget_fs_client() -> Optional[pathy.BucketClientFS]\n```\n\nGet the file-system client (or None)\n\n# use_fs_cache <kbd>function</kbd>\n\n```python (doc)\nuse_fs_cache(\n root: Optional[str, pathlib.Path, bool] = None,\n) -> Optional[pathlib.Path]\n```\n\nUse a path in the local file-system to cache blobs and buckets.\n\nThis is useful for when you want to avoid fetching large blobs multiple\ntimes, or need to pass a local file path to a third-party library.\n\n# get_fs_cache <kbd>function</kbd>\n\n```python (doc)\nget_fs_cache() -> Optional[pathlib.Path]\n```\n\nGet the folder that holds file-system cached blobs and timestamps.\n\n# set_client_params <kbd>function</kbd>\n\n```python (doc)\nset_client_params(scheme: str, kwargs: Any) -> None\n```\n\nSpecify args to pass when instantiating a service-specific Client\nobject. This allows for passing credentials in whatever way your underlying\nclient library prefers.\n\n# CLI\n\nPathy command line interface. (v0.5.2)\n\n**Usage**:\n\n```console\n$ [OPTIONS] COMMAND [ARGS]...\n```\n\n**Options**:\n\n- `--install-completion`: Install completion for the current shell.\n- `--show-completion`: Show completion for the current shell, to copy it or customize the installation.\n- `--help`: Show this message and exit.\n\n**Commands**:\n\n- `cp`: Copy a blob or folder of blobs from one...\n- `ls`: List the blobs that exist at a given...\n- `mv`: Move a blob or folder of blobs from one path...\n- `rm`: Remove a blob or folder of blobs from a given...\n\n## `cp`\n\nCopy a blob or folder of blobs from one bucket to another.\n\n**Usage**:\n\n```console\n$ cp [OPTIONS] FROM_LOCATION TO_LOCATION\n```\n\n**Arguments**:\n\n- `FROM_LOCATION`: [required]\n- `TO_LOCATION`: [required]\n\n**Options**:\n\n- `--help`: Show this message and exit.\n\n## `ls`\n\nList the blobs that exist at a given location.\n\n**Usage**:\n\n```console\n$ ls [OPTIONS] LOCATION\n```\n\n**Arguments**:\n\n- `LOCATION`: [required]\n\n**Options**:\n\n- `-l, --long`: Print long style entries with updated time and size shown. [default: False]\n- `--help`: Show this message and exit.\n\n## `mv`\n\nMove a blob or folder of blobs from one path to another.\n\n**Usage**:\n\n```console\n$ mv [OPTIONS] FROM_LOCATION TO_LOCATION\n```\n\n**Arguments**:\n\n- `FROM_LOCATION`: [required]\n- `TO_LOCATION`: [required]\n\n**Options**:\n\n- `--help`: Show this message and exit.\n\n## `rm`\n\nRemove a blob or folder of blobs from a given location.\n\n**Usage**:\n\n```console\n$ rm [OPTIONS] LOCATION\n```\n\n**Arguments**:\n\n- `LOCATION`: [required]\n\n**Options**:\n\n- `-r, --recursive`: Recursively remove files and folders. [default: False]\n- `-v, --verbose`: Print removed files and folders. [default: False]\n- `--help`: Show this message and exit.\n\n<!-- AUTO_DOCZ_END -->\n\n# Credits\n\nPathy is originally based on the [S3Path](https://github.com/liormizr/s3path) project, which provides a Path interface for S3 buckets.\n",
"bugtrack_url": null,
"license": "Apache 2.0",
"summary": "pathlib.Path subclasses for local and cloud bucket storage",
"version": "0.11.0",
"project_urls": {
"Homepage": "https://github.com/justindujardin/pathy"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "4254c8f12c7cfb9b7a994acd3d92e816130940b3d4510f87ed1c66b3e7976b73",
"md5": "e86e90aa20347a83dc74651643a29e16",
"sha256": "5027f44744cdcd6b6ffd0b0570133dc1bc4af4b87a4f574ecdd810552b1a9fb0"
},
"downloads": -1,
"filename": "pathy-0.11.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e86e90aa20347a83dc74651643a29e16",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">= 3.8",
"size": 47348,
"upload_time": "2024-01-11T23:02:10",
"upload_time_iso_8601": "2024-01-11T23:02:10.299844Z",
"url": "https://files.pythonhosted.org/packages/42/54/c8f12c7cfb9b7a994acd3d92e816130940b3d4510f87ed1c66b3e7976b73/pathy-0.11.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "1333990b4c1a5192797d0d83875a8d9eb4e602d619286decf043f3b1add6554a",
"md5": "232ad3a4c9ff0e0b299ef2bb081327e9",
"sha256": "bb3d0e6b0b8bf76ef4f63c7191e96e0af2ed65c8fdb5fa17488f9c879e63706d"
},
"downloads": -1,
"filename": "pathy-0.11.0.tar.gz",
"has_sig": false,
"md5_digest": "232ad3a4c9ff0e0b299ef2bb081327e9",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">= 3.8",
"size": 43794,
"upload_time": "2024-01-11T23:02:12",
"upload_time_iso_8601": "2024-01-11T23:02:12.803291Z",
"url": "https://files.pythonhosted.org/packages/13/33/990b4c1a5192797d0d83875a8d9eb4e602d619286decf043f3b1add6554a/pathy-0.11.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-11 23:02:12",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "justindujardin",
"github_project": "pathy",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"requirements": [],
"lcname": "pathy"
}