Browse Source

No error if files cannot be opened

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

4
patacrep/index.py

@ -40,12 +40,14 @@ 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:
index_file.close()
if index_file:
index_file.close()
i = 1
idx = Index(data[0])

4
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,7 +201,8 @@ class TexRenderer(object):
)
)
finally:
template_file.close()
if template_file:
template_file.close()
return (subvariables, subtemplates)

4
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,7 +110,8 @@ def main():
LOGGER.error("Error while loading file '{}'.".format(songbook_path))
sys.exit(1)
finally:
songbook_file.close()
if songbook_file:
songbook_file.close()
# Gathering datadirs
datadirs = []

Loading…
Cancel
Save