Permalink
Browse files

PEP8: E501 line too long

* translate/lang/*.py
  • Loading branch information...
1 parent 4a30995 commit 8c2369d37cb0dfc11670aa417cd397d68dca739b @dwaynebailey dwaynebailey committed Apr 15, 2012
View
@@ -36,13 +36,15 @@ class af(common.Common):
punctuation = u"".join([common.Common.commonpunc, common.Common.quotes,
common.Common.miscpunc])
sentenceend = u".!?…"
- sentencere = re.compile(r"""(?s) #make . also match newlines
- .*? #anything, but match non-greedy
- [%s] #the puntuation for sentence ending
- \s+ #the spacing after the puntuation
- (?='n\s[A-Z]|[^'a-z\d]|'[^n])
- #lookahead that next part starts with caps or 'n followed by caps
- """ % sentenceend, re.VERBOSE)
+ sentencere = re.compile(r"""
+ (?s) # make . also match newlines
+ .*? # anything, but match non-greedy
+ [%s] # the puntuation for sentence ending
+ \s+ # the spacing after the puntuation
+ (?='n\s[A-Z]|[^'a-z\d]|'[^n])
+ # lookahead that next part starts with caps or 'n followed by caps
+ """ % sentenceend, re.VERBOSE
+ )
def capsstart(cls, text):
"""Modify this for the indefinite article ('n)."""
@@ -150,12 +150,14 @@ class Common(object):
#what works, see test_common.py. We try to ignore abbreviations, for
#example, by checking that the following sentence doesn't start with lower
#case or numbers.
- sentencere = re.compile(ur"""(?s) #make . also match newlines
- .*? #anything, but match non-greedy
- [%s] #the puntuation for sentence ending
- \s+ #the spacing after the puntuation
- (?=[^a-zа-џ\d])#lookahead that next part starts with caps
- """ % sentenceend, re.VERBOSE | re.UNICODE)
+ sentencere = re.compile(ur"""
+ (?s) # make . also match newlines
+ .*? # anything, but match non-greedy
+ [%s] # the puntuation for sentence ending
+ \s+ # the spacing after the puntuation
+ (?=[^a-zа-џ\d]) # lookahead that next part starts with caps
+ """ % sentenceend, re.VERBOSE | re.UNICODE
+ )
puncdict = {}
"""A dictionary of punctuation transformation rules that can be used by
@@ -196,11 +198,13 @@ def __new__(cls, code):
while code:
langdata = data.languages.get(code, None)
if langdata:
- language.fullname, language.nplurals, language.pluralequation = langdata
+ language.fullname, language.nplurals, \
+ language.pluralequation = langdata
break
code = data.simplercode(code)
if not code:
-# print >> sys.stderr, "Warning: No information found about language code %s" % code
+ #print >> sys.stderr, \
+ # "Warning: No information found about language code %s" % code
pass
return language
@@ -237,7 +241,8 @@ def punctranslate(cls, text):
# As a simple improvement for messages ending in ellipses (...), we
# test that the last character is different from the second last
# This is only relevant if the string has two characters or more
- if (text[-1] + u" " in cls.puncdict) and (len(text) < 2 or text[-2] != text[-1]):
+ if ((text[-1] + u" " in cls.puncdict) and
+ (len(text) < 2 or text[-2] != text[-1])):
text = text[:-1] + cls.puncdict[text[-1] + u" "].rstrip()
return text
punctranslate = classmethod(punctranslate)
View
@@ -26,21 +26,25 @@
'ak': (u'Akan', 2, 'n > 1'),
'am': (u'Amharic', 2, 'n > 1'),
'an': (u'Aragonese', 2, '(n != 1)'),
-'ar': (u'Arabic', 6, 'n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 && n%100<=10 ? 3 : n%100>=11 ? 4 : 5'),
+'ar': (u'Arabic', 6,
+ 'n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 && n%100<=10 ? 3 : n%100>=11 ? 4 : 5'),
'arn': (u'Mapudungun; Mapuche', 2, 'n > 1'),
'ast': (u'Asturian; Bable; Leonese; Asturleonese', 2, '(n != 1)'),
'az': (u'Azerbaijani', 2, '(n != 1)'),
-'be': (u'Belarusian', 3, 'n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2'),
+'be': (u'Belarusian', 3,
+ 'n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2'),
'bg': (u'Bulgarian', 2, '(n != 1)'),
'bn': (u'Bengali', 2, '(n != 1)'),
'bn_IN': (u'Bengali (India)', 2, '(n != 1)'),
'bo': (u'Tibetan', 1, '0'),
'br': (u'Breton', 2, 'n > 1'),
-'bs': (u'Bosnian', 3, 'n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2'),
+'bs': (u'Bosnian', 3,
+ 'n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2'),
'ca': (u'Catalan; Valencian', 2, '(n != 1)'),
'ca@valencia': (u'Catalan; Valencian (Valencia)', 2, '(n != 1)'),
'cs': (u'Czech', 3, '(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2'),
-'csb': (u'Kashubian', 3, 'n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2'),
+'csb': (u'Kashubian', 3,
+ 'n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2'),
'cy': (u'Welsh', 2, '(n==2) ? 1 : 0'),
'da': (u'Danish', 2, '(n != 1)'),
'de': (u'German', 2, '(n != 1)'),
@@ -99,7 +103,8 @@
'mn': (u'Mongolian', 2, '(n != 1)'),
'mr': (u'Marathi', 2, '(n != 1)'),
'ms': (u'Malay', 1, '0'),
-'mt': (u'Maltese', 4, '(n==1 ? 0 : n==0 || ( n%100>1 && n%100<11) ? 1 : (n%100>10 && n%100<20 ) ? 2 : 3)'),
+'mt': (u'Maltese', 4,
+ '(n==1 ? 0 : n==0 || ( n%100>1 && n%100<11) ? 1 : (n%100>10 && n%100<20 ) ? 2 : 3)'),
'nah': (u'Nahuatl languages', 2, '(n != 1)'),
'nap': (u'Neapolitan', 2, '(n != 1)'),
'nb': (u'Bokmål, Norwegian; Norwegian Bokmål', 2, '(n != 1)'),
@@ -111,22 +116,25 @@
'or': (u'Oriya', 2, '(n != 1)'),
'pa': (u'Panjabi; Punjabi', 2, '(n != 1)'),
'pap': (u'Papiamento', 2, '(n != 1)'),
-'pl': (u'Polish', 3, '(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)'),
+'pl': (u'Polish', 3,
+ '(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)'),
'pms': (u'Piemontese', 2, '(n != 1)'),
'ps': (u'Pushto; Pashto', 2, '(n != 1)'),
'pt': (u'Portuguese', 2, '(n != 1)'),
'pt_BR': (u'Portuguese (Brazil)', 2, '(n != 1)'),
'rm': (u'Romansh', 2, '(n != 1)'),
'ro': (u'Romanian', 3, '(n==1 ? 0 : (n==0 || (n%100 > 0 && n%100 < 20)) ? 1 : 2);'),
-'ru': (u'Russian', 3, '(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)'),
+'ru': (u'Russian', 3,
+ '(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)'),
'sco': (u'Scots', 2, '(n != 1)'),
'si': (u'Sinhala; Sinhalese', 2, '(n != 1)'),
'sk': (u'Slovak', 3, '(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2'),
'sl': (u'Slovenian', 4, '(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3)'),
'so': (u'Somali', 2, '(n != 1)'),
'son': (u'Songhai languages', 2, '(n != 1)'),
'sq': (u'Albanian', 2, '(n != 1)'),
-'sr': (u'Serbian', 3, '(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)'),
+'sr': (u'Serbian', 3,
+ '(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)'),
'st': (u'Sotho, Southern', 2, '(n != 1)'),
'su': (u'Sundanese', 1, '0'),
'sv': (u'Swedish', 2, '(n != 1)'),
@@ -140,7 +148,8 @@
'tr': (u'Turkish', 1, '0'),
'tt': (u'Tatar', 1, '0'),
'ug': (u'Uighur; Uyghur', 1, '0'),
-'uk': (u'Ukrainian', 3, '(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)'),
+'uk': (u'Ukrainian', 3,
+ '(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)'),
'vi': (u'Vietnamese', 1, '0'),
'wa': (u'Walloon', 2, '(n > 1)'),
'yo': (u'Yoruba', 2, '(n != 1)'),
@@ -153,40 +162,41 @@
'zu': (u'Zulu', 2, '(n != 1)'),
}
"""Dictionary of language data.
-The language code is the dictionary key (which may contain country codes and modifiers).
-The value is a tuple: (Full name in English from iso-codes, nplurals, plural equation).
+The language code is the dictionary key (which may contain country codes
+and modifiers). The value is a tuple: (Full name in English from iso-codes,
+nplurals, plural equation).
Note that the English names should not be used in user facing places - it
should always be passed through the function returned from tr_lang(), or at
least passed through _fix_language_name()."""
_fixed_names = {
- u"Asturian; Bable; Leonese; Asturleonese": u"Asturian",
- u"Bokmål, Norwegian; Norwegian Bokmål": u"Norwegian Bokmål",
- u"Catalan; Valencian": u"Catalan",
- u"Central Khmer": u"Khmer",
- u"Chichewa; Chewa; Nyanja": u"Chewa; Nyanja",
- u"Divehi; Dhivehi; Maldivian": u"Divehi",
- u"Dutch; Flemish": u"Dutch",
- u"Filipino; Pilipino": u"Filipino",
- u"Gaelic; Scottish Gaelic": u"Scottish Gaelic",
- u"Greek, Modern (1453-)": u"Greek",
- u"Interlingua (International Auxiliary Language Association)": u"Interlingua",
- u"Kirghiz; Kyrgyz": u"Kirghiz",
- u"Klingon; tlhIngan-Hol": u"Klingon",
- u"Limburgan; Limburger; Limburgish": u"Limburgish",
- u"Low German; Low Saxon; German, Low; Saxon, Low": u"Low German",
- u"Luxembourgish; Letzeburgesch": u"Luxembourgish",
- u"Ndebele, South; South Ndebele": u"Southern Ndebele",
- u"Norwegian Nynorsk; Nynorsk, Norwegian": u"Norwegian Nynorsk",
- u"Occitan (post 1500)": u"Occitan",
- u"Panjabi; Punjabi": u"Punjabi",
- u"Pedi; Sepedi; Northern Sotho": u"Northern Sotho",
- u"Pushto; Pashto": u"Pashto",
- u"Sinhala; Sinhalese": u"Sinhala",
- u"Sotho, Southern": u"Sotho",
- u"Spanish; Castilian": u"Spanish",
- u"Uighur; Uyghur": u"Uighur",
+ u"Asturian; Bable; Leonese; Asturleonese": u"Asturian",
+ u"Bokmål, Norwegian; Norwegian Bokmål": u"Norwegian Bokmål",
+ u"Catalan; Valencian": u"Catalan",
+ u"Central Khmer": u"Khmer",
+ u"Chichewa; Chewa; Nyanja": u"Chewa; Nyanja",
+ u"Divehi; Dhivehi; Maldivian": u"Divehi",
+ u"Dutch; Flemish": u"Dutch",
+ u"Filipino; Pilipino": u"Filipino",
+ u"Gaelic; Scottish Gaelic": u"Scottish Gaelic",
+ u"Greek, Modern (1453-)": u"Greek",
+ u"Interlingua (International Auxiliary Language Association)": u"Interlingua",
+ u"Kirghiz; Kyrgyz": u"Kirghiz",
+ u"Klingon; tlhIngan-Hol": u"Klingon",
+ u"Limburgan; Limburger; Limburgish": u"Limburgish",
+ u"Low German; Low Saxon; German, Low; Saxon, Low": u"Low German",
+ u"Luxembourgish; Letzeburgesch": u"Luxembourgish",
+ u"Ndebele, South; South Ndebele": u"Southern Ndebele",
+ u"Norwegian Nynorsk; Nynorsk, Norwegian": u"Norwegian Nynorsk",
+ u"Occitan (post 1500)": u"Occitan",
+ u"Panjabi; Punjabi": u"Punjabi",
+ u"Pedi; Sepedi; Northern Sotho": u"Northern Sotho",
+ u"Pushto; Pashto": u"Pashto",
+ u"Sinhala; Sinhalese": u"Sinhala",
+ u"Sotho, Southern": u"Sotho",
+ u"Spanish; Castilian": u"Spanish",
+ u"Uighur; Uyghur": u"Uighur",
}
@@ -231,7 +241,8 @@ def simplercode(code):
"""ISO 3166 country codes"""
langcode_re = re.compile("^[a-z]{2,3}([_-][A-Z]{2,3}|)(@[a-zA-Z0-9]+|)$")
-langcode_ire = re.compile("^[a-z]{2,3}([_-][a-z]{2,3})?(@[a-z0-9]+)?$", re.IGNORECASE)
+langcode_ire = re.compile("^[a-z]{2,3}([_-][a-z]{2,3})?(@[a-z0-9]+)?$",
+ re.IGNORECASE)
variant_re = re.compile("^[_-][A-Z]{2,3}(@[a-zA-Z0-9]+|)$")
@@ -240,24 +251,27 @@ def languagematch(languagecode, otherlanguagecode):
if languagecode is None:
return langcode_re.match(otherlanguagecode)
return languagecode == otherlanguagecode or \
- (otherlanguagecode.startswith(languagecode) and variant_re.match(otherlanguagecode[len(languagecode):]))
+ (otherlanguagecode.startswith(languagecode) and \
+ variant_re.match(otherlanguagecode[len(languagecode):]))
dialect_name_re = re.compile(r"(.+)\s\(([^)\d]{,25})\)$")
# The limit of 25 characters on the country name is so that "Interlingua (...)"
# (see above) is correctly interpreted.
def tr_lang(langcode=None):
- """Gives a function that can translate a language name, even in the form ``"language (country)"``,
- into the language with iso code langcode, or the system language if no language is specified."""
+ """Gives a function that can translate a language name, even in the
+ form ``"language (country)"``, into the language with iso code langcode,
+ or the system language if no language is specified."""
langfunc = gettext_lang(langcode)
countryfunc = gettext_country(langcode)
def handlelanguage(name):
match = dialect_name_re.match(name)
if match:
language, country = match.groups()
- return u"%s (%s)" % (_fix_language_name(langfunc(language)), countryfunc(country))
+ return u"%s (%s)" % (_fix_language_name(langfunc(language)),
+ countryfunc(country))
else:
return _fix_language_name(langfunc(name))
@@ -290,11 +304,14 @@ def gettext_lang(langcode=None):
langcode = ""
if os.name == "nt":
# On Windows the default locale is not used for some reason
- t = gettext.translation('iso_639', languages=[locale.getdefaultlocale()[0]], fallback=True)
+ t = gettext.translation('iso_639',
+ languages=[locale.getdefaultlocale()[0]],
+ fallback=True)
else:
t = gettext.translation('iso_639', fallback=True)
else:
- t = gettext.translation('iso_639', languages=[langcode], fallback=True)
+ t = gettext.translation('iso_639', languages=[langcode],
+ fallback=True)
iso639[langcode] = t.ugettext
return iso639[langcode]
@@ -307,11 +324,14 @@ def gettext_country(langcode=None):
langcode = ""
if os.name == "nt":
# On Windows the default locale is not used for some reason
- t = gettext.translation('iso_3166', languages=[locale.getdefaultlocale()[0]], fallback=True)
+ t = gettext.translation('iso_3166',
+ languages=[locale.getdefaultlocale()[0]],
+ fallback=True)
else:
t = gettext.translation('iso_3166', fallback=True)
else:
- t = gettext.translation('iso_3166', languages=[langcode], fallback=True)
+ t = gettext.translation('iso_3166', languages=[langcode],
+ fallback=True)
iso3166[langcode] = t.ugettext
return iso3166[langcode]
@@ -365,7 +385,9 @@ def simplify_to_common(language_code, languages=languages):
language, stripping country information for languages that tend
not to be localized differently for different countries"""
simpler = simplercode(language_code)
- if normalize_code(language_code) in [normalize_code(key) for key in languages.keys()] or simpler == "":
+ if (normalize_code(language_code) in
+ [normalize_code(key) for key in languages.keys()] or
+ simpler == ""):
return language_code
else:
return simplify_to_common(simpler)
View
@@ -34,12 +34,14 @@ class el(common.Common):
# Greek uses ; as question mark and the middot instead
sentenceend = u".!;…"
- sentencere = re.compile(ur"""(?s) #make . also match newlines
- .*? #anything, but match non-greedy
- [%s] #the puntuation for sentence ending
- \s+ #the spacing after the puntuation
- (?=[^a-zά-ώ\d])#lookahead that next part starts with caps
- """ % sentenceend, re.VERBOSE | re.UNICODE)
+ sentencere = re.compile(ur"""
+ (?s) # make . also match newlines
+ .*? # anything, but match non-greedy
+ [%s] # the puntuation for sentence ending
+ \s+ # the spacing after the puntuation
+ (?=[^a-zά-ώ\d]) # lookahead that next part starts with caps
+ """ % sentenceend, re.VERBOSE | re.UNICODE
+ )
puncdict = {
u"?": u";",
@@ -40,7 +40,8 @@ def getlanguage(code):
internal_code = prefix + code
else:
internal_code = code
- module = __import__("translate.lang.%s" % internal_code, globals(), {}, internal_code)
+ module = __import__("translate.lang.%s" % internal_code, globals(), {},
+ internal_code)
langclass = getattr(module, internal_code)
return langclass(code)
except ImportError, e:
View
@@ -38,12 +38,15 @@ class hy(common.Common):
sentenceend = u"։՝՜…"
- sentencere = re.compile(ur"""(?s) #make . also match newlines
- .*? #anything, but match non-greedy
- [%s] #the puntuation for sentence ending
- \s+ #the spacing after the puntuation
- (?=[^a-zա-ֆ\d])#lookahead that next part starts with caps
- """ % sentenceend, re.VERBOSE | re.UNICODE)
+ sentencere = re.compile(ur"""
+ (?s) # make . also match newlines
+ .*? # anything, but match non-greedy
+ [%s] # the puntuation for sentence ending
+ \s+ # the spacing after the puntuation
+ (?=[^a-zա-ֆ\d]) # lookahead that next part starts with caps
+ """ % sentenceend, re.VERBOSE | re.UNICODE
+ )
+
puncdict = {
u".": u"։",
u":": u"՝",
@@ -65,7 +65,8 @@ def _load_config(self, conf_file):
continue # Skip comment- and empty lines
lname, lcode = parts[0], parts[1]
- lname = path.split(lname)[-1] # Make sure lname is not prefixed by directory names
+ # Make sure lname is not prefixed by directory names
+ lname = path.split(lname)[-1]
if extsep in lname:
lname = lname[:lname.rindex(extsep)] # Remove extension if it has
@@ -20,7 +20,8 @@
"""Functions to manage Poedit's language features.
-ISO 639 maps are from Poedit's `isocode.cpp 1.4.2 <http://poedit.svn.sourceforge.net/viewvc/poedit/poedit/tags/release-1.4.2/src/isocodes.cpp?revision=1452&view=markup>`_
+ISO 639 maps are from Poedit's
+`isocode.cpp 1.4.2 <http://poedit.svn.sourceforge.net/viewvc/poedit/poedit/tags/release-1.4.2/src/isocodes.cpp?revision=1452&view=markup>`_
to ensure that we match currently released versions of Poedit.
"""
@@ -200,11 +201,16 @@
dialects = {
"Portuguese": {"PORTUGAL": "pt", "BRAZIL": "pt_BR", "None": "pt"},
# We choose not to subtype en_US
- "English": {"UNITED KINGDOM": "en_GB", "SOUTH AFRICA": "en_ZA", "None": "en"},
+ "English": {
+ "UNITED KINGDOM": "en_GB",
+ "SOUTH AFRICA": "en_ZA",
+ "None": "en",
+ },
# zh_CN = Simplified, zh_TW = Traditional
"Chinese": {"CHINA": "zh_CN", "TAIWAN": "zh_TW", "None": "zh_CN"},
}
-"""Language dialects based on ISO 3166 country names, 'None' is the default fallback"""
+"""Language dialects based on ISO 3166 country names, 'None' is the
+default fallback"""
def isocode(language, country=None):

0 comments on commit 8c2369d

Please sign in to comment.