<commit_before># -*- coding: ISO-8859-15 -*- 
# ============================================================================= 
# Copyright (c) 2009 <NAME>
#
# Authors : <NAME> <<EMAIL>>
#           <NAME> <<EMAIL>>
#
# Contact email: <EMAIL>
# =============================================================================

""" ISO metadata parser """

from owslib.etree import etree
from owslib import util

# default variables

namespaces = {
    None : 'http://www.isotc211.org/2005/gmd',
    'gco': 'http://www.isotc211.org/2005/gco',
    'gmd': 'http://www.isotc211.org/2005/gmd',
    'gml': 'http://www.opengis.net/gml',
    'gml32': 'http://www.opengis.net/gml/3.2',
    'gmx': 'http://www.isotc211.org/2005/gmx',
    'gts': 'http://www.isotc211.org/2005/gts',
    'srv': 'http://www.isotc211.org/2005/srv',
    'xlink': 'http://www.w3.org/1999/xlink'
}

class MD_Metadata(object):
    """ Process gmd:MD_Metadata """
    def __init__(self, md):

        if hasattr(md, 'getroot'):  # standalone document
            self.xml = etree.tostring(md.getroot())
        else:  # part of a larger document
            self.xml = etree.tostring(md)

        val = md.find(util.nspath_eval('gmd:fileIdentifier/gco:CharacterString', namespaces))
        self.identifier = util.testXMLValue(val)

        val = md.find(util.nspath_eval('gmd:parentIdentifier/gco:CharacterString', namespaces))
        self.parentidentifier = util.testXMLValue(val)

        val = md.find(util.nspath_eval('gmd:language/gco:CharacterString', namespaces))
        self.language = util.testXMLValue(val)
        
        val = md.find(util.nspath_eval('gmd:datasetURI/gco:CharacterString', namespaces))
        self.dataseturi = util.testXMLValue(val)

        val = md.find(util.nspath_eval('gmd:language/gmd:LanguageCode', namespaces))
        self.languagecode = util.testXMLValue(val)
        
        val = md.find(util.nspath_eval('gmd:dateStamp/gco:Date', namespaces))
        self.datestamp = util.testXMLValue(val)

        self.charset = _testCodeListValue(md.find(util.nspath_eval('gmd:characterSet/gmd:MD_CharacterSetCode', namespaces)))<commit_msg>add fallback for gco:DateTime in gmd:dateStamp<commit_after># -*- coding: ISO-8859-15 -*- 
# ============================================================================= 
# Copyright (c) 2009 <NAME>
#
# Authors : <NAME> <<EMAIL>>
#           <NAME> <<EMAIL>>
#
# Contact email: <EMAIL>
# =============================================================================

""" ISO metadata parser """

from owslib.etree import etree
from owslib import util

# default variables

namespaces = {
    None : 'http://www.isotc211.org/2005/gmd',
    'gco': 'http://www.isotc211.org/2005/gco',
    'gmd': 'http://www.isotc211.org/2005/gmd',
    'gml': 'http://www.opengis.net/gml',
    'gml32': 'http://www.opengis.net/gml/3.2',
    'gmx': 'http://www.isotc211.org/2005/gmx',
    'gts': 'http://www.isotc211.org/2005/gts',
    'srv': 'http://www.isotc211.org/2005/srv',
    'xlink': 'http://www.w3.org/1999/xlink'
}

class MD_Metadata(object):
    """ Process gmd:MD_Metadata """
    def __init__(self, md):

        if hasattr(md, 'getroot'):  # standalone document
            self.xml = etree.tostring(md.getroot())
        else:  # part of a larger document
            self.xml = etree.tostring(md)

        val = md.find(util.nspath_eval('gmd:fileIdentifier/gco:CharacterString', namespaces))
        self.identifier = util.testXMLValue(val)

        val = md.find(util.nspath_eval('gmd:parentIdentifier/gco:CharacterString', namespaces))
        self.parentidentifier = util.testXMLValue(val)

        val = md.find(util.nspath_eval('gmd:language/gco:CharacterString', namespaces))
        self.language = util.testXMLValue(val)
        
        val = md.find(util.nspath_eval('gmd:datasetURI/gco:CharacterString', namespaces))
        self.dataseturi = util.testXMLValue(val)

        val = md.find(util.nspath_eval('gmd:language/gmd:LanguageCode', namespaces))
        self.languagecode = util.testXMLValue(val)
        
        val = md.find(util.nspath_eval('gmd:dateStamp/gco:Date', namespaces))
        self.datestamp = util.testXMLValue(val)

        if not self.datestamp:
            val = md.find(util.nspath_eval('gmd:dateStamp/gco:DateTime', namespaces))
            self.datestamp = util.testXMLValue(val)

        self.charset = _testCodeListValue(md.find(util.nspath_eval('gmd:characterSet/gmd:MD_CharacterSetCode', namespaces)))
{'fraction_non_alphanumeric': 0.21934331025240117, 'fraction_numerical': 0.027250390886754523, 'mean_word_length': 3.4914744232698096, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 18, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5673059', 'n_tokens_mistral': 1633, 'n_tokens_neox': 1497, 'n_words': 216}