def test_it_recognizes_and_return_multiline_properties_if_key_is_found(): checker = linecheck.Checker({}) test_lines = ["bar=baz \\\n", "quux", "foo=bar"] assert (test_lines == checker.get_lines(test_lines))
"translation_file", help= "Properties file with translation from languages/themes/wilma/i18n folder", metavar="TRANSLATED_FILE") parser.add_argument("output_file", default="missing.properties", nargs='?', metavar="OUTPUT_FILE") args = parser.parse_args() original = open(args.original_file, "r") translation = open(args.translation_file, "r") output_file = open(args.output_file, "w") def get_properties_dict(lines): """ Get property => value dict from an iterable. Comments, blank lines and multiline properties are ignored. """ dict_all = {} for line in lines: items = line.strip().split('=', 1) if len(items) < 2: continue dict_all[items[0]] = items[1] return dict_all checker = linecheck.Checker(get_properties_dict(translation)) output_file.write("".join(checker.get_lines(original)))
def test_it_returns_lines_if_key_is_not_found(): checker = linecheck.Checker({}) test_lines = ["foo=bar", "bar=baz"] assert (test_lines == checker.get_lines(test_lines))
def test_it_treats_comments_with_equal_signs_as_non_property_lines(): checker = linecheck.Checker({}) test_lines = ["# comment=foo", "bar=baz"] assert (test_lines == checker.get_lines(test_lines))
def test_it_omits_last_property_lines_if_key_is_found(): checker = linecheck.Checker({"bar": "boo"}) test_lines = ["foo=bar", "#comment1", "#comment2", "bar=baz"] assert (["foo=bar"] == checker.get_lines(test_lines))
def test_it_returns_non_property_lines_if_some_keys_are_not_found(): checker = linecheck.Checker({"bar": "boo"}) test_lines = ["#comment", "foo=bar", "bar=baz"] assert (["#comment", "foo=bar"] == checker.get_lines(test_lines))
def test_it_returns_non_property_lines_if_key_is_not_found(): checker = linecheck.Checker({}) test_lines = ["foo=bar", "#comment", "bar=baz"] assert (test_lines == checker.get_lines(test_lines)) test_lines = ["#comment1", "#comment2", "foo=bar", "bar=baz"] assert (test_lines == checker.get_lines(test_lines))
def test_it_handles_property_values_with_equal_sign(): checker = linecheck.Checker({}) test_lines = ["foo=bar", "bar=baz=quux"] assert (test_lines == checker.get_lines(test_lines))
def test_it_omits_lines_if_key_is_found(): checker = linecheck.Checker({"foo": "boo"}) test_lines = ["foo=bar", "bar=baz"] assert (["bar=baz"] == checker.get_lines(test_lines))