fixed flake8 CQ fixed for mpybit, language_script and some other modules

This commit is contained in:
navjot 2020-11-26 19:53:27 +05:30
parent 67292f2ea0
commit 5be08babf5
No known key found for this signature in database
GPG Key ID: 9EE70AFD71357F1C
8 changed files with 67 additions and 62 deletions

View File

@ -46,4 +46,4 @@ if platform not in ("android", "unknown"):
Other camera provider such as `gi` has some issue upon closing the camera.
by setting KIVY_CAMERA environment variable before importing kivy, we are forcing it to use opencv camera provider.
"""
environ["KIVY_CAMERA"] = "opencv"
environ["KIVY_CAMERA"] = "opencv"

View File

@ -41,29 +41,29 @@ windowsLanguageMap = {
'zh': 'Chinese',
}
current_dir_path = os.path.abspath(os.path.join(__file__ , '../'))
current_dir_path = os.path.abspath(os.path.join(__file__, '../'))
main_file = os.path.join(current_dir_path, 'mpybit.py')
kv_file = os.path.join(current_dir_path, 'main.kv')
print("Create .po files for Project")
translation_command = [
'xgettext',
'-Lpython',
'--output=messages.pot',
'--from-code=UTF-8',
main_file,
'xgettext',
'-Lpython',
'--output=messages.pot',
'--from-code=UTF-8',
main_file,
kv_file
]
for kv_file in KVFILES:
translation_command.append(f'{current_dir_path}/kv/{kv_file}.kv')
translation_command.append(f'{current_dir_path}/kv/{kv_file}.kv')
print('translation_command..............', translation_command)
# print('translation_command..............', translation_command)
subprocess.run(translation_command, stdout=subprocess.DEVNULL)
# print("The exit code1 was: %d" % list_files.returncode)
#this command is used to create seperate dir for mo and po file
# this command is used to create seperate dir for mo and po file
subprocess.run(
['mkdir', '-p', 'translations/po'], stdout=subprocess.DEVNULL)
@ -72,19 +72,23 @@ for key in windowsLanguageMap.keys():
subprocess.run(
['touch', f'{current_dir_path}/translations/po/bitmessage_{key}.po'], stdout=subprocess.DEVNULL)
subprocess.run(
['msgmerge', '--update', '--no-fuzzy-matching', '--backup=off',
f'{current_dir_path}/translations/po/bitmessage_{key}.po', f'{current_dir_path}/messages.pot'],
stdout=subprocess.DEVNULL)
['msgmerge', '--update', '--no-fuzzy-matching', '--backup=off',
f'{current_dir_path}/translations/po/bitmessage_{key}.po', f'{current_dir_path}/messages.pot'],
stdout=subprocess.DEVNULL
)
print("Create .mo file from .po file")
for key in windowsLanguageMap.keys():
subprocess.run(
['mkdir', '-p', f'{current_dir_path}/translations/mo/locales/{key}/LC_MESSAGES'],
stdout=subprocess.DEVNULL)
['mkdir', '-p', f'{current_dir_path}/translations/mo/locales/{key}/LC_MESSAGES'],
stdout=subprocess.DEVNULL
)
subprocess.run(
['touch', f'{current_dir_path}/translations/mo/locales/{key}/LC_MESSAGES/langapp.mo'],
stdout=subprocess.DEVNULL)
['touch', f'{current_dir_path}/translations/mo/locales/{key}/LC_MESSAGES/langapp.mo'],
stdout=subprocess.DEVNULL
)
subprocess.run(
['msgfmt', '-c', '-o', f'{current_dir_path}/translations/mo/locales/{key}/LC_MESSAGES/langapp.mo',
f'{current_dir_path}/translations/po/bitmessage_{key}.po'], stdout=subprocess.DEVNULL)
['msgfmt', '-c', '-o', f'{current_dir_path}/translations/mo/locales/{key}/LC_MESSAGES/langapp.mo',
f'{current_dir_path}/translations/po/bitmessage_{key}.po'], stdout=subprocess.DEVNULL
)

View File

@ -312,7 +312,6 @@ class Inbox(Screen):
int(state.sent_count) + int(state.inbox_count))
src_mng_obj.allmail_cnt.ids.badge_txt.text = showLimitedCnt(int(state.all_count))
def inboxDataQuery(self, xAddress, where, what, start_indx=0, end_indx=20):
"""This method is used for retrieving inbox data"""
self.queryreturn = kivy_helper_search.search_sql(
@ -537,7 +536,7 @@ class MyAddress(Screen):
except Exception:
meny.canvas.children[9].rgba = [0, 0, 0, 0] if is_enable == 'true' else [0.5, 0.5, 0.5, 0.5]
meny.add_widget(AvatarSampleWidget(
source= state.imageDir + '/text_images/{}.png'.format(
source=state.imageDir + '/text_images/{}.png'.format(
avatarImageFirstLetter(item['text'].strip()))))
meny.bind(on_press=partial(
self.myadd_detail, item['secondary_text'], item['text']))
@ -578,7 +577,7 @@ class MyAddress(Screen):
if BMConfigParser().get(fromaddress, 'enabled') == 'true':
obj = MyaddDetailPopup()
self.address_label = obj.address_label = label
self.text_address = obj.address =fromaddress
self.text_address = obj.address = fromaddress
width = .9 if platform == 'android' else .8
self.myadddetail_popup = MDDialog(
type="custom",
@ -591,14 +590,15 @@ class MyAddress(Screen):
# p.set_address(fromaddress, label)
else:
width = .8 if platform == 'android' else .55
dialog_box=MDDialog(
text='Address is not currently active. Please click on Toggle button to active it.',
size_hint=(width, .25),
buttons=[
MDFlatButton(
text="Ok", on_release=lambda x: callback_for_menu_items("Ok")
),
],)
dialog_box = MDDialog(
text='Address is not currently active. Please click on Toggle button to active it.',
size_hint=(width, .25),
buttons=[
MDFlatButton(
text="Ok", on_release=lambda x: callback_for_menu_items("Ok")
),
],
)
dialog_box.open()
def callback_for_menu_items(text_item, *arg):
@ -788,7 +788,7 @@ class AddressBook(Screen):
buttons=[
MDRaisedButton(
text="Send message to",
text_color=state.kivyapp.theme_cls.primary_color,
text_color=state.kivyapp.theme_cls.primary_color,
on_release=self.send_message_to,
),
MDRaisedButton(
@ -1014,7 +1014,7 @@ class DropDownWidget(BoxLayout):
def address_error_message(self, msg):
"""Generates error message"""
width = .8 if platform == 'android' else .55
dialog_box=MDDialog(
dialog_box = MDDialog(
text=msg,
size_hint=(width, .25),
buttons=[
@ -1029,7 +1029,6 @@ class DropDownWidget(BoxLayout):
dialog_box.dismiss()
toast(text_item)
# @staticmethod
# def callback_for_menu_items(text_item, *arg):
# """Callback of alert box"""
@ -1061,14 +1060,15 @@ class DropDownWidget(BoxLayout):
def camera_alert(self):
width = .8 if platform == 'android' else .55
altet_txt = 'Currently this feature is not avaialbe!'if platform == 'android' else 'Camera is not available!'
dialog_box=MDDialog(
text=altet_txt,
size_hint=(width, .25),
buttons=[
MDFlatButton(
text="Ok", on_release=lambda x: callback_for_menu_items("Ok")
),
],)
dialog_box = MDDialog(
text=altet_txt,
size_hint=(width, .25),
buttons=[
MDFlatButton(
text="Ok", on_release=lambda x: callback_for_menu_items("Ok")
),
],
)
dialog_box.open()
def callback_for_menu_items(text_item, *arg):
@ -1340,8 +1340,8 @@ class Random(Screen):
entered_label = str(self.ids.add_random_bx.children[0].ids.lab.text).strip()
if not entered_label:
self.ids.add_random_bx.children[0].ids.lab.focus = True
#self.ids.lab.error = True
#self.ids.lab.helper_text = 'This field is required'
# self.ids.lab.error = True
# self.ids.lab.helper_text = 'This field is required'
streamNumberForAddress = 1
eighteenByteRipe = False
nonceTrialsPerByte = 1000
@ -1697,7 +1697,7 @@ class Trash(Screen):
theme_text_color='Custom',
text_color=ThemeClsColor)
meny._txt_right_pad = dp(70)
img_latter =state.imageDir + '/text_images/{}.png'.format(
img_latter = state.imageDir + '/text_images/{}.png'.format(
subject[0].upper() if (subject[0].upper() >= 'A' and subject[0].upper() <= 'Z') else '!')
meny.add_widget(AvatarSampleWidget(source=img_latter))
meny.add_widget(AddTimeWidget(item[7]))
@ -1750,7 +1750,7 @@ class Trash(Screen):
def delete_confirmation(self):
"""Show confirmation delete popup"""
width = .8 if platform == 'android' else .55
dialog_box=MDDialog(
dialog_box = MDDialog(
text='Are you sure you want to delete this'
' message permanently from trash?',
size_hint=(width, .25),
@ -1759,7 +1759,7 @@ class Trash(Screen):
text="Yes", on_release=lambda x: callback_for_delete_msg("Yes")
),
MDFlatButton(
text="No",on_release=lambda x: callback_for_delete_msg("No"),
text="No", on_release=lambda x: callback_for_delete_msg("No"),
),
],)
dialog_box.open()
@ -1893,7 +1893,7 @@ class Setting(Screen):
)
def set_caller(self):
self.menu.caller= self.ids.drop_item
self.menu.caller = self.ids.drop_item
# self.menu.use_icon_item = False
self.menu.target_height = 250
@ -1903,7 +1903,7 @@ class Setting(Screen):
def change_language(self):
lang = self.ids.drop_item.current_item
for k,v in self.languages.items():
for k, v in self.languages.items():
if v == lang:
BMConfigParser().set('bitmessagesettings', 'userlocale', k)
BMConfigParser().save()
@ -1935,10 +1935,10 @@ class NavigateApp(MDApp):
count = 0
manager_open = False
file_manager = None
#state.imageDir = os.path.join(os.path.abspath(os.path.join(__file__ ,"../../..")),'images', 'kivy')
# state.imageDir = os.path.join(os.path.abspath(os.path.join(__file__ ,"../../..")),'images', 'kivy')
state.imageDir = os.path.join('./images', 'kivy')
image_path = state.imageDir
tr = Lang("en") # for changing in franch replace en with fr
tr = Lang("en") # for changing in franch replace en with fr
def build(self):
"""Method builds the widget"""
@ -2038,7 +2038,7 @@ class NavigateApp(MDApp):
buttons=[
MDRaisedButton(
text="Save",
text_color=self.theme_cls.primary_color,
text_color=self.theme_cls.primary_color,
on_release=self.savecontact,
),
MDRaisedButton(
@ -2644,6 +2644,7 @@ class NavigateApp(MDApp):
"""This method is used for opening popup"""
instance.open()
class GrashofPopup(BoxLayout):
"""Moule for save contacts and error messages"""
@ -2710,7 +2711,7 @@ class GrashofPopup(BoxLayout):
text = (
"The address is not typed or copied correctly"
# " (the checksum failed)."
)
)
elif status == 'versiontoohigh':
text = (
"The version number of this address is higher than this"
@ -3273,7 +3274,7 @@ class Allmails(Screen):
text_color=ThemeClsColor)
meny._txt_right_pad = dp(70)
meny.add_widget(AvatarSampleWidget(
source= state.imageDir +'/text_images/{}.png'.format(
source=state.imageDir + '/text_images/{}.png'.format(
avatarImageFirstLetter(body.strip()))))
meny.bind(on_press=partial(
self.mail_detail, item[5], item[4]))
@ -3554,7 +3555,7 @@ class OneLineListTitle(OneLineListItem):
"""this method is for displaying dialog box"""
self.title_text = title_text
width = .8 if platform == 'android' else .55
self.dialog_box=MDDialog(
self.dialog_box = MDDialog(
text=title_text,
size_hint=(width, .25),
buttons=[
@ -3562,7 +3563,7 @@ class OneLineListTitle(OneLineListItem):
text="Copy", on_release=self.callback_for_copy_title
),
MDFlatButton(
text="Cancel",on_release=self.callback_for_copy_title,
text="Cancel", on_release=self.callback_for_copy_title,
),
],)
self.dialog_box.open()
@ -3655,7 +3656,7 @@ class ChatList(Screen):
text=item[0], secondary_text=item[1], theme_text_color='Custom',
text_color=ThemeClsColor)
meny.add_widget(AvatarSampleWidget(
source= state.imageDir + '/text_images/{}.png'.format(
source=state.imageDir + '/text_images/{}.png'.format(
avatarImageFirstLetter(item[0].strip()))))
meny.bind(on_release=partial(
self.redirect_to_chat, item[0], item[1]))

View File

@ -53,7 +53,6 @@ sys.path.insert(0, app_dir)
depends.check_dependencies()
def _fixSocket():
if sys.platform.startswith('linux'):
socket.SO_BINDTODEVICE = 25

View File

@ -126,11 +126,13 @@ class BMConfigParser(configparser.ConfigParser):
def addresses(self, hidden=False):
"""Return a list of local bitmessage addresses (from section labels)"""
return [x for x in BMConfigParser().sections() if x.startswith('BM-') and (hidden or not BMConfigParser().safeGetBoolean(x, 'hidden'))]
return [x for x in BMConfigParser().sections() if x.startswith('BM-') and (
hidden or not BMConfigParser().safeGetBoolean(x, 'hidden'))]
def paymentaddress(self):
"""Return a list of local payment addresses (from section labels)"""
return ''.join([x for x in BMConfigParser().sections() if x.startswith('BM-') and BMConfigParser().safeGetBoolean(x, 'payment')])
return ''.join([x for x in BMConfigParser().sections() if x.startswith(
'BM-') and BMConfigParser().safeGetBoolean(x, 'payment')])
def read(self, filenames):
configparser.ConfigParser.read(self, filenames)

View File

@ -79,7 +79,6 @@ def search_sql(
return sqlQuery(sqlStatementBase, sqlArguments)
def check_match(
toAddress, fromAddress, subject, message, where=None, what=None):
"""

View File

@ -5,4 +5,4 @@ if __name__ == '__main__':
state.kivy = True
print("Kivy Loading......")
from bitmessagemain import main
main()
main()

View File

@ -39,7 +39,7 @@ class Image(qrcode.image.base.BaseImage): # pylint: disable=abstract-method
QtCore.Qt.black)
class QRCodeDialog(QtGui.QDialog):
class QRCodeDialog(QtGui.QDialog):
"""The dialog"""
def __init__(self, parent):
super(QRCodeDialog, self).__init__(parent)