Skip to content

Commit a28b263

Browse files
committed
Fix PR issues
* Delete unused options * Fix multiline options comments * Replace backup logic in MergeCatalog * Rename to ConcatenateCatalog
1 parent 8b00b02 commit a28b263

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
@@ -888,94 +888,51 @@ def run(self):
888888
return
889889

890890

891-
class ConcatenationCatalog(CommandMixin):
891+
class ConcatenateCatalog(CommandMixin):
892892
description = 'concatenates and merges the specified PO files'
893893
user_options = [
894894
('input-files', None, 'input files'),
895-
('files-from=', 'f', 'get list of input files from FILE'),
896-
('directory=', 'D', 'add DIRECTORY to list for input files search'
897-
'If input file is -, standard input is read.'),
898895
('output-file=', 'o', 'write output to specified file'),
899896
('less-than=', '<', 'print messages with less than this many'
900-
'definitions, defaults to infinite if not set'),
901-
('more-than=', '>', 'print messages with more than this many'
897+
'definitions, defaults to infinite if not set '),
898+
('more-than=', '>', 'print messages with more than this many '
902899
'definitions, defaults to 0 if not set'),
903-
('unique', 'u', 'shorthand for --less-than=2, requests'
900+
('unique', 'u', 'shorthand for --less-than=2, requests '
904901
'that only unique messages be printed'),
905-
('properties-input', 'P', 'input files are in Java .properties syntax'),
906-
('stringtable-input', None, 'input files are in NeXTstep/GNUstep .strings syntax'),
907-
('to-code=','t', 'encoding for output'),
908-
('use-first', None, 'use first available translation for each'
902+
('use-first', None, 'use first available translation for each '
909903
'message, don\'t merge several translations'),
910-
('lang=', None, 'set \'Language\' field in the header entry'),
911-
('color=', None, 'use colors and other text attributes always'),
912-
('style=', None, 'specify CSS style rule file for --color'),
913-
('no-escape', 'e', 'do not use C escapes in output (default)'),
914-
('escape', 'E', 'use C escapes in output, no extended chars'),
915-
('force-po', None, 'write PO file even if empty'),
916-
('indent', 'i', 'write the .po file using indented style'),
917904
('no-location', None, 'do not write \'#: filename:line\' lines'),
918-
('strict', None, 'write out strict Uniforum conforming .po file'),
919-
('properties-output', None, 'write out a Java .properties file'),
920-
('stringtable-output', None, 'write out a NeXTstep/GNUstep .strings file'),
921905
('width=', 'w', 'set output page width'),
922-
('no-wrap', None, 'do not break long message lines, longer than'
906+
('no-wrap', None, 'do not break long message lines, longer than '
923907
'the output page width, into several lines'),
924908
('sort-output', 's', 'generate sorted output'),
925909
('sort-by-file', 'F', 'sort output by file location'),
926910
]
927911

928-
as_args='input-files'
912+
as_args = 'input-files'
929913

930914
boolean_options = [
931915
'unique',
932-
'properties-input',
933-
'stringtable-input',
934-
'no-escape',
935-
'escape',
936-
'force-po',
937-
'indent',
916+
'use-first',
938917
'no-location',
939918
'strict',
940-
'properties-output',
941-
'stringtable-output',
942919
'no-wrap',
943920
'sort-output',
944921
'sort-by-file',
945922
]
946923

947-
option_choices = {
948-
'color': ('always', 'never', 'auto', 'html'),
949-
}
950-
951924
def initialize_options(self):
952-
self.input_files = None #
953-
self.files_from = None
954-
self.directory = None
955-
self.output_file = None #
956-
self.less_than = None #
957-
self.more_than = 0 #
958-
self.unique = False #
959-
self.properties_input = None
960-
self.stringtable_input = None
961-
self.to_code = None
962-
# the first translation is always used temporarily
963-
self.use_first = False #~
964-
self.lang = None
965-
self.color = None
966-
self.style = None
967-
self.no_escape = None
968-
self.escape = None
969-
self.force_po = None
970-
self.indent = None
971-
self.no_location = None #
972-
self.strict = None
973-
self.properties_output = None
974-
self.stringtable_output = None
975-
self.width = None #
976-
self.no_wrap = None #
977-
self.sort_output = False #
978-
self.sort_by_file = False #
925+
self.input_files = None
926+
self.output_file = None
927+
self.less_than = None
928+
self.more_than = 0
929+
self.unique = False
930+
self.use_first = False
931+
self.no_location = None
932+
self.width = None
933+
self.no_wrap = False
934+
self.sort_output = False
935+
self.sort_by_file = False
979936

980937
def finalize_options(self):
981938
if not self.input_files:
@@ -1055,37 +1012,21 @@ def run(self):
10551012

10561013

10571014
class MergeCatalog(CommandMixin):
1058-
description='combines two Uniforum-style PO files into one'
1015+
description='updates translation PO file by merging them with updated template POT file with using compendium'
10591016
user_options=[
1060-
('input-files', None, 'def.po ref.pot'),
1061-
('directory=', 'D', 'add DIRECTORY to list for input files search'),
1017+
('input-files', None, 'def.po (obsolete translations) ref.pot (actual template)'),
10621018
('compendium=', 'C', 'additional library of message translations, may be specified more than once'),
10631019
('compendium-overwrite', '', 'overwrite mode of compendium'),
10641020
('no-compendium-comment', '', ''),
10651021
('update', 'U', 'pdate def.po, do nothing if def.po already up to date'),
1066-
('output-file=', 'o', 'write output to specified file, the results are written'
1022+
('output-file=', 'o', 'write output to specified file, the results are written '
10671023
'to standard output if no output file is specified'),
10681024
('backup', None, 'make a backup of def.po'),
10691025
('suffix=', None, 'override the usual backup suffix'),
1070-
('multi-domain', 'm', 'apply ref.pot to each of the domains in def.po'),
1071-
('for-msgfmt', None, 'produce output for \'msgfmt\', not for a translator'),
10721026
('no-fuzzy-matching', 'N', 'do not use fuzzy matching'),
1073-
('previous', None, 'keep previous msgids of translated messages'),
1074-
('properties-input', 'P', 'input files are in Java .properties syntax'),
1075-
('stringtable-input', None, 'input files are in NeXTstep/GNUstep .strings syntax'),
1076-
('lang=', None, 'set \'Language\' field in the header entry'),
1077-
('color=', None, 'use colors and other text attributes always'),
1078-
('style=', None, 'specify CSS style rule file for --color'),
1079-
('no-escape', 'e', 'do not use C escapes in output (default)'),
1080-
('escape', 'E', 'use C escapes in output, no extended chars'),
1081-
('force-po', None, 'write PO file even if empty'),
1082-
('indent', 'i', 'indented output style'),
10831027
('no-location', None, 'suppress \'#: filename:line\' lines'),
1084-
('strict', None, 'strict Uniforum output style'),
1085-
('properties-output', None, 'write out a Java .properties file'),
1086-
('stringtable-output', None, 'write out a NeXTstep/GNUstep .strings file'),
10871028
('width=', 'w', 'set output page width'),
1088-
('no-wrap', None, 'do not break long message lines, longer'
1029+
('no-wrap', None, 'do not break long message lines, longer '
10891030
'than the output page width, into several lines'),
10901031
('sort-output', 's', 'generate sorted output'),
10911032
('sort-by-file', 'F', 'sort output by file location'),
@@ -1098,66 +1039,32 @@ class MergeCatalog(CommandMixin):
10981039
)
10991040

11001041
boolean_options = [
1042+
'compendium-overwrite',
1043+
'no-compendium-comment',
11011044
'update',
1102-
'multi-domain',
1103-
'for-msgfmt',
1045+
'backup',
11041046
'no-fuzzy-matching',
1105-
'previous'
1106-
'properties-input',
1107-
'stringtable-input',
1108-
'no-escape',
1109-
'escape',
1110-
'force-po',
1111-
'indent',
11121047
'no-location',
1113-
'strict',
1114-
'properties-output',
1115-
'stringtable-output',
11161048
'no-wrap',
11171049
'sort-output',
11181050
'sort-by-file',
1119-
'compendium-overwrite',
1120-
'backup',
1121-
'no-compendium-comment',
11221051
]
11231052

1124-
option_choices = {
1125-
'color': ('always', 'never', 'auto', 'html'),
1126-
}
1127-
11281053
def initialize_options(self):
1129-
self.input_files = None #
1130-
self.directory = None
1131-
1132-
self.compendium = None #~
1133-
self.compendium_overwrite = False #
1134-
self.no_compendium_comment = None #
1135-
1136-
self.update = None #
1137-
self.output_file = None #
1138-
self.backup = False #
1139-
self.suffix = '~' #
1140-
self.multi_domain = None
1141-
self.for_msgfmt = None
1142-
self.no_fuzzy_matching = None #
1143-
self.previous = None
1144-
self.properties_input = None
1145-
self.stringtable_input = None
1146-
self.lang = None
1147-
self.color = None
1148-
self.style = None
1149-
self.no_escape = None
1150-
self.escape = None
1151-
self.force_po = None
1152-
self.indent = None
1153-
self.no_location = None #
1154-
self.strict = None
1155-
self.properties_output = None
1156-
self.stringtable_output = None
1157-
self.width = None #
1158-
self.no_wrap = None #
1159-
self.sort_output = False #
1160-
self.sort_by_file = False #
1054+
self.input_files = None
1055+
self.compendium = None
1056+
self.compendium_overwrite = False
1057+
self.no_compendium_comment = False
1058+
self.update = False
1059+
self.output_file = None
1060+
self.backup = False
1061+
self.suffix = '~'
1062+
self.no_fuzzy_matching = False
1063+
self.no_location = False
1064+
self.width = None
1065+
self.no_wrap = False
1066+
self.sort_output = False
1067+
self.sort_by_file = False
11611068

11621069
def finalize_options(self):
11631070
if not self.input_files or len(self.input_files) != 2:
@@ -1182,9 +1089,6 @@ def _get_message_from_compendium(self, compendium):
11821089
def run(self):
11831090
def_file, ref_file = self.input_files
11841091

1185-
if self.update and self.backup:
1186-
shutil.copy(def_file, def_file + self.suffix)
1187-
11881092
with open(def_file, 'r') as pofile:
11891093
catalog = read_po(pofile)
11901094
with open(ref_file, 'r') as pofile:
@@ -1210,6 +1114,10 @@ def run(self):
12101114

12111115
catalog.fuzzy = any(message.fuzzy for message in catalog)
12121116
output_path = def_file if self.update else self.output_file
1117+
1118+
if self.update and self.backup:
1119+
shutil.copy(def_file, def_file + self.suffix)
1120+
12131121
with open(output_path, 'wb') as outfile:
12141122
write_po(
12151123
outfile,
@@ -1244,7 +1152,7 @@ class CommandLineInterface:
12441152
'extract': ExtractMessages,
12451153
'init': InitCatalog,
12461154
'update': UpdateCatalog,
1247-
'concat': ConcatenationCatalog,
1155+
'concat': ConcatenateCatalog,
12481156
'merge': MergeCatalog,
12491157
}
12501158

0 commit comments

Comments
 (0)