当前位置: 首页>>代码示例>>Python>>正文


Python Preprocessor.processFile方法代码示例

本文整理汇总了Python中mozbuild.preprocessor.Preprocessor.processFile方法的典型用法代码示例。如果您正苦于以下问题:Python Preprocessor.processFile方法的具体用法?Python Preprocessor.processFile怎么用?Python Preprocessor.processFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mozbuild.preprocessor.Preprocessor的用法示例。


在下文中一共展示了Preprocessor.processFile方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: copy

# 需要导入模块: from mozbuild.preprocessor import Preprocessor [as 别名]
# 或者: from mozbuild.preprocessor.Preprocessor import processFile [as 别名]
    def copy(self, dest, skip_if_older=True):
        '''
        Invokes the preprocessor to create the destination file.
        '''
        if isinstance(dest, basestring):
            dest = Dest(dest)
        else:
            assert isinstance(dest, Dest)

        # We have to account for the case where the destination exists and is a
        # symlink to something. Since we know the preprocessor is certainly not
        # going to create a symlink, we can just remove the existing one. If the
        # destination is not a symlink, we leave it alone, since we're going to
        # overwrite its contents anyway.
        # If symlinks aren't supported at all, we can skip this step.
        if hasattr(os, 'symlink'):
            if os.path.islink(dest.path):
                os.remove(dest.path)

        pp_deps = set(self.extra_depends)

        # If a dependency file was specified, and it exists, add any
        # dependencies from that file to our list.
        if self.depfile and os.path.exists(self.depfile):
            target = mozpath.normpath(dest.name)
            with open(self.depfile, 'rb') as fileobj:
                for rule in makeutil.read_dep_makefile(fileobj):
                    if target in rule.targets():
                        pp_deps.update(rule.dependencies())

        skip = False
        if dest.exists() and skip_if_older:
            # If a dependency file was specified, and it doesn't exist,
            # assume that the preprocessor needs to be rerun. That will
            # regenerate the dependency file.
            if self.depfile and not os.path.exists(self.depfile):
                skip = False
            else:
                skip = not BaseFile.any_newer(dest.path, pp_deps)

        if skip:
            return False

        deps_out = None
        if self.depfile:
            deps_out = FileAvoidWrite(self.depfile)
        pp = Preprocessor(defines=self.defines, marker=self.marker)
        pp.setSilenceDirectiveWarnings(self.silence_missing_directive_warnings)

        with open(self.path, 'rU') as input:
            pp.processFile(input=input, output=dest, depfile=deps_out)

        dest.close()
        if self.depfile:
            deps_out.close()

        return True
开发者ID:luke-chang,项目名称:gecko-1,代码行数:59,代码来源:files.py

示例2: inputs

# 需要导入模块: from mozbuild.preprocessor import Preprocessor [as 别名]
# 或者: from mozbuild.preprocessor.Preprocessor import processFile [as 别名]
    def inputs(self):
        pp = Preprocessor(defines=self.defines, marker=self.marker)
        pp.setSilenceDirectiveWarnings(self.silence_missing_directive_warnings)

        with open(self.path, 'rU') as input:
            with open(os.devnull, 'w') as output:
                pp.processFile(input=input, output=output)

        # This always yields at least self.path.
        return pp.includes
开发者ID:luke-chang,项目名称:gecko-1,代码行数:12,代码来源:files.py

示例3: process_package_overload

# 需要导入模块: from mozbuild.preprocessor import Preprocessor [as 别名]
# 或者: from mozbuild.preprocessor.Preprocessor import processFile [as 别名]
def process_package_overload(src, dst, version, app_buildid):
    ensureParentDir(dst)
    # First replace numeric version like '1.3'
    # Then replace with 'slashed' version like '1_4'
    # Finally set the full length addon version like 1.3.20131230
    defines = {
        "NUM_VERSION": version,
        "SLASH_VERSION": version.replace(".", "_"),
        "FULL_VERSION": ("%s.%s" % (version, app_buildid))
    }
    pp = Preprocessor(defines=defines)
    pp.do_filter("substitution")
    with open(dst, "w") as output:
        with open(src, "r") as input:
            pp.processFile(input=input, output=output)
