<commit_before>from xml2obj import xml2obj
from pprint import pprint

class NWSCAPParser:
    FIPS6 = []
    UGC = []
    INFO_PARAMS = {}
    def __init__(self, raw_cap_xml):
        self.alert = xml2obj(raw_cap_xml)
        self.load_fips6()
        self.load_ugc()
        self.load_info_params()

    def load_fips6(self):
        [self.FIPS6.append(g.value) for g in self.alert.info.area.geocode if g.valueName.upper() == 'FIPS6']

    def load_ugc(self):
        [self.UGC.append(g.value) for g in self.alert.info.area.geocode if g.valueName.upper() == 'UGC']

    def load_info_params(self):
        [self.INFO_PARAMS.update({p.valueName:p.value}) for p in self.alert.info.parameter]

    def __getattr__(self, name):
        if name.startswith('__'):
            raise AttributeError(name)
        return getattr(self.alert, name)

def test():
    with open(r'cap.GA124CA04A0C28.SpecialWeatherStatement.124CA04A16B4GA.FFCSPSFFC.4bac84c809ce6019c69db271dfee28ad.xml','r') as f:
        src = f.read()
        alert = NWSCAPParser(src)
        print alert.identifier
        print alert.info.effective
        print alert.FIPS6
        print alert.UGC
        print alert.INFO_PARAMS

if __name__=='__main__':
    test()<commit_msg>updated test method<commit_after>from xml2obj import xml2obj
from pprint import pprint

class NWSCAPParser:
    FIPS6 = []
    UGC = []
    INFO_PARAMS = {}
    def __init__(self, raw_cap_xml):
        self.alert = xml2obj(raw_cap_xml)
        self.load_fips6()
        self.load_ugc()
        self.load_info_params()

    def load_fips6(self):
        [self.FIPS6.append(g.value) for g in self.alert.info.area.geocode if g.valueName.upper() == 'FIPS6']

    def load_ugc(self):
        [self.UGC.append(g.value) for g in self.alert.info.area.geocode if g.valueName.upper() == 'UGC']

    def load_info_params(self):
        [self.INFO_PARAMS.update({p.valueName:p.value}) for p in self.alert.info.parameter]

    def __getattr__(self, name):
        if name.startswith('__'):
            raise AttributeError(name)
        return getattr(self.alert, name)

def test():
    fn = r'cap.GA124CA04A0C28.xml'
    with open(fn,'r') as f:
        src = f.read()
        alert = NWSCAPParser(src)
        print alert.identifier
        print alert.info.effective
        print alert.FIPS6
        print alert.UGC
        print alert.INFO_PARAMS

if __name__=='__main__':
    test()
{'fraction_non_alphanumeric': 0.1181592039800995, 'fraction_numerical': 0.024461028192371476, 'mean_word_length': 2.712307692307692, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 12}, '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': '864133', 'n_tokens_mistral': 889, 'n_tokens_neox': 852, 'n_words': 165}