Passed
Push — dev ( 812945...ef7082 )
by Máté
01:21
created

helpers.create_upload_filename()   A

Complexity

Conditions 2

Size

Total Lines 9
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 9
rs 10
c 0
b 0
f 0
cc 2
nop 4
1
from re import sub
2
3
from .illustrations.illustration import Illustration  # type: ignore
4
from .questions.helpers import format_latex_as_wikitext  # type: ignore
5
from .quiz_element import QuizElement  # type: ignore
6
from .illustrations.state_of_illustrations import StateOfIllustrations  # type: ignore
7
from .questions.question import Question  # type: ignore
8
from .questions.question_types import QuestionType  # type: ignore
9
10
11
def prettify(text: str) -> str:
12
    text = strip_whitespaces(text)
13
    text = format_latex_as_wikitext(text)
14
    return text
15
16
17
def strip_whitespaces(text: str) -> str:
18
    text = text.strip("., \n")
19
    text = sub(r" \n|\r\n|\s{2}", " ", text)
20
    return text
21