diff --git a/src/caosadvancedtools/pandoc_header_tools.py b/src/caosadvancedtools/pandoc_header_tools.py index 6322da7ea71bba8e261f33f8e8a1d260e2971d6d..4c6dfb21836f4e960fadd084336f053edbc4be41 100644 --- a/src/caosadvancedtools/pandoc_header_tools.py +++ b/src/caosadvancedtools/pandoc_header_tools.py @@ -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() diff --git a/src/caosadvancedtools/read_md_header.py b/src/caosadvancedtools/read_md_header.py index 514117a42361cb43cf56ecceed3b708577e5e937..ece81c403af7ca65fb48ebd457fdded8544413e8 100644 --- a/src/caosadvancedtools/read_md_header.py +++ b/src/caosadvancedtools/read_md_header.py @@ -27,6 +27,7 @@ from . import pandoc_header_tools + def get_header(fn): return pandoc_header_tools.get_header(fn)[2]