代码拉取完成,页面将自动刷新
同步操作将从 linbinzl/kicad_tools 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
# -*- coding: utf-8 -*-
"""
Created on Tue May 12 10:08:59 2020
"""
import io
QUOTE = {
"'":"'",
'"':'"',
}
BRACKETS = {'(': ')'}
BRACKETS_END = {')':1}
SPACE = {' ':1, '\t':1, '\r':1, '\n':1}
def quoteData(content, index):
data = ""
q_e = QUOTE[content[index]]
c_len = len(content)
escape = False
index+=1;
while index < c_len:
c = content[index]
if c == '\\':
escape = True
elif c == q_e:
if(not escape):
return data, index+1
else:
data += c;
else:
escape = False
data += c
index+=1
return data, index+1
def normalData(content, index):
data = ""
c_len = len(content)
while index < c_len:
c = content[index]
if c in SPACE:
index +=1
break
elif c in BRACKETS:
break
elif c in BRACKETS_END:
break
else:
data += c
index+=1
return data, index
def parseSexp(content, index = 0):
res = []
c_len = len(content)
data = ""
bracket_end = ""
while index < c_len:
c = content[index]
if c in BRACKETS:
bracket_end = BRACKETS[c]
data, index = parseSexp(content, index+1)
res.append(data)
elif c in QUOTE:
data, index = quoteData(content, index)
res.append(data)
elif c in SPACE:
index+=1;
elif c in BRACKETS_END:
index+=1
break
else:
data, index = normalData(content, index)
res.append(data)
return res, index
def loadKicadNet(filename):
file = io.open(filename, "r", encoding="utf-8")
data = file.read()
res = parseSexp(data)
return res[0][0]
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。