Skip to content

Commit 3f37414

Browse files
committed
Fix PR issues
* Delete unused options * Fix multiline options comments * Replace backup logic in MergeCatalog * Rename to ConcatenateCatalog
1 parent 8568e90 commit 3f37414

1 file changed

Lines changed: 45 additions & 137 deletions

File tree

babel/messages/frontend.py

Lines changed: 45 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -853,94 +853,51 @@ def run(self):
853853
return
854854

855855

856-
class ConcatenationCatalog(CommandMixin):
856+
class ConcatenateCatalog(CommandMixin):
857857
description = 'concatenates and merges the specified PO files'
858858
user_options = [
859859
('input-files', None, 'input files'),
860-
('files-from=', 'f', 'get list of input files from FILE'),
861-
('directory=', 'D', 'add DIRECTORY to list for input files search'
862-
'If input file is -, standard input is read.'),
863860
('output-file=', 'o', 'write output to specified file'),
864861
('less-than=', '<', 'print messages with less than this many'
865-
'definitions, defaults to infinite if not set'),
866-
('more-than=', '>', 'print messages with more than this many'
862+
'definitions, defaults to infinite if not set '),
863+
('more-than=', '>', 'print messages with more than this many '
867864
'definitions, defaults to 0 if not set'),
868-
('unique', 'u', 'shorthand for --less-than=2, requests'
865+
('unique', 'u', 'shorthand for --less-than=2, requests '
869866
'that only unique messages be printed'),
870-
('properties-input', 'P', 'input files are in Java .properties syntax'),
871-
('stringtable-input', None, 'input files are in NeXTstep/GNUstep .strings syntax'),
872-
('to-code=','t', 'encoding for output'),
873-
('use-first', None, 'use first available translation for each'
867+
('use-first', None, 'use first available translation for each '
874868
'message, don\'t merge several translations'),
875-
('lang=', None, 'set \'Language\' field in the header entry'),
876-
('color=', None, 'use colors and other text attributes always'),
877-
('style=', None, 'specify CSS style rule file for --color'),
878-
('no-escape', 'e', 'do not use C escapes in output (default)'),
879-
('escape', 'E', 'use C escapes in output, no extended chars'),
880-
('force-po', None, 'write PO file even if empty'),
881-
('indent', 'i', 'write the .po file using indented style'),
882869
('no-location', None, 'do not write \'#: filename:line\' lines'),
883-
('strict', None, 'write out strict Uniforum conforming .po file'),
884-
('properties-output', None, 'write out a Java .properties file'),
885-
('stringtable-output', None, 'write out a NeXTstep/GNUstep .strings file'),
886870
('width=', 'w', 'set output page width'),
887-
('no-wrap', None, 'do not break long message lines, longer than'
871+
('no-wrap', None, 'do not break long message lines, longer than '
888872
'the output page width, into several lines'),
889873
('sort-output', 's', 'generate sorted output'),
890874
('sort-by-file', 'F', 'sort output by file location'),
891875
]
892876

893-
as_args='input-files'
877+
as_args = 'input-files'
894878

895879
boolean_options = [
896880
'unique',
897-
'properties-input',
898-
'stringtable-input',
899-
'no-escape',
900-
'escape',
901-
'force-po',
902-
'indent',
881+
'use-first',
903882
'no-location',
904883
'strict',
905-
'properties-output',
906-
'stringtable-output',
907884
'no-wrap',
908885
'sort-output',
909886
'sort-by-file',
910887
]
911888

912-
option_choices = {
913-
'color': ('always', 'never', 'auto', 'html'),
914-
}
915-
916889
def initialize_options(self):
917-
self.input_files = None #
918-
self.files_from = None
919-
self.directory = None
920-
self.output_file = None #
921-
self.less_than = None #
922-
self.more_than = 0 #
923-
self.unique = False #
924-
self.properties_input = None
925-
self.stringtable_input = None
926-
self.to_code = None
927-
# the first translation is always used temporarily
928-
self.use_first = False #~
929-
self.lang = None
930-
self.color = None
931-
self.style = None
932-
self.no_escape = None
933-
self.escape = None
934-
self.force_po = None
935-
self.indent = None
936-
self.no_location = None #
937-
self.strict = None
938-
self.properties_output = None
939-
self.stringtable_output = None
940-
self.width = None #
941-
self.no_wrap = None #
942-
self.sort_output = False #
943-
self.sort_by_file = False #
890+
self.input_files = None
891+
self.output_file = None
892+
self.less_than = None
893+
self.more_than = 0
894+
self.unique = False
895+
self.use_first = False
896+
self.no_location = None
897+
self.width = None
898+
self.no_wrap = False
899+
self.sort_output = False
900+
self.sort_by_file = False
944901

945902
def finalize_options(self):
946903
if not self.input_files:
@@ -1020,37 +977,21 @@ def run(self):
1020977

1021978

1022979
class MergeCatalog(CommandMixin):
1023-
description='combines two Uniforum-style PO files into one'
980+
description='updates translation PO file by merging them with updated template POT file with using compendium'
1024981
user_options=[
1025-
('input-files', None, 'def.po ref.pot'),
1026-
('directory=', 'D', 'add DIRECTORY to list for input files search'),
982+
('input-files', None, 'def.po (obsolete translations) ref.pot (actual template)'),
1027983
('compendium=', 'C', 'additional library of message translations, may be specified more than once'),
1028984
('compendium-overwrite', '', 'overwrite mode of compendium'),
1029985
('no-compendium-comment', '', ''),
1030986
('update', 'U', 'pdate def.po, do nothing if def.po already up to date'),
1031-
('output-file=', 'o', 'write output to specified file, the results are written'
987+
('output-file=', 'o', 'write output to specified file, the results are written '
1032988
'to standard output if no output file is specified'),
1033989
('backup', None, 'make a backup of def.po'),
1034990
('suffix=', None, 'override the usual backup suffix'),
1035-
('multi-domain', 'm', 'apply ref.pot to each of the domains in def.po'),
1036-
('for-msgfmt', None, 'produce output for \'msgfmt\', not for a translator'),
1037991
('no-fuzzy-matching', 'N', 'do not use fuzzy matching'),
1038-
('previous', None, 'keep previous msgids of translated messages'),
1039-
('properties-input', 'P', 'input files are in Java .properties syntax'),
1040-
('stringtable-input', None, 'input files are in NeXTstep/GNUstep .strings syntax'),
1041-
('lang=', None, 'set \'Language\' field in the header entry'),
1042-
('color=', None, 'use colors and other text attributes always'),
1043-
('style=', None, 'specify CSS style rule file for --color'),
1044-
('no-escape', 'e', 'do not use C escapes in output (default)'),
1045-
('escape', 'E', 'use C escapes in output, no extended chars'),
1046-
('force-po', None, 'write PO file even if empty'),
1047-
('indent', 'i', 'indented output style'),
1048992
('no-location', None, 'suppress \'#: filename:line\' lines'),
1049-
('strict', None, 'strict Uniforum output style'),
1050-
('properties-output', None, 'write out a Java .properties file'),
1051-
('stringtable-output', None, 'write out a NeXTstep/GNUstep .strings file'),
1052993
('width=', 'w', 'set output page width'),
1053-
('no-wrap', None, 'do not break long message lines, longer'
994+
('no-wrap', None, 'do not break long message lines, longer '
1054995
'than the output page width, into several lines'),
1055996
('sort-output', 's', 'generate sorted output'),
1056997
('sort-by-file', 'F', 'sort output by file location'),
@@ -1063,66 +1004,32 @@ class MergeCatalog(CommandMixin):
10631004
)
10641005

10651006
boolean_options = [
1007+
'compendium-overwrite',
1008+
'no-compendium-comment',
10661009
'update',
1067-
'multi-domain',
1068-
'for-msgfmt',
1010+
'backup',
10691011
'no-fuzzy-matching',
1070-
'previous'
1071-
'properties-input',
1072-
'stringtable-input',
1073-
'no-escape',
1074-
'escape',
1075-
'force-po',
1076-
'indent',
10771012
'no-location',
1078-
'strict',
1079-
'properties-output',
1080-
'stringtable-output',
10811013
'no-wrap',
10821014
'sort-output',
10831015
'sort-by-file',
1084-
'compendium-overwrite',
1085-
'backup',
1086-
'no-compendium-comment',
10871016
]
10881017

1089-
option_choices = {
1090-
'color': ('always', 'never', 'auto', 'html'),
1091-
}
1092-
10931018
def initialize_options(self):
1094-
self.input_files = None #
1095-
self.directory = None
1096-
1097-
self.compendium = None #~
1098-
self.compendium_overwrite = False #
1099-
self.no_compendium_comment = None #
1100-
1101-
self.update = None #
1102-
self.output_file = None #
1103-
self.backup = False #
1104-
self.suffix = '~' #
1105-
self.multi_domain = None
1106-
self.for_msgfmt = None
1107-
self.no_fuzzy_matching = None #
1108-
self.previous = None
1109-
self.properties_input = None
1110-
self.stringtable_input = None
1111-
self.lang = None
1112-
self.color = None
1113-
self.style = None
1114-
self.no_escape = None
1115-
self.escape = None
1116-
self.force_po = None
1117-
self.indent = None
1118-
self.no_location = None #
1119-
self.strict = None
1120-
self.properties_output = None
1121-
self.stringtable_output = None
1122-
self.width = None #
1123-
self.no_wrap = None #
1124-
self.sort_output = False #
1125-
self.sort_by_file = False #
1019+
self.input_files = None
1020+
self.compendium = None
1021+
self.compendium_overwrite = False
1022+
self.no_compendium_comment = False
1023+
self.update = False
1024+
self.output_file = None
1025+
self.backup = False
1026+
self.suffix = '~'
1027+
self.no_fuzzy_matching = False
1028+
self.no_location = False
1029+
self.width = None
1030+
self.no_wrap = False
1031+
self.sort_output = False
1032+
self.sort_by_file = False
11261033

11271034
def finalize_options(self):
11281035
if not self.input_files or len(self.input_files) != 2:
@@ -1147,9 +1054,6 @@ def _get_message_from_compendium(self, compendium):
11471054
def run(self):
11481055
def_file, ref_file = self.input_files
11491056

1150-
if self.update and self.backup:
1151-
shutil.copy(def_file, def_file + self.suffix)
1152-
11531057
with open(def_file, 'r') as pofile:
11541058
catalog = read_po(pofile)
11551059
with open(ref_file, 'r') as pofile:
@@ -1175,6 +1079,10 @@ def run(self):
11751079

11761080
catalog.fuzzy = any(message.fuzzy for message in catalog)
11771081
output_path = def_file if self.update else self.output_file
1082+
1083+
if self.update and self.backup:
1084+
shutil.copy(def_file, def_file + self.suffix)
1085+
11781086
with open(output_path, 'wb') as outfile:
11791087
write_po(
11801088
outfile,
@@ -1209,7 +1117,7 @@ class CommandLineInterface:
12091117
'extract': ExtractMessages,
12101118
'init': InitCatalog,
12111119
'update': UpdateCatalog,
1212-
'concat': ConcatenationCatalog,
1120+
'concat': ConcatenateCatalog,
12131121
'merge': MergeCatalog,
12141122
}
12151123

0 commit comments

Comments
 (0)