Skip to content
This repository was archived by the owner on Jun 7, 2020. It is now read-only.

Commit aed0626

Browse files
committed
Merge branch 'develop'
2 parents a2ff68c + 7a7f5c8 commit aed0626

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

ifj2017/interpreter/instruction.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,17 @@ def operands(self):
140140
'READ': State.read,
141141
'TYPE': lambda state, op0, op1: state.set_value(
142142
op0,
143-
Operand.CONSTANT_MAPPING_REVERSE.get(type(state.get_value(op1))) if state.get_value(op1) is not None else ''
143+
type(state.get_value(op1)).__name__
144+
if state.get_value(op1) is not None else ''
144145
),
145146

146147
'BREAK': lambda state: state.stderr.write('{}\n'.format(state)),
147148
'DPRINT': lambda state, op0: state.stderr.write('{}\n'.format(state.get_value(op0))),
148-
'GROOT': lambda state: state.stderr.write('Price: {} ({}+{}).\n'.format(state.price, state.instruction_price, state.operand_price)),
149+
'GROOT': lambda state: state.stderr.write(
150+
'Price: {} ({}+{}).\n'.format(
151+
state.price, state.instruction_price, state.operand_price
152+
)
153+
),
149154

150155
'CONCAT': lambda state, target, op0, op1: state.set_value(target, ''.join((
151156
state.get_value(op0),

utils/release.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77
from glob import glob1
88
from operator import itemgetter
99
from os import unlink, getcwd
10-
from os.path import basename, join, abspath
10+
from os.path import basename, join, abspath, dirname
1111
from tarfile import TarFile
1212
from tempfile import mktemp
1313

1414
from git import Repo
1515

16-
__DIR__ = abspath(getcwd())
16+
__CWD_DIR__ = abspath(getcwd())
17+
__DIR__ = dirname(abspath(__file__))
18+
__PROJECT_DIR__ = abspath(join(dirname(abspath(__file__)), '..'))
1719

1820
HEADER = """\
1921
/*
@@ -23,6 +25,7 @@
2325
* @author {}
2426
*
2527
* Generated: {}
28+
* Academic year: 2017-2018
2629
* Team: xkobel02, xkolar71, xpazdi02, xnguye16
2730
* Project URL: https://github.com/thejoeejoee/IFJ-VUT-BIT-2017-2018
2831
* Encoding: UTF-8
@@ -49,8 +52,17 @@ def _add_header(original, target_file, authors):
4952
)
5053

5154

52-
def deploy(source_dir, to_archive):
53-
source_dir = abspath(join(__DIR__, source_dir))
55+
def include_tests(archive: TarFile):
56+
def exclude(name: str):
57+
return name.endswith('pyc') or '__pycache__' in name
58+
59+
archive.add(join(__PROJECT_DIR__, 'test.py'), 'tests/test.py')
60+
for d in 'benchmark interpreter test tests __init__.py'.split():
61+
archive.add(join(__PROJECT_DIR__, 'ifj2017/{}'.format(d)), 'tests/ifj2017/{}'.format(d), exclude=exclude)
62+
63+
64+
def deploy(source_dir, to_archive, tests=False):
65+
source_dir = abspath(join(__CWD_DIR__, source_dir))
5466
source_files = set(glob1(source_dir, '*.c') + glob1(source_dir, '*.h') + glob1(source_dir, 'Makefile'))
5567
source_files.add(join(source_dir, '../rozdeleni'))
5668
source_files.add(join(source_dir, '../rozsireni'))
@@ -64,7 +76,6 @@ def deploy(source_dir, to_archive):
6476
repository = Repo(source_dir, search_parent_directories=True)
6577

6678
with TarFile.open(name=to_archive, mode='x:gz') as target_archive:
67-
6879
for file_ in source_files:
6980
print('Processing {}.'.format(file_), file=sys.stderr)
7081
counter = Counter(
@@ -86,6 +97,8 @@ def deploy(source_dir, to_archive):
8697
map(itemgetter(0), counter.most_common())
8798
)
8899
target_archive.add(modified, arcname=basename(file_))
100+
if tests:
101+
include_tests(target_archive)
89102

90103

91104
def main():
@@ -95,9 +108,10 @@ def main():
95108

96109
parser.add_argument("source_dir", help="path to src of project")
97110
parser.add_argument("archive_name", help="name of produced")
111+
parser.add_argument("--tests", help="include tests?", action='store_true')
98112

99113
args = parser.parse_args()
100-
return deploy(args.source_dir, args.archive_name)
114+
return deploy(args.source_dir, args.archive_name, args.tests)
101115

102116

103117
if __name__ == '__main__':

0 commit comments

Comments
 (0)