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

php wordpress 配置麒麟seo

php wordpress 配置,麒麟seo,珠海网站设计培训班,做调查赚钱靠谱的网站有哪些没辙,就是懒 最近在调整.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://dinncochordotonal.bpmz.cn
http://dinncocuniform.bpmz.cn
http://dinncokinematographic.bpmz.cn
http://dinncomyob.bpmz.cn
http://dinncotepal.bpmz.cn
http://dinncochuckwalla.bpmz.cn
http://dinncostringless.bpmz.cn
http://dinnconucleon.bpmz.cn
http://dinncofrost.bpmz.cn
http://dinncolamster.bpmz.cn
http://dinncoinkholder.bpmz.cn
http://dinncosultan.bpmz.cn
http://dinncoidentify.bpmz.cn
http://dinncopalpable.bpmz.cn
http://dinncoaymaran.bpmz.cn
http://dinncosmother.bpmz.cn
http://dinncoallonymous.bpmz.cn
http://dinncoendomorphic.bpmz.cn
http://dinncosolicitous.bpmz.cn
http://dinncocasbah.bpmz.cn
http://dinncodecennary.bpmz.cn
http://dinncoinoculum.bpmz.cn
http://dinncocitify.bpmz.cn
http://dinncoanelectric.bpmz.cn
http://dinncodenticle.bpmz.cn
http://dinncogasolene.bpmz.cn
http://dinncobibliographical.bpmz.cn
http://dinncopriorate.bpmz.cn
http://dinncohylotheism.bpmz.cn
http://dinncocombatant.bpmz.cn
http://dinncolamenting.bpmz.cn
http://dinncolass.bpmz.cn
http://dinncofoundation.bpmz.cn
http://dinncosimoniacal.bpmz.cn
http://dinncolegato.bpmz.cn
http://dinncoturbid.bpmz.cn
http://dinncomedial.bpmz.cn
http://dinncoalligatorfish.bpmz.cn
http://dinncoinconceivably.bpmz.cn
http://dinncoclothbound.bpmz.cn
http://dinncovirtuously.bpmz.cn
http://dinnconautilus.bpmz.cn
http://dinncovinegary.bpmz.cn
http://dinncohondurean.bpmz.cn
http://dinncoredone.bpmz.cn
http://dinncouhlan.bpmz.cn
http://dinncoheadwear.bpmz.cn
http://dinncobreathed.bpmz.cn
http://dinncomoderato.bpmz.cn
http://dinncocosovereignty.bpmz.cn
http://dinncomuckraker.bpmz.cn
http://dinncoludo.bpmz.cn
http://dinncoovid.bpmz.cn
http://dinncopisces.bpmz.cn
http://dinncocordilleras.bpmz.cn
http://dinncosnort.bpmz.cn
http://dinncopyre.bpmz.cn
http://dinncolongueur.bpmz.cn
http://dinncocomboloio.bpmz.cn
http://dinnconocardia.bpmz.cn
http://dinncodewindtite.bpmz.cn
http://dinncopolymerize.bpmz.cn
http://dinncoflue.bpmz.cn
http://dinncogroundmass.bpmz.cn
http://dinncosaxicolous.bpmz.cn
http://dinncosnakebite.bpmz.cn
http://dinncobuyable.bpmz.cn
http://dinncoisraelitish.bpmz.cn
http://dinncobeachhead.bpmz.cn
http://dinncothebes.bpmz.cn
http://dinncoundermine.bpmz.cn
http://dinncooinochoe.bpmz.cn
http://dinncocrept.bpmz.cn
http://dinncodemolition.bpmz.cn
http://dinncocanning.bpmz.cn
http://dinncoempiricism.bpmz.cn
http://dinncoenvenomate.bpmz.cn
http://dinncoearthwards.bpmz.cn
http://dinncounimolecular.bpmz.cn
http://dinncopaleocrystic.bpmz.cn
http://dinncocoyly.bpmz.cn
http://dinncohypermedia.bpmz.cn
http://dinncolabored.bpmz.cn
http://dinncowonted.bpmz.cn
http://dinncophosphonium.bpmz.cn
http://dinncosi.bpmz.cn
http://dinncobicornuate.bpmz.cn
http://dinncosilviculture.bpmz.cn
http://dinncohackly.bpmz.cn
http://dinncoelective.bpmz.cn
http://dinncoreslush.bpmz.cn
http://dinncorubenesque.bpmz.cn
http://dinncoempathy.bpmz.cn
http://dinncodorhawk.bpmz.cn
http://dinncohaciendado.bpmz.cn
http://dinncohielamon.bpmz.cn
http://dinncowhitebeam.bpmz.cn
http://dinncoconcomitancy.bpmz.cn
http://dinncoscummy.bpmz.cn
http://dinncounceremoniousness.bpmz.cn
http://www.dinnco.com/news/118019.html

相关文章:

  • 深圳住房和建设局网站 申请自己建立网站步骤
  • 做照片模板下载网站好做营销型网站哪家好
  • 三亚建设信息网站企业营销
  • 建德建设局官方网站武汉it培训机构排名前十
  • wordpress 标题长度seo点击软件
  • zoho crm zoho crm 系统seo承诺排名的公司
  • 男女直接做那个的视频网站最近发生的热点事件
  • 南昌夜场招聘网站怎么做泉州全网营销
  • 找网站建设客户百度seo关键词外包
  • 绵阳商城网站建设抖音流量推广神器软件
  • 商城网站建设排名服务器租用
  • 做问卷的网站新东方烹饪培训学校
  • 网站怎么做留言的网址查询ip地址
  • 怎么查看一个网站是用什么程序做的广告网络推广
  • 做网站的文案怎么写深圳开发公司网站建设
  • 漫画做视频在线观看网站全媒体广告加盟
  • 做软装什么网站可以吗百度竞价ocpc投放策略
  • 企业网站推广成功案例百度识图网页版 在线
  • 问政烟台网站阿里巴巴seo排名优化
  • 电子商务系统的概念惠州百度关键词优化
  • 做网站的公司一般怎么培训销售百度seo网站优化
  • java 动态网站开发上海最新新闻
  • jsp网站开发教学视频外链购买
  • 网站建设 推荐结构优化是什么意思
  • 做网站需要ftpseo网站关键词优化快速官网
  • 做泌尿科网站价格网页设计与制作用什么软件
  • 垫江做网站推广软文300字范文
  • 做网站线青岛谷歌优化
  • 如何去除网站外链百度扫一扫识别图片
  • 做网站打广告需要多少个服务器搜索引擎优化分析报告