trackma 0.4__py2.7.egg

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. EGG-INFO/PKG-INFO +19 -0
  2. EGG-INFO/SOURCES.txt +35 -0
  3. EGG-INFO/dependency_links.txt +1 -0
  4. EGG-INFO/entry_points.txt +8 -0
  5. EGG-INFO/not-zip-safe +1 -0
  6. EGG-INFO/requires.txt +10 -0
  7. EGG-INFO/top_level.txt +1 -0
  8. trackma/__init__.py +0 -0
  9. trackma/__init__.pyc +0 -0
  10. trackma/accounts.py +110 -0
  11. trackma/accounts.pyc +0 -0
  12. trackma/data/anilist.jpg +0 -0
  13. trackma/data/hb.jpg +0 -0
  14. trackma/data/icon.png +0 -0
  15. trackma/data/mal.jpg +0 -0
  16. trackma/data/melative.jpg +0 -0
  17. trackma/data/vndb.jpg +0 -0
  18. trackma/data.py +585 -0
  19. trackma/data.pyc +0 -0
  20. trackma/engine.py +742 -0
  21. trackma/engine.pyc +0 -0
  22. trackma/extras/AnimeInfoExtractor.py +308 -0
  23. trackma/extras/AnimeInfoExtractor.pyc +0 -0
  24. trackma/extras/__init__.py +0 -0
  25. trackma/extras/__init__.pyc +0 -0
  26. trackma/extras/plex.py +100 -0
  27. trackma/extras/plex.pyc +0 -0
  28. trackma/lib/__init__.py +0 -0
  29. trackma/lib/__init__.pyc +0 -0
  30. trackma/lib/lib.py +162 -0
  31. trackma/lib/lib.pyc +0 -0
  32. trackma/lib/libanilist.py +355 -0
  33. trackma/lib/libanilist.pyc +0 -0
  34. trackma/lib/libhb.py +248 -0
  35. trackma/lib/libhb.pyc +0 -0
  36. trackma/lib/libmal.py +705 -0
  37. trackma/lib/libmal.pyc +0 -0
  38. trackma/lib/libmelative.py +213 -0
  39. trackma/lib/libmelative.pyc +0 -0
  40. trackma/lib/libvndb.py +373 -0
  41. trackma/lib/libvndb.pyc +0 -0
  42. trackma/messenger.py +42 -0
  43. trackma/messenger.pyc +0 -0
  44. trackma/tracker.py +301 -0
  45. trackma/tracker.pyc +0 -0
  46. trackma/ui/__init__.py +0 -0
  47. trackma/ui/__init__.pyc +0 -0
  48. trackma/ui/cli.py +712 -0
  49. trackma/ui/cli.pyc +0 -0
  50. trackma/ui/curses.py +1049 -0
  51. trackma/ui/curses.pyc +0 -0
  52. trackma/ui/gtkui.py +2360 -0
  53. trackma/ui/gtkui.pyc +0 -0
  54. trackma/ui/qtui.py +2120 -0
  55. trackma/ui/qtui.pyc +0 -0
  56. trackma/utils.py +299 -0
  57. trackma/utils.pyc +0 -0
