misc: cleanup after automatic force_text/force_str upgrade (#74840)
gitea/wcs/pipeline/head This commit looks good
Details
gitea/wcs/pipeline/head This commit looks good
Details
This commit is contained in:
parent
0ee6d323f4
commit
15051e2c2d
|
@ -23,7 +23,6 @@ from wcs.categories import Category
|
|||
from wcs.data_sources import NamedDataSource
|
||||
from wcs.formdef import FormDef
|
||||
from wcs.forms.root import PublicFormStatusPage
|
||||
from wcs.qommon import force_str
|
||||
from wcs.qommon.emails import docutils
|
||||
from wcs.qommon.ident.password_accounts import PasswordAccount
|
||||
from wcs.qommon.misc import ConnectionError
|
||||
|
|
|
@ -3,7 +3,6 @@ import html
|
|||
import os
|
||||
import string
|
||||
|
||||
import django
|
||||
import pytest
|
||||
from django.test import override_settings
|
||||
from django.utils import translation
|
||||
|
|
|
@ -19,13 +19,13 @@ import sys
|
|||
import types
|
||||
from subprocess import PIPE, Popen
|
||||
|
||||
from django.utils.encoding import force_bytes
|
||||
from django.utils.encoding import force_bytes, force_str
|
||||
from quixote import get_publisher
|
||||
|
||||
from wcs.categories import CardDefCategory
|
||||
from wcs.formdef import FormDef, FormDefDoesNotExist, get_formdefs_of_all_kinds
|
||||
|
||||
from .qommon import _, force_text, misc, pgettext_lazy
|
||||
from .qommon import _, misc, pgettext_lazy
|
||||
from .qommon.storage import ElementEqual, ElementILike, Equal, Null, StrictNotEqual
|
||||
|
||||
if not hasattr(types, 'ClassType'):
|
||||
|
@ -88,23 +88,23 @@ class CardDef(FormDef):
|
|||
def get_default_workflow(cls):
|
||||
from wcs.workflows import Workflow
|
||||
|
||||
workflow = Workflow(name=force_text(_('Default (cards)')))
|
||||
workflow = Workflow(name=force_str(_('Default (cards)')))
|
||||
workflow.id = '_carddef_default'
|
||||
workflow.roles = {
|
||||
'_viewer': force_text(_('Viewer')),
|
||||
'_editor': force_text(_('Editor')),
|
||||
'_viewer': force_str(_('Viewer')),
|
||||
'_editor': force_str(_('Editor')),
|
||||
}
|
||||
status = workflow.add_status(force_text(_('Recorded')), 'recorded')
|
||||
deleted_status = workflow.add_status(force_text(_('Deleted')), 'deleted')
|
||||
status = workflow.add_status(force_str(_('Recorded')), 'recorded')
|
||||
deleted_status = workflow.add_status(force_str(_('Deleted')), 'deleted')
|
||||
|
||||
editable = status.add_action('editable', id='_editable')
|
||||
editable.by = ['_editor']
|
||||
editable.label = force_text(_('Edit Card'))
|
||||
editable.label = force_str(_('Edit Card'))
|
||||
editable.status = status.id
|
||||
|
||||
action_delete = status.add_action('choice', id='_action_delete')
|
||||
action_delete.by = ['_editor']
|
||||
action_delete.label = force_text(_('Delete Card'))
|
||||
action_delete.label = force_str(_('Delete Card'))
|
||||
action_delete.status = deleted_status.id
|
||||
action_delete.require_confirmation = True
|
||||
|
||||
|
|
|
@ -15,9 +15,7 @@
|
|||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import collections
|
||||
import os
|
||||
|
||||
import django
|
||||
from django.core.management.base import CommandError
|
||||
from django.db.backends.postgresql.client import DatabaseClient
|
||||
|
||||
|
@ -43,5 +41,4 @@ class Command(TenantCommand):
|
|||
if not options['domain']:
|
||||
raise CommandError('missing hostname')
|
||||
pub = self.init_tenant_publisher(options['domain'], register_tld_names=False)
|
||||
# signature changed, it has a required parameter in 3.2
|
||||
PsqlDatabaseClient(pub).runshell(()) # noqa pylint: disable=too-many-function-args
|
||||
|
|
|
@ -26,8 +26,6 @@ from contextlib import ExitStack, contextmanager
|
|||
|
||||
from django.utils.encoding import force_str
|
||||
|
||||
from wcs.qommon import force_str
|
||||
|
||||
from . import custom_views, data_sources, formdef, sessions
|
||||
from .admin import RootDirectory as AdminRootDirectory
|
||||
from .backoffice import RootDirectory as BackofficeRootDirectory
|
||||
|
|
|
@ -30,10 +30,6 @@ except ImportError:
|
|||
lasso = None
|
||||
|
||||
|
||||
# force_str: compatibility function to produce an encoded string in Python 2
|
||||
# and a proper unicode string in Python 3
|
||||
force_str = force_str
|
||||
|
||||
# unpickle python2 strings as bytes
|
||||
PICKLE_KWARGS = {'encoding': 'bytes', 'fix_imports': True}
|
||||
|
||||
|
@ -48,21 +44,21 @@ def gettext(message):
|
|||
pub = get_publisher()
|
||||
if pub is None:
|
||||
return message
|
||||
return force_str(force_str(pub.gettext(str(message))))
|
||||
return force_str(pub.gettext(str(message)))
|
||||
|
||||
|
||||
def ngettext(*args):
|
||||
pub = get_publisher()
|
||||
if pub is None:
|
||||
return args[0]
|
||||
return force_str(force_str(pub.ngettext(*args)))
|
||||
return force_str(pub.ngettext(*args))
|
||||
|
||||
|
||||
def pgettext(*args):
|
||||
pub = get_publisher()
|
||||
if pub is None:
|
||||
return args[1]
|
||||
return force_str(force_str(pub.pgettext(*args)))
|
||||
return force_str(pub.pgettext(*args))
|
||||
|
||||
|
||||
def N_(x):
|
||||
|
|
|
@ -19,10 +19,11 @@ import time
|
|||
import traceback
|
||||
import uuid
|
||||
|
||||
from django.utils.encoding import force_str
|
||||
from quixote import get_publisher, get_request, get_response
|
||||
from quixote.directory import Directory
|
||||
|
||||
from . import N_, _, errors, force_text
|
||||
from . import N_, _, errors
|
||||
from .storage import StorableObject
|
||||
|
||||
|
||||
|
@ -62,7 +63,7 @@ class AfterJob(StorableObject):
|
|||
def __init__(self, label=None, cmd=None, **kwargs):
|
||||
super().__init__(id=str(uuid.uuid4()))
|
||||
if label:
|
||||
self.label = force_text(label)
|
||||
self.label = force_str(label)
|
||||
self.done_action_label_arg = kwargs.pop('done_action_label', None)
|
||||
self.done_action_url_arg = kwargs.pop('done_action_url', None)
|
||||
self.done_button_attributes_arg = kwargs.pop('done_button_attributes', None)
|
||||
|
@ -142,7 +143,7 @@ class AfterJob(StorableObject):
|
|||
|
||||
def __getstate__(self):
|
||||
if getattr(self, 'done_action_label_arg', None):
|
||||
self.done_action_label_arg = force_text(self.done_action_label_arg)
|
||||
self.done_action_label_arg = force_str(self.done_action_label_arg)
|
||||
obj_dict = self.__dict__.copy()
|
||||
if '_last_store_time' in obj_dict:
|
||||
del obj_dict['_last_store_time']
|
||||
|
|
|
@ -172,8 +172,8 @@ class QommonPublisher(Publisher):
|
|||
'datetime': datetime,
|
||||
'Decimal': Decimal,
|
||||
'codecs': codecs,
|
||||
'force_str': force_str,
|
||||
'force_bytes': force_bytes,
|
||||
'force_str': force_str,
|
||||
'force_text': force_str,
|
||||
'locals': compat_locals,
|
||||
'vars': compat_locals,
|
||||
|
|
|
@ -202,7 +202,7 @@ class Session(QommonSession, CaptchaSession, StorableObject):
|
|||
return ''
|
||||
from quixote.html import htmltext
|
||||
|
||||
# force_text are required for pre-python3 sessions
|
||||
# force_str are required for pre-python3 sessions
|
||||
s = htmltext('<div id="messages"><ul class="messages"><li class="%s">%s</li></ul></div>') % (
|
||||
force_str(self.message[0]),
|
||||
force_str(self.message[1]),
|
||||
|
|
|
@ -56,7 +56,6 @@ import wcs.roles
|
|||
import wcs.snapshots
|
||||
import wcs.tracking_code
|
||||
import wcs.users
|
||||
from wcs.qommon import force_str
|
||||
|
||||
from . import qommon
|
||||
from .carddef import CardDef
|
||||
|
|
|
@ -1198,7 +1198,7 @@ class Workflow(StorableObject):
|
|||
def get_default_workflow(cls):
|
||||
from .qommon.admin.emails import EmailsDirectory
|
||||
|
||||
# force_text() is used on lazy gettext calls as the default workflow is used
|
||||
# force_str() is used on lazy gettext calls as the default workflow is used
|
||||
# in tests as the basis for other ones and lazy gettext would fail pickling.
|
||||
workflow = Workflow(name=force_str(_('Default')))
|
||||
workflow.id = '_default'
|
||||
|
|
Loading…
Reference in New Issue