-
Notifications
You must be signed in to change notification settings - Fork 1
/
tasks.py
32 lines (27 loc) · 953 Bytes
/
tasks.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
# coding=utf-8
from shutil import copy
from time import sleep
from pathlib import Path
from invoke import run, task
@task
def tags(docs=False):
if docs:
run(u"Przygotuj tagi dla pliku pong.py w oparciu o wersje pliku w folderze zadania")
targets = {}
cwd = Path(".")
exercises = Path("./zadania")
for p in exercises.iterdir():
name, tag = p.stem.rsplit("_", 1)
targets.setdefault(tag, []).append(name)
for tag in sorted(targets.keys()):
for name in targets[tag]:
src = exercises / (name + "_" + tag + ".py")
dst = cwd / (name+".py")
print "Kopiuje ", src, " do ", dst
copy(unicode(src), unicode(dst))
run('git commit -am '+tag)
run('git tag -f '+tag)
sleep(1) # Git psuje ścieżki powiązań jeśli operacje są zbyt blisko siebie
@task
def push(docs=False):
run("git push --tags")