def __init__(self, site, settings, message): super(Publisher, self).__init__() self.logger = getLoggerWithNullHandler('hyde.engine.%s' % self.__class__.__name__) self.site = site self.message = message self.initialize(settings)
def load_publisher(site, publisher, message): logger = getLoggerWithNullHandler('hyde.engine.publisher') try: settings = attrgetter("publisher.%s" % publisher)(site.config) except AttributeError: settings = False if not settings: # Find the first configured publisher try: publisher = site.config.publisher.__dict__.iterkeys().next() logger.warning( "No default publisher configured. Using: %s" % publisher) settings = attrgetter("publisher.%s" % publisher)(site.config) except (AttributeError, StopIteration): logger.error( "Cannot find the publisher configuration: %s" % publisher) raise if not hasattr(settings, 'type'): logger.error( "Publisher type not specified: %s" % publisher) raise Exception("Please specify the publisher type in config.") pub_class = load_python_object(settings.type) return pub_class(site, settings, message)
def __init__(self, site, settings, message): super(Publisher, self).__init__() self.logger = getLoggerWithNullHandler( 'hyde.engine.%s' % self.__class__.__name__) self.site = site self.message = message self.initialize(settings)
def load_publisher(site, publisher, message): logger = getLoggerWithNullHandler('hyde.engine.publisher') try: settings = attrgetter("publisher.%s" % publisher)(site.config) except AttributeError: settings = False if not settings: # Find the first configured publisher try: publisher = next(iter(site.config.publisher.__dict__.keys())) logger.warning("No default publisher configured. Using: %s" % publisher) settings = attrgetter("publisher.%s" % publisher)(site.config) except (AttributeError, StopIteration): logger.error("Cannot find the publisher configuration: %s" % publisher) raise if not hasattr(settings, 'type'): logger.error("Publisher type not specified: %s" % publisher) raise Exception("Please specify the publisher type in config.") pub_class = load_python_object(settings.type) return pub_class(site, settings, message)
""" import os import getpass import zipfile import tempfile import httplib import urlparse from base64 import standard_b64encode import ConfigParser from hyde.publisher import Publisher from commando.util import getLoggerWithNullHandler logger = getLoggerWithNullHandler('hyde.ext.publishers.pypi') class PyPI(Publisher): def initialize(self, settings): self.settings = settings self.project = settings.project self.url = getattr(settings, "url", "https://pypi.python.org/pypi/") self.username = getattr(settings, "username", None) self.password = getattr(settings, "password", None) self.prompt_for_credentials() def prompt_for_credentials(self): pypirc_file = os.path.expanduser("~/.pypirc") if not os.path.isfile(pypirc_file): pypirc = None
""" from commando.util import getLoggerWithNullHandler from fswrap import File, Folder from hyde.exceptions import HydeException from hyde.model import Context, Dependents from hyde.plugin import Plugin from hyde.template import Template from hyde.site import Resource from contextlib import contextmanager from datetime import datetime from shutil import copymode import sys logger = getLoggerWithNullHandler('hyde.engine') class Generator(object): """ Generates output from a node or resource. """ def __init__(self, site): super(Generator, self).__init__() self.site = site self.generated_once = False self.deps = Dependents(site.sitepath) self.waiting_deps = {} self.create_context() self.template = None
generated from hyde. """ import threading import urlparse import urllib import traceback from datetime import datetime from SimpleHTTPServer import SimpleHTTPRequestHandler from BaseHTTPServer import HTTPServer from hyde.generator import Generator from fswrap import File, Folder from commando.util import getLoggerWithNullHandler logger = getLoggerWithNullHandler('hyde.server') class HydeRequestHandler(SimpleHTTPRequestHandler): """ Serves files by regenerating the resource (or) everything when a request is issued. """ def do_GET(self): """ Identify the requested path. If the query string contains `refresh`, regenerat the entire site. Otherwise, regenerate only the requested resource and serve. """ self.server.request_time = datetime.now()
ftp://my.server.com/~username/my_blog/ dav:https://username:[email protected]/path/to/my/site """ import getpass import hashlib from hyde._compat import str, input from hyde.publisher import Publisher from commando.util import getLoggerWithNullHandler logger = getLoggerWithNullHandler('hyde.ext.publishers.pyfs') try: from fs.osfs import OSFS from fs.path import pathjoin from fs.opener import fsopendir except ImportError: logger.error("The PyFS publisher requires PyFilesystem v0.4 or later.") logger.error("`pip install -U fs` to get it.") raise class PyFS(Publisher): def initialize(self, settings):
def __init__(self, site): super(Plugin, self).__init__() self.site = site self.logger = getLoggerWithNullHandler('hyde.engine.%s' % self.__class__.__name__) self.template = None
def __init__(self, sitepath): self.sitepath = sitepath self.logger = getLoggerWithNullHandler(self.__class__.__name__)
# We need absolute import so that we can import the main "sphinx" # module even though this module is also called "sphinx". Ugh. import os import json import tempfile from hyde._compat import execfile, iteritems from hyde.plugin import Plugin from hyde.model import Expando from hyde.ext.plugins.meta import MetaPlugin as _MetaPlugin from commando.util import getLoggerWithNullHandler from fswrap import File, Folder logger = getLoggerWithNullHandler('hyde.ext.plugins.sphinx') try: import sphinx from sphinx.builders.html import JSONHTMLBuilder except ImportError: logger.error("The sphinx plugin requires sphinx.") logger.error("`pip install -U sphinx` to get it.") raise class SphinxPlugin(Plugin): """The plugin class for rendering sphinx-generated documentation.""" def __init__(self, site): self.sphinx_build_dir = None self._sphinx_config = None
# We need absolute import so that we can import the main "sphinx" # module even though this module is also called "sphinx". Ugh. from __future__ import absolute_import import os import json import tempfile from hyde.plugin import Plugin from hyde.model import Expando from hyde.ext.plugins.meta import MetaPlugin as _MetaPlugin from commando.util import getLoggerWithNullHandler from fswrap import File, Folder logger = getLoggerWithNullHandler('hyde.ext.plugins.sphinx') try: import sphinx from sphinx.builders.html import JSONHTMLBuilder except ImportError: logger.error("The sphinx plugin requires sphinx.") logger.error("`pip install -U sphinx` to get it.") raise class SphinxPlugin(Plugin): """The plugin class for rendering sphinx-generated documentation.""" def __init__(self, site): self.sphinx_build_dir = None
def __init__(self, site): super(Plugin, self).__init__() self.site = site self.logger = getLoggerWithNullHandler( 'hyde.engine.%s' % self.__class__.__name__) self.template = None
from hyde.template import HtmlWrap, Template from operator import attrgetter from jinja2 import ( contextfunction, Environment, FileSystemLoader, FileSystemBytecodeCache ) from jinja2 import contextfilter, environmentfilter, Markup, Undefined, nodes from jinja2.ext import Extension from jinja2.exceptions import TemplateError from commando.util import getLoggerWithNullHandler logger = getLoggerWithNullHandler('hyde.engine.Jinja2') class SilentUndefined(Undefined): """ A redefinition of undefined that eats errors. """ def __getattr__(self, name): return self __getitem__ = __getattr__ def __call__(self, *args, **kwargs): return self @contextfunction def media_url(context, path, safe=None):
# -*- coding: utf-8 -*- """ Contains data structures and utilities for hyde. """ import codecs import yaml from datetime import datetime from UserDict import IterableUserDict from commando.util import getLoggerWithNullHandler from fswrap import File, Folder logger = getLoggerWithNullHandler('hyde.engine') class Expando(object): """ A generic expando class that creates attributes from the passed in dictionary. """ def __init__(self, d): super(Expando, self).__init__() self.update(d) def __iter__(self): """ Returns an iterator for all the items in the dictionary as key value pairs. """ return self.__dict__.iteritems()
from hyde.template import HtmlWrap, Template from operator import attrgetter from jinja2 import ( contextfunction, Environment, FileSystemLoader, FileSystemBytecodeCache ) from jinja2 import contextfilter, environmentfilter, Markup, Undefined, nodes from jinja2.ext import Extension from jinja2.exceptions import TemplateError from commando.util import getLoggerWithNullHandler logger = getLoggerWithNullHandler('hyde.engine.Jinja2') class SilentUndefined(Undefined): """ A redefinition of undefined that eats errors. """ def __getattr__(self, name): return self __getitem__ = __getattr__ def __call__(self, *args, **kwargs): return self
""" import threading import urlparse import urllib import traceback from datetime import datetime from SimpleHTTPServer import SimpleHTTPRequestHandler from BaseHTTPServer import HTTPServer from hyde.generator import Generator from fswrap import File, Folder from commando.util import getLoggerWithNullHandler logger = getLoggerWithNullHandler("hyde.server") class HydeRequestHandler(SimpleHTTPRequestHandler): """ Serves files by regenerating the resource (or) everything when a request is issued. """ def do_GET(self): """ Identify the requested path. If the query string contains `refresh`, regenerat the entire site. Otherwise, regenerate only the requested resource and serve.
""" from hyde.exceptions import HydeException from fswrap import File, Folder from hyde.model import Context, Dependents from hyde.plugin import Plugin from hyde.template import Template from hyde.site import Resource from contextlib import contextmanager from datetime import datetime from shutil import copymode from commando.util import getLoggerWithNullHandler logger = getLoggerWithNullHandler("hyde.engine") class Generator(object): """ Generates output from a node or resource. """ def __init__(self, site): super(Generator, self).__init__() self.site = site self.generated_once = False self.deps = Dependents(site.sitepath) self.waiting_deps = {} self.create_context() self.template = None