Coder Social home page Coder Social logo

evilshortgen's Introduction

Evilshortgen

It's a best way to break your app =)

Your code without shortgen looks like:

def fetch(arg1, arg2, callback):
    pass

@tornado.gen.engine
def get(self):
    value = yield tornado.gen.Task(fetch,
        arg1='arg1', arg1='arg2'
    )
    self.write(value)

But with shortgen evil magic:

@fastgen
def fetch(arg1, arg2, callback):
    pass

@tornado.gen.engine
@shortgen
def get(self):
    value << fetch(
        arg1='arg1', arg1='arg2'
    )
    self.write(value)

Usage

Call exist code like assyncmongo, patch and call with '_e':

from evilshortgen import shortgen, shortpatch
from asyncmongo.cursor import Cursor
shortpatch(Cursor)

@tornado.gen.engine
@shortgen
def get(self):
    result, status << self.db.users.find_one_e({
        '_id': ObjectId(self.user_id),
        },
    )

Call new code with decorator:

from evilshortgen import shortgen, fastgen

@fastgen
def fetch(arg1, arg2, callback):
    pass

@tornado.gen.engine
@shortgen
def get(self):
    value << fetch(
        arg1='arg1', arg1='arg2'
    )

Known issues

Short calls set only values, not arguments:

self.a << fetch()  # not work
a << fetch()  # work

Group tuple assignment not work:

(a, b), c << fetch()  # not work
a, b, c << fetch()  # work

evilshortgen's People

Contributors

nvbn avatar

Watchers

James Cloos avatar Jakub Dušek avatar

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.