def is_url(self, string): """ Test if a pdf being submitted is a valid URL """ try: urlparse(string, rule="IRI") return True except: return False
def is_url(self, string): """ Test if a pdf being submitted is a valid URL """ try: urlparse(string, rule="IRI") return True except Exception: return False
def _apply_icon(app, icon): app_path = osx.path_for_app(app) if not app_path: raise AppMissingError("Application not found: '{0}'".format(app)) try: components = urlparse(icon) tmpdir = mkdtemp() icon_path = os.path.join(tmpdir, os.path.basename(components["path"])) print(tty.progress("Downloading {0} icon: {1}".format(app, icon))) curl(icon, icon_path) except ValueError: icon_path = icon osx.set_icon(app_path, icon_path)