A flexible framework for Python
Project description
scake
A flexible framework for Python
License | Travis CI | Master: Dev: |
|
Version | Coverage | Master: Dev: |
|
Wheel | Implementation | ||
Status | Downloads | ||
Supported versions |
USAGE
Hello World with Scake
First, let's define the settings in YAML format.
settings.yaml
my_settings:
hello_message: "Hello World!"
printer:
$MyPrinter:
message: =/my_settings/hello_message
result(): __call__
In the above settings, we define the "hello_message" component holding our message: "Hello World!". The reference to it is "=/my_settings/hello_message" (very similar to file path system), first character "=" is annotation for component reference.
At the "printer" component, we initialize an instance of class "MyPrinter" (annotated by $MyPrinter) and pass the message content to its constructor. After initializing instance successfully, Scake will execute the "call" function and assign the result to component at "/printer/result()". Open and close parenthesis annotates a method component in Scake.
hello.py
# -*- coding: utf-8 -*-
import sys
import yaml
from scake import Scake
class MyPrinter:
def __init__(self, message):
self.message = message
def __call__(self):
print(self.message)
def main(yaml_path):
with open(yaml_path) as f:
config = yaml.safe_load(f)
s = Scake(config, class_mapping=globals())
s.run()
pass
if __name__ == "__main__":
main(yaml_path="settings.yaml")
Run the following command for your first "Hello World!":
$ python3 hello.py
Hello World!
FEATURES TO-DO
- Support loop
- Support flow reference
- Support integration tests
- Support generating class templates
- Import custom packages automatically
RELEASED FEATURES
v0.2.0
- Big refactoring in how we do initializing instances and executing code flow
- Remove generating class templates based on YAML
v0.1.0
- Automatically initialize Class instances from YAML description.
- Code flow is built and executed properly by checking attribute dependencies.
- Generate class templates based on YAML description.
CONTRIBUTING
- Step 1. Fork on dev branch.
- Step 2. Install pre-commit on the local dev environment.
pip install pre-commit
pre-commit install
- Step 3. Write test case(s) for the new feature or the bug.
- Step 4. Write code to pass the tests.
- Step 5. Make sure that the new code passes all the pre-commmit conditions.
pre-commit run -a
- Step 6. Create pull request.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for scake-0.2.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 587c58c6ecab34416d67387f01a1b09cc4217c982dfa0cad2d81894dfc8e1622 |
|
MD5 | 0523c907496be56dc32d099d8ad3bf8e |
|
BLAKE2b-256 | 1e7cfa734b42c1d8680e802f1c98ea78f41ea4f71cbaab78728402feaa2eece7 |