Searches in docx template all the xml pictures tag and store them
        in pic_map dict
970245
def build_pic_map(self):
        """"""
        if self.pic_to_replace:
            # Main document
            part=self.docx.part
            self.pic_map.update(self._img_filename_to_part(part))

            # Header/Footer
            for relid, rel in six.iteritems(self.docx.part.rels):
                if rel.reltype in (REL_TYPE.HEADER,REL_TYPE.FOOTER):
                    self.pic_map.update(self._img_filename_to_part(rel.target_part))
720253
def parsexml(self, xmlstring, modules, source=None):
        
        result = {}

        from fortpy.utility import XML_fromstring
        xmlroot = XML_fromstring(xmlstring, source)
        if xmlroot.tag == "fortpy" and "mode" in xmlroot.attrib and \
           xmlroot.attrib["mode"] == "docstring":
            #First, cycle through the kids to find the <global> tag (if any
            #exist). It's children will apply to any of the other tags we find
            #and we will have to update their attributes accordingly.
            xmlglobals = {}
            for child in xmlroot.iterfind("globals"):
                _update_globals(list(child), xmlglobals)
            _set_global_defaults(xmlglobals)
                
            #We fill the dictionary with decorates names as keys and lists
            #of the xml docstring elements as values.
            for child in xmlroot:
                if child.tag == "globals":
                    continue

                xmltags = []
                if child.tag == "decorates" and "name" in child.attrib:
                    decorates = child.attrib["name"]
                    xmltags.extend(list(child))
                elif "decorates" in child.attrib:
                    decorates = child.attrib["decorates"]
                    xmltags.append(child)

                for xtag in xmltags:
                    _update_from_globals(xtag, xmlglobals, child)

                if decorates in result:
                    result[decorates].extend(xmltags)
                else:
                    result[decorates] = xmltags

            #Loop through all the docstrings we found and team them up with
            #their respective module members.
            self._xml_update_modules(result, modules)
593544
function addImageAliasToXML( $domTree, $imageAlias )
    {
        $imageVariationNodeArray = $domTree->getElementsByTagName( 'alias' );
        $imageNode = false;
        foreach ( $imageVariationNodeArray as $imageVariation )
        {
            $aliasEntryName = $imageVariation->getAttribute( 'name' );
            if ( $aliasEntryName == $imageAlias['name'] )
            {
                $imageNode = $imageVariation;
                break;
            }
        }
        if ( !$imageNode )
        {
            $rootNode = $domTree->documentElement;

            $imageNode = $domTree->createElement( "alias" );
            $rootNode->appendChild( $imageNode );
        }
        else
        {
            $imageNode->removeAttribute( 'name' );
            $imageNode->removeAttribute( 'filename' );
            $imageNode->removeAttribute( 'suffix' );
            $imageNode->removeAttribute( 'dirpath' );
            $imageNode->removeAttribute( 'url' );
            $imageNode->removeAttribute( 'mime_type' );
            $imageNode->removeAttribute( 'width' );
            $imageNode->removeAttribute( 'height' );
            $imageNode->removeAttribute( 'alias_key' );
            $imageNode->removeAttribute( 'timestamp' );
            $imageNode->removeAttribute( 'is_valid' );
        }
        $imageNode->setAttribute( 'name', $imageAlias['name'] );
        $imageNode->setAttribute( 'filename', $imageAlias['filename'] );
        $imageNode->setAttribute( 'suffix', $imageAlias['suffix'] );
        $imageNode->setAttribute( 'dirpath', $imageAlias['dirpath'] );
        $imageNode->setAttribute( 'url', $imageAlias['url'] );
        $imageNode->setAttribute( 'mime_type', $imageAlias['mime_type'] );
        $imageNode->setAttribute( 'width', $imageAlias['width'] );
        $imageNode->setAttribute( 'height', $imageAlias['height'] );
        $imageNode->setAttribute( 'alias_key', $imageAlias['alias_key'] );
        $imageNode->setAttribute( 'timestamp', $imageAlias['timestamp'] );
        $imageNode->setAttribute( 'is_valid', $imageAlias['is_valid'] );
    }
