fixed pylint CQ issues

This commit is contained in:
navjot 2021-05-31 13:24:40 +05:30
parent 9333ade8cc
commit 17447683fe
No known key found for this signature in database
GPG Key ID: 9EE70AFD71357F1C
10 changed files with 126 additions and 135 deletions

View File

@ -32,6 +32,7 @@ class AddressBook(Screen):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
"""Getting AddressBook Details""" """Getting AddressBook Details"""
super(AddressBook, self).__init__(*args, **kwargs) super(AddressBook, self).__init__(*args, **kwargs)
self.addbook_popup = None
Clock.schedule_once(self.init_ui, 0) Clock.schedule_once(self.init_ui, 0)
def init_ui(self, dt=0): def init_ui(self, dt=0):

View File

@ -1,4 +1,3 @@
import os
from datetime import datetime from datetime import datetime
from kivy.core.window import Window from kivy.core.window import Window
from kivy.lang import Builder from kivy.lang import Builder
@ -10,6 +9,7 @@ from kivymd.uix.list import (
from kivy.uix.image import Image from kivy.uix.image import Image
from kivymd.uix.label import MDLabel from kivymd.uix.label import MDLabel
from bitmessagekivy.get_platform import platform from bitmessagekivy.get_platform import platform
from kivymd.toast import kivytoast
from kivymd.uix.card import MDCardSwipe from kivymd.uix.card import MDCardSwipe
from kivymd.uix.chip import MDChip from kivymd.uix.chip import MDChip
from kivy.properties import ( from kivy.properties import (
@ -49,34 +49,29 @@ def chipTag(text):
return obj return obj
def initailize_detail_page(manager): # def initailize_detail_page(manager):
if not manager.has_screen( # if not manager.has_screen(
data_screens['MailDetail']["name_screen"] # data_screens['MailDetail']["name_screen"]
): # ):
Builder.load_file( # Builder.load_file(
os.path.join( # os.path.join(
# os.environ["KITCHEN_SINK_ROOT"], # # os.environ["KITCHEN_SINK_ROOT"],
os.path.dirname(os.path.dirname(__file__)), # os.path.dirname(os.path.dirname(__file__)),
"kv", # "kv",
"maildetail.kv", # "maildetail.kv",
) # )
) # )
if "Import" in data_screens['MailDetail']: # if "Import" in data_screens['MailDetail']:
exec(data_screens['MailDetail']["Import"]) # exec(data_screens['MailDetail']["Import"])
screen_object = eval(data_screens['MailDetail']["Factory"]) # screen_object = eval(data_screens['MailDetail']["Factory"])
data_screens['MailDetail']["object"] = screen_object # data_screens['MailDetail']["object"] = screen_object
manager.add_widget(screen_object) # manager.add_widget(screen_object)
manager.current = data_screens['MailDetail']["name_screen"] # manager.current = data_screens['MailDetail']["name_screen"]
def toast(text): def toast(text):
"""Method will display the toast message""" """Method will display the toast message"""
# pylint: disable=redefined-outer-name kivytoast.toast(text)
from kivymd.toast.kivytoast import toast
toast(text)
return None
def showLimitedCnt(total_msg): def showLimitedCnt(total_msg):
"""This method set the total count limit in badge_text""" """This method set the total count limit in badge_text"""
@ -97,7 +92,7 @@ def avatarImageFirstLetter(letter_string):
return img_latter if img_latter else '!' return img_latter if img_latter else '!'
def AddTimeWidget(time): # pylint: disable=redefined-outer-name def AddTimeWidget(time): # pylint: disable=redefined-outer-name, W0201
"""This method is used to create TimeWidget""" """This method is used to create TimeWidget"""
action_time = TimeTagRightSampleWidget( action_time = TimeTagRightSampleWidget(
text=str(ShowTimeHistoy(time)), text=str(ShowTimeHistoy(time)),
@ -123,6 +118,7 @@ def ShowTimeHistoy(act_time):
return display_data return display_data
# pylint: disable=too-few-public-methods
class AvatarSampleWidget(ILeftBody, Image): class AvatarSampleWidget(ILeftBody, Image):
"""AvatarSampleWidget class for kivy Ui""" """AvatarSampleWidget class for kivy Ui"""
@ -132,6 +128,7 @@ class TimeTagRightSampleWidget(IRightBodyTouch, MDLabel):
class SwipeToDeleteItem(MDCardSwipe): class SwipeToDeleteItem(MDCardSwipe):
"""Swipe delete class for App UI"""
text = StringProperty() text = StringProperty()
cla = Window.size[0] / 2 cla = Window.size[0] / 2
# cla = 800 # cla = 800
@ -140,6 +137,7 @@ class SwipeToDeleteItem(MDCardSwipe):
class CutsomSwipeToDeleteItem(MDCardSwipe): class CutsomSwipeToDeleteItem(MDCardSwipe):
"""Custom swipe delete class for App UI"""
text = StringProperty() text = StringProperty()
cla = Window.size[0] / 2 cla = Window.size[0] / 2
swipe_distance = NumericProperty(cla) swipe_distance = NumericProperty(cla)

View File

@ -60,7 +60,7 @@ class Random(Screen):
self.manager.current = 'myaddress' self.manager.current = 'myaddress'
Clock.schedule_once(self.address_created_callback, 6) Clock.schedule_once(self.address_created_callback, 6)
def address_created_callback(self, dt=0): # pylint: disable=unused-argument def address_created_callback(self, dt=0): # pylint: disable=unused-argument
"""New address created""" """New address created"""
state.kivyapp.loadMyAddressScreen(False) state.kivyapp.loadMyAddressScreen(False)
state.kivyapp.root.ids.sc10.ids.ml.clear_widgets() state.kivyapp.root.ids.sc10.ids.ml.clear_widgets()

View File

@ -48,7 +48,7 @@ class Create(Screen):
self.add_widget(widget_1) self.add_widget(widget_1)
self.children[0].ids.id_scroll.bind(scroll_y=self.check_scroll_y) self.children[0].ids.id_scroll.bind(scroll_y=self.check_scroll_y)
def check_scroll_y(self, instance, somethingelse): # pylint: disable=unused-argument def check_scroll_y(self, instance, somethingelse): # pylint: disable=unused-argument
"""show data on scroll down""" """show data on scroll down"""
if self.children[1].ids.btn.is_open: if self.children[1].ids.btn.is_open:
self.children[1].ids.btn.is_open = False self.children[1].ids.btn.is_open = False
@ -84,100 +84,94 @@ class DropDownWidget(BoxLayout):
toAddress = self.ids.txt_input.text.strip() toAddress = self.ids.txt_input.text.strip()
subject = self.ids.subject.text.strip() subject = self.ids.subject.text.strip()
message = self.ids.body.text.strip() message = self.ids.body.text.strip()
encoding = 3
print("message: ", self.ids.body.text) print("message: ", self.ids.body.text)
sendMessageToPeople = True if toAddress != "" and subject and message:
if sendMessageToPeople: status, addressVersionNumber, streamNumber, ripe = decodeAddress(
if toAddress != "" and subject and message: toAddress
status, addressVersionNumber, streamNumber, ripe = decodeAddress( )
toAddress if status == "success":
) navApp.root.ids.sc3.children[0].active = True
if status == "success": if state.detailPageType == "draft" and state.send_draft_mail:
navApp.root.ids.sc3.children[0].active = True sqlExecute(
if state.detailPageType == "draft" and state.send_draft_mail: "UPDATE sent SET toaddress = ?"
sqlExecute( ", fromaddress = ? , subject = ?"
"UPDATE sent SET toaddress = ?" ", message = ?, folder = 'sent'"
", fromaddress = ? , subject = ?" ", senttime = ?, lastactiontime = ?"
", message = ?, folder = 'sent'" " WHERE ackdata = ?;",
", senttime = ?, lastactiontime = ?" toAddress,
" WHERE ackdata = ?;", fromAddress,
toAddress, subject,
fromAddress, message,
subject, int(time.time()),
message, int(time.time()),
int(time.time()), state.send_draft_mail)
int(time.time()), self.parent.parent.screens[13].clear_widgets()
state.send_draft_mail) self.parent.parent.screens[13].add_widget(Factory.Draft())
self.parent.parent.screens[13].clear_widgets() # state.detailPageType = ''
self.parent.parent.screens[13].add_widget(Factory.Draft()) # state.send_draft_mail = None
# state.detailPageType = ''
# state.send_draft_mail = None
else:
from addresses import addBMIfNotPresent
toAddress = addBMIfNotPresent(toAddress)
statusIconColor = 'red'
if (addressVersionNumber > 4) or (
addressVersionNumber <= 1):
print(
"addressVersionNumber > 4"
" or addressVersionNumber <= 1")
if streamNumber > 1 or streamNumber == 0:
print("streamNumber > 1 or streamNumber == 0")
if statusIconColor == 'red':
print("shared.statusIconColor == 'red'")
stealthLevel = BMConfigParser().safeGetInt(
'bitmessagesettings', 'ackstealthlevel')
from helper_ackPayload import genAckPayload
ackdata = genAckPayload(streamNumber, stealthLevel)
# t = ()
sqlExecute(
'''INSERT INTO sent VALUES
(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''',
'',
toAddress,
ripe,
fromAddress,
subject,
message,
ackdata,
int(time.time()),
int(time.time()),
0,
'msgqueued',
0,
'sent',
encoding,
BMConfigParser().safeGetInt(
'bitmessagesettings', 'ttl'))
state.check_sent_acc = fromAddress
# state.msg_counter_objs = self.parent.parent.parent.parent\
# .parent.parent.children[2].children[0].ids
if state.detailPageType == 'draft' \
and state.send_draft_mail:
state.draft_count = str(int(state.draft_count) - 1)
# state.msg_counter_objs.draft_cnt.badge_text = (
# state.draft_count)
state.detailPageType = ''
state.send_draft_mail = None
self.parent.parent.parent.ids.sc4.update_sent_messagelist()
allmailCnt_obj = state.kivyapp.root.ids.content_drawer.ids.allmail_cnt
allmailCnt_obj.ids.badge_txt.text = showLimitedCnt(int(state.all_count) + 1)
state.all_count = str(int(state.all_count) + 1)
Clock.schedule_once(self.callback_for_msgsend, 3)
queues.workerQueue.put(('sendmessage', toAddress))
print("sqlExecute successfully #######################")
state.in_composer = True
return
else: else:
msg = 'Enter a valid recipients address' from addresses import addBMIfNotPresent
elif not toAddress: # toAddress = addBMIfNotPresent(toAddress)
msg = 'Please fill the form completely' if (addressVersionNumber > 4) or (
addressVersionNumber <= 1):
print(
"addressVersionNumber > 4"
" or addressVersionNumber <= 1")
if streamNumber > 1 or streamNumber == 0:
print("streamNumber > 1 or streamNumber == 0")
stealthLevel = BMConfigParser().safeGetInt(
'bitmessagesettings', 'ackstealthlevel')
from helper_ackPayload import genAckPayload
# ackdata = genAckPayload(streamNumber, stealthLevel)
# t = ()
sqlExecute(
'''INSERT INTO sent VALUES
(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''',
'',
addBMIfNotPresent(toAddress),
ripe,
fromAddress,
subject,
message,
genAckPayload(streamNumber, stealthLevel), #ackdata
int(time.time()),
int(time.time()),
0,
'msgqueued',
0,
'sent',
3, #encoding
BMConfigParser().safeGetInt(
'bitmessagesettings', 'ttl'))
state.check_sent_acc = fromAddress
# state.msg_counter_objs = self.parent.parent.parent.parent\
# .parent.parent.children[2].children[0].ids
if state.detailPageType == 'draft' \
and state.send_draft_mail:
state.draft_count = str(int(state.draft_count) - 1)
# state.msg_counter_objs.draft_cnt.badge_text = (
# state.draft_count)
state.detailPageType = ''
state.send_draft_mail = None
self.parent.parent.parent.ids.sc4.update_sent_messagelist()
allmailCnt_obj = state.kivyapp.root.ids.content_drawer.ids.allmail_cnt
allmailCnt_obj.ids.badge_txt.text = showLimitedCnt(int(state.all_count) + 1)
state.all_count = str(int(state.all_count) + 1)
Clock.schedule_once(self.callback_for_msgsend, 3)
queues.workerQueue.put(('sendmessage', addBMIfNotPresent(toAddress)))
print("sqlExecute successfully #######################")
state.in_composer = True
return
else: else:
msg = 'Please fill the form completely' msg = 'Enter a valid recipients address'
self.address_error_message(msg) elif not toAddress:
msg = 'Please fill the form completely'
else:
msg = 'Please fill the form completely'
self.address_error_message(msg)
@staticmethod @staticmethod
def callback_for_msgsend(dt=0): # pylint: disable=unused-argument def callback_for_msgsend(dt=0): # pylint: disable=unused-argument
"""Callback method for messagesend""" """Callback method for messagesend"""
state.kivyapp.root.ids.sc3.children[0].active = False state.kivyapp.root.ids.sc3.children[0].active = False
state.in_sent_method = True state.in_sent_method = True
@ -259,7 +253,7 @@ class MyTextInput(TextInput):
super(MyTextInput, self).__init__(**kwargs) super(MyTextInput, self).__init__(**kwargs)
self.__lineBreak__ = 0 self.__lineBreak__ = 0
def on_text(self, instance, value): # pylint: disable=unused-argument def on_text(self, instance, value): # pylint: disable=unused-argument
"""Find all the occurrence of the word""" """Find all the occurrence of the word"""
self.parent.parent.parent.parent.parent.ids.rv.data = [] self.parent.parent.parent.parent.parent.ids.rv.data = []
matches = [self.word_list[i] for i in range( matches = [self.word_list[i] for i in range(

View File

@ -2,7 +2,7 @@ from bitmessagekivy.get_platform import platform
from functools import partial from functools import partial
from bmconfigparser import BMConfigParser from bmconfigparser import BMConfigParser
from kivy.clock import Clock from kivy.clock import Clock
from kivy.metrics import dp # from kivy.metrics import dp
from kivy.properties import ( from kivy.properties import (
ListProperty, ListProperty,
StringProperty StringProperty
@ -100,7 +100,7 @@ class MyAddress(Screen):
text=item['text'], secondary_text=item['secondary_text'], text=item['text'], secondary_text=item['secondary_text'],
theme_text_color='Custom' if is_enable == 'true' else 'Primary', theme_text_color='Custom' if is_enable == 'true' else 'Primary',
text_color=ThemeClsColor,) text_color=ThemeClsColor,)
meny._txt_right_pad = dp(70) # meny._txt_right_pad = dp(70)
try: try:
meny.canvas.children[3].rgba = [0, 0, 0, 0] if is_enable == 'true' else [0.5, 0.5, 0.5, 0.5] meny.canvas.children[3].rgba = [0, 0, 0, 0] if is_enable == 'true' else [0.5, 0.5, 0.5, 0.5]
except Exception: except Exception:
@ -191,7 +191,7 @@ class MyAddress(Screen):
self.ids.ml.clear_widgets() self.ids.ml.clear_widgets()
self.init_ui() self.init_ui()
self.ids.refresh_layout.refresh_done() self.ids.refresh_layout.refresh_done()
self.tick = 0 # self.tick = 0
Clock.schedule_once(self.address_permision_callback, 0) Clock.schedule_once(self.address_permision_callback, 0)
Clock.schedule_once(refresh_callback, 1) Clock.schedule_once(refresh_callback, 1)

View File

@ -4,6 +4,8 @@ from kivy.clock import Clock
from kivy.properties import StringProperty from kivy.properties import StringProperty
from kivy.uix.screenmanager import Screen from kivy.uix.screenmanager import Screen
from network import objectracker, stats
class NetworkStat(Screen): class NetworkStat(Screen):
"""NetworkStat class for kivy Ui""" """NetworkStat class for kivy Ui"""
@ -26,10 +28,8 @@ class NetworkStat(Screen):
def init_ui(self, dt=0): def init_ui(self, dt=0):
"""Clock Schdule for method networkstat screen""" """Clock Schdule for method networkstat screen"""
import network.stats
from network import objectracker
self.text_variable_1 = '{0} :: {1}'.format( self.text_variable_1 = '{0} :: {1}'.format(
'Total Connections', str(len(network.stats.connectedHostsList()))) 'Total Connections', str(len(stats.connectedHostsList())))
self.text_variable_2 = 'Processed {0} per-to-per messages'.format( self.text_variable_2 = 'Processed {0} per-to-per messages'.format(
str(state.numberOfMessagesProcessed)) str(state.numberOfMessagesProcessed))
self.text_variable_3 = 'Processed {0} brodcast messages'.format( self.text_variable_3 = 'Processed {0} brodcast messages'.format(

View File

@ -11,10 +11,10 @@ from kivymd.uix.list import (
OneLineAvatarIconListItem OneLineAvatarIconListItem
) )
from bmconfigparser import BMConfigParser # from bmconfigparser import BMConfigParser
from bitmessagekivy.baseclass.common import toast from bitmessagekivy.baseclass.common import toast
import queues # import queues
import state import state

View File

@ -203,7 +203,6 @@ class SenderDetailPopup(Popup):
device_type = 2 if platform == 'android' else 1.5 device_type = 2 if platform == 'android' else 1.5
pop_height = 1.2 * device_type * (self.ids.sd_label.height + self.ids.dismiss_btn.height) pop_height = 1.2 * device_type * (self.ids.sd_label.height + self.ids.dismiss_btn.height)
if len(to_addr) > 3: if len(to_addr) > 3:
self.height = 0
self.height = pop_height self.height = pop_height
self.ids.to_addId.size_hint_y = None self.ids.to_addId.size_hint_y = None
self.ids.to_addId.height = 50 self.ids.to_addId.height = 50
@ -215,7 +214,6 @@ class SenderDetailPopup(Popup):
self.ids.space_1.height = dp(0) self.ids.space_1.height = dp(0)
self.ids.space_2.height = dp(0) self.ids.space_2.height = dp(0)
self.ids.myadd_popup_box.spacing = dp(8 if platform == 'android' else 3) self.ids.myadd_popup_box.spacing = dp(8 if platform == 'android' else 3)
self.height = 0
self.height = pop_height / 1.2 self.height = pop_height / 1.2

View File

@ -26,7 +26,7 @@ class Trash(Screen):
trash_messages = ListProperty() trash_messages = ListProperty()
has_refreshed = True has_refreshed = True
# delete_index = StringProperty() delete_index = None
table_name = StringProperty() table_name = StringProperty()
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
@ -106,10 +106,8 @@ class Trash(Screen):
self.ids.ml.children) else False self.ids.ml.children) else False
def on_swipe_complete(self, instance, *args): def on_swipe_complete(self, instance, *args):
if instance.state == 'closed': """call on swipe left"""
instance.ids.delete_msg.disabled = True instance.ids.delete_msg.disabled = bool(instance.state == 'closed')
else:
instance.ids.delete_msg.disabled = False
def check_scroll_y(self, instance, somethingelse): def check_scroll_y(self, instance, somethingelse):
"""Load data on scroll""" """Load data on scroll"""

View File

@ -235,7 +235,8 @@ class NavigateApp(MDApp):
os.path.join( os.path.join(
os.path.dirname(__file__), os.path.dirname(__file__),
'kv', 'kv',
f'{all_data[kv]["kv_string"]}.kv', # f'{all_data[kv]["kv_string"]}.kv',
'{0}.kv'.format(all_data[kv]["kv_string"]),
) )
) )
# self.obj_1 = AddressBook() # self.obj_1 = AddressBook()
@ -957,7 +958,8 @@ class NavigateApp(MDApp):
add_obj.content_cls.ids.address.text = text add_obj.content_cls.ids.address.text = text
Clock.schedule_once(partial(self.open_popup, add_obj), .5) Clock.schedule_once(partial(self.open_popup, add_obj), .5)
def open_popup(self, instance, dt): @staticmethod
def open_popup(instance, dt):
"""This method is used for opening popup""" """This method is used for opening popup"""
instance.open() instance.open()