Ejemplo n.º 1
0
def exportdictionaries(sources, outfolder, 
		fileformats=[AEEnum(kFrameHTML)], styles=[AEEnum(kASStyle)],
		compactclasses=False, showinvisibles=False, usesubfolders=False):
	items = []
	for alias in sources:
		name = namefrompath(alias.path)
		isosax = alias.path.lower().endswith('.osax')
		items.append({
			'objcPrefix': objcglue.nametoprefix(name),
			'name': name, 
			'path': alias.path,
			'isOSAX': isosax,
			})
	outfolder = outfolder.path
	plaintext = AEEnum(kPlainText) in fileformats
	singlehtml = AEEnum(kSingleHTML) in fileformats
	framehtml = AEEnum(kFrameHTML) in fileformats
	isobjcglue = AEEnum(kObjCGlue) in fileformats
	styles = [kAECodeToStyle[o.code] for o in styles]
	options = []
	if compactclasses:
		options.append('collapse')
	if showinvisibles:
		options.append('full')
	progressobj = AEProgress(len(items), len(styles), len(fileformats), None)
	return _export(items, styles, plaintext, singlehtml, framehtml, isobjcglue, options, outfolder, usesubfolders, progressobj)
Ejemplo n.º 2
0
def handle_exportdictionaries(sources, outfolder, 
		fileformats=[AEEnum(kFrameHTML)], styles=[AEEnum(kASStyle)],
		compactclasses=False, showinvisibles=False, usesubfolders=False):
	items = []
	for alias in sources:
		name = os.path.splitext(os.path.basename(alias.path.rstrip('/')))[0]
		items.append({
			'objcPrefix': objcappscript.nametoprefix(name),
			'name': name, 
			'path': alias.path,
			})
	outfolder = outfolder.path
	plaintext = AEEnum(kPlainText) in fileformats
	singlehtml = AEEnum(kSingleHTML) in fileformats
	framehtml = AEEnum(kFrameHTML) in fileformats
	isobjcglue = AEEnum(kObjCGlue) in fileformats
	styles = [kAECodeToStyle[o.code] for o in styles]
	options = []
	if compactclasses:
		options.append('collapse')
	if showinvisibles:
		options.append('full')
	progressobj = AEProgress(len(items), len(styles), len(fileformats), None)
	
	# general info
	infoPlist = NSBundle.mainBundle().infoDictionary()
	info = {}
	info['generator-name'] = infoPlist['CFBundleDisplayName']
	info['generator-version'] = infoPlist['CFBundleShortVersionString']	
	return export(items, styles, plaintext, singlehtml, framehtml, isobjcglue, options, outfolder, usesubfolders, progressobj, info)
Ejemplo n.º 3
0
 def _addPathToSelectedFiles(self, path):
     name = os.path.splitext(os.path.basename(path.rstrip('/')))[0]
     item = {'objcPrefix': nametoprefix(name), 'name': name, 'path': path}
     if item not in self.selectedFiles():
         self.insertObject_inSelectedFilesAtIndex_(
             item, self.countOfSelectedFiles())
     self._updateLocks()
Ejemplo n.º 4
0
def handle_exportdictionaries(sources,
                              outfolder,
                              fileformats=[AEEnum(kFrameHTML)],
                              styles=[AEEnum(kASStyle)],
                              compactclasses=False,
                              showinvisibles=False,
                              usesubfolders=False):
    items = []
    for alias in sources:
        name = os.path.splitext(os.path.basename(alias.path.rstrip('/')))[0]
        items.append({
            'objcPrefix': objcappscript.nametoprefix(name),
            'name': name,
            'path': alias.path,
        })
    outfolder = outfolder.path
    plaintext = AEEnum(kPlainText) in fileformats
    singlehtml = AEEnum(kSingleHTML) in fileformats
    framehtml = AEEnum(kFrameHTML) in fileformats
    isobjcglue = AEEnum(kObjCGlue) in fileformats
    styles = [kAECodeToStyle[o.code] for o in styles]
    options = []
    if compactclasses:
        options.append('collapse')
    if showinvisibles:
        options.append('full')
    progressobj = AEProgress(len(items), len(styles), len(fileformats), None)

    # general info
    infoPlist = NSBundle.mainBundle().infoDictionary()
    info = {}
    info['generator-name'] = infoPlist['CFBundleDisplayName']
    info['generator-version'] = infoPlist['CFBundleShortVersionString']
    return export(items, styles, plaintext, singlehtml, framehtml, isobjcglue,
                  options, outfolder, usesubfolders, progressobj, info)
