Installing
pip3 install throttle
Usage
import lineopt
# dict w/ extra methods
state = lineopt.State()
@state.sub('echo')
def state_0(argument):
return argument
@state_0.sub('loud')
def state_0_0(argument):
return argument.upper()
flags = {'-c': 'content', '-s': 'meddle'}
@state_0.sub('fancy', flags)
def state_0_1(arguments):
content = arguments['-c']
meddle = arguments.get('-s', ' ')
return meddle.join(content)
starts = ('!', '.')
def parse(value, starts = starts):
try:
(start, names, argument, function) = state.context(starts, value)
except (KeyError, ValueError) as error:
raise
result = repr(error)
else:
result = function(argument)
print(result)
say = 'vocalizing is fun' # argument
parse(f'!echo {say}') # vocalizing is fun
parse(f'.echo.loud {say}') # VOCALIZING IS FUN
parse(f'!echo.fancy -c {say}') # v o c a l i z i n g i s f u n
parse(f'.echo.fancy {say} -s ~') # v~o~c~a~l~i~z~i~n~g~ ~i~s~ ~f~u~n
parse(f'-echo.loud {say}') # ValueError: 'invalid start'
parse(f'.fancy {say}') # KeyError: 'fancy' (only sub of echo)
Links
Metadata
Release files for lineopt 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| lineopt-0.0.4.tar.gz | 3.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| lineopt-0.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.0 kB
Release files / lineopt-0.0.4.tar.gz
| Download URL | lineopt-0.0.4.tar.gz |
|---|---|
| Size | 3.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a09f7bfeb61705322c19427353a22010aefdad59b7aa160d72ff0ad2202c912e
|
|
BLAKE2b-256 checksum How to use checksums |
a9efa6f18156329c53ae3bbd1f5553ef5f298e573d32380eb93e5c4587578f9e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.8.0rc1
|
Release files / lineopt-0.0.4-py3-none-any.whl
| Download URL | lineopt-0.0.4-py3-none-any.whl |
|---|---|
| Size | 3.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c10c6fa909806c8a5c94111f49b3357c92aa1f7b6ebe604b38b19797d409dd90
|
|
BLAKE2b-256 checksum How to use checksums |
7db9c1801f53569da336cc34a8c281686ec31e0b1b1a74b4a476fcc995c9da84
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.8.0rc1
|