FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Remove some more unicode literals · python-webuntis/python-webuntis@94dc88f · GitHub

Commit 94dc88f

Browse files
committed
Remove some more unicode literals
1 parent 6ca872b commit 94dc88f

5 files changed

Lines changed: 53 additions & 56 deletions

File tree

‎webuntis/errors.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
:license: BSD, see LICENSE for more details.
66
'''
77

8-
from __future__ import unicode_literals
9-
108

119
class Error(Exception):
1210
'''Superclass for all `python-webuntis`-specific errors, never gets raised

‎webuntis/objects.py‎

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
:license: BSD, see LICENSE for more details.
66
'''
77

8-
from __future__ import unicode_literals
98
from webuntis.utils import datetime_utils, lazyproperty, \
109
timetable_utils
1110

@@ -48,7 +47,7 @@ def id(self):
4847
An ID is needed for the object to be hashable. Therefore a result
4948
may bring its own implementation of this method even though the
5049
original API response didn't contain any ID.'''
51-
return self._data['id'] if 'id' in self._data else None
50+
return self._data[u'id'] if 'id' in self._data else None
5251

5352
def __int__(self):
5453
'''This is useful if the users pass a ListItem when a numerical ID
@@ -162,12 +161,12 @@ class DepartmentObject(ListItem):
162161
@lazyproperty
163162
def name(self):
164163
'''short name such as *R1A*'''
165-
return self._data['name']
164+
return self._data[u'name']
166165

167166
@lazyproperty
168167
def long_name(self):
169168
'''Long name, such as *Raum Erste A*. Not predictable.'''
170-
return self._data['longName']
169+
return self._data[u'longName']
171170

172171

173172
class DepartmentList(ListResult):
@@ -182,22 +181,22 @@ class HolidayObject(ListItem):
182181
@lazyproperty
183182
def start(self):
184183
'''The start date of the holiday, as a datetime object.'''
185-
return datetime_utils.parse_date(self._data['startDate'])
184+
return datetime_utils.parse_date(self._data[u'startDate'])
186185

187186
@lazyproperty
188187
def end(self):
189188
'''The end of the holiday'''
190-
return datetime_utils.parse_date(self._data['endDate'])
189+
return datetime_utils.parse_date(self._data[u'endDate'])
191190

192191
@lazyproperty
193192
def name(self):
194193
'''Name, such as *Nationalfeiertag*.'''
195-
return self._data['longName']
194+
return self._data[u'longName']
196195

197196
@lazyproperty
198197
def short_name(self):
199198
'''Abbreviated form of the name'''
200-
return self._data['name']
199+
return self._data[u'name']
201200

202201

203202
class HolidayList(ListResult):
@@ -212,12 +211,12 @@ class KlassenObject(ListItem):
212211
@lazyproperty
213212
def name(self):
214213
'''Name of class'''
215-
return self._data['name']
214+
return self._data[u'name']
216215

217216
@lazyproperty
218217
def long_name(self):
219218
'''Long name of class'''
220-
return self._data['longName']
219+
return self._data[u'longName']
221220

222221

223222
class KlassenList(ListResult):
@@ -234,17 +233,17 @@ def start(self):
234233
'''The start date/time of the period, as datetime object.'''
235234

236235
return datetime_utils.parse_datetime(
237-
self._data['date'],
238-
self._data['startTime']
236+
self._data[u'date'],
237+
self._data[u'startTime']
239238
)
240239

241240
@lazyproperty
242241
def end(self):
243242
'''The end date/time of the period.'''
244243

245244
return datetime_utils.parse_datetime(
246-
self._data['date'],
247-
self._data['endTime']
245+
self._data[u'date'],
246+
self._data[u'endTime']
248247
)
249248

250249
@lazyproperty
@@ -253,7 +252,7 @@ def klassen(self):
253252
this period.'''
254253

255254
return self._session.klassen(from_cache=True).filter(
256-
id=set([kl['id'] for kl in self._data['kl']])
255+
id=set([kl[u'id'] for kl in self._data[u'kl']])
257256
)
258257

259258
@lazyproperty
@@ -262,7 +261,7 @@ def teachers(self):
262261
which are attending this period.'''
263262

264263
return self._session.teachers(from_cache=True).filter(
265-
id=set([te['id'] for te in self._data['te']])
264+
id=set([te[u'id'] for te in self._data[u'te']])
266265
)
267266

268267
@lazyproperty
@@ -273,7 +272,7 @@ def subjects(self):
273272
their own period.'''
274273

