()
CREATE README.md AND LOCALE.md TRANSLATION TABLES
CREATE README.md AND LOCALE.md TRANSLATION TABLES
CREATE README . md AND LOCALE . md TRANSLATION TABLES
def create_readme_locale_tables():
    """ CREATE README.md AND LOCALE.md TRANSLATION TABLES """
    #% README TABLE: README.md
    with open(os.path.join(TABLES_DIR, 'README.md'), "w") as language_table_file:
        #% README TABLE HEAD
        reamde_thead_class2name = collections.OrderedDict()
        reamde_thead_class2name["language"] = "Language"
        reamde_thead_class2name["localeid"] = "ID"
        reamde_thead_class2name["status"] = "Status"
        reamde_thead_class2name["untranslated"] = "Untranslated"
        language_table_file.write(get_table_head(reamde_thead_class2name))

        #% LOCALE TABLE: LOCALE.md
        for locale in sorted(ID2NAME):
            length_sum = 0
            untranslated_sum = 0
            locale_table_file_path = os.path.join(TABLES_DIR, locale + '.md')
            with open(locale_table_file_path, "w") as locale_table_file:
                #% LOCALE TABLE HEAD
                thead_class2name = collections.OrderedDict()
                thead_class2name["uuid"] = "UUID"
                thead_class2name["length"] = "Length"
                thead_class2name["status"] = "Status"
                thead_class2name["untranslated"] = "Untranslated"
                locale_table_file.write(get_table_head(thead_class2name))
                for uuid in sorted(TRANSLATION_LANG_MATRIX[locale]):
                    # LOCALE TABLE CONTENT
                    tdata_class2value = collections.OrderedDict()

                    uuid_pot_length = TRANSLATION_UUID_MATRIX[uuid]["length"]
                    length_sum += uuid_pot_length
                    untranslated_length = TRANSLATION_UUID_MATRIX[uuid][locale]
                    untranslated_sum += untranslated_length


                    tdata_value = uuid
                    tdata_content = str2html_href(uuid + '.md', tdata_value)
                    tdata_class2value["uuid"] = [tdata_value, tdata_content]

                    tdata_value = str(uuid_pot_length)
                    if untranslated_length == uuid_pot_length:
                        tdata_content = tdata_value
                    else:
                        github_po_link = (SPICES_REPO_URL + urllib.parse.quote(uuid) + '/files/'
                                          + urllib.parse.quote(uuid) + '/po/' + locale + '.po')
                        tdata_content = str2html_href(github_po_link, tdata_value)
                    tdata_class2value["length"] = [tdata_value, tdata_content]

                    tdata_value = progress(untranslated_length, uuid_pot_length)
                    tdata_content = value2html_progress_image(tdata_value)
                    tdata_class2value["status"] = [tdata_value, tdata_content]

                    tdata_value = str(untranslated_length)
                    if untranslated_length == 0 or untranslated_length == uuid_pot_length:
                        tdata_content = tdata_value
                    else:
                        tdata_content = str2html_href('../po/' + uuid + '/_' + locale + '.po',
                                                      tdata_value)
                    tdata_class2value["untranslated"] = [tdata_value, tdata_content]

                    locale_table_file.write(get_table_content(tdata_class2value))

                # README TABLE CONTENT
                readme_tdata_class2value = collections.OrderedDict()

                readme_tdata_value = ID2NAME[locale]
                readme_tdata_cont = str2html_href(locale + '.md', readme_tdata_value)
                readme_tdata_class2value["language"] = [readme_tdata_value, readme_tdata_cont]

                readme_tdata_value = locale
                readme_tdata_cont = readme_tdata_value
                readme_tdata_class2value["localeid"] = [readme_tdata_value, readme_tdata_cont]

                # LOCALE TABLE FOOT
                locale_table_file.write('  <tfoot>\n')

                tdata_value = 'Overall statistics:'
                tdata_content = '<b>' + tdata_value + '</b>'
                tdata_class2value["uuid"] = [tdata_value, tdata_content]

                tdata_value = str(length_sum)
                tdata_content = '<b>' + tdata_value + '</b>'
                tdata_class2value["length"] = [tdata_value, tdata_content]

                tdata_value = progress(untranslated_sum, length_sum)
                tdata_content = value2html_progress_image(tdata_value)
                tdata_class2value["status"] = [tdata_value, tdata_content]
                readme_tdata_class2value["status"] = [tdata_value, tdata_content]

                tdata_value = str(untranslated_sum)
                tdata_content = '<b>' + tdata_value + '</b>'
                tdata_class2value["untranslated"] = [tdata_value, tdata_content]
                readme_tdata_class2value["untranslated"] = [tdata_value, tdata_value]

                locale_table_file.write(get_table_content(tdata_class2value))
                locale_table_file.write('  </tfoot>\n')
                locale_table_file.write(get_table_close())

            locale_table_file.close()


            #% write README TABLE content (but only if translations for locale exists)
            if length_sum == untranslated_sum:
                try:
                    os.remove(locale_table_file_path)
                except OSError:
                    pass
            else:
                language_table_file.write(get_table_content(readme_tdata_class2value))

        #% README TABLE close
        language_table_file.write(get_table_body_close())
        language_table_file.write(get_table_close())
    language_table_file.close()
