Пример #1
0
 def addnewmixerdetails(self, mixer, protocol, mutestyle, countbase):
     protocolelement = ET.Element('protocol')
     protocolelement.text = protocol
     mixer.insert(mixer.__len__(), protocolelement)
     mutestyleelement = ET.Element('mutestyle', mutestyle)
     mixer.insert(mixer.__len__(), mutestyleelement)
     countbaseelement = ET.Element('countbase')
     countbaseelement.text = '"{0}"'.format(countbase)
     mixer.insert(mixer.__len__(), countbaseelement)
Пример #2
0
 def addnewmixer(self, brand, model):
     newmixer = ET.Element('mixer', attrib={'mfr': brand, 'model': model})
     self.mixers.insert(self.mixers.__len__(), newmixer)
     self.mixer_list()
     self.mixer_count = len(self.mixers)
     return newmixer
     print()
Пример #3
0
    def toXMLdoc(self):
        # get cues xml
        # self.cuelist = ET.parse('/home/mac/Shows/CharTest/CharTest_cuesx.xml')
        self.cuelist = ET.parse('/home/mac/Shows/Fiddler/Fiddler_cuesx.xml')
        self.cuelist_root = self.cuelist.getroot()
        self.cues = self.cuelist_root.findall(".cues/cue")
        # get char xml
        # self.charlist = ET.parse('/home/mac/Shows/CharTest/CharTest_char.xml')
        self.charlist = ET.parse(
            '/home/mac/Shows/Fiddler/FiddlerChar_char.xml')
        self.charlist_root = self.charlist.getroot()
        self.chars = self.charlist_root.findall(".chars/char")

        showcontrol = ET.Element('showcontrol')
        newcues = ET.SubElement(showcontrol, 'cues')
        ET.SubElement(newcues, 'version').text = '1.0'
        for cue in self.cues:
            cue_uuid = cue.get('uuid')

            cue = ET.SubElement(newcues, 'cue', attrib={'uuid': cue_uuid})
            for char in self.chars:
                char_uuid = char.get('uuid')
                newchar = ET.SubElement(cue,
                                        'char',
                                        attrib={'uuid': char_uuid})
                ET.SubElement(newchar, 'mute').text = '1'
                ET.SubElement(newchar, 'onstage').text = '0'
                ET.SubElement(newchar, 'level').text = '0'
                ET.SubElement(newchar, 'eq', attrib={'uuid': 'eq uuid'})
                ET.SubElement(newchar,
                              'routing',
                              attrib={'uuid': 'routing uuid'})
        return showcontrol
Пример #4
0
 def makenewstrip(self, mixer, striptype, stripcount, stripname):
     newstrip = ET.Element('strip',
                           attrib={
                               'type': striptype,
                               'cnt': stripcount,
                               'name': stripname
                           })
     # newcontrol = ET.SubElement(newstrip, 'fader')
     mixer.insert(mixer.__len__(), newstrip)
     return newstrip
Пример #5
0
 def __init__(self, cuecharfilename, first_cue_uuid=None, char_list=None):
     """"""
     logging.info('In CueChar init')
     if not path.isfile(cuecharfilename):
         # build new cuechar file
         self.cuecharlist = ET.Element('showcontrol')
         project = ET.SubElement(self.cuecharlist, 'cues')
         ET.SubElement(project, 'version').text = '1.0'
         self.add_cue(first_cue_uuid, char_list)
         self.write(self.cuecharlist, False, cuecharfilename)
     self.setup_cuechar(cuecharfilename)
Пример #6
0
 def chars_toxmldoc(self):
     """Create a new showcontrol element from the current state of the list of character tuples"""
     newcharelements = {}
     showcontrol = ET.Element('showcontrol')
     ET.SubElement(showcontrol, 'version').text = '1.0'
     chars = ET.SubElement(showcontrol, 'chars')
     for char in self.char_list:
         charchild = ET.SubElement(chars, 'char', attrib={'uuid': char[0]})
         ET.SubElement(charchild, 'name').text = char[1]
         ET.SubElement(charchild, 'actor').text = char[2]
     return showcontrol
