def medium_format(self): formats = [] for medium in self._mbrelease["medium-list"]: format_ = medium.get("format", u"") if format_: formats.append(format_) formats = util.list_unique(formats) return u"/".join(formats)
def gd3_filter_entries(entries): # First, filter out empty strings... filtered = list(filter(None, entries)) if len(filtered) == 0: return filtered # Then, filter out any duplicate strings... filtered = list_unique(filtered) return sorted(filtered)
def options(self, section): """Returns a list of options available in the specified section.""" try: options = self._config.options(section) except NoSectionError: if self.defaults: return self.defaults.options(section) raise else: if self.defaults: try: options.extend(self.defaults.options(section)) options = list_unique(options) except NoSectionError: pass return options
def test_main(self): self.assertEqual(util.list_unique([]), []) self.assertEqual(util.list_unique(iter([])), []) self.assertEqual(util.list_unique([1, 2, 3]), [1, 2, 3]) self.assertEqual(util.list_unique([1, 2, 1, 4]), [1, 2, 4]) self.assertEqual(util.list_unique([1, 1, 1, 2]), [1, 2])
def __init__(self, func, list_func, tags): self.__func = func self.__list_func = list_func self.tags = util.list_unique(tags) self.format(self.Dummy()) # Validate string