whichcraft-0.1.1/0000755000076600000240000000000012574203464014077 5ustar dannystaff00000000000000whichcraft-0.1.1/AUTHORS.rst0000644000076600000240000000024212574175560015761 0ustar dannystaff00000000000000======= Credits ======= Development Lead ---------------- * Daniel Roy Greenfeld Contributors ------------ None yet. Why not be the first?whichcraft-0.1.1/CONTRIBUTING.rst0000644000076600000240000000612112574175560016545 0ustar dannystaff00000000000000============ Contributing ============ Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given. You can contribute in many ways: Types of Contributions ---------------------- Report Bugs ~~~~~~~~~~~ Report bugs at https://github.com/pydanny/whichcraft/issues. If you are reporting a bug, please include: * Your operating system name and version. * Any details about your local setup that might be helpful in troubleshooting. * Detailed steps to reproduce the bug. Fix Bugs ~~~~~~~~ Look through the GitHub issues for bugs. Anything tagged with "bug" is open to whoever wants to implement it. Implement Features ~~~~~~~~~~~~~~~~~~ Look through the GitHub issues for features. Anything tagged with "feature" is open to whoever wants to implement it. Write Documentation ~~~~~~~~~~~~~~~~~~~ whichcraft could always use more documentation, whether as part of the official whichcraft docs, in docstrings, or even on the web in blog posts, articles, and such. Submit Feedback ~~~~~~~~~~~~~~~ The best way to send feedback is to file an issue at https://github.com/pydanny/whichcraft/issues. If you are proposing a feature: * Explain in detail how it would work. * Keep the scope as narrow as possible, to make it easier to implement. * Remember that this is a volunteer-driven project, and that contributions are welcome :) Get Started! ------------ Ready to contribute? Here's how to set up `whichcraft` for local development. 1. Fork the `whichcraft` repo on GitHub. 2. Clone your fork locally:: $ git clone git@github.com:your_name_here/whichcraft.git 3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:: $ mkvirtualenv whichcraft $ cd whichcraft/ $ python setup.py develop 4. Create a branch for local development:: $ git checkout -b name-of-your-bugfix-or-feature Now you can make your changes locally. 5. When you're done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:: $ flake8 whichcraft.py test_whichcraft.py $ py.test $ tox To get flake8 and tox, just pip install them into your virtualenv. 6. Commit your changes and push your branch to GitHub:: $ git add . $ git commit -m "Your detailed description of your changes." $ git push origin name-of-your-bugfix-or-feature 7. Submit a pull request through the GitHub website. Pull Request Guidelines ----------------------- Before you submit a pull request, check that it meets these guidelines: 1. The pull request should include tests. 2. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst. 3. The pull request should work for Python 2.6, 2.7, 3.3, and 3.4, and for PyPy. Check https://travis-ci.org/pydanny/whichcraft/pull_requests and make sure that the tests pass for all supported Python versions. Tips ---- To run a subset of tests:: TODOwhichcraft-0.1.1/HISTORY.rst0000644000076600000240000000022112574203364015764 0ustar dannystaff00000000000000History ========= 0.1.1 (2015-09-09) --------------------- * Added lyrics 0.1.0 (2015-09-09) --------------------- * First release on PyPI. whichcraft-0.1.1/LICENSE0000644000076600000240000000270512574175560015115 0ustar dannystaff00000000000000Copyright (c) 2015, Daniel Roy Greenfeld 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 of whichcraft 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 HOLDER 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.whichcraft-0.1.1/MANIFEST.in0000644000076600000240000000024112574175560015637 0ustar dannystaff00000000000000include AUTHORS.rst include CONTRIBUTING.rst include HISTORY.rst include LICENSE include README.rst recursive-exclude * __pycache__ recursive-exclude * *.py[co]whichcraft-0.1.1/PKG-INFO0000644000076600000240000000510612574203464015176 0ustar dannystaff00000000000000Metadata-Version: 1.1 Name: whichcraft Version: 0.1.1 Summary: This package provides cross-platform cross-python shutil.which functionality. Home-page: https://github.com/pydanny/whichcraft Author: Daniel Roy Greenfeld Author-email: pydanny@gmail.com License: BSD Description: =============================== whichcraft =============================== .. image:: https://badge.fury.io/py/whichcraft.png :target: http://badge.fury.io/py/whichcraft .. image:: https://travis-ci.org/pydanny/whichcraft.png?branch=master :target: https://travis-ci.org/pydanny/whichcraft :: That code in my care That sly command-line stare That strips my operating system bare It's whichcraft This package provides cross-platform cross-python ``shutil.which`` functionality. Usage ===== On Linux, Mac, Windows for Python 2.6, 2.7, or any of the 3s: .. code-block:: python >>> from whichcraft import which >>> which('date') '/bin/date' >>> which('calendar') '/bin/calendar' >>> which('cookiecutter') '/Users/pydanny/.envs/fun/bin/cookiecutter' >>> which('a-made-up-name') is None True Notes ===== This is a shim of the ``shutil.which`` function that's designed to work across multiple versions of Python and inside of windows. The code for Python 2.x is based on Python 3 code that I extracted from source. I originally did this for Cookiecutter_ but pulled it out in order to reduce line count for that project. .. _Cookiecutter: https://github.com/audreyr/cookiecutter History ========= 0.1.1 (2015-09-09) --------------------- * Added lyrics 0.1.0 (2015-09-09) --------------------- * First release on PyPI. Keywords: whichcraft Platform: UNKNOWN Classifier: Development Status :: 2 - Pre-Alpha Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: BSD License Classifier: Natural Language :: English Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 whichcraft-0.1.1/README.rst0000644000076600000240000000234112574203345015564 0ustar dannystaff00000000000000=============================== whichcraft =============================== .. image:: https://badge.fury.io/py/whichcraft.png :target: http://badge.fury.io/py/whichcraft .. image:: https://travis-ci.org/pydanny/whichcraft.png?branch=master :target: https://travis-ci.org/pydanny/whichcraft :: That code in my care That sly command-line stare That strips my operating system bare It's whichcraft This package provides cross-platform cross-python ``shutil.which`` functionality. Usage ===== On Linux, Mac, Windows for Python 2.6, 2.7, or any of the 3s: .. code-block:: python >>> from whichcraft import which >>> which('date') '/bin/date' >>> which('calendar') '/bin/calendar' >>> which('cookiecutter') '/Users/pydanny/.envs/fun/bin/cookiecutter' >>> which('a-made-up-name') is None True Notes ===== This is a shim of the ``shutil.which`` function that's designed to work across multiple versions of Python and inside of windows. The code for Python 2.x is based on Python 3 code that I extracted from source. I originally did this for Cookiecutter_ but pulled it out in order to reduce line count for that project. .. _Cookiecutter: https://github.com/audreyr/cookiecutter whichcraft-0.1.1/setup.cfg0000644000076600000240000000015712574203464015723 0ustar dannystaff00000000000000[wheel] universal = 1 [bdist_wheel] universal = 1 [egg_info] tag_build = tag_date = 0 tag_svn_revision = 0 whichcraft-0.1.1/setup.py0000644000076600000240000000377112574203376015623 0ustar dannystaff00000000000000#!/usr/bin/env python # -*- coding: utf-8 -*- import os import sys try: from setuptools import setup except ImportError: from distutils.core import setup version = "0.1.1" if sys.argv[-1] == 'publish': try: import wheel except ImportError: raise ImportError("Fix: pip install wheel") os.system('python setup.py sdist bdist_wheel upload') print("You probably want to also tag the version now:") print(" git tag -a %s -m 'version %s'" % (version, version)) print(" git push --tags") sys.exit() if sys.argv[-1] == 'tag': print("Tagging the version on github:") os.system("git tag -a %s -m 'version %s'" % (version, version)) os.system("git push --tags") sys.exit() readme = open('README.rst').read() history = open('HISTORY.rst').read().replace('.. :changelog:', '') def get_requirements(filename): f = open(filename).read() reqs = [ # loop through list of requirements x.strip() for x in f.splitlines() # filter out comments and empty lines if not x.strip().startswith('#') ] return reqs setup( name='whichcraft', version=version, description="""This package provides cross-platform cross-python shutil.which functionality.""", long_description=readme + '\n\n' + history, author='Daniel Roy Greenfeld', author_email='pydanny@gmail.com', url='https://github.com/pydanny/whichcraft', include_package_data=True, py_modules=['whichcraft'], license="BSD", zip_safe=False, keywords='whichcraft', classifiers=[ 'Development Status :: 2 - Pre-Alpha', 'Intended Audience :: Developers', 'License :: OSI Approved :: BSD License', 'Natural Language :: English', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', ], ) whichcraft-0.1.1/whichcraft.egg-info/0000755000076600000240000000000012574203464017713 5ustar dannystaff00000000000000whichcraft-0.1.1/whichcraft.egg-info/dependency_links.txt0000644000076600000240000000000112574203464023761 0ustar dannystaff00000000000000 whichcraft-0.1.1/whichcraft.egg-info/not-zip-safe0000644000076600000240000000000112574203010022124 0ustar dannystaff00000000000000 whichcraft-0.1.1/whichcraft.egg-info/PKG-INFO0000644000076600000240000000510612574203464021012 0ustar dannystaff00000000000000Metadata-Version: 1.1 Name: whichcraft Version: 0.1.1 Summary: This package provides cross-platform cross-python shutil.which functionality. Home-page: https://github.com/pydanny/whichcraft Author: Daniel Roy Greenfeld Author-email: pydanny@gmail.com License: BSD Description: =============================== whichcraft =============================== .. image:: https://badge.fury.io/py/whichcraft.png :target: http://badge.fury.io/py/whichcraft .. image:: https://travis-ci.org/pydanny/whichcraft.png?branch=master :target: https://travis-ci.org/pydanny/whichcraft :: That code in my care That sly command-line stare That strips my operating system bare It's whichcraft This package provides cross-platform cross-python ``shutil.which`` functionality. Usage ===== On Linux, Mac, Windows for Python 2.6, 2.7, or any of the 3s: .. code-block:: python >>> from whichcraft import which >>> which('date') '/bin/date' >>> which('calendar') '/bin/calendar' >>> which('cookiecutter') '/Users/pydanny/.envs/fun/bin/cookiecutter' >>> which('a-made-up-name') is None True Notes ===== This is a shim of the ``shutil.which`` function that's designed to work across multiple versions of Python and inside of windows. The code for Python 2.x is based on Python 3 code that I extracted from source. I originally did this for Cookiecutter_ but pulled it out in order to reduce line count for that project. .. _Cookiecutter: https://github.com/audreyr/cookiecutter History ========= 0.1.1 (2015-09-09) --------------------- * Added lyrics 0.1.0 (2015-09-09) --------------------- * First release on PyPI. Keywords: whichcraft Platform: UNKNOWN Classifier: Development Status :: 2 - Pre-Alpha Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: BSD License Classifier: Natural Language :: English Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 whichcraft-0.1.1/whichcraft.egg-info/SOURCES.txt0000644000076600000240000000042112574203464021574 0ustar dannystaff00000000000000AUTHORS.rst CONTRIBUTING.rst HISTORY.rst LICENSE MANIFEST.in README.rst setup.cfg setup.py whichcraft.py whichcraft.egg-info/PKG-INFO whichcraft.egg-info/SOURCES.txt whichcraft.egg-info/dependency_links.txt whichcraft.egg-info/not-zip-safe whichcraft.egg-info/top_level.txtwhichcraft-0.1.1/whichcraft.egg-info/top_level.txt0000644000076600000240000000001312574203464022437 0ustar dannystaff00000000000000whichcraft whichcraft-0.1.1/whichcraft.py0000644000076600000240000000546112574203412016572 0ustar dannystaff00000000000000# -*- coding: utf-8 -*- __author__ = 'Daniel Roy Greenfeld' __email__ = 'pydanny@gmail.com' __version__ = '0.1.1' import os import sys PY3 = sys.version_info[0] == 3 if PY3: # Forced testing from shutil import which else: # Forced testing def which(cmd, mode=os.F_OK | os.X_OK, path=None): """Given a command, mode, and a PATH string, return the path which conforms to the given mode on the PATH, or None if there is no such file. `mode` defaults to os.F_OK | os.X_OK. `path` defaults to the result of os.environ.get("PATH"), or can be overridden with a custom search path. Note: This function was backported from the Python 3 source code. """ # Check that a given file can be accessed with the correct mode. # Additionally check that `file` is not a directory, as on Windows # directories pass the os.access check. def _access_check(fn, mode): return (os.path.exists(fn) and os.access(fn, mode) and not os.path.isdir(fn)) # If we're given a path with a directory part, look it up directly # rather than referring to PATH directories. This includes checking # relative to the current directory, e.g. ./script if os.path.dirname(cmd): if _access_check(cmd, mode): return cmd return None if path is None: path = os.environ.get("PATH", os.defpath) if not path: return None path = path.split(os.pathsep) if sys.platform == "win32": # The current directory takes precedence on Windows. if os.curdir not in path: path.insert(0, os.curdir) # PATHEXT is necessary to check on Windows. pathext = os.environ.get("PATHEXT", "").split(os.pathsep) # See if the given file matches any of the expected path # extensions. This will allow us to short circuit when given # "python.exe". If it does match, only test that one, otherwise we # have to try others. if any(cmd.lower().endswith(ext.lower()) for ext in pathext): files = [cmd] else: files = [cmd + ext for ext in pathext] else: # On other platforms you don't have things like PATHEXT to tell you # what file suffixes are executable, so just pass on cmd as-is. files = [cmd] seen = set() for dir in path: normdir = os.path.normcase(dir) if normdir not in seen: seen.add(normdir) for thefile in files: name = os.path.join(dir, thefile) if _access_check(name, mode): return name return None