• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils.write_file_content函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中utils.write_file_content函数的典型用法代码示例。如果您正苦于以下问题:Python write_file_content函数的具体用法?Python write_file_content怎么用?Python write_file_content使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: rollback_last_sync_ticket

def rollback_last_sync_ticket(cache_dir):
    ticket = get_last_sync_ticket(cache_dir)
    if ticket > 0:
        ticket -= 1
    else:
        ticket = 0
    write_file_content(get_last_sync_ticket_path(cache_dir), ticket)
开发者ID:568,项目名称:ThirdPlugin,代码行数:7,代码来源:sync_client.py


示例2: write_merge_result

def write_merge_result(path, content):
    if len(content) > 0:
        tmp_path = path + '.temp'
        write_file_content(tmp_path, content)
        result = merge_xml([path, tmp_path])
        write_file_content(path, result)
        os.remove(tmp_path)
开发者ID:Ryanst,项目名称:AndroidDemo,代码行数:7,代码来源:android_tools.py


示例3: append_r_file

    def append_r_file(self):
        if self._name != self._config['main_project_name']:
            backupdir = self.__get_freeline_backup_r_dir()
            main_r_path = os.path.join(backupdir, self._config['package'].replace('.', os.sep), 'R.java')

            # main_r_path existence means that resource modification exists, so that need to add R.java to classpath
            if os.path.exists(main_r_path):
                pns = [self._config['package'], self._module_info['packagename']]

                for m in self._module_info['local_module_dep']:
                    pns.append(self._all_module_info[m]['packagename'])

                for pn in pns:
                    rpath = os.path.join(backupdir, pn.replace('.', os.sep), 'R.java')
                    if os.path.exists(rpath) and rpath not in self._changed_files['src']:
                        self._changed_files['src'].append(rpath)
                        self.debug('add R.java to changed list: ' + rpath)
                    elif pn == self._module_info['packagename']:
                        fpath = self.__modify_other_modules_r(pn)
                        self.debug('modify {}'.format(fpath))
                        if os.path.exists(fpath):
                            self._changed_files['src'].append(fpath)
                            self.debug('add R.java to changed list: ' + fpath)
        else:
            if is_windows_system():
                main_r_path = os.path.join(self._finder.get_backup_dir(),
                                           self._module_info['packagename'].replace('.', os.sep), 'R.java')
                content = self.__fix_unicode_parse_error(get_file_content(main_r_path), main_r_path)
                write_file_content(main_r_path, content)
开发者ID:ccyingzi2009,项目名称:Weather,代码行数:29,代码来源:gradle_inc_build.py


示例4: get_apktime_path

def get_apktime_path(config):
    adir = os.path.join(config['build_cache_dir'], 'freeline-assets')
    if not os.path.exists(adir):
        os.makedirs(adir)
    path = os.path.join(adir, 'apktime')
    if not os.path.exists(path):
        write_file_content(path, '')
    return path
开发者ID:Ryanst,项目名称:AndroidDemo,代码行数:8,代码来源:android_tools.py


示例5: __save_parms_to_file

 def __save_parms_to_file(self, path, params):
     if os.path.exists(path):
         os.remove(path)
     content = ''
     for param in params:
         content += param + '\n'
     write_file_content(path, content)
     self.debug('save retrolambda params to {}'.format(path))
开发者ID:fenglincanyi,项目名称:Study,代码行数:8,代码来源:gradle_inc_build.py


示例6: _generate_java_compile_args

    def _generate_java_compile_args(self, extra_javac_args_enabled=False):
        javacargs = [self._javac]
        arguments = ['-encoding', 'UTF-8', '-g']
        if not self._is_retrolambda_enabled:
            arguments.extend(['-target', '1.7', '-source', '1.7'])

        arguments.append('-cp')
        arguments.append(os.pathsep.join(self._classpaths))

        for fpath in self._changed_files['src']:
            arguments.append(fpath)

        if extra_javac_args_enabled:
            if 'apt' in self._changed_files:
                for fpath in self._changed_files['apt']:
                    arguments.append(fpath)

            filter_tags = []
            if self._is_databinding_enabled:
                filter_tags.extend(['BindingAdapter', 'BindingConversion', 'Bindable'])

            if self._is_dagger_enabled:
                filter_tags.extend(['DaggerComponent', 'DaggerModule'])

            files = self._get_apt_related_files(filter_tags=filter_tags)
            for fpath in files:
                if fpath and os.path.exists(fpath) and fpath not in self._changed_files['src']:
                    if 'apt' in self._changed_files and fpath in self._changed_files['apt']:
                        continue
                    self.debug('add apt related file: {}'.format(fpath))
                    arguments.append(fpath)

            arguments.extend(self._extra_javac_args)

        arguments.append('-d')
        arguments.append(self._finder.get_patch_classes_cache_dir())

        # ref: https://support.microsoft.com/en-us/kb/830473
        if is_windows_system():
            arguments_length = sum(map(len, arguments))
            if arguments_length > 8000:
                argument_file_path = os.path.join(self._finder.get_module_cache_dir(), 'javac_args_file')
                self.debug('arguments length: {} > 8000, save args to {}'.format(arguments_length, argument_file_path))

                if os.path.exists(argument_file_path):
                    os.remove(argument_file_path)

                arguments_content = ' '.join(arguments)
                self.debug('javac arguments: ' + arguments_content)
                write_file_content(argument_file_path, arguments_content)
                arguments = ['@{}'.format(argument_file_path)]

        javacargs.extend(arguments)
        return javacargs
开发者ID:fenglincanyi,项目名称:Study,代码行数:54,代码来源:gradle_inc_build.py


示例7: __modify_main_r

    def __modify_main_r(self):
        main_r_fpath = os.path.join(self._finder.get_backup_dir(),
                                    self._module_info['packagename'].replace('.', os.sep), 'R.java')

        self.debug('modify {}'.format(main_r_fpath))
        buf = GradleIncBuildInvoker.remove_final_tag(get_file_content(main_r_fpath))
        buf = self.__fix_unicode_parse_error(buf, main_r_fpath)
        write_file_content(main_r_fpath, buf)

        target_main_r_dir = os.path.join(self.__get_freeline_backup_r_dir(),
                                         self._module_info['packagename'].replace('.', os.sep))
        if not os.path.exists(target_main_r_dir):
            os.makedirs(target_main_r_dir)

        target_main_r_path = os.path.join(target_main_r_dir, 'R.java')
        self.debug('copy {} to {}'.format(main_r_fpath, target_main_r_path))
        shutil.copy(main_r_fpath, target_main_r_path)
开发者ID:ccyingzi2009,项目名称:Weather,代码行数:17,代码来源:gradle_inc_build.py


示例8: fix_package_name

def fix_package_name(config, manifest):
    if config and config['package'] != config['debug_package']:
        finder = GradleDirectoryFinder(config['main_project_name'], config['main_project_dir'],
                                       config['build_cache_dir'], config=config)
        target_manifest_path = os.path.join(finder.get_backup_dir(), 'AndroidManifest.xml')
        if os.path.exists(target_manifest_path):
            return target_manifest_path

        if manifest and os.path.isfile(manifest):
            Logger.debug('find app has debug package name, freeline will fix the package name in manifest')
            content = get_file_content(manifest)
            result = re.sub('package=\"(.*)\"', 'package=\"{}\"'.format(config['package']), content)
            Logger.debug('change package name from {} to {}'.format(config['debug_package'], config['package']))
            from utils import write_file_content
            write_file_content(target_manifest_path, result)
            Logger.debug('save new manifest to {}'.format(target_manifest_path))
            return target_manifest_path
    return manifest
开发者ID:BlackYHawk,项目名称:Gank,代码行数:18,代码来源:gradle_tools.py


示例9: generate_public_files_by_r

def generate_public_files_by_r(dst_r_path, public_path, ids_path):
    buf = get_file_content(dst_r_path)

    temp = re.findall('<tr><td><code>([^<]+)</code></td>', buf)
    diykv = []
    for i in temp:
        if "{" not in i:
            diykv.append(i)
    dstbuf = ''
    idbuf = '<?xml version="1.0" encoding="utf-8"?>\n'
    idbuf += '<resources>\n'
    dstbuf += idbuf

    result = buf.split('\n')
    type_char = ''
    for r in result:
        if 'public static final class' in r:
            type_char = r.replace('public static final class ', '').replace(' {', '').replace(' ', '').replace('\n', '').replace('\r', '')
        elif 'public static class' in r:
            type_char = r.replace('public static class ', '').replace(' {', '').replace(' ', '').replace('\n', '').replace('\r', '')
            type_char = type_char.replace(' ', '').replace('\n', '').replace('\r', '')
        elif 'public static final int' in r and type_char != '' and '[]' not in r:
            kv = r.replace('public static final int ', '').replace(';', '').split('=')
            name = kv[0].replace(' ', '').replace('\n', '').replace('\r', '')
            id_char = kv[1].replace(' ', '').replace('\n', '').replace('\r', '')
            dstbuf += '    <public type="%s" name="%s" id="%s" />\n' % (type_char, name, id_char)
            if type_char == 'id' and name not in diykv:
                idbuf += '    <item name="%s" type="id"/>\n' % name

        elif 'public static int' in r and type_char != '' and '[]' not in r:
            kv = r.replace('public static int ', '').replace(';', '').split('=')
            name = kv[0].replace(' ', '').replace('\n', '').replace('\r', '')
            id_char = kv[1].replace(' ', '').replace('\n', '').replace('\r', '')
            dstbuf += '    <public type="%s" name="%s" id="%s" />\n' % (type_char, name, id_char)
            if type_char == 'id' and name not in diykv:
                idbuf += '    <item name="%s" type="id"/>\n' % name

        elif type_char != '' and '}' in r:
            type_char = ''

    dstbuf += '</resources>'
    idbuf += '</resources>'
    write_file_content(public_path, dstbuf)
    write_file_content(ids_path, idbuf)
开发者ID:Ryanst,项目名称:AndroidDemo,代码行数:44,代码来源:android_tools.py


示例10: backup_res_files

    def backup_res_files(self):
        pending_remove = []
        for fpath in self._changed_files['res']:
            # res/values/colors.xml -> build/target/generated-sources/res/values/colors.xml
            # res/values/colors.xml -> build/intermediates/res/merged/debug/values/colors.xml
            dst_path = self._get_res_incremental_dst_path(fpath)
            is_new_file = False
            if not os.path.exists(dst_path):
                is_new_file = True
                self._new_res_list.append(dst_path)

            if fpath in self._merged_xml_cache:
                backup_res_file(dst_path)  # backup old file
                cache = self._merged_xml_cache[fpath]
                write_file_content(dst_path, cache)  # write merged cache to dst path
            else:
                if is_new_file:
                    shutil.copyfile(fpath, dst_path)  # just copy to dst path, if this is new file
                    self.debug('copy {} to {}'.format(fpath, dst_path))
                    continue

                old_file_md5 = get_md5(fpath)
                dst_file_md5 = get_md5(dst_path)
                if old_file_md5 != dst_file_md5:
                    backup_res_file(dst_path)
                    shutil.copyfile(fpath, dst_path)
                    self.debug('copy {} to {}'.format(fpath, dst_path))
                else:
                    pending_remove.append(fpath)  # file is not changed, so remove from changed list
                    os.utime(dst_path, None)

        for fpath in self._changed_files['assets']:
            dst_path = self._get_res_incremental_dst_path(fpath)
            if os.path.exists(dst_path):
                backup_res_file(dst_path)
            else:
                self._new_res_list.append(dst_path)
            shutil.copyfile(fpath, dst_path)

        for fpath in pending_remove:
            if fpath in self._changed_files['res']:
                self._changed_files['res'].remove(fpath)
开发者ID:Ryanst,项目名称:AndroidDemo,代码行数:42,代码来源:android_tools.py


示例11: __modify_other_modules_r

    def __modify_other_modules_r(self, package_name, finder=None):
        if not finder:
            finder = self._finder

        r_path = android_tools.find_r_file(finder.get_dst_r_dir(), package_name=package_name)
        if os.path.exists(r_path):
            target_dir = os.path.join(self.__get_freeline_backup_r_dir(), package_name.replace('.', os.sep))
            if not os.path.exists(target_dir):
                os.makedirs(target_dir)
            target_path = os.path.join(target_dir, 'R.java')
            if not os.path.exists(target_path):
                self.debug('copy {} to {}'.format(r_path, target_path))
                shutil.copy(r_path, target_path)

                content = get_file_content(target_path)
                content = GradleIncBuildInvoker.remove_final_tag(content)
                content = GradleIncBuildInvoker.extend_main_r(content, self._config['package'])
                content = self.__fix_unicode_parse_error(content, target_path)
                write_file_content(target_path, content)

            return target_path
开发者ID:ccyingzi2009,项目名称:Weather,代码行数:21,代码来源:gradle_inc_build.py


示例12: update_last_sync_ticket

def update_last_sync_ticket(cache_dir):
    ticket = get_last_sync_ticket(cache_dir) + 1
    ticket_path = get_last_sync_ticket_path(cache_dir)
    write_file_content(ticket_path, ticket)
开发者ID:568,项目名称:ThirdPlugin,代码行数:4,代码来源:sync_client.py


示例13: mark_res_build_job

def mark_res_build_job(job_path):
    if not os.path.exists(job_path):
        write_file_content(job_path, '')
开发者ID:Ryanst,项目名称:AndroidDemo,代码行数:3,代码来源:android_tools.py


示例14: update_clean_build_created_flag

def update_clean_build_created_flag(apktime_path):
    flag = str(datetime.datetime.now().microsecond)
    Logger.debug("update apk time path: " + apktime_path)
    Logger.debug("new clean build flag value: " + flag)
    write_file_content(apktime_path, flag)
开发者ID:568,项目名称:ThirdPlugin,代码行数:5,代码来源:sync_client.py


示例15: fix_for_windows

 def fix_for_windows(path):
     if is_windows_system():
         buf = fix_unicode_parse_error(get_file_content(path), path)
         write_file_content(path, buf)
开发者ID:Ryanst,项目名称:AndroidDemo,代码行数:4,代码来源:android_tools.py


示例16: mark_res_sync_status

def mark_res_sync_status(sync_file_path):
    if not os.path.exists(sync_file_path):
        write_file_content(sync_file_path, '')
开发者ID:Ryanst,项目名称:AndroidDemo,代码行数:3,代码来源:android_tools.py


示例17: mark_res_changed

def mark_res_changed(cache_dir):
    path = get_res_changed_flag_path(cache_dir)
    if not os.path.exists(path):
        write_file_content(path, '')
开发者ID:Ryanst,项目名称:AndroidDemo,代码行数:4,代码来源:android_tools.py


示例18: mark_restart_flag

def mark_restart_flag(cache_dir):
    path = os.path.join(cache_dir, 'increment.restart')
    if not os.path.exists(path):
        write_file_content(path, '')
开发者ID:Ryanst,项目名称:AndroidDemo,代码行数:4,代码来源:android_tools.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.xml2str函数代码示例发布时间:2022-05-26
下一篇:
Python utils.write_file函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap