-
Notifications
You must be signed in to change notification settings - Fork 47
/
cute.py
62 lines (57 loc) · 1.78 KB
/
cute.py
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
#! python3
from xcute import cute, Bump, LiveReload
def date_bumper(old_version):
"""My bump task"""
from datetime import datetime
old_version = tuple(int(token) for token in old_version.split("."))
date = datetime.now()
version = (date.year, date.month, date.day)
if version < old_version:
version += (old_version[3] + 1,)
elif version == old_version:
version += (1,)
return ".".join(map(str, version))
def split_domains(text):
"""Split text into left, domains, right"""
import re
match = re.search(r'\.\. DOMAINS\s*\.\.\s*([\s\S]+?)\s*\.\. END DOMAINS', text)
i = match.start(1)
j = match.end(1)
return text[:i], text[i:j], text[j:]
def domains():
"""Update domains"""
import pathlib
from comiccrawler.mods import list_domain
domains = " ".join(list_domain())
path = pathlib.Path('README.rst')
text = path.read_text('utf-8')
left, old_domains, right = split_domains(text)
if old_domains == domains:
return
path.write_text(left + domains + right, 'utf-8')
cute(
pkg_name = "comiccrawler",
default = "python -m comiccrawler gui",
test = ['pylint comiccrawler', 'readme_build'],
bump_pre = 'test',
bump = Bump("{version_file}", date_bumper),
bump_post = ['domains', 'dist', 'release', 'publish'],
domains = domains,
dist = 'x-clean build dist *.egg-info && python setup.py sdist bdist_wheel',
release = [
'git add .',
'git commit -m "Release v{version}"',
'git tag -a v{version} -m "Release v{version}"'
],
publish = [
'twine upload dist/*',
'git push --follow-tags'
],
readme_build = [
'python setup.py --long-description | x-pipe build/readme/index.rst',
'rst2html5.py --no-raw --exit-status=1 --verbose '
'build/readme/index.rst build/readme/index.html'
],
readme_pre = "readme_build",
readme = LiveReload("README.rst", "readme_build", "build/readme")
)