# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (the "License"). You may not use this file except in compliance
# with the License.
#
# You can obtain a copy of the license at
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at
# trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
# add the following below this CDDL HEADER, with the fields enclosed
# information:
# Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2009 Sun Microsystems, Inc.
# Global variable containing the list of servers ("Server" class instances) deployed
# Define ChangelogServer class
class OIDDict:
"""OIDDict is a dictionary class that help lookup OID <-> litteral name
of both objeclasses, and attributtypes"""
"""given a schema entry definition for objectclass/attributtype
return the tuple (OID,List of names)
the List of aliases starts from list of names[1:] when exist. for ex :
attributeTypes: ( 2.5.4.4 NAME ( 'sn' 'surname' ) SUP name X-ORIGIN 'RFC 4519' )
(2.5.4.4,['sn','surname']
"""
# populate the NAME to OID : "dict" dictionary
if NAMES:
# TODO encoded schema is not handled for now
# TODO encoded schema is not handled for now
# populate SUP and MUST / MAY, : "sup", "may", "must" dictionaries
if r:
if r:
for m in r:
if r:
for m in r:
"""extract a list of attributes for a given myStr section.
The section should contain () when multivalued.
If another section comes after it starts with a Upercase.
example MUST (sn cn) MAY ( description ... )
line : line to parse
myStr : name of the section ex(MAY)
right : right boundary,
if None, function will figure out end of section"""
if left == -1:
return None
if not right:
if lpNdx > 0:
else:
else:
realStrs = []
if len(s) > 0:
if s[0] >= 'A' and s[0] <= 'Z':
break
elif s[0] != '$' and s[0] != '|':
if s[0] == '\'' and s[-1] == '\'':
s = s[1:-1]
return realStrs
"""will return the attributes the objectclassname MUST implement"""
else:
ret = []
# avoiding duplication of MUSTs
return ret
"""will return the attributes the objectclassname MAY implement"""
else:
ret = []
# avoiding duplication of MAYs
return ret
"""will return the objectclassname that this objectclassname inherit"""
if objectclassname == 'top':
return None
else:
return ret[0]
hierachy = []
while up:
return hierachy
"""get the schema as a string
and attributetypes only."""
lines=[]
line=''
for f in ref_content.splitlines():
not (f.startswith("objectClasses") or \
f.startswith("attributeTypes")):
# not handled for now
continue
# line continuation aggregated into 'line'
line += f[1:]
# populate the OID <-> Names dictionary
line = f[:-1]
line = f
# parsing the last line
f.close()
if __name__ == '__main__':
"""get example schema.ldif file with :
ldapsearch -b 'cn=schema' -Dcn=directory\ manager -s base -wpassword objectclass=* objectClasses attributeTypes > /tmp/schema.ldif
"""
f.close()
print "%s\t%s"%(k,v)
print "%s\t%s"%(k,v)
print "%s\t%s"%(k,v)
print "%s\t%s"%(k,v)
print "%s\t%s"%(k,v)
try:
except Exception, e:
print e.message
mustSize = 0
maySize = 0