This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Use numbers in field names in format strings because of Python 2.6

  • Loading branch information...
1 parent 7310b82 commit 4059af974c969e6dc6d70567ee69c94065bbec69 @bkabrda bkabrda committed Dec 4, 2013
Showing with 10 additions and 10 deletions.
  1. +7 −7 devassistant/command_runners.py
  2. +3 −3 devassistant/lang.py
@@ -654,42 +654,42 @@ def _try_obtain_mandatory_params(cls, args):
data = {}
if 'data' in args and isinstance(args['data'], dict):
data = args['data']
- logger.debug('Template context data: {}'.format(data))
+ logger.debug('Template context data: {0}'.format(data))
return (template, cls._make_output_file_name(args, template), data)
@classmethod
def run(cls, c):
# Transform list of dicts (where keys are unique) into a single dict
args = c.format_deep(True)
- logger.debug('args={}'.format(repr(args)))
+ logger.debug('args={0}'.format(repr(args)))
# Get parameters
template, result_filename, data = cls._try_obtain_mandatory_params(args)
# Create an environment!
- logger.debug('Using templats dir: {}'.format(c.files_dir))
+ logger.debug('Using templats dir: {0}'.format(c.files_dir))
env = jinja2.Environment(loader=jinja2.FileSystemLoader(c.files_dir))
env.trim_blocks = True
env.lstrip_blocks = True
# Get a template instance
tpl = None
try:
- logger.debug('Using template file: {}'.format(template))
+ logger.debug('Using template file: {0}'.format(template))
tpl = env.get_template(template)
except jinja2.TemplateError as e:
- raise exceptions.CommandException('Template file failure: {}'.format(e.message))
+ raise exceptions.CommandException('Template file failure: {0}'.format(e.message))
# Check if destination file exists, overwrite if needed
if os.path.exists(result_filename):
overwrite = args['overwrite'] if 'overwrite' in args else False
overwrite = True if overwrite == 'True' or overwrite == 'true' or overwrite == 'yes' else False
if overwrite:
- logger.info('Overwriting the destination file {}'.format(result_filename))
+ logger.info('Overwriting the destination file {0}'.format(result_filename))
os.remove(result_filename)
else:
- raise exceptions.CommandException('The destination file already exists: {}'.format(result_filename))
+ raise exceptions.CommandException('The destination file already exists: {0}'.format(result_filename))
# Generate an output file finally...
with open(result_filename, 'w') as out:
View
@@ -231,10 +231,10 @@ class symbol_base(object):
first = second = None
def nud(self):
- raise SyntaxError("Syntax error ({}).".format(self.id))
+ raise SyntaxError("Syntax error ({0}).".format(self.id))
def led(self, left):
- raise SyntaxError("Unknown operator ({}).".format(self.id))
+ raise SyntaxError("Unknown operator ({0}).".format(self.id))
def symbol(self, id, bp=0):
"""
@@ -261,7 +261,7 @@ def advance(self, id=None):
"""
if id and self.token.id != id:
- raise SyntaxError("Expected {}".format(id))
+ raise SyntaxError("Expected {0}".format(id))
self.token = self.next()
def method(self, symbol_name):

2 comments on commit 4059af9

Contributor

zaufi replied Dec 4, 2013

is this something for Python 2 compatibility?
(I use Python3 only, so just curious)

Owner

bkabrda replied Dec 4, 2013

Yeah, it's for Python 2.6 (we want DevAssistant to work on RHEL 6) - when I wrote a test for the Jinja command runner, this crashed in Travis: https://travis-ci.org/bkabrda/devassistant/jobs/14915176#L293

Please sign in to comment.