From ec28f3d2a263440b167b2ae44033f2eae5bab88c Mon Sep 17 00:00:00 2001 From: Charles Date: Thu, 21 May 2020 11:42:33 +0200 Subject: problem 1 2 3 in rust --- generate.py | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'generate.py') diff --git a/generate.py b/generate.py index b186a7f..7c69961 100644 --- a/generate.py +++ b/generate.py @@ -25,17 +25,25 @@ def read_config(): def write_problem(index, title, sub_title, content, language_config, config): - text = '\n'.join([language_config['comment']['top'], title, sub_title, '', content, - language_config['comment']['bottom']]) - # *[content[i * config['line_wrap']:(i + 1) * config['line_wrap']] - # for i in range(int(len(content) / config['line_wrap']))], - text = ('\n'.join([language_config['comment']['prefix'] - + line for line in text.split('\n')]) - + '\n' * config['problem_padding']) - slug = ''.join([c for c in title.lower().replace(' ', '_') if c.isalpha() or - c.isdigit() or c == '_']) - filename = (str(index).zfill(3) + '-' - + slug + '.' + language_config['extension']) + text = '\n'.join([ + title, + sub_title, + '', + content, + ]) + + text = '\n'.join( + [language_config['comment']['prefix'] + line for line in text.split('\n')] + ) + text = language_config['comment']['top'] + '\n' + text + text += '\n' + language_config['comment']['bottom'] + text += '\n' * config['problem_padding'] + + + slug = ''.join([c for c in title.lower().replace(' ', '_') + if c.isalpha() or c.isdigit() or c == '_']) + + filename = (str(index).zfill(3) + '-' + slug + '.' + language_config['extension']) try: with open(filename, 'w') as file: file.write(text) -- cgit