def create_readme_locale_tables ( ) : #% README TABLE: README.md with open ( os . path . join ( TABLES_DIR , 'README.md' ) , "w" ) as language_table_file : #% README TABLE HEAD reamde_thead_class2name = collections . OrderedDict ( ) reamde_thead_class2name [ "language" ] = "Language" reamde_thead_class2name [ "localeid" ] = "ID" reamde_thead_class2name [ "status" ] = "Status" reamde_thead_class2name [ "untranslated" ] = "Untranslated" language_table_file . write ( get_table_head ( reamde_thead_class2name ) ) #% LOCALE TABLE: LOCALE.md for locale in sorted ( ID2NAME ) : length_sum = 0 untranslated_sum = 0 locale_table_file_path = os . path . join ( TABLES_DIR , locale + '.md' ) with open ( locale_table_file_path , "w" ) as locale_table_file : #% LOCALE TABLE HEAD thead_class2name = collections . OrderedDict ( ) thead_class2name [ "uuid" ] = "UUID" thead_class2name [ "length" ] = "Length" thead_class2name [ "status" ] = "Status" thead_class2name [ "untranslated" ] = "Untranslated" locale_table_file . write ( get_table_head ( thead_class2name ) ) for uuid in sorted ( TRANSLATION_LANG_MATRIX [ locale ] ) : # LOCALE TABLE CONTENT tdata_class2value = collections . OrderedDict ( ) uuid_pot_length = TRANSLATION_UUID_MATRIX [ uuid ] [ "length" ] length_sum += uuid_pot_length untranslated_length = TRANSLATION_UUID_MATRIX [ uuid ] [ locale ] untranslated_sum += untranslated_length tdata_value = uuid tdata_content = str2html_href ( uuid + '.md' , tdata_value ) tdata_class2value [ "uuid" ] = [ tdata_value , tdata_content ] tdata_value = str ( uuid_pot_length ) if untranslated_length == uuid_pot_length : tdata_content = tdata_value else : github_po_link = ( SPICES_REPO_URL + urllib . parse . quote ( uuid ) + '/files/' + urllib . parse . quote ( uuid ) + '/po/' + locale + '.po' ) tdata_content = str2html_href ( github_po_link , tdata_value ) tdata_class2value [ "length" ] = [ tdata_value , tdata_content ] tdata_value = progress ( untranslated_length , uuid_pot_length ) tdata_content = value2html_progress_image ( tdata_value ) tdata_class2value [ "status" ] = [ tdata_value , tdata_content ] tdata_value = str ( untranslated_length ) if untranslated_length == 0 or untranslated_length == uuid_pot_length : tdata_content = tdata_value else : tdata_content = str2html_href ( '../po/' + uuid + '/_' + locale + '.po' , tdata_value ) tdata_class2value [ "untranslated" ] = [ tdata_value , tdata_content ] locale_table_file . write ( get_table_content ( tdata_class2value ) ) # README TABLE CONTENT readme_tdata_class2value = collections . OrderedDict ( ) readme_tdata_value = ID2NAME [ locale ] readme_tdata_cont = str2html_href ( locale + '.md' , readme_tdata_value ) readme_tdata_class2value [ "language" ] = [ readme_tdata_value , readme_tdata_cont ] readme_tdata_value = locale readme_tdata_cont = readme_tdata_value readme_tdata_class2value [ "localeid" ] = [ readme_tdata_value , readme_tdata_cont ] # LOCALE TABLE FOOT locale_table_file . write ( '  <tfoot>\n' ) tdata_value = 'Overall statistics:' tdata_content = '<b>' + tdata_value + '</b>' tdata_class2value [ "uuid" ] = [ tdata_value , tdata_content ] tdata_value = str ( length_sum ) tdata_content = '<b>' + tdata_value + '</b>' tdata_class2value [ "length" ] = [ tdata_value , tdata_content ] tdata_value = progress ( untranslated_sum , length_sum ) tdata_content = value2html_progress_image ( tdata_value ) tdata_class2value [ "status" ] = [ tdata_value , tdata_content ] readme_tdata_class2value [ "status" ] = [ tdata_value , tdata_content ] tdata_value = str ( untranslated_sum ) tdata_content = '<b>' + tdata_value + '</b>' tdata_class2value [ "untranslated" ] = [ tdata_value , tdata_content ] readme_tdata_class2value [ "untranslated" ] = [ tdata_value , tdata_value ] locale_table_file . write ( get_table_content ( tdata_class2value ) ) locale_table_file . write ( '  </tfoot>\n' ) locale_table_file . write ( get_table_close ( ) ) locale_table_file . close ( ) #% write README TABLE content (but only if translations for locale exists) if length_sum == untranslated_sum : try : os . remove ( locale_table_file_path ) except OSError : pass else : language_table_file . write ( get_table_content ( readme_tdata_class2value ) ) #% README TABLE close language_table_file . write ( get_table_body_close ( ) ) language_table_file . write ( get_table_close ( ) ) language_table_file . close ( )