开发者ID:PatMart,项目名称:gecko-dev,代码行数:17,代码来源:build_xpi.py

示例4: preprocess_file

# 需要导入模块: from mozbuild.preprocessor import Preprocessor [as 别名]
# 或者: from mozbuild.preprocessor.Preprocessor import processFile [as 别名]
def preprocess_file(src, dst, version, app_buildid, update_url):
    ensureParentDir(dst)

    defines = {
        "ADDON_ID": "fxos_" + version.replace(".", "_") + "[email protected]",
        # (reduce the app build id to only the build date
        # as addon manager doesn't handle big ints in addon versions)
        "ADDON_VERSION": ("%s.%s" % (version, app_buildid[:8])),
        "ADDON_NAME": "Firefox OS " + version + " Simulator",
        "ADDON_DESCRIPTION": "a Firefox OS " + version + " simulator",
        "ADDON_UPDATE_URL": update_url
    }
    pp = Preprocessor(defines=defines)
    pp.do_filter("substitution")
    with open(dst, "w") as output:
        with open(src, "r") as input:
            pp.processFile(input=input, output=output)
开发者ID:AOSC-Dev,项目名称:Pale-Moon,代码行数:19,代码来源:build_xpi.py

示例5: dict

# 需要导入模块: from mozbuild.preprocessor import Preprocessor [as 别名]
# 或者: from mozbuild.preprocessor.Preprocessor import processFile [as 别名]
         STYLE_CONSTRUCTOR=1,
         TINT_FOREGROUND_DRAWABLE=1,
         BOOKMARK_NO_TINT=1),
    dict(VIEW_NAME_SUFFIX='ImageView',
         BASE_TYPE='android.widget.ImageView',
         STYLE_CONSTRUCTOR=1,
         TINT_FOREGROUND_DRAWABLE=1),
    dict(VIEW_NAME_SUFFIX='LinearLayout',
         BASE_TYPE='android.widget.LinearLayout'),
    dict(VIEW_NAME_SUFFIX='RelativeLayout',
         BASE_TYPE='android.widget.RelativeLayout',
         STYLE_CONSTRUCTOR=1),
    dict(VIEW_NAME_SUFFIX='TextSwitcher',
         BASE_TYPE='android.widget.TextSwitcher'),
    dict(VIEW_NAME_SUFFIX='TextView',
         BASE_TYPE='android.widget.TextView',
         STYLE_CONSTRUCTOR=1),
    dict(VIEW_NAME_SUFFIX='View',
         BASE_TYPE='android.view.View',
         STYLE_CONSTRUCTOR=1),
]

for view in views:
    pp = Preprocessor(defines=view, marker='//#')

    dest = os.path.join(__DIR__, dest_format_string % view)
    with open(template, 'rU') as input:
        with open(dest, 'wt') as output:
            pp.processFile(input=input, output=output)
            print('%s' % dest)
开发者ID:MekliCZ,项目名称:positron,代码行数:32,代码来源:generate_themed_views.py

示例6: main

