Skip to content

Commit

Permalink
Merge pull request #318 from ktomk/patch-issue-317
Browse files Browse the repository at this point in the history
Patch issue 317
  • Loading branch information
arisktfx authored Dec 15, 2021
2 parents 6df9dce + 90151c2 commit ee56285
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ six<2.0.0
requests>=2.19.1,<3.0.0
python-slugify<5.0.0
gitpython<4.0.0

1 change: 0 additions & 1 deletion tests/project_dir/.transifexrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ api_hostname = https://api.transifex.com
hostname = https://www.transifex.com
password = foo
username = bar

16 changes: 8 additions & 8 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def tearDown(self, *args, **kwargs):

def test_init(self):
argv = []
config_text = "[main]\nhost = https://www.transifex.com\n\n"
config_text = "[main]\nhost = https://www.transifex.com\n"
with patch('txclib.commands.project.Project'):
with patch('txclib.commands.cmd_config') as set_mock:
cmd_init(argv, '')
Expand Down Expand Up @@ -255,7 +255,7 @@ def test_bare_set_source_no_file(self):

def test_bare_set_source_file(self):
expected = ("[main]\nhost = https://foo.var\n\n[project1.resource1]\n"
"source_file = test.txt\nsource_lang = en\n\n")
"source_file = test.txt\nsource_lang = en\n")
args = ["-r", "project1.resource1", '--source', '-l', 'en', 'test.txt']
cmd_config(args, self.path_to_tx)
with open(self.config_file) as config:
Expand All @@ -264,7 +264,7 @@ def test_bare_set_source_file(self):
# set translation file for de
expected = ("[main]\nhost = https://foo.var\n\n[project1.resource1]\n"
"source_file = test.txt\nsource_lang = en\n"
"trans.de = translations/de.txt\n\n")
"trans.de = translations/de.txt\n")
args = ["-r", "project1.resource1", '-l', 'de', 'translations/de.txt']
cmd_config(args, self.path_to_tx)
with open(self.config_file) as config:
Expand All @@ -289,7 +289,7 @@ def test_auto_locale_is_backwards_compatible(self):
expected = ("[main]\nhost = https://foo.var\n\n[project1.resource1]\n"
"file_filter = translations/<lang>/test.txt\n"
"source_file = translations/en/test.txt\n"
"source_lang = en\n\n")
"source_lang = en\n")

args = ["--auto-local", "-r", "project1.resource1",
'--source-language', 'en', '--execute',
Expand All @@ -302,7 +302,7 @@ def test_auto_locale_execute(self):
expected = ("[main]\nhost = https://foo.var\n\n[project1.resource1]\n"
"file_filter = translations/<lang>/test.txt\n"
"source_file = translations/en/test.txt\n"
"source_lang = en\n\n")
"source_lang = en\n")

args = [MAPPING, "-r", "project1.resource1", '--source-language',
'en', '--execute', 'translations/<lang>/test.txt']
Expand Down Expand Up @@ -333,7 +333,7 @@ def test_auto_remote_project(self, extension_mock, get_details_mock):
"file_filter = translations/proj.resource_1/<lang>.txt\n"
"source_lang = fr\ntype = TXT\n\n[proj.resource_2]\n"
"file_filter = translations/proj.resource_2/<lang>.txt\n"
"source_lang = fr\ntype = TXT\n\n")
"source_lang = fr\ntype = TXT\n")
extension_mock.return_value = ".txt"
get_details_mock.side_effect = [
# project details
Expand Down Expand Up @@ -372,7 +372,7 @@ def test_auto_remote_is_backwards_compatible(self, extension_mock,
"file_filter = translations/proj.resource_1/<lang>.txt\n"
"source_lang = fr\ntype = TXT\n\n[proj.resource_2]\n"
"file_filter = translations/proj.resource_2/<lang>.txt\n"
"source_lang = fr\ntype = TXT\n\n")
"source_lang = fr\ntype = TXT\n")
extension_mock.return_value = ".txt"
get_details_mock.side_effect = [
# project details
Expand Down Expand Up @@ -417,7 +417,7 @@ def test_bulk(self):
"[test-project.translations_en_test]\n"
"file_filter = translations/<lang>/en/test.txt\n"
"source_file = translations/en/test.txt\n"
"source_lang = en\ntype = TXT\n\n")
"source_lang = en\ntype = TXT\n")
args = [MAPPINGBULK, "-p", "test-project", "--source-file-dir",
"translations", "--source-language", "en", "-t", "TXT",
"--file-extension", ".txt", "--execute", "--expression",
Expand Down
7 changes: 4 additions & 3 deletions txclib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,21 @@ class OrderedRawConfigParser(configparser.RawConfigParser):
"""
def write(self, fp):
"""Write an .ini-format representation of the configuration state."""
section_prefix = ''
if self._defaults:
fp.write("[%s]\n" % DEFAULTSECT)
for key in sorted(self._defaults):
fp.write("%s = %s\n" % (key, str(self._defaults[key]).
replace('\n', '\n\t')))
fp.write("\n")
section_prefix = '\n'
for section in self._sections:
fp.write("[%s]\n" % section)
fp.write("%s[%s]\n" % (section_prefix, section))
for key in sorted(self._sections[section]):
if key != "__name__":
fp.write("%s = %s\n" %
(key, str(self._sections[section][key]).
replace('\n', '\n\t')))
fp.write("\n")
section_prefix = '\n'

optionxform = str

Expand Down

0 comments on commit ee56285

Please sign in to comment.