def __defaults(self, plistName='Defaults'): if self.__bundlePath is None: self.__bundlePath = NSWorkspace.sharedWorkspace().absolutePathForAppBundleWithIdentifier_(self.__bundleID) if self.__bundlePath: plistPath = path.join(self.__bundlePath, "Contents/Resources/%s.plist" % plistName) plist = NSDictionary.dictionaryWithContentsOfFile_(plistPath) if plist: return plist return NSDictionary.dictionary()
def main(): format = None opts, args = getopt.getopt(sys.argv[1:], 'f:', ['format=']) for o, a in opts: if o in ('-f', '--format'): format = a if format == 'markdown': printMarkdownHeader() codeSnippets = []; path = os.path.expanduser('~/Library/Developer/Xcode/UserData/CodeSnippets') for dirname, dirnames, filenames in os.walk(path): for filename in filenames: if filename.endswith('codesnippet'): from AppKit import NSDictionary snippetDict = NSDictionary.dictionaryWithContentsOfFile_(os.path.join(path, filename)) # objDict = NSDictionary.dictionaryWithObjectsAndKeys_(filename,'filename',snippetDict,'snippet') codeSnippets.append({'filename':filename,'snippet':snippetDict}); sortedCodeSnippets = sorted(codeSnippets, key=lambda k: k['snippet']['IDECodeSnippetTitle'].lower()) for objDict in sortedCodeSnippets: filename = objDict['filename'] dict = objDict['snippet'] if format == 'markdown': showAsMarkdown(filename, dict) else: show(filename, dict) if format == 'markdown': printMarkdownFooter()
def __setup(self, defaultsPlistName=None): NSUserDefaults.resetStandardUserDefaults() prefs = NSUserDefaults.standardUserDefaults() self.defaults = self.__defaults(defaultsPlistName) domain_data = prefs.persistentDomainForName_(self.__bundleID) if domain_data: self.data = domain_data else: self.data = NSDictionary.dictionary()
def __setup(self, defaultsPlistName=None): NSUserDefaults.resetStandardUserDefaults() prefs = NSUserDefaults.standardUserDefaults() self.defaults = self.__defaults(defaultsPlistName) domainData = prefs.persistentDomainForName_(self.__bundleID) if domainData: self.data = domainData else: self.data = NSDictionary.dictionary()
def launchAppByBundlePath(bundlePath, arguments=[]): """ launchAppByBundlePath - Launch app with a given bundle path Return True if succeed """ bundleUrl = NSURL.URLWithString_(bundlePath) workspace = AppKit.NSWorkspace.sharedWorkspace() arguments_strings = map(lambda a: NSString.stringWithString_(str(a)), arguments) arguments = NSDictionary.dictionaryWithDictionary_( {AppKit.NSWorkspaceLaunchConfigurationArguments: NSArray.arrayWithArray_(arguments_strings)} ) return workspace.launchApplicationAtURL_options_configuration_error_( bundleUrl, AppKit.NSWorkspaceLaunchAllowingClassicStartup, arguments, None )
def launchAppByBundlePath(bundlePath, arguments=[]): ''' launchAppByBundlePath - Launch app with a given bundle path Return True if succeed ''' bundleUrl = NSURL.fileURLWithPath_(bundlePath) workspace = AppKit.NSWorkspace.sharedWorkspace() arguments_strings = map(lambda a: NSString.stringWithString_(str(a)), arguments) arguments = NSDictionary.dictionaryWithDictionary_({ AppKit.NSWorkspaceLaunchConfigurationArguments: NSArray.arrayWithArray_(arguments_strings) }) return workspace.launchApplicationAtURL_options_configuration_error_( bundleUrl, AppKit.NSWorkspaceLaunchAllowingClassicStartup, arguments, None)
def main(): format = None opts, args = getopt.getopt(sys.argv[1:], 'f:', ['format=']) for o, a in opts: if o in ('-f', '--format'): format = a path = os.path.expanduser('~/Library/Developer/Xcode/UserData/CodeSnippets') for dirname, dirnames, filenames in os.walk(path): for filename in filenames: if filename.endswith('codesnippet'): from AppKit import NSDictionary dict = NSDictionary.dictionaryWithContentsOfFile_(os.path.join(path, filename)) if format == 'markdown': showAsMarkdown(filename, dict) else: show(filename, dict)
def main(): format = None opts, args = getopt.getopt(sys.argv[1:], 'f:', ['format=']) for o, a in opts: if o in ('-f', '--format'): format = a if format == 'markdown': printMarkdownHeader() codeSnippets = [] path = os.path.expanduser( '~/Library/Developer/Xcode/UserData/CodeSnippets') for dirname, dirnames, filenames in os.walk(path): for filename in filenames: if filename.endswith('codesnippet'): from AppKit import NSDictionary snippetDict = NSDictionary.dictionaryWithContentsOfFile_( os.path.join(path, filename)) # objDict = NSDictionary.dictionaryWithObjectsAndKeys_(filename,'filename',snippetDict,'snippet') codeSnippets.append({ 'filename': filename, 'snippet': snippetDict }) sortedCodeSnippets = sorted( codeSnippets, key=lambda k: k['snippet']['IDECodeSnippetTitle'].lower()) for objDict in sortedCodeSnippets: filename = objDict['filename'] dict = objDict['snippet'] if format == 'markdown': showAsMarkdown(filename, dict) else: show(filename, dict) if format == 'markdown': printMarkdownFooter()
def PList(name): path = bundle_path(name, 'plist') return NSDictionary.dictionaryWithContentsOfFile_(path)