当前位置: 首页 > news >正文

免费的ppt网站发布新闻稿

免费的ppt网站,发布新闻稿,办公室装饰设计,网站专题页制作没辙#xff0c;就是懒 最近在调整.clang-format#xff0c;这个format文件要跟着项目走#xff0c;只换本地默认的还不够。调整好以后一个项目一个项目的换#xff0c;有时候会漏掉#xff0c;索性全盘一次性换完。 基于自己操作的流程#xff0c;写了个脚本#xff0…没辙就是懒 最近在调整.clang-format这个format文件要跟着项目走只换本地默认的还不够。调整好以后一个项目一个项目的换有时候会漏掉索性全盘一次性换完。 基于自己操作的流程写了个脚本备忘的同时分享一下 用法 def print_usage():usage 使用方法python UpdateAllFile.py 需要替换的文件名 搜索用正则表达式 过滤关键字记录的文件路径在当前路径下找到需要替换的新文件根据everything搜索用的正则表达式在全盘搜索根据过滤关键字记录的文件里面的记录过滤出来需要被替换的文件用当前路径下的新文件替换需要被替换的文件如果被替换的文件是只读会先改为可读写print(usage)准备1 安装everything 准备2 下载 Everything 命令行接口:es.exe官网链接exe所在路径下载解压加入path 脚本 import pandas as pd import os import shutil import sys import subprocessdef load_filters(filter_file):从文件加载过滤路径关键字返回关键字列表try:with open(filter_file, r) as f:return [line.strip() for line in f if line.strip()]except FileNotFoundError:return []def save_filters(filter_file, filters):将过滤路径关键字保存到文件with open(filter_file, w) as f:for filter_item in filters:f.write(filter_item \n)def main(target_src_file,targetfile_regx,filter_file):filters load_filters(filter_file) # 从文件加载过滤路径关键字# 通过everything查找所有.clang-format文件try:result subprocess.run([es.exe, -r, targetfile_regx], capture_outputTrue, textTrue, checkTrue)# 将输出按行分割并去除空行formatfiles [line for line in result.stdout.splitlines() if line.strip()]except subprocess.CalledProcessError as e:print(f执行命令时出错: {e})returnexcept Exception as e:print(f发生未知错误: {e})returnwhile True:# 过滤掉包含指定关键字的文件路径,也排除当前文件formatfiletargets [file for file in formatfiles if not any(f in file for f in filters) and file ! target_src_file]# 打印过滤后的文件列表print(以下是将要被替换的文件:)for file in formatfiletargets:print(file)# 确认confirmation input(继续 - 输入 yes 或直接按回车\n退出 - 输入 no\n增加新的过滤关键字 - 输入新的关键字 \n我要 : )if confirmation.lower() yes or confirmation :breakelif confirmation.lower() no:print(操作已取消。)returnelse:new_filter confirmation.strip()filters.append(new_filter)print(f已添加过滤关键字: {new_filter})# 输出更新后的过滤关键字到文件save_filters(filter_file, filters)# 新文件路径new_file_path target_src_file# 替换旧文件for formatfile in formatfiletargets:try:# 确保旧文件存在if os.path.exists(formatfile):# 检查旧文件的只读属性if not os.access(formatfile, os.W_OK):# 取消只读属性os.chmod(formatfile, 0o666) # 设置为可读可写# 替换旧文件为新文件shutil.copy(new_file_path, formatfile) # 用新文件替换旧文件print(f已用新文件替换旧文件: {formatfile})else:print(f旧文件不存在: {formatfile})except Exception as e:print(f处理文件时出错: {e})def check_pwd_for_file(targetfile):检查当前路径下是否存在targetfile文件存在则返回文件路径不存在则返回空字符串。current_path os.getcwd() clang_format_file os.path.join(current_path, targetfile) if os.path.isfile(clang_format_file): return clang_format_fileelse:return def print_usage():usage 使用方法python UpdateAllClangFormat.py 需要替换的文件名 搜索用正则表达式 过滤关键字记录的文件路径在当前路径下找到需要替换的新文件根据搜索用的正则表达式在全盘搜索根据过滤关键字记录的文件里面的记录过滤出来需要被替换的文件用当前路径下的新文件替换需要被替换的文件如果被替换的文件是只读会先改为可读写print(usage)def get_filename_from_path(file_path):return os.path.basename(file_path)if __name__ __main__:para_from_cmd False # 是否从命令行参数中获取参数targetfile r.clang-format # 要查找的文件名targetfile_regx r^\.clang-format$ # 正则表达式匹配要查找的文件名filter_file rD:\mybin\format.filter # 过滤关键字文件if para_from_cmd :# 检查输入的参数if len(sys.argv) ! 4 :print_usage()else:targetfile sys.argv[1]targetfile_regx sys.argv[1]filter_file sys.argv[1]target_src_file check_pwd_for_file(targetfile)if target_src_file ! :print(fTargetFile : \{targetfile}\)print(fTargetFile regx str : \{targetfile_regx}\)print(fFile under PWD : \{target_src_file}\)# 确认confirmation input(请确认\n继续 - 直接按回车\n退出 - 输入 no或n\n我要 : )if confirmation.lower() no or confirmation.lower() n:print(操作已取消。)exit(0)main(target_src_file,targetfile_regx, filter_file)else:print(f当前路径没找到{targetfile})
http://www.w-s-a.com/news/853268/

相关文章:

  • 上海礼品定制网站响应式网站模版建站
  • 那种自行提取卡密的网站怎么做网站攻击
  • 洛阳免费网站建设qq是哪家公司开发的软件
  • 怎么做网站网页wordpress网址导航
  • 专业微信网站建设公司首选公司wordpress自动分类插件
  • 网站设计登录界面怎么做网站突然排名没了
  • wordpress 人物页面seo优化公司信
  • 高端网站建设报价网站建设需要硬件设备
  • 做国际物流在哪些网站找客户营销qq怎么申请
  • 网站做推广百度好还是360好科技厅
  • 网站开发工具排名万户网络建一个网站虽要多少钱
  • 用凡科做的网站要钱吗WordPress城市切换
  • 制作一个门户网站需要多少钱营销型网站特征
  • 手机网站 多html中国建设银行网站包头分行
  • 哪个网站做免费广告好招牌图片效果图设计制作
  • 网站建设优化服务机构苏州市做网站
  • 网站如何优化流程企业网站管理系统视频教程
  • 我想克隆个网站 怎么做贵州住房和城乡建设厅官网
  • 网站建设项目前景上海今天新闻综合频道
  • 做网站推销的如何谈客户wordpress怎么做商城
  • 摄影素材库网站服装页面设计的网站
  • 如何用国外网站做头条做个游戏app的费用大概多少
  • 网站 形象入口页福州网站建设网络公司排名
  • 免费下载教学设计的网站送网站建设管理信息内容审核制度
  • 外贸专业网站的公司百度旗下13个app
  • 物理组简介 网站建设高师院校语言类课程体系改革与建设 教学成果奖申报网站
  • 爱网站无法登录怎么回事手表网
  • 网站建设公司现在还挣钱吗山西手动网站建设推荐平台
  • 重庆建设工程交易信息网站网站制作公司起名
  • 东莞寮步做网站的有吗企业宣传册制作