Пример #7
0
    def addnewcue(self, cue_data=[]):
        cues_element = self.cuelist.find(".cues")
        cues = cues_element.findall(".cue")
        cue_count = len(cues)
        newcue = ET.Element('cue',attrib={'uuid':'{0}'.format(uuid.uuid4()), 'num':'{0:03}'.format(cue_count)})

        #newcue = ET.Element('cue',attrib={'uuid':'{0}'.format(uuid.uuid4()), 'num':'{0:03}'.format(self.cuecount)})
        for i in range(cue_subelements.__len__()):
            newele = ET.SubElement(newcue, cue_subelements[i].replace('_',''))
            newele.text = cue_data[i]
        cues_element.append(newcue)

        # ET.dump(cues_element)
        cues = self.cuelist.findall('.cues/cue')
        self.cuecount = len(cues)
        # self.cuelist.write('addelementtest.xml')

        return [newcue.get('uuid'), newcue.get('num')]
Пример #8
0
 def toXMLdoc(self, title, name, venue):
     showcontrol = ET.Element('showcontrol')
     project = ET.SubElement(showcontrol, 'project')
     ET.SubElement(project, 'version').text = '1.0'
     ET.SubElement(project, 'title').text = title
     ET.SubElement(project,
                   'equipment',
                   attrib={'href': venue + '_equipment.xml'})
     ET.SubElement(project,
                   'equipment',
                   attrib={'href': name + '_equipment.xml'})
     ET.SubElement(project, 'mixermap', attrib={'href': 'MixerMap.xml'})
     ET.SubElement(project, 'charmap', attrib={'href': name + '_char.xml'})
     ET.SubElement(project,
                   'cuechar',
                   attrib={'href': name + '_cuechar.xml'})
     ET.SubElement(project, 'cues', attrib={'href': venue + '_cues.xml'})
     ET.SubElement(project, 'cues', attrib={'href': name + '_cues.xml'})
     return showcontrol
Пример #9
0
 def toXMLdoc(self):
     showcontrol = ET.Element('showcontrol')
     cues = ET.SubElement(showcontrol, 'cues')
     ET.SubElement(cues, 'version').text = '1.0'
     cue = ET.SubElement(cues, 'cue', attrib={'uuid':'{0}'.format(uuid.uuid4()), 'num':'{0:03}'.format(0)})
     ET.SubElement(cue, 'Id').text = '0'
     ET.SubElement(cue, 'Act').text = '0'
     ET.SubElement(cue, 'Scene').text = 'Pre Show'
     ET.SubElement(cue, 'Page').text = '0'
     ET.SubElement(cue, 'Title').text = 'Initial State'
     ET.SubElement(cue, 'CueCall').text = 'Program Start'
     ET.SubElement(cue, 'CueType').text = 'Stage,Mixer,Sound'
     ET.SubElement(cue, 'Mutes').text = ''
     ET.SubElement(cue, 'Entrances').text = ''
     ET.SubElement(cue, 'Exits').text = ''
     ET.SubElement(cue, 'Levels').text = ''
     ET.SubElement(cue, 'OnStage').text = ''
     ET.SubElement(cue, 'Note1').text = ''
     ET.SubElement(cue, 'Note2').text = ''
     ET.SubElement(cue, 'Note3').text = ''
     ET.SubElement(cue, 'map').text = '0'
     return showcontrol
