Просмотр исходного кода

Renamefunction from func_check_in_html to function_check_html

Sergienko Anton 7 лет назад
Родитель
Сommit
a662528aa8
1 измененных файлов с 7 добавлено и 7 удалено
  1. 7 7
      src/program_efremova.py

+ 7 - 7
src/program_efremova.py

@@ -199,12 +199,12 @@ def check_word_in_academic(word, html):
     return answer
 
 
-def check_word_in_site(word, url, func_check_in_html):
+def check_word_in_site(word, url, function_check_html):
     answer = None
     try:
         response = requests.get(url + word, allow_redirects=False)
         if response.status_code == 200:
-            answer_from_html = func_check_in_html(word, response.text)
+            answer_from_html = function_check_html(word, response.text)
             if answer_from_html is not None:
                 answer = answer_from_html
         else:
@@ -220,12 +220,12 @@ def check_word_in_site(word, url, func_check_in_html):
 
 @function_execution_time
 @if_exist_json
-def check_words_on_site(url, func_check_in_html):
+def check_words_on_site(url, function_check_html):
     dictionary = read_json()
     i = 0
     for word, entry in dictionary.items():
-        if 'answerIsProbablyNotNoun' in entry and entry['answerIsProbablyNotNoun'] == 'null':
-            answer = check_word_in_site(word, url, func_check_in_html)
+        if 'answerIsProbablyNotNoun' in entry and entry['answerIsProbablyNotNoun'] in ['null', '404']:
+            answer = check_word_in_site(word, url, function_check_html)
             if answer is not None:
                 dictionary[word]['answerIsProbablyNotNoun'] = answer
                 i += 1
@@ -248,10 +248,10 @@ def main():
         {'text': 'Список непроверенных слов во мн. числе', 'function': print_list_of_words,
          'params': {'key': 'answerNeedToIncludePlural', 'answer': 'null'}},
         {'text': 'Проверить подозрительные слова на wiktionary.org', 'function': check_words_on_site,
-         'params': {'url': 'https://ru.wiktionary.org/wiki/', 'func_check_in_html': check_word_in_wiktionary}},
+         'params': {'url': 'https://ru.wiktionary.org/wiki/', 'function_check_html': check_word_in_wiktionary}},
         {'text': 'Проверить подозрительные слова на dic.academic.ru', 'function': check_words_on_site,
          'params': {'url': 'https://dic.academic.ru/searchall.php?SWord=',
-                    'func_check_in_html': check_word_in_academic}}
+                    'function_check_html': check_word_in_academic}}
     ]
 
     while True: