Kivy mock moved to src/mock dir and changed symlink

This commit is contained in:
shekhar-cis 2022-07-27 15:58:25 +05:30
parent 2f6c017420
commit 90959d8ca7
Signed by untrusted user: shekhar-cis
GPG Key ID: F4F00AB04E83F9A7
39 changed files with 227 additions and 305 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -0,0 +1,149 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="793.70081"
height="1122.5197"
id="svg2"
version="1.1"
inkscape:version="0.92.1 r"
sodipodi:docname="can-icon.svg">
<defs
id="defs4" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.70710678"
inkscape:cx="334.69166"
inkscape:cy="669.88172"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="1301"
inkscape:window-height="744"
inkscape:window-x="65"
inkscape:window-y="24"
inkscape:window-maximized="1"
showguides="true"
inkscape:guide-bbox="true" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<g
id="g3096"
transform="translate(10.559462,156.88343)">
<path
style="fill:#e6e6e6;fill-rule:evenodd;stroke:#241c1c;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;fill-opacity:1"
d="M 55.39264,532.81707 342.36431,41.508115 C 438.76759,-31.483548 745.9833,178.54104 718.72589,265.9098 L 453.97326,771.38082 C 513.19721,665.35571 140.41673,439.89351 55.39264,532.81707 Z"
id="path2391"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccc"
inkscape:export-xdpi="4.57552"
inkscape:export-ydpi="4.57552" />
<path
inkscape:connector-curvature="0"
id="path3111"
d="M 395.54691,28.063323 112.5256,508.60245"
style="fill:#808080;stroke:#000000;stroke-width:1.64679658px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.11949684"
inkscape:export-xdpi="4.57552"
inkscape:export-ydpi="4.57552" />
<path
inkscape:connector-curvature="0"
id="path2997"
d="M 193.26809,521.672 466.89638,43.16174"
style="fill:none;stroke:#000000;stroke-width:1.65778315px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.06918239"
inkscape:export-xdpi="4.57552"
inkscape:export-ydpi="4.57552" />
<path
inkscape:connector-curvature="0"
id="path3777"
d="M 283.66518,559.54595 549.75376,77.722668"
style="fill:#b3b3b3;stroke:#000000;stroke-width:1.65072334px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.07547171"
inkscape:export-xdpi="4.57552"
inkscape:export-ydpi="4.57552" />
<path
inkscape:connector-curvature="0"
id="path3787"
d="M 442.34039,696.99151 701.70079,210.05539"
style="fill:none;stroke:#000000;stroke-width:1.65072334px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.21383649"
inkscape:export-xdpi="4.57552"
inkscape:export-ydpi="4.57552" />
<path
style="fill:#e6e6e6;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 393.66782,26.589965 c -19.64834,0.192 -36.82244,4.5488 -50.17969,14.0606 L 55.837742,532.19937 c 12.78728,-13.4059 31.76749,-19.932 54.652348,-20.9707 L 395.86118,26.595865 c -0.73275,-0.0042 -1.46728,-0.013 -2.19336,-0.0059 z"
id="path2391-6"
inkscape:connector-curvature="0"
inkscape:export-xdpi="4.57552"
inkscape:export-ydpi="4.57552" />
<path
style="fill:#ececec;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 395.86314,26.595875 110.49009,511.22867 c 23.70053,-1.076 51.57709,3.7251 81.08008,12.8555 L 467.65416,40.365375 c -25.63117,-8.6186 -50.14818,-13.6453 -71.79102,-13.7695 z"
id="path2391-9"
inkscape:connector-curvature="0"
inkscape:export-xdpi="4.57552"
inkscape:export-ydpi="4.57552" />
<path
style="fill:#e6e6e6;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 467.65416,40.363375 191.57017,524.08417 c 29.57345,9.1522 60.77051,22.6569 91.02735,38.9335 L 549.75181,77.724775 c -27.23349,-15.3782 -55.27046,-28.3405 -82.09765,-37.3614 z"
id="path2391-2"
inkscape:connector-curvature="0"
inkscape:export-xdpi="4.57552"
inkscape:export-ydpi="4.57552" />
<path
style="fill:#e6e6e6;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 549.75376,77.722668 282.59752,563.01767 c 47.65328,25.635 92.95914,58.1483 125.85154,91.4453 l 262.54485,-485.375 c -31.6082,-32.5347 -75.25565,-65.3989 -121.24015,-91.365302 z"
id="path2391-0"
inkscape:connector-curvature="0"
inkscape:export-xdpi="4.57552"
inkscape:export-ydpi="4.57552" />
<path
style="fill:#cccccc;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 670.99391,169.08797 -262.5469,485.375 c 13.9989,14.1711 25.7445,28.479 34.4707,42.457 l 260.3145,-488.3418 c -8.2409,-12.7677 -19.2291,-26.0995 -32.2383,-39.4902 z"
id="path2391-36"
inkscape:connector-curvature="0"
inkscape:export-xdpi="4.57552"
inkscape:export-ydpi="4.57552" />
<path
style="fill:#b3b3b3;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 703.23221,208.57817 442.91971,696.9219 c 14.5278,23.2712 20.6735,45.6196 14.8555,64.8692 l 260.8496,-496.57623 c 4.4659,-15.7747 -1.7012,-35.4253 -15.3926,-56.6367 z"
id="path2391-62"
inkscape:connector-curvature="0"
inkscape:export-xdpi="4.57552"
inkscape:export-ydpi="4.57552" />
<ellipse
transform="matrix(0.85942572,0.51126062,-0.48882326,0.87238284,0,0)"
id="path2992"
style="fill:#000000;stroke-width:1.6510005"
cx="541.95758"
cy="429.53775"
rx="232.96017"
ry="92.650627"
inkscape:export-xdpi="4.57552"
inkscape:export-ydpi="4.57552" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 7.2 KiB

