Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sourcery refactored main branch #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Sep 12, 2023

Branch main refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the main branch, then run:

git fetch origin sourcery/main
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

Copy link
Author

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sourcery timed out performing refactorings.

Due to GitHub API limits, only the first 60 comments can be shown.

print("%s @ %s" % (filename, lineno))
print(f"{filename} @ {lineno}")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function trace refactored with the following changes:

Comment on lines -5 to +45
x = open("mybotr.po", "a")
with open('mybot.po', encoding='UTF-8') as f:
idblock=""
idblock2=""
lines = f.readlines()
for row in lines:
if row[0] == '"':
idblock = idblock + row
xr2 = deepl.translate(source_language="RU", target_language="EN", text=row)
idblock2 = idblock2 + xr2
print(idblock)
print(idblock2)
print("1")
if 'msgid ' in row:
print("2")
print("2-1")
if 'msgid ""' in row:
idblock= idblock + 'msgid ""' + "\n"
idblock2= idblock2 + 'msgstr ""' + "\n"
#x.write('msgid ""\n')
else:
idblock= idblock + row + "\n"
xb2 = deepl.translate(source_language="RU", target_language="EN", text=row[7:])
idblock2= idblock2 + 'msgstr ' + xb2
with open("mybotr.po", "a") as x:
with open('mybot.po', encoding='UTF-8') as f:
idblock=""
idblock2=""
lines = f.readlines()
for row in lines:
if row[0] == '"':
idblock = idblock + row
xr2 = deepl.translate(source_language="RU", target_language="EN", text=row)
idblock2 = idblock2 + xr2
print(idblock)
print(idblock2)
print("1")
if 'msgid ' in row:
print("2")
print("2-1")
if 'msgid ""' in row:
idblock = f'{idblock}msgid ""' + "\n"
idblock2 = f'{idblock2}msgstr ""' + "\n"
else:
idblock= idblock + row + "\n"
xb2 = deepl.translate(source_language="RU", target_language="EN", text=row[7:])
idblock2 = f'{idblock2}msgstr {xb2}'
continue
print(row[7:])
#x.write('msgstr ' + row[6:])
elif 'msgstr' in row:
print("3")
x.write(idblock)
x.write(idblock2)
idblock = ""
idblock2 = ""
continue
print(row[7:])
#x.write('msgstr ' + row[6:])
elif 'msgstr' in row:
print("3")
x.write(idblock)
x.write(idblock2)
idblock = ""
idblock2 = ""
continue
elif row[0] == "\n":
print("4")
x.write('\n')
#idblock= idblock + row
#idblock2= idblock2 + row
else:
xrow = deepl.translate(source_language="RU", target_language="EN", text=row)
x.write(xrow)
x.close()
elif row[0] == "\n":
print("4")
x.write('\n')
#idblock= idblock + row
#idblock2= idblock2 + row
else:
xrow = deepl.translate(source_language="RU", target_language="EN", text=row)
x.write(xrow)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 5-47 refactored with the following changes:

This removes the following comments ( why? ):

#x.write('msgid ""\n')

print(f"{str(cur_time.hour)}:{str(cur_time.minute)}")
print(f"{cur_time.hour}:{cur_time.minute}")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 309-309 refactored with the following changes:

  • Simplify conditional into switch-like form [×2] (switch)
  • Remove unnecessary calls to str() from formatted values in f-strings [×2] (remove-str-from-fstring)

Comment on lines -95 to +99
if dialog.chat.type == ChatType.GROUP or dialog.chat.type == ChatType.SUPERGROUP:
if dialog.chat.type in [ChatType.GROUP, ChatType.SUPERGROUP]:
for v in ids:
s = v
del ids[:1]

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function inviter refactored with the following changes:

Comment on lines -169 to +175
mode = "tohour"
ct = 0
shortlen = 450
shortmestext = message.html_text[0:449]
shortmestext = message.html_text[:449]

if user_role in ["Admin", "ShopAdmin"]:
print("P10P20R")
mode = "tohour"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function functions_ad_get refactored with the following changes:

Comment on lines -269 to +271
#async with state.proxy() as data:
# position_id = data['here_position_id']
# print(position_id)
lang = "ru"
#await state.set_state("here_position_time_selection")
if selected:
#async with state.proxy() as data:
# position_id = data['here_position_id']
# print(position_id)
lang = "ru"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function process_simple_calendar refactored with the following changes:

