BOM python plugins: restrict changes made in commit 35f9cd26
to Windows.
This commit is contained in:
parent
6381ffd10a
commit
54fbcbac36
|
@ -25,11 +25,14 @@ import csv
|
|||
import sys
|
||||
|
||||
# A helper function to convert a UTF8/Unicode/locale string read in netlist
|
||||
# for python2 or python3
|
||||
# for python2 or python3 (Windows/unix)
|
||||
def fromNetlistText( aText ):
|
||||
try:
|
||||
return aText.encode('utf-8').decode('cp1252')
|
||||
except UnicodeDecodeError:
|
||||
if sys.platform.startswith('win32'):
|
||||
try:
|
||||
return aText.encode('utf-8').decode('cp1252')
|
||||
except UnicodeDecodeError:
|
||||
return aText
|
||||
else:
|
||||
return aText
|
||||
|
||||
def myEqu(self, other):
|
||||
|
|
|
@ -23,9 +23,12 @@ import sys
|
|||
# A helper function to convert a UTF8/Unicode/locale string read in netlist
|
||||
# for python2 or python3
|
||||
def fromNetlistText( aText ):
|
||||
try:
|
||||
return aText.encode('utf-8').decode('cp1252')
|
||||
except UnicodeDecodeError:
|
||||
if sys.platform.startswith('win32'):
|
||||
try:
|
||||
return aText.encode('utf-8').decode('cp1252')
|
||||
except UnicodeDecodeError:
|
||||
return aText
|
||||
else:
|
||||
return aText
|
||||
|
||||
# Generate an instance of a generic netlist, and load the netlist tree from
|
||||
|
|
|
@ -25,9 +25,12 @@ import sys
|
|||
# A helper function to convert a UTF8/Unicode/locale string read in netlist
|
||||
# for python2 or python3
|
||||
def fromNetlistText( aText ):
|
||||
try:
|
||||
return aText.encode('utf-8').decode('cp1252')
|
||||
except UnicodeDecodeError:
|
||||
if sys.platform.startswith('win32'):
|
||||
try:
|
||||
return aText.encode('utf-8').decode('cp1252')
|
||||
except UnicodeDecodeError:
|
||||
return aText
|
||||
else:
|
||||
return aText
|
||||
|
||||
# Generate an instance of a generic netlist, and load the netlist tree from
|
||||
|
|
|
@ -21,6 +21,17 @@ from __future__ import print_function
|
|||
import kicad_netlist_reader
|
||||
import sys
|
||||
|
||||
# A helper function to convert a UTF8/Unicode/locale string read in netlist
|
||||
# for python2 or python3
|
||||
def fromNetlistText( aText ):
|
||||
if sys.platform.startswith('win32'):
|
||||
try:
|
||||
return aText.encode('utf-8').decode('cp1252')
|
||||
except UnicodeDecodeError:
|
||||
return aText
|
||||
else:
|
||||
return aText
|
||||
|
||||
# Start with a basic html template
|
||||
html = """
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
|
@ -98,7 +109,4 @@ for group in grouped:
|
|||
html = html.replace('<!--TABLEROW-->', row + "<!--TABLEROW-->")
|
||||
|
||||
# Print the formatted html to the file
|
||||
try:
|
||||
print(html.encode('utf-8').decode('cp1252'), file=f)
|
||||
except:
|
||||
print(html, file=f)
|
||||
print(fromNetlistText(html), file=f)
|
||||
|
|
|
@ -21,6 +21,17 @@ from __future__ import print_function
|
|||
import kicad_netlist_reader
|
||||
import sys
|
||||
|
||||
# A helper function to convert a UTF8/Unicode/locale string read in netlist
|
||||
# for python2 or python3
|
||||
def fromNetlistText( aText ):
|
||||
if sys.platform.startswith('win32'):
|
||||
try:
|
||||
return aText.encode('utf-8').decode('cp1252')
|
||||
except UnicodeDecodeError:
|
||||
return aText
|
||||
else:
|
||||
return aText
|
||||
|
||||
# Start with a basic html template
|
||||
html = """
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
|
@ -128,7 +139,4 @@ for group in grouped:
|
|||
html = html.replace('<!--TABLEROW-->', row + "<!--TABLEROW-->")
|
||||
|
||||
# Print the formatted html to output file
|
||||
try:
|
||||
print(html.encode('utf-8').decode('cp1252'), file=f)
|
||||
except:
|
||||
print(html, file=f)
|
||||
print(fromNetlistText(html), file=f)
|
||||
|
|
|
@ -20,6 +20,17 @@ import kicad_netlist_reader
|
|||
import csv
|
||||
import sys
|
||||
|
||||
# A helper function to convert a UTF8/Unicode/locale string read in netlist
|
||||
# for python2 or python3 (Windows/unix)
|
||||
def fromNetlistText( aText ):
|
||||
if sys.platform.startswith('win32'):
|
||||
try:
|
||||
return aText.encode('utf-8').decode('cp1252')
|
||||
except UnicodeDecodeError:
|
||||
return aText
|
||||
else:
|
||||
return aText
|
||||
|
||||
# Generate an instance of a generic netlist, and load the netlist tree from
|
||||
# the command line option. If the file doesn't exist, execution will stop
|
||||
net = kicad_netlist_reader.netlist(sys.argv[1])
|
||||
|
@ -42,7 +53,7 @@ def writerow( acsvwriter, columns ):
|
|||
utf8row = []
|
||||
for col in columns:
|
||||
txt=str(col);
|
||||
utf8row.append( txt )
|
||||
utf8row.append( fromNetlistText(txt) )
|
||||
acsvwriter.writerow( utf8row )
|
||||
|
||||
components = net.getInterestingComponents()
|
||||
|
|
Loading…
Reference in New Issue