1234199
def templateDoc(self):
        
        doc = dict(self.componentDoc(False).items() + self.testDoc().items())

        # go through auto-parameter selected components and use location index
        autoparams = copy.deepcopy(self._autoParams.allData())
        for p in autoparams:
            selection = p['selection']
            serializable_selection = []
            for component in selection:
                idx = self.indexByComponent(component)
                serializable_selection.append(idx)
            p['selection'] = serializable_selection

        doc['autoparameters'] = autoparams
        doc['reorder'] = self.reorderName
        return doc
1065613
def list_tags():
    '''
    
    '''
    ret = set()
    for item in six.itervalues(images()):
        if not item.get('RepoTags'):
            continue
        ret.update(set(item['RepoTags']))
    return sorted(ret)
810993
def _structmap(self):
        
        structmap = etree.Element(
            utils.lxmlns("mets") + "structMap",
            TYPE="physical",
            # TODO Add ability for multiple structMaps
            ID="structMap_1",
            # TODO don't hardcode this
            LABEL="Archivematica default",
        )
        for item in self._root_elements:
            child = item.serialize_structmap(recurse=True)
            if child is not None:
                structmap.append(child)

        return structmap
1039405
def parse_from_template(template_name):
    
    thisdir = os.path.split(__file__)[0]
    filename = os.path.join(
        thisdir, '..', 'templates', '%s.xml' % template_name
    )
    with open(filename, 'rb') as f:
        xml = f.read()
    return parse_xml(xml)
1135433
def get_template_as_xml(template_id,**kwargs):
    
    template_xml = etree.Element("template_definition")

    template_i = db.DBSession.query(Template).filter(
            Template.id==template_id).options(
                #joinedload_all('templatetypes.typeattrs.default_dataset.metadata')
                joinedload('templatetypes').joinedload('typeattrs').joinedload('default_dataset').joinedload('metadata')

            ).one()

    template_name = etree.SubElement(template_xml, "template_name")
    template_name.text = template_i.name
    template_description = etree.SubElement(template_xml, "template_description")
    template_description.text = template_i.description
    resources = etree.SubElement(template_xml, "resources")

    for type_i in template_i.templatetypes:
        xml_resource    = etree.SubElement(resources, "resource")

        resource_type   = etree.SubElement(xml_resource, "type")
        resource_type.text   = type_i.resource_type

        name   = etree.SubElement(xml_resource, "name")
        name.text   = type_i.name

        description   = etree.SubElement(xml_resource, "description")
        description.text   = type_i.description

        alias   = etree.SubElement(xml_resource, "alias")
        alias.text   = type_i.alias

        if type_i.layout is not None and type_i.layout != "":
            layout = _get_layout_as_etree(type_i.layout)
            xml_resource.append(layout)

        for type_attr in type_i.typeattrs:
            attr = _make_attr_element_from_typeattr(xml_resource, type_attr)

        resources.append(xml_resource)

    xml_string = etree.tostring(template_xml, encoding="unicode")

    return xml_string
447748
def file_add_tags(object_id, input_params={}, always_retry=True, **kwargs):
    
    return DXHTTPRequest('/%s/addTags' % object_id, input_params, always_retry=always_retry, **kwargs)
140636
function(opts) {
    xml2js.opts = opts;
    return opts
      .option('-i, --inputdir [directory]', 'directory for xml files', __dirname + '/xml/mraa')
      .option('-c, --custom [file]', 'json for customizations')
      .option('-t, --typemaps [directory]', 'directory for custom pointer type maps')
      .option('-g, --imagedir [directory]', 'directory to link to where the images will be kept', '')
      .option('-s, --strict', 'leave out methods/variables if unknown type')
  }
1213914
def _child_list(element, child_tagname):
    
    xpath = './%s' % child_tagname
    return element.xpath(xpath, namespaces=nsmap)
389104
def to_doc(self, xmllist, decorates):
        """"""
        result = []
        for xitem in xmllist:
            if xitem.tag != "group":
                #The docstring allows a single string to point to multiple
                #names in a comma-separated list in the names attribute.
                if "name" in list(xitem.keys()):
                    names = re.split("[\s,]+", xitem.get("name"))
                    for name in names:                        
                        #Once we have created the DocElement, we need to override
                        #its name attribute (which will have the comma-separated
                        #list) with the single name
                        docel = DocElement(xitem, self, decorates)
                        docel.attributes["name"] = name
                        result.append(docel)
                else:
                    #This docstring doesn't have a name attribute, just add it
                    result.append(DocElement(xitem, self, decorates))
            else:
                docel = DocGroup(xitem, decorates)
                result.append(docel)
        return result
1275795
function(doc) {
        var node_list = doc.getElementsByTagName("node");
        var nodes = {};
        for (var i = 0; i < node_list.length; i++) {
            var node = node_list[i];
            var id = node.getAttribute("id");
            nodes[id] = {
                'lat': node.getAttribute("lat"),
                'lon': node.getAttribute("lon"),
                'node': node
            };
        }
        return nodes;
    }
1233570
def tagMap(self):
        "
        if self.tagSet:
            return Set.tagMap.fget(self)
        else:
            return self.componentType.tagMapUnique
1328795
def updateObjectFromXML(xml_doc, obj, mapping):
    
    nsmap = None
    if isinstance(mapping, dict):
        # The special key @namespaces is used to pass
        # namespaces and prefix mappings for xpath selectors.
        # e.g. {'x': 'http://example.com/namespace'}
        if '@namespaces' in mapping:
            nsmap = mapping['@namespaces']
    else:
        raise TypeError('Tag-to-property map must be a dict.')
    # Iterate over the keys of the translation dictionary from event objects
    # to xml objects, so we can update the fields with the new information
    for k, v in mapping.items():
        if k.startswith('@'):
            continue
        selected_text = None
        if isinstance(v, basestring):
            selector = v
        elif isinstance(v, list):
            selector = '/'.join(v)
        else:
            raise TypeError(
                'Invalid tag-to-property mapping dict: '
                'values must be strings or lists, not %s.' % (type(v),)
            )
        try:
            selected_text = xml_doc.xpath(selector, namespaces=nsmap)
            if isinstance(selected_text, list):
                selected_text = selected_text[0]
            selected_text = selected_text.text
            setattr(obj, k, selected_text)
        except IndexError:
            # Assume the value is missing. It's also possible that the
            # given selector is valid but wrong, but the more common
            # case is that the element is missing. To be consistent with
            # the prior implementation, empty resultsets just mean empty
            # attributes.
            continue
    return obj
698833
protected static Map<String, Object> eventSendPicsInfo(XMLEventReader reader) throws XMLStreamException {
        Map<String, Object> sendPicsInfoMap = new HashMap<String, Object>();
        while (reader.hasNext()){
            XMLEvent event = reader.nextEvent();
            if (event.isStartElement()) {
                String tagName = event.asStartElement().getName()
                        .toString();
                if("Count".equals(tagName)){
                    sendPicsInfoMap.put(tagName, reader.getElementText());
                }else if("PicList".equals(tagName)){
//                    StringBuilder sb = new StringBuilder();
                    List<Map<String, String>> picList = CollectionUtil.newArrayList();
                    while(reader.hasNext()){
                        XMLEvent event1 = reader.nextEvent();
                        if(event1.isStartElement() && "PicMd5Sum".equals(event1.asStartElement().getName()
                                .toString())){
                            Map<String, String> picMap = new HashMap<String, String>();
                            picMap.put("PicMd5Sum", reader.getElementText());
//                            sb.append(reader.getElementText());
//                            sb.append(",");
                            picList.add(picMap);
                        }else if(event1.isEndElement() && "PicList".equals(event1.asEndElement().getName().toString())){
                            break;
                        }
                    }
//                    sendPicsInfoMap.put(tagName, sb.substring(0, sb.length()));
                    sendPicsInfoMap.put(tagName, picList);
                }
            }
        }

        return sendPicsInfoMap;
    }
99084
private static Map<String, PictureData> getPicMapXlsx(XSSFWorkbook workbook, int sheetIndex) {
		final Map<String, PictureData> sheetIndexPicMap = new HashMap<String, PictureData>();
		final XSSFSheet sheet = workbook.getSheetAt(sheetIndex);
		XSSFDrawing drawing;
		for (POIXMLDocumentPart dr : sheet.getRelations()) {
			if (dr instanceof XSSFDrawing) {
				drawing = (XSSFDrawing) dr;
				final List<XSSFShape> shapes = drawing.getShapes();
				XSSFPicture pic;
				CTMarker ctMarker;
				for (XSSFShape shape : shapes) {
					pic = (XSSFPicture) shape;
					ctMarker = pic.getPreferredSize().getFrom();
					sheetIndexPicMap.put(StrUtil.format("{}_{}", ctMarker.getRow(), ctMarker.getCol()), pic.getPictureData());
				}
			}
		}
		return sheetIndexPicMap;
	}