diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/converter/LTSpiceToKiCadConverter/src/Windows/lib_LTspice2Kicad.py | 16 | ||||
-rw-r--r-- | src/converter/libConverter.py | 6 | ||||
-rw-r--r-- | src/converter/schematic_converters/lib/PythonLib/libParser.py | 108 | ||||
-rwxr-xr-x | src/frontEnd/ProjectExplorer.py | 44 | ||||
-rw-r--r-- | src/projManagement/Validation.py | 8 | ||||
-rw-r--r-- | src/projManagement/newProject.py | 8 |
6 files changed, 102 insertions, 88 deletions
diff --git a/src/converter/LTSpiceToKiCadConverter/src/Windows/lib_LTspice2Kicad.py b/src/converter/LTSpiceToKiCadConverter/src/Windows/lib_LTspice2Kicad.py index 177fa469..bf1a1eac 100644 --- a/src/converter/LTSpiceToKiCadConverter/src/Windows/lib_LTspice2Kicad.py +++ b/src/converter/LTSpiceToKiCadConverter/src/Windows/lib_LTspice2Kicad.py @@ -33,17 +33,23 @@ def find_all(a_str, sub): yield start
start += len(sub) # use start += 1 to find overlapping matches
-directory = sys.argv[1]
-# out_file = sys.argv[2]
+# Always go 1 level up from the given path
+directory = os.path.abspath(os.path.join(sys.argv[1], ".."))
if directory=="." : directory = os.getcwd()
+if not os.path.isdir(directory):
+ print(f"ERROR: '{directory}' is not a valid directory.")
+ sys.exit(1)
+
+# out_file = sys.argv[2]
+
dir = os.listdir(directory)
comp = []
for component in dir:
if (component[-4:]==".asy") : comp.append(component)
-indir = directory.split("\\")
-out_file = directory + "\LTspice_" + indir[len(indir)-1] + ".lib"
-print("Output Lib File: ",out_file)
+base_name = os.path.basename(os.path.normpath(directory)) # Get last folder name
+out_file = os.path.join(directory, "LTspice_" + base_name + ".lib")
+print("Output Lib File: ", out_file)
outfl = codecs.open(out_file,"w");
outfl.write("EESchema-LIBRARY Version 2.3\n#encoding utf-8\n#\n")
diff --git a/src/converter/libConverter.py b/src/converter/libConverter.py index 4ac4d354..3c30f7d3 100644 --- a/src/converter/libConverter.py +++ b/src/converter/libConverter.py @@ -22,10 +22,12 @@ class PspiceLibConverter: # Construct the full path to libParser.py parser_path = os.path.join(script_dir, relative_parser_path) - print(parser_path) + print("Parser Path:",parser_path) # Prepare the command as a list - command = ["python3", "libParser.py", file_path] + output_dir = os.path.dirname(file_path) + + command = ["python3", "libparser.py", file_path, output_dir] print(f"Running command: {' '.join(command)} in directory: {parser_path}") try: diff --git a/src/converter/schematic_converters/lib/PythonLib/libParser.py b/src/converter/schematic_converters/lib/PythonLib/libParser.py index c94bd7d5..364ecedc 100644 --- a/src/converter/schematic_converters/lib/PythonLib/libParser.py +++ b/src/converter/schematic_converters/lib/PythonLib/libParser.py @@ -21,60 +21,66 @@ libDescr = 'EESchema-LIBRARY Version 4.7 Date: \n#encoding utf-8\n' nameAppend = '_PSPICE' REMOVEDCOMPONENTS = ['TITLEBLK', 'PARAM', 'readme', 'VIEWPOINT', 'LIB', 'copyright', 'WATCH1', 'VECTOR', 'NODESET1'] -for fcounter in range(1, len(sys.argv[1:])+1): - input_file = open(sys.argv[fcounter], 'r+') - fbasename = os.path.basename(sys.argv[fcounter]) - flname = fbasename[:fbasename.find('.')] + '.lib' - flib = open(flname, 'w+') #Write .lib header: - print('Library file name: ',flname) +input_file_path = sys.argv[1] +output_dir = sys.argv[2] - flib.write(libDescr) +# Prepare input/output +input_file = open(input_file_path, 'r') +fbasename = os.path.basename(input_file_path) +flname = fbasename[:fbasename.find('.')] + '.lib' +flpath = os.path.join(output_dir, flname) +os.makedirs(output_dir, exist_ok=True) - line = skipTo(input_file,'*symbol') - print('Parser',line) - ''' +flib = open(flpath, 'w+') # Output .lib file + +print('Library file name: ', flname) + + +line = skipTo(input_file,'*symbol') +print('Parser',line) +''' +while(line != '' and '*symbol' not in line): + line = input_file.readline().strip() + print(line) +''' + +while(line != '__ERROR__'): + #print(input_file.tell()) + #print('Compo line',line) + d = line.find(' ') + cnametmp = line[d+1:] + #print('cnametmp',cnametmp) + d = cnametmp.find(' ') + if d == -1: + cname = cnametmp + else: + cname = cnametmp[0:d] + + #print('cname->',cname) + + fileTMP = open(input_file_path) + c = Component(fileTMP, cname) + #print(c.ref) + fixComp(c) + #print('After fixComp',cname, 'ref=', c.ref) + + write = True + + for i in range(len(REMOVEDCOMPONENTS)): #Don't let these components be saved. + if cname == REMOVEDCOMPONENTS[i]: + write = False + break + #print('write->', write) + #print('line->', line) + if write: + c.type_ = c.type_ + nameAppend + c.print(flib) + + '''line = input_file.readline().strip() while(line != '' and '*symbol' not in line): line = input_file.readline().strip() print(line) ''' - - while(line != '__ERROR__'): - #print(input_file.tell()) - #print('Compo line',line) - d = line.find(' ') - cnametmp = line[d+1:] - #print('cnametmp',cnametmp) - d = cnametmp.find(' ') - if d == -1: - cname = cnametmp - else: - cname = cnametmp[0:d] - - #print('cname->',cname) - - fileTMP = open(sys.argv[fcounter]) - c = Component(fileTMP, cname) - #print(c.ref) - fixComp(c) - #print('After fixComp',cname, 'ref=', c.ref) - - write = True - - for i in range(len(REMOVEDCOMPONENTS)): #Don't let these components be saved. - if cname == REMOVEDCOMPONENTS[i]: - write = False - break - #print('write->', write) - #print('line->', line) - if write: - c.type_ = c.type_ + nameAppend - c.print(flib) - - '''line = input_file.readline().strip() - while(line != '' and '*symbol' not in line): - line = input_file.readline().strip() - print(line) - ''' - line = skipTo(input_file, '*symbol') - flib.write('#\n#End Library\n') - flib.close() + line = skipTo(input_file, '*symbol') +flib.write('#\n#End Library\n') +flib.close() diff --git a/src/frontEnd/ProjectExplorer.py b/src/frontEnd/ProjectExplorer.py index b91f162c..99772378 100755 --- a/src/frontEnd/ProjectExplorer.py +++ b/src/frontEnd/ProjectExplorer.py @@ -32,27 +32,29 @@ class ProjectExplorer(QtWidgets.QWidget): self.treewidget.setHeaderItem(header) self.treewidget.setColumnHidden(1, True) - # Apply dark theme to header and background to match 'Welcome' dock - self.treewidget.setStyleSheet(''' - QHeaderView::section { - background: qlineargradient(x1:0, y1:0, x2:1, y2:0, - stop:0 rgba(33, 37, 51, 0.95), stop:1 rgba(20, 25, 35, 0.9)); - color: #90caf9; /* Soft blue */ - font-weight: 700; - font-size: 17px; - border-radius: 0; - padding: 12px 0px 12px 18px; - letter-spacing: 0.5px; - - } - QTreeWidget { - background: qlineargradient(x1:0, y1:0, x2:0, y2:1, - stop:0 rgba(26, 29, 41, 0.98), stop:1 rgba(15, 20, 25, 0.95)); - color: #e8eaed; - border: 1px solid rgba(255, 255, 255, 0.12); - border-radius: 0 0 12px 12px; - } - ''') + # CSS + init_path = '../../' + if os.name == 'nt': + init_path = '' + + self.treewidget.setStyleSheet(" \ + QTreeView { border-radius: 15px; border: 1px \ + solid gray; padding: 5px; width: 200px; height: 150px; }\ + QTreeView::branch:has-siblings:!adjoins-item { \ + border-image: url(" + init_path + "images/vline.png) 0;} \ + QTreeView::branch:has-siblings:adjoins-item { \ + border-image: url(" + init_path + "images/branch-more.png) 0; } \ + QTreeView::branch:!has-children:!has-siblings:adjoins-item { \ + border-image: url(" + init_path + "images/branch-end.png) 0; } \ + QTreeView::branch:has-children:!has-siblings:closed, \ + QTreeView::branch:closed:has-children:has-siblings { \ + border-image: none; \ + image: url(" + init_path + "images/branch-closed.png); } \ + QTreeView::branch:open:has-children:!has-siblings, \ + QTreeView::branch:open:has-children:has-siblings { \ + border-image: none; \ + image: url(" + init_path + "images/branch-open.png); } \ + ") for parents, children in list( self.obj_appconfig.project_explorer.items()): diff --git a/src/projManagement/Validation.py b/src/projManagement/Validation.py index 18b8a0aa..5f239163 100644 --- a/src/projManagement/Validation.py +++ b/src/projManagement/Validation.py @@ -61,8 +61,8 @@ class Validation: :projDir => Contains path of the new projDir created @return - :"CHECKEXIST" => If same project name folder exists - :"CHECKNAME" => If space is there in project name + :"CHECKEXIST" => If smae project name folder exists + :"CHECKNAME" => If space is there in name :"VALID" => If valid project name given """ print("Function: Validating New Project Information") @@ -72,9 +72,7 @@ class Validation: return "CHECKEXIST" # Project with name already exist else: # Check Proper name for project. It should not have space - # Extract only the project name (basename) from the full path - projName = os.path.basename(projDir) - if re.search(r"\s", projName): + if re.search(r"\s", projDir): return "CHECKNAME" else: return "VALID" diff --git a/src/projManagement/newProject.py b/src/projManagement/newProject.py index 2a443678..10fb0cb5 100644 --- a/src/projManagement/newProject.py +++ b/src/projManagement/newProject.py @@ -63,8 +63,8 @@ class NewProjectInfo(QtWidgets.QWidget): self.projName = projName self.workspace = self.obj_appconfig.default_workspace['workspace'] # self.projName = self.projEdit.text() - # Remove leading and trailing spaces AND replace internal spaces with underscores - self.projName = str(self.projName).strip().replace(" ", "_") + # Remove leading and trailing space + self.projName = str(self.projName).rstrip().lstrip() self.projDir = os.path.join(self.workspace, str(self.projName)) @@ -144,5 +144,5 @@ class NewProjectInfo(QtWidgets.QWidget): self.msg.exec_() return None, None -def cancelProject(self): - self.close() + def cancelProject(self): + self.close() |