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

📄 umake.py

📁 linux下的一款播放器
💻 PY
📖 第 1 页 / 共 5 页
字号:
# # ***** BEGIN LICENSE BLOCK *****# Source last modified: $Id: umake.py,v 1.47 2004/11/30 20:50:34 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 *****# """This file is the execution enviornment for Umake.  Within the umake.pynamespace, all the *.upp (post-processed Umakefil/*.pcf files) areexecuted.  Try to keep the namespace clean, to discourage the use of utilityfunctions by over zealous Umakefil writiers (that's developers).  This isalso the namespace where the platform configuration files (*.cf) areexecuted."""import osimport sysimport stringimport reimport typesimport copyimport errimport sysinfoimport ascriptimport umake_libimport umakeppimport bldregimport marshalimport compileimport impfatal = umake_lib.fataldef stringp(str):    if type(str) == types.StringType:        return 1    try:        if type(str) == types.UnicodeType:            return 1    except AttributeError:        pass    return 0## constant globalsNO_PCF_EXECUTION = 0USE_COMMON_OBJ = 0try:    BUILD_ROOT = os.environ["BUILD_ROOT"]    UMAKE_ROOT = os.path.join(BUILD_ROOT, "umake")    UMAKECF_ROOT = os.path.join(BUILD_ROOT, "umakecf")    UMAKEPF_ROOT = os.path.join(BUILD_ROOT, "umakepf")except KeyError:    umake_lib.fatal("set your BUILD_ROOT environment variable")## context globalsclass UmakeGlobals:    """Save and restore global variables in this object to make calling    Umake recursivly easier."""    def __init__(self):        self.project = Project()        self.platform = Platform()        self.common_defines = ""        self.common_libraries = ""        self.common_includes = ""        self.common_srcs = ""        self.sub_umakes = ""        self.sub_platform_name_pcfs = ""        self.sub_platform_type_pcfs = ""        self.globals = None        self.umake_epilogue_callbacks=[]        self.umake_identify_callbacks=[]    def SaveGlobals(self):        global project, platform, common_defines, common_libraries,\               common_includes, common_srcs, sub_umakes,\               sub_platform_name_pcfs, sub_platform_type_pcfs, \               umake_epilogue_callbacks, umake_identify_callbacks        try:            self.project = project            self.platform = platform            self.common_defines = common_defines            self.common_libraries = common_libraries            self.common_includes = common_includes            self.common_srcs = common_srcs            self.sub_umakes = sub_umakes            self.sub_platform_name_pcfs = sub_platform_name_pcfs            self.sub_platform_type_pcfs = sub_platform_type_pcfs            self.umake_epilogue_callbacks = umake_epilogue_callbacks            self.umake_identify_callbacks = umake_identify_callbacks        except NameError:            pass        self.globals = globals().copy()    def SetGlobals(self):        if self.globals:            g = globals()            g.clear()            g.update(self.globals)                global project, platform, common_defines, common_libraries,\               common_includes, common_srcs, sub_umakes,\               sub_platform_name_pcfs, sub_platform_type_pcfs, \               umake_epilogue_callbacks, umake_identify_callbacks                project = self.project        platform = self.platform        common_defines = self.common_defines        common_libraries = self.common_libraries        common_includes = self.common_includes        common_srcs = self.common_srcs        sub_umakes = self.sub_umakes        sub_platform_name_pcfs = self.sub_platform_name_pcfs        sub_platform_type_pcfs = self.sub_platform_type_pcfs        umake_epilogue_callbacks = self.umake_epilogue_callbacks        umake_identify_callbacks = self.umake_identify_callbacksdef diff_mappings(a, b):    m = {}    for k in a.keys() + b.keys():        m[k] = 1    keys = m.keys()    keys.sort()    for k in keys:        if a.has_key(k):            if b.has_key(k):                if a[k] != b[k]:                    print "Value differance for key %s" % repr(k)                    print "%s != %s" % (repr(a[k]), repr(b[k]))            else:                print "KEY %s missing in 'b'" % repr(k)        else:            print "KEY %s missing in 'a'" % repr(k)def safe_execfile(filename):    """A execfile() function with extra checks meant to exec pre-processed    Umakefils (*.upp)."""    umake_lib.debug("safe_execfile=\"%s\"" % (filename))    if not os.path.isfile(filename):        return    globs = globals().copy()    approved = {"project":1,                "platform":1,                "common_defines":1,                "common_libraries":1,                "common_includes":1,                "common_srcs":1,                "sub_umakes":1,                "sub_platform_name_pcfs":1,                "sub_platform_type_pcfs":1 }    #kglobals.sort()    #klocals.sort()    # print "PROJ: %s" % repr(project)    #print "GLOBALS: %s" % repr(kglobals)    #print "LOCALS : %s" % repr(klocals)    try:        execfile(filename, globals())    except err.error, e:        e.SetTraceback(sys.exc_info())        raise err.error, e    except:        e = err.Error()        path = os.path.join(os.getcwd(), filename)        e.Set("Exception while executing file=\"%s\"." % (path))        e.SetTraceback(sys.exc_info())        raise err.error, e    for key in globals().keys():        if not globs.has_key(key):            #umake_lib.namespace_modified("modified globals=\"%s\"" % (key))            del globals()[key]        elif not approved.has_key(key) and globals()[key] != globs[key]:            umake_lib.namespace_modified("modified globals=\"%s\"" % (key))        def safe_execfile_namespace(file_name):    """This execfiles() a python source file by importing it into memory,    striping out all the troublesome bad newline charactors,    and then execing that string without a global context.    the symbols from the file are then returned in a dictionary."""    file_name=umake_lib.ci_find_file(file_name)    if not os.path.isfile(file_name):        return None    code = open(file_name, "r").read()    code = string.replace(code, "\r", "\n")    code = string.rstrip(code) + "\n"    symbols = {}    exec(code, {}, symbols)    return symbolsdef my_exec_file(path, filename = None, globs = None):    """Execs() a file"""    if not globs:        globs=globals()    if filename == None:        filename = os.path.basename(path)    path=umake_lib.ci_find_file(path)            if not path or not os.path.exists(path):        umake_lib.fatal("configuration file=\"%s\" not found" % (filename))    compfile = path + "c"    if sysinfo.host_type == 'mac' and len(os.path.basename(compfile)) > 31:        execfile(path, globs)        return    cf_mtime = umake_lib.mtime(path)    if cf_mtime > project.cf_last_modified:        project.cf_last_modified = cf_mtime    magic=""    try:        magic=open(compfile,"rb").read(4)    except IOError:        pass    if magic != imp.get_magic() or umake_lib.mtime(compfile) < cf_mtime:        import py_compile        umake_lib.debug("compiling file=\"%s\"" % (path))        py_compile.compile(path, compfile, filename)    try:        fc=open(compfile,"rb")        fc.seek(8)        code=marshal.load(fc)        fc.close()    except:        try:            fc.close()        except:            pass        print "Bad cfc file, please try again"        os.unlink(compfile)        raise    exec code in globs    def exec_config_file(filename):    """Execs() a umake .cf configuration file for a platform.  It magicly    appends the correct path based on the BUILD_ROOT."""    umake_lib.debug("exec_config_file=\"%s\"" % (filename))    my_exec_file(os.path.join(UMAKECF_ROOT, filename), filename)def exec_profile_file(filename):    """Execs() a umake .pf profile file. It magicly    appends the correct path based on the BUILD_ROOT."""    umake_lib.debug("exec_profile_file=\"%s\"" % (filename))    my_exec_file(os.path.join(UMAKEPF_ROOT, filename), filename)def find_umakerc():    """Execute $UMAKERC, $HOME/.umakerc, %HOMEDRIVE%HOMEPATH/umakerc.py or       %preferencesfolder%:umakerc"""    f=os.environ.get("UMAKERC","")    if f and os.path.isfile(f):        return f    home=os.environ.get("HOME","")    if home:        f=os.path.join(home, ".umakerc")        if os.path.isfile(f):            return f        homedrive=os.environ.get("HOMEDRIVE","")    homepath=os.environ.get("HOMEPATH","")    if homedrive and homepath:        f=os.path.join(homedrive + homepath,"umakerc.py")        if os.path.isfile(f):            return f    if sys.platform == "mac":        import macfs        import MACFS        vrefnum, curdir = macfs.FindFolder(            MACFS.kOnAppropriateDisk,            MACFS.kPreferencesFolderType,            0)        fss = macfs.FSSpec((vrefnum, curdir, 'umakerc'))        f= fss.as_pathname()        if os.path.isfile(f):            return f    return None        def exec_umakerc():    """Execute $UMAKERC, $HOME/.umakerc, %HOMEDRIVE%HOMEPATH/umakerc.py or       %preferencesfolder%:umakerc"""    file = find_umakerc()    if file:        project.cf_last_modified = max(project.cf_last_modified, umake_lib.mtime(file))        execfile(file, globals())def join_string(*args):    """Joins a varible number of strings into one string.  This function    is used in many *.cf files."""        out_string = ''    for i in range(len(args)):        if args[i] == None or not len(args[i]):            continue        out_string = out_string + args[i]    return out_stringdef form_string(*args):    """Joins a varible number of strings into one string with space    delimeters.  This function is used in many *.cf files."""        out_string = ""    for i in range(len(args)):        if args[i] == None or not len(args[i]):            continue        out_string = out_string + args[i]        if i < len(args) - 1:            out_string = out_string + " "    return out_string

⌨️ 快捷键说明

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