Last active
August 29, 2015 14:16
-
-
Save LucaLanziani/0c14bb962d2c88bf6549 to your computer and use it in GitHub Desktop.
Python project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from __future__ import (absolute_import, division, print_function, | |
unicode_literals) | |
from docopt import docopt | |
from schema import Optional, Schema, SchemaError | |
VERSION = '0.0.1' | |
class CommandLineInterface(object): | |
"""Usage: %(name)s [options] COMMAND | |
Your description here | |
Options: | |
--version print package version | |
""" | |
def __init__(self): | |
super(CommandLineInterface, self).__init__() | |
def _validate_args(self, opt): | |
schema = Schema({ | |
Optional('--version'): bool | |
}) | |
try: | |
opt = schema.validate(opt) | |
except SchemaError as e: | |
exit(e) | |
return opt | |
def _parse_args(self, name=None): | |
if name is None: | |
name = __file__ | |
opt = docopt(self.__doc__ % {'name': name}, argv=None, help=True, | |
version=None, options_first=False) | |
return self._validate_args(opt) | |
def run(self, name=None): | |
opt = self._parse_args(name) | |
if opt['--version']: | |
print(VERSION) | |
if __name__ == '__main__': | |
CommandLineInterface().run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.PHONY: TEST ENV | |
ENV: Makefile | |
virtualenv --distribute ./env | |
CHECK_ENV: | |
ifndef VIRTUAL_ENV | |
$(error PLEASE ENTER THE VIRTUALENV BEFORE FUN THE COMMAND) | |
endif | |
UPDATE_ENV: CHECK_ENV requirements.txt | |
pip install --upgrade setuptools | |
pip install --upgrade pip | |
pip install -r requirements.txt | |
TESTS: CHECK_ENV | |
nosetests --with-coverage | |
FLAKE8: CHECK_ENV | |
flake8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docopt==0.6.2 | |
nose==1.3.4 | |
schema==0.3.1 | |
flake8==2.3.0 | |
flake8-blind-except==0.1.0 | |
flake8-import-order==0.5.1 | |
coverage==3.7.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment