(self)
return index
Read in index xml file from :attr:`UDHR._index_filepath`; skip elements
        without valid ISO-639-1 language code or sufficient translation quality,
        then convert into a list of dicts with key metadata, including filenames.
Read in index xml file from :attr:`UDHR._index_filepath`; skip elements
        without valid ISO-639-1 language code or sufficient translation quality,
        then convert into a list of dicts with key metadata, including filenames.
Read in index xml file from : attr : UDHR . _index_filepath ; skip elements without valid ISO - 639 - 1 language code or sufficient translation quality then convert into a list of dicts with key metadata including filenames .
def _load_and_parse_index(self) -> List[Dict[str, Any]]:
        """
        Read in index xml file from :attr:`UDHR._index_filepath`; skip elements
        without valid ISO-639-1 language code or sufficient translation quality,
        then convert into a list of dicts with key metadata, including filenames.
        """
        index = []
        tree = xml.etree.ElementTree.parse(self._index_filepath)
        root = tree.getroot()
        for ele in root.iterfind("udhr"):
            iso_lang_code = ele.get("bcp47", "").split("-", 1)[0]
            stage = int(ele.get("stage"))
            if len(iso_lang_code) != 2 or stage < 3:
                continue
            else:
                index.append(
                    {
                        "filename": f"udhr_{ele.get('f')}.txt",
                        "lang": iso_lang_code,
                        "lang_name": ele.get("n"),
                    }
                )
        # get set of all available langs, so users can filter on it
        self.langs = {item["lang"] for item in index}
        return index
def _load_and_parse_index ( self ) -> List [ Dict [ str , Any ] ] : index = [ ] tree = xml . etree . ElementTree . parse ( self . _index_filepath ) root = tree . getroot ( ) for ele in root . iterfind ( "udhr" ) : iso_lang_code = ele . get ( "bcp47" , "" ) . split ( "-" , 1 ) [ 0 ] stage = int ( ele . get ( "stage" ) ) if len ( iso_lang_code ) != 2 or stage < 3 : continue else : index . append ( { "filename" : f"udhr_{ele.get('f')}.txt" , "lang" : iso_lang_code , "lang_name" : ele . get ( "n" ) , } ) # get set of all available langs, so users can filter on it self . langs = { item [ "lang" ] for item in index } return index