Fix flake8 issues
This commit is contained in:
parent
f98acd3ae0
commit
686967c36d
|
@ -43,7 +43,7 @@ BoxLayout:
|
|||
orientation: 'vertical'
|
||||
Toolbar:
|
||||
id: toolbar
|
||||
title: 'PyBitmessage'
|
||||
title: app.getCurrentAccount()
|
||||
background_color: app.theme_cls.primary_dark
|
||||
left_action_items: [['menu', lambda x: app.nav_drawer.toggle()]]
|
||||
Button:
|
||||
|
@ -51,7 +51,7 @@ BoxLayout:
|
|||
color: 0,0,0,1
|
||||
background_color: (0,0,0,0)
|
||||
size_hint_y: 0.4
|
||||
size_hint_x: 0.5
|
||||
size_hint_x: 0.1
|
||||
pos_hint: {'x': 0.8, 'y':0.4}
|
||||
on_press: app.say_exit()
|
||||
|
||||
|
|
|
@ -1,43 +1,41 @@
|
|||
import os
|
||||
import kivy_helper_search
|
||||
import os
|
||||
import queues
|
||||
import random
|
||||
import shutdown
|
||||
import time
|
||||
|
||||
from kivy.app import App
|
||||
from kivy.lang import Builder
|
||||
from kivy.uix.boxlayout import BoxLayout
|
||||
from kivy.properties import BooleanProperty
|
||||
from kivy.uix.button import Button
|
||||
from kivy.clock import Clock
|
||||
from kivy.uix.floatlayout import FloatLayout
|
||||
from kivy.uix.image import Image
|
||||
from kivy.uix.label import Label
|
||||
from kivy.uix.listview import ListItemButton
|
||||
from navigationdrawer import NavigationDrawer
|
||||
from kivy.properties import ObjectProperty, StringProperty, ListProperty, NumericProperty
|
||||
from kivy.properties import ObjectProperty, StringProperty, ListProperty
|
||||
from kivy.uix.screenmanager import Screen
|
||||
from kivy.uix.textinput import TextInput
|
||||
from kivymd.theming import ThemeManager
|
||||
from kivymd.toolbar import Toolbar
|
||||
from kivy.uix.widget import Widget
|
||||
from bmconfigparser import BMConfigParser
|
||||
from helper_ackPayload import genAckPayload
|
||||
from addresses import decodeAddress, addBMIfNotPresent
|
||||
from helper_sql import sqlExecute
|
||||
|
||||
statusIconColor = 'red'
|
||||
avatarlist = os.listdir("images/ngletteravatar")
|
||||
global belonging
|
||||
belonging = ''
|
||||
|
||||
|
||||
class NavigateApp(App, TextInput):
|
||||
"""Application uses kivy in which base Class of Navigate App inherits from the App class."""
|
||||
|
||||
theme_cls = ThemeManager()
|
||||
nav_drawer = ObjectProperty()
|
||||
|
||||
def build(self):
|
||||
"""Return a main_widget as a root widget.
|
||||
|
||||
An application can be built if you return a widget on build(), or if you set
|
||||
self.root.
|
||||
"""
|
||||
global main_widget
|
||||
main_widget = Builder.load_file(
|
||||
os.path.join(os.path.dirname(__file__), 'main.kv'))
|
||||
|
@ -45,6 +43,7 @@ class NavigateApp(App, TextInput):
|
|||
return main_widget
|
||||
|
||||
def getCurrentAccountData(self, text):
|
||||
"""Get Current Address Account Data."""
|
||||
global belonging
|
||||
belonging = text
|
||||
main_widget.ids.sc1.clear_widgets()
|
||||
|
@ -53,22 +52,27 @@ class NavigateApp(App, TextInput):
|
|||
main_widget.ids.sc1.add_widget(Inbox())
|
||||
main_widget.ids.sc2.add_widget(Sent())
|
||||
main_widget.ids.sc3.add_widget(Trash())
|
||||
main_widget.ids.toolbar.title = BMConfigParser().get(
|
||||
belonging, 'label') + '({})'.format(belonging)
|
||||
Inbox()
|
||||
Sent()
|
||||
Trash()
|
||||
|
||||
def say_exit(self):
|
||||
"""Exit the application as uses shutdown PyBitmessage."""
|
||||
print("**************************EXITING FROM APPLICATION*****************************")
|
||||
App.get_running_app().stop()
|
||||
shutdown.doCleanShutdown()
|
||||
|
||||
def showmeaddresses(self, name="text"):
|
||||
"""Show the addresses in spinner to make as dropdown."""
|
||||
if name == "text":
|
||||
return BMConfigParser().addresses()[0]
|
||||
elif name == "values":
|
||||
return BMConfigParser().addresses()
|
||||
|
||||
def update_index(self, data_index, index):
|
||||
"""Update index after archieve message to trash."""
|
||||
if self.root.ids.scr_mngr.current == 'inbox':
|
||||
self.root.ids.sc1.data[data_index]['index'] = index
|
||||
elif self.root.ids.scr_mngr.current == 'sent':
|
||||
|
@ -77,14 +81,17 @@ class NavigateApp(App, TextInput):
|
|||
self.root.ids.sc3.data[data_index]['index'] = index
|
||||
|
||||
def delete(self, data_index):
|
||||
"""It will make delete using remove function."""
|
||||
print("delete {}".format(data_index))
|
||||
self._remove(data_index)
|
||||
|
||||
def archive(self, data_index):
|
||||
"""It will make archieve using remove function."""
|
||||
print("archive {}".format(data_index))
|
||||
self._remove(data_index)
|
||||
|
||||
def _remove(self, data_index):
|
||||
"""It will remove message by resetting the values in recycleview data."""
|
||||
if self.root.ids.scr_mngr.current == 'inbox':
|
||||
self.root.ids.sc1.data.pop(data_index)
|
||||
self.root.ids.sc1.data = [{
|
||||
|
@ -114,19 +121,35 @@ class NavigateApp(App, TextInput):
|
|||
]
|
||||
|
||||
def getInboxMessageDetail(self, instance):
|
||||
"""It will get message detail after make selected message description."""
|
||||
try:
|
||||
self.root.ids.scr_mngr.current = 'page'
|
||||
except AttributeError:
|
||||
self.parent.manager.current = 'page'
|
||||
print('Message Clicked {}'.format(instance))
|
||||
|
||||
def getCurrentAccount(self):
|
||||
"""It uses to get current account label."""
|
||||
global belonging
|
||||
return BMConfigParser().get(belonging, 'label') + '({})'.format(belonging)
|
||||
|
||||
|
||||
class Navigator(NavigationDrawer):
|
||||
"""Navigator class uses NavigationDrawer.
|
||||
|
||||
It is an UI panel that shows our app's main navigation menu
|
||||
It is hidden when not in use, but appears when the user swipes
|
||||
a finger from the left edge of the screen or, when at the top
|
||||
level of the app, the user touches the drawer icon in the app bar
|
||||
"""
|
||||
|
||||
image_source = StringProperty('images/qidenticon_two.png')
|
||||
title = StringProperty('Navigation')
|
||||
|
||||
|
||||
class Inbox(Screen):
|
||||
"""Inbox Screen uses screen to show widgets of screens."""
|
||||
|
||||
data = ListProperty()
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
@ -148,7 +171,8 @@ class Inbox(Screen):
|
|||
|
||||
def loadMessagelist(self, account, folder, where="", what="", unreadOnly=False):
|
||||
xAddress = "toaddress"
|
||||
queryreturn = kivy_helper_search.search_sql(xAddress, account, folder, where, what, unreadOnly)
|
||||
queryreturn = kivy_helper_search.search_sql(
|
||||
xAddress, account, folder, where, what, unreadOnly)
|
||||
if queryreturn:
|
||||
self.data = [{
|
||||
'data_index': i,
|
||||
|
@ -175,6 +199,8 @@ class AddressSuccessful(Screen):
|
|||
|
||||
|
||||
class Sent(Screen):
|
||||
"""Sent Screen uses screen to show widgets of screens."""
|
||||
|
||||
data = ListProperty()
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
@ -196,7 +222,8 @@ class Sent(Screen):
|
|||
|
||||
def loadSent(self, account, where="", what=""):
|
||||
xAddress = 'fromaddress'
|
||||
queryreturn = kivy_helper_search.search_sql(xAddress, account, "sent", where, what, False)
|
||||
queryreturn = kivy_helper_search.search_sql(
|
||||
xAddress, account, "sent", where, what, False)
|
||||
if queryreturn:
|
||||
self.data = [{
|
||||
'data_index': i,
|
||||
|
@ -222,6 +249,8 @@ class Sent(Screen):
|
|||
|
||||
|
||||
class Trash(Screen):
|
||||
"""Trash Screen uses screen to show widgets of screens."""
|
||||
|
||||
data = ListProperty()
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
@ -243,7 +272,8 @@ class Trash(Screen):
|
|||
|
||||
def loadTrashlist(self, account, folder, where="", what="", unreadOnly=False):
|
||||
xAddress = "toaddress"
|
||||
queryreturn = kivy_helper_search.search_sql(xAddress, account, folder, where, what, unreadOnly)
|
||||
queryreturn = kivy_helper_search.search_sql(
|
||||
xAddress, account, folder, where, what, unreadOnly)
|
||||
if queryreturn:
|
||||
self.data = [{
|
||||
'data_index': i,
|
||||
|
@ -270,6 +300,7 @@ class Test(Screen):
|
|||
|
||||
|
||||
class Create(Screen):
|
||||
"""Create Screen uses screen to show widgets of screens."""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(Create, self).__init__(*args, **kwargs)
|
||||
|
@ -279,7 +310,7 @@ class Create(Screen):
|
|||
pass
|
||||
|
||||
def send(self):
|
||||
# toAddress = self.ids.recipent.text
|
||||
"""Send message from one address to another."""
|
||||
fromAddress = self.ids.spinner_id.text
|
||||
# For now we are using static address i.e we are not using recipent field value.
|
||||
toAddress = "BM-2cWyUfBdY2FbgyuCb7abFZ49JYxSzUhNFe"
|
||||
|
@ -332,6 +363,7 @@ class Create(Screen):
|
|||
return None
|
||||
|
||||
def cancel(self):
|
||||
"""Reset values for send message."""
|
||||
self.ids.message.text = ''
|
||||
self.ids.spinner_id.text = '<select>'
|
||||
self.ids.subject.text = ''
|
||||
|
@ -340,11 +372,14 @@ class Create(Screen):
|
|||
|
||||
|
||||
class NewIdentity(Screen):
|
||||
"""Create new address for PyBitmessage."""
|
||||
|
||||
is_active = BooleanProperty(False)
|
||||
checked = StringProperty("")
|
||||
# self.manager.parent.ids.create.children[0].source = 'images/plus-4-xxl.png'
|
||||
|
||||
def generateaddress(self):
|
||||
"""Generate new address."""
|
||||
if self.checked == 'use a random number generator to make an address':
|
||||
queues.apiAddressGeneratorReturnQueue.queue.clear()
|
||||
streamNumberForAddress = 1
|
||||
|
@ -352,10 +387,16 @@ class NewIdentity(Screen):
|
|||
eighteenByteRipe = False
|
||||
nonceTrialsPerByte = 1000
|
||||
payloadLengthExtraBytes = 1000
|
||||
|
||||
queues.addressGeneratorQueue.put((
|
||||
'createRandomAddress', 4, streamNumberForAddress, label, 1, "", eighteenByteRipe, nonceTrialsPerByte, payloadLengthExtraBytes)
|
||||
'createRandomAddress',
|
||||
4, streamNumberForAddress,
|
||||
label, 1, "", eighteenByteRipe,
|
||||
nonceTrialsPerByte,
|
||||
payloadLengthExtraBytes)
|
||||
)
|
||||
self.manager.current = 'add_sucess'
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
NavigateApp().run()
|
||||
|
|
Loading…
Reference in New Issue
Block a user