def putcuefile(newdoc, cuedict, cuenum):
    global firstuuid
    if firstuuid and cuenum == 0:
        cueele = ET.SubElement(newdoc, 'Cue', {
            'uuid': '{0}'.format(firstuuid),
            'num': '{0:003}'.format(cuenum)
        })
        firstuuid = None
    else:
        cueele = ET.SubElement(newdoc, 'Cue', {
            'uuid': '{0}'.format(uuid.uuid4()),
            'num': '{0:003}'.format(cuenum)
        })

    for key in cuedict:
        print('key: {0}'.format(key))
        firstlevelel = ET.SubElement(cueele, key)
        if type(cuedict[key]) is not dict:
            print('**')
            print(cuedict[key])
            firstlevelel.text = cuedict[key]
        else:
            children = cuedict[key]
            for child in children:
                print('child: {0}, childval: {1}'.format(
                    child, children[child]))
                secondlevel = ET.SubElement(firstlevelel, child)
                secondlevel.text = children[child]
                pass
    return newdoc
Exemple #2
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
Exemple #3
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)
Exemple #4
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
Exemple #5
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
Exemple #6
0
 def setcueelement(self, cueindex, element_text, element_name):
     # find the cue specified by cueindex
     #thiscue = self.cuelist.find("./cue[@num='" + '{0:03}'.format(cueindex) + "']")
     thiscue = self.cuelist.find(".cues/cue[@num='" + '{0:03}'.format(cueindex) + "']")
     try:
         cuetype = thiscue.find(element_name)
         if cuetype != None:
             cuetype.text = element_text
         else:
             cuetype = ET.SubElement(thiscue, 'Levels')
             cuetype.text = element_text
     except:
         print('Cue element {0} for index {1:03} not found!'.format(element_name, cueindex))
     self.cuelist.write('update.xml')
Exemple #7
0
 def add_cue(self, cue_uuid, char_list):
     print('CueChar add_cue, uuid: {}'.format(cue_uuid))
     cues_element = self.cuecharlist.find('.cues')
     new_cue = ET.SubElement(cues_element, 'cue', {'uuid': cue_uuid})
     for char in char_list:
         new_char_ele = ET.SubElement(new_cue, 'char', {'uuid': char[0]})
         ET.SubElement(new_char_ele, 'mute').text = '1'
         ET.SubElement(new_char_ele, 'onstage').text = '0'
         ET.SubElement(new_char_ele, 'level').text = '0'
         ET.SubElement(new_char_ele, 'eq', attrib={'uuid': 'eq uuid'})
         ET.SubElement(new_char_ele,
                       'routing',
                       attrib={'uuid': 'routing uuid'})
 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
Exemple #9
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')]
Exemple #10
0
 def add_new_char(self, new_char_uuid):
     cues = self.cuecharlist.findall('.cues/cue')
     for cue in cues:
         chars = cue.findall(".char")
         print('In add_new_char, char count before: {}'.format(len(chars)))
         new_char_ele = ET.SubElement(cue, 'char', {'uuid': new_char_uuid})
         ET.SubElement(new_char_ele, 'mute').text = '1'
         ET.SubElement(new_char_ele, 'onstage').text = '0'
         ET.SubElement(new_char_ele, 'level').text = '0'
         ET.SubElement(new_char_ele, 'eq', attrib={'uuid': 'eq uuid'})
         ET.SubElement(new_char_ele,
                       'routing',
                       attrib={'uuid': 'routing uuid'})
Exemple #11
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
Exemple #12
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
Exemple #13
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']")
    # cue_elements = cues.cuelist.findall("./cue")
Exemple #14
0
        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")
ET.ElementTree(root).write(outFilename)
 def addcontrol(self, strip, tag, attribs):
     newelement = ET.SubElement(strip, tag, attribs)