Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def error(code, message, **kwargs):
"""Call this to raise an exception and have it stored in the journal"""
assert code in Logger._error_code_to_exception
exc_type, domain = Logger._error_code_to_exception[code]
exc = exc_type(message, **kwargs)
Logger._log(code, exc.message, ERROR, domain)
raise exc
def info(message, domain='core'):
"""Shortcut to `Logger.info`"""
Logger.info(message, domain)
yaml.add_constructor(yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG,
_no_duplicates_constructor)
OverridePage = namedtuple('OverridePage', ['source_file', 'file'])
class TreeNoSuchPageException(HotdocSourceException):
"""
Raised when a subpage listed in the sitemap file could not be found
in any of the include paths.
"""
pass
Logger.register_error_code('no-such-subpage', TreeNoSuchPageException,
domain='doc-tree')
Logger.register_warning_code('invalid-page-metadata', InvalidPageMetadata,
domain='doc-tree')
Logger.register_warning_code('markdown-bad-link', HotdocSourceException)
# pylint: disable=too-many-instance-attributes
class Page(object):
"Banana banana"
meta_schema = {Optional('title'): And(str, len),
Optional('symbols'): Schema([And(str, len)]),
Optional('short-description'): And(str, len),
Optional('render-subpages'): bool,
Optional('auto-sort'): bool,
Optional('full-width'): bool,
Optional('extra'): Schema({str: object})}
def debug(message, domain='core'):
"""Shortcut to `Logger.debug`"""
Logger.debug(message, domain)
def info(message, domain):
"""Log simple info"""
if domain in Logger._ignored_domains:
return
Logger._log(None, message, INFO, domain)
import os
from collections import defaultdict
from lxml import etree
import networkx as nx
from hotdoc.core.symbols import QualifiedSymbol
from hotdoc.core.exceptions import BadInclusionException
from hotdoc.extensions.gi.utils import *
from hotdoc.utils.utils import DATADIR
from hotdoc.utils.loggable import warn, Logger
Logger.register_warning_code('missing-gir-include', BadInclusionException,
'gi-extension')
'''
Names of boilerplate GObject macros we don't want to expose
'''
SMART_FILTERS = set()
def __generate_smart_filters(id_prefixes, sym_prefixes, node):
sym_prefix = node.attrib['{%s}symbol-prefix' % NS_MAP['c']]
SMART_FILTERS.add(('%s_IS_%s' % (sym_prefixes, sym_prefix)).upper())
SMART_FILTERS.add(('%s_TYPE_%s' % (sym_prefixes, sym_prefix)).upper())
SMART_FILTERS.add(('%s_%s' % (sym_prefixes, sym_prefix)).upper())
SMART_FILTERS.add(('%s_%s_CLASS' % (sym_prefixes, sym_prefix)).upper())
SMART_FILTERS.add(('%s_IS_%s_CLASS' % (sym_prefixes, sym_prefix)).upper())
def debug(message, domain='core'):
"""Shortcut to `Logger.debug`"""
Logger.debug(message, domain)
def error(code, message, **kwargs):
"""Shortcut to `Logger.error`"""
Logger.error(code, message, **kwargs)
ENV_VERBOSITY = os.getenv('HOTDOC_DEBUG')
if ENV_VERBOSITY is not None:
Logger.set_verbosity(int(ENV_VERBOSITY))
Logger.register_error_code('invalid-config', ConfigError)
Logger.register_error_code('setup-issue', ConfigError)
Logger.register_warning_code('parsing-issue', ParsingException)
class SymbolListedTwiceException(InvalidPageMetadata):
pass
class InvalidRelocatedSourceException(InvalidPageMetadata):
pass
Logger.register_warning_code(
'unavailable-symbol-listed', InvalidOutputException, 'extension')
Logger.register_warning_code(
'output-page-conflict', InvalidOutputException, 'extension')
Logger.register_warning_code(
'symbol-listed-twice', SymbolListedTwiceException, 'extension')
Logger.register_warning_code(
'invalid-relocated-source', InvalidRelocatedSourceException, 'extension')
# pylint: disable=too-few-public-methods
class ExtDependency:
"""
Represents a dependency on another extension.
If not satisfied, the extension will not be instantiated.
See the `Extension.get_dependencies` static method documentation
for more information.
Attributes:
dependency_name: str, the name of the extension depended on.
is_upstream: bool, if set to true hotdoc will arrange for