-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.md.j2
101 lines (73 loc) · 3.02 KB
/
README.md.j2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<table>
<tr>
<td colspan=2>
<strong>{{project.name}}</strong>
<a href={{pypi.project_url}}><img src="https://img.shields.io/pypi/l/{{project.name}}.svg"></a>
<a href={{pypi.project_url}}><img src="https://badge.fury.io/py/{{project.name}}.svg"></a>
{%for action in github.actions%}<a href="{{action.url}}"><img src="{{action.url}}/badge.svg"></a>{%endfor%}
</td>
</tr>
<tr>
<td width=15%><img src={{github.raw_url}}/master/img/icon.png style="width:150px"></td>
<td>
Python application framework
</td>
</tr>
</table>
{{markdown_toc(__template__, level=2)}}
---------------------------------------------------------------------
## Overview
*(This is experimental; API-stability is not guaranteed.)*
Batteries-included application framework for python, including all the stuff you get tired of building from scratch: Logging, CLI parsing, exit-handlers, data-structures and more.
---------------------------------------------------------------------
## Features
* Conventions for handling logging
* CLI parsing with [click](https://click.palletsprojects.com/en/8.1.x/)
* Console output with [rich](https://rich.readthedocs.io/en/stable/index.html)
* Exit-handlers
* Plugin Framework
---------------------------------------------------------------------
## Installation
See [pypi](https://pypi.org/project/fleks/) for available releases.
```bash
pip install fleks
```
---------------------------------------------------------------------
## Usage
See also [the unit-tests](tests/units) for more examples of library usage.
### Tags & Tagging
```python
>>> from fleks import tagging
>>> class MyClass(): pass
>>> tagging.tags(key="Value")(MyClass)
<class '__main__.MyClass'>
>>> assert tagging.tags[MyClass]['key']=="Value"
>>>
```
### Class-Properties
```python
>>> import fleks
>>> class Test:
... @fleks.classproperty
... def testing(kls):
... return 42
>>> assert Test.testing==42
>>>
```
### Typing helpers
[fleks.util.typing](src/fleks/util/typing.py) collects common imports and annotation-types, i.e. various optional/composite types used in type-hints, underneath one convenient namespace. This includes stuff from:
* [stdlib's `typing`](https://docs.python.org/3/library/typing.html)
* [stdlib's `types`](https://docs.python.org/3/library/types.html)
* [pydantics BaseModel's and Field's, etc](https://docs.pydantic.dev/latest/usage/fields/)
```
>>> from fleks import typing
>>> print(sorted([name for name in dir(typing) if name.title()==name]))
['Annotated', 'Any', 'Awaitable', 'Bool', 'Callable', 'Collection', 'Container', 'Coroutine', 'Counter', 'Deque', 'Dict', 'Field', 'Final', 'Generator', 'Generic', 'Hashable', 'Iterable', 'Iterator', 'List', 'Literal', 'Mapping', 'Match', 'Namespace', 'Optional', 'Pattern', 'Protocol', 'Reversible', 'Sequence', 'Set', 'Sized', 'Text', 'Tuple', 'Type', 'Union']
>>>
```
### Base-classes for Configuration
```python
>>> from fleks import Config
>>>
```
---------------------------------------------------------------------