{"id":25077881,"url":"https://github.com/paregorios/airtight","last_synced_at":"2025-04-01T01:02:52.699Z","repository":{"id":57409353,"uuid":"106042827","full_name":"paregorios/airtight","owner":"paregorios","description":"Simplify the creation and debugging of command-line python scripts.","archived":false,"fork":false,"pushed_at":"2017-10-09T21:14:20.000Z","size":33,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-07T02:39:57.578Z","etag":null,"topics":["command-line","logging","python","scripts"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/paregorios.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-06T19:30:31.000Z","updated_at":"2017-10-06T19:36:04.000Z","dependencies_parsed_at":"2022-08-24T20:00:09.795Z","dependency_job_id":null,"html_url":"https://github.com/paregorios/airtight","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paregorios%2Fairtight","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paregorios%2Fairtight/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paregorios%2Fairtight/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paregorios%2Fairtight/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paregorios","download_url":"https://codeload.github.com/paregorios/airtight/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246563379,"owners_count":20797448,"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":["command-line","logging","python","scripts"],"created_at":"2025-02-07T02:40:02.944Z","updated_at":"2025-04-01T01:02:52.673Z","avatar_url":"https://github.com/paregorios.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# airtight\n\nIf you're going to ```import antigravity```, you'd better make sure the hatch is closed.\n\nThe **airtight** package is written for Python 3.6+. It provides idiosyncratic code that somewhat simplifies the creation and debugging of command-line python scripts.\n\n## installing\n\n```\npip install airtight\n```\n\n## simpler than a template\n\nInstead of copying some 50-line template for your python script and then writing a bunch of calls to [argparse](https://docs.python.org/3/library/argparse.html) and [logging](https://docs.python.org/3/library/logging.html) just build some lists describing the arguments and logging level you want and invoke ```artight.cli.configure_commandline()```:\n\n```python\n#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\"\"\"\nExample script template using the airtight module\n\"\"\"\n\nfrom airtight.cli import configure_commandline\nimport logging\n\nDEFAULT_LOG_LEVEL = logging.WARNING\nOPTIONAL_ARGUMENTS = [\n    # each argument is a list: short option, long option, default value, \n    # help string, required?\n    ['-l', '--loglevel', 'NOTSET',\n        'desired logging level (' +\n        'case-insensitive string: DEBUG, INFO, WARNING, or ERROR',\n        False],\n    ['-v', '--verbose', False, 'verbose output (logging level == INFO)',\n        False],\n    ['-w', '--veryverbose', False,\n        'very verbose output (logging level == DEBUG)', False],\n    ['-x', '--custom', 7, 'your custom argument', False]\n]\nPOSITIONAL_ARGUMENTS = [\n    # each argument is a list with 3 elements: name, type, help\n    ['foovar', str, 'some input value that you want']\n]\n\n\ndef main(**kwargs):\n    \"\"\"Main function of your script.\n\n    kwargs -- keyword arguments as parsed from the command line\n    \"\"\"\n    # your additional code here\n\n\nif __name__ == \"__main__\":\n    main(**configure_commandline(\n            OPTIONAL_ARGUMENTS, POSITIONAL_ARGUMENTS, DEFAULT_LOG_LEVEL))\n```\n\n\n## make debug logging just a wee bit easier\n\nThe ```airtight.logging``` module provides two methods: ```configure_logging()```, which is used by ```airtight.cli.configure_commandline()```, and ```flog()```, which reduces typing when you want to log a variable's name and value.\n\nSo, you can write:\n\n```python\n\u003e from airtight.logging import flog\n\u003e fish = 'salmon'\n\u003e flog(fish)\nDEBUG:foo_script: fish: 'salmon'\n```\n\n```flog()``` logs to DEBUG by default, but an optional keyword argument ```level``` may be used to specify another standard level, e.g.:\n\n```python\n\u003e from airtight.logging import flog\n\u003e import logging\n\u003e fish = 'salmon'\n\u003e flog(fish, level=logging.WARNING)\nWARNING:foo_script: fish: 'salmon'\n```\n\nAnother optional keyword argument (```comment```) may be specified. A string value supplied via this argument will be postfixed to the logged variable name and value, thus:\n\n```python\n\u003e from airtight.logging import flog\n\u003e fish = 'salmon'\n\u003e flog(fish, comment='I like this fish!')\nDEBUG:foo_script: fish: 'salmon' I like this fish!\n```\n\n## etc.\n\nBug reports and feature requests are welcome, but really I'd prefer pull requests. \n\n## todo\n\n - docstrings\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparegorios%2Fairtight","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparegorios%2Fairtight","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparegorios%2Fairtight/lists"}