text: # -*- coding: utf-8 -*-
  from __future__ import unicode_literals, print_function
  from django.db import migrations
  
  data = {187: "Blank",
          114: "Proto-Indo-European",
          80: "Hittite",
          133: "Luvian",
          134: "Lycian",
          135: "Palaic",
          81: "Tocharian_A",
          82: "Tocharian_B",
          173: "Mycenaean_Greek",
          110: "Ancient_Greek",
          177: "NT_Greek",
          32: "Greek",
          30: "ZLegacy_Greek_Md",
          28: "ZLegacy_Greek_D",
          210: "Greek_Cappodocian",
          211: "Greek_Pontic",
          195: "Greek_Cypriot",
          31: "ZLegacyGreek_Lesbos",
          29: "ZLegacy_Greek_K",
          201: "Greek_Italiot",
          152: "Tsakonian_Peloponnese",
          188: "Tsakonian_Propontis",
          129: "Classical_Armenian",
          8: "Armenian_Eastern",
          7: "Armenian_Western",
          3: "Albanian_Gheg",
          143: "Albanian_Standard",
          88: "Albanian",
          5: "ZLegacy_Albanian_T",
          6: "Albanian_Tosk",
          4: "Albanian_Corinth",
          2: "Albanian_Sicily",
          105: "Vedic_Sanskrit",
          162: "Pali",
          65: "Sinhalese",
          106: "Assamese",
          10: "Bengali",
          102: "Oriya",
          111: "Maithili",
          144: "Magahi",
          151: "Bhojpuri",
          35: "Hindi",
          119: "Urdu",
          50: "Marathi",
          33: "Gujarati",
          104: "Marwari",
          103: "Sindhi",
          53: "Punjabi",
          43: "Lahnda",
          51: "Nepali",
          41: "ZLegacy_Khaskura",
          40: "Kashmiri",
          34: "Romani_Greece",
          214: "Kamviri",
          141: "Kata-viriEastern",
          154: "Vasi-vari",
          213: "Kata-variKtivi",
          212: "Vasi-variPaski",
          217: "TregamiGambir",
          216: "Kalasa-alaNiseigram",
          215: "Sanu-viriWama",
          153: "Askunu",
          219: "Palula",
          128: "Avestan",
          174: "Khotanese",
          138: "Shughni",
          139: "Sarikoli",
          75: "Wakhi",
          77: "Waziri",
          1: "Pashto",
          136: "Sogdian",
          208: "Yaghnobi",
          52: "Ossetic",
          124: "Ossetic_Iron",
          125: "Ossetic_Digor",
          131: "Old_Persian",
          178: "Middle_Persian",
          54: "Persian",
          72: "Tajik",
          218: "PersianKabul",
          179: "Parthian",
          9: "Baluchi",
          118: "Kurdish",
          137: "Zazaki",
          44: "Latvian",
          190: "Latgalian",
          46: "Lithuanian",
          45: "ZLegacy_Lithuanian_O",
          108: "Old_Prussian",
          100: "Old_Church_Slavonic",
          15: "Bulgarian",
          89: "ZLegacy_BULGARIAN_P",
          92: "Macedonian",
          49: "ZLegacy_Macedonian",
          95: "Serbo-Croatian",
          64: "ZLegacy_Serbocroatian",
          113: "ZLegacy_Serbian",
          97: "Slovenian",
          67: "ZLegacy_Slovenian",
          60: "Russian",
          94: "ZLegacy_RUSSIAN_P",
          16: "Belarusian",
          90: "ZLegacy_BYELORUSSIAN_P",
          73: "Ukrainian",
          98: "ZLegacy_UKRAINIAN_P",
          55: "Polish",
          93: "ZLegacy_POLISH_P",
          175: "Kashubian",
          176: "Polabian",
          66: "Slovak",
          96: "ZLegacy_SLOVAK_P",
          18: "Czech",
          19: "ZLegacy_Czech_E",
          91: "ZLegacy_CZECH_P",
          48: "Sorbian_Upper",
          47: "Sorbian_Lower",
          107: "Gothic",
          109: "Old_Norse",
          36: "Icelandic",
          23: "Faroese",
          58: "Norwegian_Riksmal",
          159: "Stavangersk",
          145: "Elfdalian",
          157: "Old_Swedish",
          69: "Swedish",
          71: "Swedish_Vilhelmina",
          70: "Swedish_Uppland",
          160: "Old_Gutnish",
          161: "Gutnish_Lau",
          20: "Danish",
          158: "Danish_Fjolde",
          126: "Old_High_German",
          27: "German",
          121: "German_Switzerland",
          142: "ZLegacy_German_Munich",
          120: "Luxembourgish",
          86: "Pennsylvania_Dutch",
          21: "Dutch",
          24: "Flemish",
          83: "Afrikaans",
          87: "Sranan",
          26: "Frisian",
          99: "Old_English",
          22: "English",
          112: "Latin",
          59: "Romanian",
          74: "Vlach",
          206: "Aromanian",
          207: "Dalmatian",
          189: "Neapolitan",
          39: "Italian",
          205: "Venetian",
          122: "Friulian",
          42: "Ladin",
          146: "Dolomite_Ladino",
          123: "Romansh",
          61: "Sardinian_Cagliari",
          63: "Sardinian_Nuoro",
          62: "Sardinian_Logudoro",
          209: "Old_French",
          203: "Anglo-Norman",
          25: "French",
          76: "Walloon",
          84: "ZLegacy_French_Creole_C",
          85: "French_Creole_Dominica",
          57: "Provencal",
          17: "Catalan",
          204: "Old_Spanish",
          68: "Spanish",
          56: "Portuguese",
          11: "ZLegacy_Brazilian",
          130: "Oscan",
          132: "Umbrian",
          140: "Gaulish",
          148: "Old_Breton",
          172: "Middle_Breton",
          12: "Breton",
          13: "ZLegacy_Breton_Se",
          14: "ZLegacy_Breton_ST",
          149: "Old_Cornish",
          101: "Middle_Cornish",
          150: "Old_Welsh",
          171: "Middle_Welsh",
          79: "Welsh",
          78: "ZLegacy_Welsh_C",
          127: "Old_Irish",
          115: "Scottish_Gaelic",
          147: "Manx",
          38: "Irish",
          37: "ZLegacy_Irish_A"}
  
  
  def forwards_func(apps, schema_editor):
      '''
      This migration overwrites the originalAsciiName fields
      on the server. This is necessary because defaults
      may well be filled in wrongly bc fields already changed.
      https://github.com/lingdb/CoBL/issues/218
      '''
      Language = apps.get_model('lexicon', 'Language')
      for language in Language.objects.all():
          if language.id in data:
              language.originalAsciiName = data[language.id]
              language.save()
  
  
  def reverse_func(apps, schema_editor):
      print('Nothing to do for reverse_func of '
            '0082_fix_language_originalasciiname')
  
  
  class Migration(migrations.Migration):
  
      dependencies = [('lexicon', '0082_language_fill_originalasciiname')]
  
      operations = [
          migrations.RunPython(forwards_func, reverse_func),
      ]
  