Comment on lines -301 to +300
user_id = call.from_user.id
lang = "ru"
if r.selected:
user_id = call.from_user.id
lang = "ru"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function process_hour_timepicker refactored with the following changes:

Comment on lines -344 to +342
text=f"Пожалуйста, выберите дату для постинга позиции:",
reply_markup=await SimpleCalendar().start_calendar()
text="Пожалуйста, выберите дату для постинга позиции:",
reply_markup=await SimpleCalendar().start_calendar(),
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function product_position_planning_approve refactored with the following changes:

Comment on lines -360 to +361
user_id = call.from_user.id

if decision == "yes":
await update_positionx(position_id, position_state="Broadcast")

user_id = call.from_user.id

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function product_position_planning_approve refactored with the following changes:

Comment on lines -377 to +380
user_requests = get_requestx(requester=user_id)
#print(user_requests)

if user_requests:
if user_requests := get_requestx(requester=user_id):
await message.answer("У Вас уже есть запросы продавца |||| Если админ Вам не подтвердил запрос, напишите: @raclear")
#for request in user_requests:
#print(request)
await message.answer(open_profile_search_req(user_id, lang), reply_markup=menu_frep(user_id, lang))
await state.set_state("here_seller_request_direction")
await message.answer(_("<b>📁 Введите тип товара, который Вы будете продавать:</b>", locale=lang))
else:
await state.set_state("here_seller_request_direction")
await message.answer(_("<b>📁 Введите тип товара, который Вы будете продавать:</b>", locale=lang))
await state.set_state("here_seller_request_direction")
await message.answer(_("<b>📁 Введите тип товара, который Вы будете продавать:</b>", locale=lang))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function user_seller_request refactored with the following changes:

This removes the following comments ( why? ):

#print(user_requests)

Comment on lines -496 to +489
action = "edit"
if user_role in ["Admin", "ShopAdmin"]:
await state.finish()
action = "edit"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function product_position_edit refactored with the following changes:

Comment on lines -1497 to +1488
if user_role == "Admin" or user_role == "ShopAdmin": #user_id in get_admins(): #
if user_role in ["Admin", "ShopAdmin"]: #user_id in get_admins(): #
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function payment_systems refactored with the following changes:

Comment on lines -1771 to +1762
if user_role == "Admin" or user_role == "ShopAdmin":
if user_role in ["Admin", "ShopAdmin"]:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function product_position_create_select_category refactored with the following changes:

