Merge pull request #23 from cis-navjot-g/codequalitykivy

mpybit flake8 fix
This commit is contained in:
lakshyacis 2019-09-10 14:32:06 +05:30 committed by GitHub
commit 163ef2d715
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,11 +1,8 @@
"""Coding: utf-8."""
import time
from functools import partial
from bmconfigparser import BMConfigParser
from helper_sql import sqlExecute, sqlQuery
from kivy.app import App
from kivy.clock import Clock
from kivy.core.window import Window
@ -33,9 +30,7 @@ from kivy.uix.screenmanager import Screen
from kivy.uix.spinner import Spinner
from kivy.uix.textinput import TextInput
from kivy.utils import platform
import kivy_helper_search
from kivymd.button import MDIconButton
from kivymd.dialog import MDDialog
from kivymd.label import MDLabel
@ -52,23 +47,14 @@ from kivymd.navigationdrawer import (
from kivymd.selectioncontrols import MDCheckbox
from kivymd.textfields import MDTextField
from kivymd.theming import ThemeManager
import queues
from semaphores import kivyuisignaler
import state
from uikivysignaler import UIkivySignaler
import identiconGeneration
import os
from kivy.core.clipboard import Clipboard
# pylint: disable=unused-argument
# pylint: disable=broad-except
# pylint: disable=unused-argument, too-few-public-methods
def toast(text):
@ -82,7 +68,6 @@ def toast(text):
class Navigatorss(MDNavigationDrawer):
"""Navigators class contains image, title and logo."""
# pylint: disable=too-few-public-methods
image_source = StringProperty('images/qidenticon_two.png')
title = StringProperty('Navigation')
drawer_logo = StringProperty()
@ -126,7 +111,9 @@ class Inbox(Screen):
third_text = mail[3].replace('\n', ' ')
data.append({
'text': mail[4].strip(),
'secondary_text': mail[5][:50] + '........' if len(mail[5]) >= 50 else (mail[5] + ',' + mail[3].replace('\n', ''))[0:50] + '........',
'secondary_text': mail[5][:50] + '........' if len(
mail[5]) >= 50 else (
mail[5] + ',' + mail[3].replace('\n', ''))[0:50] + '........',
'receivedTime': mail[6]})
for item in data:
meny = ThreeLineAvatarIconListItem(
@ -138,7 +125,8 @@ class Inbox(Screen):
# item['secondary_text'][0].upper() >= 'A' and item[
# 'secondary_text'][0].upper() <= 'Z') else '!'
meny.add_widget(AvatarSampleWidget(
source='./images/text_images/{}.png'.format(avatarImageFirstLetter(item['secondary_text'].strip()))))
source='./images/text_images/{}.png'.format(
avatarImageFirstLetter(item['secondary_text'].strip()))))
meny.bind(on_press=partial(
self.inbox_detail, item['receivedTime']))
carousel = Carousel(direction='right')
@ -255,9 +243,11 @@ class MyAddress(Screen):
def init_ui(self, dt=0):
"""Clock Schdule for method inbox accounts."""
# pylint: disable=unnecessary-lambda, deprecated-lambda
addresses_list = state.kivyapp.variable_1
if state.searcing_text:
filtered_list = filter(lambda addr: self.filter_address(
filtered_list = filter(
lambda addr: self.filter_address(
addr), BMConfigParser().addresses())
addresses_list = filtered_list
if addresses_list:
@ -321,6 +311,7 @@ class MyAddress(Screen):
@staticmethod
def filter_address(address):
"""Method will filter the my address list data."""
# pylint: disable=deprecated-lambda
if filter(lambda x: (state.searcing_text).lower() in x, [
BMConfigParser().get(
address, 'label').lower(), address.lower()]):
@ -413,7 +404,6 @@ class SelectableRecycleBoxLayout(FocusBehavior, LayoutSelectionBehavior,
RecycleBoxLayout):
"""Adds selection and focus behaviour to the view."""
# pylint: disable=too-few-public-methods
pass
@ -450,8 +440,7 @@ class SelectableLabel(RecycleDataViewBehavior, Label):
class RV(RecycleView):
"""Recycling View."""
# pylint: disable=too-few-public-methods
def __init__(self, **kwargs):
def __init__(self, **kwargs): # pylint: disable=useless-super-delegation
"""Recycling Method."""
super(RV, self).__init__(**kwargs)
@ -462,7 +451,7 @@ class DropDownWidget(BoxLayout):
txt_input = ObjectProperty()
rv = ObjectProperty()
def send(self, navApp):
def send(self, navApp): # pylint: disable=too-many-statements, inconsistent-return-statements
"""Send message from one address to another."""
# pylint: disable=too-many-locals
fromAddress = str(self.ids.ti.text)
@ -601,7 +590,7 @@ class MyTextInput(TextInput):
starting_no = NumericProperty(3)
suggestion_text = ''
def __init__(self, **kwargs):
def __init__(self, **kwargs): # pylint: disable=useless-super-delegation
"""Getting Text Input."""
super(MyTextInput, self).__init__(**kwargs)
@ -632,21 +621,18 @@ class MyTextInput(TextInput):
class Payment(Screen):
"""Payment Method."""
# pylint: disable=too-few-public-methods
pass
class Login(Screen):
"""Login Screeen."""
# pylint: disable=too-few-public-methods
pass
class NetworkStat(Screen):
"""Method used to show network stat."""
# pylint: disable=too-few-public-methods
text_variable_1 = StringProperty(
'{0}::{1}'.format('Total Connections', '0'))
text_variable_2 = StringProperty(
@ -682,14 +668,12 @@ class NetworkStat(Screen):
class ContentNavigationDrawer(Navigatorss):
"""Navigate Content Drawer."""
# pylint: disable=too-few-public-methods
pass
class Random(Screen):
"""Generates Random Address."""
# pylint: disable=too-few-public-methods
is_active = BooleanProperty(False)
checked = StringProperty("")
@ -720,7 +704,6 @@ class Random(Screen):
class AddressSuccessful(Screen):
"""Getting Address Detail."""
# pylint: disable=too-few-public-methods
pass
@ -767,7 +750,9 @@ class Sent(Screen):
for mail in queryreturn:
self.data.append({
'text': mail[1].strip(),
'secondary_text': mail[2][:50] + '........' if len(mail[2]) >= 50 else (mail[2] + ',' + mail[3].replace('\n', ''))[0:50] + '........',
'secondary_text': mail[2][:50] + '........' if len(
mail[2]) >= 50 else (
mail[2] + ',' + mail[3].replace('\n', ''))[0:50] + '........',
'lastactiontime': mail[6]})
for item in self.data:
meny = ThreeLineAvatarIconListItem(
@ -776,7 +761,8 @@ class Sent(Screen):
theme_text_color='Custom',
text_color=NavigateApp().theme_cls.primary_color)
meny.add_widget(AvatarSampleWidget(
source='./images/text_images/{}.png'.format(avatarImageFirstLetter(item['secondary_text'].strip()))))
source='./images/text_images/{}.png'.format(
avatarImageFirstLetter(item['secondary_text'].strip()))))
meny.bind(on_press=partial(
self.sent_detail, item['lastactiontime']))
carousel = Carousel(direction='right')
@ -877,8 +863,6 @@ class Sent(Screen):
class Trash(Screen):
"""Trash Screen uses screen to show widgets of screens."""
# pylint: disable=too-few-public-methods
def __init__(self, *args, **kwargs):
"""Trash method, delete sent message and add in Trash."""
super(Trash, self).__init__(*args, **kwargs)
@ -904,7 +888,9 @@ class Trash(Screen):
for item in trash_data:
meny = ThreeLineAvatarIconListItem(
text=item[1],
secondary_text=item[2][:50] + '........' if len(item[2]) >= 50 else (item[2] + ',' + item[3].replace('\n', ''))[0:50] + '........',
secondary_text=item[2][:50] + '........' if len(
item[2]) >= 50 else (
item[2] + ',' + item[3].replace('\n', ''))[0:50] + '........',
theme_text_color='Custom',
text_color=NavigateApp().theme_cls.primary_color)
img_latter = './images/text_images/{}.png'.format(
@ -948,15 +934,12 @@ class Trash(Screen):
class Page(Screen):
"""Page Screen show widgets of page."""
# pylint: disable=too-few-public-methods
pass
class Create(Screen):
"""Creates the screen widgets."""
# pylint: disable=too-few-public-methods
def __init__(self, **kwargs):
"""Getting Labels and address from addressbook."""
super(Create, self).__init__(**kwargs)
@ -971,11 +954,10 @@ class Create(Screen):
class Setting(Screen):
"""Setting the Screen components."""
# pylint: disable=too-few-public-methods
pass
class NavigateApp(App):
class NavigateApp(App): # pylint: disable=too-many-public-methods
"""Navigation Layout of class."""
theme_cls = ThemeManager()
@ -1103,15 +1085,18 @@ class NavigateApp(App):
return BMConfigParser().addresses()[0]
return 'Select Address'
def createFolder(self, directory):
@staticmethod
def createFolder(directory):
"""This method is used to create the directory when app starts"""
try:
if not os.path.exists(directory):
os.makedirs(directory)
except OSError:
print ('Error: Creating directory. ' + directory)
print 'Error: Creating directory. ' + directory
def get_default_image(self):
@staticmethod
def get_default_image():
"""Getting default image on address"""
if BMConfigParser().addresses():
# BMConfigParser().addresses()[0]
return './images/default_identicon/{}.png'.format(BMConfigParser().addresses()[0])
@ -1308,7 +1293,9 @@ class NavigateApp(App):
img.x = 5
self.root.children[2].children[0].ids.btn.add_widget(img)
def address_identicon(self):
@staticmethod
def address_identicon():
"""Address identicon"""
return './images/drawer_logo1.png'
@ -1373,6 +1360,7 @@ class GrashofPopup(Popup):
toast('Canceled')
def checkAddress_valid(self, instance):
"""Checking is address is valid or not"""
my_addresses = self.parent.children[1].children[2].children[0].ids.btn.values
add_book = [addr[1] for addr in kivy_helper_search.search_sql(
folder="addressbook")]
@ -1400,21 +1388,18 @@ class GrashofPopup(Popup):
class AvatarSampleWidget(ILeftBody, Image):
"""Avatar Sample Widget."""
# pylint: disable=too-few-public-methods
pass
class IconLeftSampleWidget(ILeftBodyTouch, MDIconButton):
"""Left icon sample widget."""
# pylint: disable=too-few-public-methods
pass
class IconRightSampleWidget(IRightBodyTouch, MDCheckbox):
"""Right icon sample widget."""
# pylint: disable=too-few-public-methods
pass
@ -1552,7 +1537,8 @@ class MailDetail(Screen):
self.parent.parent.current = 'create'
navApp.set_navbar_for_composer()
def copy_composer_text(self, instance, *args):
@staticmethod
def copy_composer_text(instance, *args):
"""This method is used for copying the data from mail detail page"""
if len(instance.parent.text.split(':')) > 1:
cpy_text = instance.parent.text.split(':')[1].strip()
@ -1651,8 +1637,6 @@ class AddbookDetailPopup(Popup):
class ShowQRCode(Screen):
"""ShowQRCode Screen uses to show the detail of mails."""
# pylint: disable=too-few-public-methods
def qrdisplay(self):
"""Method used for showing QR Code."""
self.manager.parent.parent.parent.ids.search_bar.clear_widgets()
@ -1836,8 +1820,6 @@ class Draft(Screen):
class CustomSpinner(Spinner):
"""This class is used for setting spinner size."""
# pylint: disable=too-few-public-methods
def __init__(self, *args, **kwargs):
"""Method used for setting size of spinner."""
super(CustomSpinner, self).__init__(*args, **kwargs)
@ -1893,11 +1875,14 @@ class Allmails(Screen):
for item in all_mails:
meny = ThreeLineAvatarIconListItem(
text=item[1],
secondary_text=item[2][:50] + '........' if len(item[2]) >= 50 else (item[2] + ',' + item[3].replace('\n', ''))[0:50] + '........',
secondary_text=item[2][:50] + '........' if len(
item[2]) >= 50 else (
item[2] + ',' + item[3].replace('\n', ''))[0:50] + '........',
theme_text_color='Custom',
text_color=NavigateApp().theme_cls.primary_color)
meny.add_widget(AvatarSampleWidget(
source='./images/text_images/{}.png'.format(avatarImageFirstLetter(item[2].strip()))))
source='./images/text_images/{}.png'.format(
avatarImageFirstLetter(item[2].strip()))))
meny.bind(on_press=partial(
self.mail_detail, item[5], item[4]))
carousel = Carousel(direction='right')