Python 2.6 compatibility

This commit is contained in:
Manuel Ebert 2013-08-28 13:48:18 -07:00
parent 974f5a0f9c
commit 4e36d7baf0
4 changed files with 9 additions and 9 deletions

View file

@ -58,7 +58,7 @@ class Entry:
)
def __repr__(self):
return "<Entry '{}' on {}>".format(self.title.strip(), self.date.strftime("%Y-%m-%d %H:%M"))
return "<Entry '{0}' on {1}>".format(self.title.strip(), self.date.strftime("%Y-%m-%d %H:%M"))
def to_dict(self):
return {

View file

@ -181,7 +181,7 @@ class Journal(object):
return self.__unicode__()
def __repr__(self):
return "<Journal with {} entries>".format(len(self.entries))
return "<Journal with {0} entries>".format(len(self.entries))
def write(self, filename=None):
"""Dumps the journal into the config file, overwriting it"""
@ -234,7 +234,7 @@ class Journal(object):
for m in matches:
date = e.date.strftime(self.config['timeformat'])
excerpt = e.body[m.start():min(len(e.body), m.end()+60)]
res.append('{} {} ..'.format(date, excerpt))
res.append('{0} {1} ..'.format(date, excerpt))
e.body = "\n".join(res)
else:
for e in self.entries:

View file

@ -87,16 +87,16 @@ def export(journal, format, output=None):
try:
with open(output, 'w') as f:
f.write(content)
return "[Journal exported to {}]".format(output)
return "[Journal exported to {0}]".format(output)
except IOError as e:
return "[ERROR: {} {}]".format(e.filename, e.strerror)
return "[ERROR: {0} {1}]".format(e.filename, e.strerror)
else:
return content
def write_files(journal, path, format):
"""Turns your journal into separate files for each entry.
Format should be either json, md or txt."""
make_filename = lambda entry: e.date.strftime("%C-%m-%d_{}.{}".format(slugify(u(e.title)), format))
make_filename = lambda entry: e.date.strftime("%C-%m-%d_{0}.{1}".format(slugify(u(e.title)), format))
for e in journal.entries:
full_path = os.path.join(path, make_filename(e))
if format == 'json':
@ -107,4 +107,4 @@ def write_files(journal, path, format):
content = u(e)
with open(full_path, 'w') as f:
f.write(content)
return "[Journal exported individual files in {}]".format(path)
return "[Journal exported individual files in {0}]".format(path)

View file

@ -123,7 +123,7 @@ def cli(manual_args=None):
try:
config = json.load(f)
except ValueError as e:
util.prompt("[There seems to be something wrong with your jrnl config at {}: {}]".format(CONFIG_PATH, e.message))
util.prompt("[There seems to be something wrong with your jrnl config at {0}: {1}]".format(CONFIG_PATH, e.message))
util.prompt("[Entry was NOT added to your journal]")
sys.exit(1)
install.update_config(config, config_path=CONFIG_PATH)
@ -155,7 +155,7 @@ def cli(manual_args=None):
"entries" in os.listdir(config['journal']):
journal = Journal.DayOne(**config)
else:
util.prompt("[Error: {} is a directory, but doesn't seem to be a DayOne journal either.".format(config['journal']))
util.prompt("[Error: {0} is a directory, but doesn't seem to be a DayOne journal either.".format(config['journal']))
sys.exit(1)
else:
journal = Journal.Journal(**config)