>>> p = Preso()
        >>> z = p.to_file('/tmp/foo.odp')
        >>> sorted(z.ls('/'))
        ['META-INF/manifest.xml', 'content.xml', 'meta.xml', 'mimetype', 'settings.xml', 'styles.xml']
154
def to_file(self, filename=None, write_style=True):
        
        out = zipwrap.Zippier(filename, "w")
        out.write("mimetype", self.mime_type)
        for p in self._pictures:
            out.write("Pictures/%s" % p.internal_name, p.get_data())
        out.write("content.xml", self.to_xml())
        if write_style:
            out.write("styles.xml", self.styles_xml())
        out.write("meta.xml", self.meta_xml())
        out.write("settings.xml", self.settings_xml())
        out.write("META-INF/manifest.xml", self.manifest_xml(out))
        return out
280749
def pydict2xmlstring(metadata_dict, **kwargs):
    """"""
    ordering = kwargs.get('ordering', UNTL_XML_ORDER)
    root_label = kwargs.get('root_label', 'metadata')
    root_namespace = kwargs.get('root_namespace', None)
    elements_namespace = kwargs.get('elements_namespace', None)
    namespace_map = kwargs.get('namespace_map', None)
    root_attributes = kwargs.get('root_attributes', None)
    # Set any root namespace and namespace map.
    if root_namespace and namespace_map:
        root = Element(root_namespace + root_label, nsmap=namespace_map)
    elif namespace_map:
        root = Element(root_label, nsmap=namespace_map)
    else:
        root = Element(root_label)
    # Set any root element attributes.
    if root_attributes:
        for key, value in root_attributes.items():
            root.attrib[key] = value
    # Create an XML structure from field list.
    for metadata_key in ordering:
        if metadata_key in metadata_dict:
            for element in metadata_dict[metadata_key]:
                if 'content' in element and 'qualifier' in element:
                    create_dict_subelement(
                        root,
                        metadata_key,
                        element['content'],
                        attribs={'qualifier': element['qualifier']},
                        namespace=elements_namespace,
                    )
                elif 'content' in element and 'role' in element:
                    create_dict_subelement(
                        root,
                        metadata_key,
                        element['content'],
                        attribs={'role': element['role']},
                        namespace=elements_namespace,
                    )
                elif 'content' in element and 'scheme' in element:
                    create_dict_subelement(
                        root,
                        metadata_key,
                        element['content'],
                        attribs={'scheme': element['scheme']},
                        namespace=elements_namespace,
                    )
                elif 'content' in element:
                    create_dict_subelement(
                        root,
                        metadata_key,
                        element['content'],
                        namespace=elements_namespace,
                    )
    # Create the XML tree.
    return '<?xml version="1.0" encoding="UTF-8"?>\n' + tostring(
        root,
        pretty_print=True
    )
1076049
function parseTemplate(conf, tmpl) {
  // header
  let header = {};
  let cleanTmpl = tmpl.replace(conf.header, (m, headerStr) => {
    header = yaml.safeLoad(headerStr);
    return '';
  });

  // dependencies
  const deps = new LayoutDependency();

  const masterPath = header[conf.keys.master];
  if (masterPath) {
    deps.master = {
      path: lookupFile(conf, header[conf.keys.master]),
    };
  }

  // replace partial call's relative path to full path
  cleanTmpl = cleanTmpl.replace(conf.partial, (m, partialPath) => {
    const fullPath = lookupFile(conf, partialPath);
    deps.partials.set(
      partialPath,
      {
        path: fullPath,
      },
    );
    return m.replace(partialPath, fullPath);
  });

  return {
    header,
    deps,
    tmpl: cleanTmpl,
  };
}
390546
def _parse_postmeta(element):
    import phpserialize

    

    metadata = {}
    fields = element.findall("./{%s}postmeta" % WP_NAMESPACE)

    for field in fields:
        key = field.find("./{%s}meta_key" % WP_NAMESPACE).text
        value = field.find("./{%s}meta_value" % WP_NAMESPACE).text

        if key == "_wp_attachment_metadata":
            stream = StringIO(value.encode())
            try:
                data = phpserialize.load(stream)
                metadata["attachment_metadata"] = data
            except ValueError as e:
                pass
            except Exception as e:
                raise(e)

        if key == "_wp_attached_file":
            metadata["attached_file"] = value

    return metadata