# 需要导入模块: from mozbuild.preprocessor import Preprocessor [as 别名]
# 或者: from mozbuild.preprocessor.Preprocessor import processFile [as 别名]
def main(output_file, input_filename):
    # input_filename is an absolute path, so there's no need to join with __DIR__.
    pp = Preprocessor(defines=buildconfig.defines, marker='//#')

    CONFIG = defaultdict(lambda: None)
    CONFIG.update(buildconfig.substs)
    DEFINES = {}

    for var in ('MOZ_ANDROID_ACTIVITY_STREAM'
                'MOZ_ANDROID_ANR_REPORTER',
                'MOZ_ANDROID_BEAM',
                'MOZ_ANDROID_CUSTOM_TABS',
                'MOZ_ANDROID_DOWNLOADS_INTEGRATION',
                'MOZ_ANDROID_DOWNLOAD_CONTENT_SERVICE',
                'MOZ_ANDROID_EXCLUDE_FONTS',
                'MOZ_ANDROID_GCM',
                'MOZ_ANDROID_MLS_STUMBLER',
                'MOZ_ANDROID_SEARCH_ACTIVITY',
                'MOZ_DEBUG',
                'MOZ_INSTALL_TRACKING',
                'MOZ_LOCALE_SWITCHER',
                'MOZ_NATIVE_DEVICES',
                'MOZ_SWITCHBOARD'):
        if CONFIG[var]:
            DEFINES[var] = 1

    for var in ('MOZ_ANDROID_GCM_SENDERID',
                'MOZ_PKG_SPECIAL',
                'MOZ_UPDATER'):
        if CONFIG[var]:
            DEFINES[var] = CONFIG[var]

    for var in ('ANDROID_CPU_ARCH',
                'ANDROID_PACKAGE_NAME',
                'GRE_MILESTONE',
                'MOZ_ANDROID_APPLICATION_CLASS',
                'MOZ_ANDROID_BROWSER_INTENT_CLASS',
                'MOZ_ANDROID_SEARCH_INTENT_CLASS',
                'MOZ_APP_BASENAME',
                'MOZ_APP_DISPLAYNAME',
                'MOZ_APP_ID',
                'MOZ_APP_NAME',
                'MOZ_APP_UA_NAME',
                'MOZ_APP_VENDOR',
                'MOZ_APP_VERSION',
                'MOZ_CHILD_PROCESS_NAME',
                'MOZ_CRASHREPORTER',
                'MOZ_MOZILLA_API_KEY',
                'MOZ_UPDATE_CHANNEL',
                'OMNIJAR_NAME',
                'OS_TARGET',
                'TARGET_XPCOM_ABI'):
        DEFINES[var] = CONFIG[var]

    # Mangle our package name to avoid Bug 750548.
    DEFINES['MANGLED_ANDROID_PACKAGE_NAME'] = CONFIG['ANDROID_PACKAGE_NAME'].replace('fennec', 'f3nn3c')
    DEFINES['MOZ_APP_ABI'] = CONFIG['TARGET_XPCOM_ABI']
    if not CONFIG['COMPILE_ENVIRONMENT']:
        # These should really come from the included binaries, but that's not easy.
        DEFINES['MOZ_APP_ABI'] = 'arm-eabi-gcc3'
        DEFINES['TARGET_XPCOM_ABI'] = 'arm-eabi-gcc3'

    if '-march=armv7' in CONFIG['OS_CFLAGS']:
        DEFINES['MOZ_MIN_CPU_VERSION'] = 7
    else:
        DEFINES['MOZ_MIN_CPU_VERSION'] = 5

    # It's okay to use MOZ_ADJUST_SDK_KEY here because this doesn't
    # leak the value to build logs.
    if CONFIG['MOZ_INSTALL_TRACKING']:
        DEFINES['MOZ_INSTALL_TRACKING_ADJUST_SDK_APP_TOKEN'] = CONFIG['MOZ_ADJUST_SDK_KEY']

    # TODO: mark buildid.h as a dependency?  How about the buildconfig itself?
    DEFINES['MOZ_BUILDID'] = open(os.path.join(buildconfig.topobjdir, 'buildid.h')).readline().split()[2]

    pp.context.update(DEFINES)

    with open(input_filename, 'rU') as input:
        pp.processFile(input=input, output=output_file)

    return 0
开发者ID:mephisto41,项目名称:gecko-dev,代码行数:83,代码来源:generate_build_config.py


注:本文中的mozbuild.preprocessor.Preprocessor.processFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。