6
keys.dat Normal file
View File

@ -0,0 +1,6 @@
[BM-2cUgQGcTLWAkC6dNsv2Bc8XB3Y1GEesVLV]
label = sad
enabled = true
privsigningkey = 5KWXwYq1oJMzghUSJaJoWPn8VdeBbhDN8zFot1cBd6ezKKReqBd
privencryptionkey = 5JaeFJs8iPcQT3N8676r3gHKvJ5mTWXy1VLhGCEDqRs4vpvpxV8

View File

@ -216,8 +216,52 @@ MDNavigationLayout:
id: scr_mngr
size_hint_y: None
height: root.height - toolbar.height
# Inbox:
# id:sc1
# # Page:
# # id:sc2
# Create:
# id:sc3
# Sent:
# id:sc4
# Trash:
# id:sc5
Login:
id:sc6
Random:
id:sc7
# Spam:
# id:sc8
# Setting:
# id:sc9
MyAddress:
id:sc10
# AddressBook:
# id:sc11
# Payment:
# id:sc12
NetworkStat:
id:sc13
# MailDetail:
# id:sc14
ShowQRCode:
id:sc15
Draft:
id:sc16
Allmails:
id:sc17
# Credits:
# id:sc18
# Starred:
# id:sc19
# Archieve:
# id:sc20
# ChatRoom:
# id:sc21
# ChatList:
# id:sc22
ScanScreen:
id:sc23
MDNavigationDrawer:
id: nav_drawer

View File

