Metadata-Version: 2.1
Name: strfix
Version: 0.0.1
Summary: Literal Enum
Home-page: https://github.com/dsm-72/strfix
Author: dsm-72
Author-email: sumner.magruder@yale.edu
License: Apache Software License 2.0
Keywords: nbdev jupyter notebook python
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
License-File: LICENSE
Provides-Extra: dev

# strfix

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

## Developer Guide

### Setup

``` sh
# create conda environment
$ mamba env create -f env.yml

# update conda environment
$ mamba env update -n strfix --file env.yml
```

### Install

``` sh
pip install -e .

# install from pypi
pip install strfix
```

### nbdev

``` sh
# activate conda environment
$ conda activate strfix

# make sure the strfix package is installed in development mode
$ pip install -e .

# make changes under nbs/ directory
# ...

# compile to have changes apply to the strfix package
$ nbdev_prepare
```

### Publishing

``` sh
# publish to pypi
$ nbdev_pypi

# publish to conda
$ nbdev_conda --build_args '-c conda-forge'
$ nbdev_conda --mambabuild --build_args '-c conda-forge -c dsm-72'
```

# Usage

## Installation

Install latest from the GitHub
[repository](https://github.com/dsm-72/strfix):

``` sh
$ pip install git+https://github.com/dsm-72/strfix.git
```

or from [conda](https://anaconda.org/dsm-72/strfix)

``` sh
$ conda install -c dsm-72 strfix
```

or from [pypi](https://pypi.org/project/strfix/)

``` sh
$ pip install strfix
```

## Documentation

Documentation can be found hosted on GitHub
[repository](https://github.com/dsm-72/strfix)
[pages](https://dsm-72.github.io/strfix/). Additionally you can find
package manager specific guidelines on
[conda](https://anaconda.org/dsm-72/strfix) and
[pypi](https://pypi.org/project/strfix/) respectively.

## Examples

### Prefix

``` python
class X_(Prefix):
    fix: ClassVar[str] = 'X' # The character used to prefix the string
    sep: ClassVar[str] = '_' # The separator used to split the prefix into parts
    chainable: ClassVar[bool] = False
    add_w_sep: ClassVar[bool] = True
    pass
```

``` python
xa = X_('a')
xb = X_('b')
da = dict(X_a='hi', X_b=2)
xa, xb, da
```

    (X_a, X_b, {'X_a': 'hi', 'X_b': 2})

``` python
'hi' + xa, f'hi{xa}'
```

    ('hi_X_a', 'hiX_a')

``` python
xa + xb, xa + xa, xb + xb
```

    (X_a_b, X_a_a, X_b_b)

### Postfix

``` python
class _hvg(Postfix):
    fix: ClassVar[str] = 'hvg' # The character used to prefix the string
    sep: ClassVar[str] = '_'   # The separator used to split the prefix into parts
    chainable: ClassVar[bool] = True
    add_w_sep: ClassVar[bool] = True
    pass
```

``` python
xa = _hvg('a')
xb = _hvg('b')
da = dict(a_hvg='hi', b_hvg=2)
xa, xb, da
```

    (a_hvg, b_hvg, {'a_hvg': 'hi', 'b_hvg': 2})

``` python
'hi' + xa, f'hi{xa}', 'hi' + xa + xb
```

    (hi_a_hvg, 'hia_hvg', hi_a_b_hvg)

``` python
xa + xb, xa + xa, xb + xb
```

    (a_b_hvg, a_a_hvg, b_b_hvg)

### Extension

``` python
GZ = Ext('....gz')
GZ.isaxv(GZ), GZ, GZ.addp('gz')
```

    (True, .gz, '.gz')

``` python
'file' + GZ, f"{'file'}{GZ}", GZ + GZ
```

    ('file.gz', 'file.gz', '.gz.gz')
