Skip to content
Snippets Groups Projects
Commit d150cee5 authored by Henrik tom Wörden's avatar Henrik tom Wörden
Browse files

STY: ws

parent 074d8a1b
No related branches found
No related tags found
No related merge requests found
......@@ -45,6 +45,7 @@ class NoValidHeader(Exception):
"using -f option".format(filename))
super().__init__(msg, *args, **kwargs)
class MetadataFileMissing(Exception):
def __init__(self, filename, *args, **kwargs):
......@@ -52,6 +53,7 @@ class MetadataFileMissing(Exception):
msg = "Metadata file README.md missing in " + filename
super().__init__(msg, *args, **kwargs)
class ParseErrorsInHeader(Exception):
def __init__(self, filename, reason, *args, **kwargs):
self.filename = filename
......@@ -59,6 +61,7 @@ class ParseErrorsInHeader(Exception):
msg = "Invalid header in {}. Reason: {}".format(filename, reason)
super().__init__(msg, *args, **kwargs)
TEMPLATEHEADER = """
---
responsible:
......@@ -185,7 +188,6 @@ def save_header(filename, header_data):
f.writelines(textlines)
def add_header(filename, header_dict=None):
"""
Add a header to an md file.
......@@ -195,10 +197,10 @@ def add_header(filename, header_dict=None):
If header_dict is a dictionary and not None the header
will be created based on the keys and values of that dictionary.
"""
if os.path.isdir(filename):
filename = os.path.join(filename, "README.md")
if os.path.exists(filename):
with open(filename) as f:
textlines = f.readlines()
......
......@@ -27,6 +27,7 @@
from . import pandoc_header_tools
def get_header(fn):
return pandoc_header_tools.get_header(fn)[2]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment