Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def updateEDAselection(self):
''' @brief Update the EDA selection in the listBox based on the comboBox actual text.'''
fileNames = re.split(SEP_FILES, self.m_comboBox_files.GetValue())
if len(fileNames)==1:
eda_module = file_eda_match(fileNames[0])
if eda_module:
self.m_listBox_edatool.SetSelection(self.m_listBox_edatool.FindString(eda_dict[eda_module]['label']))
elif len(fileNames)>1:
# Check if all the EDA are the same. For different ones,
# the guide is not able now to deal, need improvement
# on `self.m_listBox_edatool`.
eda_module = file_eda_match(fileNames[0])
for fName in fileNames[1:]:
if file_eda_match(fName) != eda_module:
return
if eda_module:
self.m_listBox_edatool.SetSelection(self.m_listBox_edatool.FindString(eda_dict[eda_module]['label']))
# Use on `http://upverter.com/`.
'manufacturer part number': 'manf#',
'pcb footprint': 'footprint',
'reference designator': 'refs',
'part reference': 'refs',
}
)
GENERIC_PREFIX = 'GEN' # Part reference prefix to use when no references are present.
__all__ = ['get_part_groups']
from . import eda_dict
# Place information about this EDA into the eda_tool dictionary.
eda_dict.update(
{
'csv': {
'module': 'csv', # The directory name containing this file.
'label': 'CSV file', # Label used on the GUI.
'desc': 'CSV module reader for hand made BoM. Compatible with the software: Proteus and Eagle.',
# Formatting file match.
'file': {
'extension': '.csv', # File extension.
'content': '.' # Regular expression content match.
}
}
}
)
def get_part_groups(in_file, ignore_fields, variant):
'designator': 'refs',
'quantity': 'qty',
'manufacturer name': 'manf', # Used for some web site tools to part generator in Altium.
'manufacturer part number': 'manf#'
}
)
ALTIUM_NONE = '[NoParam]' # Value of Altium to `None`.
ALTIUM_PART_SEPRTR = r'(?[\s\S]+[\s\S]+[\s\S]+\[\s\S]+\<\/GRID>' # Regular expression content match.
}
}
}
)
def get_part_groups(in_file, ignore_fields, variant):
'''@brief Get groups of identical parts from an XML file and return them as a dictionary.
import sys, os, time
from datetime import datetime
import re
from bs4 import BeautifulSoup
from ..global_vars import logger, DEBUG_OVERVIEW, DEBUG_DETAILED, DEBUG_OBSESSIVE
from ..global_vars import SEPRTR
from ..distributors.global_vars import distributor_dict
from .tools import field_name_translations, remove_dnp_parts
__all__ = ['get_part_groups']
from . import eda_dict
# Place information about this EDA into the eda_tool dictionary.
eda_dict.update(
{
'kicad': {
'module': 'kicad', # The directory name containing this file.
'label': 'KiCad file', # Label used on the GUI.
'desc': 'KiCad open source EDA.',
# Formatting file match.
'file': {
'extension': '.xml', # File extension.
'content': 'Eeschema.*\<\/tool\>' # Regular expression content match.
}
}
}
)
def get_part_groups(in_file, ignore_fields, variant):
'''Get groups of identical parts from an XML file and return them as a dictionary.
def file_eda_match(file_name):
'''@brief Verify with which EDA the file matches.
Return the EDA name with the file matches or `None` if not founded.
@param file_name File `str` name.
@return Name of the module corresponding to read the file or `None`to not recognized.
'''
try:
file_handle = open(file_name, 'r')
content = file_handle.read()
except UnicodeDecodeError: # It happens with some Windows CSV files on Python 3.
file_handle.close()
file_handle = open(file_name, 'r', encoding ='ISO-8859-1')
content = file_handle.read()
extension = os.path.splitext(file_name)[1]
for name, defs in eda_dict.items():
#print(name, extension==defs['file']['extension'], re.search(defs['file']['content'], content, re.IGNORECASE))
if re.search(defs['file']['content'], content, re.IGNORECASE)\
and extension==defs['file']['extension']:
file_handle.close()
return name
file_handle.close()
return None
def set_properties(self):
''' @brief Set the current proprieties of the graphical elements.'''
# Current distributors module recognized.
distributors_list = sorted([ distributor_dict[d]['label']['name'] for d in distributor_dict.keys() if distributor_dict[d]['type']!='local'])
self.m_checkList_dist.Clear()
for d in distributors_list: # Make this for wxPy3 compatibility, not allow include a list.
self.m_checkList_dist.Append(d)
#self.m_checkList_dist.Append(distributors_list)
for idx in range(len(distributors_list)):
self.m_checkList_dist.Check(idx,True) # All start checked (after is modified by the configuration file).
# Current EDA tools module recognized.
eda_names = sorted([ eda_dict[eda]['label'] for eda in eda_dict.keys() ])
self.m_listBox_edatool.Clear()
for s in eda_names: # Make this for wxPy3 compatibility, not allow include a list.
self.m_listBox_edatool.Append(s)
#self.m_listBox_edatool.Append(eda_names)
# Get all the currencies present.
loc = locale.getdefaultlocale()[0]
currencyList = sorted(list(babel.numbers.list_currencies()))
for c in range(len(currencyList)):
currency = currencyList[c]
currencyList[c] = '({a} {s}) {n}'.format(a=currency,
s=babel.numbers.get_currency_symbol(currency, locale=loc),
n=babel.numbers.get_currency_name(currency, locale=loc)
)
self.m_comboBox_currency.Insert(currencyList, 0)
def file_eda_match(file_name):
'''@brief Verify with which EDA the file matches.
Return the EDA name with the file matches or `None` if not founded.
@param file_name File `str` name.
@return Name of the module corresponding to read the file or `None`to not recognized.
'''
try:
file_handle = open(file_name, 'r')
content = file_handle.read()
except UnicodeDecodeError: # It happens with some Windows CSV files on Python 3.
file_handle.close()
file_handle = open(file_name, 'r', encoding ='ISO-8859-1')
content = file_handle.read()
extension = os.path.splitext(file_name)[1]
for name, defs in eda_dict.items():
#print(name, extension==defs['file']['extension'], re.search(defs['file']['content'], content, re.IGNORECASE))
if re.search(defs['file']['content'], content, re.IGNORECASE)\
and extension==defs['file']['extension']:
file_handle.close()
return name
file_handle.close()
return None
'designator': 'refs',
'quantity': 'qty',
'manufacturer name': 'manf', # Used for some web site tools to part generator in Altium.
'manufacturer part number': 'manf#'
}
)
ALTIUM_NONE = '[NoParam]' # Value of Altium to `None`.
ALTIUM_PART_SEPRTR = r'(?[\s\S]+[\s\S]+[\s\S]+\[\s\S]+\<\/GRID>' # Regular expression content match.
}
}
}
)
def get_part_groups(in_file, ignore_fields, variant):
'''@brief Get groups of identical parts from an XML file and return them as a dictionary.
# Set up logging.
if args.debug is not None:
log_level = logging.DEBUG + 1 - args.debug
elif args.quiet is True:
log_level = logging.ERROR
else:
log_level = logging.WARNING
logging.basicConfig(level=log_level, format='%(message)s')
if args.show_dist_list:
print('Distributor list:', *sorted(list(distributor_dict.keys())))
return
if args.show_eda_list:
#eda_names = [o[0] for o in inspect.getmembers(eda_tools_imports) if inspect.ismodule(o[1])]
#print('EDA supported list:', ', '.join(eda_names))
print('EDA supported list:', *sorted(list(eda_dict.keys())))
return
# Set up spreadsheet output file.
if args.output == None:
# If no output file is given...
if args.input != None:
# Send output to spreadsheet with name of input file.
# Compose a name with the multiple BOM input file names.
args.output = output_filename(args.input)
else:
# Send output to spreadsheet with name of this application.
args.output = os.path.splitext(sys.argv[0])[0] + '.xlsx'
else:
# Output file was given. Make sure it has spreadsheet extension.
args.output = os.path.splitext(args.output)[0] + '.xlsx'
from .tools import field_name_translations, remove_dnp_parts
from .eda import eda_class
class eda_altium(eda_class):
def __init__(self):
pass
__all__ = ['get_part_groups']
from . import eda_dict
# Place information about this EDA into the eda_tool dictionary.
eda_dict.update(
{
'kicad': {
'module': 'kicad', # The directory name containing this file.
'label': 'KiCad file', # Label used on the GUI.
'desc': 'KiCad open source EDA.',
# Formatting file match.
'file': {
'extension': '.xml', # File extension.
'content': 'Eeschema.*\<\/tool\>' # Regular expression content match.
}
}
}
)
def get_part_groups(in_file, ignore_fields, variant):
'''Get groups of identical parts from an XML file and return them as a dictionary.