semvec/pypi-packages huggingface dataset:
nr.config 0.2.0
Utility library to implement composable YAML configuration files.
License: MIT
Requires Python: >=3.4.0,<4.0.0

> Note: This package is in the dangerous land of `0.x.y` versions and may be subject to breaking
> changes with minor version increments.

# nr.config

The `nr.config` package helps with configuration file processing and dynamic reloading tasks.
It can serve as a generic library or give you a fast and easy framework.

## Quickstart

The `nr.config.process_config()` function is the main function for processing config data. It
expects the data to process as well as a number of processor plugins that will run over config.
A common pattern is to use a `conf` section to hydrate variables for the remainder of the
configuration.

```py
from nr.config import process_config
from nr.config.plugins import Vars
import yaml

with open('var/conf/runtime.yaml') as fp:
  data = yaml.safe_load(fp)

config = process_config(data['runtime'], Vars({'conf': data['conf']}))
```

This particular example allows the use of references in the `runtime` block.

```yaml
conf:
  value: 42
runtime:
  answer: '{{conf.value}}'
```

Service applications may want to reload the configuration file whenever it changes. For this
purpose the `nr.config` module provides the `ConfigReloadTask` that uses the `watchdog` module
to observe file changes and reload the config when the file changes. Errors that occur during
the reload are automatically logged and the last valid configuration will be returned.

```py
from nr.config.reloader import ConfigReloadTask
from nr.proxy import Proxy

reload_task = ConfigReloadTask('var/conf/runtime.yaml', load_config_from_file)
reload_task.reload_callback(callback)
reload_task.start()
config = Proxy(reload_task.get)
```

---

<p align="center">Copyright &copy; 2020 Niklas Rosenstein</p>
nr.parsing.core 2.0.4
A simple API to scan and tokenize text for the purpose of structured language processing.
License: MIT
Requires Python: >=3.6.0,<4.0.0

# nr.parsing.core

The `nr.parsing.core` package provides a simple API to scan and tokenize text for the purpose of
structured langauge processing.

## Example

```py
from nr.parsing.core import RuleSet, Tokenizer, rules

ruleset = RuleSet()
ruleset.rule('number', rules.regex_extract(r'\-?(0|[1-9]\d*)', 0))
ruleset.rule('operator', rules.regex_extract(r'[\-\+]', 0))
ruleset.rule('whitespace', rules.regex(r'\s+'), skip=True)

def calculate(expr: str) -> int:
  tokenizer = Tokenizer(ruleset, expr)
  result = 0
  sign: t.Optional[int] = 1
  while tokenizer:
    if tokenizer.current.type != 'number':
      raise ValueError(f'unexpected token {tokenizer.current}')
    assert sign is not None
    result += sign * int(tokenizer.current.value)
    tokenizer.next()
    if tokenizer.current.type == 'operator':
      sign = -1 if tokenizer.current.value == '-' else 1
      tokenizer.next()
    else:
      sign = None
  if sign is not None:
    raise ValueError(f'unexpected trailing operator')
  return result

assert calculate('3 + 5 - 1') == 7
```

---

<p align="center">Copyright &copy; 2020 Niklas Rosenstein</p>
nr.pylang.utils 0.1.3
Package description here.
License: MIT
Requires Python: >=3.6.0,<4.0.0

> Note: This package is in the dangerous land of `0.x.y` versions and may be subject to breaking
> changes with minor version increments.

# nr.pylang.utils

Utilities for Python constructs (class and function definitions, exception
handling, modules and type annotations).

__Note__: `typing` is an optional dependency and is thus not listed in the
requirements for this package.

---

<p align="center">Copyright &copy; 2020 Niklas Rosenstein</p>
nr.utils.re 0.3.1
This module provides some utility functions for applying regular expressions.
License: MIT
Requires Python: >=3.6.0,<4.0.0

> Note: This package is in the dangerous land of `0.x.y` versions and may be subject to breaking
> changes with minor version increments.

# nr.utils.re

This module provides some utility functions for applying regular expressions.

## Contents

* `match_all(expr, string)`: Matches *expr* from the start of *string* and expects that it can be
  matched throughout. If it fails to consume the full string, a `MatchAllError` will be raised.
  (Note that this exception class is also accessible as `match_all.Error`).

---

<p align="center">Copyright &copy; 2020 Niklas Rosenstein</p>