modernize: updates for python3

This commit is contained in:
RhodeCode Admin 2023-07-18 14:45:20 +02:00
parent a6e9ccf9e0
commit 4bbb30fa06
155 changed files with 232 additions and 455 deletions

View file

@ -1,5 +1,3 @@
# Copyright (C) 2012-2023 RhodeCode GmbH
#
# This program is free software: you can redistribute it and/or modify

View file

@ -1,4 +1,3 @@
# Copyright (C) 2012-2023 RhodeCode GmbH
#
# This program is free software: you can redistribute it and/or modify

View file

@ -1,5 +1,3 @@
# Copyright (C) 2012-2023 RhodeCode GmbH
#
# This program is free software: you can redistribute it and/or modify

View file

@ -1,5 +1,3 @@
# Copyright (C) 2012-2023 RhodeCode GmbH
#
# This program is free software: you can redistribute it and/or modify

View file

@ -1,5 +1,3 @@
# Copyright (C) 2016-2023 RhodeCode GmbH
#
# This program is free software: you can redistribute it and/or modify

View file

@ -1,4 +1,3 @@
# Copyright (C) 2010-2023 RhodeCode GmbH
#
# This program is free software: you can redistribute it and/or modify

View file

@ -1,5 +1,3 @@
# Copyright (C) 2012-2023 RhodeCode GmbH
#
# This program is free software: you can redistribute it and/or modify

View file

@ -1,5 +1,3 @@
# Copyright (C) 2012-2023 RhodeCode GmbH
#
# This program is free software: you can redistribute it and/or modify
@ -43,7 +41,7 @@ class UrlTmpl(string.Template):
def safe_substitute(self, **kws):
# url encode the kw for usage in url
kws = {k: urllib.parse.quote(safe_str(v)) for k, v in kws.items()}
return super(UrlTmpl, self).safe_substitute(**kws)
return super().safe_substitute(**kws)
class IntegrationTypeBase(object):
@ -265,7 +263,7 @@ class WebhookDataHandler(CommitParsingDataHandler):
extra_vars = {}
for extra_key, extra_val in data['repo']['extra_fields'].items():
extra_vars['extra__{}'.format(extra_key)] = extra_val
extra_vars[f'extra__{extra_key}'] = extra_val
common_vars.update(extra_vars)
template_url = self.template_url.replace('${extra:', '${extra__')
@ -388,7 +386,7 @@ class WebhookDataHandler(CommitParsingDataHandler):
return self.pull_request_event_handler(event, data)
else:
raise ValueError(
'event type `{}` has no handler defined'.format(event.__class__))
f'event type `{event.__class__}` has no handler defined')
def get_auth(settings):
@ -408,7 +406,7 @@ def get_url_vars(url_vars):
items = []
for section, section_items in url_vars:
items.append('\n*{}*'.format(section))
items.append(f'\n*{section}*')
for key, explanation in section_items:
items.append(' {} - {}'.format('${' + key + '}', explanation))
return '\n'.join(items)

View file

@ -1,5 +1,3 @@
# Copyright (C) 2012-2023 RhodeCode GmbH
#
# This program is free software: you can redistribute it and/or modify

View file

@ -1,5 +1,3 @@
# Copyright (C) 2012-2023 RhodeCode GmbH
#
# This program is free software: you can redistribute it and/or modify
@ -128,7 +126,7 @@ class HipchatIntegrationType(IntegrationTypeBase, CommitParsingDataHandler):
data = event.as_dict()
text = '<b>%s<b> caused a <b>%s</b> event' % (
text = '<b>{}<b> caused a <b>{}</b> event'.format(
data['actor']['username'], event.name)
if isinstance(event, events.PullRequestCommentEvent):

View file

@ -1,5 +1,3 @@
# Copyright (C) 2012-2023 RhodeCode GmbH
#
# This program is free software: you can redistribute it and/or modify

View file

@ -1,5 +1,3 @@
# Copyright (C) 2012-2023 RhodeCode GmbH
#
# This program is free software: you can redistribute it and/or modify
@ -235,7 +233,7 @@ def post_to_webhook(url_calls, settings):
"""
call_headers = {
'User-Agent': 'RhodeCode-webhook-caller/{}'.format(rhodecode.__version__)
'User-Agent': f'RhodeCode-webhook-caller/{rhodecode.__version__}'
} # updated below with custom ones, allows override
auth = get_auth(settings)

View file

@ -1,5 +1,3 @@
# Copyright (C) 2012-2023 RhodeCode GmbH
#
# This program is free software: you can redistribute it and/or modify
@ -48,7 +46,7 @@ class IntegrationSettingsViewBase(BaseAppView):
"""
def __init__(self, context, request):
super(IntegrationSettingsViewBase, self).__init__(context, request)
super().__init__(context, request)
self._load_view_context()
def _load_view_context(self):
@ -112,7 +110,7 @@ class IntegrationSettingsViewBase(BaseAppView):
def _get_local_tmpl_context(self, include_app_defaults=True):
_ = self.request.translate
c = super(IntegrationSettingsViewBase, self)._get_local_tmpl_context(
c = super()._get_local_tmpl_context(
include_app_defaults=include_app_defaults)
c.active = 'integrations'