summaryrefslogtreecommitdiff
path: root/src/subcircuit/convertSub.py
blob: cce2747658c7136b5677c1bbb7c4923399647f58 (plain)
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
from PyQt4 import QtGui
from projManagement.Validation import Validation
from configuration.Appconfig import Appconfig
import os


# This class is called when User create new Project and contains \
# functions to convert kicad to Ngspice.
class convertSub(QtGui.QWidget):
    """
    Contains functions that checks project present for conversion and
    also function to convert Kicad to Ngspice.
    """

    def __init__(self, dockarea):
        super(convertSub, self).__init__()
        self.obj_validation = Validation()
        self.obj_appconfig = Appconfig()
        self.obj_dockarea = dockarea

    def createSub(self):
        """
        This function create command to call kicad to Ngspice converter.
        """
        print("Openinig Kicad-to-Ngspice converter from Subcircuit Module")
        self.projDir = self.obj_appconfig.current_subcircuit["SubcircuitName"]
        # Validating if current project is available or not
        if self.obj_validation.validateKicad(self.projDir):
            # Checking if project has .cir file or not
            if self.obj_validation.validateCir(self.projDir):
                # print "CIR file present"
                self.projName = os.path.basename(self.projDir)
                self.project = os.path.join(self.projDir, self.projName)

                var1 = self.project + ".cir"
                var2 = "sub"
                self.obj_dockarea.kicadToNgspiceEditor(var1, var2)
            else:
                self.msg = QtGui.QErrorMessage(None)
                self.msg.showMessage(
                    'The subcircuit does not contain any Kicad netlist\
                     file for conversion.')
                self.msg.setWindowTitle("Error Message")
        else:
            self.msg = QtGui.QErrorMessage(None)
            self.msg.showMessage(
                'Please select the subcircuit first. You can either create \
                new subcircuit or open existing subcircuit')
            self.msg.setWindowTitle("Error Message")