Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
generator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
R3
apps
generator
Commits
6fc36b81
Verified
Commit
6fc36b81
authored
2 years ago
by
Laurent Heirendt
Browse files
Options
Downloads
Patches
Plain Diff
changes for replacing links
parent
514783dd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!6
changes for cleaning up latex files
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core.py
+43
-40
43 additions, 40 deletions
core.py
qms.py
+12
-0
12 additions, 0 deletions
qms.py
with
55 additions
and
40 deletions
core.py
+
43
−
40
View file @
6fc36b81
...
...
@@ -39,6 +39,8 @@ def core(cardDirs, localroot=os.getcwd(), generate_index=True):
if
generate_index
:
print
(
"
> Generating header for:
"
+
fileName
)
else
:
print
(
"
> Preparing LATEX document:
"
+
fileName
)
# save order and legacy section
order
=
library
.
save_tag
(
localroot
,
root
,
file
,
"
card_order
"
)
...
...
@@ -59,56 +61,57 @@ def core(cardDirs, localroot=os.getcwd(), generate_index=True):
else
:
qms
.
prepare_qms_latex
(
localroot
,
root
,
file
,
nb
)
# remove the previous header
n
=
header
.
remove_header
(
localroot
,
root
,
file
)
# generate a permalink
permalink
=
"
/
"
+
root
+
"
/
"
# generate the shortcut
shortcut
=
re
.
sub
(
folder
,
''
,
root
)
# remove the first /
shortcut
=
shortcut
[
1
:]
# replace the / with a :
shortcut
=
re
.
sub
(
'
/
'
,
'
:
'
,
shortcut
)
if
generate_index
:
# remove the previous header
n
=
header
.
remove_header
(
localroot
,
root
,
file
)
# generate a permalink
permalink
=
"
/
"
+
root
+
"
/
"
# generate the shortcut
shortcut
=
re
.
sub
(
folder
,
''
,
root
)
# remove the first /
shortcut
=
shortcut
[
1
:]
# replace the / with a :
shortcut
=
re
.
sub
(
'
/
'
,
'
:
'
,
shortcut
)
if
len
(
order
)
>
0
:
# find the maximum of existing orders
if
folderFlag
:
if
len
(
orderArr
[
indexS
])
>
0
:
maxOrder
=
max
(
orderArr
[
indexS
])
else
:
maxOrder
=
0
# after determining the max order, set the folder flag to False to avoid another entry into the same block of code
folderFlag
=
False
tmp
=
orderArr
[
indexS
].
copy
()
tmp
.
append
(
maxOrder
+
int
(
order
))
orderArr
[
indexS
]
=
tmp
else
:
orderArr
[
indexS
]
=
[]
if
len
(
order
)
>
0
:
# find the maximum of existing orders
if
folderFlag
:
if
len
(
orderArr
[
indexS
])
>
0
:
maxOrder
=
max
(
orderArr
[
indexS
])
else
:
maxOrder
=
0
# after determining the max order, set the folder flag to False to avoid another entry into the same block of code
folderFlag
=
False
tmp
=
orderArr
[
indexS
].
copy
()
tmp
.
append
(
maxOrder
+
int
(
order
))
orderArr
[
indexS
]
=
tmp
else
:
orderArr
[
indexS
]
=
[]
# generate the header for each card
h
=
header
.
generate_header
(
folder
,
permalink
,
shortcut
,
order
,
legacy_from
,
title
,
description
,
name
,
nb
)
# add autogenerated links to whitelist
wl
+=
whitelist
.
generate_whitelist_entry
(
folder
,
permalink
,
shortcut
)
# generate
the header
for each card
h
=
header
.
generate_header
(
folder
,
permalink
,
shortcut
,
order
,
legacy_from
,
title
,
description
,
n
ame
,
nb
)
# add
the header
properly speaking
format
.
line_prepender
(
fileN
ame
,
h
)
# add autogenerated links to whitelist
wl
+=
whitelist
.
generate_whitelist_entry
(
folder
,
permalink
,
shortcut
)
localIndexArr
[
indexS
].
append
(
format
.
build_link
(
title
,
root
))
# add the header properly speaking
format
.
line_prepender
(
fileName
,
h
)
# output
print
(
"
+ New header added.
"
)
localIndexArr
[
indexS
].
append
(
format
.
build_link
(
title
,
root
))
# output
print
(
"
+ New header added.
"
)
print
(
"
-----------------------
"
)
localIndexArr
=
library
.
sort_sections
(
sections
,
localIndexArr
,
orderArr
)
if
generate_index
:
localIndexArr
=
library
.
sort_sections
(
sections
,
localIndexArr
,
orderArr
)
index
=
library
.
generate_index
(
index
,
sections
,
localIndexArr
)
return
index
,
wl
...
...
This diff is collapsed.
Click to expand it.
qms.py
+
12
−
0
View file @
6fc36b81
...
...
@@ -31,6 +31,18 @@ def prepare_qms_latex(localroot, root, filename, nb):
filedata
=
replace_formatting
(
filedata
)
# get the category
category
=
get_category
(
filename
)
# deal with links to other QMS docs
for
cat
in
[
"
ADM
"
,
"
BIC
"
,
"
LAB
"
,
"
ROD
"
,
"
AQA
"
]:
filedata
=
filedata
.
replace
(
"
policies/
"
+
cat
+
"
/
"
,
"
https://howto.lcsb.uni.lu/?qms:
"
)
filedata
=
filedata
.
replace
(
"
sops/
"
+
cat
+
"
/
"
,
"
https://howto.lcsb.uni.lu/?qms:
"
)
# remove leading and trailing /
filedata
=
filedata
.
replace
(
"
/http
"
,
"
http
"
)
filedata
=
filedata
.
replace
(
"
/)
"
,
"
)
"
)
# Write the file out again
with
open
(
filename
,
'
w
'
)
as
file
:
file
.
write
(
filedata
)
...
...
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