summaryrefslogtreecommitdiffstats
path: root/python/which/TODO.txt
blob: 6df2de7f70ac59b9156928d41ce6f1f86f8cec90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# High Priority

- Figure out the script story on the various platforms. On Windows, look into
  the launcher thing that effbot has. Unix, don't install the script my
  default. They can always do "python -m which ..." with Python >= 2.4.
  Suggest an alias that some folks might want to use for that.


# Medium Priority

- define __all__?
- improve test suite
- test with other versions of Python
- get the PATHEXT attached extension to reflect the actual canonical
  case of file matches on Windows, currently the extension from PATHEXT
  is always uppercase
- What to do with Change 145624 by shanec. It is a bit of a
  bastardization. Maybe allow this with a special option to allow the change
  in semantics.

    > Change 145624 by shanec@shanec-ocelotl on 2005/05/24 16:51:55
    > 
    >     make which work better on OSX
    >     - add support for searching /Applications and /Network/Applications
    >     - add support for .app bundles
    > 
    > Affected files ...
    > 
    > ... //depot/main/Apps/Komodo-devel/src/python-sitelib/which.py#7 edit
    > 
    > Differences ...
    > 
    > ==== //depot/main/Apps/Komodo-devel/src/python-sitelib/which.py#7 (text) ====
    > 
    > @@ -126,10 +126,11 @@
    >                  sys.stderr.write("duplicate: %s (%s)\n" % potential)
    >              return None
    >      else:
    > -        if not stat.S_ISREG(os.stat(potential[0]).st_mode):
    > +        darwinApp = sys.platform == 'darwin' and potential[0][-4:]=='.app'
    > +        if not darwinApp and not stat.S_ISREG(os.stat(potential[0]).st_mode):
    >              if verbose:
    >                  sys.stderr.write("not a regular file: %s (%s)\n" % potential)
    > -        elif not os.access(potential[0], os.X_OK):
    > +        elif not darwinApp and not os.access(potential[0], os.X_OK):
    >              if verbose:
    >                  sys.stderr.write("no executable access: %s (%s)\n"\
    >                                   % potential)
    > @@ -166,6 +167,9 @@
    >          path = os.environ.get("PATH", "").split(os.pathsep)
    >          if sys.platform.startswith("win"):
    >              path.insert(0, os.curdir)  # implied by Windows shell
    > +        if sys.platform == 'darwin':
    > +            path.insert(0, '/Network/Applications')
    > +            path.insert(0, '/Applications')
    >      else:
    >          usingGivenPath = 1
    >  
    > @@ -182,6 +186,9 @@
    >                  exts = ['.COM', '.EXE', '.BAT']
    >          elif not isinstance(exts, list):
    >              raise TypeError("'exts' argument must be a list or None")
    > +    elif sys.platform == 'darwin':
    > +        if exts is None:
    > +            exts = ['.app']
    >      else:
    >          if exts is not None:
    >              raise WhichError("'exts' argument is not supported on "\
    > @@ -202,7 +209,8 @@
    >              for ext in ['']+exts:
    >                  absName = os.path.abspath(
    >                      os.path.normpath(os.path.join(dirName, command+ext)))
    > -                if os.path.isfile(absName):
    > +                if os.path.isfile(absName) or (sys.platform == 'darwin' and \
    > +                    absName[-4:]=='.app' and os.path.isdir(absName)):
    >                      if usingGivenPath:
    >                          fromWhere = "from given path element %d" % i
    >                      elif not sys.platform.startswith("win"):

  Here is a start with slight improvements:

    > Index: which.py
    > ===================================================================
    > --- which.py	(revision 270)
    > +++ which.py	(working copy)
    > @@ -126,9 +126,18 @@
    >                  sys.stderr.write("duplicate: %s (%s)\n" % potential)
    >              return None
    >      else:
    > -        if not stat.S_ISREG(os.stat(potential[0]).st_mode):
    > +        st_mode = os.stat(potential[0]).st_mode
    > +        isMacAppBundle = sys.platform == "darwin" \
    > +                         and potential[0].endswith(".app") \
    > +                         and stat.S_ISDIR(st_mode)
    > +        if not isMacAppBundle and not stat.S_ISREG(st_mode):
    >              if verbose:
    > -                sys.stderr.write("not a regular file: %s (%s)\n" % potential)
    > +                if sys.platform == "darwin":
    > +                    sys.stderr.write("not a regular file or .app bundle: "
    > +                                     "%s (%s)\n" % potential)
    > +                else:
    > +                    sys.stderr.write("not a regular file: %s (%s)\n"
    > +                                     % potential)
    >          elif not os.access(potential[0], os.X_OK):
    >              if verbose:
    >                  sys.stderr.write("no executable access: %s (%s)\n"\


# Low Priority

- have a version for pre-generators (i.e. Python 2.1)
- add a "logging" interface