Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial import of tut command-line toolInitializing empty Tut project.
- Loading branch information
0 parents
commit f368ae6
Showing
11 changed files
with
528 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
*.pyc | ||
|
||
.installed.cfg | ||
bin/ | ||
develop-eggs/ | ||
|
||
*.egg-info | ||
|
||
tmp/ | ||
build/ | ||
dist/ | ||
eggs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Development setup | ||
================= | ||
|
||
To create a buildout, | ||
|
||
$ python bootstrap.py | ||
$ bin/buildout | ||
|
||
Release HOWTO | ||
============= | ||
|
||
To make a release, | ||
|
||
1) Update release date/version in NEWS.txt and setup.py | ||
2) Run 'python setup.py sdist' | ||
3) Test the generated source distribution in dist/ | ||
4) Upload to PyPI: 'python setup.py sdist register upload' | ||
5) Increase version in setup.py (for next release) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
include README.rst | ||
include NEWS.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
.. This is your project NEWS file which will contain the release notes. | ||
.. Example: http://www.python.org/download/releases/2.6/NEWS.txt | ||
.. The content of this file, along with README.rst, will appear in your | ||
.. project's PyPI page. | ||
|
||
News | ||
==== | ||
|
||
0.2a1 | ||
----- | ||
|
||
*Release date: UNRELEASED* | ||
|
||
* Example news entry for the in-development version | ||
|
||
|
||
0.1 | ||
--- | ||
|
||
*Release date: 15-Mar-2010* | ||
|
||
* Example news entry for a released version | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
===== | ||
Tut | ||
===== | ||
|
||
**Tut** is a Sphinx_ extension that helps you write tutorial style | ||
documentation. Tutorial style documentation is documentation where | ||
sections build on one another, and include code examples along the | ||
way. *Tut* helps you manage the code in the tutorial as you write it, | ||
and include the correct segments in your document. | ||
|
||
How does *Tut* help you? *Tut* provides the following features: | ||
|
||
- Denote where each step begins, and helps you manage your git | ||
workflow by letting you start new steps and switch between steps. | ||
|
||
$ tut points | ||
$ tut checkpoint step_identifier | ||
$ tut steps | ||
- step_indentifier <1as85d> | ||
|
||
- *Tut* works with git: when you create a new step, *Tut* records the | ||
current SHA as the starting point for that step. You can then work | ||
on the next step. If you want to make changes to a previous step, | ||
just switch back to it. | ||
|
||
$ tut switch step_one | ||
Switching to step_one... done. | ||
|
||
- When you're done working on step_one, you can switch to another | ||
step, or jump to the end of the tutorial: | ||
|
||
$ tut switch end | ||
|
||
- Note that if you're changing history, *Tut* will rebase_ your future | ||
steps onto the old step. | ||
|
||
|
||
Within Sphinx you can denote where the steps begin:: | ||
|
||
.. tut-step:: step_one | ||
:path: /path/to/code/repo | ||
|
||
This means that any directives that refer to the filesystem after this | ||
will be using the ``step_one`` state. So using ``literalinclude``, for | ||
example, will include the source as it was in step one. | ||
|
||
|
||
|
||
.. It'd be nice to figure out if there's going to be anything needed | ||
.. to make the doctest builder work. Probably. Groups? | ||
What I've semi-done: | ||
|
||
* Checkpoint | ||
* Edit checkpoints | ||
* List checkpoints | ||
* Maintain checkpoint tags after editing. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
############################################################################## | ||
# | ||
# Copyright (c) 2006 Zope Corporation and Contributors. | ||
# All Rights Reserved. | ||
# | ||
# This software is subject to the provisions of the Zope Public License, | ||
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. | ||
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED | ||
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS | ||
# FOR A PARTICULAR PURPOSE. | ||
# | ||
############################################################################## | ||
"""Bootstrap a buildout-based project | ||
Simply run this script in a directory containing a buildout.cfg. | ||
The script accepts buildout command-line options, so you can | ||
use the -c option to specify an alternate configuration file. | ||
$Id: bootstrap.py 102545 2009-08-06 14:49:47Z chrisw $ | ||
""" | ||
|
||
import os, shutil, sys, tempfile, urllib2 | ||
from optparse import OptionParser | ||
|
||
tmpeggs = tempfile.mkdtemp() | ||
|
||
is_jython = sys.platform.startswith('java') | ||
|
||
# parsing arguments | ||
parser = OptionParser() | ||
parser.add_option("-v", "--version", dest="version", | ||
help="use a specific zc.buildout version") | ||
parser.add_option("-d", "--distribute", | ||
action="store_true", dest="distribute", default=True, | ||
help="Use Disribute rather than Setuptools.") | ||
|
||
options, args = parser.parse_args() | ||
|
||
if options.version is not None: | ||
VERSION = '==%s' % options.version | ||
else: | ||
VERSION = '' | ||
|
||
USE_DISTRIBUTE = options.distribute | ||
args = args + ['bootstrap'] | ||
|
||
to_reload = False | ||
try: | ||
import pkg_resources | ||
if not hasattr(pkg_resources, '_distribute'): | ||
to_reload = True | ||
raise ImportError | ||
except ImportError: | ||
ez = {} | ||
if USE_DISTRIBUTE: | ||
exec urllib2.urlopen('http://python-distribute.org/distribute_setup.py' | ||
).read() in ez | ||
ez['use_setuptools'](to_dir=tmpeggs, download_delay=0, no_fake=True) | ||
else: | ||
exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py' | ||
).read() in ez | ||
ez['use_setuptools'](to_dir=tmpeggs, download_delay=0) | ||
|
||
if to_reload: | ||
reload(pkg_resources) | ||
else: | ||
import pkg_resources | ||
|
||
if sys.platform == 'win32': | ||
def quote(c): | ||
if ' ' in c: | ||
return '"%s"' % c # work around spawn lamosity on windows | ||
else: | ||
return c | ||
else: | ||
def quote (c): | ||
return c | ||
|
||
cmd = 'from setuptools.command.easy_install import main; main()' | ||
ws = pkg_resources.working_set | ||
|
||
if USE_DISTRIBUTE: | ||
requirement = 'distribute' | ||
else: | ||
requirement = 'setuptools' | ||
|
||
if is_jython: | ||
import subprocess | ||
|
||
assert subprocess.Popen([sys.executable] + ['-c', quote(cmd), '-mqNxd', | ||
quote(tmpeggs), 'zc.buildout' + VERSION], | ||
env=dict(os.environ, | ||
PYTHONPATH= | ||
ws.find(pkg_resources.Requirement.parse(requirement)).location | ||
), | ||
).wait() == 0 | ||
|
||
else: | ||
assert os.spawnle( | ||
os.P_WAIT, sys.executable, quote (sys.executable), | ||
'-c', quote (cmd), '-mqNxd', quote (tmpeggs), 'zc.buildout' + VERSION, | ||
dict(os.environ, | ||
PYTHONPATH= | ||
ws.find(pkg_resources.Requirement.parse(requirement)).location | ||
), | ||
) == 0 | ||
|
||
ws.add_entry(tmpeggs) | ||
ws.require('zc.buildout' + VERSION) | ||
import zc.buildout.buildout | ||
zc.buildout.buildout.main(args) | ||
shutil.rmtree(tmpeggs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[buildout] | ||
parts = python scripts | ||
develop = . | ||
eggs = tut | ||
|
||
[python] | ||
recipe = zc.recipe.egg | ||
interpreter = python | ||
eggs = ${buildout:eggs} | ||
|
||
[scripts] | ||
recipe = zc.recipe.egg:scripts | ||
eggs = ${buildout:eggs} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from setuptools import setup, find_packages | ||
import sys, os | ||
|
||
here = os.path.abspath(os.path.dirname(__file__)) | ||
README = open(os.path.join(here, 'README.rst')).read() | ||
NEWS = open(os.path.join(here, 'NEWS.txt')).read() | ||
|
||
|
||
version = '0.0.1' | ||
|
||
install_requires = [ | ||
'docopt', | ||
'sh', | ||
'GitPython > 0.3', | ||
] | ||
|
||
|
||
setup(name='tut', | ||
version=version, | ||
description="", | ||
long_description=README + '\n\n' + NEWS, | ||
classifiers=[ | ||
], | ||
keywords='', | ||
author='Nathan Yergler', | ||
author_email='nathan@yergler.net', | ||
url='', | ||
license='', | ||
packages=find_packages('src'), | ||
package_dir={'': 'src'}, | ||
include_package_data=True, | ||
zip_safe=False, | ||
install_requires=install_requires, | ||
entry_points={ | ||
'console_scripts': [ | ||
'tut=tut.cmd:main', | ||
'tut_remap=tut.cmd:post_rewrite', | ||
], | ||
}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
def version(): | ||
"""Return the installed package version.""" | ||
|
||
import pkg_resources | ||
|
||
return pkg_resources.get_distribution('tut').version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
"""Tut. | ||
Usage: | ||
tut init [<path>] | ||
tut points | ||
tut checkpoint <name> [-m <message>] | ||
tut edit <name> | ||
Options: | ||
-h --help Show this screen. | ||
--version Show version. | ||
""" | ||
|
||
from __future__ import absolute_import | ||
import os | ||
import sys | ||
|
||
from docopt import docopt | ||
|
||
import tut | ||
from tut.model import Tut | ||
|
||
|
||
def init(args): | ||
|
||
path = args.get('<path>') | ||
if path is None: | ||
path = os.getcwd() | ||
else: | ||
path = os.path.join(os.getcwd(), path) | ||
|
||
tut_repo = Tut(path) | ||
|
||
if not os.path.exists(os.path.join(path, '.git')): | ||
tut_repo.init() | ||
tut_repo.install_hooks() | ||
|
||
|
||
def points(args): | ||
|
||
for point in Tut(os.getcwd()).points(): | ||
print point | ||
|
||
|
||
def checkpoint(args): | ||
|
||
point = Tut(os.getcwd()).checkpoint( | ||
args['<name>'], | ||
message=args.get('<message>'), | ||
) | ||
|
||
print "Recorded checkpoint: %s" % point | ||
|
||
|
||
def edit(args): | ||
|
||
Tut(os.getcwd()).edit( | ||
args['<name>'], | ||
) | ||
|
||
|
||
CMD_MAP = { | ||
'init': init, | ||
'points': points, | ||
'checkpoint': checkpoint, | ||
'edit': edit, | ||
} | ||
|
||
|
||
def main(): | ||
arguments = docopt(__doc__, version='Tut %s' % tut.version()) | ||
#print arguments | ||
|
||
for cmd in CMD_MAP: | ||
if arguments.get(cmd): | ||
CMD_MAP[cmd](arguments) | ||
break | ||
|
||
|
||
def post_rewrite(): | ||
|
||
tut = Tut(os.getcwd()) | ||
|
||
for line in sys.stdin: | ||
rewrite = line.split() | ||
tut.move_checkpoints(rewrite[0].strip(), rewrite[1].strip()) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
Oops, something went wrong.