X-Git-Url: https://git.wpitchoune.net/gitweb/?p=mp3tohtml.git;a=blobdiff_plain;f=mp3tohtml%2Fmp3tohtml.py;h=1cd100476028950305f3eacae06f96d8e3d4dfa2;hp=ee51dee381281ada5bb498eaee548de17ec96355;hb=483ba9fc12e5b34c2cac93a096450c35a6d01579;hpb=1c886ddc907395d54fde0384089526c97b173161 diff --git a/mp3tohtml/mp3tohtml.py b/mp3tohtml/mp3tohtml.py index ee51dee..1cd1004 100755 --- a/mp3tohtml/mp3tohtml.py +++ b/mp3tohtml/mp3tohtml.py @@ -50,15 +50,29 @@ def fma_copyright_to_html(path, copyright): def copy_header(path): header_path = path + "/header.tpl" - header = open(header_path, "r") - for line in header: - sys.stdout.write(line) + try: + header = open(header_path, "r") + for line in header: + sys.stdout.write(line) + header.close() + except IOError as e: + sys.stderr.write("Failed to read header file " + + header_path + + ": " + e.strerror + "\n") + raise def copy_footer(path): footer_path = path + "/footer.tpl" - footer = open(footer_path, "r") - for line in footer: - sys.stdout.write(line) + try: + footer = open(footer_path, "r") + for line in footer: + sys.stdout.write(line) + footer.close() + except IOError as e: + sys.stderr.write("Failed to read footer file " + + footer_path + + ": " + e.strerror + "\n") + raise parser = argparse.ArgumentParser(description='Generate an HTML containing information about the MP3 files.') parser.add_argument('dir', help='The directory containing the MP3 files')