Name | pyforce-p4 JSON |
Version |
0.1.1
JSON |
| download |
home_page | None |
Summary | Python wrapper for Perforce p4 command-line client |
upload_time | 2024-03-31 16:08:03 |
maintainer | None |
docs_url | None |
author | Thibaud Gambier |
requires_python | >=3.7 |
license | None |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Pyforce
[![License - MIT][license-badge]][pyforce-license]
[![PyPI - Python Version][python-version-badge]][pyforce-pypi]
[![PyPI - Version][version-badge]][pyforce-pypi]
[![Linter - Ruff][ruff-badge]][ruff-repo]
[![Types - Mypy][mypy-badge]][mypy-repo]
[![CI - Tests][pyforce-workflow-tests-badge]][pyforce-workflow-tests]
[![Documentation Status][pyforce-docs-badge]][pyforce-documentation]
Python wrapper for Perforce p4 command-line client.
## Features
- Python wrapper for the `p4` command using [marshal](https://docs.python.org/3/library/marshal.html).
- Built with [Pydantic](https://github.com/pydantic/pydantic).
- Fully typed.
- Built for scripting.
## Installation
```bash
python -m pip install pyforce-p4
```
## Quickstart
```python
import pyforce
connection = pyforce.Connection(host="localhost:1666", user="foo", client="my-client")
# Create a new file in our client
file = "/home/foo/my-client/bar.txt"
fp = open(file, "w")
fp.write("bar")
fp.close()
# Run 'p4 add', open our file for addition to the depot
_, infos = pyforce.add(connection, [file])
print(infos[0])
"""
ActionInfo(
action='add',
client_file='/home/foo/my-client/bar.txt',
depot_file='//my-depot/my-stream/bar.txt',
file_type='text',
work_rev=1
)
"""
# Run 'p4 submit', submitting our local file
pyforce.p4(connection, ["submit", "-d", "Added bar.txt", file])
# Run 'p4 fstat', listing all files in depot
fstats = list(pyforce.fstat(connection, ["//..."]))
print(fstats[0])
"""
FStat(
client_file='/home/foo/my-client/bar.txt',
depot_file='//my-depot/my-stream/bar.txt',
head=HeadInfo(
action=<Action.ADD: 'add'>,
change=2,
revision=1,
file_type='text',
time=datetime.datetime(2024, 3, 29, 13, 56, 57, tzinfo=datetime.timezone.utc),
mod_time=datetime.datetime(2024, 3, 29, 13, 56, 11, tzinfo=datetime.timezone.utc)
),
have_rev=1,
is_mapped=True,
others_open=None
)
"""
```
Pyforce has functions for the most common `p4` commands
but can execute more complexe commands with `pyforce.p4`.
For example, pyforce doesn't have a function to create a new client workspace,
here is how to create one using `pyforce.p4`.
```python
import pyforce
connection = pyforce.Connection(port="localhost:1666", user="foo")
# Create client
command = ["client", "-o", "-S", "//my-depot/my-stream", "my-client"]
data = pyforce.p4(connection, command)[0]
data["Root"] = "/home/foo/my-client"
pyforce.p4(connection, ["client", "-i"], stdin=data)
# Get created client
client = pyforce.get_client(connection, "my-client")
print(client)
"""
Client(
name='my-client',
host='5bb1735f73fc',
owner='foo',
root=PosixPath('/home/foo/my-client'),
stream='//my-depot/my-stream',
type=<ClientType.STANDARD: 'writeable'>,
views=[View(left='//my-depot/my-stream/...', right='//my-client/...')]
)
"""
```
## Documentation
See pyforce [documentation](https://pyforce.readthedocs.io/en/latest) for more details.
## Contributing
For guidance on setting up a development environment and contributing to pyforce,
see the [Contributing](https://pyforce.readthedocs.io/en/latest/contributing.html) section.
<!-- Links -->
[license-badge]: https://img.shields.io/github/license/tahv/pyforce?label=License
[ruff-badge]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v1.json
[version-badge]: https://img.shields.io/pypi/v/pyforce-p4?logo=pypi&label=PyPI&logoColor=white
[python-version-badge]: https://img.shields.io/pypi/pyversions/pyforce-p4?logo=python&label=Python&logoColor=white
[mypy-badge]: https://img.shields.io/badge/Types-Mypy-blue.svg
[pyforce-workflow-tests-badge]: https://github.com/tahv/pyforce/actions/workflows/tests.yml/badge.svg
[pyforce-docs-badge]: https://readthedocs.org/projects/pyforce/badge/?version=latest
[pyforce-license]: https://github.com/tahv/pyforce/blob/main/LICENSE
[ruff-repo]: https://github.com/astral-sh/ruff
[pyforce-pypi]: https://pypi.org/project/pyforce-p4
[mypy-repo]: https://github.com/python/mypy
[pyforce-workflow-tests]: https://github.com/tahv/pyforce/actions/workflows/tests.yml
[pyforce-documentation]: https://pyforce.readthedocs.io/en/latest
Raw data
{
"_id": null,
"home_page": null,
"name": "pyforce-p4",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": null,
"author": "Thibaud Gambier",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/fd/1b/b7433858a3aee9629ba514f3a81e4b898fcbb7b056eda7f3654744b7d2f2/pyforce_p4-0.1.1.tar.gz",
"platform": null,
"description": "# Pyforce\n\n[![License - MIT][license-badge]][pyforce-license]\n[![PyPI - Python Version][python-version-badge]][pyforce-pypi]\n[![PyPI - Version][version-badge]][pyforce-pypi]\n[![Linter - Ruff][ruff-badge]][ruff-repo]\n[![Types - Mypy][mypy-badge]][mypy-repo]\n[![CI - Tests][pyforce-workflow-tests-badge]][pyforce-workflow-tests]\n[![Documentation Status][pyforce-docs-badge]][pyforce-documentation]\n\nPython wrapper for Perforce p4 command-line client.\n\n## Features\n\n- Python wrapper for the `p4` command using [marshal](https://docs.python.org/3/library/marshal.html).\n- Built with [Pydantic](https://github.com/pydantic/pydantic).\n- Fully typed.\n- Built for scripting.\n\n## Installation\n\n```bash\npython -m pip install pyforce-p4\n```\n\n## Quickstart\n\n```python\nimport pyforce\n\nconnection = pyforce.Connection(host=\"localhost:1666\", user=\"foo\", client=\"my-client\")\n\n# Create a new file in our client\nfile = \"/home/foo/my-client/bar.txt\"\nfp = open(file, \"w\")\nfp.write(\"bar\")\nfp.close()\n\n# Run 'p4 add', open our file for addition to the depot\n_, infos = pyforce.add(connection, [file])\nprint(infos[0])\n\"\"\"\nActionInfo(\n action='add', \n client_file='/home/foo/my-client/bar.txt', \n depot_file='//my-depot/my-stream/bar.txt', \n file_type='text', \n work_rev=1\n)\n\"\"\"\n\n# Run 'p4 submit', submitting our local file\npyforce.p4(connection, [\"submit\", \"-d\", \"Added bar.txt\", file])\n\n# Run 'p4 fstat', listing all files in depot\nfstats = list(pyforce.fstat(connection, [\"//...\"]))\nprint(fstats[0])\n\"\"\"\nFStat(\n client_file='/home/foo/my-client/bar.txt', \n depot_file='//my-depot/my-stream/bar.txt', \n head=HeadInfo(\n action=<Action.ADD: 'add'>, \n change=2, \n revision=1, \n file_type='text', \n time=datetime.datetime(2024, 3, 29, 13, 56, 57, tzinfo=datetime.timezone.utc), \n mod_time=datetime.datetime(2024, 3, 29, 13, 56, 11, tzinfo=datetime.timezone.utc)\n ), \n have_rev=1, \n is_mapped=True, \n others_open=None\n)\n\"\"\"\n```\n\nPyforce has functions for the most common `p4` commands\nbut can execute more complexe commands with `pyforce.p4`.\n\nFor example, pyforce doesn't have a function to create a new client workspace,\nhere is how to create one using `pyforce.p4`.\n\n```python\nimport pyforce\n\nconnection = pyforce.Connection(port=\"localhost:1666\", user=\"foo\")\n\n# Create client\ncommand = [\"client\", \"-o\", \"-S\", \"//my-depot/my-stream\", \"my-client\"]\ndata = pyforce.p4(connection, command)[0]\ndata[\"Root\"] = \"/home/foo/my-client\"\npyforce.p4(connection, [\"client\", \"-i\"], stdin=data)\n\n# Get created client\nclient = pyforce.get_client(connection, \"my-client\")\nprint(client)\n\"\"\"\nClient(\n name='my-client', \n host='5bb1735f73fc', \n owner='foo', \n root=PosixPath('/home/foo/my-client'), \n stream='//my-depot/my-stream', \n type=<ClientType.STANDARD: 'writeable'>, \n views=[View(left='//my-depot/my-stream/...', right='//my-client/...')]\n)\n\"\"\"\n```\n\n## Documentation\n\nSee pyforce [documentation](https://pyforce.readthedocs.io/en/latest) for more details.\n\n## Contributing\n\nFor guidance on setting up a development environment and contributing to pyforce,\nsee the [Contributing](https://pyforce.readthedocs.io/en/latest/contributing.html) section.\n\n<!-- Links -->\n\n[license-badge]: https://img.shields.io/github/license/tahv/pyforce?label=License\n[ruff-badge]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v1.json\n[version-badge]: https://img.shields.io/pypi/v/pyforce-p4?logo=pypi&label=PyPI&logoColor=white\n[python-version-badge]: https://img.shields.io/pypi/pyversions/pyforce-p4?logo=python&label=Python&logoColor=white\n[mypy-badge]: https://img.shields.io/badge/Types-Mypy-blue.svg\n[pyforce-workflow-tests-badge]: https://github.com/tahv/pyforce/actions/workflows/tests.yml/badge.svg\n[pyforce-docs-badge]: https://readthedocs.org/projects/pyforce/badge/?version=latest\n\n[pyforce-license]: https://github.com/tahv/pyforce/blob/main/LICENSE\n[ruff-repo]: https://github.com/astral-sh/ruff\n[pyforce-pypi]: https://pypi.org/project/pyforce-p4\n[mypy-repo]: https://github.com/python/mypy\n[pyforce-workflow-tests]: https://github.com/tahv/pyforce/actions/workflows/tests.yml\n[pyforce-documentation]: https://pyforce.readthedocs.io/en/latest\n",
"bugtrack_url": null,
"license": null,
"summary": "Python wrapper for Perforce p4 command-line client",
"version": "0.1.1",
"project_urls": {
"Changelog": "https://github.com/tahv/pyforce/blob/main/CHANGELOG.md",
"Documentation": "https://pyforce.readthedocs.io/en/latest",
"Github": "https://github.com/tahv/pyforce"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "db31a5da88aecfb01d19aecae90b1fcda4f05bf3a6dfb30f07654e45a3a0e1ec",
"md5": "d2d4ca8e3c5ad1aca71b90bcb80ae0dc",
"sha256": "7efb4799aee7c57f0fef658ddf0fc98a2b067d655c0b0d7c1f758148f51827d1"
},
"downloads": -1,
"filename": "pyforce_p4-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d2d4ca8e3c5ad1aca71b90bcb80ae0dc",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 14669,
"upload_time": "2024-03-31T16:08:01",
"upload_time_iso_8601": "2024-03-31T16:08:01.732919Z",
"url": "https://files.pythonhosted.org/packages/db/31/a5da88aecfb01d19aecae90b1fcda4f05bf3a6dfb30f07654e45a3a0e1ec/pyforce_p4-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "fd1bb7433858a3aee9629ba514f3a81e4b898fcbb7b056eda7f3654744b7d2f2",
"md5": "977a3484227073ef596d8fc40dafa710",
"sha256": "6156b694285cb16c1d009e03ecb9616aee9393ff373f4ad1960d6ac67ee1d905"
},
"downloads": -1,
"filename": "pyforce_p4-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "977a3484227073ef596d8fc40dafa710",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 22049,
"upload_time": "2024-03-31T16:08:03",
"upload_time_iso_8601": "2024-03-31T16:08:03.247489Z",
"url": "https://files.pythonhosted.org/packages/fd/1b/b7433858a3aee9629ba514f3a81e4b898fcbb7b056eda7f3654744b7d2f2/pyforce_p4-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-31 16:08:03",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "tahv",
"github_project": "pyforce",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pyforce-p4"
}