@@ -1785,14 +1776,14 @@ async def product_position_open_select_category(call: CallbackQuery, state: FSMC
#else: city_id = int(call.data.split(":")[3])
print(category_id, city_id, get_category)

source = "people"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function product_position_open_select_category refactored with the following changes:

Comment on lines -1814 to -1815
action = "edit"
source = "commercial"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function product_position_create_select_category refactored with the following changes:

Comment on lines -70 to +67
priceusdt = response['price']
return priceusdt
return response['price']
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function GetUSDTPrice refactored with the following changes:

Comment on lines -84 to +80
btc_price = response['price']
return btc_price
return response['price']
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function GetBtcPrice refactored with the following changes:

Comment on lines -92 to +87
tokens = response.json()

return tokens
return response.json()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function getTokens refactored with the following changes:

Comment on lines -113 to +109
tron_address = get_tron_address(call.from_user.id)
trx_addr_txt = ""
if tron_address: trx_addr_txt = f"<b>Ваш текущий Tron TRC20 адрес</b>: {tron_address['tron_address']}\n"
if tron_address := get_tron_address(call.from_user.id):
trx_addr_txt = f"<b>Ваш текущий Tron TRC20 адрес</b>: {tron_address['tron_address']}\n"
else:
trx_addr_txt = ""
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function change_trc20 refactored with the following changes:

Comment on lines -125 to +122
btcb_address = get_crypto_address(call.from_user.id, "BTCB")
btcb_addr_txt = ""
if btcb_address: btcb_addr_txt = f"<b>Ваш текущий BTC BEP20 адрес</b>: {btcb_address['tron_address']}\n"
if btcb_address := get_crypto_address(call.from_user.id, "BTCB"):
btcb_addr_txt = f"<b>Ваш текущий BTC BEP20 адрес</b>: {btcb_address['tron_address']}\n"
else:
btcb_addr_txt = ""
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function change_trc20 refactored with the following changes:

if get_way == "Form" or get_way == "Nickname" or get_way == "Number":
if get_way in ["Form", "Nickname", "Number"]:
get_message, get_link, receipt = await (
await QiwiAPI(cache_message, user_bill_pass=True)
).bill_pay(pay_amount, get_way)

if get_way == "Tron" or get_way == "BTCB":
if get_way in ["Tron", "BTCB"]:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function refill_get refactored with the following changes:

Comment on lines -447 to +442
await call.answer(f"♻ Подождите, платёж проверяется...")
await call.answer("♻ Подождите, платёж проверяется...")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function refill_check_tron refactored with the following changes:

Comment on lines -523 to +520
await call.answer(f"♻ Подождите, платёж проверяется...")
await call.answer("♻ Подождите, платёж проверяется...")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function refill_check_tron refactored with the following changes:

Comment on lines -580 to +582
await message.answer(f"<b>♻ Был введен пустой адрес</b>", reply_markup=back_to_profile_finl('ru'))
await message.answer(
"<b>♻ Был введен пустой адрес</b>",
reply_markup=back_to_profile_finl('ru'),
)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function enter_tron_address refactored with the following changes:

Comment on lines -643 to +646
await message.answer(f"<b>♻ Успешно сохранили Ваш BEP-20 адрес в профиле.</b>", reply_markup=back_to_profile_finl('ru'))
await message.answer(
"<b>♻ Успешно сохранили Ваш BEP-20 адрес в профиле.</b>",
reply_markup=back_to_profile_finl('ru'),
)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function enter_tron_address refactored with the following changes:

Comment on lines -404 to +410
if lang == "ru":
dbtn = "❌ Да, удалить"
cbtn = "✅ Нет, отменить"

if lang == "en":
dbtn = "❌ Yes, Delete Please"
cbtn = "✅ No, Cancel Please"

elif lang == "ru":
dbtn = "❌ Да, удалить"
cbtn = "✅ Нет, отменить"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function category_edit_delete_finl refactored with the following changes:

  • Simplify conditional into switch-like form (switch)

Comment on lines -425 to -431
if lang == "ru":
yesbtn = "❌ Да, удалить"
nobtn = "✅ Нет, отменить"
if lang == "en":
if lang in ["ru", "en"]:
yesbtn = "❌ Да, удалить"
nobtn = "✅ Нет, отменить"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function shop_edit_delete_finl2 refactored with the following changes:

  • Simplify conditional into switch-like form (switch)

Comment on lines -446 to -459
if lang == "ru":
chnbtn = "🏷 Изм. название"
chpbtn = "💰 Изм. цену"
chdbtn = "📜 Изм. описание"
chphbtn = "📸 Изм. фото"
chrbtn = "📜 Изменить остаток"
chlbtn = "📸 <---<ВП>-->"
chcbtn = "🏙 Изм. город"
chsbtn = "🏙 Изм. магазин"
chclbtn = "🗑 Очистить"
agbtn = "🎁 Добавить товары"
prsbtn = "📥 Товары"
delbtn = "❌ Удалить"
backbtn = "⬅ Вернуться ↩"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function position_edit_open_finl refactored with the following changes:

  • Simplify conditional into switch-like form (switch)

Comment on lines -608 to +610
if lang == "ru":
dbtn = "❌ Да, удалить"
cbtn = "✅ Нет, отменить"
if lang == "en":
dbtn = "❌ Yes, Delete"
cbtn = "✅ No, Cancel"

elif lang == "ru":
dbtn = "❌ Да, удалить"
cbtn = "✅ Нет, отменить"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function position_edit_delete_finl refactored with the following changes:

  • Simplify conditional into switch-like form (switch)

Comment on lines -629 to +631
if lang == "ru":
clbtn = "❌ Да, очистить"
ccbtn = "✅ Нет, отменить"
if lang == "en":
clbtn = "❌ Yes, Clear"
ccbtn = "✅ No, Cancel"

elif lang == "ru":
clbtn = "❌ Да, очистить"
ccbtn = "✅ Нет, отменить"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function position_edit_clear_finl refactored with the following changes:

  • Simplify conditional into switch-like form (switch)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants