Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CiS Projekt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package 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
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ockenden, Samuel
CiS Projekt
Commits
718aacb6
Commit
718aacb6
authored
3 years ago
by
Suireen
Browse files
Options
Downloads
Patches
Plain Diff
README and Dokumentation in citation_parser_main
parent
b6691b33
No related branches found
No related tags found
1 merge request
!27
Main
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
citation_parser_main.py
+35
-11
35 additions, 11 deletions
citation_parser_main.py
with
35 additions
and
11 deletions
citation_parser_main.py
+
35
−
11
View file @
718aacb6
...
...
@@ -22,7 +22,7 @@ app = dash.Dash(__name__, external_stylesheets=[dbc.themes.SPACELAB])
additional_options
=
[
'
Update Automatically
'
,
'
Smart Input
'
]
# Reads the contents of info_box.txt.
# They can later be displayed by pressing the corresponding button.
# They can later be displayed by pressing the corresponding
"Show Info"
button.
f
=
open
(
'
info_box.txt
'
,
'
r
'
)
boxcontent
=
f
.
read
()
f
.
close
()
...
...
@@ -30,6 +30,7 @@ f.close()
app
.
layout
=
html
.
Div
([
html
.
Div
(
children
=
[
# Layer 0: For the Header and Help Function(s)
#Show Info button for showing Informations
dbc
.
Button
(
'
Show Info
'
,
id
=
'
collapse-button
'
,
...
...
@@ -37,6 +38,7 @@ html.Div(children=[
color
=
"
primary
"
,
n_clicks
=
0
,
),
#state is set to be collapsed at first
dbc
.
Collapse
(
dbc
.
Card
(
dbc
.
CardBody
(
html
.
Div
(
boxcontent
,
style
=
{
'
whiteSpace
'
:
'
pre-line
'
,
'
font-size
'
:
'
10px
'
}))),
id
=
'
collapse
'
,
...
...
@@ -72,14 +74,22 @@ html.Div(children=[
#Drag and drop or click to select a file to upload
[
"
Drag and drop
"
]),
style
=
{
<<<<<<<
HEAD
:
citation_parser_main
.
py
"
width
"
:
"
400px
"
,
=======
"
width
"
:
"
360px
"
,
>>>>>>>
main
:
citation_parser_ui
.
py
"
height
"
:
"
60px
"
,
"
lineHeight
"
:
"
60px
"
,
"
borderWidth
"
:
"
1px
"
,
"
borderStyle
"
:
"
dashed
"
,
"
borderRadius
"
:
"
5px
"
,
"
textAlign
"
:
"
center
"
,
<<<<<<<
HEAD
:
citation_parser_main
.
py
"
margin
"
:
"
10px
"
,
=======
"
margin
"
:
"
10px
"
>>>>>>>
main
:
citation_parser_ui
.
py
}),
size
=
"
lg
"
,
color
=
"
primary
"
,
type
=
"
border
"
,
fullscreen
=
True
,),
]),
...
...
@@ -105,17 +115,28 @@ html.Div(children=[
dcc
.
Checklist
(
id
=
'
additional-options
'
,
options
=
[{
'
label
'
:
k
,
'
value
'
:
k
}
for
k
in
additional_options
],
value
=
[],
labelStyle
=
dict
(
display
=
'
block
'
))
<<<<<<<
HEAD
:
citation_parser_main
.
py
]),
=======
],
style
=
{
'
margin-top
'
:
"
50px
"
}),
>>>>>>>
main
:
citation_parser_ui
.
py
],
style
=
{
'
padding
'
:
10
,
'
flex
'
:
0.8
}),
html
.
Div
(
children
=
[
# Layer 5: For the Graph and corresponding error messages
dbc
.
Spinner
(
html
.
Div
([
<<<<<<<
HEAD
:
citation_parser_main
.
py
html
.
Div
(
id
=
'
generate-graph-error
'
,
style
=
{
'
color
'
:
'
red
'
}),
html
.
Iframe
(
src
=
"
assets/index.html
"
,
style
=
{
"
height
"
:
"
650px
"
,
"
width
"
:
"
100%
"
},
=======
html
.
Div
(
id
=
'
generate-graph-error
'
,
style
=
{
'
color
'
:
'
red
'
,
'
position
'
:
"
absolute
"
,
'
margin-top
'
:
"
650px
"
}),
html
.
Iframe
(
src
=
"
assets/index.html
"
,
style
=
{
"
height
"
:
"
650px
"
,
"
width
"
:
"
1000px
"
},
>>>>>>>
main
:
citation_parser_ui
.
py
),
]),
size
=
"
lg
"
,
color
=
"
primary
"
,
type
=
"
border
"
,
fullscreen
=
True
,),
],
style
=
{
'
padding
'
:
10
,
'
flex
'
:
1.2
})
...
...
@@ -165,11 +186,7 @@ def update_input_checklist(input_value,btn1,btn2,filecontents,all_inputs,
# if clear-all-button was pressed:
if
'
clear-all-button
'
in
changed_id
:
# the try/except is needed so that clear-all may be used even if there is no json-file
try
:
os
.
remove
(
'
assets/json_text.json
'
)
except
:
pass
os
.
remove
(
'
assets/json_text.json
'
)
return
list
(),
list
(),
''
,
''
# if clear-selected-button was pressed:
...
...
@@ -248,10 +265,12 @@ def update_input_checklist(input_value,btn1,btn2,filecontents,all_inputs,
)
def
toggle_collapse
(
n
,
is_open
):
'''
This callback shows and hides the (first) info-box by, checking how often
the button has been pressed. The text was loaded at the top.
:param n_clicks: number of times show-info has been clicked.
'
type n_clicks: int
This callback shows and hides the info-box. The text was loaded at the top from an extern .txt.
:param n: number of times show-info has been clicked.
:type n: int
:param is_open state of the show-info button
:type is_open: boolean
'''
if
n
:
return
not
is_open
...
...
@@ -286,17 +305,22 @@ def generate_output(n_clicks,all_inputs,forward_depth,backward_depth,additional_
changed_id
=
[
p
[
'
prop_id
'
]
for
p
in
callback_context
.
triggered
][
0
]
if
n_clicks
is
None
:
raise
PreventUpdate
# This branch is entered when 'Generate Graph' is pushed or 'Update Automatically' is selected
# and the checklist or recursion depths are changed.
elif
'
Update Automatically
'
in
additional_options
\
or
'
start-button
'
in
changed_id
:
input_links
=
[
x
[
'
value
'
]
for
x
in
all_inputs
]
# Processing only returns a potential error message. The data for the graph is simply saved
# in the specified file.
errors
=
Processing
(
input_links
,
int
(
forward_depth
),
int
(
backward_depth
),
'
assets/json_text.json
'
)
if
errors
:
# This construct is needed because dash removes white spaces and newlines when concatinating
# strings with '\n'.join(...) or similar methods.
message
=
[
'
The following inputs are invalid and were not used:
'
]
for
error
in
errors
:
message
.
append
(
html
.
Br
())
message
.
append
(
error
)
message
=
html
.
P
(
message
)
#message = [html.P(error) for error in errors]
return
message
if
__name__
==
'
__main__
'
:
...
...
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