275274
return self._session.subjects(from_cache=True).filter(
276-
id=set([su['id'] for su in self._data['su']])
275+
id=set([su[u'id'] for su in self._data[u'su']])
277276
)
278277

279278
@lazyproperty
@@ -283,7 +282,7 @@ def rooms(self):
283282
lesson that is actually occuring at multiple locations (?).'''
284283

285284
return self._session.rooms(from_cache=True).filter(
286-
id=set([ro['id'] for ro in self._data['ro']])
285+
id=set([ro[u'id'] for ro in self._data[u'ro']])
287286
)
288287

289288
@lazyproperty
@@ -310,7 +309,7 @@ def type(self):
310309
- ``"ex"`` -- Examination
311310
'''
312311

313-
return (self._data['lstype'] if 'lstype' in self._data else 'ls')
312+
return self._data.get(u'lstype', u'ls')
314313

315314

316315
class PeriodList(ListResult):
@@ -351,12 +350,12 @@ class RoomObject(ListItem):
351350
@lazyproperty
352351
def name(self):
353352
'''The short name of the room. Such as PHY.'''
354-
return self._data['name']
353+
return self._data[u'name']
355354

356355
@lazyproperty
357356
def long_name(self):
358357
'''The long name of the room. Such as "Physics lab".'''
359-
return self._data['longName']
358+
return self._data[u'longName']
360359

361360

362361
class RoomList(ListResult):
@@ -371,17 +370,17 @@ class SchoolyearObject(ListItem):
371370
def name(self):
372371
'''"2010/2011"'''
373372

374-
return self._data['name']
373+
return self._data[u'name']
375374

376375
@lazyproperty
377376
def start(self):
378377
'''The start date of the schoolyear, as datetime object'''
379-
return datetime_utils.parse_date(self._data['startDate'])
378+
return datetime_utils.parse_date(self._data[u'startDate'])
380379

381380
@lazyproperty
382381
def end(self):
383382
'''The end date'''
384-
return datetime_utils.parse_date(self._data['endDate'])
383+
return datetime_utils.parse_date(self._data[u'endDate'])
385384

386385
@lazyproperty
387386
def is_current(self):
@@ -410,7 +409,7 @@ def current(self):
410409
'''Returns the current schoolyear in form of a
411410
:py:class:`SchoolyearObject`'''
412411
current_data = self._session._request('getCurrentSchoolyear')
413-
current = self.filter(id=current_data['id'])[0]
412+
current = self.filter(id=current_data[u'id'])[0]
414413
return current
415414

416415

@@ -420,12 +419,12 @@ class SubjectObject(ListItem):
420419
@lazyproperty
421420
def name(self):
422421
'''Short name of subject, such as *PHY*'''
423-
return self._data['name']
422+
return self._data[u'name']
424423

425424
@lazyproperty
426425
def long_name(self):
427426
'''Long name of subject, such as *Physics*'''
428-
return self._data['longName']
427+
return self._data[u'longName']
429428

430429

431430
class SubjectList(ListResult):
@@ -438,19 +437,19 @@ class TeacherObject(ListItem):
438437
@lazyproperty
439438
def fore_name(self):
440439
'''fore name of the teacher'''
441-
return self._data['foreName']
440+
return self._data[u'foreName']
442441

443442
@lazyproperty
444443
def long_name(self):
445444
'''surname of teacher'''
446-
return self._data['longName']
445+
return self._data[u'longName']
447446

448447
surname = long_name
449448

450449
@lazyproperty
451450
def name(self):
452451
'''full name of the teacher'''
453-
return self._data['name']
452+
return self._data[u'name']
454453

455454

456455
class TeacherList(ListResult):
@@ -468,15 +467,15 @@ def times(self):
468467

469468
return [
470469
(
471-
datetime_utils.parse_time(unit['startTime']),
472-
datetime_utils.parse_time(unit['endTime'])
473-
) for unit in self._data['timeUnits']
470+
datetime_utils.parse_time(unit[u'startTime']),
471+
datetime_utils.parse_time(unit[u'endTime'])
472+
) for unit in self._data[u'timeUnits']
474473
]
475474

476475
@lazyproperty
477476
def day(self):
478477
'''The day the timeunit list is for'''
479-
return self._data['day']
478+
return self._data[u'day']
480479

481480
@lazyproperty
482481
def id(self):
@@ -546,12 +545,12 @@ def name(self):
546545
@lazyproperty
547546
def forecolor(self):
548547
'''The foreground color used in the web interface and elsewhere'''
549-
return self._data[self.name]['foreColor']
548+
return self._data[self.name][u'foreColor']
550549

