Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | # High Priority |
michael@0 | 2 | |
michael@0 | 3 | - Figure out the script story on the various platforms. On Windows, look into |
michael@0 | 4 | the launcher thing that effbot has. Unix, don't install the script my |
michael@0 | 5 | default. They can always do "python -m which ..." with Python >= 2.4. |
michael@0 | 6 | Suggest an alias that some folks might want to use for that. |
michael@0 | 7 | |
michael@0 | 8 | |
michael@0 | 9 | # Medium Priority |
michael@0 | 10 | |
michael@0 | 11 | - define __all__? |
michael@0 | 12 | - improve test suite |
michael@0 | 13 | - test with other versions of Python |
michael@0 | 14 | - get the PATHEXT attached extension to reflect the actual canonical |
michael@0 | 15 | case of file matches on Windows, currently the extension from PATHEXT |
michael@0 | 16 | is always uppercase |
michael@0 | 17 | - What to do with Change 145624 by shanec. It is a bit of a |
michael@0 | 18 | bastardization. Maybe allow this with a special option to allow the change |
michael@0 | 19 | in semantics. |
michael@0 | 20 | |
michael@0 | 21 | > Change 145624 by shanec@shanec-ocelotl on 2005/05/24 16:51:55 |
michael@0 | 22 | > |
michael@0 | 23 | > make which work better on OSX |
michael@0 | 24 | > - add support for searching /Applications and /Network/Applications |
michael@0 | 25 | > - add support for .app bundles |
michael@0 | 26 | > |
michael@0 | 27 | > Affected files ... |
michael@0 | 28 | > |
michael@0 | 29 | > ... //depot/main/Apps/Komodo-devel/src/python-sitelib/which.py#7 edit |
michael@0 | 30 | > |
michael@0 | 31 | > Differences ... |
michael@0 | 32 | > |
michael@0 | 33 | > ==== //depot/main/Apps/Komodo-devel/src/python-sitelib/which.py#7 (text) ==== |
michael@0 | 34 | > |
michael@0 | 35 | > @@ -126,10 +126,11 @@ |
michael@0 | 36 | > sys.stderr.write("duplicate: %s (%s)\n" % potential) |
michael@0 | 37 | > return None |
michael@0 | 38 | > else: |
michael@0 | 39 | > - if not stat.S_ISREG(os.stat(potential[0]).st_mode): |
michael@0 | 40 | > + darwinApp = sys.platform == 'darwin' and potential[0][-4:]=='.app' |
michael@0 | 41 | > + if not darwinApp and not stat.S_ISREG(os.stat(potential[0]).st_mode): |
michael@0 | 42 | > if verbose: |
michael@0 | 43 | > sys.stderr.write("not a regular file: %s (%s)\n" % potential) |
michael@0 | 44 | > - elif not os.access(potential[0], os.X_OK): |
michael@0 | 45 | > + elif not darwinApp and not os.access(potential[0], os.X_OK): |
michael@0 | 46 | > if verbose: |
michael@0 | 47 | > sys.stderr.write("no executable access: %s (%s)\n"\ |
michael@0 | 48 | > % potential) |
michael@0 | 49 | > @@ -166,6 +167,9 @@ |
michael@0 | 50 | > path = os.environ.get("PATH", "").split(os.pathsep) |
michael@0 | 51 | > if sys.platform.startswith("win"): |
michael@0 | 52 | > path.insert(0, os.curdir) # implied by Windows shell |
michael@0 | 53 | > + if sys.platform == 'darwin': |
michael@0 | 54 | > + path.insert(0, '/Network/Applications') |
michael@0 | 55 | > + path.insert(0, '/Applications') |
michael@0 | 56 | > else: |
michael@0 | 57 | > usingGivenPath = 1 |
michael@0 | 58 | > |
michael@0 | 59 | > @@ -182,6 +186,9 @@ |
michael@0 | 60 | > exts = ['.COM', '.EXE', '.BAT'] |
michael@0 | 61 | > elif not isinstance(exts, list): |
michael@0 | 62 | > raise TypeError("'exts' argument must be a list or None") |
michael@0 | 63 | > + elif sys.platform == 'darwin': |
michael@0 | 64 | > + if exts is None: |
michael@0 | 65 | > + exts = ['.app'] |
michael@0 | 66 | > else: |
michael@0 | 67 | > if exts is not None: |
michael@0 | 68 | > raise WhichError("'exts' argument is not supported on "\ |
michael@0 | 69 | > @@ -202,7 +209,8 @@ |
michael@0 | 70 | > for ext in ['']+exts: |
michael@0 | 71 | > absName = os.path.abspath( |
michael@0 | 72 | > os.path.normpath(os.path.join(dirName, command+ext))) |
michael@0 | 73 | > - if os.path.isfile(absName): |
michael@0 | 74 | > + if os.path.isfile(absName) or (sys.platform == 'darwin' and \ |
michael@0 | 75 | > + absName[-4:]=='.app' and os.path.isdir(absName)): |
michael@0 | 76 | > if usingGivenPath: |
michael@0 | 77 | > fromWhere = "from given path element %d" % i |
michael@0 | 78 | > elif not sys.platform.startswith("win"): |
michael@0 | 79 | |
michael@0 | 80 | Here is a start with slight improvements: |
michael@0 | 81 | |
michael@0 | 82 | > Index: which.py |
michael@0 | 83 | > =================================================================== |
michael@0 | 84 | > --- which.py (revision 270) |
michael@0 | 85 | > +++ which.py (working copy) |
michael@0 | 86 | > @@ -126,9 +126,18 @@ |
michael@0 | 87 | > sys.stderr.write("duplicate: %s (%s)\n" % potential) |
michael@0 | 88 | > return None |
michael@0 | 89 | > else: |
michael@0 | 90 | > - if not stat.S_ISREG(os.stat(potential[0]).st_mode): |
michael@0 | 91 | > + st_mode = os.stat(potential[0]).st_mode |
michael@0 | 92 | > + isMacAppBundle = sys.platform == "darwin" \ |
michael@0 | 93 | > + and potential[0].endswith(".app") \ |
michael@0 | 94 | > + and stat.S_ISDIR(st_mode) |
michael@0 | 95 | > + if not isMacAppBundle and not stat.S_ISREG(st_mode): |
michael@0 | 96 | > if verbose: |
michael@0 | 97 | > - sys.stderr.write("not a regular file: %s (%s)\n" % potential) |
michael@0 | 98 | > + if sys.platform == "darwin": |
michael@0 | 99 | > + sys.stderr.write("not a regular file or .app bundle: " |
michael@0 | 100 | > + "%s (%s)\n" % potential) |
michael@0 | 101 | > + else: |
michael@0 | 102 | > + sys.stderr.write("not a regular file: %s (%s)\n" |
michael@0 | 103 | > + % potential) |
michael@0 | 104 | > elif not os.access(potential[0], os.X_OK): |
michael@0 | 105 | > if verbose: |
michael@0 | 106 | > sys.stderr.write("no executable access: %s (%s)\n"\ |
michael@0 | 107 | |
michael@0 | 108 | |
michael@0 | 109 | # Low Priority |
michael@0 | 110 | |
michael@0 | 111 | - have a version for pre-generators (i.e. Python 2.1) |
michael@0 | 112 | - add a "logging" interface |
michael@0 | 113 |