{"id":25633004,"url":"https://github.com/lasuillard/pydantic-fixedwidth","last_synced_at":"2025-07-15T05:40:53.086Z","repository":{"id":278767447,"uuid":"935494924","full_name":"lasuillard/pydantic-fixedwidth","owner":"lasuillard","description":"Custom Pydantic models for serializing and deserializing fixed-width format data.","archived":false,"fork":false,"pushed_at":"2025-07-02T03:10:14.000Z","size":338,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-02T03:16:30.801Z","etag":null,"topics":["fixed-width","pydantic","python"],"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/lasuillard.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2025-02-19T14:37:48.000Z","updated_at":"2025-07-02T03:10:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"fcfc0f5e-fa5d-4fa2-8e4e-3721c10b624c","html_url":"https://github.com/lasuillard/pydantic-fixedwidth","commit_stats":null,"previous_names":["lasuillard/pydantic-fixedwidth"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/lasuillard/pydantic-fixedwidth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lasuillard%2Fpydantic-fixedwidth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lasuillard%2Fpydantic-fixedwidth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lasuillard%2Fpydantic-fixedwidth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lasuillard%2Fpydantic-fixedwidth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lasuillard","download_url":"https://codeload.github.com/lasuillard/pydantic-fixedwidth/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lasuillard%2Fpydantic-fixedwidth/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265411574,"owners_count":23760637,"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","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":["fixed-width","pydantic","python"],"created_at":"2025-02-22T21:19:34.922Z","updated_at":"2025-07-15T05:40:53.064Z","avatar_url":"https://github.com/lasuillard.png","language":"Python","readme":"# pydantic-fixedwidth\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![CI](https://github.com/lasuillard/pydantic-fixedwidth/actions/workflows/ci.yaml/badge.svg)](https://github.com/lasuillard/pydantic-fixedwidth/actions/workflows/ci.yaml)\n[![codecov](https://codecov.io/gh/lasuillard/pydantic-fixedwidth/graph/badge.svg?token=R5pQWB43DP)](https://codecov.io/gh/lasuillard/pydantic-fixedwidth)\n[![PyPI - Version](https://img.shields.io/pypi/v/pydantic-fixedwidth)](https://pypi.org/project/pydantic-fixedwidth/)\n\nCustom Pydantic models for serializing and deserializing fixed-width format data.\n\n\n## 🚀 Quick Start\n\nInstall this package with pip:\n\n```shell\n$ pip install pydantic-fixedwidth\n```\n\nUsage example:\n\n```python\nfrom datetime import datetime, timezone\n\nfrom pydantic_fixedwidth import Fixedwidth, Padding\nfrom pydantic_fixedwidth import OrderedField as Field\n\ntzinfo = timezone.utc\n\n\nclass SomeRequest(Fixedwidth):\n    string: str = Field(length=8)\n    hangul: str = Field(length=6)\n    number: int = Field(length=10, justify=\"right\", fill_char=b\"0\")\n\n    # Just an padding field\n    p_: str = Padding(length=10)\n\n    # This field will be ignored in ser/de\n    ignore: str = Field(length=10, default=\"IGNORE\", exclude=True)\n\n    ts: datetime = Field(\n        length=20,\n        to_str=lambda dt: dt.strftime(\"%Y%m%d%H%M%S%f\"),\n        from_str=lambda s: datetime.strptime(s, \"%Y%m%d%H%M%S%f\").replace(tzinfo=tzinfo),\n    )\n\n\n# Format model to bytes\nsome_request = SomeRequest(\n    string=\"\u003cDFG\u0026\",\n    hangul=\"한글\",\n    number=381,\n    ts=datetime(2024, 1, 23, 14, 11, 20, 124277, tzinfo=tzinfo),\n)\nb = some_request.format_bytes()\n\nassert len(b) == 54\nassert b == b\"\u003cDFG\u0026   \\xed\\x95\\x9c\\xea\\xb8\\x800000000381          20240123141120124277\"\n\n# Parse bytes into model\nparsed_request = SomeRequest.parse_bytes(b)\n\nassert parsed_request == some_request\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flasuillard%2Fpydantic-fixedwidth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flasuillard%2Fpydantic-fixedwidth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flasuillard%2Fpydantic-fixedwidth/lists"}