Browse Source

No error if files cannot be opened

pull/58/head
Louis 10 years ago
parent
commit
5048930f44
  1. 2
      patacrep/index.py
  2. 2
      patacrep/templates.py
  3. 2
      songbook

2
patacrep/index.py

@ -40,11 +40,13 @@ def process_sxd(filename):
Return an Index object.
"""
data = []
index_file = None
try:
index_file = encoding.open_read(filename, 'r')
for line in index_file:
data.append(line.strip())
finally:
if index_file:
index_file.close()
i = 1

2
patacrep/templates.py

@ -177,6 +177,7 @@ class TexRenderer(object):
"""
subvariables = {}
template_file = None
templatename = self.texenv.get_template(template).filename
try:
template_file = encoding.open_read(templatename, 'r')
@ -200,6 +201,7 @@ class TexRenderer(object):
)
)
finally:
if template_file:
template_file.close()
return (subvariables, subtemplates)

2
songbook

@ -101,6 +101,7 @@ def main():
basename = os.path.basename(songbook_path)[:-3]
songbook_file = None
try:
songbook_file = encoding.open_read(songbook_path)
songbook = json.load(songbook_file)
@ -109,6 +110,7 @@ def main():
LOGGER.error("Error while loading file '{}'.".format(songbook_path))
sys.exit(1)
finally:
if songbook_file:
songbook_file.close()
# Gathering datadirs

Loading…
Cancel
Save