forked from bolin62007/FuckJLC
-
Notifications
You must be signed in to change notification settings - Fork 1
/
modify.py
75 lines (64 loc) · 3.38 KB
/
modify.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import os
from tkinter import filedialog
header="""G04 Layer: TopLayer*
G04 EasyEDA v6.5.9, 2022-08-01 21:18:00*
G04 ac5e******************************************aa,10*
G04 Gerber Generator version 0.2*
G04 Scale: 100 percent, Rotated: No, Reflected: No *
G04 Dimensions in millimeters *
G04 leading zeros omitted , absolute positions ,4 integer and 5 decimal *\n"""
path = r"C:/Users/Acha/Desktop/gerber_PCB1"
textFile="""如何进行PCB下单
请查看:
https://docs.lceda.cn/cn/PCB/Order-PCB"""
textFileName="PCB下单必读.txt"
currentDir=os.listdir(path)
for file in currentDir:
if os.path.splitext(file)[-1][1:].lower() == "gbl":
os.rename(os.path.join(path,file),os.path.join(path,"Gerber_BottomLayer.GBL"))
if os.path.splitext(file)[-1][1:].lower() == "gko":
os.rename(os.path.join(path,file),os.path.join(path,"Gerber_BoardOutlineLayer.GKO"))
if os.path.splitext(file)[-1][1:].lower() == "gbp":
os.rename(os.path.join(path,file),os.path.join(path,"Gerber_BottomPasteMaskLayer.GBP"))
if os.path.splitext(file)[-1][1:].lower() == "gbo":
os.rename(os.path.join(path,file),os.path.join(path,"Gerber_BottomSilkscreenLayer.GBO"))
if os.path.splitext(file)[-1][1:].lower() == "gbs":
os.rename(os.path.join(path,file),os.path.join(path,"Gerber_BottomSolderMaskLayer.GBS"))
if os.path.splitext(file)[-1][1:].lower() == "gtl":
os.rename(os.path.join(path,file),os.path.join(path,"Gerber_TopLayer.GTL"))
if os.path.splitext(file)[-1][1:].lower() == "gtp":
os.rename(os.path.join(path,file),os.path.join(path,"Gerber_TopPasteMaskLayer.GTP"))
if os.path.splitext(file)[-1][1:].lower() == "gto":
os.rename(os.path.join(path,file),os.path.join(path,"Gerber_TopSilkscreenLayer.GTO"))
if os.path.splitext(file)[-1][1:].lower() == "gts":
os.rename(os.path.join(path,file),os.path.join(path,"Gerber_TopSolderMaskLayer.GTS"))
if os.path.splitext(file)[-1][1:].lower() == "gd1":
os.rename(os.path.join(path,file),os.path.join(path,"Drill_Through.GD1"))
if os.path.splitext(file)[-1][1:].lower() == "gm1":
os.rename(os.path.join(path,file),os.path.join(path,"Gerber_MechanicalLayer1.GM1"))
if os.path.splitext(file)[-1][1:].lower() == "gm13":
os.rename(os.path.join(path,file),os.path.join(path,"Gerber_MechanicalLayer13.GM13"))
if file.find("_PCB-PTH")!=-1:
os.rename(os.path.join(path,file),os.path.join(path,"Drill_PTH_Through.DRL"))
if file.find("_PCB-NPTH")!=-1:
os.rename(os.path.join(path,file),os.path.join(path,"Drill_NPTH_Through.DRL"))
if file.find("_PCB-In1_Cu")!=-1 or file.find(".G1")!=-1:
os.rename(os.path.join(path,file),os.path.join(path,"Gerber_InnerLayer1.G1"))
if file.find("_PCB-In2_Cu")!=-1 or file.find(".G2")!=-1:
os.rename(os.path.join(path,file),os.path.join(path,"Gerber_InnerLayer2.G2"))
if file.find("_PCB-Edge_Cuts")!=-1 :
os.rename(os.path.join(path,file),os.path.join(path,"Gerber_BoardOutlineLayer.GKO"))
currentDir=os.listdir(path)
for file in currentDir:
fileType=os.path.splitext(file)[-1][1:].lower()
if fileType!="txt" and fileType!="py":
f=open(os.path.join(path,file),"r")
fileData=f.read()
f.close()
f=open(os.path.join(path,file),"w")
f.write(header)
f.write(fileData)
f.close()
file=open(textFileName,"w")
file.write(textFile)
file.close()