You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello student. Thank you for downloading a CORGIS library. However, you do not need to open this library. Instead you should use the following:
3
+
4
+
import billionaires
5
+
6
+
If you opened the file because you are curious how this library works, then well done! We hope that you find it a useful learning experience. However, you should know that this code is meant to solve somewhat esoteric pedagogical problems, so it is often not best practices.
7
+
'''
8
+
9
+
importsysas_sys
10
+
importosas_os
11
+
importjsonas_json
12
+
importsqlite3as_sql
13
+
importdifflibas_difflib
14
+
15
+
class_Constants(object):
16
+
'''
17
+
Global singleton object to hide some of the constants; some IDEs reveal internal module details very aggressively, and there's no other way to hide stuff.
18
+
'''
19
+
_HEADER= {'User-Agent':
20
+
'CORGIS Billionaires library for educational purposes'}
21
+
_PYTHON_3=_sys.version_info>= (3, 0)
22
+
_TEST=False
23
+
_HARDWARE=1000
24
+
25
+
if_Constants._PYTHON_3:
26
+
importurllib.requestas_request
27
+
fromurllib.parseimportquote_plusas_quote_plus
28
+
fromurllib.errorimportHTTPErroras_HTTPError
29
+
else:
30
+
importurllib2as_urllib2
31
+
fromurllibimportquote_plusas_quote_plus
32
+
fromurllib2importHTTPErroras_HTTPError
33
+
34
+
classDatasetException(Exception):
35
+
''' Thrown when there is an error loading the dataset for some reason.'''
raiseDatasetException("Error! Could not find a \"{0}\" file. Make sure that there is a \"{0}\" in the same directory as \"{1}.py\"! Spelling is very important here.".format(_Constants._DATABASE_NAME, __name__))
raiseDatasetException("Error! Could not read the \"{0}\" file. Make sure that it readable by changing its permissions. You may need to get help from your instructor.".format(_Constants._DATABASE_NAME, __name__))
_sys.stderr.write('The local cache (\"\") will not be updated. Make sure that it is writable by changing its permissions. You may need to get help from your instructor.\n'.format(_Constants._DATABASE_NAME))
0 commit comments