Commit Graph

10 Commits

Author SHA1 Message Date
Gregory Szorc
5380dea2a7 global: mass rewrite to use modern exception syntax
Python 2.6 introduced the "except type as instance" syntax, replacing
the "except type, instance" syntax that came before. Python 3 dropped
support for the latter syntax. Since we no longer support Python 2.4 or
2.5, we have no need to continue supporting the "except type, instance".

This patch mass rewrites the exception syntax to be Python 2.6+ and
Python 3 compatible.

This patch was produced by running `2to3 -f except -w -n .`.
2015-06-23 22:20:08 -07:00
Jordi Gutiérrez Hermoso
8eb132f5ea style: kill ersatz if-else ternary operators
Although Python supports `X = Y if COND else Z`, this was only
introduced in Python 2.5. Since we have to support Python 2.4, it was
a very common thing to write instead `X = COND and Y or Z`, which is a
bit obscure at a glance. It requires some intricate knowledge of
Python to understand how to parse these one-liners.

We change instead all of these one-liners to 4-liners. This was
executed with the following perlism:

    find -name "*.py" -exec perl -pi -e 's,(\s*)([\.\w]+) = \(?(\S+)\s+and\s+(\S*)\)?\s+or\s+(\S*)$,$1if $3:\n$1    $2 = $4\n$1else:\n$1    $2 = $5,' {} \;

I tweaked the following cases from the automatic Perl output:

    prev = (parents and parents[0]) or nullid
    port = (use_ssl and 443 or 80)
    cwd = (pats and repo.getcwd()) or ''
    rename = fctx and webutil.renamelink(fctx) or []
    ctx = fctx and fctx or ctx
    self.base = (mapfile and os.path.dirname(mapfile)) or ''

I also added some newlines wherever they seemd appropriate for readability

There are probably a few ersatz ternary operators still in the code
somewhere, lurking away from the power of a simple regex.
2015-03-13 17:00:06 -04:00
Mads Kiilerich
523c87c1fe spelling: fixes from proofreading of spell checker issues 2014-04-17 22:47:38 +02:00
Mads Kiilerich
3f5dd3e256 codingstyle: remove trailing spaces in various text files
Better do it once than see random changes in diffs later.
2013-04-17 03:40:18 +02:00
Wagner Bruna
78b3f6c991 i18n: import polib 0.6.4 (rev 84598f2b5365)
This version fixes some upstream issues observed during the pt_BR
translation update: #8 (obsolete entries reappearing); an
unidentified issue that made i18n/posplit produce some spurious
messages on the resulting po file; possibly others.

These bugs probably didn't cause actual differences on the translated
output, since an invalid message added to the .mo file wouldn't match
an input message most of the time. But they do pollute the .po file
contents (and diffs), adding some confusion to the translation
process.

2f1d9e562f9c, 9c9fa4e0be7b and fe9ec223d90c were included upstream,
so the only remaining difference is the "no-check-code" marking.
2011-10-17 11:54:12 -02:00
Martin Geisler
74088e23d0 polib: remove unnecessary comparisons with True
Submitted to upstream repository as changeset f11e0b1b37b0.
2010-11-22 17:57:11 +01:00
Dan Villiom Podlaski Christiansen
f385faac7a *: kill all unnecessary shebangs. 2010-10-26 12:18:39 +02:00
Matt Mackall
2c615ad604 i18n: disable check-code on polib.py 2010-06-22 15:44:19 -05:00
Martin Geisler
a8b8a1d541 i18n: patch polib.unescape
Patch submitted to upstream as rev b9174a342092 in

  http://bitbucket.org/mg/polib/
2010-06-19 16:52:25 +02:00
Wagner Bruna
bca08eb78c i18n: import polib 0.5.2 (rev b0ab301cfdcc) 2010-06-17 20:10:34 -03:00