Addon Manager: Refactor Licenses and People tables
This commit is contained in:
@@ -30,6 +30,7 @@ from PySide2.QtGui import (
|
||||
)
|
||||
from PySide2.QtCore import QRegularExpression
|
||||
|
||||
|
||||
def isidentifier(ident: str) -> bool:
|
||||
|
||||
if not ident.isidentifier():
|
||||
@@ -40,6 +41,7 @@ def isidentifier(ident: str) -> bool:
|
||||
|
||||
return True
|
||||
|
||||
|
||||
class NameValidator(QValidator):
|
||||
"""Simple validator to exclude characters that are not valid in filenames."""
|
||||
|
||||
@@ -62,18 +64,20 @@ class NameValidator(QValidator):
|
||||
|
||||
|
||||
class PythonIdentifierValidator(QValidator):
|
||||
""" Validates whether input is a valid Python identifier. """
|
||||
"""Validates whether input is a valid Python identifier."""
|
||||
|
||||
def validate(self, value: str, _: int):
|
||||
if not value:
|
||||
return QValidator.Intermediate
|
||||
|
||||
if not value.isidentifier():
|
||||
return QValidator.Invalid # Includes an illegal character of some sort
|
||||
return QValidator.Invalid # Includes an illegal character of some sort
|
||||
|
||||
if keyword.iskeyword(value):
|
||||
return QValidator.Intermediate # They can keep typing and it might become valid
|
||||
|
||||
return (
|
||||
QValidator.Intermediate
|
||||
) # They can keep typing and it might become valid
|
||||
|
||||
return QValidator.Acceptable
|
||||
|
||||
|
||||
@@ -142,4 +146,4 @@ class VersionValidator(QValidator):
|
||||
return semver_result
|
||||
if calver_result[0] == QValidator.Intermediate:
|
||||
return calver_result
|
||||
return (QValidator.Invalid, value, position)
|
||||
return (QValidator.Invalid, value, position)
|
||||
|
||||
Reference in New Issue
Block a user