From d150cee5b833f66bea248f177156ed6c3828df07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20tom=20W=C3=B6rden?= <henrik@trineo.org> Date: Sun, 29 Dec 2019 14:20:30 +0100 Subject: [PATCH] STY: ws --- src/caosadvancedtools/pandoc_header_tools.py | 8 +++++--- src/caosadvancedtools/read_md_header.py | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/caosadvancedtools/pandoc_header_tools.py b/src/caosadvancedtools/pandoc_header_tools.py index 6322da7e..4c6dfb21 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 514117a4..ece81c40 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] -- GitLab