From 256d6e72a01c3965199effacbf0ae4cf1b2ba638 Mon Sep 17 00:00:00 2001 From: Jose De Freitas Date: Fri, 19 Feb 2021 11:04:53 -0500 Subject: [PATCH] Add last value --- linter/rules/content_about.py | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/linter/rules/content_about.py b/linter/rules/content_about.py index ccf4819..d8a76f3 100644 --- a/linter/rules/content_about.py +++ b/linter/rules/content_about.py @@ -11,24 +11,28 @@ def content_about(): Looks for trailing slashes and words separated by commas at every "Content about:" section found in the readme.md file (this is, the list itself). + + result (str): return value of the function. + checker (str): detector of the line corresponding the file. """ - content_about_result = 'No errors found.' - # content_about_errors = {} - content_about_line = 'Content about:' + result = 'No errors found.' + checker = 'Content about:' - for j, i in enumerate(content_readme): - if content_about_line in i: - # content_about_words = i[len(content_about_line):-2] - - if i[-2] != '\\': - content_readme[j] = i.replace('&', '\\') + for line, value in enumerate(content_readme): + if checker in value: + # words = i[len(checker):-2].split(', ') + # Check for trailing slash + if value[-1] != '\\': + last = value[-2:-1] + replaced = last.replace(' ', '\\', 1) + content_readme[line] = value[:-2] + ' ' + replaced + '\n' with open(file_readme, 'w') as write_readme: write_readme.writelines(content_readme) - content_about_result = "Found errors. Fixed them." - # content_about_errors.append(j) - return content_about_result - # return content_about_errors + result = "Found errors. Fixed them." + # Check for comma separated words + + return result print(content_about())