Name | nanos JSON |
Version |
0.1.8
JSON |
| download |
home_page | https://github.com/aleosd/nanos |
Summary | Collection of small utility-functions |
upload_time | 2025-08-28 13:53:29 |
maintainer | None |
docs_url | None |
author | Alex |
requires_python | <4.0,>=3.10 |
license | Apache-2.0 |
keywords |
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Nanos

*Nanos* is a collection of small but handy Python utilities: different
functions, classes and mixins. The library has zero dependencies and relies
only on built-in Python modules.
Complete documentation: https://nanos.readthedocs.io/en/latest/index.html
## Features
* **Data Processing** - Utilities for working with data structures (chunking, ID mapping, empty value handling)
* **Date & Time** - Helper functions for common date operations and time measurements
* **Formatting** - Human-readable formatting for data types (file sizes, etc.)
* **Logging** - Simple logging setup and convenient LoggerMixin
* **Zero Dependencies** - Works with just the Python standard library
## Installation
Library is available on PyPI and can be installed using pip:
```bash
pip install nanos
```
## Quick Examples
### Format file sizes
```python
from nanos import fmt
print(fmt.size(1024)) # 1.00 KiB
print(fmt.size(1572864)) # 1.50 MiB
print(fmt.size(3.5 * 10**9)) # 3.26 GiB
```
### Measure execution time
```python
import time
from nanos import time as ntime
with ntime.Timer() as t:
time.sleep(1.5)
print(t.elapsed) # 1.5033...
print(t) # 0:00:01.50
```
### Date helpers
```python
from nanos import dt
import datetime
# Get tomorrow's date in UTC
tomorrow = dt.tomorrow()
# Get yesterday's start/end timestamps
day_start = dt.yesterday_start()
day_end = dt.yesterday_end()
```
### Data processing
```python
from nanos import data
# Split a list into chunks
chunks = data.chunker(range(10), 3) # [[0, 1, 2], [3, 4, 5], [6, 7, 8], [9]]
# Convert a list of objects to a dict indexed by ID
users = [{"id": 1, "name": "Alice"}, {"id": 2, "name": "Bob"}]
users_by_id = data.idfy(users) # {1: {"id": 1, "name": "Alice"}, 2: {"id": 2, "name": "Bob"}}
# Remove empty values from nested data
cleaned = data.remove_empty_members({"user": {"name": "Alice", "bio": ""}}) # {"user": {"name": "Alice"}}
```
### Simple logging setup
```python
from nanos import logging
# Get a pre-configured logger with console output
logger = logging.get_simple_logger(name="myapp")
logger.info("Application started") # 2023-05-01T12:34:56 myapp INFO Application started
# Use LoggerMixin in your classes
class MyService(logging.LoggerMixin):
def process(self):
self.logger.debug("Processing started") # mypackage.MyService DEBUG Processing started
```
## Type Hinting
Nanos is fully typed and includes a `py.typed` marker file for better IDE support.
## License
The library is released under the [Apache License 2.0](LICENSE)
Raw data
{
"_id": null,
"home_page": "https://github.com/aleosd/nanos",
"name": "nanos",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.10",
"maintainer_email": null,
"keywords": null,
"author": "Alex",
"author_email": "aleosd@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/ee/52/ed9d23dac504de0040bbd0208ee7af15ae930b699785c3eac51b1564037e/nanos-0.1.8.tar.gz",
"platform": null,
"description": "# Nanos\n\n\n\n*Nanos* is a collection of small but handy Python utilities: different\nfunctions, classes and mixins. The library has zero dependencies and relies\nonly on built-in Python modules.\n\nComplete documentation: https://nanos.readthedocs.io/en/latest/index.html\n\n## Features\n\n* **Data Processing** - Utilities for working with data structures (chunking, ID mapping, empty value handling)\n* **Date & Time** - Helper functions for common date operations and time measurements\n* **Formatting** - Human-readable formatting for data types (file sizes, etc.)\n* **Logging** - Simple logging setup and convenient LoggerMixin\n* **Zero Dependencies** - Works with just the Python standard library\n\n## Installation\n\nLibrary is available on PyPI and can be installed using pip:\n\n```bash\npip install nanos\n```\n\n## Quick Examples\n\n### Format file sizes\n\n```python\nfrom nanos import fmt\n\nprint(fmt.size(1024)) # 1.00 KiB\nprint(fmt.size(1572864)) # 1.50 MiB\nprint(fmt.size(3.5 * 10**9)) # 3.26 GiB\n```\n\n### Measure execution time\n\n```python\nimport time\nfrom nanos import time as ntime\n\nwith ntime.Timer() as t:\n time.sleep(1.5)\n\nprint(t.elapsed) # 1.5033...\nprint(t) # 0:00:01.50\n```\n\n### Date helpers\n\n```python\nfrom nanos import dt\nimport datetime\n\n# Get tomorrow's date in UTC\ntomorrow = dt.tomorrow()\n\n# Get yesterday's start/end timestamps\nday_start = dt.yesterday_start()\nday_end = dt.yesterday_end()\n```\n\n### Data processing\n\n```python\nfrom nanos import data\n\n# Split a list into chunks\nchunks = data.chunker(range(10), 3) # [[0, 1, 2], [3, 4, 5], [6, 7, 8], [9]]\n\n# Convert a list of objects to a dict indexed by ID\nusers = [{\"id\": 1, \"name\": \"Alice\"}, {\"id\": 2, \"name\": \"Bob\"}]\nusers_by_id = data.idfy(users) # {1: {\"id\": 1, \"name\": \"Alice\"}, 2: {\"id\": 2, \"name\": \"Bob\"}}\n\n# Remove empty values from nested data\ncleaned = data.remove_empty_members({\"user\": {\"name\": \"Alice\", \"bio\": \"\"}}) # {\"user\": {\"name\": \"Alice\"}}\n```\n\n### Simple logging setup\n\n```python\nfrom nanos import logging\n\n# Get a pre-configured logger with console output\nlogger = logging.get_simple_logger(name=\"myapp\")\nlogger.info(\"Application started\") # 2023-05-01T12:34:56 myapp INFO Application started\n\n# Use LoggerMixin in your classes\nclass MyService(logging.LoggerMixin):\n def process(self):\n self.logger.debug(\"Processing started\") # mypackage.MyService DEBUG Processing started\n```\n\n## Type Hinting\n\nNanos is fully typed and includes a `py.typed` marker file for better IDE support.\n\n## License\n\nThe library is released under the [Apache License 2.0](LICENSE)\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "Collection of small utility-functions",
"version": "0.1.8",
"project_urls": {
"Documentation": "https://nanos.readthedocs.io/en/stable/index.html",
"Homepage": "https://github.com/aleosd/nanos",
"Repository": "https://github.com/aleosd/nanos"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "9842f192f6d16822b41ae7a2c2d645b6d0118d28566823f984be925c6ab2db2d",
"md5": "9cc3801faf49e908f7920218f282b741",
"sha256": "cdeb2e129789852ba663deccf471b1cb7764b55dad49dc73bb9fcb67deeffd7e"
},
"downloads": -1,
"filename": "nanos-0.1.8-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9cc3801faf49e908f7920218f282b741",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.10",
"size": 12652,
"upload_time": "2025-08-28T13:53:26",
"upload_time_iso_8601": "2025-08-28T13:53:26.677047Z",
"url": "https://files.pythonhosted.org/packages/98/42/f192f6d16822b41ae7a2c2d645b6d0118d28566823f984be925c6ab2db2d/nanos-0.1.8-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ee52ed9d23dac504de0040bbd0208ee7af15ae930b699785c3eac51b1564037e",
"md5": "7efd64e4f7218810ab55ccb1260e3cb3",
"sha256": "97e3b5c0d9d3c0920b06620befdc4749115a514a68d0550de13fc0289783defa"
},
"downloads": -1,
"filename": "nanos-0.1.8.tar.gz",
"has_sig": false,
"md5_digest": "7efd64e4f7218810ab55ccb1260e3cb3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.10",
"size": 12156,
"upload_time": "2025-08-28T13:53:29",
"upload_time_iso_8601": "2025-08-28T13:53:29.709206Z",
"url": "https://files.pythonhosted.org/packages/ee/52/ed9d23dac504de0040bbd0208ee7af15ae930b699785c3eac51b1564037e/nanos-0.1.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-28 13:53:29",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "aleosd",
"github_project": "nanos",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "nanos"
}