Skip to content

Commit a45423d

Browse files
committed
Major code cleanup, full PEP8 compliance, replace %-formatting with .format()
All changes: - import the print function - replace the %-formatting with .format() - full PEP8 compliance - fix problem when latest string in file has a plural form (this last translation was ignored) - use codecs module to unescape strings (faster with python 3) - display full exception in case of problem when reading file - add short option synonym '-P' for '--pwl' - add short option synonym '-e' for '--extract' - rename some long names for command line options: --compile --> --no-compile --lines --> --no-lines --punct --> --no-punct --whitespace --> --no-whitespace --onlymisspelled --> --only-misspelled - major code cleanup: add comments, move checking/error functions from class PoMessage to class PoFile
1 parent 09137b4 commit a45423d

File tree

2 files changed

+374
-271
lines changed

2 files changed

+374
-271
lines changed

README.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* punctuation at end of string
1111
* spelling
1212

13-
The script can run with either Python 2.x or 3.x.
13+
The script requires Python >= 2.7.
1414

1515
Module `python-enchant` is required if spelling is checked (option `-s`).
1616

@@ -23,24 +23,29 @@ Syntax:
2323
Options:
2424

2525
* `-h`, `--help`: display help message and exit
26-
* `-c`, `--compile`: do not check compilation of file (with `msgfmt -c`)
27-
* `-f`, `--fuzzy`: check fuzzy strings (default: ignored)
28-
* `-l`, `--lines`: do not check number of lines
29-
* `-p`, `--punct`: do not check punctuation at end of string
26+
* `-c`, `--no-compile`: do not check compilation of file (with `msgfmt -c`)
27+
* `-f`, `--fuzzy`: check fuzzy strings
28+
* `-l`, `--no-lines`: do not check number of lines
29+
* `-p`, `--no-punct`: do not check punctuation at end of strings
3030
* `-s`, `--spelling`: check spelling
3131
* `-d <dicts>`, `--dicts <dicts>`: comma-separated list of extra dictionaries
3232
to use (in addition to file language)
33-
* `--pwl <file>`: file with personal word list used when checking spelling
34-
* `-m`, `--onlymisspelled`: display only misspelled words (no error, line number
35-
and translation)
36-
* `-w`, `--whitespace`: do not check whitespace at beginning/end of string
37-
* `--extract`: display all translations and exit (all checks except compilation
38-
are disabled in this mode)
33+
* `-P <file>`, `--pwl <file>`: file with personal word list used when checking
34+
spelling
35+
* `-m`, `--only-misspelled`: display only misspelled words (no error, line
36+
number and translation)
37+
* `-w`, `--no-whitespace`: do not check whitespace at beginning/end of strings
38+
* `-e`, `--extract`: display all translations and exit (all checks except
39+
compilation are disabled in this mode)
3940
* `-q`, `--quiet`: quiet mode: only display number of errors
4041
* `-v`, `--version`: display version and exit
4142

4243
Environment variable 'MSGCHECK_OPTIONS' can be set with some default options.
4344

45+
The script returns following exit code:
46+
0: all files checked are OK (0 errors) (or --extract given)
47+
n: number of files with errors (n >= 1)
48+
4449
## Example
4550

4651
$ python msgcheck.py fr.po

0 commit comments

Comments
 (0)