Explorar o código

Правки по PEP8

Vildan %!s(int64=2) %!d(string=hai) anos
pai
achega
e78b40b607
Modificáronse 11 ficheiros con 214 adicións e 33 borrados
  1. 185 0
      .gitignore
  2. 0 2
      config.py
  3. 16 16
      database.py
  4. 1 1
      dispatcher.py
  5. 4 4
      draft.py
  6. 0 2
      functions.py
  7. 0 0
      handlers.py
  8. 1 1
      handlers/admin/admin_menu.py
  9. 2 3
      handlers/comands.py
  10. 4 4
      handlers/events.py
  11. 1 0
      requirements.txt

+ 185 - 0
.gitignore

@@ -0,0 +1,185 @@
+# Created by .ignore support plugin (hsz.mobi)
+### Python template
+# Byte-compiled / optimized / DLL files
+__pycache__/
+*.py[cod]
+*$py.class
+
+# C extensions
+*.so
+
+# Distribution / packaging
+.Python
+env/
+build/
+develop-eggs/
+dist/
+downloads/
+eggs/
+.eggs/
+lib/
+lib64/
+parts/
+sdist/
+var/
+*.egg-info/
+.installed.cfg
+*.egg
+
+# PyInstaller
+#  Usually these files are written by a python script from a template
+#  before PyInstaller builds the exe, so as to inject date/other infos into it.
+*.manifest
+*.spec
+
+# Installer logs
+pip-log.txt
+pip-delete-this-directory.txt
+
+# Unit test / coverage reports
+htmlcov/
+.tox/
+.coverage
+.coverage.*
+.cache
+nosetests.xml
+coverage.xml
+*,cover
+.hypothesis/
+
+# Translations
+*.mo
+*.pot
+
+# Django stuff:
+*.log
+local_settings.py
+
+# Flask stuff:
+instance/
+.webassets-cache
+
+# Scrapy stuff:
+.scrapy
+
+# Sphinx documentation
+docs/_build/
+
+# PyBuilder
+target/
+
+# IPython Notebook
+.ipynb_checkpoints
+
+# pyenv
+.python-version
+
+# celery beat schedule file
+celerybeat-schedule
+
+# dotenv
+.env
+
+# virtualenv
+venv/
+ENV/
+
+# Spyder project settings
+.spyderproject
+
+# Rope project settings
+.ropeproject
+### VirtualEnv template
+# Virtualenv
+# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
+[Bb]in
+[Ii]nclude
+[Ll]ib
+[Ll]ib64
+[Ll]ocal
+[Ss]cripts
+pyvenv.cfg
+.venv
+pip-selfcheck.json
+
+### JetBrains template
+# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
+# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
+
+# User-specific stuff
+.idea/**/workspace.xml
+.idea/**/tasks.xml
+.idea/**/usage.statistics.xml
+.idea/**/dictionaries
+.idea/**/shelf
+
+# AWS User-specific
+.idea/**/aws.xml
+
+# Generated files
+.idea/**/contentModel.xml
+
+# Sensitive or high-churn files
+.idea/**/dataSources/
+.idea/**/dataSources.ids
+.idea/**/dataSources.local.xml
+.idea/**/sqlDataSources.xml
+.idea/**/dynamic.xml
+.idea/**/uiDesigner.xml
+.idea/**/dbnavigator.xml
+
+# Gradle
+.idea/**/gradle.xml
+.idea/**/libraries
+
+# Gradle and Maven with auto-import
+# When using Gradle or Maven with auto-import, you should exclude module files,
+# since they will be recreated, and may cause churn.  Uncomment if using
+# auto-import.
+# .idea/artifacts
+# .idea/compiler.xml
+# .idea/jarRepositories.xml
+# .idea/modules.xml
+# .idea/*.iml
+# .idea/modules
+# *.iml
+# *.ipr
+
+# CMake
+cmake-build-*/
+
+# Mongo Explorer plugin
+.idea/**/mongoSettings.xml
+
+# File-based project format
+*.iws
+
+# IntelliJ
+out/
+
+# mpeltonen/sbt-idea plugin
+.idea_modules/
+
+# JIRA plugin
+atlassian-ide-plugin.xml
+
+# Cursive Clojure plugin
+.idea/replstate.xml
+
+# SonarLint plugin
+.idea/sonarlint/
+
+# Crashlytics plugin (for Android Studio and IntelliJ)
+com_crashlytics_export_strings.xml
+crashlytics.properties
+crashlytics-build.properties
+fabric.properties
+
+# Editor-based Rest Client
+.idea/httpRequests
+
+# Android studio 3.1+ serialized cache file
+.idea/caches/build_file_checksums.ser
+
+# idea folder, uncomment if you don't need it
+# .idea

+ 0 - 2
config.py

@@ -11,5 +11,3 @@ DB_HOST = os.getenv('DB_HOST')
 DB_NAME = os.getenv('DB_NAME')
 DB_USER = os.getenv('DB_USER')
 DB_PASS = os.getenv('DB_PASS')
-
-

+ 16 - 16
database.py

@@ -3,10 +3,10 @@ import config as conf
 
 
 def sql_check_user(db_query):
-    conn = connect(host=conf.db_host,
-                   user=conf.db_user,
-                   password=conf.db_password,
-                   database=conf.db_name)
+    conn = connect(host=conf.DB_HOST,
+                   user=conf.DB_USER,
+                   password=conf.DB_PASS,
+                   database=conf.DB_NAME)
 
     cursor = conn.cursor()
     cursor.execute(db_query)
@@ -18,10 +18,10 @@ def sql_check_user(db_query):
 
 
 def sql_simple_check(db_query, field):
