Commits

Ronald Oussoren committed 26ecdf4

* sync main.m with Cocoa-Python Application
* the template now creates a working application

Comments (0)

Files changed (4)

Xcode/Project Templates/Cocoa-Python Document-based Application/CocoaApp.xcode/TemplateInfo.plist

 	FilesToMacroExpand = (
 		"__main__.py",
 		"ÇPROJECTNAMEASIDENTIFIERČAppDelegate.py",
+		"ÇPROJECTNAMEASIDENTIFIERČDocument.py",
 		"ÇPROJECTNAMEASIDENTIFIERČ_Prefix.pch",
 		"Info.plist",
 		"English.lproj/InfoPlist.strings",

Xcode/Project Templates/Cocoa-Python Document-based Application/CocoaAppDocument.py

-"""?PROJECTNAMEASIDENTIFIER? -- A minimal Document-based Cocoa application."""
+#
+#  ÇPROJECTNAMEASIDENTIFIERČDocument.py
+#  ÇPROJECTNAMEČ
+#
+#  Created by ÇFULLUSERNAMEČ on ÇDATEČ.
+#  Copyright (c) ÇYEARČ ÇORGANIZATIONNAMEČ. All rights reserved.
+#
+
 
 
 from PyObjCTools import NibClassBuilder, AppHelper
 
 
-NibClassBuilder.extractClasses("?PROJECTNAMEASIDENTIFIER?")
+NibClassBuilder.extractClasses("ÇPROJECTNAMEASIDENTIFIERČDocument")
 
 
 # class defined in TinyTinyDocument.nib
-class ?PROJECTNAMEASIDENTIFIER?(NibClassBuilder.AutoBaseClass):
+class ÇPROJECTNAMEASIDENTIFIERČDocument(NibClassBuilder.AutoBaseClass):
     # the actual base class is NSDocument
     # The following outlets are added to the class:
     # textView
     path = None
 
     def windowNibName(self):
-        return "?PROJECTNAMEASIDENTIFIER?"
+        return "ÇPROJECTNAMEASIDENTIFIERČDocument"
 
     def readFromFile_ofType_(self, path, tp):
         if self.textView is None:

Xcode/Project Templates/Cocoa-Python Document-based Application/Info.plist

 		<dict>
 			<key>CFBundleTypeExtensions</key>
 			<array>
-				<string>ÂŤPROJECTNAMEAIDENTIFIERÂť</string>
+				<string>ÂŤPROJECTNAMEASIDENTIFIERÂť</string>
 				<string>*</string>
 			</array>
 			<key>CFBundleTypeName</key>
-			<string>ÂŤPROJECTNAMEAIDENTIFIERÂť File</string>
+			<string>ÂŤPROJECTNAMEASIDENTIFIERÂť File</string>
 			<key>CFBundleTypeRole</key>
 			<string>Editor</string>
 			<key>NSDocumentClass</key>
-			<string>ÂŤPROJECTNAMEAIDENTIFIERÂťDocument</string>
+			<string>ÂŤPROJECTNAMEASIDENTIFIERÂťDocument</string>
 		</dict>
 	</array>
 	<key>CFBundleExecutable</key>

Xcode/Project Templates/Cocoa-Python Document-based Application/main.m

 	}
 	
 	NSString *pythonPath = [[[NSProcessInfo processInfo] environment] objectForKey: @"PYTHONPATH"];
-    NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
-    NSMutableArray *pythonPathArray = [NSMutableArray arrayWithObjects: resourcePath, [resourcePath stringByAppendingPathComponent:@"PyObjC"], nil];
+	NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
+	NSMutableArray *pythonPathArray = [NSMutableArray arrayWithObjects: resourcePath, [resourcePath stringByAppendingPathComponent:@"PyObjC"], nil];
 	if (pythonPath != nil)
-        [pythonPathArray addObjectsFromArray: [pythonPath componentsSeparatedByString: @":"]];
-    
+		[pythonPathArray addObjectsFromArray: [pythonPath componentsSeparatedByString: @":"]];
+
 	// I *refuse* to set dirty DYLD environment variables..  
 	// If you want that, you'll have to do it in your main script or fork this bootstrap ;)
 	//
-    setenv("PYTHONPATH", [[pythonPathArray componentsJoinedByString:@":"] UTF8String], 1);
+	setenv("PYTHONPATH", [[pythonPathArray componentsJoinedByString:@":"] UTF8String], 1);
 	
 	NSArray *possibleMains = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"PyMainFileNames"];
 	if ( !possibleMains )
 		possibleMains = [NSArray array];
 	// find main python file.  __main__.py seems to be a standard, so we'll go ahead and add defaults.
-    possibleMains = [possibleMains arrayByAddingObjectsFromArray:[NSArray arrayWithObjects:
-        @"__main__.py",
-        @"__main__.pyc",
-        @"__main__.pyo",
-        @"__realmain__.py",
-        @"__realmain__.pyc",
-        @"__realmain__.pyo",
-        @"Main.py",
-        @"Main.pyc",
-        @"Main.pyo",
-        nil]];
-    NSEnumerator *possibleMainsEnumerator = [possibleMains objectEnumerator];
-    NSString *mainPyPath = nil;
-    NSString *nextFileName;
+	possibleMains = [possibleMains arrayByAddingObjectsFromArray:[NSArray arrayWithObjects:
+		@"__main__.py",
+		@"__main__.pyc",
+		@"__main__.pyo",
+		@"__realmain__.py",
+		@"__realmain__.pyc",
+		@"__realmain__.pyo",
+		@"Main.py",
+		@"Main.pyc",
+		@"Main.pyo",
+		nil]];
+	NSEnumerator *possibleMainsEnumerator = [possibleMains objectEnumerator];
+	NSString *mainPyPath = nil;
+	NSString *nextFileName;
 	
-    while (nextFileName = [possibleMainsEnumerator nextObject]) {
-        mainPyPath = [[NSBundle mainBundle] pathForResource: nextFileName ofType: nil];
-        if ( mainPyPath )
-            break;
-    }
+	while (nextFileName = [possibleMainsEnumerator nextObject]) {
+		mainPyPath = [[NSBundle mainBundle] pathForResource: nextFileName ofType: nil];
+		if ( mainPyPath )
+			break;
+	}
 
 	if ( !mainPyPath )
 		return report_error([ERR_NOPYTHONSCRIPT stringByAppendingString:[possibleMains componentsJoinedByString:@"\r"]]);
 		return report_linkEdit_error(); \
 	NAME ## Ptr NAME = (NAME ## Ptr)NSAddressOfSymbol(tmpSymbol)
 
-    LOOKUP(Py_SetProgramName);
-    LOOKUP(Py_Initialize);
-    LOOKUP(PyRun_SimpleFile);
-    LOOKUP(Py_Finalize);
-    LOOKUP(PySys_GetObject);
-    LOOKUP(PySys_SetArgv);
-    LOOKUP(PyObject_Str);
-    LOOKUP(PyString_AsString);
-    LOOKUP(PyObject_GetAttrString);
+	LOOKUP(Py_SetProgramName);
+	LOOKUP(Py_Initialize);
+	LOOKUP(PyRun_SimpleFile);
+	LOOKUP(Py_Finalize);
+	LOOKUP(PySys_GetObject);
+	LOOKUP(PySys_SetArgv);
+	LOOKUP(PyObject_Str);
+	LOOKUP(PyString_AsString);
+	LOOKUP(PyObject_GetAttrString);
 
 #undef LOOKUP
 
 	pythonProgramName = [[[pythonProgramName stringByAppendingPathComponent:@"bin"] stringByAppendingPathComponent:pyExecutableName] retain];
 	Py_SetProgramName([pythonProgramName fileSystemRepresentation]);
 	Py_Initialize();
-    PySys_SetArgv(argc, (char **)argv);
+	PySys_SetArgv(argc, (char **)argv);
 	
-    NSAutoreleasePool *pythonPool = [[NSAutoreleasePool alloc] init];
-    
-	FILE *mainPy = fopen([[mainPyPath retain] fileSystemRepresentation], "r");
-	NSString *scriptName = [mainPyPath lastPathComponent];
-	int rval = PyRun_SimpleFile(mainPy, [[scriptName retain] cString]);
+	NSAutoreleasePool *pythonPool = [[NSAutoreleasePool alloc] init];
+
+	[mainPyPath retain];
+	FILE *mainPy = fopen([mainPyPath retain fileSystemRepresentation], "r");
+	int rval = PyRun_SimpleFile(mainPy, [mainPyPath fileSystemRepresentation]);
 	fclose(mainPy);
-	[scriptName release];
 	[mainPyPath release];
 
 	while ( rval ) {
 		break;
 	}
 
-    [pythonPool release];
-    
+	[pythonPool release];
+
 	Py_Finalize();
 
 	[pythonProgramName release];
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.