trackma/lib/libmal.py ADDED
@@ -0,0 +1,705 @@
1
+ # -*- coding: utf-8 -*-
2
+ # This file is part of Trackma.
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+ #
17
+
18
+ from trackma.lib.lib import lib
19
+ import trackma.utils as utils
20
+
21
+ import urllib, urllib2
22
+ import datetime
23
+ import base64
24
+ import gzip
25
+ import xml.etree.ElementTree as ET
26
+ from cStringIO import StringIO
27
+
28
+ class libmal(lib):
29
+ """
30
+ API class to communicate with MyAnimeList
31
+ Should inherit a base library interface.
32
+
33
+ Website: http://www.myanimelist.net
34
+ API documentation: http://myanimelist.net/modules.php?go=api
35
+ Designed by: Garrett Gyssler (http://myanimelist.net/profile/Xinil)
36
+
37
+ """
38
+ name = 'libmal'
39
+
40
+ username = '' # TODO Must be filled by check_credentials
41
+ logged_in = False
42
+ opener = None
43
+
44
+ api_info = { 'name': 'MyAnimeList', 'version': 'v0.3', 'merge': False }
45
+
46
+ default_mediatype = 'anime'
47
+ mediatypes = dict()
48
+ mediatypes['anime'] = {
49
+ 'has_progress': True,
50
+ 'can_add': True,
51
+ 'can_delete': True,
52
+ 'can_score': True,
53
+ 'can_status': True,
54
+ 'can_update': True,
55
+ 'can_play': True,
56
+ 'can_date': True,
57
+ 'status_start': 1,
58
+ 'status_finish': 2,
59
+ 'statuses': [1, 2, 3, 4, 6],
60
+ 'statuses_dict': { 1: 'Watching', 2: 'Completed', 3: 'On Hold', 4: 'Dropped', 6: 'Plan to Watch' },
61
+ 'score_max': 10,
62
+ 'score_step': 1,
63
+ }
64
+ mediatypes['manga'] = {
65
+ 'has_progress': True,
66
+ 'can_add': True,
67
+ 'can_delete': True,
68
+ 'can_score': True,
69
+ 'can_status': True,
70
+ 'can_update': True,
71
+ 'can_play': False,
72
+ 'can_date': True,
73
+ 'status_start': 1,
74
+ 'status_finish': 2,
75
+ 'statuses': [1, 2, 3, 4, 6],
76
+ 'statuses_dict': { 1: 'Reading', 2: 'Completed', 3: 'On Hold', 4: 'Dropped', 6: 'Plan to Read' },
77
+ 'score_max': 10,
78
+ 'score_step': 1,
79
+ }
80
+
81
+ # Authorized User-Agent for Trackma
82
+ url = 'http://myanimelist.net/api/'
83
+ useragent = 'api-team-f894427cc1c571f79da49605ef8b112f'
84
+
85
+ def __init__(self, messenger, account, userconfig):
86
+ """Initializes the useragent through credentials."""
87
+ # Since MyAnimeList uses a cookie we just create a HTTP Auth handler
88
+ # together with the urllib2 opener.
89
+ super(libmal, self).__init__(messenger, account, userconfig)
90
+
91
+ auth_string = 'Basic ' + base64.encodestring('%s:%s' % (account['username'], account['password'])).replace('\n', '')
92
+
93
+ self.username = self._get_userconfig('username')
94
+ self.opener = urllib2.build_opener()
95
+ self.opener.addheaders = [
96
+ ('User-Agent', self.useragent),
97
+ ('Authorization', auth_string),
98
+ ]
99
+
100
+ def _request(self, url):
101
+ """
102
+ Requests the page as gzip and uncompresses it
103
+
104
+ Returns a stream object
105
+
106
+ """
107
+ try:
108
+ request = urllib2.Request(url)
109
+ request.add_header('Accept-Encoding', 'gzip')
110
+ response = self.opener.open(request, timeout = 10)
111
+ except urllib2.HTTPError, e:
112
+ if e.code == 401:
113
+ raise utils.APIError(
114
+ "Unauthorized. Please check if your username and password are correct."
115
+ "\n\nPlease note that you might also be getting this error if you have "
116
+ "non-alphanumeric characters in your password due to an upstream "
117
+ "MAL bug (#138).")
118
+ else:
119
+ raise utils.APIError("HTTP error %d: %s" % (e.code, e.reason))
120
+ except urllib2.URLError, e:
121
+ raise utils.APIError("Connection error: %s" % e)
122
+
123
+ if response.info().get('content-encoding') == 'gzip':
124
+ compressed_stream = StringIO(response.read())
125
+ return gzip.GzipFile(fileobj=compressed_stream)
126
+ else:
127
+ # If the content is not gzipped return it as-is
128
+ return response
129
+
130
+ def check_credentials(self):
131
+ """Checks if credentials are correct; returns True or False."""
132
+ if self.logged_in:
133
+ return True # Already logged in
134
+
135
+ self.msg.info(self.name, 'Logging in...')
136
+
137
+ response = self._request(self.url + "account/verify_credentials.xml")
138
+ root = ET.ElementTree().parse(response, parser=self._make_parser())
139
+ (userid, username) = self._parse_credentials(root)
140
+ self.username = username
141
+
142
+ self._set_userconfig('userid', userid)
143
+ self._set_userconfig('username', username)
144
+ self._emit_signal('userconfig_changed')
145
+
146
+ self.logged_in = True
147
+ return True
148
+
149
+ def fetch_list(self):
150
+ """Queries the full list from the remote server.
151
+ Returns the list if successful, False otherwise."""
152
+ self.check_credentials()
153
+ self.msg.info(self.name, 'Downloading list...')
154
+
155
+ try:
156
+ # Get an XML list from MyAnimeList API
157
+ data = self._request("http://myanimelist.net/malappinfo.php?u="+self.username+"&status=all&type="+self.mediatype)
158
+
159
+ # Parse the XML data and load it into a dictionary
160
+ # using the proper function (anime or manga)
161
+ root = ET.ElementTree().parse(data, parser=self._make_parser())
162
+
163
+ if self.mediatype == 'anime':
164
+ self.msg.info(self.name, 'Parsing anime list...')
165
+ return self._parse_anime(root)
166
+ elif self.mediatype == 'manga':
167
+ self.msg.info(self.name, 'Parsing manga list...')
168
+ return self._parse_manga(root)
169
+ else:
170
+ raise utils.APIFatal('Attempted to parse unsupported media type.')
171
+ except urllib2.HTTPError, e:
172
+ raise utils.APIError("Error getting list.")
173
+ except IOError, e:
174
+ raise utils.APIError("Error reading list: %s" % e.message)
175
+
176
+ def add_show(self, item):
177
+ """Adds a new show in the server"""
178
+ self.check_credentials()
179
+ self.msg.info(self.name, "Adding show %s..." % item['title'])
180
+
181
+ xml = self._build_xml(item)
182
+
183
+ # Send the XML as POST data to the MyAnimeList API
184
+ values = {'data': xml}
185
+ data = self._urlencode(values)
186
+ try:
187
+ response = self.opener.open(self.url + self.mediatype + "list/add/" + str(item['id']) + ".xml", data)
188
+ return True
189
+ except urllib2.HTTPError, e:
190
+ raise utils.APIError('Error adding: ' + str(e.code))
191
+
192
+ def update_show(self, item):
193
+ """Sends a show update to the server"""
194
+ self.check_credentials()
195
+ self.msg.info(self.name, "Updating show %s..." % item['title'])
196
+
197
+ xml = self._build_xml(item)
198
+
199
+ # Send the XML as POST data to the MyAnimeList API
200
+ values = {'data': xml}
201
+ data = self._urlencode(values)
202
+ try:
203
+ response = self.opener.open(self.url + self.mediatype + "list/update/" + str(item['id']) + ".xml", data)
204
+ return True
205
+ except urllib2.HTTPError, e:
206
+ raise utils.APIError('Error updating: ' + str(e.code))
207
+
208
+ def delete_show(self, item):
209
+ """Sends a show delete to the server"""
210
+ self.check_credentials()
211
+ self.msg.info(self.name, "Deleting show %s..." % item['title'])
212
+
213
+ try:
214
+ response = self.opener.open(self.url + self.mediatype + "list/delete/" + str(item['id']) + ".xml")
215
+ return True
216
+ except urllib2.HTTPError, e:
217
+ raise utils.APIError('Error deleting: ' + str(e.code))
218
+
219
+ def search(self, criteria):
220
+ """Searches MyAnimeList database for the queried show"""
221
+ self.msg.info(self.name, "Searching for %s..." % criteria)
222
+
223
+ # Send the urlencoded query to the search API
224
+ query = self._urlencode({'q': criteria})
225
+ data = self._request(self.url + self.mediatype + "/search.xml?" + query)
226
+
227
+ # Load the results into XML
228
+ try:
229
+ root = ET.ElementTree().parse(data, parser=self._make_parser())
230
+ except ET.ParseError, e:
231
+ if e.code == 3:
232
+ # Empty document; no results
233
+ return []
234
+ else:
235
+ raise utils.APIError("Parser error: %s" % repr(e.message))
236
+ except IOError:
237
+ raise utils.APIError("IO error: %s" % repr(e.message))
238
+
239
+ # Use the correct tag name for episodes
240
+ if self.mediatype == 'manga':
241
+ episodes_str = 'chapters'
242
+ else:
243
+ episodes_str = 'episodes'
244
+
245
+ # Since the MAL API returns the status as a string, and
246
+ # we handle statuses as integers, we need to convert them
247
+ if self.mediatype == 'anime':
248
+ status_translate = {'Currently Airing': utils.STATUS_AIRING,
249
+ 'Finished Airing': utils.STATUS_FINISHED,
250
+ 'Not yet aired': utils.STATUS_NOTYET}
251
+ elif self.mediatype == 'manga':
252
+ status_translate = {'Publishing': utils.STATUS_AIRING,
253
+ 'Finished': utils.STATUS_AIRING}
254
+
255
+ entries = list()
256
+ for child in root.iter('entry'):
257
+ show = utils.show()
258
+ showid = int(child.find('id').text)
259
+ show.update({
260
+ 'id': showid,
261
+ 'title': child.find('title').text,
262
+ 'type': child.find('type').text,
263
+ 'status': status_translate[child.find('status').text], # TODO : This should return an int!
264
+ 'total': int(child.find(episodes_str).text),
265
+ 'image': child.find('image').text,
266
+ 'url': "http://myanimelist.net/anime/%d" % showid,
267
+ 'start_date': self._str2date( child.find('start_date').text ),
268
+ 'end_date': self._str2date( child.find('end_date').text ),
269
+ 'extra': [
270
+ ('English', child.find('english').text),
271
+ ('Synonyms', child.find('synonyms').text),
272
+ ('Synopsis', self._translate_synopsis(child.find('synopsis').text)),
273
+ (episodes_str.title(), child.find(episodes_str).text),
274
+ ('Type', child.find('type').text),
275
+ ('Score', child.find('score').text),
276
+ ('Status', child.find('status').text),
277
+ ('Start date', child.find('start_date').text),
278
+ ('End date', child.find('end_date').text),
279
+ ]
280
+ })
281
+ entries.append(show)
282
+
283
+ self._emit_signal('show_info_changed', entries)
284
+ return entries
285
+
286
+ def _translate_synopsis(self, string):
287
+ if string is None:
288
+ return None
289
+ else:
290
+ return string.replace('<br />', '')
291
+
292
+ def request_info(self, itemlist):
293
+ resultdict = dict()
294
+ for item in itemlist:
295
+ # Search for it only if it hasn't been found earlier
296
+ if item['id'] not in resultdict:
297
+ infos = self.search(item['title'])
298
+ for info in infos:
299
+ showid = info['id']
300
+ resultdict[showid] = info
301
+
302
+ itemids = [ show['id'] for show in itemlist ]
303
+
304
+ try:
305
+ reslist = [ resultdict[itemid] for itemid in itemids ]
306
+ except KeyError:
307
+ raise utils.APIError('There was a problem getting the show details.')
308
+
309
+ return reslist
310
+
311
+ def _parse_credentials(self, root):
312
+ if root is not None:
313
+ userid = int(root.find('id').text)
314
+ username = root.find('username').text
315
+ return (userid, username)
316
+
317
+ def _parse_anime(self, root):
318
+ """Converts an XML anime list to a dictionary"""
319
+ showlist = dict()
320
+ for child in root.iter('anime'):
321
+ show_id = int(child.find('series_animedb_id').text)
322
+ if child.find('series_synonyms').text:
323
+ aliases = child.find('series_synonyms').text.lstrip('; ').split('; ')
324
+ else:
325
+ aliases = []
326
+
327
+ show = utils.show()
328
+ show.update({
329
+ 'id': show_id,
330
+ 'title': child.find('series_title').text,
331
+ 'aliases': aliases,
332
+ 'my_progress': int(child.find('my_watched_episodes').text),
333
+ 'my_status': int(child.find('my_status').text),
334
+ 'my_score': int(child.find('my_score').text),
335
+ 'my_start_date': self._str2date( child.find('my_start_date').text ),
336
+ 'my_finish_date': self._str2date( child.find('my_finish_date').text ),
337
+ 'total': int(child.find('series_episodes').text),
338
+ 'status': int(child.find('series_status').text),
339
+ 'start_date': self._str2date( child.find('series_start').text ),
340
+ 'end_date': self._str2date( child.find('series_end').text ),
341
+ 'image': child.find('series_image').text,
342
+ 'url': "http://myanimelist.net/anime/%d" % show_id,
343
+ })
344
+ showlist[show_id] = show
345
+ return showlist
346
+
347
+ def _parse_manga(self, root):
348
+ """Converts an XML manga list to a dictionary"""
349
+ mangalist = dict()
350
+ for child in root.iter('manga'):
351
+ manga_id = int(child.find('series_mangadb_id').text)
352
+ if child.find('series_synonyms').text:
353
+ aliases = child.find('series_synonyms').text.lstrip('; ').split('; ')
354
+ else:
355
+ aliases = []
356
+
357
+ show = utils.show()
358
+ show.update({
359
+ 'id': manga_id,
360
+ 'title': child.find('series_title').text,
361
+ 'aliases': aliases,
362
+ 'my_progress': int(child.find('my_read_chapters').text),
363
+ 'my_status': int(child.find('my_status').text),
364
+ 'my_score': int(child.find('my_score').text),
365
+ 'my_start_date': self._str2date( child.find('my_start_date').text ),
366
+ 'my_finish_date': self._str2date( child.find('my_finish_date').text ),
367
+ 'total': int(child.find('series_chapters').text),
368
+ 'status': int(child.find('series_status').text),
369
+ 'start_date': self._str2date( child.find('series_start').text ),
370
+ 'end_date': self._str2date( child.find('series_end').text ),
371
+ 'image': child.find('series_image').text,
372
+ 'url': "http://myanimelist.net/manga/%d" % manga_id,
373
+ })
374
+ mangalist[manga_id] = show
375
+ return mangalist
376
+
377
+ def _build_xml(self, item):
378
+ """
379
+ Creates an "anime|manga data" XML to be used in the
380
+ add, update and delete methods.
381
+
382
+ More information:
383
+ http://myanimelist.net/modules.php?go=api#animevalues
384
+ http://myanimelist.net/modules.php?go=api#mangavalues
385
+
386
+ """
387
+
388
+ # Start building XML
389
+ root = ET.Element("entry")
390
+
391
+ # Use the correct name depending on mediatype
392
+ if self.mediatype == 'anime':
393
+ progressname = 'episode'
394
+ else:
395
+ progressname = 'chapter'
396
+
397
+ # Update necessary keys
398
+ if 'my_progress' in item.keys():
399
+ episode = ET.SubElement(root, progressname)
400
+ episode.text = str(item['my_progress'])
401
+ if 'my_status' in item.keys():
402
+ status = ET.SubElement(root, "status")
403
+ status.text = str(item['my_status'])
404
+ if 'my_score' in item.keys():
405
+ score = ET.SubElement(root, "score")
406
+ score.text = str(item['my_score'])
407
+ if 'my_start_date' in item.keys():
408
+ start_date = ET.SubElement(root, "date_start")
409
+ start_date.text = self._date2str(item['my_start_date'])
410
+ if 'my_finish_date' in item.keys():
411
+ finish_date = ET.SubElement(root, "date_finish")
412
+ finish_date.text = self._date2str(item['my_finish_date'])
413
+
414
+ return ET.tostring(root)
415
+
416
+ def _date2str(self, date):
417
+ if date:
418
+ return date.strftime("%m%d%Y")
419
+ else:
420
+ return '0000-00-00'
421
+
422
+ def _str2date(self, string):
423
+ if string != '0000-00-00':
424
+ try:
425
+ return datetime.datetime.strptime(string, "%Y-%m-%d")
426
+ except ValueError:
427
+ return None # Ignore date if it's invalid
428
+ else:
429
+ return None
430
+
431
+ def _urlencode(self, in_dict):
432
+ """Helper function to urlencode dicts in unicode. urllib doesn't like them."""
433
+ out_dict = {}
434
+ for k, v in in_dict.iteritems():
435
+ out_dict[k] = v
436
+ if isinstance(v, unicode):
437
+ out_dict[k] = v.encode('utf8')
438
+ elif isinstance(v, str):
439
+ out_dict[k] = v.decode('utf8')
440
+ return urllib.urlencode(out_dict)
441
+
442
+ def _make_parser(self):
443
+ # For some reason MAL returns an XML file with HTML exclusive
444
+ # entities like &aacute;, so we have to create a custom XMLParser
445
+ # to convert these entities correctly.
446
+ parser = ET.XMLParser()
447
+ parser.parser.UseForeignDTD(True)
448
+
449
+ entities = dict()
450
+ entities["nbsp"] = u'\u00A0'
451
+ entities["iexcl"] = u'\u00A1'
452
+ entities["cent"] = u'\u00A2'
453
+ entities["pound"] = u'\u00A3'
454
+ entities["curren"] = u'\u00A4'
455
+ entities["yen"] = u'\u00A5'
456
+ entities["brvbar"] = u'\u00A6'
457
+ entities["sect"] = u'\u00A7'
458
+ entities["uml"] = u'\u00A8'
459
+ entities["copy"] = u'\u00A9'
460
+ entities["ordf"] = u'\u00AA'
461
+ entities["laquo"] = u'\u00AB'
462
+ entities["not"] = u'\u00AC'
463
+ entities["shy"] = u'\u00AD'
464
+ entities["reg"] = u'\u00AE'
465
+ entities["macr"] = u'\u00AF'
466
+ entities["deg"] = u'\u00B0'
467
+ entities["plusmn"] = u'\u00B1'
468
+ entities["sup2"] = u'\u00B2'
469
+ entities["sup3"] = u'\u00B3'
470
+ entities["acute"] = u'\u00B4'
471
+ entities["micro"] = u'\u00B5'
472
+ entities["para"] = u'\u00B6'
473
+ entities["middot"] = u'\u00B7'
474
+ entities["cedil"] = u'\u00B8'
475
+ entities["sup1"] = u'\u00B9'
476
+ entities["ordm"] = u'\u00BA'
477
+ entities["raquo"] = u'\u00BB'
478
+ entities["frac14"] = u'\u00BC'
479
+ entities["frac12"] = u'\u00BD'
480
+ entities["frac34"] = u'\u00BE'
481
+ entities["iquest"] = u'\u00BF'
482
+ entities["Agrave"] = u'\u00C0'
483
+ entities["Aacute"] = u'\u00C1'
484
+ entities["Acirc"] = u'\u00C2'
485
+ entities["Atilde"] = u'\u00C3'
486
+ entities["Auml"] = u'\u00C4'
487
+ entities["Aring"] = u'\u00C5'
488
+ entities["AElig"] = u'\u00C6'
489
+ entities["Ccedil"] = u'\u00C7'
490
+ entities["Egrave"] = u'\u00C8'
491
+ entities["Eacute"] = u'\u00C9'
492
+ entities["Ecirc"] = u'\u00CA'
493
+ entities["Euml"] = u'\u00CB'
494
+ entities["Igrave"] = u'\u00CC'
495
+ entities["Iacute"] = u'\u00CD'
496
+ entities["Icirc"] = u'\u00CE'
497
+ entities["Iuml"] = u'\u00CF'
498
+ entities["ETH"] = u'\u00D0'
499
+ entities["Ntilde"] = u'\u00D1'
500
+ entities["Ograve"] = u'\u00D2'
501
+ entities["Oacute"] = u'\u00D3'
502
+ entities["Ocirc"] = u'\u00D4'
503
+ entities["Otilde"] = u'\u00D5'
504
+ entities["Ouml"] = u'\u00D6'
505
+ entities["times"] = u'\u00D7'
506
+ entities["Oslash"] = u'\u00D8'
507
+ entities["Ugrave"] = u'\u00D9'
508
+ entities["Uacute"] = u'\u00DA'
509
+ entities["Ucirc"] = u'\u00DB'
510
+ entities["Uuml"] = u'\u00DC'
511
+ entities["Yacute"] = u'\u00DD'
512
+ entities["THORN"] = u'\u00DE'
513
+ entities["szlig"] = u'\u00DF'
514
+ entities["agrave"] = u'\u00E0'
515
+ entities["aacute"] = u'\u00E1'
516
+ entities["acirc"] = u'\u00E2'
517
+ entities["atilde"] = u'\u00E3'
518
+ entities["auml"] = u'\u00E4'
519
+ entities["aring"] = u'\u00E5'
520
+ entities["aelig"] = u'\u00E6'
521
+ entities["ccedil"] = u'\u00E7'
522
+ entities["egrave"] = u'\u00E8'
523
+ entities["eacute"] = u'\u00E9'
524
+ entities["ecirc"] = u'\u00EA'
525
+ entities["euml"] = u'\u00EB'
526
+ entities["igrave"] = u'\u00EC'
527
+ entities["iacute"] = u'\u00ED'
528
+ entities["icirc"] = u'\u00EE'
529
+ entities["iuml"] = u'\u00EF'
530
+ entities["eth"] = u'\u00F0'
531
+ entities["ntilde"] = u'\u00F1'
532
+ entities["ograve"] = u'\u00F2'
533
+ entities["oacute"] = u'\u00F3'
534
+ entities["ocirc"] = u'\u00F4'
535
+ entities["otilde"] = u'\u00F5'
536
+ entities["ouml"] = u'\u00F6'
537
+ entities["divide"] = u'\u00F7'
538
+ entities["oslash"] = u'\u00F8'
539
+ entities["ugrave"] = u'\u00F9'
540
+ entities["uacute"] = u'\u00FA'
541
+ entities["ucirc"] = u'\u00FB'
542
+ entities["uuml"] = u'\u00FC'
543
+ entities["yacute"] = u'\u00FD'
544
+ entities["thorn"] = u'\u00FE'
545
+ entities["yuml"] = u'\u00FF'
546
+ entities["fnof"] = u'\u0192'
547
+ entities["Alpha"] = u'\u0391'
548
+ entities["Beta"] = u'\u0392'
549
+ entities["Gamma"] = u'\u0393'
550
+ entities["Delta"] = u'\u0394'
551
+ entities["Epsilon"] = u'\u0395'
552
+ entities["Zeta"] = u'\u0396'
553
+ entities["Eta"] = u'\u0397'
554
+ entities["Theta"] = u'\u0398'
555
+ entities["Iota"] = u'\u0399'
556
+ entities["Kappa"] = u'\u039A'
557
+ entities["Lambda"] = u'\u039B'
558
+ entities["Mu"] = u'\u039C'
559
+ entities["Nu"] = u'\u039D'
560
+ entities["Xi"] = u'\u039E'
561
+ entities["Omicron"] = u'\u039F'
562
+ entities["Pi"] = u'\u03A0'
563
+ entities["Rho"] = u'\u03A1'
564
+ entities["Sigma"] = u'\u03A3'
565
+ entities["Tau"] = u'\u03A4'
566
+ entities["Upsilon"] = u'\u03A5'
567
+ entities["Phi"] = u'\u03A6'
568
+ entities["Chi"] = u'\u03A7'
569
+ entities["Psi"] = u'\u03A8'
570
+ entities["Omega"] = u'\u03A9'
571
+ entities["alpha"] = u'\u03B1'
572
+ entities["beta"] = u'\u03B2'
573
+ entities["gamma"] = u'\u03B3'
574
+ entities["delta"] = u'\u03B4'
575
+ entities["epsilon"] = u'\u03B5'
576
+ entities["zeta"] = u'\u03B6'
577
+ entities["eta"] = u'\u03B7'
578
+ entities["theta"] = u'\u03B8'
579
+ entities["iota"] = u'\u03B9'
580
+ entities["kappa"] = u'\u03BA'
581
+ entities["lambda"] = u'\u03BB'
582
+ entities["mu"] = u'\u03BC'
583
+ entities["nu"] = u'\u03BD'
584
+ entities["xi"] = u'\u03BE'
585
+ entities["omicron"] = u'\u03BF'
586
+ entities["pi"] = u'\u03C0'
587
+ entities["rho"] = u'\u03C1'
588
+ entities["sigmaf"] = u'\u03C2'
589
+ entities["sigma"] = u'\u03C3'
590
+ entities["tau"] = u'\u03C4'
591
+ entities["upsilon"] = u'\u03C5'
592
+ entities["phi"] = u'\u03C6'
593
+ entities["chi"] = u'\u03C7'
594
+ entities["psi"] = u'\u03C8'
595
+ entities["omega"] = u'\u03C9'
596
+ entities["thetasym"] = u'\u03D1'
597
+ entities["upsih"] = u'\u03D2'
598
+ entities["piv"] = u'\u03D6'
599
+ entities["bull"] = u'\u2022'
600
+ entities["hellip"] = u'\u2026'
601
+ entities["prime"] = u'\u2032'
602
+ entities["Prime"] = u'\u2033'
603
+ entities["oline"] = u'\u203E'
604
+ entities["frasl"] = u'\u2044'
605
+ entities["weierp"] = u'\u2118'
606
+ entities["image"] = u'\u2111'
607
+ entities["real"] = u'\u211C'
608
+ entities["trade"] = u'\u2122'
609
+ entities["alefsym"] = u'\u2135'
610
+ entities["larr"] = u'\u2190'
611
+ entities["uarr"] = u'\u2191'
612
+ entities["rarr"] = u'\u2192'
613
+ entities["darr"] = u'\u2193'
614
+ entities["harr"] = u'\u2194'
615
+ entities["crarr"] = u'\u21B5'
616
+ entities["lArr"] = u'\u21D0'
617
+ entities["uArr"] = u'\u21D1'
618
+ entities["rArr"] = u'\u21D2'
619
+ entities["dArr"] = u'\u21D3'
620
+ entities["hArr"] = u'\u21D4'
621
+ entities["forall"] = u'\u2200'
622
+ entities["part"] = u'\u2202'
623
+ entities["exist"] = u'\u2203'
624
+ entities["empty"] = u'\u2205'
625
+ entities["nabla"] = u'\u2207'
626
+ entities["isin"] = u'\u2208'
627
+ entities["notin"] = u'\u2209'
628
+ entities["ni"] = u'\u220B'
629
+ entities["prod"] = u'\u220F'
630
+ entities["sum"] = u'\u2211'
631
+ entities["minus"] = u'\u2212'
632
+ entities["lowast"] = u'\u2217'
633
+ entities["radic"] = u'\u221A'
634
+ entities["prop"] = u'\u221D'
635
+ entities["infin"] = u'\u221E'
636
+ entities["ang"] = u'\u2220'
637
+ entities["and"] = u'\u2227'
638
+ entities["or"] = u'\u2228'
639
+ entities["cap"] = u'\u2229'
640
+ entities["cup"] = u'\u222A'
641
+ entities["int"] = u'\u222B'
642
+ entities["there4"] = u'\u2234'
643
+ entities["sim"] = u'\u223C'
644
+ entities["cong"] = u'\u2245'
645
+ entities["asymp"] = u'\u2248'
646
+ entities["ne"] = u'\u2260'
647
+ entities["equiv"] = u'\u2261'
648
+ entities["le"] = u'\u2264'
649
+ entities["ge"] = u'\u2265'
650
+ entities["sub"] = u'\u2282'
651
+ entities["sup"] = u'\u2283'
652
+ entities["nsub"] = u'\u2284'
653
+ entities["sube"] = u'\u2286'
654
+ entities["supe"] = u'\u2287'
655
+ entities["oplus"] = u'\u2295'
656
+ entities["otimes"] = u'\u2297'
657
+ entities["perp"] = u'\u22A5'
658
+ entities["sdot"] = u'\u22C5'
659
+ entities["lceil"] = u'\u2308'
660
+ entities["rceil"] = u'\u2309'
661
+ entities["lfloor"] = u'\u230A'
662
+ entities["rfloor"] = u'\u230B'
663
+ entities["lang"] = u'\u2329'
664
+ entities["rang"] = u'\u232A'
665
+ entities["loz"] = u'\u25CA'
666
+ entities["spades"] = u'\u2660'
667
+ entities["clubs"] = u'\u2663'
668
+ entities["hearts"] = u'\u2665'
669
+ entities["diams"] = u'\u2666'
670
+ entities["quot"] = u'\"'
671
+ entities["amp"] = u'&'
672
+ entities["lt"] = u'<'
673
+ entities["gt"] = u'>'
674
+ entities["OElig"] = u'\u0152'
675
+ entities["oelig"] = u'\u0153'
676
+ entities["Scaron"] = u'\u0160'
677
+ entities["scaron"] = u'\u0161'
678
+ entities["Yuml"] = u'\u0178'
679
+ entities["circ"] = u'\u02C6'
680
+ entities["tilde"] = u'\u02DC'
681
+ entities["ensp"] = u'\u2002'
682
+ entities["emsp"] = u'\u2003'
683
+ entities["thinsp"] = u'\u2009'
684
+ entities["zwnj"] = u'\u200C'
685
+ entities["zwj"] = u'\u200D'
686
+ entities["lrm"] = u'\u200E'
687
+ entities["rlm"] = u'\u200F'
688
+ entities["ndash"] = u'\u2013'
689
+ entities["mdash"] = u'\u2014'
690
+ entities["lsquo"] = u'\u2018'
691
+ entities["rsquo"] = u'\u2019'
692
+ entities["sbquo"] = u'\u201A'
693
+ entities["ldquo"] = u'\u201C'
694
+ entities["rdquo"] = u'\u201D'
695
+ entities["bdquo"] = u'\u201E'
696
+ entities["dagger"] = u'\u2020'
697
+ entities["Dagger"] = u'\u2021'
698
+ entities["permil"] = u'\u2030'
699
+ entities["lsaquo"] = u'\u2039'
700
+ entities["rsaquo"] = u'\u203A'
701
+ entities["euro"] = u'\u20AC'
702
+ parser.entity.update(entities)
703
+
704
+ return parser
705
+