Beispiel #1
0
    def __init__(self):

        self.logger = logging.getLogger(self.LOG_NAME or self.__class__.__name__)
        self.logger.setLevel(logging.DEBUG)
        self.formatter = logging.Formatter(self.LOG_FORMAT)
        for handler in self.LOG_HANDLERS:
            handler.setFormatter(self.formatter)
            self.logger.addHandler(handler)

        self.WATCH_EXCLUDE.extend(["%s/*" % self.BUILD_DIR, self.BUILD_DIR])
        self.WATCH_EXCLUDE = ["%s/%s" % (self.BASE_DIR, p) for p in self.WATCH_EXCLUDE]

        self.BUILD_DIR = path(self.BUILD_DIR)

        render.render.klass = self

        parser = argparse.ArgumentParser()
        subparsers = parser.add_subparsers()

        for _command in command.register:
            sub_parser = subparsers.add_parser(
                _command.func.func_name,
                help=_command.func.__doc__
            )
            sub_parser.add_argument('args', nargs=argparse.REMAINDER)
            sub_parser.set_defaults(func=_command.func)

        args = parser.parse_args()
        args.func(self, args)
Beispiel #2
0
    def __init__(self, source, name):

        try:
            import markdown
        except ImportError:
            self.klass.logger.error("Python markdown package is required")
            sys.exit()

        md = markdown.Markdown(extensions=['codehilite', 'meta'])

        self.name = name
        self.content = md.convert(path(source).content)
        self.meta = {a:b if len(b) > 1 else b[0] for a,b in md.Meta.items()}
Beispiel #3
0
    def __init__(self, template_file, name,  **context):

        try:
            from jinja2 import Environment, FileSystemLoader
        except ImportError:
            self.klass.logger.error("Python jinja2 package is required")
            sys.exit()

        env = Environment(loader=FileSystemLoader(self.klass.TEMPLATES_DIR))
        template = env.get_template(path(template_file))

        self.name = name
        self.content = template.render(**context)
Beispiel #4
0
 def _ensure_path(self, name):
     directory = path(name).dir()
     directory_build = self.BUILD_DIR / directory
     if directory and not directory_build.exists:
         directory_build.mkdir(p=True)
Beispiel #5
0
 def _include(self):
     for element in self.INCLUDE:
         path(element).cp(self.BUILD_DIR / element)