{"id":20126698,"url":"https://github.com/cc-d/pyshared","last_synced_at":"2026-01-30T19:04:47.188Z","repository":{"id":230777284,"uuid":"741728175","full_name":"cc-d/PyShared","owner":"cc-d","description":"Shared utility lib for python, previously MyFuncs","archived":false,"fork":false,"pushed_at":"2024-06-05T16:49:36.000Z","size":136,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-07T04:27:36.576Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/cc-d.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2024-01-11T01:39:56.000Z","updated_at":"2024-06-05T16:49:39.000Z","dependencies_parsed_at":"2024-04-08T00:32:51.911Z","dependency_job_id":"a5c523e9-1f3f-4daa-8290-26dc9725c0c3","html_url":"https://github.com/cc-d/PyShared","commit_stats":null,"previous_names":["cc-d/pyshared"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cc-d/PyShared","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cc-d%2FPyShared","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cc-d%2FPyShared/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cc-d%2FPyShared/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cc-d%2FPyShared/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cc-d","download_url":"https://codeload.github.com/cc-d/PyShared/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cc-d%2FPyShared/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28917458,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-30T16:37:38.804Z","status":"ssl_error","status_checked_at":"2026-01-30T16:37:37.878Z","response_time":66,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2024-11-13T20:17:18.620Z","updated_at":"2026-01-30T19:04:47.171Z","avatar_url":"https://github.com/cc-d.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PyShared\n\nPyShared is a Python utility library providing a collection of functions and constants I've found useful across multiple projects.\n\nIt also has several common aliases I use for typehints and common imports.\n\n## Installation\n\nTo incorporate PyShared into your project, use pip for installation:\n\n```bash\npip install pyshared\n# To include development dependencies:\npip install pyshared[dev]\n```\n\n## Feature Overview\n\n### `args.py`\n\n-\n\n### `consts.py`\n\n- `ALPHANUMERIC_CHARS`: A string of alphanumeric characters.\n- `ALPHANUMERIC_EXT_CHARS`: Alphanumeric characters, including underscores and hyphens.\n\n### `crypto.py`\n\n- `is_jwt`: Simply verifies if a string looks like a JSON Web Token (JWT)\n\n### `env.py`\n\n- `typed_evar`: Retrieves and type-casts environment variables.\n\nExamples: (input, default, type, expected_output)\n\n```\n'evname, ev, default, vartype, expected',\n    # with default arg\n    ('evname', '0', 0, None, 0),\n    # this shouldnt ever happen but if it does, it should raise error\n    (None, None, '20.1', int, ValueError),\n    (None, None, None, float, ValueError),\n    # assumed typing\n    ('evname', '0.0', None, None, 0.0),\n    ('evname', '0.', None, None, '0.'),\n    ('evname', '.0', None, None, 0.0),\n    ('evname', 'True', None, None, True),\n    ('evname', 'tRuE', None, None, True),\n    ('evname', 'false', None, None, False),\n    ('evname', 'fAlSe', None, None, False),\n    ('evname', '0', None, None, 0),\n    ('evname', '0', True, None, False),\n    ('evname', '0', False, None, False),\n    ('evname', '0', None, bool, True),\n    ('evname', '0', None, int, 0),\n    ('evname', '0', 1.0, float, 0.0),\n    ('evname', '0', None, float, 0.0),\n    ('evname', 'true', None, str, 'true'),\n    ('evname', 'test', True, None, ValueError),\n    ('evname', 'test', None, int, ValueError),\n    ('evname', 'test', 1, None, ValueError),\n```\n\n### `exceptions.py`\n\n- `NotPrintableError`: Both str and repr methods raised exceptions.\n\n### `python.py`\n\n- `HumanTime`: A class for converting seconds to human-readable time strings.\n- `UniqueList`: A list that only allows unique elements.\n- `default_repr`: Generates a default representation for custom objects.\n- `htime`: A function for converting seconds to human-readable time strings.\n- `ranstr`: Creates random strings of specified length and character set.\n- `safe_repr`: Safely returns the object's repr/str or an error string without throwing exceptions if the object is not printable.\n- `tmp_pythonpath`: Adds a temporary directory to the Python path for the duration of a context manager.\n- `truncstr`: Truncates a string, preserving a portion from the start and/or end.\n\n### `pytest.py`\n\n- `multiscope_fixture`: Creates multiple scoped pytest fixture and ensures the fixtures are available in the module.\n\n### `shell.py`\n\nShell command execution within Python.\n\n- `runcmd`: Executes a command in the system shell.\n\n### `terminal.py`\n\nTerminal utilities for improved user interaction.\n\n- `get_terminal_width`: Safely retrieves the terminal width, defaulting to 80 columns on failure.\n- `print_middle`: Centers text within left/right padding based on terminal width.\n- `print_columns`: Arranges a list of strings into guestimated $x length strings based on what is approximately optimal for the contents/terminal width.\n\n### `tests.py`\n\n- `RanData`: A class for generating random data for testing purposes.\n\n## Test Coverage\n\nnot quite 100% lol\n\n```\n---------- coverage: platform darwin, python 3.9.18-final-0 ----------\nName                     Stmts   Miss  Cover   Missing\n------------------------------------------------------\npyshared/__init__.py        17      0   100%\npyshared/consts.py           3      0   100%\npyshared/crypto.py          21      0   100%\npyshared/env.py             34      3    91%   30, 42, 54\npyshared/exceptions.py       8      0   100%\npyshared/pytest.py          12      0   100%\npyshared/python.py          69      3    96%   40, 63, 139\npyshared/shell.py            9      0   100%\npyshared/terminal.py        34      0   100%\npyshared/test.py            54      0   100%\npyshared/version.py          1      0   100%\n------------------------------------------------------\nTOTAL                      262      6    98%\n```\n\n## License\n\nMIT\n\n## Contact\n\nccarterdev@gmail.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcc-d%2Fpyshared","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcc-d%2Fpyshared","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcc-d%2Fpyshared/lists"}