GithubHelp home page GithubHelp logo

wd5 / simptools Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ranux/simptools

0.0 2.0 0.0 78 KB

Simptools is a suit with useful python functions for daily usage.

Home Page: http://httpbots.com

simptools's Introduction

About

Simptools is a suit with useful functions for daily usage.

Dependencies

See requirements file:

pip install -r requirements

Installation

Installation from github:

pip install -e git+https://github.com/RANUX/simptools#egg=simptools

DictObject

DictObject is useful when you need to convert dictionary to object.:

from simptools.dict2object import DictObject

obj=DictObject({ 'a':'1', 'b':'test'}, {'a': {'type': int}})
obj.a
obj.b

Example from simple django view function:

from simptools.dict2object import DictObject

def hello_view(request):
    GET = DictObject(request.GET)
    return render_to_response('hello.html', {'name': GET.name})

class_factory

Dynamically loads class:

EmptyClass = class_factory('tests.classes.EmptyClass')
empty_cls = EmptyClass()

money extension

moneyed.Money extension.

Example:

>>> from simptools.money import Money, round_down, round_up
>>> import moneyed
>>> round_up(Money(10.0001, moneyed.RUB))  # result 10.01 RUB
>>> round_down(Money(10.0001, moneyed.RUB))  # result 10.00 RUB

test_catch_and_log_exception

Wraps try-except block and log it

Example:

@catch_and_log_exception(return_expression=-1)
def div_by_zero(self):
    return 1/0

return_expression - will leave the current function call with the expression list (or None) as return value.

Testing

Go to simptools directory and run tests:

nosetests --all-modules --nologcapture --verbosity=2

Release notes

  • 0.6 - simptools.http HttpClient wrapper over requests.
  • 0.5 - simptools.decorators.catch_and_log_exception added
  • 0.4 - simptools.decimals removed

Contributing

The source is available on GitHub - to contribute to the project, fork it on GitHub and send a pull request, all contributions and suggestions are welcome!

simptools's People

Watchers

James Cloos avatar wd5 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.