Changeset - 624971c4d246
[Not reviewed]
default
0 2 0
Thomas De Schampheleire - 6 years ago 2019-06-16 20:16:44
thomas.de_schampheleire@nokia.com
Grafted from: ef6da19dbf56
setup: bump formencode minimum version to 1.3.0

The formencode version range included both 1.2.x and 1.3.x releases.
However, since 1.3.0, _to_python and validate_python are deprecated and
renamed to _convert_to_python and _validate_python, respectively.

With current pytest, these (long) deprecation warnings are shown in the test
logs.

There are two options:
- restrict maximum version to 1.2.x
- bump minimum version to 1.3.x

In this commit we choose the latter approach, going towards the future
rather than the past.
2 files changed with 34 insertions and 34 deletions:
0 comments (0 inline, 0 general)
kallithea/model/validators.py
Show inline comments
 
@@ -55,7 +55,7 @@ def UniqueListFromString():
 
            missing_value=_('Value cannot be an empty list'),
 
        )
 

	
 
        def _to_python(self, value, state):
 
        def _convert_to_python(self, value, state):
 
            value = aslist(value, ',')
 
            seen = set()
 
            return [c for c in value if not (c in seen or seen.add(c))]
 
@@ -80,7 +80,7 @@ def ValidUsername(edit=False, old_data=N
 
                  'alphanumeric character or underscore')
 
        }
 

	
 
        def validate_python(self, value, state):
 
        def _validate_python(self, value, state):
 
            if value in ['default', 'new_user']:
 
                msg = self.message('system_invalid_username', state, username=value)
 
                raise formencode.Invalid(msg, value, state)
 
@@ -112,7 +112,7 @@ def ValidRepoUser():
 
            'invalid_username': _('Username %(username)s is not valid')
 
        }
 

	
 
        def validate_python(self, value, state):
 
        def _validate_python(self, value, state):
 
            try:
 
                User.query().filter(User.active == True) \
 
                    .filter(User.username == value).one()
 
@@ -138,7 +138,7 @@ def ValidUserGroup(edit=False, old_data=
 
                  'with alphanumeric character')
 
        }
 

	
 
        def validate_python(self, value, state):
 
        def _validate_python(self, value, state):
 
            if value in ['default']:
 
                msg = self.message('invalid_group', state)
 
                raise formencode.Invalid(msg, value, state,
 
@@ -179,7 +179,7 @@ def ValidRepoGroup(edit=False, old_data=
 
                _('Repository with name "%(group_name)s" already exists')
 
        }
 

	
 
        def validate_python(self, value, state):
 
        def _validate_python(self, value, state):
 
            # TODO WRITE VALIDATIONS
 
            group_name = value.get('group_name')
 
            parent_group_id = value.get('parent_group_id')
 
@@ -235,7 +235,7 @@ def ValidPassword():
 
                _('Invalid characters (non-ascii) in password')
 
        }
 

	
 
        def validate_python(self, value, state):
 
        def _validate_python(self, value, state):
 
            try:
 
                (value or '').decode('ascii')
 
            except UnicodeError:
 
@@ -250,7 +250,7 @@ def ValidOldPassword(username):
 
            'invalid_password': _('Invalid old password')
 
        }
 

	
 
        def validate_python(self, value, state):
 
        def _validate_python(self, value, state):
 
            from kallithea.lib import auth_modules
 
            if auth_modules.authenticate(username, value, '') is None:
 
                msg = self.message('invalid_password', state)
 
@@ -266,7 +266,7 @@ def ValidPasswordsMatch(password_field, 
 
            'password_mismatch': _('Passwords do not match'),
 
        }
 

	
 
        def validate_python(self, value, state):
 
        def _validate_python(self, value, state):
 
            if value.get(password_field) != value[password_confirmation_field]:
 
                msg = self.message('password_mismatch', state)
 
                raise formencode.Invalid(msg, value, state,
 
@@ -281,7 +281,7 @@ def ValidAuth():
 
            'invalid_auth': _(u'Invalid username or password'),
 
        }
 

	
 
        def validate_python(self, value, state):
 
        def _validate_python(self, value, state):
 
            from kallithea.lib import auth_modules
 

	
 
            password = value['password']
 
