コード例 #1
0
ファイル: TTX.py プロジェクト: FilippiSilva/MEDWEB
    def handle_xml_file(self, path):
        prefs = getprefs()
        makesuitcase = int(prefs.get("makesuitcases", 0))
        dstfolder = prefs.get("ttoutput", DEFAULTTTOUTPUT)
        if not os.path.exists(dstfolder):
            os.mkdir(dstfolder)
        srcfilename = dstfilename = os.path.basename(path)
        if dstfilename[-4:] in (".ttx", ".xml"):
            dstfilename = dstfilename[:-4]
        if dstfilename[-4:] not in (".TTF", ".ttf"):
            dstfilename = dstfilename + ".TTF"
        dst = os.path.join(dstfolder, dstfilename)

        if makesuitcase:
            try:
                # see if the destination file is writable,
                # otherwise we'll get an error waaay at the end of
                # the parse procedure
                testref = Res.FSpOpenResFile(macfs.FSSpec(dst),
                                             3)  # read-write
            except Res.Error, why:
                if why[0] <> -43:  # file not found
                    EasyDialogs.Message(
                        "Can't create '%s'; file already open" % dst)
                    return
            else:
                Res.CloseResFile(testref)
コード例 #2
0
ファイル: TTX.py プロジェクト: FilippiSilva/MEDWEB
 def handle_resource_file(self, path):
     prefs = getprefs()
     dstfolder = prefs.get("xmloutput", DEFAULTXMLOUTPUT)
     if not os.path.exists(dstfolder):
         os.mkdir(dstfolder)
     filename = os.path.basename(path)
     fss = macfs.FSSpec(path)
     try:
         resref = Res.FSpOpenResFile(fss, 1)  # read-only
     except:
         return "unknown"
     Res.UseResFile(resref)
     pb = None
     try:
         n = Res.Count1Resources("sfnt")
         for i in range(1, n + 1):
             res = Res.Get1IndResource('sfnt', i)
             resid, restype, resname = res.GetResInfo()
             if not resname:
                 resname = filename + ` i `
             pb = ProgressBar("Dumping '%s' to XML..." % resname)
             dst = os.path.join(dstfolder, resname + ".ttx")
             try:
                 tt = ttLib.TTFont(path, i)
                 tt.saveXML(dst, pb)
             finally:
                 pb.close()
     finally:
         Res.CloseResFile(resref)
コード例 #3
0
 def evaluate(self, solution):
     y = solution.variables
     solution.objectives[:] = [
         -Res.Res(y, self.d, self.hStar),
         Cost.Cost(y, self.d)
     ]
     solution.constraints[:] = Constraint.Constraint(y, self.d, self.hStar)
コード例 #4
0
def mkalias(src, dst):
    """Create a finder alias"""
    srcfss = macfs.FSSpec(src)
    dstfss = macfs.FSSpec(dst)
    alias = srcfss.NewAlias()
    srcfinfo = srcfss.GetFInfo()

    Res.FSpCreateResFile(dstfss, srcfinfo.Creator, srcfinfo.Type, -1)
    h = Res.FSpOpenResFile(dstfss, 3)
    resource = Res.Resource(alias.data)
    resource.AddResource('alis', 0, '')
    Res.CloseResFile(h)

    dstfinfo = dstfss.GetFInfo()
    dstfinfo.Flags = dstfinfo.Flags | 0x8000  # Alias flag
    dstfss.SetFInfo(dstfinfo)
コード例 #5
0
 def __init__(self):
     import sys
     Res.OpenResFile('MkDistr.rsrc')
     self.inc = _testerhelp('include')
     self.exc = _testerhelp('exclude')
     self.ui = MkDistrUI(self)
     self.ui.mainloop()
     sys.exit(1)
コード例 #6
0
ファイル: homeResFile.py プロジェクト: Kurios/Project32
	def getInfo(self):
		if self.__haveInfo:
			return
		data = sstruct.pack(_FCBPBFormat, self)
		buf = array.array("c", data)
		ptr = buf.buffer_info()[0]
		err = _getInfo(ptr)
		if err:
			raise Res.Error("can't get file info", err)
		sstruct.unpack(_FCBPBFormat, buf.tostring(), self)
		self.__haveInfo = 1
コード例 #7
0
def create_from_scene_file(gtype, params):
    if 'use' in params and params['use'] == False:
        return None
    if 'shader' in params:
        params['shader'] = Res.combine_res_path(params['shader'])

    createCmd = '%s.create(%s)' % (gtype, params)
    go = eval(createCmd)
    if 'shader_params' in params:
        for p in params["shader_params"]:
            go.material.set_param(p, params["shader_params"][p])
    return go
