{"id":20915779,"url":"https://github.com/brainelectronics/be-helpers","last_synced_at":"2025-05-13T10:33:35.843Z","repository":{"id":58920722,"uuid":"522478535","full_name":"brainelectronics/be-helpers","owner":"brainelectronics","description":"Custom brainelectronics python helper modules","archived":false,"fork":false,"pushed_at":"2023-09-21T13:22:05.000Z","size":33,"stargazers_count":0,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-31T15:47:14.035Z","etag":null,"topics":["helper-functions","helpers","helpers-library","python3"],"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/brainelectronics.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","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":"2022-08-08T09:09:55.000Z","updated_at":"2022-10-23T19:48:50.000Z","dependencies_parsed_at":"2022-09-21T18:52:27.646Z","dependency_job_id":null,"html_url":"https://github.com/brainelectronics/be-helpers","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brainelectronics%2Fbe-helpers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brainelectronics%2Fbe-helpers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brainelectronics%2Fbe-helpers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brainelectronics%2Fbe-helpers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brainelectronics","download_url":"https://codeload.github.com/brainelectronics/be-helpers/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225206833,"owners_count":17438200,"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":["helper-functions","helpers","helpers-library","python3"],"created_at":"2024-11-18T16:18:19.100Z","updated_at":"2024-11-18T16:18:19.623Z","avatar_url":"https://github.com/brainelectronics.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BE Helpers\n\n[![Downloads](https://pepy.tech/badge/be-helpers)](https://pepy.tech/project/be-helpers)\n![Release](https://img.shields.io/github/v/release/brainelectronics/be-helpers?include_prereleases\u0026color=success)\n![Python](https://img.shields.io/badge/python3-Ok-green.svg)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![codecov](https://codecov.io/github/brainelectronics/be-helpers/branch/main/graph/badge.svg)](https://app.codecov.io/github/brainelectronics/be-helpers)\n\nCustom brainelectronics python helper modules\n\n---------------\n\n## General\n\nCollection of custom brainelectronics specific python helper modules.\n\n\u003c!-- MarkdownTOC --\u003e\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [Contributing](#contributing)\n\t- [Unittests](#unittests)\n- [Credits](#credits)\n\n\u003c!-- /MarkdownTOC --\u003e\n\n\n## Installation\n\n```bash\npip install be-helpers\n```\n\n## Usage\n\n```python\nfrom be_helpers import ModuleHelper\nimport time\nfrom pathlib import Path\n\n# default name is 'be_helpers.module_helper'\nmy_logger = ModuleHelper.create_logger()\n\n# set logger level to INFO\nModuleHelper.set_logger_verbose_level(logger=my_logger, verbose_level=3)\n\n# check 'a' to be an option of ['a', 'b', 'c'], result will be True\nresult = ModuleHelper.check_option_values(options=['a', 'b', 'c'], option='a')\nprint('\"a\" is an option of [\"a\", \"b\", \"c\"]: {}'.format(result))\n# \"a\" is an option of [\"a\", \"b\", \"c\"]: True\n\n# get current unix timestamp and format it\nnow = ModuleHelper.get_unix_timestamp()\ntime_format = \"%H:%M:%S\"\nprint('{}'.format(ModuleHelper.format_timestamp(timestamp=now, format=time_format)))\n# 11:30:01\n\n# create a random character number string of length 10\nprint('{}'.format(ModuleHelper.get_random_string(length=10)))\n# 235LS5AY6BPC\n\n# convert a string to a \"uint16_t\" list, useful for Modbus communications\nresult = ModuleHelper.convert_string_to_uint16t(content=\"test\")\nprint('\"test\" as uint16_t: {}'.format(result))\n# \"test\" as uint16_t: [29797, 29556]\n\n# check for valid files or folders\nhere = ModuleHelper.get_full_path('.')\nModuleHelper.check_file(here / 'README.md', '.md')\n# True\n\nModuleHelper.check_folder(here)\n# True\n\n# load YAML or JSON files as dictionaries\nconfig = ModuleHelper.load_dict_from_file(here / 'tests/data/valid.json')\nconfig = ModuleHelper.load_dict_from_file(here / 'tests/data/valid.yaml')\n# {'key': 'val', 'key2': {'key_nested': 'val_nested'}, 'key3': ['asdf', 123, {'key4': 'val4'}]}\n\n# save dictionaries as JSON or YAML files\nModuleHelper.save_dict_to_file(path=here / 'example/cfg.json', content=config)\nModuleHelper.save_dict_to_file(path=here / 'example/cfg.yaml', content=config)\n# True\n```\n\n## Contributing\n\n### Unittests\n\nRun the unittests locally with the following command after installing this\npackage in a virtual environment\n\n```bash\n# run all tests\nnose2 --config tests/unittest.cfg\n\n# run only one specific tests\nnose2 tests.test_module_helper.TestModuleHelper.test_set_logger_verbose_level\n```\n\nGenerate the coverage files with\n\n```bash\npython create_report_dirs.py\ncoverage html\n```\n\nThe coverage report is placed at `be-helpers/reports/coverage/html/index.html`\n\n## Credits\n\nBased on the [PyPa sample project][ref-pypa-sample].\n\n\u003c!-- Links --\u003e\n[ref-pypa-sample]: https://github.com/pypa/sampleproject\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrainelectronics%2Fbe-helpers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrainelectronics%2Fbe-helpers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrainelectronics%2Fbe-helpers/lists"}