Example #1
0
 def isSameName(self, other):
     """Return true if two company have the same name
     and/or companyID."""
     if not isinstance(other, self.__class__):
         return False
     if 'name' in self.data and \
             'name' in other.data and \
             build_company_name(self.data) == \
             build_company_name(other.data):
         return True
     if self.accessSystem == other.accessSystem and \
             self.companyID is not None and \
             self.companyID == other.companyID:
         return True
     return False
Example #2
0
 def isSameName(self, other):
     """Return true if two company have the same name
     and/or companyID."""
     if not isinstance(other, self.__class__):
         return 0
     if self.data.has_key('name') and \
             other.data.has_key('name') and \
             build_company_name(self.data) == \
             build_company_name(other.data):
         return 1
     if self.accessSystem == other.accessSystem and \
             self.companyID is not None and \
             self.companyID == other.companyID:
         return 1
     return 0
Example #3
0
 def isSameName(self, other):
     """Return true if two company have the same name
     and/or companyID."""
     if not isinstance(other, self.__class__):
         return 0
     if self.data.has_key('name') and \
             other.data.has_key('name') and \
             build_company_name(self.data) == \
             build_company_name(other.data):
         return 1
     if self.accessSystem == other.accessSystem and \
             self.companyID is not None and \
             self.companyID == other.companyID:
         return 1
     return 0
Example #4
0
 def isSameName(self, other):
     """Return true if two company have the same name
     and/or companyID."""
     if not isinstance(other, self.__class__):
         return False
     if 'name' in self.data and \
             'name' in other.data and \
             build_company_name(self.data) == \
             build_company_name(other.data):
         return True
     if self.accessSystem == other.accessSystem and \
             self.companyID is not None and \
             self.companyID == other.companyID:
         return True
     return False
Example #5
0
 def get_imdbID(self, mop):
     """Return the imdbID for the given Movie, Person, Character or Company
     object."""
     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.title2imdbID(build_title(mop, canonical=0,
                                             ptdf=0, appendKind=False),
                                             mop['kind'])
     elif isinstance(mop, Person.Person):
         if mop.personID is not None:
             imdbID = aSystem.get_imdbPersonID(mop.personID)
         else:
             imdbID = aSystem.name2imdbID(build_name(mop, canonical=1))
     elif isinstance(mop, Character.Character):
         if mop.characterID is not None:
             imdbID = aSystem.get_imdbCharacterID(mop.characterID)
         else:
             # canonical=0 ?
             imdbID = aSystem.character2imdbID(build_name(mop, canonical=1))
     elif isinstance(mop, Company.Company):
         if mop.companyID is not None:
             imdbID = aSystem.get_imdbCompanyID(mop.companyID)
         else:
             imdbID = aSystem.company2imdbID(build_company_name(mop))
     else:
         raise IMDbError('object ' + repr(mop) + \
                     ' is not a Movie, Person or Character instance')
     return imdbID
Example #6
0
 def get_imdbID(self, mop):
     """Return the imdbID for the given Movie, Person, Character or Company
     object."""
     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.title2imdbID(
                 build_title(mop, canonical=0, ptdf=0, appendKind=False),
                 mop['kind'])
     elif isinstance(mop, Person.Person):
         if mop.personID is not None:
             imdbID = aSystem.get_imdbPersonID(mop.personID)
         else:
             imdbID = aSystem.name2imdbID(build_name(mop, canonical=1))
     elif isinstance(mop, Character.Character):
         if mop.characterID is not None:
             imdbID = aSystem.get_imdbCharacterID(mop.characterID)
         else:
             # canonical=0 ?
             imdbID = aSystem.character2imdbID(build_name(mop, canonical=1))
     elif isinstance(mop, Company.Company):
         if mop.companyID is not None:
             imdbID = aSystem.get_imdbCompanyID(mop.companyID)
         else:
             imdbID = aSystem.company2imdbID(build_company_name(mop))
     else:
         raise IMDbError('object ' + repr(mop) + \
                     ' is not a Movie, Person or Character instance')
     return imdbID
Example #7
0
class DOMHTMLSearchCompanyParser(DOMHTMLSearchMovieParser):
    _BaseParser = DOMBasicCompanyParser
    _notDirectHitTitle = '<title>find - imdb'
    _titleBuilder = lambda self, x: build_company_name(x)
    _linkPrefix = '/company/co'

    _attrs = [
        Attribute(key='data',
                  multi=True,
                  path={
                      'link': "./a[1]/@href",
                      'name': "./a[1]/text()",
                      'notes': "./text()[1]"
                  },
                  postprocess=lambda x:
                  (analyze_imdbid(x.get('link')),
                   analyze_company_name(x.get('name') + (x.get('notes') or ''),
                                        stripNotes=True)))
    ]

    extractors = [
        Extractor(
            label='search',
            path=
            "//td[@class='result_text']/a[starts-with(@href, '/company/co')]/..",
            attrs=_attrs)
    ]
Example #8
0
 def _getitem(self, key):
     """Handle special keys."""
     # XXX: can a company have an imdbIndex?
     if 'name' in self.data:
         if key == 'long imdb name':
             return build_company_name(self.data)
     return None
Example #9
0
 def _getitem(self, key):
     """Handle special keys."""
     ## XXX: can a company have an imdbIndex?
     if self.data.has_key('name'):
         if key == 'long imdb name':
             return build_company_name(self.data)
     return None
Example #10
0
 def get_imdbCompanyID(self, companyID):
     """Translate a companyID in an imdbID.
     If not in the database, try an Exact Primary Name search on IMDb;
     return None if it's unable to get the imdbID.
     """
     try:
         company = CompanyName.get(companyID)
     except NotFoundError:
         return None
     imdbID = company.imdbID
     if imdbID is not None: return '%07d' % imdbID
     n_dict = {'name': company.name, 'country': company.countryCode}
     namline = build_company_name(n_dict)
     imdbID = self.company2imdbID(namline)
     if imdbID is not None:
         try:
             company.imdbID = int(imdbID)
         except:
             pass
     return imdbID
Example #11
0
        if soundexCode is None:
            condition = ISNULL(CompanyName.q.namePcodeNf)
        else:
            if name.endswith(']'):
                condition = CompanyName.q.namePcodeSf == soundexCode
            else:
                condition = CompanyName.q.namePcodeNf == soundexCode
        try:
            qr = [(q.id, {
                'name': q.name,
                'country': q.countryCode
            }) for q in CompanyName.select(condition)]
        except NotFoundError, e:
            raise IMDbDataAccessError, \
                    'unable to search the database: "%s"' % str(e)
        qr[:] = [(x[0], build_company_name(x[1])) for x in qr]
        res = scan_company_names(qr, name, results)
        res[:] = [x[1] for x in res]
        # Purge empty country keys.
        returnl = []
        for x in res:
            tmpd = x[1]
            country = tmpd.get('country')
            if country is None and tmpd.has_key('country'):
                del tmpd['country']
            returnl.append((x[0], tmpd))
        return returnl

    def get_company_main(self, companyID, results=0):
        # Every company information is retrieved from here.
        infosets = self.get_company_infoset()