summaryrefslogtreecommitdiffstats
path: root/Mac/Tools/IDE/PythonIDEMain.py
diff options
context:
space:
mode:
Diffstat (limited to 'Mac/Tools/IDE/PythonIDEMain.py')
-rw-r--r--Mac/Tools/IDE/PythonIDEMain.py45
1 files changed, 34 insertions, 11 deletions
diff --git a/Mac/Tools/IDE/PythonIDEMain.py b/Mac/Tools/IDE/PythonIDEMain.py
index 5987c10..3ad35b7 100644
--- a/Mac/Tools/IDE/PythonIDEMain.py
+++ b/Mac/Tools/IDE/PythonIDEMain.py
@@ -32,6 +32,11 @@ def getmodtime(file):
class PythonIDE(Wapplication.Application):
def __init__(self):
+ if sys.platform == "darwin":
+ if len(sys.argv) > 1 and sys.argv[1].startswith("-psn"):
+ home = os.getenv("HOME")
+ if home:
+ os.chdir(home)
self.preffilepath = os.path.join("Python", "PythonIDE preferences")
Wapplication.Application.__init__(self, 'Pide')
from Carbon import AE
@@ -49,11 +54,6 @@ class PythonIDE(Wapplication.Application):
self.quitevent)
import PyConsole, PyEdit
Splash.wait()
- if sys.platform == "darwin":
- if sys.argv and sys.argv[0].startswith("-psn"):
- home = os.getenv("HOME")
- if home:
- os.chdir(home)
# With -D option (OSX command line only) keep stderr, for debugging the IDE
# itself.
debug_stderr = None
@@ -140,9 +140,12 @@ class PythonIDE(Wapplication.Application):
except:
path = os.path.join(os.getcwd(), "Mac", "IDE scripts")
if not os.path.exists(path):
- path = os.path.join(os.getcwd(), "Scripts")
+ if sys.platform == "darwin":
+ path = os.path.join(os.getenv("HOME"), "Library", "Python", "IDE-Scripts")
+ else:
+ path = os.path.join(os.getcwd(), "Scripts")
if not os.path.exists(path):
- os.mkdir(path)
+ os.makedirs(path)
f = open(os.path.join(path, "Place your scripts here"+ELIPSES), "w")
f.close()
fsr = File.FSRef(path)
@@ -451,11 +454,31 @@ class PythonIDE(Wapplication.Application):
# is located in the framework, but there's a symlink in Python.app.
# And as AHRegisterHelpBook wants a bundle (with the right bits in
# the plist file) we refer it to Python.app
+ #
+ # To make matters worse we have to look in two places: first in the IDE
+ # itself, then in the Python application inside the framework.
+ has_help = False
+ has_doc = False
+ ide_path_components = sys.argv[0].split("/")
+ if ide_path_components[-3:] == ["Contents", "Resources", "PythonIDE.py"]:
+ ide_app = "/".join(ide_path_components[:-3])
+ help_source = os.path.join(ide_app, 'Contents/Resources/English.lproj/Documentation')
+ doc_source = os.path.join(ide_app, 'Contents/Resources/English.lproj/PythonDocumentation')
+ has_help = os.path.isdir(help_source)
+ has_doc = os.path.isdir(doc_source)
+ if has_help or has_doc:
+ try:
+ from Carbon import AH
+ AH.AHRegisterHelpBook(ide_app)
+ except (ImportError, MacOS.Error), arg:
+ pass # W.Message("Cannot register Python Documentation: %s" % str(arg))
python_app = os.path.join(sys.prefix, 'Resources/Python.app')
- help_source = os.path.join(python_app, 'Contents/Resources/English.lproj/Documentation')
- doc_source = os.path.join(python_app, 'Contents/Resources/English.lproj/PythonDocumentation')
- has_help = os.path.isdir(help_source)
- has_doc = os.path.isdir(doc_source)
+ if not has_help:
+ help_source = os.path.join(python_app, 'Contents/Resources/English.lproj/Documentation')
+ has_help = os.path.isdir(help_source)
+ if not has_doc:
+ doc_source = os.path.join(python_app, 'Contents/Resources/English.lproj/PythonDocumentation')
+ has_doc = os.path.isdir(doc_source)
if has_help or has_doc:
try:
from Carbon import AH