Fix unit test with property name sanitize.
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="propertyName">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Name of property.</p></body></html></string>
|
||||
<string><html><head/><body><p>Name of property. Can only contain letters, numbers, and underscores. MixedCase names will display with spaces &quot;Mixed Case&quot;</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
import FreeCAD
|
||||
import PySide
|
||||
import re
|
||||
|
||||
__title__ = 'Generic property container to store some values.'
|
||||
__author__ = 'sliptonic (Brad Collette)'
|
||||
@@ -70,7 +71,7 @@ class PropertyBag(object):
|
||||
def __sanitizePropertyName(self, name):
|
||||
if(len(name) == 0):
|
||||
return
|
||||
clean = name[0].lower()
|
||||
clean = name[0]
|
||||
for i in range(1, len(name)):
|
||||
if (name[i] == ' '):
|
||||
clean += name[i + 1].upper()
|
||||
@@ -96,6 +97,8 @@ class PropertyBag(object):
|
||||
groups = self.obj.CustomPropertyGroups
|
||||
|
||||
name = self.__sanitizePropertyName(name)
|
||||
if not re.match("^[A-Za-z0-9_]*$", name):
|
||||
raise ValueError('Property Name can only contain letters and numbers')
|
||||
|
||||
if not group in groups:
|
||||
groups.append(group)
|
||||
|
||||
@@ -22,12 +22,13 @@
|
||||
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
import PathGui
|
||||
#import PathGui
|
||||
import PathScripts.PathIconViewProvider as PathIconViewProvider
|
||||
import PathScripts.PathLog as PathLog
|
||||
import PathScripts.PathPropertyBag as PathPropertyBag
|
||||
import PathScripts.PathPropertyEditor as PathPropertyEditor
|
||||
import PathScripts.PathUtil as PathUtil
|
||||
import re
|
||||
|
||||
from PySide import QtCore, QtGui
|
||||
|
||||
@@ -153,6 +154,7 @@ class PropertyCreate(object):
|
||||
self.form.propertyEnum.textChanged.connect(self.updateUI)
|
||||
|
||||
def updateUI(self):
|
||||
|
||||
typeSet = True
|
||||
if self.propertyIsEnumeration():
|
||||
self.form.labelEnum.setEnabled(True)
|
||||
@@ -166,7 +168,10 @@ class PropertyCreate(object):
|
||||
|
||||
ok = self.form.buttonBox.button(QtGui.QDialogButtonBox.Ok)
|
||||
|
||||
if typeSet and self.propertyName() and self.propertyGroup():
|
||||
if not re.match("^[A-Za-z0-9_]*$", self.form.propertyName.text()):
|
||||
typeSet = False
|
||||
|
||||
if typeSet and self.propertyGroup():
|
||||
ok.setEnabled(True)
|
||||
else:
|
||||
ok.setEnabled(False)
|
||||
|
||||
Reference in New Issue
Block a user