desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'Set self.currentRole to a Character or Person instance.'
| def _set_currentRole(self, role):
| if isinstance(role, (unicode, str)):
if (not role):
self.__role = None
else:
self.__role = self._roleClass(name=role, modFunct=self.modFunct, accessSystem=self.accessSystem)
elif isinstance(role, (list, tuple)):
self.__role = RolesList()
for item in role:
... |
'Reset the object.'
| def reset(self):
| self.data = {}
self.myID = None
self.notes = u''
self.titlesRefs = {}
self.namesRefs = {}
self.charactersRefs = {}
self.modFunct = modClearRefs
self.current_info = []
self.infoset2keys = {}
self.key2infoset = {}
self.__role = None
self._reset()
|
'Reset the dictionary.'
| def clear(self):
| self.data.clear()
self.notes = u''
self.titlesRefs = {}
self.namesRefs = {}
self.charactersRefs = {}
self.current_info = []
self.infoset2keys = {}
self.key2infoset = {}
self.__role = None
self._clear()
|
'Return the current set of information retrieved.'
| def get_current_info(self):
| return self.current_info
|
'Update the mappings between infoset and keys.'
| def update_infoset_map(self, infoset, keys, mainInfoset):
| if (keys is None):
keys = []
if (mainInfoset is not None):
theIS = mainInfoset
else:
theIS = infoset
self.infoset2keys[theIS] = keys
for key in keys:
self.key2infoset[key] = theIS
|
'Set the current set of information retrieved.'
| def set_current_info(self, ci):
| self.current_info = ci
|
'Add a set of information to the current list.'
| def add_to_current_info(self, val, keys=None, mainInfoset=None):
| if (val not in self.current_info):
self.current_info.append(val)
self.update_infoset_map(val, keys, mainInfoset)
|
'Return true if the given set of information is in the list.'
| def has_current_info(self, val):
| return (val in self.current_info)
|
'Set the fuction used to modify the strings.'
| def set_mod_funct(self, modFunct):
| if (modFunct is None):
modFunct = modClearRefs
self.modFunct = modFunct
|
'Update the dictionary with the references to movies.'
| def update_titlesRefs(self, titlesRefs):
| self.titlesRefs.update(titlesRefs)
|
'Return the dictionary with the references to movies.'
| def get_titlesRefs(self):
| return self.titlesRefs
|
'Update the dictionary with the references to names.'
| def update_namesRefs(self, namesRefs):
| self.namesRefs.update(namesRefs)
|
'Return the dictionary with the references to names.'
| def get_namesRefs(self):
| return self.namesRefs
|
'Update the dictionary with the references to characters.'
| def update_charactersRefs(self, charactersRefs):
| self.charactersRefs.update(charactersRefs)
|
'Return the dictionary with the references to characters.'
| def get_charactersRefs(self):
| return self.charactersRefs
|
'Set the movie data to the given dictionary; if \'override\' is
set, the previous data is removed, otherwise the two dictionary
are merged.'
| def set_data(self, data, override=0):
| if (not override):
self.data.update(data)
else:
self.data = data
|
'Return movieID, personID, characterID or companyID.'
| def getID(self):
| raise NotImplementedError('override this method')
|
'Compare two Movie, Person, Character or Company objects.'
| def __cmp__(self, other):
| if (self.cmpFunct is None):
return (-1)
if (not isinstance(other, self.__class__)):
return (-1)
return self.cmpFunct(other)
|
'Hash for this object.'
| def __hash__(self):
| theID = self.getID()
if ((theID is not None) and (self.accessSystem not in ('UNKNOWN', None))):
acs = self.accessSystem
if (acs in ('mobile', 'httpThin')):
acs = 'http'
s4h = ('%s:%s[%s]' % (self.__class__.__name__, theID, acs))
else:
s4h = repr(self)
return h... |
'Return True if the two represent the same object.'
| def isSame(self, other):
| if (not isinstance(other, self.__class__)):
return 0
if (hash(self) == hash(other)):
return 1
return 0
|
'Number of items in the data dictionary.'
| def __len__(self):
| return len(self.data)
|
'Return a XML representation of the specified key, or None
if empty. If _with_add_keys is False, dinamically generated
keys are excluded.'
| def getAsXML(self, key, _with_add_keys=True):
| origModFunct = self.modFunct
self.modFunct = modNull
key = self.keys_alias.get(key, key)
if ((not _with_add_keys) and (key in self._additional_keys())):
self.modFunct = origModFunct
return None
try:
withRefs = False
if ((key in self.keys_tomodify) and (origModFunct no... |
'Return a XML representation of the whole object.
If _with_add_keys is False, dinamically generated keys are excluded.'
| def asXML(self, _with_add_keys=True):
| (beginTag, endTag) = _tag4TON(self, addAccessSystem=True, _containerOnly=True)
resList = [beginTag]
for key in self.keys():
value = self.getAsXML(key, _with_add_keys=_with_add_keys)
if (not value):
continue
resList.append(value)
resList.append(endTag)
head = (_xml... |
'Handle special keys.'
| def _getitem(self, key):
| return None
|
'Return the value for a given key, checking key aliases;
a KeyError exception is raised if the key is not found.'
| def __getitem__(self, key):
| value = self._getitem(key)
if (value is not None):
return value
key = self.keys_alias.get(key, key)
rawData = self.data[key]
if ((key in self.keys_tomodify) and (self.modFunct not in (None, modNull))):
try:
return modifyStrings(rawData, self.modFunct, self.titlesRefs, sel... |
'Directly store the item with the given key.'
| def __setitem__(self, key, item):
| self.data[key] = item
|
'Remove the given section or key.'
| def __delitem__(self, key):
| del self.data[key]
|
'Valid keys to append to the data.keys() list.'
| def _additional_keys(self):
| return []
|
'Return a list of valid keys.'
| def keys(self):
| return (self.data.keys() + self._additional_keys())
|
'Return the items in the dictionary.'
| def items(self):
| return [(k, self.get(k)) for k in self.keys()]
|
'Return the values in the dictionary.'
| def values(self):
| return [self.get(k) for k in self.keys()]
|
'Return true if a given section is defined.'
| def has_key(self, key):
| try:
self.__getitem__(key)
except KeyError:
return 0
return 1
|
'Return the given section, or default if it\'s not found.'
| def get(self, key, failobj=None):
| try:
return self.__getitem__(key)
except KeyError:
return failobj
|
'String representation of an object.'
| def __repr__(self):
| raise NotImplementedError('override this method')
|
'Movie title or person name.'
| def __str__(self):
| raise NotImplementedError('override this method')
|
'The item is appended to the list identified by the given key.'
| def append_item(self, key, item):
| self.data.setdefault(key, []).append(item)
|
'Directly store the item with the given key.'
| def set_item(self, key, item):
| self.data[key] = item
|
'Return true if self.data contains something.'
| def __nonzero__(self):
| if self.data:
return 1
return 0
|
'Return a deep copy of the object itself.'
| def copy(self):
| return deepcopy(self)
|
'Initialize the parser.
*defaults* -- defaults values.
*confFile* -- the file (or list of files) to parse.'
| def __init__(self, defaults=None, confFile=None, *args, **kwds):
| ConfigParser.ConfigParser.__init__(self, defaults=defaults)
if (confFile is None):
dotFileName = ('.' + confFileName)
confFile = [os.path.join(os.getcwd(), confFileName), os.path.join(os.getcwd(), dotFileName), os.path.join(os.path.expanduser('~'), confFileName), os.path.join(os.path.expanduser(... |
'Option names are case sensitive.'
| def optionxform(self, optionstr):
| return optionstr
|
'Custom substitutions for values.'
| def _manageValue(self, value):
| if (not isinstance(value, (str, unicode))):
return value
vlower = value.lower()
if (vlower in self._boolean_states):
return self._boolean_states[vlower]
elif (vlower == 'none'):
return None
return value
|
'Return the value of an option from a given section.'
| def get(self, section, option, *args, **kwds):
| value = ConfigParser.ConfigParser.get(self, section, option, *args, **kwds)
return self._manageValue(value)
|
'Return a list of (key, value) tuples of items of the
given section.'
| def items(self, section, *args, **kwds):
| if ((section != 'DEFAULT') and (not self.has_section(section))):
return []
keys = ConfigParser.ConfigParser.options(self, section)
return [(k, self.get(section, k, *args, **kwds)) for k in keys]
|
'Return a dictionary of items of the specified section.'
| def getDict(self, section):
| return dict(self.items(section))
|
'Initialize the access system.
If specified, defaultModFunct is the function used by
default by the Person, Movie and Character objects, when
accessing their text fields.'
| def __init__(self, defaultModFunct=None, results=20, keywordsResults=100, *arguments, **keywords):
| self._defModFunct = defaultModFunct
try:
results = int(results)
except (TypeError, ValueError):
results = 20
if (results < 1):
results = 20
self._results = results
try:
keywordsResults = int(keywordsResults)
except (TypeError, ValueError):
keywordsResu... |
'Set the urls used accessing the IMDb site.'
| def set_imdb_urls(self, imdbURL_base):
| imdbURL_base = imdbURL_base.strip().strip('"\'')
if (not imdbURL_base.startswith('http://')):
imdbURL_base = ('http://%s' % imdbURL_base)
if (not imdbURL_base.endswith('/')):
imdbURL_base = ('%s/' % imdbURL_base)
imdbURL_movie_base = ('%stitle/' % imdbURL_base)
imdbURL_movie_main = (... |
'Normalize the given movieID.'
| def _normalize_movieID(self, movieID):
| return movieID
|
'Normalize the given personID.'
| def _normalize_personID(self, personID):
| return personID
|
'Normalize the given characterID.'
| def _normalize_characterID(self, characterID):
| return characterID
|
'Normalize the given companyID.'
| def _normalize_companyID(self, companyID):
| return companyID
|
'Handle title aliases.'
| def _get_real_movieID(self, movieID):
| return movieID
|
'Handle name aliases.'
| def _get_real_personID(self, personID):
| return personID
|
'Handle character name aliases.'
| def _get_real_characterID(self, characterID):
| return characterID
|
'Handle company name aliases.'
| def _get_real_companyID(self, companyID):
| return companyID
|
'Return methods with the name starting with prefname.'
| def _get_infoset(self, prefname):
| infoset = []
excludes = (('%sinfoset' % prefname),)
preflen = len(prefname)
for name in dir(self.__class__):
if (name.startswith(prefname) and (name not in excludes)):
member = getattr(self.__class__, name)
if isinstance(member, MethodType):
infoset.append... |
'Return the list of info set available for movies.'
| def get_movie_infoset(self):
| return self._get_infoset('get_movie_')
|
'Return the list of info set available for persons.'
| def get_person_infoset(self):
| return self._get_infoset('get_person_')
|
'Return the list of info set available for characters.'
| def get_character_infoset(self):
| return self._get_infoset('get_character_')
|
'Return the list of info set available for companies.'
| def get_company_infoset(self):
| return self._get_infoset('get_company_')
|
'Return a Movie object for the given movieID.
The movieID is something used to univocally identify a movie;
it can be the imdbID used by the IMDb web server, a file
pointer, a line number in a file, an ID in a database, etc.
info is the list of sets of information to retrieve.
If specified, modFunct will be the functio... | def get_movie(self, movieID, info=Movie.Movie.default_info, modFunct=None):
| movieID = self._normalize_movieID(movieID)
movieID = self._get_real_movieID(movieID)
movie = Movie.Movie(movieID=movieID, accessSystem=self.accessSystem)
modFunct = (modFunct or self._defModFunct)
if (modFunct is not None):
movie.set_mod_funct(modFunct)
self.update(movie, info)
retur... |
'Return a list of tuples (movieID, {movieData})'
| def _search_movie(self, title, results):
| raise NotImplementedError('override this method')
|
'Return a list of Movie objects for a query for the given title.
The results argument is the maximum number of results to return.'
| def search_movie(self, title, results=None, _episodes=False):
| if (results is None):
results = self._results
try:
results = int(results)
except (ValueError, OverflowError):
results = 20
if (not isinstance(title, unicode)):
title = unicode(title, encoding, 'replace')
if (not _episodes):
res = self._search_movie(title, resu... |
'Return a list of tuples (movieID, {movieData})'
| def _search_episode(self, title, results):
| raise NotImplementedError('override this method')
|
'Return a list of Movie objects for a query for the given title.
The results argument is the maximum number of results to return;
this method searches only for titles of tv (mini) series\' episodes.'
| def search_episode(self, title, results=None):
| return self.search_movie(title, results=results, _episodes=True)
|
'Return a Person object for the given personID.
The personID is something used to univocally identify a person;
it can be the imdbID used by the IMDb web server, a file
pointer, a line number in a file, an ID in a database, etc.
info is the list of sets of information to retrieve.
If specified, modFunct will be the fun... | def get_person(self, personID, info=Person.Person.default_info, modFunct=None):
| personID = self._normalize_personID(personID)
personID = self._get_real_personID(personID)
person = Person.Person(personID=personID, accessSystem=self.accessSystem)
modFunct = (modFunct or self._defModFunct)
if (modFunct is not None):
person.set_mod_funct(modFunct)
self.update(person, in... |
'Return a list of tuples (personID, {personData})'
| def _search_person(self, name, results):
| raise NotImplementedError('override this method')
|
'Return a list of Person objects for a query for the given name.
The results argument is the maximum number of results to return.'
| def search_person(self, name, results=None):
| if (results is None):
results = self._results
try:
results = int(results)
except (ValueError, OverflowError):
results = 20
if (not isinstance(name, unicode)):
name = unicode(name, encoding, 'replace')
res = self._search_person(name, results)
return [Person.Person(... |
'Return a Character object for the given characterID.
The characterID is something used to univocally identify a character;
it can be the imdbID used by the IMDb web server, a file
pointer, a line number in a file, an ID in a database, etc.
info is the list of sets of information to retrieve.
If specified, modFunct wil... | def get_character(self, characterID, info=Character.Character.default_info, modFunct=None):
| characterID = self._normalize_characterID(characterID)
characterID = self._get_real_characterID(characterID)
character = Character.Character(characterID=characterID, accessSystem=self.accessSystem)
modFunct = (modFunct or self._defModFunct)
if (modFunct is not None):
character.set_mod_funct(... |
'Return a list of tuples (characterID, {characterData})'
| def _search_character(self, name, results):
| raise NotImplementedError('override this method')
|
'Return a list of Character objects for a query for the given name.
The results argument is the maximum number of results to return.'
| def search_character(self, name, results=None):
| if (results is None):
results = self._results
try:
results = int(results)
except (ValueError, OverflowError):
results = 20
if (not isinstance(name, unicode)):
name = unicode(name, encoding, 'replace')
res = self._search_character(name, results)
return [Character.C... |
'Return a Company object for the given companyID.
The companyID is something used to univocally identify a company;
it can be the imdbID used by the IMDb web server, a file
pointer, a line number in a file, an ID in a database, etc.
info is the list of sets of information to retrieve.
If specified, modFunct will be the... | def get_company(self, companyID, info=Company.Company.default_info, modFunct=None):
| companyID = self._normalize_companyID(companyID)
companyID = self._get_real_companyID(companyID)
company = Company.Company(companyID=companyID, accessSystem=self.accessSystem)
modFunct = (modFunct or self._defModFunct)
if (modFunct is not None):
company.set_mod_funct(modFunct)
self.updat... |
'Return a list of tuples (companyID, {companyData})'
| def _search_company(self, name, results):
| raise NotImplementedError('override this method')
|
'Return a list of Company objects for a query for the given name.
The results argument is the maximum number of results to return.'
| def search_company(self, name, results=None):
| if (results is None):
results = self._results
try:
results = int(results)
except (ValueError, OverflowError):
results = 20
if (not isinstance(name, unicode)):
name = unicode(name, encoding, 'replace')
res = self._search_company(name, results)
return [Company.Compa... |
'Return a list of \'keyword\' strings.'
| def _search_keyword(self, keyword, results):
| raise NotImplementedError('override this method')
|
'Search for existing keywords, similar to the given one.'
| def search_keyword(self, keyword, results=None):
| if (results is None):
results = self._keywordsResults
try:
results = int(results)
except (ValueError, OverflowError):
results = 100
if (not isinstance(keyword, unicode)):
keyword = unicode(keyword, encoding, 'replace')
return self._search_keyword(keyword, results)
|
'Return a list of tuples (movieID, {movieData})'
| def _get_keyword(self, keyword, results):
| raise NotImplementedError('override this method')
|
'Return a list of movies for the given keyword.'
| def get_keyword(self, keyword, results=None):
| if (results is None):
results = self._keywordsResults
try:
results = int(results)
except (ValueError, OverflowError):
results = 100
if (not isinstance(keyword, unicode)):
keyword = unicode(keyword, encoding, 'replace')
res = self._get_keyword(keyword, results)
ret... |
'Return the list of the top 250 or bottom 100 movies.'
| def _get_top_bottom_movies(self, kind):
| raise NotImplementedError('override this method')
|
'Return the list of the top 250 movies.'
| def get_top250_movies(self):
| res = self._get_top_bottom_movies('top')
return [Movie.Movie(movieID=self._get_real_movieID(mi), data=md, modFunct=self._defModFunct, accessSystem=self.accessSystem) for (mi, md) in res]
|
'Return the list of the bottom 100 movies.'
| def get_bottom100_movies(self):
| res = self._get_top_bottom_movies('bottom')
return [Movie.Movie(movieID=self._get_real_movieID(mi), data=md, modFunct=self._defModFunct, accessSystem=self.accessSystem) for (mi, md) in res]
|
'Return a Movie object.'
| def new_movie(self, *arguments, **keywords):
| if ('title' in keywords):
if (not isinstance(keywords['title'], unicode)):
keywords['title'] = unicode(keywords['title'], encoding, 'replace')
elif (len(arguments) > 1):
if (not isinstance(arguments[1], unicode)):
arguments[1] = unicode(arguments[1], encoding, 'replace')
... |
'Return a Person object.'
| def new_person(self, *arguments, **keywords):
| if ('name' in keywords):
if (not isinstance(keywords['name'], unicode)):
keywords['name'] = unicode(keywords['name'], encoding, 'replace')
elif (len(arguments) > 1):
if (not isinstance(arguments[1], unicode)):
arguments[1] = unicode(arguments[1], encoding, 'replace')
... |
'Return a Character object.'
| def new_character(self, *arguments, **keywords):
| if ('name' in keywords):
if (not isinstance(keywords['name'], unicode)):
keywords['name'] = unicode(keywords['name'], encoding, 'replace')
elif (len(arguments) > 1):
if (not isinstance(arguments[1], unicode)):
arguments[1] = unicode(arguments[1], encoding, 'replace')
... |
'Return a Company object.'
| def new_company(self, *arguments, **keywords):
| if ('name' in keywords):
if (not isinstance(keywords['name'], unicode)):
keywords['name'] = unicode(keywords['name'], encoding, 'replace')
elif (len(arguments) > 1):
if (not isinstance(arguments[1], unicode)):
arguments[1] = unicode(arguments[1], encoding, 'replace')
... |
'Given a Movie, Person, Character or Company object with only
partial information, retrieve the required set of information.
info is the list of sets of information to retrieve.
If override is set, the information are retrieved and updated
even if they\'re already in the object.'
| def update(self, mop, info=None, override=0):
| mopID = None
prefix = ''
if isinstance(mop, Movie.Movie):
mopID = mop.movieID
prefix = 'movie'
elif isinstance(mop, Person.Person):
mopID = mop.personID
prefix = 'person'
elif isinstance(mop, Character.Character):
mopID = mop.characterID
prefix = 'char... |
'Translate a movieID in an imdbID (the ID used by the IMDb
web server); must be overridden by the subclass.'
| def get_imdbMovieID(self, movieID):
| raise NotImplementedError('override this method')
|
'Translate a personID in a imdbID (the ID used by the IMDb
web server); must be overridden by the subclass.'
| def get_imdbPersonID(self, personID):
| raise NotImplementedError('override this method')
|
'Translate a characterID in a imdbID (the ID used by the IMDb
web server); must be overridden by the subclass.'
| def get_imdbCharacterID(self, characterID):
| raise NotImplementedError('override this method')
|
'Translate a companyID in a imdbID (the ID used by the IMDb
web server); must be overridden by the subclass.'
| def get_imdbCompanyID(self, companyID):
| raise NotImplementedError('override this method')
|
'Search the IMDb akas server for the given title or name.'
| def _searchIMDb(self, kind, ton, title_kind=None):
| if (not ton):
return None
ton = ton.strip('"')
aSystem = IMDb('mobile')
if (kind == 'tt'):
searchFunct = aSystem.search_movie
check = 'long imdb title'
elif (kind == 'nm'):
searchFunct = aSystem.search_person
check = 'long imdb name'
elif (kind... |
'Translate a movie title (in the plain text data files format)
to an imdbID.
Try an Exact Primary Title search on IMDb;
return None if it\'s unable to get the imdbID;
Always specify kind: movie, tv series, video game etc. or search can
return list of IDs if multiple matches found'
| def title2imdbID(self, title, kind=None):
| return self._searchIMDb('tt', title, kind)
|
'Translate a person name in an imdbID.
Try an Exact Primary Name search on IMDb;
return None if it\'s unable to get the imdbID.'
| def name2imdbID(self, name):
| return self._searchIMDb('nm', name)
|
'Translate a character name in an imdbID.
Try an Exact Primary Name search on IMDb;
return None if it\'s unable to get the imdbID.'
| def character2imdbID(self, name):
| return self._searchIMDb('char', name)
|
'Translate a company name in an imdbID.
Try an Exact Primary Name search on IMDb;
return None if it\'s unable to get the imdbID.'
| def company2imdbID(self, name):
| return self._searchIMDb('co', name)
|
'Return the imdbID for the given Movie, Person, Character or Company
object.'
| def get_imdbID(self, mop):
| imdbID = None
if (mop.accessSystem == self.accessSystem):
aSystem = self
else:
aSystem = IMDb(mop.accessSystem)
if isinstance(mop, Movie.Movie):
if (mop.movieID is not None):
imdbID = aSystem.get_imdbMovieID(mop.movieID)
else:
imdbID = aSystem.titl... |
'Return the main IMDb URL for the given Movie, Person,
Character or Company object, or None if unable to get it.'
| def get_imdbURL(self, mop):
| imdbID = self.get_imdbID(mop)
if (imdbID is None):
return None
if isinstance(mop, Movie.Movie):
url_firstPart = imdbURL_movie_main
elif isinstance(mop, Person.Person):
url_firstPart = imdbURL_person_main
elif isinstance(mop, Character.Character):
url_firstPart = imdbU... |
'Return the special methods defined by the subclass.'
| def get_special_methods(self):
| sm_dict = {}
base_methods = []
for name in dir(IMDbBase):
member = getattr(IMDbBase, name)
if isinstance(member, MethodType):
base_methods.append(name)
for name in dir(self.__class__):
if (name.startswith('_') or (name in base_methods) or name.startswith('get_movie_')... |
'Initialize a Person object.
*personID* -- the unique identifier for the person.
*name* -- the name of the Person, if not in the data dictionary.
*myName* -- the nickname you use for this person.
*myID* -- your personal id for this person.
*data* -- a dictionary used to initialize the object.
*currentRole* -- a Charact... | def _init(self, **kwds):
| name = kwds.get('name')
if (name and (not self.data.has_key('name'))):
self.set_name(name)
self.personID = kwds.get('personID', None)
self.myName = kwds.get('myName', u'')
self.billingPos = kwds.get('billingPos', None)
|
'Reset the Person object.'
| def _reset(self):
| self.personID = None
self.myName = u''
self.billingPos = None
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.