mirror of
https://github.com/bregman-arie/devops-exercises.git
synced 2026-02-04 15:49:11 +00:00
question_utils.py each long line has been split to ensure that no line exceeds 100 characters (#10568)
This commit is contained in:
parent
d3fd48bd84
commit
5fde9ba3d3
@ -22,7 +22,11 @@ def get_file_content() -> str:
|
|||||||
|
|
||||||
def get_question_list(file_content: str) -> List[str]:
|
def get_question_list(file_content: str) -> List[str]:
|
||||||
details = DETAILS_PATTERN.findall(file_content)
|
details = DETAILS_PATTERN.findall(file_content)
|
||||||
return [SUMMARY_PATTERN.search(detail).group(1) for detail in details if SUMMARY_PATTERN.search(detail)]
|
return [
|
||||||
|
SUMMARY_PATTERN.search(detail).group(1)
|
||||||
|
for detail in details
|
||||||
|
if SUMMARY_PATTERN.search(detail)
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
def get_answered_questions(file_content: str) -> List[str]:
|
def get_answered_questions(file_content: str) -> List[str]:
|
||||||
@ -31,7 +35,12 @@ def get_answered_questions(file_content: str) -> List[str]:
|
|||||||
for detail in details:
|
for detail in details:
|
||||||
summary_match = SUMMARY_PATTERN.search(detail)
|
summary_match = SUMMARY_PATTERN.search(detail)
|
||||||
b_match = B_PATTERN.search(detail)
|
b_match = B_PATTERN.search(detail)
|
||||||
if summary_match and b_match and summary_match.group(1).strip() and b_match.group(1).strip():
|
if (
|
||||||
|
summary_match
|
||||||
|
and b_match
|
||||||
|
and summary_match.group(1).strip()
|
||||||
|
and b_match.group(1).strip()
|
||||||
|
):
|
||||||
answered.append(summary_match.group(1))
|
answered.append(summary_match.group(1))
|
||||||
return answered
|
return answered
|
||||||
|
|
||||||
@ -56,11 +65,17 @@ def get_random_question(question_list: List[str], with_answer: bool = False) ->
|
|||||||
"""Use this question_list. Unless you have already opened/worked/need the file, then don't or
|
"""Use this question_list. Unless you have already opened/worked/need the file, then don't or
|
||||||
you will end up doing the same thing twice.
|
you will end up doing the same thing twice.
|
||||||
eg:
|
eg:
|
||||||
#my_dir/main.py
|
# my_dir/main.py
|
||||||
from scripts import question_utils
|
from scripts import question_utils
|
||||||
print(question_utils.get_answered_questions(question_utils.get_question_list(question_utils.get_file_content()))
|
|
||||||
|
print(
|
||||||
|
question_utils.get_answered_questions(
|
||||||
|
question_utils.get_question_list(
|
||||||
|
question_utils.get_file_content()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
>> 123
|
>> 123
|
||||||
# noqa: E501
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user