Skip to content
Snippets Groups Projects
Commit 34439a1b authored by I. Nüske's avatar I. Nüske
Browse files

MNT: Fix pandoc_header_tools.get_header() name collision

parent 3c4042a4
No related branches found
No related tags found
2 merge requests!128MNT: Added a warning when column metadata is not configured, and a better...,!126Fix pylint errors
Pipeline #59029 failed
......@@ -20,6 +20,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `h5` instead of `h5-crawler`
- `dev`, `doc`, `test` and `all` are new, they install the dependencies for developing, testing,
documentation and everything.
- The `pandoc_header_tools.get_header()` parameter `add_header` has been renamed to `add_header_to_file`
to resolve a name collision.
### Deprecated ###
......
......@@ -68,31 +68,30 @@ description:
"""
def get_header(filename, add_header=False):
"""Open an md file identified by filename and read out the yaml
header.
def get_header(filename, add_header_to_file=False):
"""Open an md file identified by filename and read out the yaml header.
filename can also be a folder. In this case folder/README.md will be used for
getting the header.
filename can also be a folder. In this case folder/README.md will be used
for getting the header.
If a header is found a tuple is returned: (first yaml header line index, last+1
yaml header line index, header)
If a header is found a tuple is returned: (first yaml header line index,
last+1 yaml header line index, header)
Otherwise, if `add_header` is True, a header is added and the function is called
again.
Otherwise, if `add_header_to_file` is True, a header is added and the
function is called again.
The header is normalized in the following way:
The header is normalized in the following way:
- If the value to a key is a string, a list with that string as only element is
returned.
- If the value to a key is a string, a list with that string as only
element is returned.
From https://pandoc.org/MANUAL.html:
A YAML metadata block is a valid YAML object, delimited by a line of three
hyphens (---) at the top and a line of three hyphens (---) or three dots (...)
at the bottom. A YAML metadata block may occur anywhere in the document, but if
it is not at the beginning, it must be preceded by a blank line.
From https://pandoc.org/MANUAL.html:
A YAML metadata block is a valid YAML object, delimited by a line of three
hyphens (---) at the top and a line of three hyphens (---) or three
dots (...) at the bottom. A YAML metadata block may occur anywhere in the
document, but if it is not at the beginning, it must be preceded by a blank
line.
"""
if os.path.isdir(filename):
......@@ -146,7 +145,7 @@ it is not at the beginning, it must be preceded by a blank line.
raise NoValidHeader(filename)
return (found_1, found_2, clean_header(yaml_part))
if not add_header:
if not add_header_to_file:
raise NoValidHeader(filename)
else:
print("Adding header in: {fn}".format(fn=filename))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment