This release is a pre-release and may not be stable for production use.
Argteller
The argteller package provides the class and method decorators for a self-documenting, highly user-friendly interactive class object constructor. It will ask you for parameters that you need to provide, one by one. It will tell you the options that are available, and ask you for different parameters depending on what you have already provided. You can encode all of these in the custom DSL (domain specific language) script.
Install
pip install argteller
Getting started: topics and parameters
To start using argteller, you must first create a DSL script, either in the form of a text file or a string value. This script contains the names of the parameters as well as other auxiliary information, which we will go over in detail.
The first two, and most basic, pieces of information are: topic and parameter. The name of a topic is just a line of string. The name of a parameter is a line of string preceded by -. Let’s look at an example:
person <--- topic -height <--- parameter -weight -name
We will now apply this DSL script to a Python class. First we need to import the class decorator. Also, we need to put the script either as a string variable or a text file, in which case, we need the path to the file. Let’s assume this variable is string.
from argteller import ArgtellerClassDecorator
@ArgtellerClassDecorator(map_str=string)
class MyClass():
def __init__(self):
print('Finally!')
my_object = MyClass()
Running the above code will parse the script into tree data structure and prompt the user for the required arguments by recursively traversing down this tree, giving appropriate prompts for the given node.
✔ Checking person requirements... Failed! Required argument(s): ► height weight name
Providing an argument for one of the parameter will prompt different set of required arguments:
my_object = MyClass(height=189, name='Tim')
✔ Checking person requirements... Failed! Required argument(s): ► weight
You could have multiple topics:
person <--- topic -height -weight -name other_details <--- 2nd topic -hobby -major
It will check them one by one, providing the user an opportunity to partition and organize the parameters by topics:
my_object = MyClass(height=189, weight=80, name='Tim',
hobby='basketball')
✔ Checking person requirements... Passed! ✔ Checking other_details requirements... Failed! Required argument(s): ► major
Once you provide all the required parameters, the original __init__ method will be called.
my_object = MyClass(height=189, weight=80, name='Tim',
hobby='basketball', major='math')
✔ Checking person requirements... Passed! ✔ Checking other_details requirements... Passed! Finally!
At this point, all of the parameters are accessible as object fields, anywhere as if they were always there, including from within the __init__ method as well as any other instance methods.
print(my_object.major)
print(my_object.name)
Available options
You can specify available options by preceding the name with a tab and = character:
person
-height
-weight
-name
other_details
-hobby
=basketball <--- available options
=soccer
-major
my_object = MyClass(height=189, weight=80, name='Tim')
✔ Checking person requirements... Passed! ✔ Checking other_details requirements... Failed! Required argument(s): ► hobby major Available [ hobby ] options: ► basketball soccer
Conditional parameters
What if there is a parameter that’s needed only if the hobby is basketball, such as style, that could be indoor or outdoor?
person
-height
-weight
-name
other_details
-hobby
=basketball
-style <--- conditional parameter
=indoor
=outdoor
=soccer
-major
my_object = MyClass(height=189, weight=80, name='Tim',
hobby='basketball')
✔ Checking person requirements... Passed! ✔ Checking other_details requirements... Failed! Required argument(s): ► major Required argument(s) for [ basketball ] hobby: ► style Available [ style ] options: ► indoor outdoor
Optional parameters
You could also have optional parameters, which are parameters that you can leave empty and still pass the topic requirement. For these you use + character.
person
-height
-weight
-name
+gender <--- you can provide this parameter or not
other_details
-hobby
=basketball
-style
=indoor
=outdoor
=soccer
-major
my_object = MyClass(height=189, weight=80, name='Tim',
hobby='basketball')
✔ Checking person requirements... Passed! ✔ Checking other_details requirements... Failed! Required argument(s): ► major Required argument(s) for [ basketball ] hobby: ► style Available [ style ] options: ► indoor outdoor Optional argument(s) for person: ► gender
Boolean parameter conditioned parameter
You could have a parameter whose value is either True or False, and perhaps a conditional parameter depends on this boolean parameter. For these you use ? character. For example:
person
-height
-weight
-name
+gender
other_details
-hobby
-major
?has_car <--- only ask for car_brand if this person has_car
-car_brand
my_object = MyClass(height=189, weight=80, name='Tim',
hobby='basketball', has_car=True)
✔ Checking person requirements... Passed! ✔ Checking other_details requirements... Failed! Required argument(s): ► major Required argument(s) for [ has_car ] option: ► car_brand Optional argument(s) for person: ► gender
String examples of the parameter values
You could provide example for the parameter value with explicit string values. For these you use == characters.
person
-height
-weight
-name
+gender
other_details
-hobby
-major
?has_car
-car_brand
=='Toyota', 'BMW', 'Tesla' <--- string examples of the value
my_object = MyClass(height=189, weight=80, name='Tim',
hobby='basketball', has_car=True)
✔ Checking person requirements... Passed! ✔ Checking other_details requirements... Failed! Required argument(s): ► major Required argument(s) for [ has_car ] option: ► car_brand Examples for [ car_brand ]: 'Toyota', 'BMW', 'Tesla' Optional argument(s) for person: ► gender
Conditional parameter value assignement
Lastly, you can assign a value to a parameter depending on which available option argument was chosen:
person
-height
-weight
-name
+gender
other_details
-hobby
=basketball
-style
=indoor
=outdoor
=soccer
=coding
-major:'comp-sci'
-major
my_object = MyClass(height=189, weight=80, name='Tim',
hobby='coding')
✔ Checking person requirements... Passed! ✔ Checking other_details requirements... Passed! Optional argument(s) for person: ► gender Finally!
This object now has comp-sci string value assigned to major field because we chose coding option for the hobby parameter:
print(my_object.major) # comp-sci
Subtopics
In case there are too many parameters to cover under one topic, but you feel reluctant to branch it out into a separate topic, you have an option of using subtopic. The subtopic only differs in that it adds a tab.
main_topic
sub_topic1
-param1
-param2
sub_topic2
-param3
-param4
my_object = MyClass(param1=1, param2=2)
✔ Checking main_topic requirements... ⮑ sub_topic1 requirements... Passed! ⮑ sub_topic2 requirements... Failed! Required argument(s): ► param3 param4
Metadata
Release files for argteller-orig 0.0b21
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| argteller_orig-0.0b21.tar.gz | 11.5 kB | Without provenance | Details for argteller_orig-0.0b21.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| argteller_orig-0.0b21-py3-none-any.whl | Python 3 | none | any | Details for argteller_orig-0.0b21-py3-none-any.whl |
Total release size: 29.3 kB
Release files / argteller_orig-0.0b21.tar.gz
| Download URL | argteller_orig-0.0b21.tar.gz |
|---|---|
| Size | 11.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
74bbfb49e7f23143df8a8e0da207d87d71aeb3c3e050721b4522e9dd2b2dec40
|
|
BLAKE2b-256 checksum How to use checksums |
b6cea934e1658a8a62a841fe2ce2aa0f0bfced389ab337eef9d0c37417ddedd5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.7.8
|
Release files / argteller_orig-0.0b21-py3-none-any.whl
| Download URL | argteller_orig-0.0b21-py3-none-any.whl |
|---|---|
| Size | 17.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c42b3ba4ff804d183e9e3b39c7155e0c0841037577fa3345781c9c58eec41690
|
|
BLAKE2b-256 checksum How to use checksums |
27dea4c15859410086bae6d1e27e8a7173644642096110b1892da6e0fc2a2740
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.7.8
|
Security for argteller-orig 0.0b21
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.