X-Git-Url: https://code.delx.au/bg-scripts/blobdiff_plain/7fef5e45b01eb71bba28aefb7a50be3fcca9345c..f667bb5991af1eb85cb9585b4dfbdf7ea80f6024:/lib/wget_lib.py diff --git a/lib/wget_lib.py b/lib/wget_lib.py deleted file mode 100644 index ce79d86..0000000 --- a/lib/wget_lib.py +++ /dev/null @@ -1,42 +0,0 @@ -#! python - -__all__ = ('parse_url', 'isImageURL', 'unique', 'removeDups', 'xRemoveDups') - -IMAGE_EXTENSIONS = ('PNG', 'JPG', 'JPEG', 'BMP', 'GIF', 'SWF', 'TIF', 'TIFF') - -def parse_url(url): - """Parses a url into a tuple of (hostname, directory, filename).""" - return ('hostname', 'directory', 'filename') - -def isImageURL(url): - """Checks if an filename is an image""" - try: - _, extension = url.rsplit('.', 1) - except ValueError: - # There was no '.' in the url - return False - else: - return extension.upper() in IMAGE_EXTENSIONS - -def unique(l): - list_iter = iter(l) - last_item = list_iter.next() - yield last_item - for item in list_iter: - if last_item != item: - yield item - last_item = item - -def removeDups(l): - """Removes duplicates from the list (Note: The ordering of the list may change)""" - return list(unique(sorted(l))) - -def xRemoveDups(l): - """Removes duplicates from the list. - Requires O(n) memory, objects must be hashable""" - yielded = set() - for elem in l: - if elem in yielded: - continue - yielded.add(elem) - yield elem