Mercurial > hg > TextShaper
diff INSTALL.py @ 0:53cfd6e1ad0f
initial commit,
from http://k0s.org/portfolio/ideas/textshaper.py ,
see also http://k0s.org/portfolio/ideas/cleanuptext.py
So you have a block of text ... What do you want to do with it?!? ==
Desired Functionality == == Previous work == /corpus of past programs
-> consolidate/ - onelineit - quoting - dequoting (including e.g. +/-,
diff-ish shit) - removing timestamps - removing/adding irc quote tags
Interface: - library code - (n)curses - javascript/REST Consider the
pattern: * things that add and/or remove a thing * things that alter
spacing == Reference == Previous k0s.ware (big and small): -
http://k0s.org/hg/config/rev/5e0b4ec36013 Highly related (~>
identity): http://k0s.org/portfolio/ideas/cleanuptext.py Ubuntu
packages: - par (paragraph reformatter)
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Sat, 10 Aug 2013 15:47:30 -0700 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/INSTALL.py Sat Aug 10 15:47:30 2013 -0700 @@ -0,0 +1,67 @@ +#!/usr/bin/env python + +""" +installation script for TextShaper +package to shape text blocks +""" + +import os +import sys +import urllib2 +import subprocess +try: + from subprocess import check_call as call +except: + from subprocess import call + +REPO='http://k0s.org/hg/TextShaper' +DEST='TextShaper' # name of the virtualenv +VIRTUALENV='https://raw.github.com/pypa/virtualenv/develop/virtualenv.py' + +def which(binary, path=os.environ['PATH']): + dirs = path.split(os.pathsep) + for dir in dirs: + if os.path.isfile(os.path.join(dir, fileName)): + return os.path.join(dir, fileName) + if os.path.isfile(os.path.join(dir, fileName + ".exe")): + return os.path.join(dir, fileName + ".exe") + +def main(args=sys.argv[1:]): + + # create a virtualenv + virtualenv = which('virtualenv') or which('virtualenv.py') + if virtualenv: + call([virtualenv, DEST]) + else: + process = subproces.Popen([sys.executable, '-', DEST], stdin=subprocess.PIPE) + process.communicate(stdin=urllib2.urlopen(VIRTUALENV).read()) + + # create a src directory + src = os.path.join(DEST, 'src') + os.mkdir(src) + + # clone the repository + call(['hg', 'clone', REPO], cwd=src) + + # find the virtualenv python + python = None + for path in (('bin', 'python'), ('Scripts', 'python.exe')): + _python = os.path.join(DEST, *path) + if os.path.exists(_python) + python = _python + break + else: + raise Exception("Python binary not found in %s" % DEST) + + # find the clone + filename = REPO.rstrip('/') + filename = filename.split('/')[-1] + clone = os.path.join(src, filename) + assert os.path.exists(clone), "Clone directory not found in %s" % src + + # ensure setup.py exists + assert os.path.exists(os.path.join(clone, 'setup.py')), 'setup.py not found in %s' % clone + + # install the package in develop mode + call([python 'setup.py', 'develop'], cwd=clone) +