return a version of url safe for use as a filename

def make_safe_filename_from_url(self, url):
        '''return a version of url safe for use as a filename'''
        r = re.compile("([^a-zA-Z0-9_.-])")
        filename = r.sub(lambda m : "%" + str(hex(ord(str(m.group(1))))).upper(), url)
        return filename