def _sameas(self, sameas): if sameas.startswith('http'): url = self.URL_SAMEAS % sameas sameas = sameas.replace('http%3A//', 'http://') data = self.get(url) if type(data) == list: for item in data[0]["duplicates"]: if item.find('http://rdf.freebase.com/ns/') > -1: item=item.replace('http://rdf.freebase.com/ns/', 'http://data.kbresearch.nl/fb:/').replace('en.','en/').replace('guid.','guid/') self._add(sameas, item.replace('http://dbpedia.org/resource/','http://data.kbresearch.nl/DBP:'), "same") else: return(False) elif isbn_check.isValid(sameas): data = self.get(self.URL_SAMEAS_ISBN % sameas) xml = lxml_lib.fromstring(data) for item in xml.iterchildren(): isbn = str(item.text) if not sameas == isbn and not sameas == isbn_check.convert(isbn): self._add(sameas, "http://data.kbresearch.nl/isbn:"+isbn, "same") else: url = self.URL_SAMEASQ % sameas data = self.get(url) if type(data) == list: for item in data[0]["duplicates"]: if item.find('http://rdf.freebase.com/ns/') > -1: item=item.replace('http://rdf.freebase.com/ns/', 'http://data.kbresearch.nl/fb:/').replace('en.','en/').replace('guid.','guid/') self._add(sameas, item.replace('http://dbpedia.org/resource/','http://data.kbresearch.nl/DBP:'), "same")
def _get_isbn_record(self, isbn): if isbn_check.isValid(isbn): self.isbn=isbn self._sameas() self._sru_lookup() self._openlibrary_lookup() self._ryerson_lookup() self._google_lookup() for item in self.keys(): if len(self[item]) == 0: self.__delitem__(item) self.isbn=isbn_check.convert(isbn) if not "ryerson" in self.keys(): self._ryerson_lookup() if not "openlibrary" in self.keys(): self._openlibrary_lookup() if not "google" in self.keys(): self._google_lookup() if not "librarything_sameas" in self.keys(): self._sameas() if not "sru" in self.keys(): self._sru_lookup() for item in self.keys(): if len(self[item]) == 0: self.__delitem__(item)