{"id":25878311,"url":"https://github.com/zyv/trac-rpc-client","last_synced_at":"2025-09-04T18:52:34.768Z","repository":{"id":279791131,"uuid":"939450117","full_name":"zyv/trac-rpc-client","owner":"zyv","description":"Modern, Pythonic and type-safe Trac RPC API client","archived":false,"fork":false,"pushed_at":"2025-07-01T05:26:53.000Z","size":154,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-01T06:27:38.559Z","etag":null,"topics":["httpx","pydantic","rpc","rpc-api","trac"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zyv.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["zyv"]}},"created_at":"2025-02-26T15:02:59.000Z","updated_at":"2025-07-01T05:26:55.000Z","dependencies_parsed_at":"2025-02-27T17:48:44.914Z","dependency_job_id":"6c80b688-44fe-456f-ac29-57502c32699b","html_url":"https://github.com/zyv/trac-rpc-client","commit_stats":null,"previous_names":["zyv/trac-rpc-client"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/zyv/trac-rpc-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zyv%2Ftrac-rpc-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zyv%2Ftrac-rpc-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zyv%2Ftrac-rpc-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zyv%2Ftrac-rpc-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zyv","download_url":"https://codeload.github.com/zyv/trac-rpc-client/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zyv%2Ftrac-rpc-client/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273657084,"owners_count":25145003,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-04T02:00:08.968Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["httpx","pydantic","rpc","rpc-api","trac"],"created_at":"2025-03-02T12:30:05.757Z","updated_at":"2025-09-04T18:52:34.744Z","avatar_url":"https://github.com/zyv.png","language":"Python","funding_links":["https://github.com/sponsors/zyv"],"categories":[],"sub_categories":[],"readme":"# Trac RPC API client\n\n[![PyPI License](https://img.shields.io/pypi/l/trac-rpc)](https://github.com/zyv/trac-rpc-client/blob/main/LICENSE)\n[![PyPI project](https://img.shields.io/pypi/v/trac-rpc.svg?logo=python\u0026logoColor=edb641)](https://pypi.python.org/pypi/trac-rpc)\n![Python versions](https://img.shields.io/pypi/pyversions/trac-rpc.svg?logo=python\u0026logoColor=edb641)\n[![Pydantic v2](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/pydantic/pydantic/main/docs/badge/v2.json)](https://docs.pydantic.dev/latest/contributing/#badges)\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n[![CI](https://github.com/zyv/trac-rpc-client/workflows/CI/badge.svg)](https://github.com/zyv/trac-rpc-client/actions)\n\nModern, Pythonic and type-safe Trac RPC API client.\n\n\u003e [!NOTE]\n\u003e This package was developed primarily to satisfy my personal migration needs and as such covers only the **read** interface of the API!\n\u003e\n\u003e Please feel free to contact me for complex migration projects from Trac and/or custom development needs. High quality contributions that follow the library structure and donations are also much appreciated.\n\n## Installation\n\n```shell\n$ pip install trac-rpc\n```\n\n### Dependencies\n\n* [Pydantic V2](https://pydantic.dev)\n* [httpx](https://www.python-httpx.org)\n\n## Usage\n\n```pycon\n\u003e\u003e\u003e from trac_rpc.client import ApiClient, HttpClient\n\n\u003e\u003e\u003e api_client = ApiClient(\n    rpc_url=\"http://127.0.0.1:8000/login/rpc\",\n    http_client=HttpClient(auth=(\"admin\", \"admin\")),\n)\n\n\u003e\u003e\u003e api_client.get_api_version()\nTracApiVersion(epoch=1, major=2, minor=0)\n\n\u003e\u003e\u003e result = api_client.get_ticket_last_field_change(1, \"status\", \"closed\")\n\u003e\u003e\u003e result.timestamp\ndatetime.datetime(2025, 2, 27, 13, 37, 11, 171873, tzinfo=TzInfo(UTC))\n```\n\n\u003e [!IMPORTANT]\n\u003e Trac APIs (e.g. `query_tickets`) do not return IDs and/or objects sorted in alphanumeric order!\n\u003e\n\u003e They can either be returned in a custom order (such as priority levels) or grouped by certain fields (such as ticket IDs). If you want to iterate on the objects in a particular order, always remember to sort them appropriately after you call the API.\n\n### Customizing models\n\n#### Changing default string type\n\nSome models like `TracMilestone` can be parameterized with a string type such as `TracStrippedStr` instead of `str` to strip leading and trailing whitespace:\n\n```python\nfrom trac_rpc.client import ApiClient\nfrom trac_rpc.models import TracMilestone\nfrom trac_rpc.validators import TracStrippedStr\n\napi_client = ApiClient(rpc_url=\"http://127.0.0.1:8000/rpc\")\nmilestone = api_client.get_milestone(\" milestone2  \", TracMilestone[TracStrippedStr])\n```\n\nThis is especially useful for migrations to detect unnoticed whitespace problems. However, this can potentially cause calls to the Trac RPC API with string object names to fail, so it is not enabled by default.\n\n#### Adjusting `TracTicket` model\n\nEach Trac installation is configured in its own way. The default `TracTicket` model can be easily customized by subclassing:\n\n```python\nfrom trac_rpc.models import TracTicket as TracTicketBase\nfrom trac_rpc.validators import TracSpaceOrCommaSeparated\n\nclass TracTicket(TracTicketBase):\n    keywords: TracSpaceOrCommaSeparated[str]\n    cc: TracSpaceOrCommaSeparated[str]\n```\n\nUsually Trac fields are separated by spaces (`TracSpaceSeparated`), but alternative types are provided for convenience (`TracCommaSeparated`, `TracSpaceOrCommaSeparated`).\n\nComplex validation to ensure data consistency is possible with the `validate_in_set` validator:\n\n```python\nfrom functools import partial\nfrom typing import Annotated\n\nfrom pydantic import AfterValidator\nfrom trac_rpc.models import TracTicket as TracTicketBase\nfrom trac_rpc.validators import validate_in_set, TracOptionalField\n\nVERSIONS = {\"1.0\", \"2.0\"}\n\n\nclass TracTicket(TracTicketBase):\n    validate_version = partial(validate_in_set, allowed=VERSIONS, optional=True)\n    ...\n    version: Annotated[TracOptionalField[str], AfterValidator(validate_version)]\n```\n\n## Development\n\n### Setting up test Trac server\n\nSee [GitHub Actions workflow](.github/workflows/ci.yml) for integration tests.\n\n### Releases\n\nTo release a new version and publish it to PyPI:\n\n* Bump version with `hatch` and commit\n  * `hatch version minor` or `hatch version patch`\n* Create GitHub release (and tag)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzyv%2Ftrac-rpc-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzyv%2Ftrac-rpc-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzyv%2Ftrac-rpc-client/lists"}