コード例 #8
0
def create_sky(shader, shaderParams):
    if shader == None:
        return None
    if shaderParams == None:
        return None

    shader = Res.combine_res_path(shader)

    sky = Sky(shader)

    for p in shaderParams:
        sky.material.set_param(p, shaderParams[p])
    return sky
コード例 #9
0
ファイル: TTX.py プロジェクト: FilippiSilva/MEDWEB
def guessfiletype(path):
    #if path[-3:] == ".py":
    #	return "python"
    f = open(path, "rb")
    data = f.read(21)
    f.close()
    if data[:5] == "<?xml":
        return "xml"
    elif data[:4] in ("\000\001\000\000", "OTTO", "true"):
        return "datafork"
    else:
        # assume res fork font
        fss = macfs.FSSpec(path)
        try:
            resref = Res.FSpOpenResFile(fss, 1)  # read-only
        except:
            return "unknown"
        Res.UseResFile(resref)
        i = Res.Count1Resources("sfnt")
        Res.CloseResFile(resref)
        if i > 0:
            return "resource"
    return "unknown"
コード例 #10
0
ファイル: Light.py プロジェクト: AsehesL/PyRayTracerDemo
 def create(params):
     samplertype = params['sampler']
     samplenum = params['num_samples']
     sampler = eval('%s(%d)' % (samplertype, samplenum))
     shadow = False
     if 'shadow' in params:
         shadow = params['shadow'] == 1
     if 'shader' in params:
         params['shader'] = Res.combine_res_path(params['shader'])
     mat = Material(params["shader"], params["shader_params"])
     # if 'shader_params' in params:
     # 	for p in params["shader_params"]:
     # 		mat.set_param(p, params["shader_params"][p])
     return EnvironmentLight(sampler, shadow, mat)
コード例 #11
0
ファイル: listres.py プロジェクト: olympu/ancient-pythons
def list1resources():
    ntypes = Res.Count1Types()
    for itype in range(1, 1 + ntypes):
        type = Res.Get1IndType(itype)
        print "Type:", ` type `
        nresources = Res.Count1Resources(type)
        for i in range(1, 1 + nresources):
            Res.SetResLoad(0)
            res = Res.Get1IndResource(type, i)
            Res.SetResLoad(1)
            info(res)
コード例 #12
0
def main():
    curdir = os.getcwd()
    import Res
    try:
        Res.OpenResFile('RunLibScript.rsrc')
    except:
        pass  # Assume we're an applet already
    name, argv, stdin, stdout, wdir, pause = interact()
    if not name:
        sys.exit(0)
    sys.argv = [name] + string.split(argv)
    if stdin:
        sys.stdin = open(stdin.as_pathname())
    if stdout:
        sys.stdout = open(stdout.as_pathname(), 'w')
    if wdir:
        os.chdir(wdir.as_pathname())
    else:
        os.chdir(curdir)

    import_as_main(name)

    if pause:
        sys.exit(1)
コード例 #13
0
ファイル: homeResFile.py プロジェクト: Kurios/Project32
	def getInfo(self):
		if self.__haveInfo:
			return
		data = sstruct.pack(_FCBPBFormat, self)
		buf = array.array("c", data)
		ptr = buf.buffer_info()[0]
		err = _getInfo(ptr)
		if err:
			raise Res.Error("can't get file info", err)
		sstruct.unpack(_FCBPBFormat, buf.tostring(), self)
		self.__haveInfo = 1
	
	def getFileName(self):
		self.getInfo()
		data = self.__fileName.tostring()
		return data[1:ord(data[0])+1]
	
	def getFSSpec(self):
		self.getInfo()
		vRefNum = self.ioVRefNum
		parID = self.ioFCBParID
		return macfs.FSSpec((vRefNum, parID, self.getFileName()))
	
	def getPath(self):
		return self.getFSSpec().as_pathname()


if __name__ == "__main__":
	fond = Res.GetNamedResource("FOND", "Helvetica")
	print(HomeResFile(fond))
コード例 #14
0
ファイル: PySpaceEditor.py プロジェクト: tml/osteele.com
	def currentline(self):
		selstart, selend = self.get_selection()
		pos, dummy = self.ted.WEFindLine(selstart, 0)
		lineres = Res.Resource('')
		self.ted.WECopyRange(pos, selstart, lineres, None, None)
		return lineres.data
コード例 #15
0
def InitUI():
    """Initialize stuff needed by UI (a resource file)"""
    Res.OpenResFile('MkDistr.rsrc')