@@ -312,7 +312,7 @@ def ValidAuthToken():
 
            'invalid_token': _('Token mismatch')
 
        }
 

	
 
        def validate_python(self, value, state):
 
        def _validate_python(self, value, state):
 
            if value != authentication_token():
 
                msg = self.message('invalid_token', state)
 
                raise formencode.Invalid(msg, value, state)
 
@@ -334,7 +334,7 @@ def ValidRepoName(edit=False, old_data=N
 
                                   'already exists')
 
        }
 

	
 
        def _to_python(self, value, state):
 
        def _convert_to_python(self, value, state):
 
            repo_name = repo_name_slug(value.get('repo_name', ''))
 
            repo_group = value.get('repo_group')
 
            if repo_group:
 
@@ -355,7 +355,7 @@ def ValidRepoName(edit=False, old_data=N
 
            value['group_name'] = group_name
 
            return value
 

	
 
        def validate_python(self, value, state):
 
        def _validate_python(self, value, state):
 
            repo_name = value.get('repo_name')
 
            repo_name_full = value.get('repo_name_full')
 
            group_path = value.get('group_path')
 
@@ -402,10 +402,10 @@ def ValidForkName(*args, **kwargs):
 
def SlugifyName():
 
    class _validator(formencode.validators.FancyValidator):
 

	
 
        def _to_python(self, value, state):
 
        def _convert_to_python(self, value, state):
 
            return repo_name_slug(value)
 

	
 
        def validate_python(self, value, state):
 
        def _validate_python(self, value, state):
 
            pass
 

	
 
    return _validator
 
@@ -421,7 +421,7 @@ def ValidCloneUri():
 
                                   'valid http, https, ssh, svn+http or svn+https URL'),
 
        }
 

	
 
        def validate_python(self, value, state):
 
        def _validate_python(self, value, state):
 
            repo_type = value.get('repo_type')
 
            url = value.get('clone_uri')
 

	
 
@@ -445,7 +445,7 @@ def ValidForkType(old_data=None):
 
            'invalid_fork_type': _('Fork has to be the same type as parent')
 
        }
 

	
 
        def validate_python(self, value, state):
 
        def _validate_python(self, value, state):
 
            if old_data['repo_type'] != value:
 
                msg = self.message('invalid_fork_type', state)
 
                raise formencode.Invalid(msg, value, state,
 
@@ -463,13 +463,13 @@ def CanWriteGroup(old_data=None):
 
                                        "in root location")
 
        }
 

	
 
        def _to_python(self, value, state):
 
        def _convert_to_python(self, value, state):
 
            # root location
 
            if value == -1:
 
                return None
 
            return value
 

	
 
        def validate_python(self, value, state):
 
        def _validate_python(self, value, state):
 
            gr = RepoGroup.get(value)
 
            gr_name = gr.group_name if gr is not None else None # None means ROOT location
 

	
 
@@ -519,7 +519,7 @@ def CanCreateGroup(can_create_in_root=Fa
 
                return None
 
            return value
 

	
 
        def validate_python(self, value, state):
 
        def _validate_python(self, value, state):
 
            gr = RepoGroup.get(value)
 
            gr_name = gr.group_name if gr is not None else None # None means ROOT location
 

	
 
@@ -619,7 +619,7 @@ def ValidPerms(type_='repo'):
 

	
 
def ValidSettings():
 
    class _validator(formencode.validators.FancyValidator):
 
        def _to_python(self, value, state):
 
        def _convert_to_python(self, value, state):
 
            # settings  form for users that are not admin
 
            # can't edit certain parameters, it's extra backup if they mangle
 
            # with forms
 
@@ -634,7 +634,7 @@ def ValidSettings():
 
                    del value[param]
 
            return value
 

	
 
        def validate_python(self, value, state):
 
        def _validate_python(self, value, state):
 
            pass
 
    return _validator
 

	
 
@@ -645,7 +645,7 @@ def ValidPath():
 
            'invalid_path': _('This is not a valid path')
 
        }
 

	
 
        def validate_python(self, value, state):
 
        def _validate_python(self, value, state):
 
            if not os.path.isdir(value):
 
                msg = self.message('invalid_path', state)
 
                raise formencode.Invalid(msg, value, state,
 
@@ -662,10 +662,10 @@ def UniqSystemEmail(old_data=None):
 
            'email_taken': _('This email address is already in use')
 
        }
 

	
 
        def _to_python(self, value, state):
 
        def _convert_to_python(self, value, state):
 
            return value.lower()
 

	
 
        def validate_python(self, value, state):
 
        def _validate_python(self, value, state):
 
            if (old_data.get('email') or '').lower() != value:
 
                user = User.get_by_email(value)
 
                if user is not None:
 
@@ -682,10 +682,10 @@ def ValidSystemEmail():
 
            'non_existing_email': _('Email address "%(email)s" not found')
 
        }
 

	
 
        def _to_python(self, value, state):
 
        def _convert_to_python(self, value, state):
 
            return value.lower()
 

	
 
        def validate_python(self, value, state):
 
        def _validate_python(self, value, state):
 
            user = User.get_by_email(value)
 
            if user is None:
 
                msg = self.message('non_existing_email', state, email=value)
 
@@ -702,7 +702,7 @@ def LdapLibValidator():
 

	
 
        }
 

	
 
        def validate_python(self, value, state):
 
        def _validate_python(self, value, state):
 
            try:
 
                import ldap
 
                ldap  # pyflakes silence !
 
@@ -747,7 +747,7 @@ def ValidIp():
 
                    v += '/128'
 
            return v
 

	
 
        def validate_python(self, value, state):
 
        def _validate_python(self, value, state):
 
            try:
 
                addr = value.strip()
 
                # this raises an ValueError if address is not IPv4 or IPv6
 
@@ -766,7 +766,7 @@ def FieldKey():
 
                        'underscore, dash or numbers')
 
        )
 

	
 
        def validate_python(self, value, state):
 
        def _validate_python(self, value, state):
 
            if not re.match('[a-zA-Z0-9_-]+$', value):
 
                raise formencode.Invalid(self.message('badFormat', state),
 
                                         value, state)
 
@@ -779,10 +779,10 @@ def BasePath():
 
            badPath=_('Filename cannot be inside a directory')
 
        )
 

	
 
        def _to_python(self, value, state):
 
        def _convert_to_python(self, value, state):
 
            return value
 

	
 
        def validate_python(self, value, state):
 
        def _validate_python(self, value, state):
 
            if value != os.path.basename(value):
 
                raise formencode.Invalid(self.message('badPath', state),
 
                                         value, state)
 
@@ -795,11 +795,11 @@ def ValidAuthPlugins():
 
            import_duplicate=_('Plugins %(loaded)s and %(next_to_load)s both export the same name')
 
        )
 

	
 
        def _to_python(self, value, state):
 
        def _convert_to_python(self, value, state):
 
            # filter empty values
 
            return filter(lambda s: s not in [None, ''], value)
 

	
 
        def validate_python(self, value, state):
 
        def _validate_python(self, value, state):
 
            from kallithea.lib import auth_modules
 
            module_list = value
 
            unique_names = {}
setup.py
Show inline comments
 
@@ -44,7 +44,7 @@ requirements = [
 
    "tgext.routes >= 0.2.0, < 1",
 
    "Beaker >= 1.7.0, < 2",
 
    "WebHelpers >= 1.3, < 1.4",
 
    "FormEncode >= 1.2.4, < 1.4",
 
    "FormEncode >= 1.3.0, < 1.4",
 
    "SQLAlchemy >= 1.1, < 1.4",
 
    "Mako >= 0.9.0, < 1.1",
 
    "Pygments >= 2.0, < 2.5",
0 comments (0 inline, 0 general)