コード例 #1
0
ファイル: Program.py プロジェクト: cyplo/heekscnc
    def GetMachines(self):
        machines_file = self.alternative_machines_file
        if machines_file == "":
            machines_file = HeeksCNC.heekscnc_path + "/nc/machines2.txt"

        print "machines_file = ", machines_file

        f = open(machines_file)

        machines = []

        while True:
            line = f.readline()
            if len(line) == 0:
                break
            line = line.rstrip("\n")

            machine = Machine()
            space_pos = line.find(" ")
            if space_pos == -1:
                machine.file_name = line
                machine.description = line
            else:
                machine.file_name = str(line)[0:space_pos]
                machine.description = line[space_pos:]
            machines.append(machine)

        return machines
コード例 #2
0
    def GetMachines(self):
        machines_file = self.alternative_machines_file
        if machines_file == "":
            machines_file = HeeksCNC.heekscnc_path + "/nc/machines2.txt"

        print 'machines_file = ', machines_file

        f = open(machines_file)

        machines = []

        while (True):
            line = f.readline()
            if (len(line) == 0): break
            line = line.rstrip('\n')

            machine = Machine()
            space_pos = line.find(' ')
            if space_pos == -1:
                machine.file_name = line
                machine.description = line
            else:
                machine.file_name = str(line)[0:space_pos]
                machine.description = line[space_pos:]
            machines.append(machine)

        return machines
コード例 #3
0
ファイル: Program.py プロジェクト: danheeks/PyCAM
    def GetMachines(self):
        machines_file = self.alternative_machines_file
        if machines_file == "":
            machines_file = wx.GetApp().cam_dir + "/nc/machines.xml"

        import re
        import xml.etree.ElementTree as ET

        with open(machines_file) as f:
            xml = f.read()
        root = ET.fromstring(
            re.sub(r"(<\?xml[^>]+\?>)", r"\1<root>", xml) + "</root>")
        #root = tree.getroot()

        machines = []

        for item in root.findall('Machine'):
            machine = Machine()
            machine.post = item.attrib['post']
            machine.reader = item.attrib['reader']
            machine.suffix = item.attrib['suffix']
            machine.description = item.attrib['description']
            machines.append(machine)

        return machines