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
139422c1
Commit
139422c1
authored
Jan 27, 2018
by
Aaron R Poulter-martinez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
small edit to make sure all locations are lists
parent
f238ea0e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
34 deletions
+61
-34
README.md
README.md
+3
-1
pscripts/parscript.py
pscripts/parscript.py
+58
-33
No files found.
README.md
View file @
139422c1
...
...
@@ -6,4 +6,6 @@ We make soup. A lot of it.
This is currently licensed under the "wut" license. Plznosteal
wutz a git
Step 1 - xml parsing to create a massive dictionary of objects
Step 2 - figure out how create an implement tag system
Step 3 - Create a web page that list out all the events and change what are present and what aren't based on tag system
pscripts/parscript.py
View file @
139422c1
...
...
@@ -5,6 +5,20 @@ import requests
eventDict
=
{}
DaysOfWeek
=
{
"Sunday"
:
0
,
"Monday"
:
1
,
"Tuesday"
:
2
,
"Wednesday"
:
3
,
"Thursday"
:
4
,
"Friday"
:
5
,
"Saturday"
:
6
,
}
notProvide
=
"Not not provided"
counter
=
0
class
Event
:
def
__init__
(
self
,
entryTag
):
#where var entryTag is a specific event tag
self
.
__name
=
entryTag
.
find
(
'title'
).
string
...
...
@@ -48,6 +62,17 @@ def cleancontent(str):
str
=
str
[
0
:
len
(
str
)
-
1
]
return
str
class
eventException
:
def
__init__
(
self
,
message
):
self
.
__message
=
message
self
.
__exceptionlist
=
[]
def
__str__
(
self
):
return
self
.
__exceptionlist
xmldoc
=
requests
.
get
(
"http://25livepub.collegenet.com/calendars/events_all.xml"
)
#grabs the xml from 25live
#xmldoc = open("events.xml", "r") #Opens a local document. events.xml is a shortened version of the larger events doc
...
...
@@ -109,54 +134,40 @@ for entry in entries:
#(F) if the length of the list = 3 and date is index [1] --> location is given at [0] and description is given at [2]
#the two if statements finds the date string. The date string always starts with
#Monday Tuesday Wednesday Thursday Friday Saturday Sunday or Ongoing and the date
#is always on either [0] or [1]
if
(
#see (A) above
entry_detailes
[
0
][
0
:
6
]
==
"Monday"
or
entry_detailes
[
0
][
0
:
7
]
==
"Tuesday"
or
entry_detailes
[
0
][
0
:
9
]
==
"Wednesday"
or
entry_detailes
[
0
][
0
:
8
]
==
"Thursday"
or
entry_detailes
[
0
][
0
:
6
]
==
"Friday"
or
entry_detailes
[
0
][
0
:
8
]
==
"Saturday"
or
entry_detailes
[
0
][
0
:
6
]
==
"Sunday"
or
entry_detailes
[
0
][
0
:
7
]
==
"Ongoing"
):
#see (A) above
if
entry_detailes
[
0
].
split
(
","
)[
0
]
in
DaysOfWeek
:
#See (B)
if
len
(
entry_detailes
)
==
1
:
location
=
"no location"
location
=
notProvide
date
=
entry_detailes
[
0
]
description
=
"no description"
description
=
notProvide
#see (C)
elif
len
(
entry_detailes
)
==
2
:
location
=
"no location"
location
=
notProvide
date
=
entry_detailes
[
0
]
description
=
entry_detailes
[
1
]
#This extra case was made because one entry had the description split into two by a
#newline so it registered as two descriptions making the length = 3
elif
len
(
entry_detailes
)
==
3
:
location
=
"no location"
location
=
notProvide
date
=
entry_detailes
[
0
]
description
=
entry_detailes
[
1
]
+
" "
+
entry_detailes
[
2
]
#this will print if the code has failed to account for something in detailes, but it works as of December 26th 2017
else
:
print
"wut, this hsouldn't print plz halp,"
elif
(
#see (D) above
entry_detailes
[
1
][
0
:
6
]
==
"Monday"
or
entry_detailes
[
1
][
0
:
7
]
==
"Tuesday"
or
entry_detailes
[
1
][
0
:
9
]
==
"Wednesday"
or
entry_detailes
[
1
][
0
:
8
]
==
"Thursday"
or
entry_detailes
[
1
][
0
:
6
]
==
"Friday"
or
entry_detailes
[
1
][
0
:
8
]
==
"Saturday"
or
entry_detailes
[
1
][
0
:
6
]
==
"Sunday"
or
entry_detailes
[
1
][
0
:
7
]
==
"Ongoing"
):
raise
eventException
(
"failed to account for detail in entry_detailes when date element is index 0 on entry_detailes list"
)
#see (D) above
elif
entry_detailes
[
1
].
split
(
","
)[
0
]
in
DaysOfWeek
:
#See (E)
if
len
(
entry_detailes
)
==
2
:
location
=
entry_detailes
[
0
]
date
=
entry_detailes
[
1
]
description
=
"no description given"
description
=
notProvide
#See (F)
elif
len
(
entry_detailes
)
==
3
:
location
=
entry_detailes
[
0
]
...
...
@@ -170,15 +181,29 @@ for entry in entries:
description
=
entry_detailes
[
2
]
+
" "
+
entry_detailes
[
3
]
#this will print if the code has failed to account for something in detailes
else
:
print
"wut, this hsouldn't print plz halp"
raise
eventException
(
"failed to account for detail in entry_detailes when date element is index 1 on entry_detailes list"
)
#this will print if the above if statements failed to find the date block
else
:
print
"if this prints there is something wrong please don't show up"
print
"-----------------------------------------------------------------------------"
raise
eventException
(
"failed to find and account for date element in entry_detailes list"
)
if
"Fairfax Campus"
in
location
:
location
=
location
.
split
(
", Fairfax Campus"
)
campus
=
"Fairfax"
elif
"Arlington Campus"
in
location
:
location
=
location
.
split
(
", Arlington Campus"
)
campus
=
"Arlington"
else
:
location
=
[
location
]
#print "-----------------------------------------------------------------------------"
#print entry_title
print
location
print
date
print
description
#print campus
#print date
#print description
print
"----------------------------------------------------------------------------"
...
...
@@ -193,4 +218,4 @@ for entry in entries:
#everything in the house is fuzzy
\ No newline at end of file
#everything in the house is fuzzy, stupid dogs were acting like pollinators, if that's how you even spell it
\ No newline at end of file
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