⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 umake_pb.py

📁 linux下的一款播放器
💻 PY
📖 第 1 页 / 共 4 页
字号:
#!/usr/bin/env python# -*- Mode: Python -*-# # ***** BEGIN LICENSE BLOCK *****# Source last modified: $Id: umake_pb.py,v 1.38 2004/07/07 22:00:04 hubbe Exp $# # Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved.# # The contents of this file, and the files included with this file,# are subject to the current version of the RealNetworks Public# Source License (the "RPSL") available at# http://www.helixcommunity.org/content/rpsl unless you have licensed# the file under the current version of the RealNetworks Community# Source License (the "RCSL") available at# http://www.helixcommunity.org/content/rcsl, in which case the RCSL# will apply. You may also obtain the license terms directly from# RealNetworks.  You may not use this file except in compliance with# the RPSL or, if you have a valid RCSL with RealNetworks applicable# to this file, the RCSL.  Please see the applicable RPSL or RCSL for# the rights, obligations and limitations governing use of the# contents of the file.# # Alternatively, the contents of this file may be used under the# terms of the GNU General Public License Version 2 or later (the# "GPL") in which case the provisions of the GPL are applicable# instead of those above. If you wish to allow use of your version of# this file only under the terms of the GPL, and not to allow others# to use your version of this file under the terms of either the RPSL# or RCSL, indicate your decision by deleting the provisions above# and replace them with the notice and other provisions required by# the GPL. If you do not delete the provisions above, a recipient may# use your version of this file under the terms of any one of the# RPSL, the RCSL or the GPL.# # This file is part of the Helix DNA Technology. RealNetworks is the# developer of the Original Code and owns the copyrights in the# portions it created.# # This file, and the files included with this file, is distributed# and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY# KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS# ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET# ENJOYMENT OR NON-INFRINGEMENT.# # Technology Compatibility Kit Test Suite(s) Location:#    http://www.helixcommunity.org/content/tck# # Contributor(s):# # ***** END LICENSE BLOCK *****# """ Projectbuild backend for umake """## Python importsimport reimport stringimport typesimport osimport copyimport marshalimport reif __name__ == '__main__':    import sys    ## add Python import paths    build_root = os.environ['BUILD_ROOT']    sys.path.insert(0, os.path.join(build_root, 'lib'))    sys.path.insert(0, os.path.join(build_root, 'umake'))## Local importsimport umake_libimport umake_makefileimport shellimport makefileimport errobjectVersion=38import sysinfoif 'xcode' in sysinfo.family_list:    objectVersion=39class codec:    def __init__(self):        import time        self.timestamp=int(time.time())    ws_reg=re.compile("(([ \r\n\t])|(//[^\r\n]*))*")    word_reg=re.compile("[^ \r\n\t;,]*")    int_reg=re.compile("^[0-9][0-9]*$")    ws_semi_ws_reg=re.compile("(([ \r\n\t])|(//[^\r\n]*))*;(([ \r\n\t])|(//[^\r\n]*))*")    ws_comma_ws_reg=re.compile("(([ \r\n\t])|(//[^\r\n]*))*,(([ \r\n\t])|(//[^\r\n]*))*")    ws_eq_ws_reg=re.compile("(([ \r\n\t])|(//[^\r\n]*))*=(([ \r\n\t])|(//[^\r\n]*))*")    def skipspace(self):        self.pos = self.ws_reg.match(self.data, self.pos).end()        return            while 1:            #while self.data[self.pos] in [" ", "\r", "\n", "\t"]:            #    self.pos=self.pos+1            self.pos = self.ws_reg.match(self.data, self.pos).end()            if self.data[self.pos:self.pos+2] != "//":                return            while self.data[self.pos] not in ["\r", "\n"]:                self.pos=self.pos+1    def get_word(self):        self.skipspace()        start=self.pos        self.pos = self.word_reg.match(self.data, self.pos).end()        #while self.data[self.pos] not in [" ", "\r", "\n", "\t", ";", ","]:        #    self.pos=self.pos+1        return self.data[start:self.pos]    def gobble(self, str):        if self.data[self.pos:self.pos+len(str)] == str:            self.pos=self.pos+len(str)            return 1        else:            return 0    def gobble1(self, str):        if self.data[self.pos] == str:            self.pos=self.pos+1            return 1        else:            return 0    def get_string(self):        ret=[]        q=string.find(self.data,'"',self.pos)        s=string.find(self.data,'\\',self.pos)        while s != -1 and s < q:            ret.append(self.data[self.pos:s])            ret.append(self.data[s+1])            self.pos=s+2            s=string.find(self.data,'\\',self.pos)            if q < self.pos:                q=string.find(self.data,'"',self.pos)        ret.append(self.data[self.pos:q])        self.pos=q+1        return string.join(ret,"")    def unserialize(self):        # print "pos = %d %s" %(self.pos, repr(self.data[self.pos:self.pos+8]))        self.skipspace()        if self.gobble1("{"): ## hash            ret={}            self.skipspace()            while not self.gobble1("}"):                key=self.unserialize()                self.pos = self.ws_eq_ws_reg.match(self.data, self.pos).end()                ret[key]=self.unserialize()                self.pos = self.ws_semi_ws_reg.match(self.data, self.pos).end()            return ret        if self.gobble1("("): ## list            ret=[]            self.skipspace()            while not self.gobble1(")"):                ret.append(self.unserialize())                self.pos = self.ws_comma_ws_reg.match(self.data, self.pos).end()            return ret        if self.gobble1('"'): ## string            return self.get_string()        return self.get_word()        #if self.int_reg.match(w):        #    return int(w)        #return w                            ############################################    str_unquoted_reg=re.compile("^[a-zA-Z./0-9_]*$")    def serialize(self, data, indent=0):        t = type(data)        if t == types.StringType:            if data and self.str_unquoted_reg.match(data):                return data            return '"%s"' % string.replace(string.replace(data,"\\","\\\\"),'"','\\"')        if t == types.DictType:            indent = indent+1            ret=[ "{" ]            keys=data.keys()            keys.sort()            for key in keys:                if data[key] != None:                    ret.append("\t%s = %s;" % (                        self.serialize(key),                        self.serialize(data[key], indent)))            ret.append("}")            return string.join(ret,"\n" + "\t" * indent)        if t == types.IntType:            return str(data)        if t == types.ListType:            indent = indent+1            ret=[ "(" ]            for v in data:                ret.append("\t%s," % self.serialize(v, indent))            ret.append(")")            return string.join(ret,"\n" + "\t" * indent)    ############################################    def mangle(self, data):        t=type(data)        if t == types.InstanceType:            if self.ids.has_key(data):                return self.ids[data]            id = "11ADDED1%08X%08X" % (self.timestamp, self.counter)            self.counter = self.counter + 1            self.ids[data]=id            tmp = self.mangle(data.__dict__)            tmp["isa"]=data.__class__.__name__            self.data["objects"][id]=tmp            return id                        if t == types.DictType:            ret={}            for k in data.keys():                ret[k]=self.mangle(data[k])            return ret        if t == types.ListType:            return map(self.mangle, data)        #print "LITERAL: %s" % repr(data)        return data    ## public    def convert(self,data):        self.counter=1        self.ids={}        self.data={            "archiveVersion" :1,            "objectVersion" : objectVersion,            "classes" : {},            "objects" : {},            }        self.data["rootObject"]=self.mangle(data)        return self.data    ############################################    def unmangle(self, data):        t=type(data)        if t == types.StringType:            if self.objects.has_key(data):                return self.objects[data]            return data        if t == types.DictType:            ret={}            for k in data.keys():                ret[k]=self.unmangle(data[k])            return ret        if t == types.ListType:            return map(self.unmangle, data)        return data    def unconvert(self, data):        if type(data) == types.StringType:            self.data=data            self.pos=0            data=self.unserialize()                ## Instanciate all objects        self.objects={}        for o in data["objects"].keys():            odata=data["objects"][o]            self.objects[o]=globals()[odata["isa"]]()        for o in data["objects"].keys():            ob=self.objects[o]            odata=data["objects"][o]            for k in odata.keys():                ob.__dict__[k]=self.unmangle(odata[k])        return self.objects[data["rootObject"]]            ############################################    def pp(self, data, indent=0):        ret=[]        t=type(data)        if t == types.InstanceType:            if self.done.has_key(data):                return "$%s" % self.done[data]            num=len(self.done)            self.done[data]=num            return "$%d = %s %s" % (                num,                data.__class__.__name__,                self.pp(data.__dict__, indent))        if t == types.DictType:            if not data:                return "{}"            ret=["{ // %d element(s)" % len(data) ]            for k in data.keys():                if k != "isa":                    ret.append("  %s = %s;" %(k,self.pp(data[k],indent+1)))            ret.append("}");            return string.join(ret,"\n" + ("  " * indent))        if t == types.ListType:            if not data:                return "()"            ret=["( // %d element(s)" % len(data) ]            for k in data:                ret.append("  %s," % (self.pp(k, indent+1)))            ret.append(")");            return string.join(ret,"\n" + ("  " * indent) )        return self.serialize(data)                def prettyprint(self,data):        self.counter=1        self.done={}        return self.pp(data,0)## PBX classes...class PBXFileReference:    def __init__(self, path=None):        self.fileEncoding = 30 ## int (4=? 30=?)        # self.name = None       ## string (optional)        self.path = path       ## string        self.refType = 4       ## int (0=ABS,3=output path rel?,4=group rel)        if path and os.path.isabs(path):            self.refType=0        ## XCODE support        if objectVersion > 38:            self.sourceTree = "<group>"            if self.refType == 0:                self.sourceTree = "<absolute>"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -