Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scake-0.2.0.tar.gz (6.6 kB view hashes)

Uploaded Source

Built Distribution

scake-0.2.0-py2.py3-none-any.whl (8.2 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page