/
update
executable file
·78 lines (66 loc) · 1.82 KB
/
update
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
from contextlib import suppress
import importlib
import tempfile
import shutil
import subprocess
import sys
CWD = os.getcwd()
TMP = tempfile.gettempdir()
CONFIG = {
"full_name": "Jace Browning",
"email": "jacebrowning@gmail.com",
"github_username": "jacebrowning",
"github_repo": "minilog",
"default_branch": "main",
"project_name": "minilog",
"package_name": "log",
"project_short_description": "Minimalistic wrapper for Python logging.",
"python_major_version": 3,
"python_minor_version": 6,
}
def install(package='cookiecutter'):
try:
importlib.import_module(package)
except ImportError:
print("Installing cookiecutter")
subprocess.check_call([sys.executable, '-m', 'pip', 'install', package])
def run():
print("Generating project")
from cookiecutter.main import cookiecutter
os.chdir(TMP)
cookiecutter(
'https://github.com/jacebrowning/template-python.git',
no_input=True,
overwrite_if_exists=True,
extra_context=CONFIG,
)
def copy():
for filename in [
os.path.join('bin', 'update'),
os.path.join('bin', 'checksum'),
os.path.join('bin', 'open'),
os.path.join('bin', 'verchew'),
'.appveyor.yml',
'.coveragerc',
'.gitattributes',
'.gitignore',
'.pydocstyle.ini',
'.pylint.ini',
'.scrutinizer.yml',
'.verchew.ini',
'CONTRIBUTING.md',
'Makefile',
'scent.py',
]:
src = os.path.join(TMP, CONFIG['project_name'], filename)
dst = os.path.join(CWD, filename)
print("Updating " + filename)
with suppress(FileNotFoundError):
shutil.copy(src, dst)
if __name__ == '__main__':
install()
run()
copy()