Пример #10
0
 def insertcue(self, cueindex, cue_data=[]):
     # cueidx is the index that we're inserting above, so
     # create an empty place by incrementing the cue num for this and each subsequent cue
     for anidx in reversed(range(cueindex, self.cuecount)):
         cuenum = '{0:03}'.format(anidx)
         thiscue = self.cuelist.find(".cues/cue[@num='"+cuenum+"']")
         thisidx = thiscue.get('num')
         thiscue.set('num', '{0:03}'.format(int(thisidx) + 1))
         print(thiscue.get('num'))
     # now we have an empty place
     # create the new cue
     # show = self.cuelist.getroot()
     # ET.dump(show)
     cues_element = self.cuelist.find(".cues")
     newcue = ET.Element('cue',attrib={'uuid':'{0}'.format(uuid.uuid4()), 'num':'{0:03}'.format(cueindex)})
     for i in range(cue_subelements.__len__()):
         newele = ET.SubElement(newcue, cue_subelements[i].replace('_',''))
         newele.text = cue_data[i]
     cues_element.insert(cueindex + 1, newcue)
     # show.insert(cueindex, newcue)
     # ET.dump(show)
     cues = self.cuelist.findall('.cues/cue')
     self.cuecount = len(cues)
     return
Пример #11
0
 def updateFromDict(self):
     newdoc = ET.Element('show_control')
     for key in self.cfgdict:
         print('key: {0}'.format(key))
         firstlevelel = ET.SubElement(newdoc, key)
         if type(self.cfgdict[key]) is not dict:
             print('**')
             print(self.cfgdict[key])
             firstlevelel.text = self.cfgdict[key]
         else:
             children = self.cfgdict[key]
             for child in children:
                 print('child: {0}, childval: {1}'.format(
                     child, children[child]))
                 secondlevel = ET.SubElement(firstlevelel, child)
                 child_item = children[child]
                 if type(child_item) is dict:
                     for item in child_item:
                         thirdlevel = ET.SubElement(secondlevel, item)
                         thirdlevel.text = child_item[item]
                 else:
                     secondlevel.text = children[child]
                 pass
     return newdoc
Пример #12
0
        return


if __name__ == "__main__":
    #/home/mac/SharedData/PycharmProjs/ShowControl/ShowControl/utils/
    logging.basicConfig(level=logging.INFO,
                        filename='CueList.log', filemode='w',
                        format='%(name)s %(levelname)s %(message)s')

    app = QtWidgets.QApplication([''])
    cues = CueList('/home/mac/Shows/Fiddler/Fiddler_cuesx.xml')
    cues.getcuetype(0)
    ET.dump(cues.cuelist)
    allcues = cues.cuelist.findall(".cues/cue")
    showcontrol = ET.Element('showcontrol')
    sortedcues = ET.SubElement(showcontrol, 'cues')
    ET.SubElement(sortedcues, 'version').text = '1.0'
    for count, cue in enumerate(allcues):
        cuenum = cue.get("num")
        print('count: {}, num: {} {}'.format(count, cuenum, count == int(cuenum)))
        if count == int(cuenum):
            # save it in new doc
            sortedcues.append(cue)
        else: # find the cue element for this count and save it in the new doc
            nextcue = cues.cuelist.find(".cues/cue[@num='" + '{0:03}'.format(count) + "']")
            sortedcues.append(nextcue)
    ET.dump(showcontrol)
    cuesxml = CuesXML()
    cuesxml.write(showcontrol, False, '/home/mac/Shows/Fiddler/sorted_Fiddler_cuesx.xml')
    # somecue = cues.cuelist.find(".cues/cue[@num='000']")
Пример #13
0
        import cElementTree as ET
        print("running with cElementTree")
      except ImportError:
        try:
          # normal ElementTree install
          import elementtree.ElementTree as ET
          print("running with ElementTree")
        except ImportError:
          print("Failed to import ElementTree from any known place")





    
root = ET.Element("TeamA")
elem = ET.SubElement(root, "team_counter")
elem.text = "1"
elem = ET.SubElement(root, "attackpoints")
elem.text = "2"
elem = ET.SubElement(root, "keeperpoints")
elem.text = "3"

#for child in root:
#    print (child.tag, child.attrib)



outFilename = "./output.xml"
html = ET.Element("html")
body = ET.SubElement(html, "body")