changeset 0:bcd62e6d822c

initial commit
author Jeff Hammel <k0scist@gmail.com>
date Mon, 20 Feb 2017 10:27:27 -0800
parents
children f4b604d44ff5
files README.txt setup.py which.py
diffstat 3 files changed, 67 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README.txt	Mon Feb 20 10:27:27 2017 -0800
@@ -0,0 +1,11 @@
+whichpy
+===========
+
+python equivalent of which
+
+----
+
+Jeff Hammel
+
+https://pypi.python.org/pypi/whichpy
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/setup.py	Mon Feb 20 10:27:27 2017 -0800
@@ -0,0 +1,35 @@
+import os
+from setuptools import setup
+
+try:
+    here = os.path.dirname(os.path.abspath(__file__))
+    description = open(os.path.join(here, 'README.txt')).read()
+except IOError:
+    description = None
+
+version = '0.0'
+
+deps = []
+
+setup(name='whichpy',
+      version=version,
+      description="python equivalent of which",
+      long_description=description,
+      classifiers=[], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
+      keywords='',
+      author='Jeff Hammel',
+      author_email='k0scist@gmail.com',
+      url='https://pypi.python.org/pypi/whichpy',
+      license='',
+      py_modules=['which'],
+      packages=[],
+      include_package_data=True,
+      zip_safe=False,
+      install_requires=deps,
+      entry_points="""
+      # -*- Entry points: -*-
+      [console_scripts]
+      which.py = which:main
+      """,
+      )
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/which.py	Mon Feb 20 10:27:27 2017 -0800
@@ -0,0 +1,21 @@
+#!/usr/bin/env python
+
+import os
+import sys
+
+def which(fileName, path=os.environ['PATH']):
+    """python equivalent of which; should really be in the stdlib"""
+    dirs = path.split(os.pathsep)
+    for dir in dirs:
+        if os.path.isfile(os.path.join(dir, fileName)):
+            return os.path.join(dir, fileName)
+        if os.path.isfile(os.path.join(dir, fileName + ".exe")):
+            return os.path.join(dir, fileName + ".exe")
+
+def main(args=sys.argv[1:]):
+    """CLI"""
+    for i in sys.argv[1:]:
+        print which(i)
+
+if __name__ == '__main__':
+    main()