Skip to content
This repository has been archived by the owner on May 25, 2023. It is now read-only.

Commit

Permalink
Remove all python3 incompatible decode functions
Browse files Browse the repository at this point in the history
  • Loading branch information
edwinvandeven committed Jul 30, 2019
1 parent 4628963 commit 70f0255
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 38 deletions.
16 changes: 8 additions & 8 deletions controllers/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1825,16 +1825,16 @@ def writer_location(locID=None):

time = repr_row.classes.Starttime + " - " + repr_row.classes.Endtime
if locID is None:
class_data += location.decode('utf-8') + "\n" + \
class_data += location + "\n" + \
time + " \n" + \
classtype.decode('utf-8') + " \n" + \
teacher.decode('utf-8') + " \n" + \
teacher2.decode('utf-8') + " \n"
classtype + " \n" + \
teacher + " \n" + \
teacher2 + " \n"
else:
class_data += time + " \n" + \
classtype.decode('utf-8') + " \n" + \
teacher.decode('utf-8') + " \n" + \
teacher2.decode('utf-8') + " \n"
classtype + " \n" + \
teacher + " \n" + \
teacher2 + " \n"
c_id = get_cell_id(col, r)
ws[c_id] = class_data
ws[c_id].font = font
Expand All @@ -1861,7 +1861,7 @@ def writer_location(locID=None):
orderby=db.school_locations.Name)
for row in rows:
location = locations_dict.get(row.id, None)
title = location.decode('utf-8')[0:30]
title = location[0:30]
ws = wb.create_sheet(title=title)
ws['A1'] = "Schedule" + " " + title + " " + \
"week " + str(iso_week)
Expand Down
6 changes: 3 additions & 3 deletions controllers/staff.py
Original file line number Diff line number Diff line change
Expand Up @@ -1105,11 +1105,11 @@ def writer_location(locID=None):
employee2 = repr_row.shifts_otc.auth_employee_id2

try:
employee = employee.decode('utf-8')
employee = employee
except AttributeError:
employee = ''
try:
employee2 = employee2.decode('utf-8')
employee2 = employee2
except AttributeError:
employee2 = ''

Expand Down Expand Up @@ -1156,7 +1156,7 @@ def writer_location(locID=None):
orderby=db.school_locations.Name)
for row in rows:
location = locations_dict.get(row.id, None)
title = location.decode('utf-8')[0:30]
title = location[0:30]
ws = wb.create_sheet(title=title)
ws['A1'] = "Schedule" + " " + location + " " + \
"week " + str(iso_week)
Expand Down
4 changes: 2 additions & 2 deletions modules/openstudio/os_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,12 @@ def _get_modal_button(self,
button_xml += ' id="' + button_id + '" '
if button_title:
try:
button_xml += ' title="' + button_title.decode('utf-8') + '" '
button_xml += ' title="' + button_title + '" '
except:
button_xml += ' title="' + button_title + '" '
button_xml += 'data-toggle="modal" data-target=".' + modal_class + '"> '
try:
button_xml += button_text.decode('utf-8')
button_xml += button_text
except AttributeError:
# button_xml might be XML() or other object that doesn't have a decode method
button_xml += button_text
Expand Down
2 changes: 1 addition & 1 deletion modules/openstudio/os_receipt.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ def _get_print_display_get_logo(var=None):
# iiID = db.receipts_items.insert(
# receipts_id=self.receipts_id,
# ProductName=T("Class card"),
# Description=classcard.name.decode('utf-8') + u' (' + T("Class card") + u' ' + unicode(ccdID) + u')',
# Description=classcard.name + u' (' + T("Class card") + u' ' + unicode(ccdID) + u')',
# Quantity=1,
# Price=price,
# Sorting=next_sort_nr,
Expand Down
2 changes: 1 addition & 1 deletion tests/controllers/test_02_default_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
# assert client.status == 200
#
# assert mst_name in client.text
# assert unicode(monthly_fee*2) in client.text.decode('utf-8') # check whether total works
# assert unicode(monthly_fee*2) in client.text # check whether total works
#
#
# def test_workshop_payments(client, web2py):
Expand Down
46 changes: 23 additions & 23 deletions tests/controllers/test_20_api_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def test_schedule_get_extension_error():
"""
url = base_url + '/api/schedule_get'
with urllib.request.urlopen(url) as page:
content = page.read().decode('utf-8')
content = page.read()
assert "Extension error" in content


Expand All @@ -123,7 +123,7 @@ def test_schedule_get_days_extension_error():
"""
url = base_url + '/api/schedule_get_days'
with urllib.request.urlopen(url) as page:
content = page.read().decode('utf-8')
content = page.read()
assert "Extension error" in content


Expand All @@ -133,7 +133,7 @@ def test_workshops_get_extension_error():
"""
url = base_url + '/api/workshops_get'
with urllib.request.urlopen(url) as page:
content = page.read().decode('utf-8')
content = page.read()
assert "Extension error" in content


Expand All @@ -145,7 +145,7 @@ def test_schedule_get_authentication_error():
url = base_url + \
'/api/schedule_get.json?user=test&key=test&year=2014&week=1'
with urllib.request.urlopen(url) as page:
content = page.read().decode('utf-8')
content = page.read()
assert "Authentication error" in content


Expand All @@ -157,7 +157,7 @@ def test_schedule_get_days_authentication_error():
url = base_url + \
'/api/schedule_get_days.json?user=test&key=test&date_start=2014-01-01&date_end=2014-01-06'
with urllib.request.urlopen(url) as page:
content = page.read().decode('utf-8')
content = page.read()
assert "Authentication error" in content


Expand All @@ -169,7 +169,7 @@ def test_workshops_get_authentication_error():
url = base_url + \
'/api/workshops_get.json?user=test&key=test'
with urllib.request.urlopen(url) as page:
content = page.read().decode('utf-8')
content = page.read()
assert "Authentication error" in content


Expand All @@ -180,7 +180,7 @@ def test_schedule_get_value_error():
url = base_url + \
'/api/schedule_get.json?user=test&key=test&year=bla&week=bla'
with urllib.request.urlopen(url) as page:
content = page.read().decode('utf-8')
content = page.read()
assert "Value error" in content


Expand All @@ -191,7 +191,7 @@ def test_schedule_get_days_value_error():
url = base_url + \
'/api/schedule_get_days.json?user=test&key=test&date_start=2000&date_end=2014-01-06'
with urllib.request.urlopen(url) as page:
content = page.read().decode('utf-8')
content = page.read()
assert "Missing value" in content


Expand All @@ -202,7 +202,7 @@ def test_schedule_get_missing_value():
url = base_url + \
'/api/schedule_get.json'
with urllib.request.urlopen(url) as page:
content = page.read().decode('utf-8')
content = page.read()
assert "Missing value" in content


Expand All @@ -213,7 +213,7 @@ def test_schedule_get_days_missing_value():
url = base_url + \
'/api/schedule_get_days.json'
with urllib.request.urlopen(url) as page:
content = page.read().decode('utf-8')
content = page.read()
assert "Missing value" in content


Expand Down Expand Up @@ -271,7 +271,7 @@ def test_schedule_get_json(client, web2py):
url = base_url + \
'/api/schedule_get.json?user=test&key=test&year=2014&week=3'
with urllib.request.urlopen(url) as page:
content = page.read().decode('utf-8')
content = page.read()

json = sj.loads(content)

Expand All @@ -292,7 +292,7 @@ def test_schedule_get_json(client, web2py):
url = base_url + \
'/api/schedule_get.json?user=test&key=test&year=2014&week=4'
with urllib.request.urlopen(url) as page:
content = page.read().decode('utf-8')
content = page.read()

json = sj.loads(content)

Expand All @@ -304,7 +304,7 @@ def test_schedule_get_json(client, web2py):
url = base_url + \
'/api/schedule_get.json?user=test&key=test&year=2014&week=5'
with urllib.request.urlopen(url) as page:
content = page.read().decode('utf-8')
content = page.read()

json = sj.loads(content)

Expand All @@ -316,7 +316,7 @@ def test_schedule_get_json(client, web2py):
url = base_url + \
'/api/schedule_get.json?user=test&key=test&year=2014&week=2&TeacherID=' + str(teID)
with urllib.request.urlopen(url) as page:
content = page.read().decode('utf-8')
content = page.read()

json = sj.loads(content)

Expand All @@ -337,7 +337,7 @@ def test_shedule_get_days_json(client, web2py):
url = base_url + \
'/api/schedule_get_days.json?user=test&key=test&date_start=2014-01-06&date_end=2014-01-06'
with urllib.request.urlopen(url) as page:
content = page.read().decode('utf-8')
content = page.read()
json = sj.loads(content)


Expand All @@ -361,7 +361,7 @@ def test_shedule_get_days_json(client, web2py):
url = base_url + \
'/api/schedule_get_days.json?user=test&key=test&date_start=2014-01-13&date_end=2014-01-13'
with urllib.request.urlopen(url) as page:
content = page.read().decode('utf-8')
content = page.read()
json = sj.loads(content)

assert json['data']['schedule'][0]['date'] == '2014-01-13'
Expand All @@ -380,7 +380,7 @@ def test_shedule_get_days_json(client, web2py):
url = base_url + \
'/api/schedule_get_days.json?user=test&key=test&date_start=2014-01-20&date_end=2014-01-20'
with urllib.request.urlopen(url) as page:
content = page.read().decode('utf-8')
content = page.read()
json = sj.loads(content)

assert json['data']['schedule'][0]['date'] == '2014-01-20'
Expand All @@ -391,7 +391,7 @@ def test_shedule_get_days_json(client, web2py):
url = base_url + \
'/api/schedule_get_days.json?user=test&key=test&date_start=2014-01-27&date_end=2014-01-27'
with urllib.request.urlopen(url) as page:
content = page.read().decode('utf-8')
content = page.read()
json = sj.loads(content)

assert json['data']['schedule'][0]['date'] == '2014-01-27'
Expand All @@ -407,7 +407,7 @@ def test_workshops_get_json(client, web2py):
# Check if workshop is in the list
url = base_url + '/api/workshops_get.json?user=test&key=test'
with urllib.request.urlopen(url) as page:
content = page.read().decode('utf-8')
content = page.read()
json = sj.loads(content)

workshop = web2py.db.workshops(1)
Expand Down Expand Up @@ -437,7 +437,7 @@ def test_workshop_get_json(client, web2py):
# Check if workshop is in the list
url = base_url + '/api/workshop_get.json?user=test&key=test&id=1'
with urllib.request.urlopen(url) as page:
content = page.read().decode('utf-8')
content = page.read()

json = sj.loads(content)

Expand Down Expand Up @@ -489,7 +489,7 @@ def test_school_subscriptions_get_json(client, web2py):

url = base_url + '/api/school_subscriptions_get.json?user=test&key=test'
with urllib.request.urlopen(url) as page:
content = page.read().decode('utf-8')
content = page.read()
json = sj.loads(content)

subscription = web2py.db.school_subscriptions(1)
Expand All @@ -508,7 +508,7 @@ def test_school_classcards_get_json(client, web2py):

url = base_url + '/api/school_classcards_get.json?user=test&key=test'
with urllib.request.urlopen(url) as page:
content = page.read().decode('utf-8')
content = page.read()
json = sj.loads(content)

classcard = web2py.db.school_classcards(1)
Expand All @@ -527,7 +527,7 @@ def test_school_teachers_get_json(client, web2py):

url = base_url + '/api/school_teachers_get.json?user=test&key=test'
with urllib.request.urlopen(url) as page:
content = page.read().decode('utf-8')
content = page.read()
json = sj.loads(content)

teacher = web2py.db.auth_user(2)
Expand Down

0 comments on commit 70f0255

Please sign in to comment.