Code Monkey home page Code Monkey logo

precept's Introduction

precept

CircleCI Documentation Status Coverage Status PyPI version LICENSE Downloads

Async application framework.

Install

Install with pip: $ pip install precept

Usage

Basic:

from precept import Precept, Command, Argument

class MyCli(Precept):
    """
    The name of the application will be the spinal-case version of 
    the name of the class.
    
    Class docstring is added as cli description.
    """
    @Command(Argument('argument', type=str))
    async def my_command(self, argument):
        print(argument)

def cli():
    MyCli().start()

if __name__ == '__main__':
   cli()

For local testing:

  • Set entry_points.console_script to my-cli = my_package.my_cli:cli in setup.py
  • Install locally: $ pip install -e .
  • Then call: $ my-cli my-command hello -> print hello

Full documentation

precept's People

Contributors

t4rk1n avatar

Stargazers

 avatar  avatar

Watchers

 avatar

precept's Issues

config auto_environ doesn't work well with nested config.

Let say you have multiple path variables under nested config like so:

class Conf(Config):
    class NestOne(Nested):
        path = ConfigProperty(config_type=str, auto_environ=True)  # auto_environ currently default to True
    
    class NestTwo(Nested):
        path = ConfigProperty(config_type=str)

The PATH environ value will be inserted in the config for each of the nested on the python side. They should be prefixed with the nested name (eg: NEST_ONE_PATH).

[toml-config] Config with a default of type bool fail to dump

If a config default is of type bool and has a comment with less than 40 characters, it will throw an error when dumping the config using the dump-configs command.

  File "precept/_configs.py", line 224, in dump
    section[key].comment(prop.comment)
AttributeError: 'bool' object has no attribute 'comment'

[toml-config] Dumping nestable config type str with no default or comment fail.

Stack trace:

Traceback (most recent call last):
  File "/home/t4rk/repos/dazzler/venv/bin/dazzler", line 33, in <module>
    sys.exit(load_entry_point('dazzler', 'console_scripts', 'dazzler')())
  File "/home/t4rk/repos/dazzler/dazzler/_dazzler.py", line 565, in cli
    dazzler.start()
  File "/home/t4rk/repos/dazzler/venv/lib/python3.9/site-packages/precept/_precept.py", line 241, in start
    self.loop.run_until_complete(self.cli.run(args=args))
  File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/home/t4rk/repos/dazzler/venv/lib/python3.9/site-packages/precept/_cli.py", line 345, in run
    await asyncio.gather(event, operation)
  File "/home/t4rk/repos/dazzler/venv/lib/python3.9/site-packages/precept/_precept.py", line 188, in dump_configs
    self.config.save(outfile)
  File "/home/t4rk/repos/dazzler/venv/lib/python3.9/site-packages/precept/_configs.py", line 538, in save
    self._serializer.dump(self, path)
  File "/home/t4rk/repos/dazzler/venv/lib/python3.9/site-packages/precept/_configs.py", line 226, in dump
    section.add(key, value)
  File "/home/t4rk/repos/dazzler/venv/lib/python3.9/site-packages/tomlkit/items.py", line 907, in add
    raise ValueError(
ValueError: Non comment/whitespace items must have an associated key

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.