Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shlomif committed Nov 13, 2019
1 parent e65c236 commit 0961401
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 21 deletions.
1 change: 1 addition & 0 deletions pysollib/kivy/LApp.py
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,7 @@ def __init__(self, **kw):
def send_event_pressed_1(self, event):
if self.group and '<1>' in self.group.bindings:
self.group.bindings['<1>'](event)

def send_event_pressed_double_1(self, event):
if self.group and '<Double-1>' in self.group.bindings:
self.group.bindings['<Double-1>'](event)
Expand Down
23 changes: 13 additions & 10 deletions pysollib/kivy/androidperms.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import time
import logging
try:
import jnius
Expand All @@ -15,22 +14,26 @@
# wait loop removed. (Implement it in external code if needed.)
# LB191011.


class AndroidPerms(object):
def __init__(self):
if jnius is None:
return
self.PythonActivity = jnius.autoclass('org.kivy.android.PythonActivity')
self.Compat = jnius.autoclass('android.support.v4.content.ContextCompat')
self.currentActivity = jnius.cast('android.app.Activity', self.PythonActivity.mActivity)
self.PythonActivity = jnius.autoclass(
'org.kivy.android.PythonActivity')
self.Compat = jnius.autoclass(
'android.support.v4.content.ContextCompat')
self.currentActivity = jnius.cast(
'android.app.Activity', self.PythonActivity.mActivity)

def getPerm(self,permission):
def getPerm(self, permission):
if jnius is None:
return True
p = self.Compat.checkSelfPermission(self.currentActivity,permission)
p = self.Compat.checkSelfPermission(self.currentActivity, permission)
return p == 0

# check actual permissions
def getPerms(self,permissions):
def getPerms(self, permissions):
if jnius is None:
return True
haveperms = True
Expand All @@ -39,7 +42,7 @@ def getPerms(self,permissions):
return haveperms

# invoke the permissions dialog
def requestPerms(self,permissions):
def requestPerms(self, permissions):
if jnius is None:
return True
logging.info("androidperms: invoke permission dialog")
Expand All @@ -52,10 +55,10 @@ def getStoragePerm():
return ap.getPerms(
["android.permission.WRITE_EXTERNAL_STORAGE"])


def requestStoragePerm():
ap = AndroidPerms()
#ap.requestPerms(
# ap.requestPerms(
# ["android.permission.READ_EXTERNAL_STORAGE","android.permission.WRITE_EXTERNAL_STORAGE"])
ap.requestPerms(
["android.permission.WRITE_EXTERNAL_STORAGE"])

4 changes: 2 additions & 2 deletions pysollib/kivy/menubar.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@
from pysollib.kivy.tkutil import bind
from pysollib.mfxutil import Struct
from pysollib.mygettext import _
from pysollib.pysoltk import MfxMessageDialog
from pysollib.pysoltk import connect_game_find_card_dialog
from pysollib.settings import SELECT_GAME_MENU
from pysollib.settings import TITLE

from pysollib.pysoltk import MfxMessageDialog

# ************************************************************************
# * tk emuls:
Expand Down Expand Up @@ -1909,7 +1909,7 @@ def mOptLanguage(self, *args):
if self._cancelDrag(break_pause=False):
return
self.app.opt.language = self.tkopt.language.get()
d = MfxMessageDialog(
MfxMessageDialog(
self.app.top, title=_("Note"),
text=_("""\
These settings will take effect
Expand Down
1 change: 0 additions & 1 deletion pysollib/kivy/tkwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,4 +635,3 @@ def scroll_bottom(self, *event):
# *
# ************************************************************************
# not used witch kivy. would not nun as it refers TkInter.

6 changes: 5 additions & 1 deletion pysollib/mfxutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,11 @@ def getprefdir(package):


# high resolution clock() and sleep()
uclock = time.clock
try:
uclock = time.perf_counter
except Exception:
uclock = time.clock

usleep = time.sleep
if os.name == "posix":
uclock = time.time
Expand Down
13 changes: 10 additions & 3 deletions pysollib/mygettext.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import gettext
import sys

import six


class myLocalGettext(object):
def __init__(self, lang):
self.language = lang
Expand All @@ -12,15 +14,16 @@ def translation(self):
if self.language == "":
t = gettext.translation(domain, localedir)
else:
t = gettext.translation(domain, localedir, languages=[self.language])
t = gettext.translation(
domain, localedir, languages=[self.language])
return t

def maketext(self, msg):
if not isinstance(msg, six.text_type):
return six.text_type(msg, 'utf-8')
return msg

def ungettext(self,msgid1, msgid2, n):
def ungettext(self, msgid1, msgid2, n):
# unicoded ngettext
msgid1 = self.maketext(msgid1)
msgid2 = self.maketext(msgid2)
Expand All @@ -36,7 +39,7 @@ def ungettext(self,msgid1, msgid2, n):
else:
return t.ungettext(msgid1, msgid2, n)

def ugettext(self,message):
def ugettext(self, message):
# unicoded gettext
message = self.maketext(message)
try:
Expand All @@ -48,15 +51,19 @@ def ugettext(self,message):
else:
return t.ugettext(message)


myGettext = myLocalGettext('')


def n_(x):
return x


def fix_gettext():
gettext.ugettext = myGettext.ugettext
gettext.ungettext = myGettext.ungettext


fix_gettext()

_ = gettext.ugettext
Expand Down
2 changes: 1 addition & 1 deletion pysollib/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
import pysollib.settings
from pysollib.mfxutil import print_err
from pysollib.mygettext import _
from pysollib.mygettext import myGettext
from pysollib.pysoltk import TOOLBAR_BUTTONS, TOOLKIT
from pysollib.resource import CSI

from pysollib.mygettext import myGettext

import six

Expand Down
13 changes: 10 additions & 3 deletions scripts/gen_individual_importing_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,15 @@
from sys import platform

IS_MAC = (platform == "darwin")
PY_VERS = ([] if re.search("\\bSKIP_PY2\\b",
os.getenv('TEST_TAGS', '')) else [2])+[3]
TEST_TAGS = os.getenv('TEST_TAGS', '')


def _has_tag(tag):
return re.search("\\b{}\\b".format(tag), TEST_TAGS)


PY_VERS = ([] if _has_tag('SKIP_PY2') else [2])+[3]
SKIP_GTK = _has_tag('SKIP_GTK')
module_names = []
for d, _, files in os.walk("pysollib"):
for f in files:
Expand All @@ -23,7 +30,7 @@
continue
is_gtk = ("gtk" in module_name)
for ver in PY_VERS:
if ((not is_gtk) or (ver == 2 and (not IS_MAC))):
if ((not is_gtk) or (ver == 2 and (not IS_MAC) and (not SKIP_GTK))):
def fmt(s):
return s % {'module_name': module_name, 'ver': ver}
open(os.path.join(".", "tests", "individually-importing", fmt("import_v%(ver)d_%(module_name)s.py")), 'w').write(fmt('''#!/usr/bin/env python%(ver)d
Expand Down

0 comments on commit 0961401

Please sign in to comment.