def removeDuplicates(self, repo): # XXX: rename!? """ remove plugins whose origin is not the repository specified @param repo (str): repository URL @return: None """ repo = trimURI(repo) for plugin in self.store.findChildren("div", title = True): slices = getSlices(plugin.pre.renderContents()) if "Source" in slices: # N.B.: plugin accepted if Source slice not present -- XXX: harmful? (e.g. includes simple config tweaks) try: source = decodePrettyLink(slices["Source"])["uri"] except ValueError: source = slices["Source"] source = trimURI(source) if source != repo: plugin.extract()
def testRemovesURLFragments(self): """removes URL fragments""" uri = "http://localhost/foo#bar" expected = "http://localhost/foo" self.assertEqual(expected, utils.trimURI(uri))
def testConvertsURIToLowercase(self): """converts URI to lowercase""" uri = "http://LocalHost/Foo" expected = "http://localhost/foo" self.assertEqual(expected, utils.trimURI(uri))
def testRemovesTrailingSlash(self): """removes trailing slash""" uri = "http://localhost/" expected = "http://localhost" self.assertEqual(expected, utils.trimURI(uri))