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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
lineopt-0.0.3.tar.gz
(3.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lineopt-0.0.3.tar.gz.
File metadata
- Download URL: lineopt-0.0.3.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ca344c735aebab595f12e0e016024365e1b8575020e99079e51994e1685fbcd
|
|
| MD5 |
653183862fc1dd95e622673c25db4c10
|
|
| BLAKE2b-256 |
54d5dcb0989b3268887039f89cd343637d8a4b11653d417919af96698f349d1b
|
File details
Details for the file lineopt-0.0.3-py3-none-any.whl.
File metadata
- Download URL: lineopt-0.0.3-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9492e98a348f9316035583e76c776e50af846cc38c0049a2eb5babdd3f7fbb8a
|
|
| MD5 |
320f41987e90bf0816a005bfbb98d923
|
|
| BLAKE2b-256 |
c9eb4bbe1ae8afed4cae756720b7d6fd567f8191bbd22110f0f2b034f8ad2c2e
|