'Extract content language from meta'

def get_meta_lang(self, doc):

    attr = self.parser.getAttribute(doc, attr='lang')
    if (attr is None):
        items = [{'tag': 'meta', 'attr': 'http-equiv', 'value': 'content-language'}, {'tag': 'meta', 'attr': 'name', 'value': 'lang'}]
        for item in items:
            meta = self.parser.getElementsByTag(doc, **item)
            if meta:
                attr = self.parser.getAttribute(meta[0], attr='content')
                break
    if attr:
        value = attr[:2]
        if re.search(RE_LANG, value):
            return value.lower()
    return None
