whichcraft-0.4.1/0000755000076500000240000000000013077735150016101 5ustar danielgreenfeldstaff00000000000000whichcraft-0.4.1/AUTHORS.rst0000644000076500000240000000027413077733136017765 0ustar danielgreenfeldstaff00000000000000======= Credits ======= Development Lead ---------------- * Daniel Roy Greenfeld Contributors ------------ * Edward Betts (@EdwardBetts) * Nick Coghlan (@ncoghlan) whichcraft-0.4.1/CONTRIBUTING.rst0000644000076500000240000000612113077733136020544 0ustar danielgreenfeldstaff00000000000000============ 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.4.1/HISTORY.rst0000644000076500000240000000115313077733703017776 0ustar danielgreenfeldstaff00000000000000History ========= 0.4.1 (2017-04-25) --------------------- * Added tests to support Python 3.6 0.3.1 (2016-05-10) --------------------- * Now testing for `which` directly, so we can support versions of Python 3 before 3.3 (@nickcoghlan) 0.3.1 (2016-04-24) --------------------- * Correcting version in whichcraft.py 0.3.0 (2016-04-24) --------------------- * Include tests in release source tarball (@Edwardbetts) 0.2.0 (2016-04-23) --------------------- * Python 3.5 compatability 0.1.1 (2015-09-09) --------------------- * Added lyrics 0.1.0 (2015-09-09) --------------------- * First release on PyPI. whichcraft-0.4.1/LICENSE0000644000076500000240000000271313077733136017113 0ustar danielgreenfeldstaff00000000000000Copyright (c) 2015-2016, 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.4.1/MANIFEST.in0000644000076500000240000000027513077733136017645 0ustar danielgreenfeldstaff00000000000000include AUTHORS.rst include CONTRIBUTING.rst include HISTORY.rst include LICENSE include README.rst include test_whichcraft.py recursive-exclude * __pycache__ recursive-exclude * *.py[co] whichcraft-0.4.1/PKG-INFO0000644000076500000240000000733613077735150017207 0ustar danielgreenfeldstaff00000000000000Metadata-Version: 1.1 Name: whichcraft Version: 0.4.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.svg :target: http://badge.fury.io/py/whichcraft .. image:: https://travis-ci.org/pydanny/whichcraft.svg?branch=master :target: https://travis-ci.org/pydanny/whichcraft .. image:: http://codecov.io/github/pydanny/whichcraft/coverage.svg?branch=master :target: http://codecov.io/github/pydanny/whichcraft?branch=master .. image:: https://ci.appveyor.com/api/projects/status/v9coijayykhkeu4d?svg=true :target: https://ci.appveyor.com/project/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.4.1 (2017-04-25) --------------------- * Added tests to support Python 3.6 0.3.1 (2016-05-10) --------------------- * Now testing for `which` directly, so we can support versions of Python 3 before 3.3 (@nickcoghlan) 0.3.1 (2016-04-24) --------------------- * Correcting version in whichcraft.py 0.3.0 (2016-04-24) --------------------- * Include tests in release source tarball (@Edwardbetts) 0.2.0 (2016-04-23) --------------------- * Python 3.5 compatability 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 :: 3 - 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.2 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 whichcraft-0.4.1/README.rst0000644000076500000240000000302513077733552017574 0ustar danielgreenfeldstaff00000000000000=============================== whichcraft =============================== .. image:: https://badge.fury.io/py/whichcraft.svg :target: http://badge.fury.io/py/whichcraft .. image:: https://travis-ci.org/pydanny/whichcraft.svg?branch=master :target: https://travis-ci.org/pydanny/whichcraft .. image:: http://codecov.io/github/pydanny/whichcraft/coverage.svg?branch=master :target: http://codecov.io/github/pydanny/whichcraft?branch=master .. image:: https://ci.appveyor.com/api/projects/status/v9coijayykhkeu4d?svg=true :target: https://ci.appveyor.com/project/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.4.1/setup.cfg0000644000076500000240000000015713077735150017725 0ustar danielgreenfeldstaff00000000000000[wheel] universal = 1 [bdist_wheel] universal = 1 [egg_info] tag_build = tag_date = 0 tag_svn_revision = 0 whichcraft-0.4.1/setup.py0000644000076500000240000000421013077733736017620 0ustar danielgreenfeldstaff00000000000000#!/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.4.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 :: 3 - 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.2', 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', ], ) whichcraft-0.4.1/test_whichcraft.py0000644000076500000240000000056413077733136021643 0ustar danielgreenfeldstaff00000000000000import os import pytest from whichcraft import which def test_existing_command(): cmd = which('date') assert cmd assert os.path.exists(cmd) assert os.access(cmd, os.F_OK | os.X_OK) assert not os.path.isdir(cmd) def test_non_existing_command(): assert which('stringthatisntashellcommand') is None if __name__ == '__main__': pytest.main() whichcraft-0.4.1/whichcraft.egg-info/0000755000076500000240000000000013077735150021715 5ustar danielgreenfeldstaff00000000000000whichcraft-0.4.1/whichcraft.egg-info/dependency_links.txt0000644000076500000240000000000113077735150025763 0ustar danielgreenfeldstaff00000000000000 whichcraft-0.4.1/whichcraft.egg-info/not-zip-safe0000644000076500000240000000000113077733474024152 0ustar danielgreenfeldstaff00000000000000 whichcraft-0.4.1/whichcraft.egg-info/PKG-INFO0000644000076500000240000000733613077735150023023 0ustar danielgreenfeldstaff00000000000000Metadata-Version: 1.1 Name: whichcraft Version: 0.4.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.svg :target: http://badge.fury.io/py/whichcraft .. image:: https://travis-ci.org/pydanny/whichcraft.svg?branch=master :target: https://travis-ci.org/pydanny/whichcraft .. image:: http://codecov.io/github/pydanny/whichcraft/coverage.svg?branch=master :target: http://codecov.io/github/pydanny/whichcraft?branch=master .. image:: https://ci.appveyor.com/api/projects/status/v9coijayykhkeu4d?svg=true :target: https://ci.appveyor.com/project/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.4.1 (2017-04-25) --------------------- * Added tests to support Python 3.6 0.3.1 (2016-05-10) --------------------- * Now testing for `which` directly, so we can support versions of Python 3 before 3.3 (@nickcoghlan) 0.3.1 (2016-04-24) --------------------- * Correcting version in whichcraft.py 0.3.0 (2016-04-24) --------------------- * Include tests in release source tarball (@Edwardbetts) 0.2.0 (2016-04-23) --------------------- * Python 3.5 compatability 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 :: 3 - 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.2 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 whichcraft-0.4.1/whichcraft.egg-info/SOURCES.txt0000644000076500000240000000044413077735150023603 0ustar danielgreenfeldstaff00000000000000AUTHORS.rst CONTRIBUTING.rst HISTORY.rst LICENSE MANIFEST.in README.rst setup.cfg setup.py test_whichcraft.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.4.1/whichcraft.egg-info/top_level.txt0000644000076500000240000000001313077735150024441 0ustar danielgreenfeldstaff00000000000000whichcraft whichcraft-0.4.1/whichcraft.py0000644000076500000240000000552713077733732020612 0ustar danielgreenfeldstaff00000000000000# -*- coding: utf-8 -*- __author__ = 'Daniel Roy Greenfeld' __email__ = 'pydanny@gmail.com' __version__ = '0.4.1' import os import sys try: # Forced testing from shutil import which except ImportError: # Forced testing # Versions prior to Python 3.3 don't have shutil.which 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