Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mason-today-web
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
8
Issues
8
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SRCT
mason-today-web
Commits
32032477
Commit
32032477
authored
Jul 15, 2018
by
Robert Hitt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored to make things more pythonic
parent
978a89fa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
30 deletions
+23
-30
mason-today/parscript.py
mason-today/parscript.py
+23
-30
No files found.
mason-today/parscript.py
View file @
32032477
...
...
@@ -4,6 +4,20 @@
from
bs4
import
BeautifulSoup
import
requests
_MONTH_DICT
=
{
"January"
:
1
,
"Febuary"
:
2
,
"March"
:
3
,
"April"
:
4
,
"May"
:
5
,
"June"
:
6
,
"July"
:
7
,
"August"
:
8
,
"September"
:
9
,
"October"
:
10
,
"November"
:
11
,
"December"
:
12
}
# this function cleans up some of the useless html leftovers to characters we can actually use
def
cleanup
(
dirtystring
):
...
...
@@ -26,7 +40,7 @@ def cleanup(dirtystring):
dirtystring
=
dirtystring
.
replace
(
replacement
[
0
],
replacement
[
1
])
return
dirtystring
[:
-
1
]
# Simple event quality test
def
qualityTest
(
desc
):
# none, bad, okay, good
...
...
@@ -42,7 +56,7 @@ def qualityTest(desc):
return
"good"
elif
length
<
100
:
return
"verygood"
else
:
else
:
return
"excellent"
# convertTime accepts strings in the form of ""
...
...
@@ -81,39 +95,18 @@ def convertTime(stri): # this function is used for splicing the event times.
def
filter_data_into_days
(
dictlist
):
new_dictlist
=
{}
date_reference
=
""
for
event
in
dictlist
:
if
"error"
in
event
:
if
"error"
in
event
:
continue
event_date
=
event
[
"dayofmonth"
]
+
"/"
+
str
(
month_to_number
(
event
[
"month"
]))
+
"/"
+
event
[
"year"
]
event_date
=
"{}/{}/{}"
.
format
(
event
[
"dayofmonth"
],
_MONTH_DICT
[
event
[
"month"
]],
event
[
"year"
])
if
event_date
in
new_dictlist
:
new_dictlist
[
event_date
].
append
(
event
)
else
:
else
:
new_dictlist
[
event_date
]
=
[
event
]
return
new_dictlist
def
month_to_number
(
month
):
month_dict
=
{
"January"
:
1
,
"Febuary"
:
2
,
"March"
:
3
,
"April"
:
4
,
"May"
:
5
,
"June"
:
6
,
"July"
:
7
,
"August"
:
8
,
"September"
:
9
,
"October"
:
10
,
"November"
:
11
,
"December"
:
12
}
try
:
out
=
month_dict
[
month
]
return
out
except
:
raise
Exception
(
"Invalid month to convert to number"
)
def
load_data
():
"""
...
...
@@ -309,7 +302,7 @@ def load_data():
"year"
:
year
,
"timestart"
:
timestart
,
"timestop"
:
timestop
,
"location"
:
location
,
"description"
:
description
})
else
:
dictlist
.
append
({
"id"
:
uniqueid
,
"error"
:
error
})
return
filter_data_into_days
(
dictlist
)
# everything in the house is fuzzy, stupid dogs were acting like pollinators, if that's how you even spell it
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment