python3: fixed various code issues
- iterators - use of u''
This commit is contained in:
parent
7556b374d5
commit
34af9cfa2f
39 changed files with 182 additions and 188 deletions
|
|
@ -252,7 +252,7 @@ def request_view(request):
|
|||
default_empty = types.NotImplementedType
|
||||
|
||||
# kw arguments required by this method
|
||||
func_kwargs = dict(itertools.izip_longest(
|
||||
func_kwargs = dict(itertools.zip_longest(
|
||||
reversed(arglist), reversed(defaults), fillvalue=default_empty))
|
||||
|
||||
# This attribute will need to be first param of a method that uses
|
||||
|
|
|
|||
|
|
@ -352,7 +352,7 @@ def get_method(request, apiuser, pattern=Optional('*')):
|
|||
default_empty = '<RequiredType>'
|
||||
|
||||
# kw arguments required by this method
|
||||
func_kwargs = dict(itertools.izip_longest(
|
||||
func_kwargs = dict(itertools.zip_longest(
|
||||
reversed(arglist), reversed(defaults), fillvalue=default_empty))
|
||||
args_desc.append(func_kwargs)
|
||||
|
||||
|
|
|
|||
|
|
@ -339,7 +339,7 @@ class AdminPermissionsView(BaseAppView, DataGridAppView):
|
|||
mapper = self.request.registry.queryUtility(IRoutesMapper)
|
||||
c.view_data = []
|
||||
|
||||
_argument_prog = re.compile('\{(.*?)\}|:\((.*)\)')
|
||||
_argument_prog = re.compile(r'\{(.*?)\}|:\((.*)\)')
|
||||
introspector = self.request.registry.introspector
|
||||
|
||||
view_intr = {}
|
||||
|
|
|
|||
|
|
@ -18,9 +18,8 @@
|
|||
# RhodeCode Enterprise Edition, including its added features, Support services,
|
||||
# and proprietary license terms, please see https://rhodecode.com/licenses/
|
||||
|
||||
|
||||
import io
|
||||
import uuid
|
||||
from io import StringIO
|
||||
import pathlib2
|
||||
|
||||
|
||||
|
|
@ -55,4 +54,4 @@ def uid_filename(filename, randomized=True):
|
|||
|
||||
|
||||
def bytes_to_file_obj(bytes_data):
|
||||
return StringIO.StringIO(bytes_data)
|
||||
return io.StringIO(bytes_data)
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ class TestLoginController(object):
|
|||
h.route_path('repo_summary', repo_name=HG_REPO, _query=kwargs),
|
||||
status=302)
|
||||
|
||||
response_query = urllib.parse.urlparse.parse_qsl(response.location)
|
||||
response_query = urllib.parse.parse_qsl(response.location)
|
||||
assert 'branch=stable' in response_query[0][1]
|
||||
|
||||
def test_login_form_with_get_args(self):
|
||||
|
|
|
|||
|
|
@ -753,7 +753,7 @@ class RepoPullRequestsView(RepoAppView, DataGridAppView):
|
|||
c.commit_changes = []
|
||||
|
||||
def mark(cs, fw):
|
||||
return list(h.itertools.izip_longest([], cs, fillvalue=fw))
|
||||
return list(h.itertools.zip_longest([], cs, fillvalue=fw))
|
||||
|
||||
for c_type, raw_id in mark(commit_changes.added, 'a') \
|
||||
+ mark(commit_changes.removed, 'r') \
|
||||
|
|
|
|||
|
|
@ -39,8 +39,6 @@ log = logging.getLogger(__name__)
|
|||
class RepoSettingsIssueTrackersView(RepoAppView):
|
||||
def load_default_context(self):
|
||||
c = self._get_local_tmpl_context()
|
||||
|
||||
|
||||
return c
|
||||
|
||||
@LoginRequired()
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ class RepoSummaryView(RepoAppView):
|
|||
size += node.size
|
||||
if not _show_stats:
|
||||
continue
|
||||
ext = string.lower(node.extension)
|
||||
ext = node.extension.lower()
|
||||
ext_info = LANGUAGES_EXTENSIONS_MAP.get(ext)
|
||||
if ext_info:
|
||||
if ext in code_stats:
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ class PamSettingsSchema(AuthnPluginSettingsSchemaBase):
|
|||
widget='string')
|
||||
gecos = colander.SchemaNode(
|
||||
colander.String(),
|
||||
default='(?P<last_name>.+),\s*(?P<first_name>\w+)',
|
||||
default=r'(?P<last_name>.+),\s*(?P<first_name>\w+)',
|
||||
description=_('Regular expression for extracting user name/email etc. '
|
||||
'from Unix userinfo.'),
|
||||
preparer=strip_whitespace,
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
import os
|
||||
import logging
|
||||
import rhodecode
|
||||
import collections
|
||||
|
||||
from rhodecode.config import utils
|
||||
|
||||
|
|
@ -67,7 +68,7 @@ def load_pyramid_environment(global_config, settings):
|
|||
|
||||
_sorted_backend = sorted(rhodecode.BACKENDS.items(),
|
||||
key=lambda item: settings['vcs.backends'].index(item[0]))
|
||||
rhodecode.BACKENDS = rhodecode.OrderedDict(_sorted_backend)
|
||||
rhodecode.BACKENDS = collections.OrderedDict(_sorted_backend)
|
||||
|
||||
log.info('Enabled VCS backends: %s', rhodecode.BACKENDS.keys())
|
||||
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ import abc
|
|||
from authomatic.core import Response
|
||||
|
||||
|
||||
class BaseAdapter(object):
|
||||
class BaseAdapter(object, metaclass=abc.ABCMeta):
|
||||
"""
|
||||
Base class for platform adapters.
|
||||
|
||||
|
|
@ -67,8 +67,6 @@ class BaseAdapter(object):
|
|||
|
||||
"""
|
||||
|
||||
__metaclass__ = abc.ABCMeta
|
||||
|
||||
@abc.abstractproperty
|
||||
def params(self):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -139,13 +139,13 @@ def _store_log(action_name, action_data, user_id, username, user_data,
|
|||
user_log.version = UserLog.VERSION_2
|
||||
|
||||
user_log.action = action_name
|
||||
user_log.action_data = action_data or JsonRaw(u'{}')
|
||||
user_log.action_data = action_data or JsonRaw('{}')
|
||||
|
||||
user_log.user_ip = ip_address
|
||||
|
||||
user_log.user_id = user_id
|
||||
user_log.username = username
|
||||
user_log.user_data = user_data or JsonRaw(u'{}')
|
||||
user_log.user_data = user_data or JsonRaw('{}')
|
||||
|
||||
user_log.repository_id = repository_id
|
||||
user_log.repository_name = repository_name
|
||||
|
|
|
|||
|
|
@ -293,11 +293,11 @@ def pr_channel(pull_request):
|
|||
def comment_channel(repo_name, commit_obj=None, pull_request_obj=None):
|
||||
channel = None
|
||||
if commit_obj:
|
||||
channel = u'/repo${}$/commit/{}'.format(
|
||||
channel = '/repo${}$/commit/{}'.format(
|
||||
repo_name, commit_obj.raw_id
|
||||
)
|
||||
elif pull_request_obj:
|
||||
channel = u'/repo${}$/pr/{}'.format(
|
||||
channel = '/repo${}$/pr/{}'.format(
|
||||
repo_name, pull_request_obj.pull_request_id
|
||||
)
|
||||
log.debug('Getting comment channelstream broadcast channel: %s', channel)
|
||||
|
|
|
|||
|
|
@ -158,14 +158,14 @@ def render_tokenstream(tokenstream):
|
|||
for token_class, token_ops_texts in rollup_tokenstream(tokenstream):
|
||||
|
||||
if token_class:
|
||||
result.append(u'<span class="%s">' % token_class)
|
||||
result.append('<span class="%s">' % token_class)
|
||||
else:
|
||||
result.append(u'<span>')
|
||||
result.append('<span>')
|
||||
|
||||
for op_tag, token_text in token_ops_texts:
|
||||
|
||||
if op_tag:
|
||||
result.append(u'<%s>' % op_tag)
|
||||
result.append('<%s>' % op_tag)
|
||||
|
||||
# NOTE(marcink): in some cases of mixed encodings, we might run into
|
||||
# troubles in the html_escape, in this case we say unicode force on token_text
|
||||
|
|
@ -183,9 +183,9 @@ def render_tokenstream(tokenstream):
|
|||
result.append(escaped_text)
|
||||
|
||||
if op_tag:
|
||||
result.append(u'</%s>' % op_tag)
|
||||
result.append('</%s>' % op_tag)
|
||||
|
||||
result.append(u'</span>')
|
||||
result.append('</span>')
|
||||
|
||||
html = ''.join(result)
|
||||
return html
|
||||
|
|
@ -555,20 +555,20 @@ class DiffSet(object):
|
|||
actions = []
|
||||
for op_id, op_text in filediff.patch['stats']['ops'].items():
|
||||
if op_id == DEL_FILENODE:
|
||||
actions.append(u'file was removed')
|
||||
actions.append('file was removed')
|
||||
elif op_id == BIN_FILENODE:
|
||||
actions.append(u'binary diff hidden')
|
||||
actions.append('binary diff hidden')
|
||||
else:
|
||||
actions.append(safe_unicode(op_text))
|
||||
action_line = u'NO CONTENT: ' + \
|
||||
u', '.join(actions) or u'UNDEFINED_ACTION'
|
||||
action_line = 'NO CONTENT: ' + \
|
||||
', '.join(actions) or 'UNDEFINED_ACTION'
|
||||
|
||||
hunk_ops = {'source_length': 0, 'source_start': 0,
|
||||
'lines': [
|
||||
{'new_lineno': 0, 'old_lineno': 1,
|
||||
'action': 'unmod-no-hl', 'line': action_line}
|
||||
],
|
||||
'section_header': u'', 'target_start': 1, 'target_length': 1}
|
||||
'section_header': '', 'target_start': 1, 'target_length': 1}
|
||||
|
||||
hunkbit = self.parse_hunk(hunk_ops, source_file, target_file)
|
||||
hunkbit.source_file_path = source_file_path
|
||||
|
|
@ -742,7 +742,7 @@ class DiffSet(object):
|
|||
return self.highlighted_filenodes[source][filenode][line_number - 1]
|
||||
except Exception:
|
||||
log.exception('diff rendering error')
|
||||
return [('', u'L{}: rhodecode diff rendering error'.format(line_number))]
|
||||
return [('', 'L{}: rhodecode diff rendering error'.format(line_number))]
|
||||
|
||||
def action_to_op(self, action):
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -269,7 +269,7 @@ class DbManage(object):
|
|||
email = defaults.get('email')
|
||||
|
||||
if username is None:
|
||||
username = input('Specify admin username:')
|
||||
username = eval(input('Specify admin username:'))
|
||||
if password is None:
|
||||
password = self._get_admin_password()
|
||||
if not password:
|
||||
|
|
@ -278,7 +278,7 @@ class DbManage(object):
|
|||
if not password:
|
||||
sys.exit()
|
||||
if email is None:
|
||||
email = input('Specify admin email:')
|
||||
email = eval(input('Specify admin email:'))
|
||||
api_key = self.cli_args.get('api_key')
|
||||
self.create_user(username, password, email, True,
|
||||
strict_creation_check=False,
|
||||
|
|
@ -517,10 +517,10 @@ class DbManage(object):
|
|||
if _path is not None:
|
||||
path = _path
|
||||
elif not self.tests and not test_repo_path:
|
||||
path = input(
|
||||
path = eval(input(
|
||||
'Enter a valid absolute path to store repositories. '
|
||||
'All repositories in that path will be added automatically:'
|
||||
)
|
||||
))
|
||||
else:
|
||||
path = test_repo_path
|
||||
path_ok = True
|
||||
|
|
@ -634,7 +634,7 @@ class DbManage(object):
|
|||
strict_creation_check=True, api_key=None):
|
||||
log.info('creating user `%s`', username)
|
||||
user = UserModel().create_or_update(
|
||||
username, password, email, firstname=u'RhodeCode', lastname=u'Admin',
|
||||
username, password, email, firstname='RhodeCode', lastname='Admin',
|
||||
active=True, admin=admin, extern_type="rhodecode",
|
||||
strict_creation_check=strict_creation_check)
|
||||
|
||||
|
|
@ -643,7 +643,7 @@ class DbManage(object):
|
|||
UserModel().add_auth_token(
|
||||
user=user, lifetime_minutes=-1,
|
||||
role=UserModel.auth_token_role.ROLE_ALL,
|
||||
description=u'BUILTIN TOKEN')
|
||||
description='BUILTIN TOKEN')
|
||||
|
||||
def create_default_user(self):
|
||||
log.info('creating default user')
|
||||
|
|
@ -651,11 +651,11 @@ class DbManage(object):
|
|||
user = UserModel().create_or_update(username=User.DEFAULT_USER,
|
||||
password=str(uuid.uuid1())[:20],
|
||||
email=User.DEFAULT_USER_EMAIL,
|
||||
firstname=u'Anonymous',
|
||||
lastname=u'User',
|
||||
firstname='Anonymous',
|
||||
lastname='User',
|
||||
strict_creation_check=False)
|
||||
# based on configuration options activate/de-activate this user which
|
||||
# controlls anonymous access
|
||||
# controls anonymous access
|
||||
if self.cli_args.get('public_access') is False:
|
||||
log.info('Public access disabled')
|
||||
user.active = False
|
||||
|
|
|
|||
|
|
@ -1920,7 +1920,7 @@ class diff_match_patch:
|
|||
Raises:
|
||||
ValueError: If invalid input.
|
||||
"""
|
||||
if type(textline) == unicode:
|
||||
if type(textline) == str:
|
||||
# Patches should be composed of a subset of ascii chars, Unicode not
|
||||
# required. If this encode raises UnicodeEncodeError, patch is invalid.
|
||||
textline = textline.encode("ascii")
|
||||
|
|
|
|||
|
|
@ -73,8 +73,7 @@ def get_gitdiff(filenode_old, filenode_new, ignore_whitespace=True, context=3):
|
|||
if context > MAX_CONTEXT:
|
||||
context = MAX_CONTEXT
|
||||
|
||||
submodules = filter(lambda o: isinstance(o, SubModuleNode),
|
||||
[filenode_new, filenode_old])
|
||||
submodules = [o for o in [filenode_new, filenode_old] if isinstance(o, SubModuleNode)]
|
||||
if submodules:
|
||||
return ''
|
||||
|
||||
|
|
@ -847,7 +846,7 @@ class DiffProcessor(object):
|
|||
if not string:
|
||||
return
|
||||
elif string == '\n':
|
||||
yield u'\n'
|
||||
yield '\n'
|
||||
else:
|
||||
|
||||
has_newline = string.endswith('\n')
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ http://web.archive.org/web/20110718035220/http://diveintomark.org/archives/2004/
|
|||
|
||||
|
||||
import datetime
|
||||
from io import StringIO
|
||||
import io
|
||||
|
||||
import pytz
|
||||
from six.moves.urllib import parse as urlparse
|
||||
|
|
@ -207,7 +207,7 @@ class SyndicationFeed(object):
|
|||
"""
|
||||
Returns the feed in the given encoding as a string.
|
||||
"""
|
||||
s = StringIO()
|
||||
s = io.StringIO()
|
||||
self.write(s, encoding)
|
||||
return s.getvalue()
|
||||
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ def _get_scm_size(alias, root_path):
|
|||
def repo_size(extras):
|
||||
"""Present size of repository after push."""
|
||||
repo = Repository.get_by_repo_name(extras.repository)
|
||||
vcs_part = safe_str(u'.%s' % repo.repo_type)
|
||||
vcs_part = safe_str('.%s' % repo.repo_type)
|
||||
size_vcs, size_root, size_total = _get_scm_size(vcs_part,
|
||||
repo.repo_full_path)
|
||||
msg = ('Repository `%s` size summary %s:%s repo:%s total:%s\n'
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import sys
|
|||
import logging
|
||||
|
||||
|
||||
BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = range(30, 38)
|
||||
BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = list(range(30, 38))
|
||||
|
||||
# Sequences
|
||||
RESET_SEQ = "\033[0m"
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ def relative_path(path, request_path, is_repo_file=None):
|
|||
path = safe_unicode(path)
|
||||
request_path = safe_unicode(request_path)
|
||||
|
||||
if path.startswith((u'data:', u'javascript:', u'#', u':')):
|
||||
if path.startswith(('data:', 'javascript:', '#', ':')):
|
||||
# skip data, anchor, invalid links
|
||||
return path
|
||||
|
||||
|
|
@ -149,10 +149,10 @@ def relative_path(path, request_path, is_repo_file=None):
|
|||
if not request_path:
|
||||
return path
|
||||
|
||||
if path.startswith(u'/'):
|
||||
if path.startswith('/'):
|
||||
path = path[1:]
|
||||
|
||||
if path.startswith(u'./'):
|
||||
if path.startswith('./'):
|
||||
path = path[2:]
|
||||
|
||||
parts = request_path.split('/')
|
||||
|
|
@ -164,7 +164,7 @@ def relative_path(path, request_path, is_repo_file=None):
|
|||
# one level up
|
||||
depth += 1
|
||||
|
||||
while path.startswith(u'../'):
|
||||
while path.startswith('../'):
|
||||
depth += 1
|
||||
path = path[3:]
|
||||
|
||||
|
|
@ -172,9 +172,9 @@ def relative_path(path, request_path, is_repo_file=None):
|
|||
parts = parts[:-depth]
|
||||
|
||||
parts.append(path)
|
||||
final_path = u'/'.join(parts).lstrip(u'/')
|
||||
final_path = '/'.join(parts).lstrip('/')
|
||||
|
||||
return u'/' + final_path
|
||||
return '/' + final_path
|
||||
|
||||
|
||||
_cached_markdown_renderer = None
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ class SimpleGit(simplevcs.SimpleVCS):
|
|||
path = environ['PATH_INFO']
|
||||
|
||||
if path.endswith('/info/refs'):
|
||||
query = urllib.parse.urlparse.parse_qs(environ['QUERY_STRING'])
|
||||
query = urllib.parse.parse_qs(environ['QUERY_STRING'])
|
||||
service_cmd = query.get('service', [''])[0]
|
||||
return self._ACTION_MAPPING.get(service_cmd, 'pull')
|
||||
|
||||
|
|
|
|||
|
|
@ -135,8 +135,7 @@ class SimpleHg(simplevcs.SimpleVCS):
|
|||
:param environ:
|
||||
"""
|
||||
default = 'push'
|
||||
query = urllib.parse.urlparse.parse_qs(environ['QUERY_STRING'],
|
||||
keep_blank_values=True)
|
||||
query = urllib.parse.parse_qs(environ['QUERY_STRING'], keep_blank_values=True)
|
||||
|
||||
if 'cmd' in query:
|
||||
cmd = query['cmd'][0]
|
||||
|
|
|
|||
|
|
@ -25,10 +25,10 @@ It's implemented with basic auth function
|
|||
|
||||
import os
|
||||
import re
|
||||
import io
|
||||
import logging
|
||||
import importlib
|
||||
from functools import wraps
|
||||
from io import StringIO
|
||||
from lxml import etree
|
||||
|
||||
import time
|
||||
|
|
@ -122,10 +122,10 @@ class SimpleVCS(object):
|
|||
# we use this regex which will match only on URLs pointing to shadow
|
||||
# repositories.
|
||||
shadow_repo_re = re.compile(
|
||||
'(?P<groups>(?:{slug_pat}/)*)' # repo groups
|
||||
'(?P<target>{slug_pat})/' # target repo
|
||||
'pull-request/(?P<pr_id>\d+)/' # pull request
|
||||
'repository$' # shadow repo
|
||||
'(?P<groups>(?:{slug_pat}/)*)' # repo groups
|
||||
'(?P<target>{slug_pat})/' # target repo
|
||||
'pull-request/(?P<pr_id>\\d+)/' # pull request
|
||||
'repository$' # shadow repo
|
||||
.format(slug_pat=SLUG_RE.pattern))
|
||||
|
||||
def __init__(self, config, registry):
|
||||
|
|
@ -595,7 +595,7 @@ class SimpleVCS(object):
|
|||
# so we use the txn_id, for this we peek the body, and still save
|
||||
# it as wsgi.input
|
||||
data = environ['wsgi.input'].read()
|
||||
environ['wsgi.input'] = StringIO(data)
|
||||
environ['wsgi.input'] = io.StringIO(data)
|
||||
txn_id = extract_svn_txn_id(self.acl_repo_name, data)
|
||||
|
||||
callback_daemon, extras = self._prepare_callback_daemon(
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ def is_hg(environ):
|
|||
http_accept = environ.get('HTTP_ACCEPT')
|
||||
|
||||
if http_accept and http_accept.startswith('application/mercurial'):
|
||||
query = urllib.parse.urlparse.parse_qs(environ['QUERY_STRING'])
|
||||
query = urllib.parse.parse_qs(environ['QUERY_STRING'])
|
||||
if 'cmd' in query:
|
||||
is_hg_path = True
|
||||
|
||||
|
|
|
|||
|
|
@ -146,14 +146,14 @@ def make_html_tag(tag, text=None, **params):
|
|||
# to be used as a CSS class specification instead of the reserved Python keyword 'class'.
|
||||
key = key.lstrip("_")
|
||||
|
||||
params_string += u' {0}="{1}"'.format(key, value)
|
||||
params_string += ' {0}="{1}"'.format(key, value)
|
||||
|
||||
# Create the tag string
|
||||
tag_string = u"<{0}{1}>".format(tag, params_string)
|
||||
tag_string = "<{0}{1}>".format(tag, params_string)
|
||||
|
||||
# Add text and closing tag if required.
|
||||
if text:
|
||||
tag_string += u"{0}</{1}>".format(text, tag)
|
||||
tag_string += "{0}</{1}>".format(text, tag)
|
||||
|
||||
return tag_string
|
||||
|
||||
|
|
@ -552,13 +552,13 @@ class _Page(list):
|
|||
|
||||
def _get_edges(self, cur_page, max_page, items):
|
||||
cur_page = int(cur_page)
|
||||
edge = (items / 2) + 1
|
||||
edge = (items // 2) + 1
|
||||
if cur_page <= edge:
|
||||
radius = max(items / 2, items - cur_page)
|
||||
radius = max(items // 2, items - cur_page)
|
||||
elif (max_page - cur_page) < edge:
|
||||
radius = (items - 1) - (max_page - cur_page)
|
||||
else:
|
||||
radius = (items / 2) - 1
|
||||
radius = (items // 2) - 1
|
||||
|
||||
left = max(1, (cur_page - radius))
|
||||
right = min(max_page, cur_page + radius)
|
||||
|
|
@ -726,7 +726,7 @@ class _Page(list):
|
|||
|
||||
nav_items["first_page"] = {
|
||||
"type": "first_page",
|
||||
"value": unicode(symbol_first),
|
||||
"value": str(symbol_first),
|
||||
"attrs": self.link_attr,
|
||||
"number": self.first_page,
|
||||
"href": self.url_maker(self.first_page),
|
||||
|
|
@ -753,7 +753,7 @@ class _Page(list):
|
|||
nav_items["range_pages"].append(
|
||||
{
|
||||
"type": "current_page",
|
||||
"value": unicode(this_page),
|
||||
"value": str(this_page),
|
||||
"number": this_page,
|
||||
"attrs": self.curpage_attr,
|
||||
"href": self.url_maker(this_page),
|
||||
|
|
@ -770,7 +770,7 @@ class _Page(list):
|
|||
nav_items["range_pages"].append(
|
||||
{
|
||||
"type": "page",
|
||||
"value": unicode(this_page),
|
||||
"value": str(this_page),
|
||||
"number": this_page,
|
||||
"attrs": self.link_attr,
|
||||
"href": self.url_maker(this_page),
|
||||
|
|
@ -795,7 +795,7 @@ class _Page(list):
|
|||
# page or there would be no need to insert '..' spacers)
|
||||
nav_items["last_page"] = {
|
||||
"type": "last_page",
|
||||
"value": unicode(symbol_last),
|
||||
"value": str(symbol_last),
|
||||
"attrs": self.link_attr,
|
||||
"href": self.url_maker(self.last_page),
|
||||
"number": self.last_page,
|
||||
|
|
@ -803,7 +803,7 @@ class _Page(list):
|
|||
|
||||
nav_items["previous_page"] = {
|
||||
"type": "previous_page",
|
||||
"value": unicode(symbol_previous),
|
||||
"value": str(symbol_previous),
|
||||
"attrs": self.link_attr,
|
||||
"number": self.previous_page or self.first_page,
|
||||
"href": self.url_maker(self.previous_page or self.first_page),
|
||||
|
|
@ -811,7 +811,7 @@ class _Page(list):
|
|||
|
||||
nav_items["next_page"] = {
|
||||
"type": "next_page",
|
||||
"value": unicode(symbol_next),
|
||||
"value": str(symbol_next),
|
||||
"attrs": self.link_attr,
|
||||
"number": self.next_page or self.last_page,
|
||||
"href": self.url_maker(self.next_page or self.last_page),
|
||||
|
|
@ -835,7 +835,7 @@ class _Page(list):
|
|||
# or there would be no need to insert '..' spacers)
|
||||
if self.first_page and self.page != self.first_page and self.first_page < leftmost_page:
|
||||
page = link_map["first_page"].copy()
|
||||
page["value"] = unicode(page["number"])
|
||||
page["value"] = str(page["number"])
|
||||
nav_items.append(self.link_tag(page))
|
||||
|
||||
for item in link_map["range_pages"]:
|
||||
|
|
@ -845,7 +845,7 @@ class _Page(list):
|
|||
# page or there would be no need to insert '..' spacers)
|
||||
if self.last_page and self.page != self.last_page and rightmost_page < self.last_page:
|
||||
page = link_map["last_page"].copy()
|
||||
page["value"] = unicode(page["number"])
|
||||
page["value"] = str(page["number"])
|
||||
nav_items.append(self.link_tag(page))
|
||||
|
||||
return self.separator.join(nav_items)
|
||||
|
|
@ -859,7 +859,7 @@ class _Page(list):
|
|||
if "$page" not in self.url:
|
||||
raise Exception("The 'url' parameter must contain a '$page' placeholder.")
|
||||
|
||||
return self.url.replace("$page", unicode(page_number))
|
||||
return self.url.replace("$page", str(page_number))
|
||||
|
||||
@staticmethod
|
||||
def default_link_tag(item):
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ class MemcachedAuthSessions(BaseAuthSessions):
|
|||
try:
|
||||
slabs = []
|
||||
for server, slabs_data in client.get_slabs():
|
||||
slabs.extend(slabs_data.keys())
|
||||
slabs.extend(list(slabs_data.keys()))
|
||||
|
||||
host, port = client.servers[0].address
|
||||
telnet_client = self._get_telnet_client(host, port)
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ def _get_dirpaths(p):
|
|||
def _has_correct_type(item):
|
||||
if type(item) is not expected_type:
|
||||
log.error(
|
||||
u"Ignoring path %s since it cannot be decoded into unicode.",
|
||||
"Ignoring path %s since it cannot be decoded into unicode.",
|
||||
# Using "repr" to make sure that we see the byte value in case
|
||||
# of support.
|
||||
repr(item))
|
||||
|
|
@ -320,7 +320,7 @@ def is_valid_repo_group(repo_group_name, base_path, skip_path_check=False):
|
|||
|
||||
def ask_ok(prompt, retries=4, complaint='[y]es or [n]o please!'):
|
||||
while True:
|
||||
ok = raw_input(prompt)
|
||||
ok = eval(input(prompt))
|
||||
if ok.lower() in ('y', 'ye', 'yes'):
|
||||
return True
|
||||
if ok.lower() in ('n', 'no', 'nop', 'nope'):
|
||||
|
|
|
|||
|
|
@ -367,21 +367,21 @@ def age(prevdate, now=None, show_short_version=False, show_suffix=True, short_fo
|
|||
# Format the result
|
||||
if short_format:
|
||||
fmt_funcs = {
|
||||
'year': lambda d: u'%dy' % d,
|
||||
'month': lambda d: u'%dm' % d,
|
||||
'day': lambda d: u'%dd' % d,
|
||||
'hour': lambda d: u'%dh' % d,
|
||||
'minute': lambda d: u'%dmin' % d,
|
||||
'second': lambda d: u'%dsec' % d,
|
||||
'year': lambda d: '%dy' % d,
|
||||
'month': lambda d: '%dm' % d,
|
||||
'day': lambda d: '%dd' % d,
|
||||
'hour': lambda d: '%dh' % d,
|
||||
'minute': lambda d: '%dmin' % d,
|
||||
'second': lambda d: '%dsec' % d,
|
||||
}
|
||||
else:
|
||||
fmt_funcs = {
|
||||
'year': lambda d: _pluralize(u'${num} year', u'${num} years', d, mapping={'num': d}).interpolate(),
|
||||
'month': lambda d: _pluralize(u'${num} month', u'${num} months', d, mapping={'num': d}).interpolate(),
|
||||
'day': lambda d: _pluralize(u'${num} day', u'${num} days', d, mapping={'num': d}).interpolate(),
|
||||
'hour': lambda d: _pluralize(u'${num} hour', u'${num} hours', d, mapping={'num': d}).interpolate(),
|
||||
'minute': lambda d: _pluralize(u'${num} minute', u'${num} minutes', d, mapping={'num': d}).interpolate(),
|
||||
'second': lambda d: _pluralize(u'${num} second', u'${num} seconds', d, mapping={'num': d}).interpolate(),
|
||||
'year': lambda d: _pluralize('${num} year', '${num} years', d, mapping={'num': d}).interpolate(),
|
||||
'month': lambda d: _pluralize('${num} month', '${num} months', d, mapping={'num': d}).interpolate(),
|
||||
'day': lambda d: _pluralize('${num} day', '${num} days', d, mapping={'num': d}).interpolate(),
|
||||
'hour': lambda d: _pluralize('${num} hour', '${num} hours', d, mapping={'num': d}).interpolate(),
|
||||
'minute': lambda d: _pluralize('${num} minute', '${num} minutes', d, mapping={'num': d}).interpolate(),
|
||||
'second': lambda d: _pluralize('${num} second', '${num} seconds', d, mapping={'num': d}).interpolate(),
|
||||
}
|
||||
|
||||
i = 0
|
||||
|
|
@ -399,13 +399,13 @@ def age(prevdate, now=None, show_short_version=False, show_suffix=True, short_fo
|
|||
_val = fmt_funcs[part](value)
|
||||
if future:
|
||||
if show_suffix:
|
||||
return _(u'in ${ago}', mapping={'ago': _val})
|
||||
return _('in ${ago}', mapping={'ago': _val})
|
||||
else:
|
||||
return _(_val)
|
||||
|
||||
else:
|
||||
if show_suffix:
|
||||
return _(u'${ago} ago', mapping={'ago': _val})
|
||||
return _('${ago} ago', mapping={'ago': _val})
|
||||
else:
|
||||
return _(_val)
|
||||
|
||||
|
|
@ -414,21 +414,21 @@ def age(prevdate, now=None, show_short_version=False, show_suffix=True, short_fo
|
|||
mapping = {'val': val, 'detail': val_detail}
|
||||
|
||||
if short_format:
|
||||
datetime_tmpl = _(u'${val}, ${detail}', mapping=mapping)
|
||||
datetime_tmpl = _('${val}, ${detail}', mapping=mapping)
|
||||
if show_suffix:
|
||||
datetime_tmpl = _(u'${val}, ${detail} ago', mapping=mapping)
|
||||
datetime_tmpl = _('${val}, ${detail} ago', mapping=mapping)
|
||||
if future:
|
||||
datetime_tmpl = _(u'in ${val}, ${detail}', mapping=mapping)
|
||||
datetime_tmpl = _('in ${val}, ${detail}', mapping=mapping)
|
||||
else:
|
||||
datetime_tmpl = _(u'${val} and ${detail}', mapping=mapping)
|
||||
datetime_tmpl = _('${val} and ${detail}', mapping=mapping)
|
||||
if show_suffix:
|
||||
datetime_tmpl = _(u'${val} and ${detail} ago', mapping=mapping)
|
||||
datetime_tmpl = _('${val} and ${detail} ago', mapping=mapping)
|
||||
if future:
|
||||
datetime_tmpl = _(u'in ${val} and ${detail}', mapping=mapping)
|
||||
datetime_tmpl = _('in ${val} and ${detail}', mapping=mapping)
|
||||
|
||||
return datetime_tmpl
|
||||
i += 1
|
||||
return _(u'just now')
|
||||
return _('just now')
|
||||
|
||||
|
||||
def age_from_seconds(seconds):
|
||||
|
|
|
|||
|
|
@ -23,10 +23,10 @@ GIT commit module
|
|||
"""
|
||||
|
||||
import re
|
||||
import io
|
||||
import stat
|
||||
import configparser
|
||||
from itertools import chain
|
||||
from io import StringIO
|
||||
|
||||
from zope.cachedescriptors.property import Lazy as LazyProperty
|
||||
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ class MercurialCommit(base.BaseCommit):
|
|||
return
|
||||
|
||||
result = self._remote.bulk_request(self.raw_id, pre_load)
|
||||
|
||||
for attr, value in result.items():
|
||||
if attr in ["author", "branch", "message"]:
|
||||
value = safe_unicode(value)
|
||||
|
|
|
|||
|
|
@ -96,16 +96,16 @@ class PermissionModel(BaseModel):
|
|||
c_obj.register_choices = [
|
||||
('hg.register.none', _('Disabled')),
|
||||
('hg.register.manual_activate', _('Allowed with manual account activation')),
|
||||
('hg.register.auto_activate', _('Allowed with automatic account activation')),]
|
||||
('hg.register.auto_activate', _('Allowed with automatic account activation'))]
|
||||
|
||||
c_obj.password_reset_choices = [
|
||||
('hg.password_reset.enabled', _('Allow password recovery')),
|
||||
('hg.password_reset.hidden', _('Hide password recovery link')),
|
||||
('hg.password_reset.disabled', _('Disable password recovery')),]
|
||||
('hg.password_reset.disabled', _('Disable password recovery'))]
|
||||
|
||||
c_obj.extern_activate_choices = [
|
||||
('hg.extern_activate.manual', _('Manual activation of external account')),
|
||||
('hg.extern_activate.auto', _('Automatic activation of external account')),]
|
||||
('hg.extern_activate.auto', _('Automatic activation of external account'))]
|
||||
|
||||
c_obj.repo_create_choices = [
|
||||
('hg.create.none', _('Disabled')),
|
||||
|
|
@ -246,7 +246,7 @@ class PermissionModel(BaseModel):
|
|||
.all()
|
||||
return self._clear_object_perm(perms, preserve=preserve)
|
||||
|
||||
def _set_new_object_perms(self, obj_type, object, form_result, preserve=None):
|
||||
def _set_new_object_perms(self, obj_type, to_object, form_result, preserve=None):
|
||||
# clear current entries, to make this function idempotent
|
||||
# it will fix even if we define more permissions or permissions
|
||||
# are somehow missing
|
||||
|
|
@ -262,9 +262,9 @@ class PermissionModel(BaseModel):
|
|||
global_perms, default_user_perms))
|
||||
|
||||
if obj_type == 'user':
|
||||
self._clear_user_perms(object.user_id, preserve)
|
||||
self._clear_user_perms(to_object.user_id, preserve)
|
||||
if obj_type == 'user_group':
|
||||
self._clear_user_group_perms(object.users_group_id, preserve)
|
||||
self._clear_user_group_perms(to_object.users_group_id, preserve)
|
||||
|
||||
# now kill the keys that we want to preserve from the form.
|
||||
for key in preserve:
|
||||
|
|
@ -395,7 +395,7 @@ class PermissionModel(BaseModel):
|
|||
'default_repo_create_on_write',
|
||||
'default_repo_create',
|
||||
'default_fork_create',
|
||||
'default_inherit_default_permissions',])
|
||||
'default_inherit_default_permissions'])
|
||||
|
||||
self.sa.commit()
|
||||
except (DatabaseError,):
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ Scm model for RhodeCode
|
|||
import os.path
|
||||
import traceback
|
||||
import logging
|
||||
from io import StringIO
|
||||
import io
|
||||
|
||||
from sqlalchemy import func
|
||||
from zope.cachedescriptors.property import Lazy as LazyProperty
|
||||
|
|
|
|||
|
|
@ -89,8 +89,8 @@ def UniqueList(localizer, convert=None):
|
|||
Unique List !
|
||||
"""
|
||||
messages = {
|
||||
'empty': _(u'Value cannot be an empty list'),
|
||||
'missing_value': _(u'Value cannot be an empty list'),
|
||||
'empty': _('Value cannot be an empty list'),
|
||||
'missing_value': _('Value cannot be an empty list'),
|
||||
}
|
||||
|
||||
def _to_python(self, value, state):
|
||||
|
|
@ -136,7 +136,7 @@ def ValidSvnPattern(localizer, section, repo_name=None):
|
|||
|
||||
class _validator(formencode.validators.FancyValidator):
|
||||
messages = {
|
||||
'pattern_exists': _(u'Pattern already exists'),
|
||||
'pattern_exists': _('Pattern already exists'),
|
||||
}
|
||||
|
||||
def validate_python(self, value, state):
|
||||
|
|
@ -157,13 +157,13 @@ def ValidUsername(localizer, edit=False, old_data=None):
|
|||
|
||||
class _validator(formencode.validators.FancyValidator):
|
||||
messages = {
|
||||
'username_exists': _(u'Username "%(username)s" already exists'),
|
||||
'username_exists': _('Username "%(username)s" already exists'),
|
||||
'system_invalid_username':
|
||||
_(u'Username "%(username)s" is forbidden'),
|
||||
_('Username "%(username)s" is forbidden'),
|
||||
'invalid_username':
|
||||
_(u'Username may only contain alphanumeric characters '
|
||||
u'underscores, periods or dashes and must begin with '
|
||||
u'alphanumeric character or underscore')
|
||||
_('Username may only contain alphanumeric characters '
|
||||
'underscores, periods or dashes and must begin with '
|
||||
'alphanumeric character or underscore')
|
||||
}
|
||||
|
||||
def validate_python(self, value, state):
|
||||
|
|
@ -192,8 +192,8 @@ def ValidRepoUser(localizer, allow_disabled=False):
|
|||
|
||||
class _validator(formencode.validators.FancyValidator):
|
||||
messages = {
|
||||
'invalid_username': _(u'Username %(username)s is not valid'),
|
||||
'disabled_username': _(u'Username %(username)s is disabled')
|
||||
'invalid_username': _('Username %(username)s is not valid'),
|
||||
'disabled_username': _('Username %(username)s is disabled')
|
||||
}
|
||||
|
||||
def validate_python(self, value, state):
|
||||
|
|
@ -218,12 +218,12 @@ def ValidUserGroup(localizer, edit=False, old_data=None):
|
|||
|
||||
class _validator(formencode.validators.FancyValidator):
|
||||
messages = {
|
||||
'invalid_group': _(u'Invalid user group name'),
|
||||
'group_exist': _(u'User group `%(usergroup)s` already exists'),
|
||||
'invalid_group': _('Invalid user group name'),
|
||||
'group_exist': _('User group `%(usergroup)s` already exists'),
|
||||
'invalid_usergroup_name':
|
||||
_(u'user group name may only contain alphanumeric '
|
||||
u'characters underscores, periods or dashes and must begin '
|
||||
u'with alphanumeric character')
|
||||
_('user group name may only contain alphanumeric '
|
||||
'characters underscores, periods or dashes and must begin '
|
||||
'with alphanumeric character')
|
||||
}
|
||||
|
||||
def validate_python(self, value, state):
|
||||
|
|
@ -261,15 +261,15 @@ def ValidRepoGroup(localizer, edit=False, old_data=None, can_create_in_root=Fals
|
|||
|
||||
class _validator(formencode.validators.FancyValidator):
|
||||
messages = {
|
||||
'group_parent_id': _(u'Cannot assign this group as parent'),
|
||||
'group_exists': _(u'Group "%(group_name)s" already exists'),
|
||||
'repo_exists': _(u'Repository with name "%(group_name)s" '
|
||||
u'already exists'),
|
||||
'permission_denied': _(u"no permission to store repository group"
|
||||
u"in this location"),
|
||||
'group_parent_id': _('Cannot assign this group as parent'),
|
||||
'group_exists': _('Group "%(group_name)s" already exists'),
|
||||
'repo_exists': _('Repository with name "%(group_name)s" '
|
||||
'already exists'),
|
||||
'permission_denied': _("no permission to store repository group"
|
||||
"in this location"),
|
||||
'permission_denied_root': _(
|
||||
u"no permission to store repository group "
|
||||
u"in root location")
|
||||
"no permission to store repository group "
|
||||
"in root location")
|
||||
}
|
||||
|
||||
def _to_python(self, value, state):
|
||||
|
|
@ -384,7 +384,7 @@ def ValidPassword(localizer):
|
|||
class _validator(formencode.validators.FancyValidator):
|
||||
messages = {
|
||||
'invalid_password':
|
||||
_(u'Invalid characters (non-ascii) in password')
|
||||
_('Invalid characters (non-ascii) in password')
|
||||
}
|
||||
|
||||
def validate_python(self, value, state):
|
||||
|
|
@ -403,7 +403,7 @@ def ValidPasswordsMatch(
|
|||
|
||||
class _validator(formencode.validators.FancyValidator):
|
||||
messages = {
|
||||
'password_mismatch': _(u'Passwords do not match'),
|
||||
'password_mismatch': _('Passwords do not match'),
|
||||
}
|
||||
|
||||
def validate_python(self, value, state):
|
||||
|
|
@ -423,9 +423,9 @@ def ValidAuth(localizer):
|
|||
|
||||
class _validator(formencode.validators.FancyValidator):
|
||||
messages = {
|
||||
'invalid_password': _(u'invalid password'),
|
||||
'invalid_username': _(u'invalid user name'),
|
||||
'disabled_account': _(u'Your account is disabled')
|
||||
'invalid_password': _('invalid password'),
|
||||
'invalid_username': _('invalid user name'),
|
||||
'disabled_account': _('Your account is disabled')
|
||||
}
|
||||
|
||||
def validate_python(self, value, state):
|
||||
|
|
@ -461,18 +461,18 @@ def ValidRepoName(localizer, edit=False, old_data=None):
|
|||
class _validator(formencode.validators.FancyValidator):
|
||||
messages = {
|
||||
'invalid_repo_name':
|
||||
_(u'Repository name %(repo)s is disallowed'),
|
||||
_('Repository name %(repo)s is disallowed'),
|
||||
# top level
|
||||
'repository_exists': _(u'Repository with name %(repo)s '
|
||||
u'already exists'),
|
||||
'group_exists': _(u'Repository group with name "%(repo)s" '
|
||||
u'already exists'),
|
||||
'repository_exists': _('Repository with name %(repo)s '
|
||||
'already exists'),
|
||||
'group_exists': _('Repository group with name "%(repo)s" '
|
||||
'already exists'),
|
||||
# inside a group
|
||||
'repository_in_group_exists': _(u'Repository with name %(repo)s '
|
||||
u'exists in group "%(group)s"'),
|
||||
'repository_in_group_exists': _('Repository with name %(repo)s '
|
||||
'exists in group "%(group)s"'),
|
||||
'group_in_group_exists': _(
|
||||
u'Repository group with name "%(repo)s" '
|
||||
u'exists in group "%(group)s"'),
|
||||
'Repository group with name "%(repo)s" '
|
||||
'exists in group "%(group)s"'),
|
||||
}
|
||||
|
||||
def _to_python(self, value, state):
|
||||
|
|
@ -563,7 +563,7 @@ def CannotHaveGitSuffix(localizer):
|
|||
class _validator(formencode.validators.FancyValidator):
|
||||
messages = {
|
||||
'has_git_suffix':
|
||||
_(u'Repository name cannot end with .git'),
|
||||
_('Repository name cannot end with .git'),
|
||||
}
|
||||
|
||||
def _to_python(self, value, state):
|
||||
|
|
@ -623,10 +623,10 @@ def ValidCloneUri(localizer):
|
|||
|
||||
class _validator(formencode.validators.FancyValidator):
|
||||
messages = {
|
||||
'clone_uri': _(u'invalid clone url or credentials for %(rtype)s repository'),
|
||||
'clone_uri': _('invalid clone url or credentials for %(rtype)s repository'),
|
||||
'invalid_clone_uri': _(
|
||||
u'Invalid clone url, provide a valid clone '
|
||||
u'url starting with one of %(allowed_prefixes)s')
|
||||
'Invalid clone url, provide a valid clone '
|
||||
'url starting with one of %(allowed_prefixes)s')
|
||||
}
|
||||
|
||||
def validate_python(self, value, state):
|
||||
|
|
@ -656,7 +656,7 @@ def ValidForkType(localizer, old_data=None):
|
|||
|
||||
class _validator(formencode.validators.FancyValidator):
|
||||
messages = {
|
||||
'invalid_fork_type': _(u'Fork have to be the same type as parent')
|
||||
'invalid_fork_type': _('Fork have to be the same type as parent')
|
||||
}
|
||||
|
||||
def validate_python(self, value, state):
|
||||
|
|
@ -674,11 +674,11 @@ def CanWriteGroup(localizer, old_data=None):
|
|||
class _validator(formencode.validators.FancyValidator):
|
||||
messages = {
|
||||
'permission_denied': _(
|
||||
u"You do not have the permission "
|
||||
u"to create repositories in this group."),
|
||||
"You do not have the permission "
|
||||
"to create repositories in this group."),
|
||||
'permission_denied_root': _(
|
||||
u"You do not have the permission to store repositories in "
|
||||
u"the root location.")
|
||||
"You do not have the permission to store repositories in "
|
||||
"the root location.")
|
||||
}
|
||||
|
||||
def _to_python(self, value, state):
|
||||
|
|
@ -736,7 +736,7 @@ def ValidPerms(localizer, type_='repo'):
|
|||
class _validator(formencode.validators.FancyValidator):
|
||||
messages = {
|
||||
'perm_new_member_name':
|
||||
_(u'This username or user group name is not valid')
|
||||
_('This username or user group name is not valid')
|
||||
}
|
||||
|
||||
def _to_python(self, value, state):
|
||||
|
|
@ -849,7 +849,7 @@ def ValidPath(localizer):
|
|||
|
||||
class _validator(formencode.validators.FancyValidator):
|
||||
messages = {
|
||||
'invalid_path': _(u'This is not a valid path')
|
||||
'invalid_path': _('This is not a valid path')
|
||||
}
|
||||
|
||||
def validate_python(self, value, state):
|
||||
|
|
@ -867,7 +867,7 @@ def UniqSystemEmail(localizer, old_data=None):
|
|||
|
||||
class _validator(formencode.validators.FancyValidator):
|
||||
messages = {
|
||||
'email_taken': _(u'This e-mail address is already taken')
|
||||
'email_taken': _('This e-mail address is already taken')
|
||||
}
|
||||
|
||||
def _to_python(self, value, state):
|
||||
|
|
@ -889,7 +889,7 @@ def ValidSystemEmail(localizer):
|
|||
|
||||
class _validator(formencode.validators.FancyValidator):
|
||||
messages = {
|
||||
'non_existing_email': _(u'e-mail "%(email)s" does not exist.')
|
||||
'non_existing_email': _('e-mail "%(email)s" does not exist.')
|
||||
}
|
||||
|
||||
def _to_python(self, value, state):
|
||||
|
|
@ -910,8 +910,8 @@ def NotReviewedRevisions(localizer, repo_id):
|
|||
class _validator(formencode.validators.FancyValidator):
|
||||
messages = {
|
||||
'rev_already_reviewed':
|
||||
_(u'Revisions %(revs)s are already part of pull request '
|
||||
u'or have set status'),
|
||||
_('Revisions %(revs)s are already part of pull request '
|
||||
'or have set status'),
|
||||
}
|
||||
|
||||
def validate_python(self, value, state):
|
||||
|
|
@ -943,10 +943,10 @@ def ValidIp(localizer):
|
|||
|
||||
class _validator(CIDR):
|
||||
messages = {
|
||||
'badFormat': _(u'Please enter a valid IPv4 or IpV6 address'),
|
||||
'badFormat': _('Please enter a valid IPv4 or IpV6 address'),
|
||||
'illegalBits': _(
|
||||
u'The network size (bits) must be within the range '
|
||||
u'of 0-32 (not %(bits)r)'),
|
||||
'The network size (bits) must be within the range '
|
||||
'of 0-32 (not %(bits)r)'),
|
||||
}
|
||||
|
||||
# we ovveride the default to_python() call
|
||||
|
|
@ -973,8 +973,8 @@ def FieldKey(localizer):
|
|||
class _validator(formencode.validators.FancyValidator):
|
||||
messages = {
|
||||
'badFormat': _(
|
||||
u'Key name can only consist of letters, '
|
||||
u'underscore, dash or numbers'),
|
||||
'Key name can only consist of letters, '
|
||||
'underscore, dash or numbers'),
|
||||
}
|
||||
|
||||
def validate_python(self, value, state):
|
||||
|
|
@ -990,15 +990,15 @@ def ValidAuthPlugins(localizer):
|
|||
class _validator(formencode.validators.FancyValidator):
|
||||
messages = {
|
||||
'import_duplicate': _(
|
||||
u'Plugins %(loaded)s and %(next_to_load)s '
|
||||
u'both export the same name'),
|
||||
'Plugins %(loaded)s and %(next_to_load)s '
|
||||
'both export the same name'),
|
||||
'missing_includeme': _(
|
||||
u'The plugin "%(plugin_id)s" is missing an includeme '
|
||||
u'function.'),
|
||||
'The plugin "%(plugin_id)s" is missing an includeme '
|
||||
'function.'),
|
||||
'import_error': _(
|
||||
u'Can not load plugin "%(plugin_id)s"'),
|
||||
'Can not load plugin "%(plugin_id)s"'),
|
||||
'no_plugin': _(
|
||||
u'No plugin available with ID "%(plugin_id)s"'),
|
||||
'No plugin available with ID "%(plugin_id)s"'),
|
||||
}
|
||||
|
||||
def _to_python(self, value, state):
|
||||
|
|
@ -1065,7 +1065,7 @@ def ValidPattern(localizer):
|
|||
|
||||
class _validator(formencode.validators.FancyValidator):
|
||||
messages = {
|
||||
'bad_format': _(u'Url must start with http or /'),
|
||||
'bad_format': _('Url must start with http or /'),
|
||||
}
|
||||
|
||||
def _to_python(self, value, state):
|
||||
|
|
|
|||
|
|
@ -264,7 +264,7 @@ def write_js_routes_if_enabled(event):
|
|||
registry = event.app.registry
|
||||
|
||||
mapper = registry.queryUtility(IRoutesMapper)
|
||||
_argument_prog = re.compile('\{(.*?)\}|:\((.*)\)')
|
||||
_argument_prog = re.compile(r'\{(.*?)\}|:\((.*)\)')
|
||||
|
||||
def _extract_route_information(route):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -670,7 +670,7 @@ def get_inline_comments(comments, filename):
|
|||
if hasattr(filename, 'unicode_path'):
|
||||
filename = filename.unicode_path
|
||||
|
||||
if not isinstance(filename, (unicode, str)):
|
||||
if not isinstance(filename, str):
|
||||
return None
|
||||
|
||||
if comments and filename in comments:
|
||||
|
|
@ -682,7 +682,7 @@ def get_comments_for(diff_type, comments, filename, line_version, line_number):
|
|||
if hasattr(filename, 'unicode_path'):
|
||||
filename = filename.unicode_path
|
||||
|
||||
if not isinstance(filename, (unicode, str)):
|
||||
if not isinstance(filename, str):
|
||||
return None
|
||||
|
||||
file_comments = get_inline_comments(comments, filename)
|
||||
|
|
|
|||
|
|
@ -17,8 +17,7 @@
|
|||
# This program is dual-licensed. If you wish to learn more about the
|
||||
# RhodeCode Enterprise Edition, including its added features, Support services,
|
||||
# and proprietary license terms, please see https://rhodecode.com/licenses/
|
||||
|
||||
from io import StringIO
|
||||
import io
|
||||
|
||||
import pytest
|
||||
from mock import patch, Mock
|
||||
|
|
@ -104,7 +103,7 @@ class TestSimpleSvn(object):
|
|||
class TestSimpleSvnApp(object):
|
||||
data = '<xml></xml>'
|
||||
path = '/group/my-repo'
|
||||
wsgi_input = StringIO(data)
|
||||
wsgi_input = io.StringIO(data)
|
||||
environment = {
|
||||
'HTTP_DAV': (
|
||||
'http://subversion.tigris.org/xmlns/dav/svn/depth,'
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
import json
|
||||
import logging
|
||||
from io import StringIO
|
||||
import io
|
||||
|
||||
import mock
|
||||
import pytest
|
||||
|
|
@ -320,8 +320,8 @@ class TestPrepareHooksDaemon(object):
|
|||
class MockRequest(object):
|
||||
def __init__(self, request):
|
||||
self.request = request
|
||||
self.input_stream = StringIO(b'{}'.format(self.request))
|
||||
self.output_stream = StringIO()
|
||||
self.input_stream = io.StringIO(b'{}'.format(self.request))
|
||||
self.output_stream = io.StringIO()
|
||||
|
||||
def makefile(self, mode, *args, **kwargs):
|
||||
return self.output_stream if mode == 'wb' else self.input_stream
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import shutil
|
|||
import tarfile
|
||||
import tempfile
|
||||
import zipfile
|
||||
from io import StringIO
|
||||
import io
|
||||
|
||||
import mock
|
||||
import pytest
|
||||
|
|
@ -108,7 +108,7 @@ class TestArchives(BackendTestMixin):
|
|||
|
||||
for x in range(5):
|
||||
node_path = '%d/file_%d.txt' % (x, x)
|
||||
decompressed = StringIO.StringIO()
|
||||
decompressed = io.StringIO()
|
||||
decompressed.write(out.read('repo/' + node_path))
|
||||
assert decompressed.getvalue() == \
|
||||
self.tip.get_node(node_path).content
|
||||
|
|
@ -126,7 +126,7 @@ class TestArchives(BackendTestMixin):
|
|||
|
||||
for x in range(5):
|
||||
node_path = '%d/file_%d.txt' % (x, x)
|
||||
decompressed = StringIO.StringIO()
|
||||
decompressed = io.StringIO()
|
||||
decompressed.write(out.read('repo/' + node_path))
|
||||
assert decompressed.getvalue() == \
|
||||
self.tip.get_node(node_path).content
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue