Browse Source

fix various errors related to switching to python3

master
wes 8 years ago
parent
commit
f3ca7429e3
  1. 2
      src/mcmaster/classes.py
  2. 2
      src/mcmaster/sylla.py
  3. 2
      src/openlibrary.py
  4. 12
      src/search.py
  5. 2
      src/website.py

2
src/mcmaster/classes.py

@ -238,7 +238,7 @@ class MosReq(object):
# Let the server set some cookies before doing the searching
cookies = {}
for key, val in s.cookies.iteritems():
for key, val in s.cookies.items():
cookies[key] = val
self.cookies = cookies
self.statenum = False

2
src/mcmaster/sylla.py

@ -70,7 +70,7 @@ def books(dept, code, withPrices):
pricelist = prices(parsed)
for div in parsed.xpath(".//div"):
if (div.attrib.has_key("id") and
if ("id" in div.attrib and
"prodDesc" in div.attrib["id"]):
textbook = div.text_content()

2
src/openlibrary.py

@ -15,7 +15,7 @@ def bookUrls(title, author):
requrl = searchurl % (quote(author), quote(title))
results = loads(req.get(requrl).text)
for result in results["docs"][0:2]:
if result.has_key("edition_key"):
if "edition_key" in result:
yield "https://openlibrary.org/books/%s" % result["edition_key"][0]
# 'http://openlibrary.org/query.json?type=/type/edition&title=The+Personality+Puzzle'

12
src/search.py

@ -13,6 +13,8 @@ from syslog import syslog
from textbookExceptions import UnIndexable
from functools import reduce
# Generic instance of elasticsearch right now
es = elasticsearch.Elasticsearch()
@ -168,8 +170,8 @@ def searchTerms(terms):
# A list of all the queries we want to run
qs = [searchers[field](term) for
field, term in
terms.iteritems() if
term and searchers.has_key(field)]
terms.items() if
term and field in searchers]
if not qs:
# No queries = no results
@ -202,9 +204,9 @@ def searchTerms(terms):
if obj.books:
secs["books"] = [
{
"booktitle" : summarize(book[0].encode("ASCII")),
"bookauthor" : book[1].encode("ASCII"),
"bookprice" : book[2].encode("ASCII")
"booktitle" : summarize(book[0]),
"bookauthor" : book[1],
"bookprice" : book[2]
}
for book in obj.books
]

2
src/website.py

@ -91,7 +91,7 @@ def ClassSearch(configfile=None):
""" Filter Courses """
print("trying to get courses")
params = dict(request.args.items())
for key, val in params.iteritems():
for key, val in params.items():
if val in defaults:
del params[key]
results = searchTerms(params)

Loading…
Cancel
Save