167731
protected Format getFormat(Map<String,String> metaInfo) {
        Format format = Format.json;
        metaInfo.put(Listener.METAINFO_CONTENT_TYPE, Listener.CONTENT_TYPE_JSON);
        String formatParam = (String) metaInfo.get("format");
        if (formatParam != null) {
            if (formatParam.equals("xml")) {
                format = Format.xml;
                metaInfo.put(Listener.METAINFO_CONTENT_TYPE, Listener.CONTENT_TYPE_XML);
            }
            else if (formatParam.equals("text")) {
                format = Format.text;
                metaInfo.put(Listener.METAINFO_CONTENT_TYPE, Listener.CONTENT_TYPE_TEXT);
            }
        }
        else {
            if (Listener.CONTENT_TYPE_XML.equals(metaInfo.get(Listener.METAINFO_CONTENT_TYPE)) || Listener.CONTENT_TYPE_XML.equals(metaInfo.get(Listener.METAINFO_CONTENT_TYPE.toLowerCase()))) {
                format = Format.xml;
                metaInfo.put(Listener.METAINFO_CONTENT_TYPE, Listener.CONTENT_TYPE_XML);
            }
            else if (Listener.CONTENT_TYPE_TEXT.equals(metaInfo.get(Listener.METAINFO_CONTENT_TYPE)) || Listener.CONTENT_TYPE_TEXT.equals(metaInfo.get(Listener.METAINFO_CONTENT_TYPE.toLowerCase()))) {
                format = Format.text;
                metaInfo.put(Listener.METAINFO_CONTENT_TYPE, Listener.CONTENT_TYPE_JSON);
            }
        }
        return format;
    }
647705
def pp(el,preString=''):
	
	tab=' '*4
	if isinstance(el,dict):
		keys=list(el.keys())
		keys.sort()
		for key in keys:
			val=el[key]
			if isinstance(val,dict) or isinstance(val,list):
				print('%s%s :' % (preString,key))
				pp(val,preString+tab)
			else:
				print('%s%s  =  %s' % (preString,key,val))
	
	elif isinstance(el,list):
		print(preString+tab+'[')
		preString+=tab	
		for _ in el:
			if isinstance(_,dict):
				print (preString+tab+'{')
				pp(_,preString+tab*2)
				print(preString+tab+'}')
			elif isinstance(_,list):
				print(preString+tab+'[')
				pp(_,preString+tab)
				print(preString+tab+']')
			else:
				pp(_,preString+tab)
			#print preString+'      '+str('-')*10            
		print(preString	+']')
	else:
		print(preString+str(el))
133462
private void buildPackageMetadata() throws IOException {
    metadata.validate();
    buildTemplatedMetadataFile(META_DIR + "/" + CONFIG_XML);
    buildPropertiesFile(META_DIR + "/" + PROPERTIES_XML);
    buildTemplatedMetadataFile(META_DIR + "/" + SETTINGS_XML);
    buildTemplatedMetadataFile(META_DIR + "/" + PACKAGE_DEFINITION_XML);
    writeXmlDocument(META_DIR + "/" + FILTER_XML, xmlContentBuilder.buildFilter(metadata.getFilters()));

    // package thumbnail
    byte[] thumbnailImage = metadata.getThumbnailImage();
    if (thumbnailImage != null) {
      zip.putNextEntry(new ZipEntry(META_DIR + "/definition/thumbnail.png"));
      try {
        zip.write(thumbnailImage);
      }
      finally {
        zip.closeEntry();
      }
    }
  }
