Commit d4730068 authored by De Boissieu Florian's avatar De Boissieu Florian

add check in add method for list childs

--HG--
branch : settersOptions
parent 189a8189
......@@ -4782,26 +4782,31 @@ def generateGettersAndSetters(wrt, prefix, element):
wrt(' self.%s = value\n' % (varname))
# if PostSetter is not None:
# wrt(' if value is not None:\n')
# wrt(' %s\n' % (PostSetter))
# if PostChildSetter is not None:
# wrt('%s\n' % (indent(PostChildSetter,2)))
if child.getMaxOccurs() > 1:
wrt(' def add%s(self, value):\n' % (capName))
if child.getMaxOccurs() != 99999:
wrt(' if (value is not None) and (len(self.{}) == {}):\n'.format(varname, child.getMaxOccurs()))
wrt(" raise ValueError('Maximum length already reached.')\n")
wrt(' value.parent = self\n')
wrt(' self.%s.append(value)\n' % (varname))
# if PostSetter is not None:
# wrt(' %s\n' % (PostSetter))
if PostChildSetter is not None:
wrt('%s\n' % (indent(PostChildSetter,2)))
suffix = make_gs_name('at')
wrt(' def insert%s%s(self, index, value):\n' % (capName, suffix))
wrt(' self.%s.insert(index, value)\n' % (name))
if child.getMaxOccurs() != 99999:
wrt(' if (value is not None) and (len(self.{}) == {}):\n'.format(varname, child.getMaxOccurs()))
wrt(" raise ValueError('Maximum length already reached.')\n")
wrt(' value.parent = self\n')
# if PostSetter is not None:
# wrt(' %s\n' % (PostSetter))
wrt(' self.%s.insert(index, value)\n' % (name))
if PostChildSetter is not None:
wrt('%s\n' % (indent(PostChildSetter,2)))
wrt(' def replace%s%s(self, index, value):\n' % (capName, suffix))
wrt(' value.parent = self\n')
wrt(' self.%s[index] = value\n' % (name))
# if PostSetter is not None:
# wrt('%s\n' % (indent(PostSetter,2)))
if PostChildSetter is not None:
wrt('%s\n' % (indent(PostChildSetter,2)))
if GenerateProperties:
# wrt(' %sProp = property(get%s, set%s)\n' %
# (unmappedName, capName, capName))
......@@ -4821,8 +4826,8 @@ def generateGettersAndSetters(wrt, prefix, element):
wrt(' def set%s(self, value):\n' % (
gsName,))
wrt(' self.%s = value\n' %(varname))
if PostSetter is not None:
wrt('%s\n' % (indent(PostSetter, 2)))
if PostAttribSetter is not None:
wrt('%s\n' % (indent(PostAttribSetter, 2)))
if GenerateProperties:
# wrt(' %sProp = property(get%s, set%s)\n' %
# (name, gsName, gsName))
......@@ -7380,7 +7385,7 @@ def main():
PreserveCdataTags, CleanupNameList, \
NoWarnings, AlwaysExportDefault, \
UppercaseEnums, CreateMandatoryChildren, \
PostSetter, PreCtor, PostCtor, \
PostAttribSetter, PostChildSetter, PreCtor, PostCtor, \
HeadImports
outputText = True
args = sys.argv[1:]
......@@ -7404,8 +7409,8 @@ def main():
'no-warnings',
'no-collect-includes', 'no-redefine-groups',
'always-export-default', 'mixed-case-enums',
'create-mandatory-children', 'post-setter=',
'pre-ctor=', 'post-ctor=', 'imports='
'create-mandatory-children', 'post-attrib-setter=',
'post-child-setter=', 'pre-ctor=', 'post-ctor=', 'imports='
])
except getopt.GetoptError:
usage()
......@@ -7430,7 +7435,8 @@ def main():
noRedefineGroups = False
UppercaseEnums = True
CreateMandatoryChildren = False
PostSetter = None
PostAttribSetter = None
PostChildSetter = None
PreCtor = None
PostCtor = None
HeadImports = ''
......@@ -7621,8 +7627,10 @@ def main():
UppercaseEnums = False
elif option[0] == '--create-mandatory-children':
CreateMandatoryChildren = True
elif option[0] == '--post-setter':
PostSetter = option[1]
elif option[0] == '--post-attrib-setter':
PostAttribSetter = option[1]
elif option[0] == '--post-child-setter':
PostAttribSetter = option[1]
elif option[0] == '--pre-ctor':
PreCtor = option[1]
elif option[0] == '--post-ctor':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment