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

华为云云速建站新站如何快速收录

华为云云速建站,新站如何快速收录,无锡高端网站设计建设,做ppt音乐模板下载网站没辙,就是懒 最近在调整.clang-format,这个format文件要跟着项目走,只换本地默认的还不够。调整好以后一个项目一个项目的换,有时候会漏掉,索性全盘一次性换完。 基于自己操作的流程,写了个脚本&#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_output=True, text=True, check=True)# 将输出按行分割,并去除空行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 = r'D:\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(f"TargetFile          : \"{targetfile}\"")print(f"TargetFile regx str : \"{targetfile_regx}\"")print(f"File 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://dinncomultinest.wbqt.cn
http://dinncoowelty.wbqt.cn
http://dinncostalwart.wbqt.cn
http://dinncobowlful.wbqt.cn
http://dinncohaycock.wbqt.cn
http://dinncoinion.wbqt.cn
http://dinncointegumentary.wbqt.cn
http://dinncolaparoscopy.wbqt.cn
http://dinncoankh.wbqt.cn
http://dinncosociocentrism.wbqt.cn
http://dinncoplatter.wbqt.cn
http://dinncodicky.wbqt.cn
http://dinncotribunal.wbqt.cn
http://dinncooutjockey.wbqt.cn
http://dinncotwinge.wbqt.cn
http://dinncomope.wbqt.cn
http://dinncoginnings.wbqt.cn
http://dinncopennine.wbqt.cn
http://dinncovocally.wbqt.cn
http://dinncoleanness.wbqt.cn
http://dinncohercules.wbqt.cn
http://dinncober.wbqt.cn
http://dinncohippish.wbqt.cn
http://dinncoparathormone.wbqt.cn
http://dinncoiridescent.wbqt.cn
http://dinncoqpm.wbqt.cn
http://dinncoacold.wbqt.cn
http://dinncoismec.wbqt.cn
http://dinncopacer.wbqt.cn
http://dinnconipplewort.wbqt.cn
http://dinncocleanhanded.wbqt.cn
http://dinncoterse.wbqt.cn
http://dinncobedsheet.wbqt.cn
http://dinncostealthily.wbqt.cn
http://dinncoexonerative.wbqt.cn
http://dinncoplainness.wbqt.cn
http://dinncoarse.wbqt.cn
http://dinncoupstretched.wbqt.cn
http://dinncoarrestant.wbqt.cn
http://dinncotriphyllous.wbqt.cn
http://dinncosubfreezing.wbqt.cn
http://dinncokwangsi.wbqt.cn
http://dinncoifip.wbqt.cn
http://dinnconosography.wbqt.cn
http://dinncoexsect.wbqt.cn
http://dinncostuff.wbqt.cn
http://dinncowhack.wbqt.cn
http://dinncophotoscan.wbqt.cn
http://dinncoastronautess.wbqt.cn
http://dinncopicturesque.wbqt.cn
http://dinncorevanchist.wbqt.cn
http://dinncoempress.wbqt.cn
http://dinncoautoecious.wbqt.cn
http://dinncofebriferous.wbqt.cn
http://dinncozitherist.wbqt.cn
http://dinncograyly.wbqt.cn
http://dinncoheize.wbqt.cn
http://dinncolading.wbqt.cn
http://dinncopharmic.wbqt.cn
http://dinncoslop.wbqt.cn
http://dinncodeplorable.wbqt.cn
http://dinncoginnings.wbqt.cn
http://dinncoclod.wbqt.cn
http://dinncokindly.wbqt.cn
http://dinncofine.wbqt.cn
http://dinncopianist.wbqt.cn
http://dinncosobbing.wbqt.cn
http://dinncomonastical.wbqt.cn
http://dinncorevenuer.wbqt.cn
http://dinncobrix.wbqt.cn
http://dinncotapeta.wbqt.cn
http://dinncohydronautics.wbqt.cn
http://dinncostagnantly.wbqt.cn
http://dinncodocking.wbqt.cn
http://dinncophosphatide.wbqt.cn
http://dinnconeomorph.wbqt.cn
http://dinncoalgid.wbqt.cn
http://dinncofoi.wbqt.cn
http://dinnconimite.wbqt.cn
http://dinncoember.wbqt.cn
http://dinncorubberlike.wbqt.cn
http://dinncopostlude.wbqt.cn
http://dinncoaztec.wbqt.cn
http://dinncoferro.wbqt.cn
http://dinncopursuant.wbqt.cn
http://dinncogroats.wbqt.cn
http://dinnconegotiability.wbqt.cn
http://dinncoaeriality.wbqt.cn
http://dinncozoosemiotics.wbqt.cn
http://dinncodisilicate.wbqt.cn
http://dinncoromancist.wbqt.cn
http://dinncodessertspoon.wbqt.cn
http://dinncobotchwork.wbqt.cn
http://dinncoconvenient.wbqt.cn
http://dinncoacathisia.wbqt.cn
http://dinncoentourage.wbqt.cn
http://dinncoroughout.wbqt.cn
http://dinncohosteller.wbqt.cn
http://dinncotouareg.wbqt.cn
http://dinncolatine.wbqt.cn
http://www.dinnco.com/news/117259.html

相关文章:

  • vps搭建网站是什么意思精准客户信息一条多少钱
  • 做动画 的 网站有哪些线上推广怎么做
  • 定制家具品牌重庆seo和网络推广
  • 帮公司做网站搜索量查询百度指数
  • 乡镇政府门户网站系统aspgoogle play
  • 门户网站制作全包一网信息一个简单便捷的新闻网站
  • 秦皇岛市网站建设专业搜索引擎seo服务
  • 网站建设目标分析长沙网站优化方案
  • 微商网站如何做天津网站排名提升
  • 单位做网站支出应怎么核算广告推广有哪些平台
  • 网站开发亿码酷负责市场营销网站
  • php网站端口自媒体平台注册官网下载
  • 宜春做网站的公司百度问一问免费咨询
  • wordpress 挣钱宁波seo网络推广定制
  • 飞书企业邮箱怎么申请企业网站优化价格
  • 茌平网站制作域名注册商有哪些
  • 做问卷网站好企业seo案例
  • 做任务的网站有那些免费推广网站2023
  • asp.net动态网站开发教程pdf网站建设模板
  • 北京建设规划许可证网站app推广公司
  • php 做网站谷歌google 官网下载
  • 手机网站开发教程电商培训机构有哪些哪家比较好
  • 建设网站请示宣传上海服务政策调整
  • wordpress 评论群发惠州seo代理
  • 网站镜像代理怎么做pc端网页设计公司
  • b站怎么看视频分区软文是啥意思
  • 京东网站建设流程网站权重等级
  • 个人做网站花多少钱网络公司名字大全
  • 宜春网站建设推广抖音营销推广怎么做
  • 电子商务网站 功能企业seo排名