551550
@lazyproperty
552551
def backcolor(self):
553552
'''The background color used in the web interface and elsewhere'''
554-
return self._data[self.name]['backColor']
553+
return self._data[self.name][u'backColor']
555554

556555

557556
class StatusData(Result):
@@ -563,7 +562,7 @@ def lesson_types(self):
563562
information about all lesson types defined'''
564563
return [
565564
ColorInfo(parent=self, data=data)
566-
for data in self._data['lstypes']
565+
for data in self._data[u'lstypes']
567566
]
568567

569568
@lazyproperty
@@ -572,5 +571,5 @@ def period_codes(self):
572571
information about all period codes defined'''
573572
return [
574573
ColorInfo(parent=self, data=data)
575-
for data in self._data['codes']
574+
for data in self._data[u'codes']
576575
]

‎webuntis/session.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
:copyright: (c) 2012 by Markus Unterwaditzer.
55
:license: BSD, see LICENSE for more details.
66
'''
7-
from __future__ import unicode_literals
87
from webuntis import utils, objects, errors
98
from webuntis.utils import result_wrapper, log, rpc_request
109
from webuntis.utils.userinput import unicode_string

‎webuntis/tests/test_objects.py‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,24 @@ def test_initialization(self):
1010
r = self.Result(data={'id': 124}, parent=r)
1111
assert r.id == int(r) == 124
1212

13-
self.assertRaises(TypeError, self.Result, data={'id': 137})
14-
self.assertRaises(TypeError, self.Result, data={'id': 137},
13+
self.assertRaises(TypeError, self.Result, data={u'id': 137})
14+
self.assertRaises(TypeError, self.Result, data={u'id': 137},
1515
session=object(), parent=r)
16-
self.assertRaises(TypeError, self.Result, data={'id': 139},
16+
self.assertRaises(TypeError, self.Result, data={u'id': 139},
1717
parent=object())
1818

1919
def test_hashes(self):
20-
r1 = self.Result(data={'id': 124}, session=object())
20+
r1 = self.Result(data={u'id': 124}, session=object())
2121

2222
r2 = None
2323
assert r1 != r2
2424
assert hash(r1) != hash(r2)
2525

26-
r2 = self.Result(data={'id': 123}, session=object())
26+
r2 = self.Result(data={u'id': 123}, session=object())
2727
assert r1 != r2
2828
assert hash(r1) != hash(r2)
2929

30-
r2 = self.Result(data={'id': 124}, session=object())
30+
r2 = self.Result(data={u'id': 124}, session=object())
3131
assert r1 == r2
3232
assert hash(r1) == hash(r2)
3333

@@ -40,7 +40,7 @@ def test_basics(self):
4040
class CustomItem(webuntis.objects.ListItem):
4141
@self.lazyproperty
4242
def value(self):
43-
return self._data['val']
43+
return self._data[u'val']
4444

4545
class CustomListResult(self.Result):
4646
_itemclass = CustomItem
@@ -57,18 +57,18 @@ class CustomListResult(self.Result):
5757
for res, raw in zip(r, data):
5858
assert type(res) is CustomItem
5959
assert res in r
60-
assert {'id': res.id, 'value': res.value} in r
61-
assert res.id == raw['id']
60+
assert {u'id': res.id, u'value': res.value} in r
61+
assert res.id == raw[u'id']
6262

6363
def test_filter(self):
6464
class CustomItem(webuntis.objects.ListItem):
6565
@self.lazyproperty
6666
def one(self):
67-
return self._data['one']
67+
return self._data[u'one']
6868

6969
@self.lazyproperty
7070
def two(self):
71-
return self._data['two']
71+
return self._data[u'two']
7272

7373
class CustomListResult(self.Result):
7474
_itemclass = CustomItem

‎webuntis/utils/userinput.py‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
:copyright: (c) 2013 by Markus Unterwaditzer.
55
:license: BSD, see LICENSE for more details.
66
'''
7-
from __future__ import unicode_literals
87
import re
98
from .logger import log
109
from .third_party import urlparse
@@ -35,14 +34,16 @@ def server(url):
3534
'parameter.')
3635

3736
return urlobj.scheme + \
38-
'://' + \
37+
u'://' + \
3938
urlobj.netloc + \
40-
(urlobj.path or '/WebUntis/jsonrpc.do')
39+
(urlobj.path or u'/WebUntis/jsonrpc.do')
4140

4241

4342
def string(value):
4443
'''Make the string unicode'''
45-
return '' + value
44+
if isinstance(value, unicode_string):
45+
return value
46+
return value.decode('ascii')
4647

4748
config_keys = {
4849
'username': string,

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL