From 7cbb6ea3891b350457bb46731b822c1ab58531ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Thu, 16 Sep 2021 15:27:35 +0200 Subject: [PATCH] refactor utils file and move MAX_LEN parameter into config file --- scripts/config.py | 1 + scripts/utils.py | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/config.py b/scripts/config.py index c152848..9ef3ea8 100644 --- a/scripts/config.py +++ b/scripts/config.py @@ -20,3 +20,4 @@ LOCALE = "de_DE.utf8" COURSE_IGNORE_FILE = '.courseignore' COURSE_INFO_FILE = 'info.yaml' DEFAULT_MASTER_FILE_NAME = 'master.tex' +MAX_LEN = 40 diff --git a/scripts/utils.py b/scripts/utils.py index ac06a70..428a227 100644 --- a/scripts/utils.py +++ b/scripts/utils.py @@ -1,14 +1,17 @@ +from config import MAX_LEN + + def beautify(string): return string.replace('_', ' ').replace('-', ' ').title() + def unbeautify(string): return string.replace(' ', '-').lower() -MAX_LEN = 40 + def generate_short_title(title): short_title = title or 'Untitled' if len(title) >= MAX_LEN: short_title = title[:MAX_LEN - len(' ... ')] + ' ... ' short_title = short_title.replace('$', '') return short_title -