@ -9,7 +9,7 @@
Bitmessage android(mobile) interface
"""
from pybitmessage.bitmessagekivy.get_platform import platform
from pybitmessage.get_platform import platform
import os
from pybitmessage.bmconfigparser import BMConfigParser
from functools import partial
@ -41,13 +41,13 @@ from kivy.uix.screenmanager import SlideTransition, FallOutTransition
from pybitmessage import queues
from pybitmessage import state
from pybitmessage.bitmessagekivy import kivy_state
from pybitmessage import kivy_state
from kivymd.uix.bottomsheet import MDCustomBottomSheet
from kivy.lang import Observable
import ast
# from pybitmessage.bitmessagekivy.baseclass.common import toast
# from pybitmessage.baseclass.common import toast
if platform != "android":
@ -207,7 +207,7 @@ class NavigateApp(MDApp):
state.screen_density = Window.size
window_size = state.screen_density
app_platform = platform
title = "PyBitmessageChange"
title = "PyBitmessageChange123"
imgstatus = False
count = 0
manager_open = False
@ -219,12 +219,7 @@ class NavigateApp(MDApp):
def build(self):
"""Method builds the widget"""
for kv in data_screens:
Builder.load_file(
os.path.join(
os.path.dirname(__file__),
'kv',
# f'{all_data[kv]["kv_string"]}.kv',
'{0}.kv'.format(all_data[kv]["kv_string"]),
Builder.load_file(os.path.join(os.path.dirname(__file__),'kv','{0}.kv'.format(all_data[kv]["kv_string"]),
)
)
# self.obj_1 = AddressBook()
@ -234,6 +229,9 @@ class NavigateApp(MDApp):
Window.bind(on_keyboard=self.on_key, on_request_close=self.on_request_close)
return Builder.load_file(os.path.join(os.path.dirname(__file__), 'main.kv'))
def set_screen(self, screen_name):
self.root.ids.scr_mngr.current = screen_name
def run(self):
"""Running the widgets"""
super(NavigateApp, self).run()

View File

@ -19,9 +19,9 @@ from kivymd.uix.button import MDRaisedButton
from kivymd.uix.dialog import MDDialog
from kivymd.uix.label import MDLabel
from pybitmessage.bitmessagekivy.get_platform import platform
from pybitmessage.get_platform import platform
from pybitmessage import state
from pybitmessage.bitmessagekivy import kivy_state
from pybitmessage import kivy_state
class AddressBook(Screen):

View File

@ -23,7 +23,7 @@ from baseclass.common import (
from kivymd.uix.label import MDLabel
from pybitmessage import state
from pybitmessage.bitmessagekivy import kivy_state
from pybitmessage import kivy_state
class Allmails(Screen):

View File

@ -22,7 +22,7 @@ from baseclass.common import (
from kivymd.uix.label import MDLabel
from pybitmessage import state
from pybitmessage.bitmessagekivy import kivy_state
from pybitmessage import kivy_state
class Draft(Screen):

View File

@ -17,7 +17,7 @@ from baseclass.common import showLimitedCnt
from kivymd.uix.label import MDLabel
from pybitmessage import state
from pybitmessage.bitmessagekivy import kivy_state
from pybitmessage import kivy_state
class Inbox(Screen):

View File

@ -25,7 +25,7 @@ from kivymd.uix.list import (
)
from pybitmessage import state
from pybitmessage.bitmessagekivy import kivy_state
from pybitmessage import kivy_state
from .common import (
toast, avatarImageFirstLetter, ShowTimeHistoy

View File

@ -32,11 +32,11 @@ from kivymd.uix.button import MDFlatButton
from kivymd.uix.dialog import MDDialog
from pybitmessage import state
from pybitmessage.bitmessagekivy import kivy_state
from pybitmessage import kivy_state
from pybitmessage import queues
from pybitmessage.addresses import decodeAddress, addBMIfNotPresent
from pybitmessage.bitmessagekivy.get_platform import platform
from pybitmessage.get_platform import platform
from pybitmessage.bmconfigparser import BMConfigParser

View File

@ -5,7 +5,7 @@
Kivy My Address Book screen
"""
from pybitmessage.bitmessagekivy.get_platform import platform
from pybitmessage.get_platform import platform
from functools import partial
from pybitmessage.bmconfigparser import BMConfigParser
from kivy.clock import Clock

View File

@ -16,7 +16,7 @@ from kivy.properties import (
)
from kivy.uix.screenmanager import Screen
from pybitmessage.bitmessagekivy.get_platform import platform
from pybitmessage.get_platform import platform
class ScanScreen(Screen):

View File

