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

📄 umakepp.py

📁 linux下的一款播放器
💻 PY
📖 第 1 页 / 共 2 页
字号:
# # ***** BEGIN LICENSE BLOCK *****# Source last modified: $Id: umakepp.py,v 1.4 2004/08/31 22:01:25 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 *****# """Umake pre-processor and code morpher.  Umakefil/*.pcf files havedepricated syntax which is converted to new syntax, commented out, andmorphed before it can be executed through umake.py."""import osimport stringimport reimport sysimport umake_libdef pylex(ib, name):    """Takes a input buffer of Python.  It then removes comments, blank lines,    explicit line continuations, and implicit line continuations.  This    prepares the Python code for the regular expression matching used to    morph the code."""    if len(ib) == 0:        return ""    ib = string.replace(ib, "\r\n","\n")    ib = string.replace(ib, "\r","\n")    ## This is not safe - Hubbe    #ib = string.expandtabs(ib, 8)    if ib[-1] != "\n":        ib = ib + "\n"    ci = 0    li = 1    lines = []        r_begin = re.compile("[ \t]*[^] \t()[{}\"'\n#\\\\]*")    r_white = re.compile("[ \t]*")    r_normal = re.compile("[^] \t()[{}\"'\n#\\\\]*")    _openers = ["(", "[", "{"]    _closers = [")", "]", "}"]    r_normstr= re.compile("[^\n\"'\\\\]*")    while ci < len(ib):        ## Preserve whitespace in beginning        m = r_begin.match(ib, ci)        line = m.group(0)        ci = m.end(0)        par = 0        while 1:            # print "POS = %s:%d (%s, %d) par=%d" % (name, ci+1, repr(ib[ci]), ord(ib[ci]),par)            if ib[ci] == "\n":                li = li + 1                ci = ci + 1                if par:                    if line[-1] != " ":                        line=line+" "                    if ci >= len(ib):                        print "umakepp: Missing close parenthesis/braces in file %s" % (name)                        return []                else:                    break                            if ib[ci] in _openers:                par = par + 1                line = line + ib[ci]                ci = ci + 1            if ib[ci] in _closers:                par = par - 1                line = line + ib[ci]                ci = ci + 1                        if ib[ci] in [" ", "\t"]:                if line[-1] != " ":                    line=line+" "                m=r_white.match(ib, ci)                ci=m.end(0)            if ib[ci] == "#":                p = string.find(ib, "\n", ci)                ci = p                continue            if ib[ci] in ["'", '"']:                s = ib[ci]                ci = ci + 1                while 1:                    m=r_normstr.match(ib, ci)                    s=s+m.group(0)                    ci=m.end(0)                    if ib[ci] == "\n":                        print "umakepp: Newline in string %s:%d" % (name, li)                        return []                    if ib[ci] == '\\':                        if ib[ci+1] == '\n':                            ci = ci + 2                            li = li + 1                            if ci >= len(ib):                                print "umakepp: End of file in string %s" % (name)                                return []                            continue                        s = s + ib[ci:ci+2]                        ci = ci + 2                        continue                    s=s+ib[ci]                    ci = ci + 1                    if s[-1] == s[0]:                        break                line = line + s            if ib[ci] == '\\':                if ib[ci+1] == '\n':                    ci = ci + 2                    li = li + 1                    if ci >= len(ib):                        break                else:                    s = s + ib[ci:ci+2]                    ci = ci + 2            m=r_normal.match(ib,ci)            line = line + m.group(0)            ci=m.end(0)                        lines.append(line)    return linesdef remove_line_continuations(um_buff, name):    """Takes a string of Python code as input, runs it through pylex() to    remove line continuations, then it removes all the blank lines.  It    returns a list of strings with one Python statment per line."""    umake_lib.debug("calling pylex..")    _line_list = pylex(um_buff, name)    umake_lib.debug("pylex done")    line_list = []    for line in _line_list:        line = string.rstrip(line)        if len(line) == 0:            continue        line_list.append(line)    return line_list#### Umakefil/*.pcf command translation functions##def rpl_print(m):    temp = "pre-processor removed=\"%s\"" % (m.group(2))    return "%spass ## %s" % (m.group(1), temp)def rpl_target_name(m):    return "project.SetFakeTargetName(%s)" % (m.group(2))def rpl_lib_subdir(m):    return "project.output_dir"def rpl_pass(m):    temp = "pre-processor removed=\"%s\"" % (m.group(1))    return "pass ## %s" % (temp)def rpl_EmptyTarget(m):    temp = "pre-processor removed=\"%s\"" % (m.group(1))    return "EmptyTarget() ## %s" % (temp)def rpl_sources(m):    return "project.AddSources(%s)" % (m.group(2))def rpl_objsrcs(m):    return "project.AddSourceObjects(%s)" % (m.group(2))def rpl_includes(m):    return "project.AddIncludes(%s)" % (m.group(2))def rpl_defines(m):    return "project.AddDefines(%s)" % (m.group(2))def rpl_libraries(m):    return "project.AddLibraries(%s)" % (m.group(2))def rpl_libraries2(m):    return "project.AddLibraries2(%s)" % (m.group(2))def rpl_sys_libraries(m):    return "project.AddSystemLibraries(%s)" % (m.group(2))def rpl_dynamic_libraries(m):    return "project.AddDynamicLibraries(%s)" % (m.group(2))def rpl_module_libs(m):    return "project.AddModuleLibraries(%s)" % (m.group(2))

⌨️ 快捷键说明

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