Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setup(self):
"""
Banana banana
"""
info('Setting up %s' % self.project_name, 'project')
for extension in list(self.extensions.values()):
info('Setting up %s' % extension.extension_name)
extension.setup()
sitemap = SitemapParser().parse(self.sitemap_path)
self.tree.build(sitemap, self.extensions)
info("Resolving symbols", 'resolution')
self.tree.resolve_symbols(self.app.database, self.app.link_resolver)
def __create_change_tracker(self):
try:
with open(os.path.join(self.get_private_folder(),
'change_tracker.p'), 'rb') as _:
self.change_tracker = pickle.loads(_.read())
if self.change_tracker.hard_dependencies_are_stale():
raise IOError
self.incremental = True
info("Building incrementally")
# pylint: disable=broad-except
except Exception:
info("Building from scratch")
shutil.rmtree(self.get_private_folder(), ignore_errors=True)
if self.output:
shutil.rmtree(self.output, ignore_errors=True)
self.change_tracker = ChangeTracker()
def setup(self):
"""
Banana banana
"""
info('Setting up %s' % self.project_name, 'project')
for extension in list(self.extensions.values()):
info('Setting up %s' % extension.extension_name)
extension.setup()
sitemap = SitemapParser().parse(self.sitemap_path)
self.tree.build(sitemap, self.extensions)
info("Resolving symbols", 'resolution')
self.tree.resolve_symbols(self.app.database, self.app.link_resolver)
def info(message):
core_info(message, domain='c-extension')
extra_classes = []
wset = pkg_resources.WorkingSet([])
distributions, _ = wset.find_plugins(pkg_resources.Environment(paths))
for dist in distributions:
sys.path.append(dist.location)
wset.add(dist)
for entry_point in wset.iter_entry_points(group='hotdoc.extensions',
name='get_extension_classes'):
try:
activation_function = entry_point.load()
classes = activation_function()
# pylint: disable=broad-except
except Exception as exc:
info("Failed to load %s %s" % (entry_point.module_name, exc))
debug(traceback.format_exc())
continue
for klass in classes:
extra_classes.append(klass)
return extra_classes
@staticmethod
def parse_config(doc_repo, config):
"""Banana banana
"""
html_theme = config.get('html_theme', 'default')
if html_theme == 'default':
default_theme = os.path.join(HERE, '..',
'default_theme-%s' % THEME_VERSION)
html_theme = os.path.abspath(default_theme)
info("Using default theme")
else:
html_theme = config.get_path('html_theme')
info("Using theme located at %s" % html_theme)
HtmlFormatter.theme_path = html_theme
HtmlFormatter.extra_theme_path = config.get_path('html_extra_theme')
HtmlFormatter.add_anchors = bool(config.get("html_add_anchors"))
HtmlFormatter.number_headings = bool(
config.get("html_number_headings"))
def finalize(self):
"""
Banana banana
"""
self.formatted_signal.clear()
if self.database is not None:
info('Closing database')
self.database.close()
sub_path = ''
addr = urllib.parse.urlparse(repo_url)
# Avoid blocking on password prompts
env = os.environ.copy()
env['GIT_ASKPASS'] = 'true'
while True:
try:
args = ['git', 'ls-remote', repo_url]
info('Checking if {} is a git repo'.format(' '.join(args)),
domain='git-uploader')
subprocess.check_output(args, env=env, stderr=subprocess.STDOUT)
return repo_url, sub_path
except subprocess.CalledProcessError as e:
info('No; {}'.format(e.output.decode('utf-8')),
domain='git-uploader')
sub_path = os.path.join(os.path.basename(addr.path), sub_path)
addr = urllib.parse.ParseResult(addr.scheme, addr.netloc,
os.path.dirname(addr.path),
addr.params, addr.query,
addr.fragment)
if repo_url == addr.geturl():
break
repo_url = addr.geturl()
return None, None
def format(self, link_resolver, output, extensions):
"""Banana banana
"""
info('Formatting documentation tree', 'formatting')
self.__setup_folder(output)
link_resolver.get_link_signal.connect(self.__get_link_cb)
# Page.formatting_signal.connect(self.__formatting_page_cb)
# Link.resolving_link_signal.connect(self.__link_referenced_cb)
self.__extensions = extensions
for page in self.walk():
self.format_page(page, link_resolver, output, extensions)
self.__extensions = None
link_resolver.get_link_signal.disconnect(self.__get_link_cb)
@staticmethod
def parse_config(doc_repo, config):
"""Banana banana
"""
html_theme = config.get('html_theme', 'default')
if html_theme == 'default':
default_theme = os.path.join(HERE, '..',
'default_theme-%s' % THEME_VERSION)
html_theme = os.path.abspath(default_theme)
info("Using default theme")
else:
html_theme = config.get_path('html_theme')
info("Using theme located at %s" % html_theme)
HtmlFormatter.theme_path = html_theme
HtmlFormatter.extra_theme_path = config.get_path('html_extra_theme')
HtmlFormatter.add_anchors = bool(config.get("html_add_anchors"))
HtmlFormatter.number_headings = bool(
config.get("html_number_headings"))