def resources(self): files = [] anchors = self.find_links_in_content(self.markup) for anchor in anchors: resource = Resource(anchor.getText(), anchor.get('href'), self.web, "http://elearning.uni-heidelberg.de/mod/resource/") if resource.url == '' or resource.isOnExternalWebsite(): continue try: if resource.isAPage(): content = resource.load() f = Page(content, self.web).resources() files.append(f) else: files.append(resource) except urllib2.HTTPError as e: debug("Could not retrieve %s." % resource.url) continue return deflate(files)
def test_flatten_array_that_contains_non_iteratable_objects(self): a = ['a','b',[ Resource("File 1","view.pdf", None),'d'], Resource("File 2", "file.txt", None)] b = deflate(a) self.assertEqual(5, len(b))
def test_flatten_array(self): a = ['a','b',['c','d']] self.assertEqual(3, len(a)) b = deflate(a) self.assertEqual(4, len(b))