151742
def _get_src_path_line_nodes_jacoco(self, xml_document, src_path):
        

        files = []
        packages = [pkg for pkg in xml_document.findall(".//package")]
        for pkg in packages:
            _files = [_file
                      for _file in pkg.findall('sourcefile')
                      if self._measured_source_path_matches(pkg.get('name'), _file.get('name'), src_path)
                      or []
                      ]
            files.extend(_files)

        if not files:
            return None
        lines = [file_tree.findall('./line')
                 for file_tree in files]
        return [elem for elem in itertools.chain(*lines)]
700540
static function getMetaAttributeType( $name, $context = 'search' )
    {


        $attributeList = array( 'search' => array_merge( array( 'guid' => 'mstring',
                                             'installation_id' => 'mstring',
                                             'installation_url' => 'mstring',
                                             'name' => 'text',
                                             'sort_name' => 'mstring',
                                             'anon_access' => 'boolean',
                                             'language_code' => 'mstring',
                                             'available_language_codes' => 'mstring',
                                             'main_url_alias' => 'mstring',
                                             'main_path_string' => 'mstring',
                                             'owner_name' => 'text',
                                             'owner_group_id' => 'sint',
                                             'path' => 'sint',
                                             'object_states' => 'sint',
                                             'visible_path' => 'sint',
                                             'hidden_path' => 'sint',
                                             'visible_path_string' => 'mstring',
                                             'hidden_path_string' => 'mstring' ),
                                      self::metaAttributes(),
                                      self::nodeAttributes() ),
                                'facet' =>  array(
                                             'owner_name' => 'string' ),
                                'filter' => array(),
                                'sort' => array() );
        if ( ! empty( $attributeList[$context][$name] ) )
        {
            return $attributeList[$context][$name];
        }
        elseif ( ! empty( $attributeList['search'][$name] ) )
        {
            return $attributeList['search'][$name];
        }
        else
        {
            return null;
        }
        //return $attributeList[$name];
    }
1177535
public void sortPom() {
        log.info("Sorting file " + pomFile.getAbsolutePath());

        String originalXml = fileUtil.getPomFileContent();
        String sortedXml = sortXml(originalXml);
        if (pomFileIsSorted(originalXml, sortedXml)) {
            log.info("Pom file is already sorted, exiting");
            return;
        }
        createBackupFile();
        saveSortedPomFile(sortedXml);
    }
488064
def _add_meta_dict_to_xml(self, doc, parent, meta_dict):
        
        if not meta_dict:
            return
        key_list = list(meta_dict.keys())
        key_list.sort()
        for key in key_list:
            el_list = _index_list_of_values(meta_dict, key)
            for el in el_list:
                self._add_meta_value_to_xml_doc(doc, parent, el)
1252642
def list_extmods():
    '''
    
    '''
    ret = {}
    ext_dir = os.path.join(__opts__['cachedir'], 'extmods')
    mod_types = os.listdir(ext_dir)
    for mod_type in mod_types:
        ret[mod_type] = set()
        for _, _, files in salt.utils.path.os_walk(os.path.join(ext_dir, mod_type)):
            for fh_ in files:
                ret[mod_type].add(fh_.split('.')[0])
        ret[mod_type] = list(ret[mod_type])
    return ret
329126
def get_pr_arguments_with_xml(mark, *args)
      res = get_pr_arguments_without_xml((!!mark).to_s, *args)
      res[:file] = File.expand_path(res[:file])
      res
    end
763994
def default(cls, package):
        
        partname = PackURI('/word/settings.xml')
        content_type = CT.WML_SETTINGS
        element = parse_xml(cls._default_settings_xml())
        return cls(partname, content_type, element, package)
985087
def toxml(self):
        

        xmlstr = '<ComponentType name="{0}"'.format(self.name) +\
          (' extends="{0}"'.format(self.extends) if self.extends else '') +\
          (' description="{0}"'.format(self.description) if self.description else '')

        chxmlstr = ''

        for property in self.properties:
            chxmlstr += property.toxml()

        for parameter in self.parameters:
            chxmlstr += parameter.toxml()
            
        for derived_parameter in self.derived_parameters:
            chxmlstr += derived_parameter.toxml()
            
        for index_parameter in self.index_parameters:
            chxmlstr += index_parameter.toxml()

        for constant in self.constants:
            chxmlstr += constant.toxml()
            
        childxml = ''
        childrenxml = ''
        
        for children in self.children:
            if children.multiple:
                childrenxml += children.toxml()
            else:
                childxml += children.toxml()
            
        chxmlstr += childxml
        chxmlstr += childrenxml
            
        for link in self.links:
            chxmlstr += link.toxml()
            
        for component_reference in self.component_references:
            chxmlstr += component_reference.toxml()
            
        for attachment in self.attachments:
            chxmlstr += attachment.toxml()
            
        for event_port in self.event_ports:
            chxmlstr += event_port.toxml()
            
        for exposure in self.exposures:
            chxmlstr += exposure.toxml()
            
        for requirement in self.requirements:
            chxmlstr += requirement.toxml()
            
        for component_requirement in self.component_requirements:
            chxmlstr += component_requirement.toxml()
            
        for instance_requirement in self.instance_requirements:
            chxmlstr += instance_requirement.toxml()
            
        for path in self.paths:
            chxmlstr += path.toxml()
            
        for text in self.texts:
            chxmlstr += text.toxml()

        chxmlstr += self.dynamics.toxml()
        chxmlstr += self.structure.toxml()
        chxmlstr += self.simulation.toxml()
            
        if chxmlstr:
            xmlstr += '>' + chxmlstr + '</ComponentType>'
        else:
            xmlstr += '/>'

        return xmlstr
975692
def getSRTemplates(self):
        
        this_dir = os.path.dirname(os.path.abspath(__file__))
        templates_dir = os.path.join(this_dir, self._TEMPLATES_DIR)
        tempath = '%s/%s' % (templates_dir, '*.pt')
        templates = [t.split('/')[-1] for t in glob.glob(tempath)]
        out = []
        for template in templates:
            out.append({'id': template, 'title': template[:-3]})
        for templates_resource in iterDirectoriesOfType(self._TEMPLATES_ADDON_DIR):
            prefix = templates_resource.__name__
            templates = [
                tpl for tpl in templates_resource.listDirectory()
                if tpl.endswith('.pt')
                ]
            for template in templates:
                out.append({
                    'id': '{0}:{1}'.format(prefix, template),
                    'title': '{0} ({1})'.format(template[:-3], prefix),
                })
        return out
1179428
def respth2ck(argv=None):
    
    parser = ArgumentParser(
        description='Convert a ReSpecTh XML file to a ChemKED YAML file.'
        )
    parser.add_argument('-i', '--input',
                        type=str,
                        required=True,
                        help='Input filename (e.g., "file1.yaml")'
                        )
    parser.add_argument('-o', '--output',
                        type=str,
                        required=False,
                        default='',
                        help='Output filename (e.g., "file1.xml")'
                        )
    parser.add_argument('-fa', '--file-author',
                        dest='file_author',
                        type=str,
                        required=False,
                        default='',
                        help='File author name to override original'
                        )
    parser.add_argument('-fo', '--file-author-orcid',
                        dest='file_author_orcid',
                        type=str,
                        required=False,
                        default='',
                        help='File author ORCID'
                        )

    args = parser.parse_args(argv)

    filename_ck = args.output
    filename_xml = args.input

    properties = ReSpecTh_to_ChemKED(filename_xml, args.file_author, args.file_author_orcid,
                                     validate=True)

    # set output filename and path
    if not filename_ck:
        filename_ck = os.path.join(os.path.dirname(filename_xml),
                                   os.path.splitext(os.path.basename(filename_xml))[0] + '.yaml'
                                   )

    with open(filename_ck, 'w') as outfile:
        yaml.dump(properties, outfile, default_flow_style=False)
    print('Converted to ' + filename_ck)