Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-advanced-user-tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-advanced-user-tools
Commits
34439a1b
Commit
34439a1b
authored
6 months ago
by
I. Nüske
Browse files
Options
Downloads
Patches
Plain Diff
MNT: Fix pandoc_header_tools.get_header() name collision
parent
3c4042a4
No related branches found
No related tags found
2 merge requests
!128
MNT: Added a warning when column metadata is not configured, and a better...
,
!126
Fix pylint errors
Pipeline
#59029
failed
6 months ago
Stage: setup
Stage: cert
Stage: style
Stage: unittest
Stage: integrationtest
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CHANGELOG.md
+2
-0
2 additions, 0 deletions
CHANGELOG.md
src/caosadvancedtools/pandoc_header_tools.py
+18
-19
18 additions, 19 deletions
src/caosadvancedtools/pandoc_header_tools.py
with
20 additions
and
19 deletions
CHANGELOG.md
+
2
−
0
View file @
34439a1b
...
...
@@ -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 ###
...
...
This diff is collapsed.
Click to expand it.
src/caosadvancedtools/pandoc_header_tools.py
+
18
−
19
View file @
34439a1b
...
...
@@ -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
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment