Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
try:
asset_path = external_assets.versioned_folder(file_path)
break
except IOError:
pass
if asset_path is not None:
if self.env.url:
# see if it's a complete url (rather than a folder)
# otherwise we want a relative path in the CSS
if self.env.url.startswith('http://')\
or self.env.url.startswith('https://')\
or self.env.url.startswith('//'):
replacement = urlparse.urljoin(self.env.url, asset_path)
else:
replacement = urlpath.relpathto(self.env.directory, self.output_path, self.env.absurl(asset_path))
else:
replacement = urlpath.relpathto(self.env.directory, self.output_path, asset_path)
if replacement is None:
url = urlpath.relpath(self.output_url,
urlparse.urljoin(self.source_url, url))
else:
url = replacement
else:
# Default mode: auto correct relative urls
# If path is an absolute one, keep it
if not self._is_abs_url(url):
# rewritten url: relative path from new location (output)
# to location of referenced file (source + current url)
url = urlpath.relpath(self.output_url,
break
except IOError:
pass
if asset_path is not None:
if self.env.url:
# see if it's a complete url (rather than a folder)
# otherwise we want a relative path in the CSS
if self.env.url.startswith('http://')\
or self.env.url.startswith('https://')\
or self.env.url.startswith('//'):
replacement = urlparse.urljoin(self.env.url, asset_path)
else:
replacement = urlpath.relpathto(self.env.directory, self.output_path, self.env.absurl(asset_path))
else:
replacement = urlpath.relpathto(self.env.directory, self.output_path, asset_path)
if replacement is None:
url = urlpath.relpath(self.output_url,
urlparse.urljoin(self.source_url, url))
else:
url = replacement
else:
# Default mode: auto correct relative urls
# If path is an absolute one, keep it
if not self._is_abs_url(url):
# rewritten url: relative path from new location (output)
# to location of referenced file (source + current url)
url = urlpath.relpath(self.output_url,
urlparse.urljoin(self.source_url, url))