Metadata-Version: 2.1
Name: bytetype
Version: 0.0.4
Summary: byte type
Home-page: https://github.com/dsm-72/bytetype
Author: dsm-72
Author-email: sumner.magruder@yale.edu
License: Apache Software License 2.0
Keywords: nbdev jupyter notebook python byte bytes kilo tera giga unit dataclass strenum
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3.11
Classifier: License :: OSI Approved :: Apache Software License
Requires-Python: >=3.11
Description-Content-Type: text/markdown
Provides-Extra: dev
License-File: LICENSE

# bytetype

<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

A simple Byte type

## Install

``` sh
pip install bytetype
```

## Usage

**NOTE** that: -
[`ByteSize`](https://dsm-72.github.io/bytetype/enums.html#bytesize)
corresponds to the base numeric value to use i.e. `1024` -
[`BytesUnit`](https://dsm-72.github.io/bytetype/enums.html#bytesunit)
corresponds to the string unit to use i.e. `"KB"`

### Examples

#### Enums

##### get byte sizes

``` python
ByteSize.memdict
```

##### get byte size index

``` python
{k: bytes_idx(v) for k, v in ByteSize.items}
```

##### convert unit to size

``` python
BytesUnit.from_bytes(ByteSize.MB), BytesUnit.from_bytes(ByteSize.GB)
```

#### Convert bytes to size

``` python
{k: bytes_to_size(v * (2*i+1)) for i, (k, v) in enumerate(ByteSize.items)}
```

``` python
{bytes_to_size(ByteSize.KB * i) for i in range(1, 10)}
```

#### Iterate over files

``` python
for e in os.listdir():
    print(e, Bytes.from_file(e))
```
