{"id":19138526,"url":"https://github.com/rsgalloway/pyseq","last_synced_at":"2025-05-16T10:08:50.582Z","repository":{"id":1199970,"uuid":"1107823","full_name":"rsgalloway/pyseq","owner":"rsgalloway","description":"Compressed sequence string module for Python","archived":false,"fork":false,"pushed_at":"2025-05-15T13:44:28.000Z","size":6805,"stargazers_count":124,"open_issues_count":10,"forks_count":37,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-05-16T10:08:43.837Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://pyseq.rsgalloway.com/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rsgalloway.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","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":"AUTHORS","dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2010-11-24T02:08:22.000Z","updated_at":"2025-05-02T13:33:45.000Z","dependencies_parsed_at":"2024-11-09T06:43:19.908Z","dependency_job_id":"aa2b8fa6-857a-4072-b04a-364c8e7e4bdf","html_url":"https://github.com/rsgalloway/pyseq","commit_stats":{"total_commits":144,"total_committers":12,"mean_commits":12.0,"dds":0.7083333333333333,"last_synced_commit":"7c0e9bf3ce54cdb6595c6ad30796afbea5a8062e"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsgalloway%2Fpyseq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsgalloway%2Fpyseq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsgalloway%2Fpyseq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsgalloway%2Fpyseq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rsgalloway","download_url":"https://codeload.github.com/rsgalloway/pyseq/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254509477,"owners_count":22082892,"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":[],"created_at":"2024-11-09T06:43:06.335Z","updated_at":"2025-05-16T10:08:45.575Z","avatar_url":"https://github.com/rsgalloway.png","language":"Python","readme":"PySeq\n=====\n\nPySeq is a python module that finds groups of items that follow a naming\nconvention containing  a numerical sequence index (e.g. fileA.001.png,\nfileA.002.png, fileA.003.png...) and serializes them into a compressed sequence\nstring representing the entire sequence (e.g. fileA.1-3.png). It should work\nregardless of where the numerical sequence index is embedded in the name. For\nexamples, see basic usage below or http://rsgalloway.github.io/pyseq\n\n## Installation\n\nThe easiest way to install pyseq:\n\n```bash\n$ pip install -U pyseq\n```\n\n#### distman\n\nIf installing from source you can use [distman](https://github.com/rsgalloway/distman)\nto install pyseq using the provided `dist.json` file:\n\n```bash\n$ distman [-d]\n```\n\nUsing distman will deploy the targets defined in the `dist.json` file to the\nroot folder defined by `$DEPLOY_ROOT`.\n\n#### envstack\n\nPySeq uses [envstack](https://github.com/rsgalloway/envstack) to manage configs\nvia environment variables.\n\n```bash\n$ envstack pyseq\nPYSEQ_RANGE_SEP=, \nPYSEQ_STRICT_PAD=0\nSTACK=pyseq\n```\n\n## Basic Usage\n\nUsing the \"z1\" file sequence example in the \"tests\" directory, we start by\nlisting the directory\ncontents using `ls`:\n\n```bash\n$ ls tests/files/z1*\ntests/files/z1_001_v1.1.png  tests/files/z1_001_v1.4.png  tests/files/z1_002_v1.3.png   tests/files/z1_002_v2.11.png\ntests/files/z1_001_v1.2.png  tests/files/z1_002_v1.1.png  tests/files/z1_002_v1.4.png   tests/files/z1_002_v2.12.png\ntests/files/z1_001_v1.3.png  tests/files/z1_002_v1.2.png  tests/files/z1_002_v2.10.png  tests/files/z1_002_v2.9.png\n```\n\nNow we list the same directory contents using `lss`, which will find the\nsequences and display them in the default compressed format:\n\n```bash\n$ lss tests/files/z1*\n   4 z1_001_v1.%d.png [1-4]\n   4 z1_002_v1.%d.png [1-4]\n   4 z1_002_v2.%d.png [9-12]\n```\n\nWith a custom format:\n\n```bash\n$ lss tests/files/z1* -f \"%h%r%t\"\nz1_001_v1.1-4.png\nz1_002_v1.1-4.png\nz1_002_v2.9-12.png\n```\n\nRecursive:\n\n```bash\n$ lss -r tests\ntests\n├── test_pyseq.py\n└── files\n    ├── 012_vb_110_v001.1-10.png\n    ├── 012_vb_110_v002.1-10.png\n    ├── a.1-14.tga\n    ├── alpha.txt\n    ├── bnc01_TinkSO_tx_0_ty_0.101-105.tif\n    ├── bnc01_TinkSO_tx_0_ty_1.101-105.tif\n    ├── bnc01_TinkSO_tx_1_ty_0.101-105.tif\n    ├── bnc01_TinkSO_tx_1_ty_1.101-105.tif\n    ├── file.1-2.tif\n    ├── file.info.03.rgb\n    ├── file01.1-4.j2k\n    ├── file01_40-43.rgb\n    ├── file02_44-47.rgb\n    ├── file1-4.03.rgb\n    ├── fileA.1-3.jpg\n    ├── fileA.1-3.png\n    ├── file_02.tif\n    ├── z1_001_v1.1-4.png\n    ├── z1_002_v1.1-4.png\n    └── z1_002_v2.9-12.png\n```\n\n## API Examples\n\nCompression, or serialization, of lists of items:\n\n```python\n\u003e\u003e\u003e s = Sequence(['file.0001.jpg', 'file.0002.jpg', 'file.0003.jpg'])\n\u003e\u003e\u003e print(s)\nfile.1-3.jpg\n\u003e\u003e\u003e s.append('file.0006.jpg')\n\u003e\u003e\u003e print(s.format(\"%h%p%t %R\"))\nfile.%04d.jpg [1-3, 6]\n```\n\nUncompression, or deserialization, of compressed sequences strings:\n\n```python\n\u003e\u003e\u003e s = uncompress('./tests/012_vb_110_v001.%04d.png 1-1001', fmt='%h%p%t %r')\n\u003e\u003e\u003e len(s)\n1001\n\u003e\u003e\u003e print(s.format('%04l %h%p%t %R'))\n1001 012_vb_110_v001.%04d.png [1-1001]\n```\n\nWalk a directory tree and print disk usage for file sequences:\n\n```python\n\u003e\u003e\u003e for root, dirs, seqs in pyseq.walk(folder):\n...     for seq in seqs:\n...         print(seq.format(\"%h%r%t %H\"))\n012_vb_110_v001.1000-1321.exr   123.5G\n012_vb_110_v002.1000-1163.exr    40.2G\n012_vb_110_v003.1000-1027.exr    72.2G\n```\n\n## Formatting\n\nThe following directives can be embedded in the format string.\n\n| Directive | Meaning                              |\n|-----------|--------------------------------------|\n| `%s`      | sequence start                       |\n| `%e`      | sequence end                         |\n| `%l`      | sequence length                      |\n| `%f`      | list of found files                  |\n| `%m`      | list of missing files                |\n| `%M`      | explicit missing files [11-14,19-21] |\n| `%p`      | padding, e.g. %06d                   |\n| `%r`      | implied range, start-end             |\n| `%R`      | explicit broken range, [1-10, 15-20] |\n| `%d`      | disk usage                           |\n| `%H`      | disk usage (human readable)          |\n| `%D`      | parent directory                     |\n| `%h`      | string preceding sequence number     |\n| `%t`      | string after the sequence number     |\n\nHere are some examples using `lss -f \u003cformat\u003e` and `seq.format(..)`:\n\nUsing `lss -f \u003cformat\u003e`:\n\n```bash\n$ $ lss tests/files/a*.tga -f \"%h%r%t\"\na.1-14.tga\n$ lss tests/files/a*.tga -f \"%l %h%r%t\"\n7 a.1-14.tga\n$ lss tests/files/a*.tga -f \"%l %h%r%t %M\"\n7 a.1-14.tga [4-9, 11]\n```\n\nIn Python, using `seq.format(..)`:\n\n```python\n\u003e\u003e\u003e s = pyseq.get_sequences(\"tests/files/a*.tga\")[0]\n\u003e\u003e\u003e print(s.format(\"%h%r%t\"))\na.1-14.tga\n\u003e\u003e\u003e print(s.format(\"%l %h%r%t\"))\n7 a.1-14.tga\n\u003e\u003e\u003e print(s.format(\"%l %h%r%t %M\"))\n7 a.1-14.tga [4-9, 11]\n```\n\n## Testing\n\nTo run the unit tests, simply run `pytest` in a shell:\n\n```bash\n$ pytest test/ -s\n```\n\nOr if you don't have `pytest`, you can run:\n\n```bash\n$ python tests/test_pyseq.py\n```","funding_links":[],"categories":["Libraries"],"sub_categories":["File path"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frsgalloway%2Fpyseq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frsgalloway%2Fpyseq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frsgalloway%2Fpyseq/lists"}