Mercurial > piecrust2
changeset 78:c80a3be091da 2.0.0-alpha3
Merge changes.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sat, 30 Aug 2014 17:37:46 -0700 |
parents | 25bfed36a620 (diff) d9e494df2a99 (current diff) |
children | c605fd808fc5 |
files | |
diffstat | 12 files changed, 130 insertions(+), 46 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgignore Fri Aug 29 21:28:55 2014 -0700 +++ b/.hgignore Sat Aug 30 17:37:46 2014 -0700 @@ -2,6 +2,7 @@ *.pyc venv tags +build/lib build/messages/_cache dist piecrust.egg-info
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.hgtags Sat Aug 30 17:37:46 2014 -0700 @@ -0,0 +1,6 @@ +cb1ed436642caadf9d3f19c1750096b116e43606 2.0.0-alpha1 +cb1ed436642caadf9d3f19c1750096b116e43606 2.0.0-alpha1 +ecee3e8f35e57e4a606794a11fc6e8aba2734d2f 2.0.0-alpha1 +ecee3e8f35e57e4a606794a11fc6e8aba2734d2f 2.0.0-alpha1 +8f988aa54433e0c4aa036cd00bcfa5904d3be304 2.0.0-alpha1 +fdb08d986384687959fe11640f058eac22c17b8f 2.0.0-alpha2
--- a/MANIFEST.in Fri Aug 29 21:28:55 2014 -0700 +++ b/MANIFEST.in Sat Aug 30 17:37:46 2014 -0700 @@ -1,7 +1,8 @@ -include README.md -include CHANGELOG.md -include LICENSE.md -recursive-include piecrust *.py +include README.rst +include CHANGELOG.rst +include LICENSE.rst +recursive-include piecrust *.py mime.types +recursive-include piecrust/resources * recursive-include tests *.py #global-exclude .DS_Store #global-exclude Thumbs.db
--- a/piecrust/__init__.py Fri Aug 29 21:28:55 2014 -0700 +++ b/piecrust/__init__.py Sat Aug 30 17:37:46 2014 -0700 @@ -1,5 +1,3 @@ - -APP_VERSION = '2.0.0alpha' CACHE_DIR = '_cache' ASSETS_DIR = 'assets' @@ -19,3 +17,8 @@ PIECRUST_URL = 'http://bolt80.com/piecrust/' +try: + from piecrust.__version__ import APP_VERSION +except ImportError: + APP_VERSION = 'unknown' +
--- a/piecrust/app.py Fri Aug 29 21:28:55 2014 -0700 +++ b/piecrust/app.py Sat Aug 30 17:37:46 2014 -0700 @@ -26,7 +26,7 @@ logger = logging.getLogger(__name__) -CACHE_VERSION = 13 +CACHE_VERSION = 14 class VariantNotFoundError(Exception):
--- a/piecrust/data/builder.py Fri Aug 29 21:28:55 2014 -0700 +++ b/piecrust/data/builder.py Sat Aug 30 17:37:46 2014 -0700 @@ -1,5 +1,6 @@ import time import logging +from piecrust import APP_VERSION from piecrust.configuration import merge_dicts from piecrust.data.assetor import Assetor from piecrust.data.debug import build_debug_info @@ -75,22 +76,16 @@ return data -try: - from piecrust.__version__ import VERSION -except ImportError: - from piecrust import APP_VERSION as VERSION - - class PieCrustData(object): debug_render = ['version', 'url', 'branding', 'debug_info'] debug_render_invoke = ['version', 'url', 'branding', 'debug_info'] debug_render_redirect = {'debug_info': '_debugRenderDebugInfo'} def __init__(self): - self.version = VERSION + self.version = APP_VERSION self.url = 'http://bolt80.com/piecrust/' self.branding = 'Baked with <em><a href="%s">PieCrust</a> %s</em>.' % ( - 'http://bolt80.com/piecrust/', VERSION) + 'http://bolt80.com/piecrust/', APP_VERSION) self._page = None self._data = None
--- a/piecrust/formatting/markdownformatter.py Fri Aug 29 21:28:55 2014 -0700 +++ b/piecrust/formatting/markdownformatter.py Sat Aug 30 17:37:46 2014 -0700 @@ -11,6 +11,7 @@ self._extensions = None def render(self, format_name, txt): + assert format_name in self.FORMAT_NAMES self._ensureInitialized() return markdown(txt, extensions=self._extensions)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/piecrust/formatting/smartypantsformatter.py Sat Aug 30 17:37:46 2014 -0700 @@ -0,0 +1,22 @@ +import smartypants +from piecrust.formatting.base import Formatter, PRIORITY_LAST + + +class SmartyPantsFormatter(Formatter): + FORMAT_NAMES = ['html'] + OUTPUT_FORMAT = 'html' + + def __init__(self): + super(SmartyPantsFormatter, self).__init__() + self.priority = PRIORITY_LAST + + def initialize(self, app): + super(SmartyPantsFormatter, self).initialize(app) + self.enabled = ( + app.config.get('smartypants/enable') or + app.config.get('smartypants/enabled')) + + def render(self, format_name, txt): + assert format_name == 'html' + return smartypants.smartypants(txt) +
--- a/piecrust/main.py Fri Aug 29 21:28:55 2014 -0700 +++ b/piecrust/main.py Sat Aug 30 17:37:46 2014 -0700 @@ -4,7 +4,8 @@ import logging import argparse import colorama -from piecrust.app import PieCrust, PieCrustConfiguration, APP_VERSION +from piecrust import APP_VERSION +from piecrust.app import PieCrust, PieCrustConfiguration from piecrust.chefutil import format_timed, log_friendly_exception from piecrust.commands.base import CommandContext from piecrust.environment import StandardEnvironment
--- a/piecrust/plugins/builtin.py Fri Aug 29 21:28:55 2014 -0700 +++ b/piecrust/plugins/builtin.py Sat Aug 30 17:37:46 2014 -0700 @@ -7,6 +7,7 @@ PrepareCommand, ImportCommand) from piecrust.data.provider import (IteratorDataProvider, BlogDataProvider) from piecrust.formatting.markdownformatter import MarkdownFormatter +from piecrust.formatting.smartypantsformatter import SmartyPantsFormatter from piecrust.importing.jekyll import JekyllImporter from piecrust.importing.piecrust import PieCrust1Importer from piecrust.plugins.base import PieCrustPlugin @@ -61,7 +62,8 @@ def getFormatters(self): return [ - MarkdownFormatter()] + MarkdownFormatter(), + SmartyPantsFormatter()] def getProcessors(self): return [
--- a/requirements.txt Fri Aug 29 21:28:55 2014 -0700 +++ b/requirements.txt Sat Aug 30 17:37:46 2014 -0700 @@ -13,4 +13,5 @@ python-dateutil==2.2 repoze.lru==0.6 six==1.7.3 +smartypants==1.8.6 strict-rfc3339==0.4
--- a/setup.py Fri Aug 29 21:28:55 2014 -0700 +++ b/setup.py Sat Aug 30 17:37:46 2014 -0700 @@ -6,7 +6,7 @@ import sys import time import subprocess -from setuptools import setup, find_packages +from setuptools import setup, find_packages, Command from setuptools.command.test import test @@ -34,52 +34,101 @@ sys.exit(errno) -# Figure out the version. -# (this is loosely based on what Mercurial does) -version = None -try: - if os.path.isdir(os.path.join(os.path.dirname(__file__), '.hg')): +class GenerateVersionCommand(Command): + description = 'generates a version file' + user_options = [ + ('force=', 'f', 'force a specific version number')] + + def initialize_options(self): + self.force = None + + def finalize_options(self): + pass + + def run(self): + v = self.force or generate_version() + write_version(v) + print("Generated version %s" % v) + return 0 + + +def generate_version(): + """ Generate a version file from the source control information. + (this is loosely based on what Mercurial does)""" + if not os.path.isdir(os.path.join(os.path.dirname(__file__), '.hg')): + raise Exception("Can't generate version number: this is not a " + "Mercurial repository.") + + try: + # Get the version we're currently on. Also see if we have local + # changes. + cmd = ['hg', 'id', '-i'] + hgid, err = runcmd(cmd) + hgid = hgid.decode('utf8').strip() + has_local_changes = hgid.endswith('+') + hgid = hgid.rstrip('+') + + # Get the tags on the current version. cmd = ['hg', 'log', '-r', '.', '--template', '{tags}\n'] tags, err = runcmd(cmd) versions = [t for t in tags.decode('utf8').split() if t[0].isdigit()] - cmd = ['hg', 'id', '-i'] - hgid, err = runcmd(cmd) - hgid = hgid.decode('utf8').strip() - if versions: - # Use tag found at the current revision. Add dirty flag if any. + # Use the tag found at the current revision. version = versions[-1] - if hgid.endswith('+'): - version += '+' else: - # Use latest tag. - cmd = ['hg', 'parents', '--template', '{latesttag}+{latesttagdistance}-'] + # Use the latest tag, but add info about how many revisions + # there have been since then. + cmd = ['hg', 'parents', '--template', + '{latesttag}+{latesttagdistance}'] version, err = runcmd(cmd) - version = version.decode('utf8') + hgid + tag, dist = version.decode('utf8').split('+') + if dist == '1': + # We're on the commit that created the tag in the first place. + # Let's just do as if we were on the tag. + version = tag + else: + version = '%s-%s.%s' % (tag, dist, hgid) - if version.endswith('+'): - version += time.strftime('%Y%m%d') -except OSError: - # Mercurial isn't installed, or not in the PATH. - version = None + if has_local_changes: + version += time.strftime('+%Y%m%d') + + return version + except OSError: + raise Exception("Can't generate version number: Mercurial isn't " + "installed, or in the PATH.") + except Exception as ex: + raise Exception("Can't generate version number: %s" % ex) -if version: +def write_version(version): + if not version: + raise Exception("No version to write!") + f = open("piecrust/__version__.py", "w") f.write('# this file is autogenerated by setup.py\n') - f.write('version = "%s"\n' % version) + f.write('APP_VERSION = "%s"\n' % version) f.close() +# Always try to generate an up to date version. +# Otherwise, fall back on an (hopefully) existing version file. try: - from piecrust import __version__ - version = __version__.version -except ImportError: - version = 'unknown' + version = generate_version() + write_version(version) +except: + version = None + +if version is None: + try: + from piecrust.__version__ import APP_VERSION + version = APP_VERSION + except ImportError: + raise Exception("Can't get version from either a version file or " + "from the repository.") -setup(name="piecrust", +setup(name="PieCrust", version=version, description="A powerful static website generator and lightweight CMS.", long_description=read('README.rst') + '\n\n' + read('CHANGELOG.rst'), @@ -112,6 +161,7 @@ 'py==1.4.23', 'python-dateutil==2.2', 'repoze.lru==0.6', + 'smartypants==1.8.6', 'strict-rfc3339==0.4' ], tests_require=[ @@ -119,7 +169,8 @@ 'pytest-mock==0.2.0' ], cmdclass={ - 'test': PyTest + 'test': PyTest, + 'version' : GenerateVersionCommand }, classifiers=[ 'Development Status :: 3 - Alpha',