A flexible framework for Python
A flexible framework for Python
Hello World with Scake
First, let's define the settings in YAML format.
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.
# -*- 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!
- [ ] Design logo for Scake.
- [ ] Write documentation & tutorials for Scake.
- [ ] Support "requirements.txt" in settings. Installing Python packages on-the-fly.
- [ ] Support loop in settings.
- [ ] Support flow reference (connect multiple settings files together).
- [ ] Support integration tests (try as friendly as possible).
- [ ] Support generating class templates (> scake /path/to/settings.yaml).
- [ ] Import custom packages automatically by defining in the settings file.
- [ ] Setting element inherit / override.
Far future plan:
- [ ] Packaging scake with Cython.
- [ ] Packaging scake to a library or executable binary.
- [ ] Scake server for listening file changes and update code flow status (ok or error) in real-time.
- [ ] Scake component on the cloud. Be able to reference a scake component by URL @ specific version.
- [ ] Interactive IDE for designing a settings fully compatible to Scake.
- Object attribute reference in YAML settings
- Fix bug: similar keys in settings
- Big refactoring in how we do initializing instances and executing code flow
- Remove generating class templates based on YAML
- 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.
- 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.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size scake-0.2.1-py2.py3-none-any.whl (8.7 kB)||File type Wheel||Python version py2.py3||Upload date||Hashes View hashes|
|Filename, size scake-0.2.1.tar.gz (7.9 kB)||File type Source||Python version None||Upload date||Hashes View hashes|
Hashes for scake-0.2.1-py2.py3-none-any.whl