@ -20,7 +20,7 @@ from baseclass.common import (
from kivymd.uix.label import MDLabel
from pybitmessage import state
from pybitmessage.bitmessagekivy import kivy_state
from pybitmessage import kivy_state
class Sent(Screen):

View File

@ -17,7 +17,7 @@ from baseclass.common import showLimitedCnt
from kivymd.uix.label import MDLabel
from pybitmessage import state
from pybitmessage.bitmessagekivy import kivy_state
from pybitmessage import kivy_state
class Trash(Screen):

View File

@ -1,7 +1,7 @@
"""Mock kivy app with mock threads."""
from pybitmessage import state
from pybitmessage.bitmessagekivy.mpybit import NavigateApp
from mpybit import NavigateApp
from class_addressGenerator import FakeAddressGenerator

1
src/mock/kv Symbolic link
View File

@ -0,0 +1 @@
../bitmessagekivy/kv

1
src/mock/main.kv Symbolic link
View File

@ -0,0 +1 @@
../bitmessagekivy/main.kv

View File

@ -1,280 +0,0 @@
# pylint: disable=too-many-lines,import-error,no-name-in-module,unused-argument, no-else-return, unused-variable
# pylint: disable=too-many-ancestors,too-many-locals,useless-super-delegation, attribute-defined-outside-init
# pylint: disable=protected-access
# pylint: disable=import-outside-toplevel,ungrouped-imports,wrong-import-order,unused-import,arguments-differ
# pylint: disable=invalid-name,unnecessary-comprehension,broad-except,simplifiable-if-expression,no-member
# pylint: disable=too-many-return-statements
"""
BMConfigParser class definition and default configuration settings
"""
import os
import shutil
import sys # FIXME: bad style! write more generally
from datetime import datetime
from six import string_types
from six.moves import configparser
try:
import state
from singleton import Singleton
except ImportError:
from pybitmessage import state
from pybitmessage.singleton import Singleton
SafeConfigParser = configparser.SafeConfigParser
BMConfigDefaults = {
"bitmessagesettings": {
"maxaddrperstreamsend": 500,
"maxbootstrapconnections": 20,
"maxdownloadrate": 0,
"maxoutboundconnections": 8,
"maxtotalconnections": 200,
"maxuploadrate": 0,
"apiinterface": "127.0.0.1",
"apiport": 8442,
"udp": "True"
},
"threads": {
"receive": 3,
},
"network": {
"bind": "",
"dandelion": 90,
},
"inventory": {
"storage": "sqlite",
"acceptmismatch": "False",
},
"knownnodes": {
"maxnodes": 20000,
},
"zlib": {
"maxsize": 1048576
}
}
@Singleton
class BMConfigParser(SafeConfigParser):
"""
Singleton class inherited from :class:`ConfigParser.SafeConfigParser`
with additional methods specific to bitmessage config.
"""
# pylint: disable=too-many-ancestors
_temp = {}
def set(self, section, option, value=None):
if self._optcre is self.OPTCRE or value:
if not isinstance(value, string_types):
raise TypeError("option values must be strings")
if not self.validate(section, option, value):
raise ValueError("Invalid value %s" % value)
return SafeConfigParser.set(self, section, option, value)
# pylint: disable=redefined-builtinm, too-many-return-statements
def get(self, section, option, raw=False, vars=None):
if sys.version_info[0] == 3:
# pylint: disable=arguments-differ
try:
if section == "bitmessagesettings" and option == "timeformat":
return SafeConfigParser.get(
self, section, option, raw=True, vars=vars)
try:
return self._temp[section][option]
except KeyError:
pass
return SafeConfigParser.get(
self, section, option, raw=True, vars=vars)
except configparser.InterpolationError:
return SafeConfigParser.get(
self, section, option, raw=True, vars=vars)
except (configparser.NoSectionError, configparser.NoOptionError) as e:
try:
return BMConfigDefaults[section][option]
except (KeyError, ValueError, AttributeError):
raise e
else:
# pylint: disable=arguments-differ
try:
if section == "bitmessagesettings" and option == "timeformat":
return SafeConfigParser.get(
self, section, option, raw, vars)
try:
return self._temp[section][option]
except KeyError:
pass
return SafeConfigParser.get(
self, section, option, True, vars)
except configparser.InterpolationError:
return SafeConfigParser.get(
self, section, option, True, vars)
except (configparser.NoSectionError, configparser.NoOptionError) as e:
try:
return BMConfigDefaults[section][option]
except (KeyError, ValueError, AttributeError):
raise e
def setTemp(self, section, option, value=None):
"""Temporary set option to value, not saving."""
try:
self._temp[section][option] = value
except KeyError:
self._temp[section] = {option: value}
def safeGetBoolean(self, section, field):
"""Return value as boolean, False on exceptions"""
try:
# Used in the python2.7
# return self.getboolean(section, field)
# Used in the python3.5.2
# print(config, section, field)
return self.getboolean(section, field)
except (configparser.NoSectionError, configparser.NoOptionError,
ValueError, AttributeError):
return False
def safeGetInt(self, section, field, default=0):
"""Return value as integer, default on exceptions,
0 if default missing"""
try:
# Used in the python2.7
# return self.getint(section, field)
# Used in the python3.7.0
return int(self.get(section, field))
except (configparser.NoSectionError, configparser.NoOptionError,
ValueError, AttributeError):
return default
def safeGetFloat(self, section, field, default=0.0):
"""Return value as float, default on exceptions,
0.0 if default missing"""
try:
return self.getfloat(section, field)
except (configparser.NoSectionError, configparser.NoOptionError,
ValueError, AttributeError):
return default
def safeGet(self, section, option, default=None):
"""Return value as is, default on exceptions, None if default missing"""
try:
return self.get(section, option)
except (configparser.NoSectionError, configparser.NoOptionError,
ValueError, AttributeError):
return default
def items(self, section, raw=False, variables=None):
# pylint: disable=signature-differs
"""Return section variables as parent,
but override the "raw" argument to always True"""
return SafeConfigParser.items(self, section, True, variables)
def _reset(self):
"""Reset current config. There doesn't appear to be a built in
method for this"""
sections = self.sections()
for x in sections:
self.remove_section(x)
if sys.version_info[0] == 3:
@staticmethod
def addresses(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'))]
def read(self, filenames):
self._reset()
SafeConfigParser.read(self, filenames)
for section in self.sections():
for option in self.options(section):
try:
# pylint: disable=unsubscriptable-object
if not self.validate(
section, option,
self[section][option]
):
try:
newVal = BMConfigDefaults[section][option]
except configparser.NoSectionError:
continue
except KeyError:
continue
SafeConfigParser.set(
self, section, option, newVal)
except configparser.InterpolationError:
continue
def readfp(self, fp, filename=None):
# pylint: disable=no-member
SafeConfigParser.read_file(self, fp)
else:
@staticmethod
def addresses():
"""Return a list of local bitmessage addresses (from section labels)"""
return [
x for x in BMConfigParser().sections() if x.startswith('BM-')]
def read(self, filenames):
"""Read config and populate defaults"""
self._reset()
SafeConfigParser.read(self, filenames)
for section in self.sections():
for option in self.options(section):
try:
if not self.validate(
section, option,
SafeConfigParser.get(self, section, option)
):
try:
newVal = BMConfigDefaults[section][option]
except KeyError:
continue
SafeConfigParser.set(
self, section, option, newVal)
except configparser.InterpolationError:
continue
def save(self):
"""Save the runtime config onto the filesystem"""
fileName = os.path.join(state.appdata, 'keys.dat')
fileNameBak = '.'.join([
fileName, datetime.now().strftime("%Y%j%H%M%S%f"), 'bak'])
# create a backup copy to prevent the accidental loss due to
# the disk write failure
try:
shutil.copyfile(fileName, fileNameBak)
# The backup succeeded.
fileNameExisted = True
except (IOError, Exception):
# The backup failed. This can happen if the file
# didn't exist before.
fileNameExisted = False
with open(fileName, 'w') as configfile:
self.write(configfile)
# delete the backup
if fileNameExisted:
os.remove(fileNameBak)
def validate(self, section, option, value):
"""Input validator interface (using factory pattern)"""
try:
return getattr(self, 'validate_%s_%s' % (section, option))(value)
except AttributeError:
return True
@staticmethod
def validate_bitmessagesettings_maxoutboundconnections(value):
"""Reject maxoutboundconnections that are too high or too low"""
try:
value = int(value)
except ValueError:
return False
if value < 0 or value > 8:
return False
return True

View File

@ -1 +0,0 @@
../../../../../PyBitmessage/src/bitmessagekivy/kv

View File

@ -1 +0,0 @@
../../../../network/threads.py

1
src/mock/mpybit.py Symbolic link
View File

@ -0,0 +1 @@
../bitmessagekivy/mpybit.py

View File

@ -0,0 +1 @@
../../addresses.py

View File

@ -0,0 +1 @@
../../bmconfigparser.py

View File

@ -0,0 +1 @@
../../../network/threads.py

View File

@ -0,0 +1 @@
../../singleton.py