python/which/TODO.txt

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/python/which/TODO.txt	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,113 @@
     1.4 +# High Priority
     1.5 +
     1.6 +- Figure out the script story on the various platforms. On Windows, look into
     1.7 +  the launcher thing that effbot has. Unix, don't install the script my
     1.8 +  default. They can always do "python -m which ..." with Python >= 2.4.
     1.9 +  Suggest an alias that some folks might want to use for that.
    1.10 +
    1.11 +
    1.12 +# Medium Priority
    1.13 +
    1.14 +- define __all__?
    1.15 +- improve test suite
    1.16 +- test with other versions of Python
    1.17 +- get the PATHEXT attached extension to reflect the actual canonical
    1.18 +  case of file matches on Windows, currently the extension from PATHEXT
    1.19 +  is always uppercase
    1.20 +- What to do with Change 145624 by shanec. It is a bit of a
    1.21 +  bastardization. Maybe allow this with a special option to allow the change
    1.22 +  in semantics.
    1.23 +
    1.24 +    > Change 145624 by shanec@shanec-ocelotl on 2005/05/24 16:51:55
    1.25 +    > 
    1.26 +    >     make which work better on OSX
    1.27 +    >     - add support for searching /Applications and /Network/Applications
    1.28 +    >     - add support for .app bundles
    1.29 +    > 
    1.30 +    > Affected files ...
    1.31 +    > 
    1.32 +    > ... //depot/main/Apps/Komodo-devel/src/python-sitelib/which.py#7 edit
    1.33 +    > 
    1.34 +    > Differences ...
    1.35 +    > 
    1.36 +    > ==== //depot/main/Apps/Komodo-devel/src/python-sitelib/which.py#7 (text) ====
    1.37 +    > 
    1.38 +    > @@ -126,10 +126,11 @@
    1.39 +    >                  sys.stderr.write("duplicate: %s (%s)\n" % potential)
    1.40 +    >              return None
    1.41 +    >      else:
    1.42 +    > -        if not stat.S_ISREG(os.stat(potential[0]).st_mode):
    1.43 +    > +        darwinApp = sys.platform == 'darwin' and potential[0][-4:]=='.app'
    1.44 +    > +        if not darwinApp and not stat.S_ISREG(os.stat(potential[0]).st_mode):
    1.45 +    >              if verbose:
    1.46 +    >                  sys.stderr.write("not a regular file: %s (%s)\n" % potential)
    1.47 +    > -        elif not os.access(potential[0], os.X_OK):
    1.48 +    > +        elif not darwinApp and not os.access(potential[0], os.X_OK):
    1.49 +    >              if verbose:
    1.50 +    >                  sys.stderr.write("no executable access: %s (%s)\n"\
    1.51 +    >                                   % potential)
    1.52 +    > @@ -166,6 +167,9 @@
    1.53 +    >          path = os.environ.get("PATH", "").split(os.pathsep)
    1.54 +    >          if sys.platform.startswith("win"):
    1.55 +    >              path.insert(0, os.curdir)  # implied by Windows shell
    1.56 +    > +        if sys.platform == 'darwin':
    1.57 +    > +            path.insert(0, '/Network/Applications')
    1.58 +    > +            path.insert(0, '/Applications')
    1.59 +    >      else:
    1.60 +    >          usingGivenPath = 1
    1.61 +    >  
    1.62 +    > @@ -182,6 +186,9 @@
    1.63 +    >                  exts = ['.COM', '.EXE', '.BAT']
    1.64 +    >          elif not isinstance(exts, list):
    1.65 +    >              raise TypeError("'exts' argument must be a list or None")
    1.66 +    > +    elif sys.platform == 'darwin':
    1.67 +    > +        if exts is None:
    1.68 +    > +            exts = ['.app']
    1.69 +    >      else:
    1.70 +    >          if exts is not None:
    1.71 +    >              raise WhichError("'exts' argument is not supported on "\
    1.72 +    > @@ -202,7 +209,8 @@
    1.73 +    >              for ext in ['']+exts:
    1.74 +    >                  absName = os.path.abspath(
    1.75 +    >                      os.path.normpath(os.path.join(dirName, command+ext)))
    1.76 +    > -                if os.path.isfile(absName):
    1.77 +    > +                if os.path.isfile(absName) or (sys.platform == 'darwin' and \
    1.78 +    > +                    absName[-4:]=='.app' and os.path.isdir(absName)):
    1.79 +    >                      if usingGivenPath:
    1.80 +    >                          fromWhere = "from given path element %d" % i
    1.81 +    >                      elif not sys.platform.startswith("win"):
    1.82 +
    1.83 +  Here is a start with slight improvements:
    1.84 +
    1.85 +    > Index: which.py
    1.86 +    > ===================================================================
    1.87 +    > --- which.py	(revision 270)
    1.88 +    > +++ which.py	(working copy)
    1.89 +    > @@ -126,9 +126,18 @@
    1.90 +    >                  sys.stderr.write("duplicate: %s (%s)\n" % potential)
    1.91 +    >              return None
    1.92 +    >      else:
    1.93 +    > -        if not stat.S_ISREG(os.stat(potential[0]).st_mode):
    1.94 +    > +        st_mode = os.stat(potential[0]).st_mode
    1.95 +    > +        isMacAppBundle = sys.platform == "darwin" \
    1.96 +    > +                         and potential[0].endswith(".app") \
    1.97 +    > +                         and stat.S_ISDIR(st_mode)
    1.98 +    > +        if not isMacAppBundle and not stat.S_ISREG(st_mode):
    1.99 +    >              if verbose:
   1.100 +    > -                sys.stderr.write("not a regular file: %s (%s)\n" % potential)
   1.101 +    > +                if sys.platform == "darwin":
   1.102 +    > +                    sys.stderr.write("not a regular file or .app bundle: "
   1.103 +    > +                                     "%s (%s)\n" % potential)
   1.104 +    > +                else:
   1.105 +    > +                    sys.stderr.write("not a regular file: %s (%s)\n"
   1.106 +    > +                                     % potential)
   1.107 +    >          elif not os.access(potential[0], os.X_OK):
   1.108 +    >              if verbose:
   1.109 +    >                  sys.stderr.write("no executable access: %s (%s)\n"\
   1.110 +
   1.111 +
   1.112 +# Low Priority
   1.113 +
   1.114 +- have a version for pre-generators (i.e. Python 2.1)
   1.115 +- add a "logging" interface
   1.116 +

mercurial