Commit 621ea058 authored by Luc Saffre's avatar Luc Saffre
Browse files
parent 442a43c1
......@@ -43,6 +43,7 @@ and
# from __future__ import unicode_literals
# from __future__ import absolute_import
# from builtins import str
import sys
import os
......
......@@ -22,7 +22,7 @@ from bs4 import BeautifulSoup
from atelier.rstgen import table
from atelier import rstgen
from atelier.rstgen import attrtable
from atelier.utils import unindent, rmu
from atelier.utils import unindent, rmu, sixprint
from lino.utils import AttrDict
from lino.utils import i2d
......
......@@ -979,7 +979,8 @@ class Actor(with_metaclass(ActorMetaClass, type('NewBase', (actions.Parametrizab
if not k in cls.actions:
cls._bind_action(k, v)
cls._actions_list.sort(key=lambda a: a.action.sort_index)
cls._actions_list.sort(
key=lambda a: (a.action.sort_index, a.action.action_name))
# cls._actions_list = tuple(cls._actions_list)
# build a dict which maps state.name to a set of action names
......
......@@ -1540,7 +1540,7 @@ class Site(object):
#~ logger.info("20130404 lino.site.Site.override_defaults")
for k, v in list(kwargs.items()):
for k, v in kwargs.items():
if not hasattr(self, k):
raise Exception("%s has no attribute %s" % (self.__class__, k))
setattr(self, k, v)
......@@ -2673,7 +2673,7 @@ this field.
#~ self.language_dict[info.name] = info
else:
if isinstance(self.languages, six.string_types):
self.languages = self.languages.split()
self.languages = str(self.languages).split()
#~ lc = [x for x in self.django_settings.get('LANGUAGES' if x[0] in languages]
#~ lc = language_choices(*self.languages)
#~ self.update_settings(LANGUAGES = lc)
......@@ -2685,7 +2685,7 @@ this field.
languages = []
for i, django_code in enumerate(self.languages):
assert_django_code(django_code)
name = (to_locale(django_code))
name = str(to_locale(django_code))
if name in self.language_dict:
raise Exception("Duplicate name %s for language code %r"
% (name, django_code))
......@@ -2784,7 +2784,7 @@ this field.
#~ set_language(self.get_default_language())
"""
reduce LANGUAGES to my babel languages:
reduce Django's LANGUAGES to my babel languages:
"""
self.update_settings(
LANGUAGES=[x for x in LANGUAGES
......@@ -2835,7 +2835,7 @@ this field.
"""
rv = []
if isinstance(languages, six.string_types):
languages = languages.split()
languages = str(languages).split()
for k in languages:
if isinstance(k, six.string_types):
li = self.get_language_info(k)
......@@ -3556,7 +3556,7 @@ signature as `django.core.mail.EmailMessage`.
print(PRINT_EMAIL.format(
subject=subject, sender=sender, body=body,
recipients=u', '.join(recipients)).encode(
'ascii', 'replace'))
'ascii', 'replace').decode())
return
recipients = [a for a in recipients if '@example.com' not in a]
......
......@@ -62,7 +62,8 @@ if is_devserver():
urlpatterns += static(
settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
# 'django.views.static', (pat, 'serve', opts))
# print('\n'.join(map(str, lst)))
# print(20171212, lst)
# why do i need the following? i thought that this is done
# automatically:
# urlpatterns += static(
......
......@@ -176,8 +176,11 @@ def obj2str(i, force_detailed=False):
return str(i) # AutoField is long on mysql, int on sqlite
if isinstance(i, datetime.date):
return i.isoformat()
if isinstance(i, str):
return repr(i)[1:]
if six.PY2:
if isinstance(i, unicode):
i = str(i)
# if isinstance(i, str):
# return repr(i)[1:]
return repr(i)
if i.pk is None:
force_detailed = True
......@@ -196,10 +199,7 @@ def obj2str(i, force_detailed=False):
#~ names = [fld.name for (fld,model) in i._meta.get_fields_with_model()]
#~ s = ','.join(["%s=%r" % (n, getattr(i,n)) for n in names])
pairs = []
if AFTER17:
fields_list = i._meta.concrete_fields
else:
fields_list = i._meta.fields
fields_list = i._meta.concrete_fields
for fld in fields_list:
#~ if fld.name == 'language':
#~ print 20120905, model, fld
......
......@@ -142,6 +142,8 @@ class Problem(Controllable, UserAuthored):
verbose_name_plural = _("Data problems")
ordering = ['owner_type', 'owner_id', 'checker']
allow_merge_action = False
# problem_type = ProblemTypes.field()
checker = Checkers.field(verbose_name=_("Checker"))
# severity = Severities.field()
......
......@@ -151,7 +151,9 @@ class Comment(CreatedModified, UserAuthored, Controllable,
user=user, obj=ar.obj2memo(self.owner))
if dd.is_installed("inbox"):
#mailto:ADDR@HOST.com?subject=SUBJECT&body=Filling%20in%20the%20Body!%0D%0Afoo%0D%0Abar
s += ' <a href="{href}">{reply}</a>'.format(href=comment_email.gen_href(self, user), reply=_("Reply"))
s += ' <a href="{href}">{reply}</a>'.format(
href=comment_email.gen_href(self, user),
reply=_("Reply"))
s += ':<br>' + self.short_text
if False:
......
......@@ -125,10 +125,11 @@ class DjangoManageTestCase(DjangoTestCase, CommonTestCase):
if res.status_code != 200:
raise Exception("{} gave status code {} instead of 200".format(
url, res.status_code))
content = res.content.decode()
try:
d = json.loads(res.content)
d = json.loads(content)
except ValueError as e:
raise ValueError("Invalid JSON {} : {}".format(res.content, e))
raise ValueError("Invalid JSON {} : {}".format(content, e))
return AttrDict(d)
def check_callback_dialog(self, meth, username, url, dialog, *data, **extra):
......
......@@ -84,7 +84,7 @@ class CommonTestCase(unittest.TestCase):
if report_plain:
msg = "----- EXPECTED : -----\n%s\n----- GOT : -----\n%s" % (a, b)
else:
msg = "EXPECTED : %s" % (' '.join(ta))
msg = "\nEXPECTED : %s" % (' '.join(ta))
msg += "\n GOT : %s" % (' '.join(tb))
if False:
logger.warning(msg)
......
......@@ -9,6 +9,7 @@ Added by LS:
- register_namespace is not in __all__
"""
import six
import xml.etree.ElementTree as etree
if hasattr(etree, '_serialize_xml'):
......@@ -35,3 +36,11 @@ else:
pass
from xml.etree.ElementTree import *
if six.PY3:
_tostring = tostring
# # change default value for encoding to 'unicode'
# def tostring(element, encoding="us-ascii", *args, **kwargs):
# return _tostring(element, encoding, *args, **kwargs)
def tostring(*args, **kwargs):
return _tostring(*args, **kwargs).decode()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment