Skip to main content

Toolbox for Python scripts

Project description

https://badge.fury.io/py/pytoolbox.png https://pypip.in/d/pytoolbox/badge.png https://secure.travis-ci.org/davidfischer-ch/pytoolbox.png https://coveralls.io/repos/davidfischer-ch/pytoolbox/badge.png https://landscape.io/github/davidfischer-ch/pytoolbox/master/landscape.png 'Stories in Ready'

Afraid of red status ? Please click on the link, sometimes this is not my fault ;-)

This module is a Toolbox for Python scripts.

Documentation: https://pytoolbox.readthedocs.org

Repository: https://github.com/davidfischer-ch/pytoolbox

This library supports Python 2.6, 2.7, 3.2, 3.3, 3.4 and PyPy.

What the release number stands for ?

I do my best to follow this interesting recommendation : Semantic Versioning 2.0.0

How to install it (Python 2.7) ?

Install some packages that are not handled by pip:

sudo apt-get install gir1.2-gexiv2-0.10 libexiv2-dev liblzma-dev libxml2-dev libxslt-dev libyaml-dev libz-dev
sudo apt-get install ffmpeg git-core python-dev python-gi python-pip screen

Make sure that pip is up-to-date (PIPception):

sudo pip-2.7 install --upgrade pip

Then, you only need to run setup.py:

python2 setup.py test
sudo python2 setup.py install

How to install it (Python 3.3) ?

Install some packages that are not handled by pip:

sudo apt-get install gir1.2-gexiv2-0.10 libexiv2-dev liblzma-dev libxml2-dev libxslt-dev libyaml-dev libz-dev
sudo apt-get install ffmpeg git-core python3-dev python3-gi python3-pip screen

Make sure that pip is up-to-date (PIPception):

sudo pip-3.3 install --upgrade pip

Then, you only need to run setup.py:

python3 setup.py test
sudo python3 setup.py install

How to enable features/modules ?

Example:

sudo python setup.py install --help
usage: setup.py [-h] [--extra-flask] [--extra-mongo] [--extra-smpte2022]
                     [--extra-django] [--extra-all]

optional arguments:
  -h, --help         show this help message and exit
  --extra-all                   Install dependencies for all features.
  --extra-atlassian             Install dependencies for the feature atlassian.
  --extra-django                Install dependencies for the feature django.
  --extra-django-filter         Install dependencies for the feature django_filter.
  --extra-django-formtools      Install dependencies for the feature django_formtools.
  --extra-flask                 Install dependencies for the feature flask.
  --extra-mongo                 Install dependencies for the feature mongo.
  --extra-rest-framework        Install dependencies for the feature rest_framework.
  --extra-selenium              Install dependencies for the feature selenium.
  --extra-smpte2022             Install dependencies for the feature smpte2022.
  --extra-voluptuous            Install dependencies for the feature voluptuous.


Some Python utility functions

sudo python setup.py install --extra-smpte2022

Another way to do this, with pip:

sudo pip install -e .[django,flask,mongo,smpte2022] --use-mirrors

How to check coverage ?

python setup.py test
xdg-open tests/cover/index.html

How to use it ?

Here is an example hello.py using the cmd function provided by pytoolbox:

from pytoolbox.subprocess import cmd

print(cmd('echo Hello World!')['stdout'])

How to generate documentation ?

The documentation is generated by Sphinx. In fact most of this documentation is extracted from the docstrings of the code.

Here is the procedure:

python setup.py docs
xdg-open docs/build/html/index.html

How to add it to dependencies of my own project ?

Here is an example setup.py for a project called my-cool-project:

from setuptools import setup

setup(name='my-cool-project',
          version='0.8',
          author='Firstname Lastname',
          author_email='author@something.com',
          install_requires=['...', 'pytoolbox', '...'],
          tests_require=['nose'],
          license='GPLv3',
          url='https://github.com/nickname/my-cool-project',
          packages=['my_cool_project'])

See pip vcs support to get further details about this.

You also need to install git-core, but it is probably already the case, at least on your development computer ;-)

2014 - David Fischer

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

pytoolbox-11.4.3.tar.gz (122.4 kB view hashes)

Uploaded Source

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