diff options
author | elie <elie> | 2009-08-29 08:09:10 +0000 |
---|---|---|
committer | elie <elie> | 2009-08-29 08:09:10 +0000 |
commit | 8c56fe3183fe277a5fe3ae8011d916fce213811d (patch) | |
tree | 8c34eb76c765cfd53fa234d7280526963b7f9064 | |
parent | 4e8c2fb8ca31d15da79d68cd27c145be2ee19d82 (diff) | |
download | pysnmp-8c56fe3183fe277a5fe3ae8011d916fce213811d.tar.gz |
fix to build constraints of more than 256 items (Python has a limit
on the number of function params)
-rw-r--r-- | tools/libsmi2pysnmp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/tools/libsmi2pysnmp b/tools/libsmi2pysnmp index 276aceb..7be8cee 100644 --- a/tools/libsmi2pysnmp +++ b/tools/libsmi2pysnmp @@ -198,13 +198,23 @@ def __genTypeDef((symName, symDef), classMode=0): r = r + ', %s()' % parentType if baseType == 'Enumeration': if classMode: - r = r + 'subtypeSpec = %s.subtypeSpec+constraint.SingleValueConstraint(' % parentType + r = r + 'subtypeSpec = %s.subtypeSpec+' % parentType else: - r = r + '.subtype(subtypeSpec=constraint.SingleValueConstraint(' + r = r + '.subtype(subtypeSpec=' + # Python has certain limit on the number of func params + if len(typeDef) > 127: + r = r + 'constraint.ConstraintsUnion(' + r = r + 'constraint.SingleValueConstraint(' + cnt = 1 for e, v in typeDef.items(): if type(v) == DictType and v.has_key('nodetype') \ and v['nodetype'] == 'namednumber': r = r + '%s,' % v['number'] + if cnt % 127 == 0: + r = r + '), constraint.SingleValueConstraint(' + cnt = cnt + 1 + if len(typeDef) > 127: + r = r + ')' if classMode: r = r + ')\n' r = r + identFiller*identValue @@ -216,10 +226,14 @@ def __genTypeDef((symName, symDef), classMode=0): r = r + '.subtype(namedValues=namedval.NamedValues(' typedesc = typeDef.items() typedesc.sort(lambda x,y: cmp(x[1],y[1])) + cnt = 1 for e, v in typedesc: if type(v) == DictType and v.has_key('nodetype') \ and v['nodetype'] == 'namednumber': r = r + '(\"%s\", %s), ' % (e, v['number']) + if cnt % 127 == 0: + r = r + ') + namedval.NamedValues(' + cnt = cnt + 1 if classMode: r = r + ')\n' r = r + identFiller*identValue |