Skip to content

Commit

Permalink
Merge branch 'feature/format-syntax' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Fantomas42 committed Dec 5, 2013
2 parents f298cda + ebab358 commit 900c44d
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions bvc/configparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,20 @@ def write_section(self, fd, section, indentation):
if value is None:
value = ''
operator = ''
key_indentation = indentation
buildout_operator = OPERATORS.search(key)
if buildout_operator:
operator = buildout_operator.group(0)
key_indentation -= 1
key = key[:-1]
if key == '<':
value = ''.rjust(indentation - 1) + value
value = '{value:>{indent}}'.format(
value=value, indent=indentation + len(value) - 1)
else:
key = key.ljust(key_indentation) + operator
value = str(value).replace('\n', '\n'.ljust(
key_indentation + 3 + int(bool(operator))))
string_section += '%s= %s\n' % (key, value)
key = '{key:<{indent}}{operator}'.format(
key=key, operator=operator,
indent=indentation - int(bool(operator)))
value = value.replace('\n', '{:<{indent}}'.format(
'\n', indent=indentation + 3))
string_section += '{key}= {value}\n'.format(key=key, value=value)

fd.write(string_section.encode('utf-8'))

Expand Down

0 comments on commit 900c44d

Please sign in to comment.