-    conn = connect(host=conf.db_host,
-                   user=conf.db_user,
-                   password=conf.db_password,
-                   database=conf.db_name)
+    conn = connect(host=conf.DB_HOST,
+                   user=conf.DB_USER,
+                   password=conf.DB_PASS,
+                   database=conf.DB_NAME)
 
     cursor = conn.cursor(dictionary=True)
     cursor.execute(db_query)
@@ -33,10 +33,10 @@ def sql_simple_check(db_query, field):
 
 
 def sql_parse_users(db_query):
-    conn = connect(host=conf.db_host,
-                   user=conf.db_user,
-                   password=conf.db_password,
-                   database=conf.db_name)
+    conn = connect(host=conf.DB_HOST,
+                   user=conf.DB_USER,
+                   password=conf.DB_PASS,
+                   database=conf.DB_NAME)
     cursor = conn.cursor(dictionary=True)
     cursor.execute(db_query)
     result_set = cursor.fetchall()
@@ -54,10 +54,10 @@ def sql_parse_users(db_query):
 
 
 def sql_query_send(db_query):
-    conn = connect(host=conf.db_host,
-                   user=conf.db_user,
-                   password=conf.db_password,
-                   database=conf.db_name)
+    conn = connect(host=conf.DB_HOST,
+                   user=conf.DB_USER,
+                   password=conf.DB_PASS,
+                   database=conf.DB_NAME)
 
     cursor = conn.cursor()
     cursor.execute(db_query)

+ 1 - 1
dispatcher.py

@@ -4,5 +4,5 @@ from config import BOT_TOKEN
 from aiogram.contrib.fsm_storage.memory import MemoryStorage
 
 
-bot = Bot(token=BOT_TOKEN, parse_mode="HTML",disable_web_page_preview=True)
+bot = Bot(token=BOT_TOKEN, parse_mode="HTML", disable_web_page_preview=True)
 dp = Dispatcher(bot, storage=MemoryStorage())

+ 4 - 4
draft.py

@@ -20,8 +20,6 @@
 #     persons = State()
 
 
-
-
 # async def user_manage(message: types.Message):
 #     if not sql_check_user(f"select tg_id from user_table where tg_id ={message.from_user.id}") or \
 #             not sql_simple_check(f"select approved from user_table where tg_id={message.from_user.id}", "approved"):
@@ -37,11 +35,13 @@
 #         else:
 #             data = sql_parse_users(f"select id,name,phone from user_table where approved = '0'")
 #             await message.answer(f"Заявки на регистрацию")
-#             await message.answer(" ".join(sql_parse_users(f"select id,name,phone from user_table where approved = '0'")))
+#            await message.answer(" ".join(sql_parse_users(f"select id,name,phone"
+#                                                          f"from user_table"
+#                                                          f"where approved = '0'")))
 #             await message.answer(''.join(data[:1]), reply_markup=kb_user_manage())
 
 
 # @dp.callback_query_handler()
 # async def select_date(call: types.CallbackQuery):
 #     await bot.answer_callback_query(call.id)
-#     await bot.send_message(call.message.chat.id, "Вы выбрали " + call.data)
+#     await bot.send_message(call.message.chat.id, "Вы выбрали " + call.data)

+ 0 - 2
functions.py

@@ -48,7 +48,6 @@ def validate_time():
 
 
 def beauty_reg_request(data):
-
     result = (f"ФИО: {data['ФИО']}\n"
               f"Контакт: {data['Номер телефона']}")
 
@@ -58,4 +57,3 @@ def beauty_reg_request(data):
 def make_date():
     today = datetime.datetime.now()
     return datetime.datetime.strftime(today, '%d.%m.%Y')
-

+ 0 - 0
handlers.py


+ 1 - 1
handlers/admin/admin_menu.py

@@ -1,4 +1,4 @@
-from aiogram import types,Dispatcher
+from aiogram import types, Dispatcher
 from database import sql_simple_check, sql_check_user
 from keyboards import register_kb, main_kb, admin_keyboard
 

+ 2 - 3
handlers/comands.py

@@ -1,6 +1,5 @@
 from aiogram import types, Dispatcher
-from dispatcher import bot
-from keyboards import main_kb, register_kb, make_calendar, admin_keyboard, check_register_kb
+from keyboards import main_kb, register_kb,   check_register_kb
 from database import sql_check_user, sql_simple_check
 
 
@@ -11,7 +10,7 @@ async def start_cmd(message: types.Message):
         await message.answer(f"🤖Вас приветствует лакей ТТИТ🤖\n\n"
                              "Для доступа к функциям нужно пройти простую регистрацию\n",
                              reply_markup=register_kb)
-    elif not sql_simple_check(f"select approved from user_table where tg_id={message.from_user.id}", "approved"):
+    elif not sql_simple_check(f'select approved from user_table where tg_id={message.from_user.id}', "approved"):
         await message.answer(f"Ваша заявка находится на рассмотрернии", reply_markup=check_register_kb)
     else:
         await message.answer(f"🤖Вас приветствует лакей ТТИТ🤖\n"

+ 4 - 4
handlers/events.py

@@ -1,6 +1,6 @@
 from aiogram import types, Dispatcher
-from database import sql_check_user,sql_simple_check
-from keyboards import register_kb,make_calendar
+from database import sql_check_user, sql_simple_check
+from keyboards import register_kb, make_calendar
 from functions import make_date
 
 
@@ -26,11 +26,11 @@ async def select_date(call: types.CallbackQuery):
 
 
 async def my_events(message: types.Message):
-    pass
+    await message.answer("")
 
 
 async def all_events(message: types.Message):
-    pass
+    await message.answer("")
 
 
 def events_register(dp: Dispatcher):

+ 1 - 0
requirements.txt

@@ -1,3 +1,4 @@
+mysql
 dotenv
 aiogram==2.22.2
 aiohttp==3.8.3