Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Armory Dashboard
Manage
Activity
Members
Labels
Plan
Issues
1
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
Anton Sarukhanov
Armory Dashboard
Commits
d3da3019
Commit
d3da3019
authored
8 years ago
by
Anton Sarukhanov
Browse files
Options
Downloads
Patches
Plain Diff
Count checked-in fencers
parent
65aabd8d
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
scrape.py
+21
-5
21 additions, 5 deletions
scrape.py
templates/index.html
+8
-1
8 additions, 1 deletion
templates/index.html
with
29 additions
and
6 deletions
scrape.py
+
21
−
5
View file @
d3da3019
...
...
@@ -2,6 +2,7 @@ from lxml import html
import
requests
import
re
from
urllib.parse
import
urlparse
,
urljoin
from
itertools
import
repeat
def
scrape
():
...
...
@@ -29,38 +30,53 @@ def scrape():
event_time
=
event_details
[
1
]
if
event_tree
.
xpath
(
'
//a[text()=
"
Final Results
"
]
'
):
fencers
=
event_tree
.
xpath
(
'
//div[@id=
"
finalResults
"
]/table/tr/td[2]/text()
'
)
fencers
=
dict
(
zip
(
fencers
,
repeat
(
"
Checked In
"
)))
event_status
=
"
Event Closed ({0} fencers)
"
.
format
(
len
(
fencers
))
elif
event_tree
.
xpath
(
'
//a[text()=
"
Seeding
"
]
'
):
fencers
=
event_tree
.
xpath
(
'
//div[@id=
"
Round1Seeding
"
]/table/tr/td[2]/text()
'
)
fencers
=
dict
(
zip
(
fencers
,
repeat
(
"
Checked In
"
)))
event_status
=
"
Event is Ongoing ({0} fencers)
"
.
format
(
len
(
fencers
))
elif
event_tree
.
xpath
(
'
//a[text()=
"
Check-In Status
"
]
'
):
event_status
=
event_tree
.
xpath
(
'
normalize-space(//div[@class=
"
checkInSummary
"
]/text())
'
)
fencers_checked_in
=
event_tree
.
xpath
(
'
//div[@id=
"
checkIn
"
]/table/tr/td[1]/text()
'
)
fencers
=
event_tree
.
xpath
(
'
//div[@id=
"
checkIn
"
]/table/tr/td[2]/text()
'
)
fencers
=
dict
(
zip
(
fencers
,
fencers_checked_in
))
try
:
del
this_event
except
:
pass
pass
# not yet set, oh well
this_event
=
{
'
name
'
:
event_name
,
'
time
'
:
event_time
,
'
status
'
:
event_status
,
'
fencers
'
:
[],
'
fencers_checked_in
'
:
[],
'
new_fencers_not_checked_in
'
:
[],
'
previously_fenced
'
:
{},
'
previous_total
'
:
0
}
for
fencer
in
fencers
:
this_event
[
'
fencers
'
].
append
(
fencer
.
strip
())
for
fencer
,
is_checked_in
in
fencers
.
items
():
is_checked_in
=
bool
(
is_checked_in
.
strip
())
fencer
=
fencer
.
strip
()
this_event
[
'
fencers
'
].
append
(
fencer
)
if
is_checked_in
:
this_event
[
'
fencers_checked_in
'
].
append
(
fencer
)
else
:
this_event
[
'
new_fencers_not_checked_in
'
].
append
(
fencer
)
for
e
in
events
:
if
e
[
'
name
'
]
==
event_details
:
continue
if
fencer
.
strip
()
in
e
[
'
fencers
'
]:
if
fencer
in
e
[
'
fencers
'
]:
if
e
[
'
name
'
]
in
this_event
[
'
previously_fenced
'
]:
this_event
[
'
previously_fenced
'
][
e
[
'
name
'
]]
+=
1
else
:
this_event
[
'
previously_fenced
'
][
e
[
'
name
'
]]
=
1
this_event
[
'
previous_total
'
]
+=
1
try
:
this_event
[
'
new_fencers_not_checked_in
'
].
remove
(
fencer
)
except
ValueError
:
pass
# already removed; ignore
break
events
.
append
(
this_event
)
# TODO: Tally fencers who have checked in
return
(
tournament_name
,
tournament_details
,
events
)
This diff is collapsed.
Click to expand it.
templates/index.html
+
8
−
1
View file @
d3da3019
...
...
@@ -6,10 +6,11 @@
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
>
<style>
body
{
font
:
1
4
px
sans-serif
;
font
:
1
8
px
sans-serif
;
}
section
{
border-bottom
:
1px
dashed
#aaa
;
margin
:
1em
0
;
}
h1
,
h2
,
h3
,
h4
,
h5
,
h6
{
margin
:
.35em
0
;
...
...
@@ -27,6 +28,9 @@
text-decoration
:
underline
;
color
:
#000
;
}
.hl
{
background-color
:
#ee8
;
}
</style>
</head>
<body>
...
...
@@ -48,6 +52,9 @@
{% endfor %}
</ul>
{% endif %}
{% if e['new_fencers_not_checked_in'] %}
<p
class=
"hl"
>
{{e['new_fencers_not_checked_in']|length}} new fencers not yet checked in
</p>
{% endif %}
</section>
{% endfor %}
</body>
...
...
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