voodo_setup

This commit is contained in:
Juan-Pablo Scaletti 2015-03-26 20:55:50 -05:00
parent 3aedca590e
commit e00a3dc466
15 changed files with 47 additions and 27 deletions

View File

@ -1,5 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# coding=utf-8
#
# complexity documentation build configuration file, created by
# sphinx-quickstart on Tue Jul 9 22:26:36 2013.

View File

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# coding=utf-8
from hashlib import sha512
from os import urandom
from os.path import join, dirname, basename

View File

@ -1,5 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# coding=utf-8
b'This library requires pypy or Python 2.6, 2.7, 3.3, pypy or newer'
import io
import os

View File

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# coding=utf-8
from tempfile import mkdtemp
import shutil

View File

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# coding=utf-8
from hashlib import sha1
from os import urandom
from os.path import join, dirname

View File

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# coding=utf-8
from __future__ import print_function
import re

View File

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# coding=utf-8
from os.path import join, dirname, exists
import pytest

View File

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# coding=utf-8
from os.path import exists, join
import pytest

View File

@ -1,5 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# coding=utf-8
"""
============
Voodoo
@ -18,6 +18,6 @@ See the documentation and code at: `<http://github.com/lucuma/Voodoo>`_
from voodoo.main import render_skeleton
from voodoo.cli import prompt, prompt_bool # noqa
__version__ = '1.3.6'
__version__ = '1.4.0'
reanimate_skeleton = render_skeleton # backward compat

View File

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# coding=utf-8
"""
Utilities for writing code that runs on Python 2 and 3.
"""

View File

@ -1,5 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# coding=utf-8
try:
input = raw_input
except NameError:

View File

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# coding=utf-8
import io
import os
import errno

View File

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# coding=utf-8
from __future__ import print_function
from fnmatch import fnmatch
@ -9,6 +9,7 @@ import json
import os
import re
import shutil
import subprocess
import jinja2
@ -24,7 +25,10 @@ DEFAULT_DATA = {
'now': datetime.datetime.utcnow,
}
DEFAULT_FILTER = ('.*', '~*', '*.py[co]')
DEFAULT_FILTER = (
'~*', '*.py[co]',
'.git', '.git/*', '.hg', '.hg/*', '.svn', '.svn/*',
)
DEFAULT_INCLUDE = ()
DEFAULT_ENV_OPTIONS = {
@ -86,6 +90,10 @@ def render_skeleton(
"""
src_path = to_unicode(src_path)
vcs = get_vcs_from_url(src_path)
if filter_this is None:
filter_this = DEFAULT_FILTER
if include_this is None:
include_this = DEFAULT_INCLUDE
try:
if vcs:
src_path = clone(vcs, quiet)
@ -100,6 +108,7 @@ def render_skeleton(
src_path, dst_path, data=data,
filter_this=filter_this, include_this=include_this,
pretend=pretend, force=force, skip=skip, quiet=quiet, envops=envops)
run_setup(dst_path)
finally:
if src_path and vcs:
shutil.rmtree(src_path)
@ -127,6 +136,11 @@ def get_user_data(src_path, force, quiet):
resp = prompt('{0}?'.format(key), value)
user_data[key] = resp.decode('utf8')
print('\n' + '-' * 50 + '\n')
try:
os.remove(json_path)
except OSError:
pass
return user_data
@ -161,6 +175,19 @@ def render_local_skeleton(
)
def run_setup(dst_path):
setup_path = os.path.join(dst_path, 'voodoo_setup.py')
if not os.path.exists(setup_path):
return
os.chdir(dst_path)
setup_cmd = 'python ' + setup_path
subprocess.Popen(setup_cmd, shell=True).communicate()
try:
os.remove(setup_path)
except OSError:
pass
def clean_data(data):
data = data or {}
_data = DEFAULT_DATA.copy()
@ -196,10 +223,8 @@ def get_name_filter(filter_this, include_this):
decomposed unicode string. In those systems, u'ñ' is read as `\u0303`
instead of `\xf1`.
"""
filter_this = [normalize(to_unicode(f)) for f in
filter_this or DEFAULT_FILTER]
include_this = [normalize(to_unicode(f)) for f in
include_this or DEFAULT_INCLUDE]
filter_this = [normalize(to_unicode(f)) for f in filter_this]
include_this = [normalize(to_unicode(f)) for f in include_this]
def fullmatch(path, pattern):
path = normalize(path)

View File

@ -1,5 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# coding=utf-8
import argparse
from hashlib import sha512
from os import urandom
@ -18,12 +18,7 @@ def new_project(path, tmpl=None, **options):
if tmpl is None:
raise ValueError("tmpl must be be a path to the template.")
data = default_context.copy()
render_skeleton(
tmpl, path, data=data,
filter_this=['voodoo.json', '.git/*', '.hg/*'],
include_this=['.gittouch'],
**options
)
render_skeleton(tmpl, path, data=data, **options)
class DefaultHelpParser(argparse.ArgumentParser):

View File

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# coding=utf-8
from __future__ import print_function
from collections import namedtuple