Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if self.source.isUrl() or isinstance(self.source.source, list):
raise self.SourceError('CSS files can be added only to a single file or string')
if not isinstance(path, list):
path = [path]
css_data = []
for p in path:
with codecs.open(p, encoding="UTF-8") as f:
css_data.append(f.read())
css_data = "\n".join(css_data)
if self.source.isFile():
with codecs.open(self.source.to_s(), encoding="UTF-8") as f:
inp = f.read()
self.source = Source(
inp.replace('', self._style_tag(css_data) + ''),
'string')
elif self.source.isString():
if '' in self.source.to_s():
self.source.source = self.source.to_s().replace(
'', self._style_tag(css_data) + '')
else:
self.source.source = self._style_tag(css_data) + self.source.to_s()
def __init__(self, url_or_file, source_type, options=None, toc=None, cover=None,
css=None, config=None, cover_first=None):
self.source = Source(url_or_file, source_type)
self.config = Config() if not config else config
try:
self.wkhtmltoimage = self.config.wkhtmltoimage.decode('utf-8')
except AttributeError:
self.wkhtmltoimage = self.config.wkhtmltoimage
self.xvfb = self.config.xvfb
self.options = {}
if self.source.isString():
self.options.update(self._find_options_in_meta(url_or_file))
if options:
self.options.update(options)
self.toc = toc if toc else {}