home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_1383 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  6.0 KB  |  198 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. __license__ = 'GPL v3'
  5. __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
  6. import shutil
  7. import tarfile
  8. import re
  9. import os
  10. import subprocess
  11. import urllib2
  12. language_codes = {
  13.     'aa': 'Afar',
  14.     'ab': 'Abkhazian',
  15.     'af': 'Afrikaans',
  16.     'am': 'Amharic',
  17.     'ar': 'Arabic',
  18.     'as': 'Assamese',
  19.     'ay': 'Aymara',
  20.     'az': 'Azerbaijani',
  21.     'ba': 'Bashkir',
  22.     'be': 'Byelorussian',
  23.     'bg': 'Bulgarian',
  24.     'bh': 'Bihari',
  25.     'bi': 'Bislama',
  26.     'bn': 'Bengali',
  27.     'bo': 'Tibetan',
  28.     'br': 'Breton',
  29.     'ca': 'Catalan',
  30.     'co': 'Corsican',
  31.     'cs': 'Czech',
  32.     'cy': 'Welsh',
  33.     'da': 'Danish',
  34.     'de': 'German',
  35.     'dz': 'Bhutani',
  36.     'el': 'Greek',
  37.     'en': 'English',
  38.     'eo': 'Esperanto',
  39.     'es': 'Spanish',
  40.     'et': 'Estonian',
  41.     'eu': 'Basque',
  42.     'fa': 'Persian',
  43.     'fi': 'Finnish',
  44.     'fj': 'Fiji',
  45.     'fo': 'Faroese',
  46.     'fr': 'French',
  47.     'fy': 'Frisian',
  48.     'ga': 'Irish',
  49.     'gd': 'Scots Gaelic',
  50.     'gl': 'Galician',
  51.     'gn': 'Guarani',
  52.     'gu': 'Gujarati',
  53.     'ha': 'Hausa',
  54.     'he': 'Hebrew',
  55.     'hi': 'Hindi',
  56.     'hr': 'Croatian',
  57.     'hu': 'Hungarian',
  58.     'hy': 'Armenian',
  59.     'ia': 'Interlingua',
  60.     'id': 'Indonesian',
  61.     'ie': 'Interlingue',
  62.     'ik': 'Inupiak',
  63.     'is': 'Icelandic',
  64.     'it': 'Italian',
  65.     'iu': 'Inuktitut',
  66.     'ja': 'Japanese',
  67.     'jw': 'Javanese',
  68.     'ka': 'Georgian',
  69.     'kk': 'Kazakh',
  70.     'kl': 'Greenlandic',
  71.     'km': 'Cambodian',
  72.     'kn': 'Kannada',
  73.     'ko': 'Korean',
  74.     'ks': 'Kashmiri',
  75.     'ku': 'Kurdish',
  76.     'ky': 'Kirghiz',
  77.     'la': 'Latin',
  78.     'ln': 'Lingala',
  79.     'lo': 'Laothian',
  80.     'lt': 'Lithuanian',
  81.     'lv': 'Latvian, Lettish',
  82.     'mg': 'Malagasy',
  83.     'mi': 'Maori',
  84.     'mk': 'Macedonian',
  85.     'ml': 'Malayalam',
  86.     'mn': 'Mongolian',
  87.     'mo': 'Moldavian',
  88.     'mr': 'Marathi',
  89.     'ms': 'Malay',
  90.     'mt': 'Maltese',
  91.     'my': 'Burmese',
  92.     'na': 'Nauru',
  93.     'nb': 'Norwegian Bokmal',
  94.     'nds': 'German,Low',
  95.     'ne': 'Nepali',
  96.     'nl': 'Dutch',
  97.     'no': 'Norwegian',
  98.     'oc': 'Occitan',
  99.     'om': '(Afan) Oromo',
  100.     'or': 'Oriya',
  101.     'pa': 'Punjabi',
  102.     'pl': 'Polish',
  103.     'ps': 'Pashto, Pushto',
  104.     'pt': 'Portuguese',
  105.     'qu': 'Quechua',
  106.     'rm': 'Rhaeto-Romance',
  107.     'rn': 'Kirundi',
  108.     'ro': 'Romanian',
  109.     'ru': 'Russian',
  110.     'rw': 'Kinyarwanda',
  111.     'sa': 'Sanskrit',
  112.     'sd': 'Sindhi',
  113.     'sg': 'Sangho',
  114.     'sh': 'Serbo-Croatian',
  115.     'si': 'Sinhalese',
  116.     'sk': 'Slovak',
  117.     'sl': 'Slovenian',
  118.     'sm': 'Samoan',
  119.     'sn': 'Shona',
  120.     'so': 'Somali',
  121.     'sq': 'Albanian',
  122.     'sr': 'Serbian',
  123.     'ss': 'Siswati',
  124.     'st': 'Sesotho',
  125.     'su': 'Sundanese',
  126.     'sv': 'Swedish',
  127.     'sw': 'Swahili',
  128.     'ta': 'Tamil',
  129.     'te': 'Telugu',
  130.     'tg': 'Tajik',
  131.     'th': 'Thai',
  132.     'ti': 'Tigrinya',
  133.     'tk': 'Turkmen',
  134.     'tl': 'Tagalog',
  135.     'tn': 'Setswana',
  136.     'to': 'Tonga',
  137.     'tr': 'Turkish',
  138.     'ts': 'Tsonga',
  139.     'tt': 'Tatar',
  140.     'tw': 'Twi',
  141.     'ug': 'Uighur',
  142.     'uk': 'Ukrainian',
  143.     'ur': 'Urdu',
  144.     'uz': 'Uzbek',
  145.     'vi': 'Vietnamese',
  146.     'vo': 'Volapuk',
  147.     'wo': 'Wolof',
  148.     'xh': 'Xhosa',
  149.     'yi': 'Yiddish',
  150.     'yo': 'Yoruba',
  151.     'za': 'Zhuang',
  152.     'zh': 'Chinese',
  153.     'zu': 'Zulu' }
  154.  
  155. def import_from_launchpad(url):
  156.     f = open('/tmp/launchpad_export.tar.gz', 'wb')
  157.     shutil.copyfileobj(urllib2.urlopen(url), f)
  158.     f.close()
  159.     tf = tarfile.open('/tmp/launchpad_export.tar.gz', 'r:gz')
  160.     next = tf.next()
  161.     while next is not None:
  162.         if next.isfile() and next.name.endswith('.po'):
  163.             
  164.             try:
  165.                 po = re.search('-([a-z]{2,3}\\.po)', next.name).group(1)
  166.             except:
  167.                 next = tf.next()
  168.                 continue
  169.  
  170.             out = os.path.abspath(os.path.join('.', os.path.basename(po)))
  171.             print 'Updating', '%6s' % po, '-->', out
  172.             open(out, 'wb').write(tf.extractfile(next).read())
  173.         
  174.         next = tf.next()
  175.     check_for_critical_bugs()
  176.     path = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
  177.     print path
  178.     subprocess.check_call('python setup.py translations'.split(), cwd = path)
  179.     return 0
  180.  
  181.  
  182. def check_for_critical_bugs():
  183.     if os.path.exists('.errors'):
  184.         shutil.rmtree('.errors')
  185.     
  186.     pofilter = ('pofilter', '-i', '.', '-o', '.errors', '-t', 'accelerators', '-t', 'escapes', '-t', 'variables', '-t', 'printf')
  187.     subprocess.check_call(pofilter)
  188.     errs = os.listdir('.errors')
  189.     if errs:
  190.         print 'WARNING: Translation errors detected'
  191.         print 'See the .errors directory and http://translate.sourceforge.net/wiki/toolkit/using_pofilter'
  192.     
  193.  
  194. if __name__ == '__main__':
  195.     import sys
  196.     import_from_launchpad(sys.argv[1])
  197.  
  198.