Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
Bielefeld-CeBiTec-Temp-until-thaw
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package Registry
Model registry
Operate
Terraform modules
Analyze
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
Liliana Sanfilippo
Bielefeld-CeBiTec-Temp-until-thaw
Commits
f48da81c
Commit
f48da81c
authored
5 months ago
by
Kaya Lange
Browse files
Options
Downloads
Plain Diff
Merge branch 'main' of
ssh://gitlab.igem.org/2024/bielefeld-cebitec
parents
5eab495b
afe3c855
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
code/cit.py
+43
-19
43 additions, 19 deletions
code/cit.py
code/output.txt
+2
-2
2 additions, 2 deletions
code/output.txt
with
45 additions
and
21 deletions
code/cit.py
+
43
−
19
View file @
f48da81c
import
argparse
import
bibtexparser
import
re
# Voraussetzungen
#- Python 3.x
#- bibtexparser (Installieren Sie es mit `pip install bibtexparser`)
problemlist
=
[]
def
main
():
print
(
"
Starting program...
"
)
try
:
import
bibtexparser
except
ImportError
:
print
(
"
The package
'
bibtexparser
'
is not installed. Install with: pip install bibtexparser
"
)
exit
(
1
)
try
:
import
argparse
except
ImportError
:
print
(
"
The package
'
argparse
'
is not installed.
"
)
exit
(
1
)
try
:
import
re
except
ImportError
:
print
(
"
The package
'
re
'
is not installed.
"
)
exit
(
1
)
try
:
#reading command line input and parsing it
parser
=
argparse
.
ArgumentParser
(
prog
=
'
HTML Citations
'
,
description
=
'
create acessible HTML Citations from bib files
'
)
parser
.
add_argument
(
'
-i
'
,
'
--input
'
)
parser
.
add_argument
(
'
-i
'
,
'
--input
'
,
required
=
True
,
help
=
"
path to source bib
"
)
parser
.
add_argument
(
'
-s
'
,
'
--startnumber
'
,
required
=
True
,
help
=
"
number from which to start numbering
"
)
args
=
parser
.
parse_args
()
print
(
"
Source:
"
+
args
.
input
)
except
argparse
.
ArgumentError
as
e
:
...
...
@@ -21,6 +41,7 @@ def main():
print
(
f
"
An unexpected error occurred:
{
e
}
"
)
print
(
"
Reading file...
"
)
#reading and parsing the file
try
:
with
open
(
args
.
input
,
'
r
'
)
as
file
:
file_content
=
file
.
read
()
...
...
@@ -33,12 +54,15 @@ def main():
length
=
len
(
library
.
entries
)
print
(
"
found
"
+
str
(
length
)
+
"
entries
"
)
ran
=
range
(
length
)
startnum
=
int
(
args
.
startnumber
);
count
=
0
;
#processing every entry and writing the dictionary for it
for
x
in
ran
:
print
(
"
\n
Initializing empty dictionary for entry
"
+
str
(
x
+
1
)
+
"
...
"
)
print
(
"
\n
Initializing empty dictionary for entry
"
+
str
(
startnum
+
count
)
+
"
...
"
)
dictio
=
{}
en_x
=
library
.
entries
[
x
]
print
(
"
Filling dictionary for entry
"
+
str
(
x
+
1
)
+
""
)
print
(
"
Filling dictionary for entry
"
+
str
(
startnum
+
count
)
+
""
)
# Direkt auf die Einträge zugreifen, da es sich um ein Dictionary handelt
for
key
,
value
in
en_x
.
items
():
...
...
@@ -47,9 +71,9 @@ def main():
# Überprüfung auf den Typ des Eintrags über 'ENTRYTYPE'
if
en_x
[
'
ENTRYTYPE
'
]
==
"
article
"
:
articleHTML
(
dictio
,
x
,
out
)
articleHTML
(
dictio
,
(
startnum
+
count
)
,
out
)
elif
en_x
[
'
ENTRYTYPE
'
]
==
"
misc
"
:
miscHTML
(
dictio
,
x
,
out
)
miscHTML
(
dictio
,
(
startnum
+
count
)
,
out
)
except
Exception
as
e
:
...
...
@@ -71,9 +95,9 @@ def main():
def
articleHTML
(
dictio
,
x
,
out
):
print
(
"
Writing html code for entry
"
+
str
(
x
+
1
)
+
"
...
"
)
out
.
write
(
"
{/*<!-- Citation num
"
+
str
(
x
+
1
)
+
"
--> */}
"
+
"
\n
"
)
out
.
write
(
"
<li typeof=
\"
schema:ScolarlyArticle
\"
role=
\"
doc-biblioentry
\"
property=
\"
schema:citation
\"
id=
\"
desc-
"
+
str
(
x
+
1
)
+
"
\"
>
"
+
"
\n
"
)
print
(
"
Writing html code for entry
"
+
str
(
x
)
+
"
...
"
)
out
.
write
(
"
{/*<!-- Citation num
"
+
str
(
x
)
+
"
--> */}
"
+
"
\n
"
)
out
.
write
(
"
<li typeof=
\"
schema:ScolarlyArticle
\"
role=
\"
doc-biblioentry
\"
property=
\"
schema:citation
\"
id=
\"
desc-
"
+
str
(
x
)
+
"
\"
>
"
+
"
\n
"
)
out
.
write
(
"
\t
"
+
"
<span property=
\"
schema:author
\"
typeof=
\"
schema:Person
\"
>
"
+
"
\n
"
)
print
(
"
Just a sec, seperating authors...
"
)
...
...
@@ -137,16 +161,16 @@ def articleHTML(dictio, x, out):
out
.
write
(
"
\t
"
+
"
<span property=
\"
schema:pageBegin
\"
>
"
+
pages
+
"
</span>
"
+
"
\n
"
)
else
:
print
(
"
Sorry, no readable page information
"
)
problemlist
.
append
(
"
Check for missing page info at
"
+
str
(
x
+
1
))
problemlist
.
append
(
"
Check for missing page info at
"
+
str
(
x
))
else
:
print
(
"
Sorry, no page information
"
)
problemlist
.
append
(
"
Check for missing page info at
"
+
str
(
x
+
1
))
problemlist
.
append
(
"
Check for missing page info at
"
+
str
(
x
))
else
:
print
(
"
Sorry, no page information
"
)
problemlist
.
append
(
"
Check for missing page info at
"
+
str
(
x
+
1
))
problemlist
.
append
(
"
Check for missing page info at
"
+
str
(
x
))
except
KeyError
as
e
:
print
(
"
Sorry, no page information
"
)
problemlist
.
append
(
"
Check for missing page info at
"
+
str
(
x
+
1
))
problemlist
.
append
(
"
Check for missing page info at
"
+
str
(
x
))
year
=
dictio
[
'
year
'
]
out
.
write
(
"
\t
"
+
"
(<time property=
\"
schema:datePublished
\"
datatype=
\"
xsd:gYear
\"
dateTime=
\"
"
+
year
+
"
\"
>
"
+
year
+
"
</time>).
"
+
"
\n
"
)
...
...
@@ -156,15 +180,15 @@ def articleHTML(dictio, x, out):
out
.
write
(
"
\t
"
+
"
<a className=
\"
doi
\"
href=
\"
https://doi.org/
"
+
doi
+
"
\"
> doi:
"
+
doi
+
"
</a>
"
+
"
\n
"
)
except
KeyError
as
e
:
print
(
"
Sorry, no doi information
"
)
problemlist
.
append
(
"
Check for missing doi info at
"
+
str
(
x
+
1
))
problemlist
.
append
(
"
Check for missing doi info at
"
+
str
(
x
))
out
.
write
(
"
</li>
"
+
"
\n
"
+
"
\n
"
)
def
miscHTML
(
dictio
,
x
,
out
):
print
(
"
Writing html code for entry
"
+
str
(
x
+
1
)
+
"
...
"
)
out
.
write
(
"
#<!-- Citation num
"
+
str
(
x
+
1
)
+
"
-->
"
+
"
\n
"
)
out
.
write
(
"
<li typeof=
\"
schema:WebPage
\"
role=
\"
doc-biblioentry
\"
property=
\"
schema:citation
\"
id=
\"
desc-
"
+
str
(
x
+
1
)
+
"
\"
>
"
+
"
\n
"
)
print
(
"
Writing html code for entry
"
+
str
(
x
)
+
"
...
"
)
out
.
write
(
"
#<!-- Citation num
"
+
str
(
x
)
+
"
-->
"
+
"
\n
"
)
out
.
write
(
"
<li typeof=
\"
schema:WebPage
\"
role=
\"
doc-biblioentry
\"
property=
\"
schema:citation
\"
id=
\"
desc-
"
+
str
(
x
)
+
"
\"
>
"
+
"
\n
"
)
out
.
write
(
"
\t
"
+
"
<span property=
\"
schema:author
\"
typeof=
\"
schema:Organisation
\"
>
"
+
"
\n
"
)
aut
=
dictio
[
'
author
'
]
out
.
write
(
"
\t
"
+
"
\t
"
+
"
<span property=
\"
schema:Name
\"
>
"
+
aut
+
"
</span>.
"
+
"
\n
"
)
...
...
This diff is collapsed.
Click to expand it.
code/output.txt
+
2
−
2
View file @
f48da81c
{/*<!-- Citation num
1
--> */}
<li typeof="schema:ScolarlyArticle" role="doc-biblioentry" property="schema:citation" id="desc-
1
">
{/*<!-- Citation num
3
--> */}
<li typeof="schema:ScolarlyArticle" role="doc-biblioentry" property="schema:citation" id="desc-
3
">
<span property="schema:author" typeof="schema:Person">
<span property="schema:Name"> Roth, F.</span>;
<span property="schema:Name"> Draguhn, A.</span>
...
...
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