Ejemplo n.º 5
0
def exportdictionaries(sources,
                       outfolder,
                       fileformats=[AEEnum(kFrameHTML)],
                       styles=[AEEnum(kASStyle)],
                       compactclasses=False,
                       showinvisibles=False,
                       usesubfolders=False):
    items = []
    for alias in sources:
        name = namefrompath(alias.path)
        isosax = alias.path.lower().endswith('.osax')
        items.append({
            'objcPrefix': objcglue.nametoprefix(name),
            'name': name,
            'path': alias.path,
            'isOSAX': isosax,
        })
    outfolder = outfolder.path
    plaintext = AEEnum(kPlainText) in fileformats
    singlehtml = AEEnum(kSingleHTML) in fileformats
    framehtml = AEEnum(kFrameHTML) in fileformats
    isobjcglue = AEEnum(kObjCGlue) in fileformats
    styles = [kAECodeToStyle[o.code] for o in styles]
    options = []
    if compactclasses:
        options.append('collapse')
    if showinvisibles:
        options.append('full')
    progressobj = AEProgress(len(items), len(styles), len(fileformats), None)
    return _export(items, styles, plaintext, singlehtml, framehtml, isobjcglue,
                   options, outfolder, usesubfolders, progressobj)
Ejemplo n.º 6
0
 def _addPathToSelectedFiles(self, path, isosax=False):
     name = namefrompath(path)
     item = {
         'objcPrefix': objcglue.nametoprefix(name),
         'name': name,
         'path': path,
         'isOSAX': isosax
     }
     if item not in self.selectedFiles():
         self.insertObject_inSelectedFilesAtIndex_(
             item, self.countOfSelectedFiles())
     self._updateLocks()
Ejemplo n.º 7
0
	def _addPathToSelectedFiles(self, path):
		name = os.path.splitext(os.path.basename(path.rstrip('/')))[0]
		item = {'objcPrefix': nametoprefix(name), 'name': name, 'path': path}
		if item not in self.selectedFiles():
			self.insertObject_inSelectedFilesAtIndex_(item, self.countOfSelectedFiles())
		self._updateLocks()
Ejemplo n.º 8
0
def renderCommand(apppath, addressdesc, 
		eventcode, 
		targetref, directparam, paramsdict, 
		resulttype, modeflags, timeout, 
		appdata):
	global _appData
	_appData = appdata
	if not _formatterCache.has_key((addressdesc.type, addressdesc.data)):
		typebycode, typebyname, referencebycode, referencebyname = \
				_terminology.tablesforapp(aem.Application(desc=addressdesc))
		_formatterCache[(addressdesc.type, addressdesc.data)] = typebycode, referencebycode
	typebycode, referencebycode = _formatterCache[(addressdesc.type, addressdesc.data)]
	
	appname = os.path.splitext(os.path.basename(apppath))[0]
	appvar = _convert(appname.lower())
	prefix = nametoprefix(appname)
	
	s = '#import "%sGlue/%sGlue.h"\n' % (prefix, prefix)
	
	f = _Formatter(typebycode, referencebycode, '', '')
	s += '%sApplication *%s = [%sApplication applicationWithName: %s];\n' % (
			prefix, appvar, prefix, f.format(appname)) # TO DO: use bundle ID if available

	commandname, paramnamebycode = referencebycode[kCommand+eventcode][1]
	
	if directparam is not kNoParam:
		f = _Formatter(typebycode, referencebycode, appvar, prefix)
		directparam = f.format(directparam)
	
	params = []
	for k, v in paramsdict.items():
		f = _Formatter(typebycode, referencebycode, appvar, prefix)
		params.append('%s: %s' % (paramnamebycode[k], f.format(v)))
	
	if targetref and not isinstance(targetref, appscript.Application):
		f = _Formatter(typebycode, referencebycode, appvar, prefix)
		s += '%sReference *ref = %s;\n' % (prefix, f.format(targetref))
		target = 'ref'
	else:
		target = appvar
	if params or resulttype or modeflags != 0x1043 or timeout != -1:
		if eventcode == 'coresetd': 
			# unlike py-appscript, objc-appscript doesn't special-case 'set' command's 'to' param,
			# so put it back in params list
			params = ['to: %s' % directparam] + params
			directparam = kNoParam
		classprefix = commandname[0].upper() + commandname[1:]
		if directparam is not kNoParam:
			tmp = '[%s %s: %s]' % (target, commandname, directparam)
		else:
			tmp = '[%s %s]' % (target, commandname)
		for param in params:
			tmp = '[%s %s]' % (tmp, param)
		# args
		if resulttype:
			code = _codecs.unpack(appdata.pack(resulttype)).code
			tmp = '[%s requestedType: [ASConstant %s]]' % (tmp, typebycode[code]) # .AS_name
		if timeout != -1:
			tmp = '[%s timeout: %i]' % (tmp, timeout / 60)
		if modeflags & 3 == aem.kae.kAENoReply:
			tmp = '[%s ignoreReply]' % tmp
		
		s += '%s%sCommand *cmd = %s;\n' % (prefix, classprefix, tmp)
		target = 'cmd'
	elif eventcode == 'coresetd':
		return s + 'id result = [%s setItem: %s];' % (target, directparam)
	elif eventcode == 'coregetd':
		return s + 'id result = [%s getItem];' % target
	else:
		target = '[%s %s]' % (target, commandname)
	s += 'id result = [%s send];' % target
	return s
Ejemplo n.º 9
0
	def _addPathToSelectedFiles(self, path, isosax=False):
		name = namefrompath(path)
		item = {'objcPrefix': objcglue.nametoprefix(name), 'name': name, 'path': path, 'isOSAX': isosax}
		if item not in self.selectedFiles():
			self.insertObject_inSelectedFilesAtIndex_(item, self.countOfSelectedFiles())
		self._updateLocks()
Ejemplo n.º 10
0
def renderCommand(apppath, addressdesc, eventcode, targetref, directparam,
                  paramsdict, resulttype, modeflags, timeout, appdata):
    global _appData
    _appData = appdata
    if not _formatterCache.has_key((addressdesc.type, addressdesc.data)):
        typebycode, typebyname, referencebycode, referencebyname = \
          _terminology.tablesforapp(aem.Application(desc=addressdesc))
        _formatterCache[(addressdesc.type,
                         addressdesc.data)] = typebycode, referencebycode
    typebycode, referencebycode = _formatterCache[(addressdesc.type,
                                                   addressdesc.data)]

    appname = os.path.splitext(os.path.basename(apppath))[0]
    appvar = _convert(appname.lower())
    prefix = nametoprefix(appname)

    s = '#import "%sGlue/%sGlue.h"\n' % (prefix, prefix)

    f = _Formatter(typebycode, referencebycode, '', '')
    s += '%sApplication *%s = [%sApplication applicationWithName: %s];\n' % (
        prefix, appvar, prefix, f.format(appname)
    )  # TO DO: use bundle ID if available

    commandname, paramnamebycode = referencebycode[kCommand + eventcode][1]

    if directparam is not kNoParam:
        f = _Formatter(typebycode, referencebycode, appvar, prefix)
        directparam = f.format(directparam)

    params = []
    for k, v in paramsdict.items():
        f = _Formatter(typebycode, referencebycode, appvar, prefix)
        params.append('%s: %s' % (paramnamebycode[k], f.format(v)))

    if targetref and not isinstance(targetref, appscript.Application):
        f = _Formatter(typebycode, referencebycode, appvar, prefix)
        s += '%sReference *ref = %s;\n' % (prefix, f.format(targetref))
        target = 'ref'
    else:
        target = appvar
    if params or resulttype or modeflags != 0x1043 or timeout != -1:
        if eventcode == 'coresetd':
            # unlike py-appscript, objc-appscript doesn't special-case 'set' command's 'to' param,
            # so put it back in params list
            params = ['to: %s' % directparam] + params
            directparam = kNoParam
        classprefix = commandname[0].upper() + commandname[1:]
        if directparam is not kNoParam:
            tmp = '[%s %s: %s]' % (target, commandname, directparam)
        else:
            tmp = '[%s %s]' % (target, commandname)
        for param in params:
            tmp = '[%s %s]' % (tmp, param)
        # args
        if resulttype:
            code = _codecs.unpack(appdata.pack(resulttype)).code
            tmp = '[%s requestedType: [ASConstant %s]]' % (
                tmp, typebycode[code])  # .AS_name
        if timeout != -1:
            tmp = '[%s timeout: %i]' % (tmp, timeout / 60)
        if modeflags & 3 == aem.kae.kAENoReply:
            tmp = '[%s ignoreReply]' % tmp

        s += '%s%sCommand *cmd = %s;\n' % (prefix, classprefix, tmp)
        target = 'cmd'
    elif eventcode == 'coresetd':
        return s + 'id result = [%s setItem: %s];' % (target, directparam)
    elif eventcode == 'coregetd':
        return s + 'id result = [%s getItem];' % target
    else:
        target = '[%s %s]' % (target, commandname)
    s += 'id result = [%s send];' % target
    return s