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_logger(name):
"""Set up stream and file handlers."""
root = logging.getLogger(name)
root.setLevel(logging.DEBUG)
root.propagate = False
stream_handler = coloredlogs.ColoredStreamHandler(
stream=sys.stdout,
show_name=False,
show_hostname=False,
level=logging.DEBUG)
root.addHandler(stream_handler)
return root
# External dependency, install with:
# pip install coloredlogs
import coloredlogs
# External dependency, bundled because it's not on PyPi.
import libs.soupselect as soupselect
# Sensible defaults (you probably shouldn't change these).
TEXT_WIDTH = 79
SHIFT_WIDTH = 2
# Initialize the logging subsystem.
logger = logging.getLogger('html2vimdoc')
logger.setLevel(logging.INFO)
logger.addHandler(coloredlogs.ColoredStreamHandler(show_name=True))
# Mapping of HTML element names to custom Node types.
name_to_type_mapping = {}
def main():
"""
Command line interface for html2vimdoc.
"""
filename, title, url, arguments, preview, markdown_extensions = parse_args(sys.argv[1:])
filename, url, text = get_input(filename, url, arguments, markdown_extensions)
vimdoc = html2vimdoc(text, title=title, filename=filename, url=url)
output = vimdoc.encode('utf-8')
logger.info("Done!")
if preview:
os.popen("gvim -c 'set nomod' -", 'w').write(output)
else:
# External dependency, install with:
# pip install coloredlogs
import coloredlogs
# External dependency, bundled because it's not on PyPi.
import libs.soupselect as soupselect
# Sensible defaults.
TEXT_WIDTH = 79
SHIFT_WIDTH = 2
# Initialize the logging subsystem.
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
logger.addHandler(coloredlogs.ColoredStreamHandler())
def main():
filename = 'demo/lpeg-0.10.html'
filename = 'demo/apr-0.17.html'
with open(filename) as handle:
html = handle.read()
html = re.sub(r'test coverage: \S+', '', html)
output = Converter().convert(html, selectors_to_ignore=['h3 a[class=anchor]'])
print output.encode('utf-8')
class Converter(object):
# XXX This class is just here for decoration, it's not useful :-x
def convert(self, html, selector='#content', selectors_to_ignore=[]):
"""
import logging
import os
import os.path
import re
import sys
import textwrap
import time
# External dependency, install with:
# pip install coloredlogs
import coloredlogs
# Initialize the logging subsystem.
logger = logging.getLogger('vimdoctool')
logger.setLevel(logging.INFO)
logger.addHandler(coloredlogs.ColoredStreamHandler(show_name=True))
# Compiled regular expressions used by parse_vim_script().
function_pattern = re.compile(r'^function! ([^(]+)\(')
comment_pattern = re.compile(r'^\s*"\s?(.*)$')
def main():
"""
Command line interface for vim-doc-tool.
"""
markdown_document = os.path.abspath(sys.argv[1])
directory = os.path.dirname(markdown_document)
embed_documentation(directory, markdown_document, startlevel=1)
logger.info("Done!")
def embed_documentation(directory, filename, startlevel=1, vfs=None):
"""
def enable_logger(log_name, level=logging.DEBUG):
log = logging.getLogger(log_name)
handler = ColoredStreamHandler()
handler.setLevel(level)
log.setLevel(level)
log.addHandler(handler)