diff options
author | Yu-Jie Lin <livibetter@gmail.com> | 2013-08-11 22:53:30 +0800 |
---|---|---|
committer | Yu-Jie Lin <livibetter@gmail.com> | 2013-08-11 22:53:30 +0800 |
commit | 7a6a404de3c0cdc15d9511c1596837e444c4a040 (patch) | |
tree | 9c060e6868e4dbaf6c097eb6ab4ceb20a947784d | |
parent | 4fb3b42252a8d4c596065de833b27eb9a006fc23 (diff) | |
download | smartypants-7a6a404de3c0cdc15d9511c1596837e444c4a040.tar.gz |
set up setup.py, COPYING, and hgignore
-rw-r--r-- | .hgignore | 3 | ||||
-rw-r--r-- | COPYING | 65 | ||||
-rwxr-xr-x | setup.py | 227 | ||||
-rwxr-xr-x[-rw-r--r--] | smartypants.py | 15 |
4 files changed, 302 insertions, 8 deletions
diff --git a/.hgignore b/.hgignore new file mode 100644 index 0000000..ec2ea52 --- /dev/null +++ b/.hgignore @@ -0,0 +1,3 @@ +syntax: glob +dist +MANIFEST @@ -0,0 +1,65 @@ +SmartyPants license:: + + Copyright (c) 2003 John Gruber + (http://daringfireball.net/) + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + * Neither the name "SmartyPants" nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. + + This software is provided by the copyright holders and contributors "as + is" and any express or implied warranties, including, but not limited + to, the implied warranties of merchantability and fitness for a + particular purpose are disclaimed. In no event shall the copyright + owner or contributors be liable for any direct, indirect, incidental, + special, exemplary, or consequential damages (including, but not + limited to, procurement of substitute goods or services; loss of use, + data, or profits; or business interruption) however caused and on any + theory of liability, whether in contract, strict liability, or tort + (including negligence or otherwise) arising in any way out of the use + of this software, even if advised of the possibility of such damage. + + +smartypants.py license:: + + smartypants.py is a derivative work of SmartyPants. + + Copyright (c) 2013 Yu-Jie Lin + Copyright (c) 2004, 2005, 2007, 2013 Chad Miller + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + This software is provided by the copyright holders and contributors "as + is" and any express or implied warranties, including, but not limited + to, the implied warranties of merchantability and fitness for a + particular purpose are disclaimed. In no event shall the copyright + owner or contributors be liable for any direct, indirect, incidental, + special, exemplary, or consequential damages (including, but not + limited to, procurement of substitute goods or services; loss of use, + data, or profits; or business interruption) however caused and on any + theory of liability, whether in contract, strict liability, or tort + (including negligence or otherwise) arising in any way out of the use + of this software, even if advised of the possibility of such damage. diff --git a/setup.py b/setup.py new file mode 100755 index 0000000..6ccb5ad --- /dev/null +++ b/setup.py @@ -0,0 +1,227 @@ +#!/usr/bin/env python +# Copyright (C) 2013 by Yu-Jie Lin +# For detail license information, See COPYING + +from __future__ import print_function +from distutils.core import Command, setup +from unittest import TestLoader, TextTestRunner +import sys + +# scripts to be exculded from checking +EXCLUDE_SCRIPTS = () + +script_name = 'smartypants.py' + +# ============================================================================ + + +class cmd_test(Command): + + description = 'run tests' + user_options = [] + + def initialize_options(self): + + pass + + def finalize_options(self): + + pass + + def run(self): + + loader = TestLoader() + tests = loader.discover(start_dir='tests') + runner = TextTestRunner(verbosity=2) + runner.run(tests) + + +class cmd_pep8(Command): + + description = 'run pep8' + user_options = [] + + def initialize_options(self): + + pass + + def finalize_options(self): + + pass + + def run(self): + + try: + import pep8 + except ImportError: + print(('Cannot import pep8, you forgot to install?\n' + 'run `pip install pep8` to install.'), file=sys.stderr) + sys.exit(1) + + p8 = pep8.StyleGuide() + + # do not include code not written in b.py + p8.options.exclude += EXCLUDE_SCRIPTS + # ignore four-space indentation error + p8.options.ignore += () + + print() + print('Options') + print('=======') + print() + print('Exclude:', p8.options.exclude) + print('Ignore :', p8.options.ignore) + + print() + print('Results') + print('=======') + print() + report = p8.check_files('.') + + print() + print('Statistics') + print('==========') + print() + report.print_statistics() + print('%-7d Total errors and warnings' % report.get_count()) + + +class cmd_pyflakes(Command): + + description = 'run Pyflakes' + user_options = [] + + def initialize_options(self): + + pass + + def finalize_options(self): + + pass + + def run(self): + + try: + from pyflakes import api + from pyflakes import reporter as modReporter + except ImportError: + print(('Cannot import pyflakes, you forgot to install?\n' + 'run `pip install pyflakes` to install.'), file=sys.stderr) + sys.exit(1) + + from os.path import basename + + reporter = modReporter._makeDefaultReporter() + + # monkey patch for exclusion of pathes + api_iterSourceCode = api.iterSourceCode + + def _iterSourceCode(paths): + for path in api_iterSourceCode(paths): + if basename(path) not in EXCLUDE_SCRIPTS: + yield path + api.iterSourceCode = _iterSourceCode + + print() + print('Options') + print('=======') + print() + print('Exclude:', EXCLUDE_SCRIPTS) + + print() + print('Results') + print('=======') + print() + warnings = api.checkRecursive('.', reporter) + print() + print('Total warnings: %d' % warnings) + + +class cmd_pylint(Command): + + description = 'run Pylint' + user_options = [] + + def initialize_options(self): + + pass + + def finalize_options(self): + + pass + + def run(self): + + from glob import glob + try: + from pylint import lint + except ImportError: + print(('Cannot import pylint, you forgot to install?\n' + 'run `pip install pylint` to install.'), file=sys.stderr) + sys.exit(1) + + print() + print('Options') + print('=======') + print() + print('Exclude:', EXCLUDE_SCRIPTS) + + files = ['setup.py', script_name] + glob('tests/*.py') + args = [ + '--ignore=%s' % ','.join(EXCLUDE_SCRIPTS), + '--output-format=colorized', + '--include-ids=y', + '--indent-string=" "', + ] + files + print() + lint.Run(args) + +# ============================================================================ + +with open(script_name) as f: + meta = dict( + (k.strip(' _'), eval(v)) for k, v in + # There will be a '\n', with eval(), it's safe to ignore + (line.split('=') for line in f if line.startswith('__')) + ) + + # renaming meta-data keys + meta_renames = [ + ('website', 'url'), + ('email', 'author_email'), + ] + for old, new in meta_renames: + if old in meta: + meta[new] = meta[old] + del meta[old] + + # keep these + meta_keys = ['name', 'description', 'version', 'license', 'url', 'author', + 'author_email'] + meta = dict([m for m in meta.items() if m[0] in meta_keys]) + +classifiers = [ + 'Development Status :: 5 - Production/Stable', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: BSD License', + 'Operating System :: OS Independent', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 3', + 'Topic :: Text Processing :: Filters', +] + +setup_d = dict( + name='smartypants', + cmdclass={ + 'pep8': cmd_pep8, + 'pyflakes': cmd_pyflakes, + 'pylint': cmd_pylint, + 'test': cmd_test, + }, + classifiers=classifiers, + py_modules=['smartypants'], + **meta +) + +if __name__ == '__main__': + setup(**setup_d) diff --git a/smartypants.py b/smartypants.py index e18e282..783914a 100644..100755 --- a/smartypants.py +++ b/smartypants.py @@ -377,6 +377,13 @@ smartypants.py license:: """ +__author__ = 'Yu-Jie Lin' +__email__ = 'livibetter@gmail.com' +__version__ = '1.7.0dev' +__license__ = 'BSD License' +__url__ = 'https://bitbucket.org/livibetter/smartypants.py' +__description__ = 'Smart-quotes, smart-ellipses, and smart-dashes' + default_smartypants_attr = "1" import re @@ -898,11 +905,3 @@ if __name__ == "__main__": self.assertEqual(sp('''"Isn't this fun?"'''), '''“Isn’t this fun?”''') unittest.main() - - - - -__author__ = "Chad Miller <smartypantspy@chad.org>" -__version__ = "1.5_1.6: Fri, 27 Jul 2007 07:06:40 -0400" -__url__ = "http://wiki.chad.org/SmartyPantsPy" -__description__ = "Smart-quotes, smart-ellipses, and smart-dashes for weblog entries in pyblosxom" |