<s> """<STR_LIT>""" <EOL> import os <EOL> import re <EOL> import sys <EOL> import json <EOL> import locale <EOL> import zipfile <EOL> import logging <EOL> import textwrap <EOL> import validictory <EOL> from . sharedtypes import JSONEncoder <EOL> from ilorest . rest . v1_helper import ( RisObject ) <EOL> LOGGER = logging . getLogger ( __name__ ) <EOL> class ValidationError ( Exception ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> class SchemaValidationError ( ValidationError ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> class RegistryValidationError ( ValidationError ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , msg , regentry = None , selector = None ) : <EOL> super ( RegistryValidationError , self ) . __init__ ( msg ) <EOL> self . reg = regentry <EOL> self . sel = selector <EOL> class UnknownValidatorError ( Exception ) : <EOL> """<STR_LIT>""" <EOL> """<STR_LIT>""" <EOL> class ValidationManager ( object ) : <EOL> """<STR_LIT>""" <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , local_path , bios_local_path , romfamily = None , biosversion = None , iloversion = None , monolith = None ) : <EOL> super ( ValidationManager , self ) . __init__ ( ) <EOL> defaultilopath = None <EOL> defaultbiospath = None <EOL> schemamainfolder = None <EOL> if float ( iloversion ) < <NUM_LIT> : <EOL> if os . name == '<STR_LIT>' : <EOL> defaultilopath = r"<STR_LIT>" <EOL> defaultbiospath = r"<STR_LIT>" <EOL> schemamainfolder = os . path . dirname ( sys . executable ) <EOL> else : <EOL> defaultilopath = "<STR_LIT>" <EOL> defaultbiospath = "<STR_LIT>" <EOL> schemamainfolder = "<STR_LIT>" <EOL> if not local_path : <EOL> if not os . path . isdir ( defaultilopath ) : <EOL> ilozip = self . getiloziplocation ( schemamainfolder , iloversion ) <EOL> if ilozip and os . path . exists ( ilozip ) : <EOL> with zipfile . ZipFile ( os . path . join ( schemamainfolder , ilozip ) , "<STR_LIT:r>" ) as zfile : <EOL> zfile . extractall ( os . path . join ( schemamainfolder , "<STR_LIT>" ) ) <EOL> local_path = os . path . join ( schemamainfolder , u'<STR_LIT>' ) <EOL> else : <EOL> raise SchemaValidationError ( u'<STR_LIT>' '<STR_LIT>' '<STR_LIT>' '<STR_LIT>' ) <EOL> else : <EOL> local_path = defaultilopath <EOL> else : <EOL> if not os . path . isdir ( local_path ) : <EOL> raise SchemaValidationError ( u"<STR_LIT>" <EOL> "<STR_LIT>" % local_path ) <EOL> if not bios_local_path : <EOL> if not os . path . isdir ( defaultbiospath ) : <EOL> bioszip = self . getbiosziplocation ( romfamily , schemamainfolder , biosversion ) <EOL> if bioszip and os . path . exists ( bioszip ) : <EOL> with zipfile . ZipFile ( <EOL> os . path . join ( schemamainfolder , bioszip ) , "<STR_LIT:r>" ) as zfile : <EOL> zfile . extractall ( os . path . join ( schemamainfolder , "<STR_LIT>" ) ) <EOL> bios_local_path = os . path . join ( schemamainfolder , u'<STR_LIT>' ) <EOL> else : <EOL> raise SchemaValidationError ( u'<STR_LIT>' '<STR_LIT>' '<STR_LIT>' '<STR_LIT>' ) <EOL> else : <EOL> bios_local_path = defaultbiospath <EOL> else : <EOL> if not os . path . isdir ( bios_local_path ) : <EOL> raise SchemaValidationError ( u"<STR_LIT>" "<STR_LIT>" % bios_local_path ) <EOL> else : <EOL> if monolith . is_redfish : <EOL> local_path = "<STR_LIT>" <EOL> bios_local_path = "<STR_LIT>" <EOL> else : <EOL> local_path = "<STR_LIT>" <EOL> bios_local_path = "<STR_LIT>" <EOL> self . _schema_locations = list ( ) <EOL> self . _classes = list ( ) <EOL> self . _registry_locations = list ( ) <EOL> self . _classes_registry = list ( ) <EOL> self . _bios_schema_locations = list ( ) <EOL> self . _bios_classes = list ( ) <EOL> self . _bios_registry_locations = list ( ) <EOL> self . _bios_classes_registry = list ( ) <EOL> self . _ilo_messages = list ( ) <EOL> self . _base_messages = list ( ) <EOL> self . _hpcommon_messages = list ( ) <EOL> self . _iloevents_messages = list ( ) <EOL> self . _errors = list ( ) <EOL> if monolith . is_redfish : <EOL> self . _schemaid = [ "<STR_LIT>" , "<STR_LIT>" ] <EOL> self . _regid = [ "<STR_LIT>" , "<STR_LIT>" ] <EOL> else : <EOL> self . _schemaid = [ "<STR_LIT>" , "<STR_LIT>" ] <EOL> self . _regid = [ "<STR_LIT>" , "<STR_LIT>" ] <EOL> if local_path : <EOL> self . add_location ( schema_path = local_path , monolith = monolith ) <EOL> self . add_location ( registry_path = local_path , monolith = monolith ) <EOL> if bios_local_path : <EOL> self . add_location ( schema_path = bios_local_path , biossection = True , monolith = monolith ) <EOL> self . add_location ( registry_path = bios_local_path , biossection = True , monolith = monolith ) <EOL> def getbiosziplocation ( self , romfamily , schemadir , biosversion ) : <EOL> """<STR_LIT>""" <EOL> foundfile = None <EOL> currentver = None <EOL> tempstr = "<STR_LIT>" + romfamily + "<STR_LIT:->" + biosversion <EOL> for _ , _ , filenames in os . walk ( schemadir ) : <EOL> for filename in filenames : <EOL> if tempstr in filename : <EOL> regentry = re . compile ( '<STR_LIT>' % tempstr ) <EOL> mentry = regentry . search ( filename ) <EOL> if mentry and currentver : <EOL> if currentver < mentry . group ( <NUM_LIT:1> ) : <EOL> foundfile = filename <EOL> currentver = mentry . group ( <NUM_LIT:1> ) <EOL> elif mentry and not currentver : <EOL> foundfile = filename <EOL> currentver = mentry . group ( <NUM_LIT:1> ) <EOL> if foundfile : <EOL> return os . path . join ( schemadir , foundfile ) <EOL> else : <EOL> return None <EOL> def getiloziplocation ( self , schemadir , iloversion ) : <EOL> """<STR_LIT>""" <EOL> if float ( iloversion ) < <NUM_LIT> : <EOL> iloversion = u'<STR_LIT>' <EOL> tempstr = "<STR_LIT>" + iloversion . replace ( "<STR_LIT:.>" , "<STR_LIT>" ) <EOL> for _ , _ , filenames in os . walk ( schemadir ) : <EOL> for filename in filenames : <EOL> if tempstr in filename : <EOL> return os . path . join ( schemadir , filename ) <EOL> return None <EOL> def add_location ( self , schema_path = None , registry_path = None , <EOL> biossection = False , monolith = None ) : <EOL> """<STR_LIT>""" <EOL> """<STR_LIT>""" <EOL> if schema_path : <EOL> if not biossection : <EOL> self . _schema_locations . append ( schema_path ) <EOL> self . _update_location_map ( monolith = monolith ) <EOL> else : <EOL> self . _bios_schema_locations . append ( schema_path ) <EOL> self . _update_location_map ( biossection = True , monolith = monolith ) <EOL> elif registry_path : <EOL> if not biossection : <EOL> self . _registry_locations . append ( registry_path ) <EOL> self . _update_location_map ( registries = True , monolith = monolith ) <EOL> else : <EOL> self . _bios_registry_locations . append ( registry_path ) <EOL> self . _update_location_map ( biossection = True , registries = True , monolith = monolith ) <EOL> else : <EOL> raise ValueError ( u"<STR_LIT>" "<STR_LIT>" ) <EOL> def _update_location_map ( self , biossection = False , registries = False , <EOL> monolith = None ) : <EOL> """<STR_LIT>""" <EOL> locationslist = list ( ) <EOL> pathjoinstr = None <EOL> if not registries : <EOL> pathjoinstr = "<STR_LIT>" <EOL> if not biossection : <EOL> locationslist = self . _schema_locations <EOL> else : <EOL> locationslist = self . _bios_schema_locations <EOL> else : <EOL> pathjoinstr = "<STR_LIT>" <EOL> if not biossection : <EOL> locationslist = self . _registry_locations <EOL> else : <EOL> locationslist = self . _bios_registry_locations <EOL> for location in locationslist : <EOL> if monolith : <EOL> self . new_load_file ( monolith , root = location , biossection = biossection , registries = registries ) <EOL> elif self . _is_local ( location ) : <EOL> for root , _ , filenames in os . walk ( os . path . join ( location , <EOL> pathjoinstr ) ) : <EOL> for filename in filenames : <EOL> fqpath = os . path . abspath ( os . path . join ( os . path . normpath ( root ) , filename ) ) <EOL> if self . load_file ( fqpath , root = location , biossection = biossection , registries = registries ) : <EOL> LOGGER . info ( "<STR_LIT>" , fqpath ) <EOL> def new_load_file ( self , monolith , root = None , biossection = False , registries = False ) : <EOL> """<STR_LIT>""" <EOL> classesdataholder = [ ] <EOL> for itemtype in monolith . types : <EOL> if itemtype . startswith ( "<STR_LIT>" ) or itemtype . startswith ( "<STR_LIT>" ) and u'<STR_LIT>' in monolith . types [ itemtype ] : <EOL> for instance in monolith . types [ itemtype ] [ u'<STR_LIT>' ] : <EOL> if self . _schemaid [ <NUM_LIT:0> ] in instance . resp . request . path . lower ( ) or self . _regid [ <NUM_LIT:0> ] in instance . resp . request . path . lower ( ) : <EOL> if not registries and self . _schemaid [ <NUM_LIT:0> ] in instance . resp . request . path . lower ( ) : <EOL> if classesdataholder : <EOL> if self . _schemaid [ <NUM_LIT:1> ] in instance . resp . dict : <EOL> classesdataholder [ <NUM_LIT:0> ] [ self . _schemaid [ <NUM_LIT:1> ] ] . extend ( instance . resp . dict [ self . _schemaid [ <NUM_LIT:1> ] ] ) <EOL> else : <EOL> classesdataholder . append ( instance . resp . dict ) <EOL> elif registries and self . _regid [ <NUM_LIT:0> ] in instance . resp . request . path . lower ( ) : <EOL> if classesdataholder : <EOL> if monolith . is_redfish : <EOL> classesdataholder [ <NUM_LIT:0> ] [ self . _regid [ <NUM_LIT:1> ] ] . extend ( instance . resp . dict [ self . _regid [ <NUM_LIT:1> ] ] ) <EOL> else : <EOL> classesdataholder . append ( instance . resp . dict ) <EOL> if classesdataholder : <EOL> classesdataholder = classesdataholder [ <NUM_LIT:0> ] <EOL> try : <EOL> if monolith . _typestring in classesdataholder and ( '<STR_LIT>' in classesdataholder [ monolith . _typestring ] or ( '<STR_LIT>' in classesdataholder [ monolith . _typestring ] and monolith . is_redfish ) ) : <EOL> newclass = Classes . parse ( classesdataholder ) <EOL> newclass . set_root ( root ) <EOL> if not registries : <EOL> if not biossection : <EOL> self . _classes . append ( newclass ) <EOL> else : <EOL> self . _bios_classes . append ( newclass ) <EOL> else : <EOL> if not biossection : <EOL> self . _classes_registry . append ( newclass ) <EOL> else : <EOL> self . _bios_classes_registry . append ( newclass ) <EOL> except BaseException : <EOL> pass <EOL> else : <EOL> pass <EOL> def load_file ( self , filepath , root = None , biossection = False , <EOL> registries = False , datareturn = False ) : <EOL> """<STR_LIT>""" <EOL> result = False <EOL> if os . path . isfile ( filepath ) : <EOL> try : <EOL> filehand = open ( filepath , '<STR_LIT:r>' ) <EOL> data = json . load ( filehand ) <EOL> if datareturn : <EOL> return data <EOL> if u'<STR_LIT>' in data and data [ u'<STR_LIT>' ] == '<STR_LIT>' : <EOL> if biossection and registries : <EOL> itemsreturn = self . bios_helper_function ( data , root ) <EOL> data [ "<STR_LIT>" ] = itemsreturn <EOL> newclass = Classes . parse ( data ) <EOL> newclass . set_root ( root ) <EOL> if not registries : <EOL> if not biossection : <EOL> self . _classes . append ( newclass ) <EOL> else : <EOL> self . _bios_classes . append ( newclass ) <EOL> else : <EOL> if not biossection : <EOL> self . _classes_registry . append ( newclass ) <EOL> else : <EOL> self . _bios_classes_registry . append ( newclass ) <EOL> result = True <EOL> except BaseException : <EOL> pass <EOL> else : <EOL> pass <EOL> finally : <EOL> filehand . close ( ) <EOL> return result <EOL> def bios_helper_function ( self , data , root ) : <EOL> """<STR_LIT>""" <EOL> folderentries = data [ "<STR_LIT>" ] <EOL> datareturn = list ( ) <EOL> for entry in folderentries [ "<STR_LIT>" ] : <EOL> joinstr = entry [ "<STR_LIT>" ] <EOL> if os . name == '<STR_LIT>' and joinstr [ <NUM_LIT:0> ] == "<STR_LIT:/>" : <EOL> joinstr = joinstr . replace ( "<STR_LIT:/>" , "<STR_LIT:\\>" ) [ <NUM_LIT:1> : ] <EOL> elif joinstr [ <NUM_LIT:0> ] == "<STR_LIT:/>" : <EOL> joinstr = joinstr [ <NUM_LIT:1> : ] <EOL> for root , _ , filenames in os . walk ( os . path . join ( root , joinstr ) ) : <EOL> for filename in filenames : <EOL> fqpath = os . path . abspath ( os . path . join ( os . path . normpath ( root ) , filename ) ) <EOL> datareturn . append ( self . load_file ( fqpath , root = root , biossection = True , registries = True , datareturn = True ) ) <EOL> LOGGER . info ( "<STR_LIT>" , fqpath ) <EOL> return datareturn <EOL> def validate ( self , item , selector = None , currdict = None , monolith = None , <EOL> newarg = None , checkall = False , regloc = None ) : <EOL> """<STR_LIT>""" <EOL> """<STR_LIT>""" <EOL> if regloc : <EOL> attrreg = RepoRegistryEntry ( regloc ) <EOL> else : <EOL> attrreg = self . find_schema ( schname = item [ monolith . _typestring ] ) <EOL> if attrreg : <EOL> tempvalue = attrreg . validate ( item , self . _errors , selector = selector , <EOL> currdict = currdict , monolith = monolith , <EOL> newarg = newarg , checkall = checkall ) <EOL> if tempvalue is True : <EOL> return False <EOL> elif tempvalue : <EOL> self . _errors = tempvalue <EOL> return True <EOL> def bios_validate ( self , item , regname , selector = None , currdict = None , <EOL> checkall = False , monolith = None ) : <EOL> """<STR_LIT>""" <EOL> """<STR_LIT>""" <EOL> attrreg = self . find_bios_registry ( regname = regname ) <EOL> if attrreg : <EOL> tempvalue = attrreg . validate_bios_version ( item , self . _errors , selector = selector , currdict = currdict , checkall = checkall , monolith = monolith ) <EOL> if tempvalue == '<STR_LIT>' : <EOL> return tempvalue <EOL> elif tempvalue == '<STR_LIT>' : <EOL> return tempvalue <EOL> elif tempvalue : <EOL> self . _errors = tempvalue <EOL> return True <EOL> def bios_info ( self , item , regname , selector ) : <EOL> """<STR_LIT>""" <EOL> """<STR_LIT>""" <EOL> attrreg = self . find_bios_registry ( regname = regname ) <EOL> if attrreg : <EOL> if attrreg . validate_bios_version ( item , self . _errors , selector = selector ) : <EOL> return False <EOL> return True <EOL> def find_schema ( self , schname ) : <EOL> """<STR_LIT>""" <EOL> """<STR_LIT>""" <EOL> for cls in self . _classes : <EOL> found = cls . find_schema ( schname = schname ) <EOL> if found : <EOL> return found <EOL> return None <EOL> def find_registry ( self , regname ) : <EOL> """<STR_LIT>""" <EOL> """<STR_LIT>""" <EOL> for cls in self . _classes_registry : <EOL> found = cls . find_registry ( regname = regname ) <EOL> if found : <EOL> return found <EOL> return None <EOL> def find_bios_registry ( self , regname ) : <EOL> """<STR_LIT>""" <EOL> """<STR_LIT>""" <EOL> for cls in self . _bios_classes_registry : <EOL> found = cls . find_bios_registry ( regname = regname ) <EOL> if found : <EOL> return found <EOL> return None <EOL> def get_errors ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _errors <EOL> def _is_local ( self , path ) : <EOL> """<STR_LIT>""" <EOL> if u'<STR_LIT>' in path : <EOL> return False <EOL> return True <EOL> class Classes ( RisObject ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , item ) : <EOL> super ( Classes , self ) . __init__ ( item ) <EOL> self . _root = None <EOL> def set_root ( self , newroot ) : <EOL> """<STR_LIT>""" <EOL> self . _root = newroot <EOL> def find_schema ( self , schname ) : <EOL> """<STR_LIT>""" <EOL> result = None <EOL> if hasattr ( self , '<STR_LIT>' ) and isinstance ( self . Items , list ) : <EOL> for entry in self . Items : <EOL> if entry and u'<STR_LIT>' in entry and entry [ u'<STR_LIT>' ] . lower ( ) == schname . lower ( ) : <EOL> regentry = RepoRegistryEntry . parse ( entry ) <EOL> regentry . set_root ( self . _root ) <EOL> result = regentry <EOL> break <EOL> elif hasattr ( self , '<STR_LIT>' ) and isinstance ( self . Members , list ) : <EOL> schname = schname . split ( '<STR_LIT:.>' ) [ - <NUM_LIT:1> ] <EOL> for entry in self . Members : <EOL> schlink = entry [ u'<STR_LIT>' ] . split ( '<STR_LIT:/>' ) <EOL> schlink = schlink [ len ( schlink ) - <NUM_LIT:2> ] <EOL> if schname . lower ( ) == schlink . lower ( ) : <EOL> result = entry <EOL> break <EOL> return result <EOL> def find_registry ( self , regname ) : <EOL> """<STR_LIT>""" <EOL> result = None <EOL> if hasattr ( self , '<STR_LIT>' ) and isinstance ( self . Items , list ) : <EOL> for entry in self . Items : <EOL> if entry and ( u'<STR_LIT>' in entry and <EOL> entry [ u'<STR_LIT>' ] . lower ( ) . startswith ( regname . lower ( ) ) ) : <EOL> regentry = RepoRegistryEntry . parse ( entry ) <EOL> regentry . set_root ( self . _root ) <EOL> result = regentry <EOL> break <EOL> elif hasattr ( self , '<STR_LIT>' ) and isinstance ( self . Members , list ) : <EOL> regname = regname . split ( '<STR_LIT:.>' ) [ - <NUM_LIT:1> ] <EOL> for entry in self . Members : <EOL> reglink = entry [ u'<STR_LIT>' ] . split ( '<STR_LIT:/>' ) <EOL> reglink = reglink [ len ( reglink ) - <NUM_LIT:2> ] <EOL> if regname . lower ( ) == reglink . lower ( ) : <EOL> result = entry <EOL> break <EOL> return result <EOL> def find_bios_schema ( self , schname ) : <EOL> """<STR_LIT>""" <EOL> result = None <EOL> if hasattr ( self , '<STR_LIT>' ) and isinstance ( self . Items , list ) : <EOL> for entry in self . Items : <EOL> if ( u'<STR_LIT>' in entry and entry [ u'<STR_LIT>' ] . lower ( ) == <EOL> schname . lower ( ) ) : <EOL> regentry = RepoRegistryEntry . parse ( entry ) <EOL> regentry . set_root ( self . _root ) <EOL> result = regentry <EOL> break <EOL> return result <EOL> def find_bios_registry ( self , regname ) : <EOL> """<STR_LIT>""" <EOL> result = None <EOL> if hasattr ( self , '<STR_LIT>' ) and isinstance ( self . Items , list ) : <EOL> for entry in self . Items : <EOL> if entry and ( u'<STR_LIT>' in entry and regname . lower ( ) in entry [ u'<STR_LIT>' ] . lower ( ) ) : <EOL> regentry = RepoRegistryEntry . parse ( entry ) <EOL> regentry . set_root ( self . _root ) <EOL> result = regentry <EOL> break <EOL> return result <EOL> class RepoBaseEntry ( RisObject ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , d ) : <EOL> super ( RepoBaseEntry , self ) . __init__ ( d ) <EOL> self . _root = None <EOL> def set_root ( self , newroot ) : <EOL> """<STR_LIT>""" <EOL> self . _root = newroot <EOL> def _read_location_file ( self , currloc , errlist ) : <EOL> """<STR_LIT>""" <EOL> result = None <EOL> if u'<STR_LIT>' in currloc : <EOL> root = os . path . normpath ( self . _root ) <EOL> xref = os . path . normpath ( currloc . Uri . extref ) . lstrip ( os . path . sep ) <EOL> fqpath = os . path . join ( root , xref ) <EOL> if not os . path . isfile ( fqpath ) : <EOL> errlist . append ( SchemaValidationError ( <EOL> u"<STR_LIT>" % fqpath ) ) <EOL> else : <EOL> result = None <EOL> if fqpath . endswith ( '<STR_LIT>' ) : <EOL> result = open ( fqpath ) . read ( ) <EOL> return result <EOL> class RepoRegistryEntry ( RepoBaseEntry ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , d ) : <EOL> super ( RepoRegistryEntry , self ) . __init__ ( d ) <EOL> def validate ( self , tdict , errlist = None , selector = None , currdict = None , checkall = False , monolith = None , newarg = None ) : <EOL> """<STR_LIT>""" <EOL> if not errlist : <EOL> errlist = list ( ) <EOL> reg = self . get_registry_model ( errlist = errlist , currdict = currdict , monolith = monolith , newarg = newarg ) <EOL> if reg and not checkall : <EOL> try : <EOL> if reg [ selector ] . readonly : <EOL> return True <EOL> except BaseException : <EOL> pass <EOL> else : <EOL> pass <EOL> results = reg . validate_attribute_values ( tdict ) <EOL> errlist . extend ( results ) <EOL> elif checkall and selector is None : <EOL> results = reg . validate_attribute_values ( tdict ) <EOL> errlist . extend ( results ) <EOL> else : <EOL> errlist . append ( RegistryValidationError ( u'<STR_LIT>' '<STR_LIT>' ) ) <EOL> if errlist : <EOL> return errlist <EOL> def validate_bios_version ( self , tdict , errlist = None , selector = None , checkall = False , currdict = None , monolith = None ) : <EOL> """<STR_LIT>""" <EOL> if not errlist : <EOL> errlist = list ( ) <EOL> reg = self . get_registry_model_bios_version ( errlist = errlist , currdict = currdict , monolith = monolith ) <EOL> if reg and not checkall : <EOL> for item in reg . Attributes : <EOL> if not item [ "<STR_LIT:Name>" ] == selector : <EOL> continue <EOL> if item [ "<STR_LIT>" ] is True : <EOL> return '<STR_LIT>' <EOL> try : <EOL> if item [ "<STR_LIT>" ] is True : <EOL> return '<STR_LIT>' <EOL> except BaseException : <EOL> continue <EOL> else : <EOL> continue <EOL> results = reg . validate_att_val_bios ( tdict ) <EOL> errlist . extend ( results ) <EOL> elif checkall and selector is None : <EOL> results = reg . validate_att_val_bios ( tdict ) <EOL> errlist . extend ( results ) <EOL> else : <EOL> errlist . append ( RegistryValidationError ( u'<STR_LIT>' '<STR_LIT>' ) ) <EOL> if errlist : <EOL> return errlist <EOL> def validate_deprecated ( self , tdict , errlist = None ) : <EOL> """<STR_LIT>""" <EOL> if not errlist : <EOL> errlist = list ( ) <EOL> if not hasattr ( self , u'<STR_LIT>' ) : <EOL> errlist . append ( RegistryValidationError ( u'<STR_LIT>' '<STR_LIT>' ) ) <EOL> return errlist <EOL> currloc = None <EOL> defloc = None <EOL> langcode = '<STR_LIT>' <EOL> for loc in self . Location : <EOL> for loclang in loc . keys ( ) : <EOL> if loclang . lower ( ) == langcode . lower ( ) : <EOL> currloc = loc [ loclang ] <EOL> break <EOL> elif loclang . lower ( ) == u'<STR_LIT:default>' : <EOL> defloc = loc [ loclang ] <EOL> if not currloc : <EOL> currloc = defloc <EOL> if not currloc : <EOL> errlist . append ( RegistryValidationError ( u'<STR_LIT>' '<STR_LIT>' ) ) <EOL> return <EOL> location_file = self . _read_location_file ( currloc , errlist = errlist ) <EOL> if not location_file : <EOL> errlist . append ( RegistryValidationError ( u'<STR_LIT>' ) ) <EOL> else : <EOL> jsonreg = json . loads ( location_file ) <EOL> if u'<STR_LIT>' in jsonreg : <EOL> if u'<STR_LIT>' in jsonreg and jsonreg [ u'<STR_LIT>' ] == u'<STR_LIT>' : <EOL> reg = HpPropertiesRegistry . parse ( jsonreg [ u'<STR_LIT>' ] ) <EOL> results = reg . validate_attribute_values ( tdict ) <EOL> errlist . extend ( results ) <EOL> def get_registry_model ( self , currdict = None , monolith = None , errlist = None , skipcommit = False , searchtype = None , newarg = None , latestschema = None ) : <EOL> """<STR_LIT>""" <EOL> if not errlist : <EOL> errlist = list ( ) <EOL> if not hasattr ( self , u'<STR_LIT>' ) : <EOL> errlist . append ( RegistryValidationError ( <EOL> u'<STR_LIT>' ) ) <EOL> return None <EOL> currloc = None <EOL> defloc = "<STR_LIT>" <EOL> langcode = list ( locale . getdefaultlocale ( ) ) <EOL> if not langcode [ <NUM_LIT:0> ] : <EOL> langcode [ <NUM_LIT:0> ] = "<STR_LIT>" <EOL> for loc in self . Location : <EOL> locationlanguage = loc [ "<STR_LIT>" ] . lower ( ) <EOL> locationlanguage = locationlanguage . replace ( "<STR_LIT:->" , "<STR_LIT:_>" ) <EOL> if locationlanguage in langcode [ <NUM_LIT:0> ] . lower ( ) : <EOL> currloc = loc <EOL> break <EOL> if not currloc : <EOL> currloc = defloc <EOL> if not currloc : <EOL> errlist . append ( RegistryValidationError ( u'<STR_LIT>' '<STR_LIT:location>' ) ) <EOL> return None <EOL> if not searchtype : <EOL> searchtype = "<STR_LIT>" <EOL> location_file = None <EOL> if currdict and monolith : <EOL> for itemtype in monolith . types : <EOL> if itemtype . lower ( ) . startswith ( searchtype . lower ( ) ) and u'<STR_LIT>' in monolith . types [ itemtype ] : <EOL> for instance in monolith . types [ itemtype ] [ u'<STR_LIT>' ] : <EOL> try : <EOL> if monolith . is_redfish : <EOL> currtype = currdict [ instance . _typestring ] . split ( '<STR_LIT:#>' ) [ - <NUM_LIT:1> ] <EOL> currtype = currtype . split ( '<STR_LIT:.>' ) [ <NUM_LIT:0> ] + '<STR_LIT:.>' <EOL> else : <EOL> currtype = currdict [ instance . _typestring ] <EOL> if latestschema : <EOL> currtype = currdict [ instance . _typestring ] . split ( '<STR_LIT:.>' ) [ : <NUM_LIT:1> ] <EOL> insttype = instance . resp . dict [ "<STR_LIT:title>" ] . split ( '<STR_LIT:.>' ) [ : <NUM_LIT:1> ] <EOL> if currtype == insttype or currtype == instance . resp . dict [ "<STR_LIT>" ] . split ( '<STR_LIT:.>' ) [ : <NUM_LIT:1> ] : <EOL> location_file = instance . resp . dict <EOL> break <EOL> elif searchtype == "<STR_LIT>" and instance . resp . dict [ "<STR_LIT:title>" ] . startswith ( currtype ) or "<STR_LIT>" in instance . resp . dict . keys ( ) and currdict [ instance . _typestring ] == instance . resp . dict [ "<STR_LIT>" ] : <EOL> location_file = instance . resp . dict <EOL> break <EOL> elif searchtype != "<STR_LIT>" and currdict [ instance . _typestring ] in instance . resp . dict [ "<STR_LIT>" ] : <EOL> location_file = instance . resp . dict <EOL> break <EOL> except BaseException : <EOL> pass <EOL> else : <EOL> pass <EOL> if location_file : <EOL> break <EOL> else : <EOL> location_file = self . _read_location_file ( currloc , errlist = errlist ) <EOL> if not location_file : <EOL> errlist . append ( RegistryValidationError ( u'<STR_LIT>' ) ) <EOL> else : <EOL> if currdict and monolith : <EOL> jsonreg = json . loads ( json . dumps ( location_file , indent = <NUM_LIT:2> , cls = JSONEncoder ) ) <EOL> else : <EOL> jsonreg = json . loads ( location_file ) <EOL> if skipcommit : <EOL> return jsonreg [ "<STR_LIT>" ] <EOL> if u'<STR_LIT>' in jsonreg : <EOL> regitem = jsonreg [ u'<STR_LIT>' ] <EOL> reg = HpPropertiesRegistry . parse ( regitem ) <EOL> if newarg : <EOL> regcopy = reg <EOL> for arg in newarg [ : - <NUM_LIT:1> ] : <EOL> try : <EOL> if '<STR_LIT>' in regcopy [ arg ] . iterkeys ( ) and ( '<STR_LIT>' in regcopy [ arg ] . iterkeys ( ) ) : <EOL> regcopy [ arg ] [ '<STR_LIT>' ] . update ( regcopy [ arg ] [ '<STR_LIT>' ] ) <EOL> regcopy = regcopy [ arg ] [ "<STR_LIT>" ] <EOL> for pattern in regcopy . iterkeys ( ) : <EOL> test = re . compile ( pattern ) <EOL> nextarg = newarg [ newarg . index ( arg ) + <NUM_LIT:1> ] <EOL> match = test . match ( nextarg ) <EOL> if match : <EOL> regcopy [ nextarg ] = regcopy . pop ( pattern ) <EOL> break <EOL> elif '<STR_LIT>' in regcopy [ arg ] : <EOL> oneof = regcopy [ arg ] [ '<STR_LIT>' ] <EOL> for item in oneof : <EOL> regcopy = item [ '<STR_LIT>' ] <EOL> if not arg == newarg [ - <NUM_LIT:1> ] : <EOL> try : <EOL> nextitem = newarg [ newarg . index ( arg ) + <NUM_LIT:1> ] <EOL> regcopy [ nextitem ] <EOL> break <EOL> except Exception : <EOL> continue <EOL> else : <EOL> regcopy = regcopy [ arg ] [ "<STR_LIT>" ] <EOL> except Exception : <EOL> try : <EOL> regcopy = regcopy [ arg ] [ '<STR_LIT>' ] <EOL> for pattern in regcopy . iterkeys ( ) : <EOL> test = re . compile ( pattern ) <EOL> nextarg = newarg [ newarg . index ( arg ) + <NUM_LIT:1> ] <EOL> match = test . match ( nextarg ) <EOL> if match : <EOL> patterninfo = regcopy . pop ( pattern ) <EOL> regcopy [ nextarg ] = patterninfo <EOL> except BaseException : <EOL> return None <EOL> reg = regcopy <EOL> return reg <EOL> return None <EOL> def get_registry_model_bios_version ( self , currdict = None , monolith = None , errlist = None ) : <EOL> """<STR_LIT>""" <EOL> """<STR_LIT>""" <EOL> if not errlist : <EOL> errlist = list ( ) <EOL> if not hasattr ( self , u'<STR_LIT>' ) : <EOL> errlist . append ( RegistryValidationError ( <EOL> u'<STR_LIT>' ) ) <EOL> return None <EOL> currloc = None <EOL> defloc = "<STR_LIT>" <EOL> langcode = list ( locale . getdefaultlocale ( ) ) <EOL> if not langcode [ <NUM_LIT:0> ] : <EOL> langcode [ <NUM_LIT:0> ] = "<STR_LIT>" <EOL> for loc in self . Location : <EOL> locationlanguage = loc [ "<STR_LIT>" ] . lower ( ) <EOL> locationlanguage = locationlanguage . replace ( "<STR_LIT:->" , "<STR_LIT:_>" ) <EOL> if locationlanguage in langcode [ <NUM_LIT:0> ] . lower ( ) : <EOL> currloc = loc <EOL> break <EOL> if not currloc : <EOL> currloc = defloc <EOL> if not currloc : <EOL> errlist . append ( RegistryValidationError ( <EOL> u'<STR_LIT>' ) ) <EOL> return None <EOL> location_file = None <EOL> if currdict and monolith : <EOL> for itemtype in monolith . types : <EOL> if "<STR_LIT>" in itemtype and u'<STR_LIT>' in monolith . types [ itemtype ] : <EOL> for instance in monolith . types [ itemtype ] [ u'<STR_LIT>' ] : <EOL> location_file = instance . resp . dict <EOL> break <EOL> if location_file : <EOL> break <EOL> else : <EOL> location_file = self . _read_location_file ( currloc , errlist = errlist ) <EOL> if not location_file : <EOL> errlist . append ( RegistryValidationError ( u'<STR_LIT>' ) ) <EOL> else : <EOL> if currdict and monolith : <EOL> jsonreg = json . loads ( json . dumps ( location_file , indent = <NUM_LIT:2> , cls = JSONEncoder ) ) <EOL> else : <EOL> jsonreg = json . loads ( location_file ) <EOL> if u'<STR_LIT>' in jsonreg : <EOL> regitem = jsonreg [ u'<STR_LIT>' ] <EOL> reg = HpPropertiesRegistry . parse ( regitem ) <EOL> return reg <EOL> return None <EOL> class RepoSchemaEntry ( RepoBaseEntry ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , item ) : <EOL> super ( RepoSchemaEntry , self ) . __init__ ( item ) <EOL> self . _root = None <EOL> def set_root ( self , newroot ) : <EOL> """<STR_LIT>""" <EOL> self . _root = newroot <EOL> def _read_location_file ( self , currloc , errlist ) : <EOL> """<STR_LIT>""" <EOL> if u'<STR_LIT>' in currloc and u'<STR_LIT>' in currloc : <EOL> fqpath = os . path . join ( self . _root , currloc . ArchiveUri . xref . lstrip ( os . path . sep ) ) <EOL> if not os . path . isfile ( fqpath ) : <EOL> errlist . append ( SchemaValidationError ( u"<STR_LIT>" "<STR_LIT>" % fqpath ) ) <EOL> else : <EOL> archive_file = currloc . ArchiveFile <EOL> archive_fh = None <EOL> result = None <EOL> if fqpath . endswith ( '<STR_LIT>' ) : <EOL> archive_fh = zipfile . ZipFile ( fqpath ) <EOL> infolist = archive_fh . infolist ( ) <EOL> for i in infolist : <EOL> if i . filename . lower ( ) == archive_file . lower ( ) : <EOL> jsonsch_fh = archive_fh . open ( i ) <EOL> result = jsonsch_fh . read ( ) <EOL> jsonsch_fh . close ( ) <EOL> archive_fh . close ( ) <EOL> return result <EOL> def validate ( self , tdict , errlist = None ) : <EOL> """<STR_LIT>""" <EOL> if not errlist : <EOL> errlist = list ( ) <EOL> result = list ( ) <EOL> if not hasattr ( self , u'<STR_LIT>' ) : <EOL> result . append ( SchemaValidationError ( u'<STR_LIT>' '<STR_LIT>' ) ) <EOL> return result <EOL> currloc = None <EOL> defloc = None <EOL> langcode = '<STR_LIT>' <EOL> for loc in self . Location : <EOL> for loclang in loc . keys ( ) : <EOL> if loclang . lower ( ) == langcode . lower ( ) : <EOL> currloc = loc [ loclang ] <EOL> break <EOL> elif loclang . lower ( ) == u'<STR_LIT:default>' : <EOL> defloc = loc [ loclang ] <EOL> if not currloc : <EOL> currloc = defloc <EOL> if not currloc : <EOL> result . append ( SchemaValidationError ( <EOL> u'<STR_LIT>' ) ) <EOL> return <EOL> location_file = self . _read_location_file ( currloc , errlist = result ) <EOL> if not location_file : <EOL> result . append ( SchemaValidationError ( u'<STR_LIT>' ) ) <EOL> else : <EOL> jsonsch = json . loads ( location_file ) <EOL> validictory . validate ( tdict , jsonsch ) <EOL> class HpPropertiesRegistry ( RisObject ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , d ) : <EOL> super ( HpPropertiesRegistry , self ) . __init__ ( d ) <EOL> def validate_attribute_values ( self , tdict ) : <EOL> """<STR_LIT>""" <EOL> result = list ( ) <EOL> for tkey in tdict : <EOL> try : <EOL> if self [ tkey ] and hasattr ( self [ tkey ] , "<STR_LIT:type>" ) : <EOL> temp = self . validate_attribute ( self [ tkey ] , tdict [ tkey ] , tkey ) <EOL> for err in temp : <EOL> if isinstance ( err , RegistryValidationError ) : <EOL> if err . reg : <EOL> err . sel = tkey <EOL> result . extend ( temp ) <EOL> except Exception : <EOL> pass <EOL> return result <EOL> def validate_att_val_bios ( self , tdict ) : <EOL> """<STR_LIT>""" <EOL> result = list ( ) <EOL> for tkey in tdict : <EOL> for item in self . Attributes : <EOL> try : <EOL> if item [ "<STR_LIT:Name>" ] == tkey and hasattr ( item , "<STR_LIT>" ) : <EOL> temp = self . validate_attribute ( item , tdict [ tkey ] , tkey ) <EOL> for err in temp : <EOL> if isinstance ( err , RegistryValidationError ) : <EOL> if err . reg : <EOL> err . sel = tkey <EOL> result . extend ( temp ) <EOL> break <EOL> except Exception : <EOL> pass <EOL> return result <EOL> def get_validator ( self , attrname , newargs = None , oneof = None ) : <EOL> """<STR_LIT>""" <EOL> if oneof : <EOL> self = oneof <EOL> if newargs : <EOL> for arg in newargs : <EOL> try : <EOL> self = self [ '<STR_LIT>' ] <EOL> except Exception : <EOL> pass <EOL> if not hasattr ( self , arg ) : <EOL> return None <EOL> elif not arg == newargs [ - <NUM_LIT:1> ] : <EOL> self = self [ arg ] <EOL> if not hasattr ( self , attrname ) : <EOL> return None <EOL> validator = None <EOL> if EnumValidator . is_type ( self [ attrname ] ) : <EOL> validator = EnumValidator . parse ( self [ attrname ] ) <EOL> elif StringValidator . is_type ( self [ attrname ] ) : <EOL> validator = StringValidator . parse ( self [ attrname ] ) <EOL> elif ObjectValidator . is_type ( self [ attrname ] ) : <EOL> validator = ObjectValidator . parse ( self [ attrname ] ) <EOL> elif IntegerValidator . is_type ( self [ attrname ] ) : <EOL> validator = IntegerValidator . parse ( self [ attrname ] ) <EOL> elif BoolValidator . is_type ( self [ attrname ] ) : <EOL> validator = BoolValidator . parse ( self [ attrname ] ) <EOL> elif PasswordValidator . is_type ( self [ attrname ] ) : <EOL> validator = PasswordValidator . parse ( self [ attrname ] ) <EOL> elif u'<STR_LIT>' in self [ attrname ] . keys ( ) : <EOL> for item in self [ attrname ] [ '<STR_LIT>' ] : <EOL> validator = self . get_validator ( attrname , newargs , HpPropertiesRegistry ( { attrname : item } ) ) <EOL> if validator : <EOL> break <EOL> return validator <EOL> def get_validator_bios ( self , attrname ) : <EOL> """<STR_LIT>""" <EOL> for item in self . Attributes : <EOL> if item [ "<STR_LIT:Name>" ] == attrname : <EOL> validator = None <EOL> if EnumValidator . is_type ( item ) : <EOL> validator = EnumValidator . parse ( item ) <EOL> elif StringValidator . is_type ( item ) : <EOL> validator = StringValidator . parse ( item ) <EOL> elif IntegerValidator . is_type ( item ) : <EOL> validator = IntegerValidator . parse ( item ) <EOL> elif BoolValidator . is_type ( item ) : <EOL> validator = BoolValidator . parse ( item ) <EOL> elif ObjectValidator . is_type ( item ) : <EOL> validator = ObjectValidator . parse ( item ) <EOL> elif PasswordValidator . is_type ( item ) : <EOL> validator = PasswordValidator . parse ( item ) <EOL> return validator <EOL> return None <EOL> def validate_attribute ( self , attrentry , attrval , name ) : <EOL> """<STR_LIT>""" <EOL> result = list ( ) <EOL> validator = None <EOL> if EnumValidator . is_type ( attrentry ) : <EOL> validator = EnumValidator . parse ( attrentry ) <EOL> elif StringValidator . is_type ( attrentry ) : <EOL> validator = StringValidator . parse ( attrentry ) <EOL> elif IntegerValidator . is_type ( attrentry ) : <EOL> validator = IntegerValidator . parse ( attrentry ) <EOL> elif BoolValidator . is_type ( attrentry ) : <EOL> validator = BoolValidator . parse ( attrentry ) <EOL> elif ObjectValidator . is_type ( attrentry ) : <EOL> validator = ObjectValidator . parse ( attrentry ) <EOL> elif PasswordValidator . is_type ( attrentry ) : <EOL> validator = PasswordValidator . parse ( attrentry ) <EOL> else : <EOL> raise UnknownValidatorError ( attrentry ) <EOL> if validator : <EOL> result . extend ( validator . validate ( attrval , name ) ) <EOL> return result <EOL> class BaseValidator ( RisObject ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , d ) : <EOL> super ( BaseValidator , self ) . __init__ ( d ) <EOL> def validate ( self ) : <EOL> """<STR_LIT>""" <EOL> raise RuntimeError ( u'<STR_LIT>' '<STR_LIT:class>' ) <EOL> class EnumValidator ( BaseValidator ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , d ) : <EOL> super ( EnumValidator , self ) . __init__ ( d ) <EOL> @ staticmethod <EOL> def is_type ( attrentry ) : <EOL> """<STR_LIT>""" <EOL> if u'<STR_LIT:type>' in attrentry : <EOL> if isinstance ( attrentry [ u'<STR_LIT:type>' ] , list ) : <EOL> for item in attrentry [ u'<STR_LIT:type>' ] : <EOL> if item . lower ( ) == u'<STR_LIT>' : <EOL> return True <EOL> elif u'<STR_LIT>' in attrentry and item . lower ( ) == u'<STR_LIT:string>' : <EOL> return True <EOL> elif u'<STR_LIT>' in attrentry and attrentry [ u'<STR_LIT:type>' ] == "<STR_LIT>" : <EOL> for key , value in attrentry [ u'<STR_LIT>' ] . iteritems ( ) : <EOL> if key . lower ( ) == "<STR_LIT:type>" and value . lower ( ) == u'<STR_LIT:string>' : <EOL> return True <EOL> else : <EOL> if attrentry [ u'<STR_LIT:type>' ] . lower ( ) == u'<STR_LIT>' : <EOL> return True <EOL> elif u'<STR_LIT>' in attrentry and attrentry [ u'<STR_LIT:type>' ] . lower ( ) == u'<STR_LIT:string>' : <EOL> return True <EOL> elif u'<STR_LIT>' in attrentry : <EOL> if attrentry [ u'<STR_LIT>' ] . lower ( ) == u'<STR_LIT>' : <EOL> return True <EOL> return False <EOL> def validate ( self , newval , name ) : <EOL> """<STR_LIT>""" <EOL> result = list ( ) <EOL> try : <EOL> for possibleval in self . enum : <EOL> if possibleval . lower ( ) == newval . lower ( ) : <EOL> return result <EOL> except Exception : <EOL> for possibleval in self . Value : <EOL> if possibleval . ValueName . lower ( ) == str ( newval ) . lower ( ) : <EOL> return result <EOL> result . append ( RegistryValidationError ( u"<STR_LIT>" <EOL> "<STR_LIT>" % ( newval , name ) , <EOL> regentry = self ) ) <EOL> return result <EOL> def print_help ( self , name , out = sys . stdout ) : <EOL> """<STR_LIT>""" <EOL> wrapper = textwrap . TextWrapper ( ) <EOL> wrapper . initial_indent = '<STR_LIT:U+0020>' * <NUM_LIT:4> <EOL> wrapper . subsequent_indent = '<STR_LIT:U+0020>' * <NUM_LIT:4> <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT:%s>' % name ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> if u'<STR_LIT>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> if u'<STR_LIT:description>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> if u'<STR_LIT>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> if u'<STR_LIT>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> if u'<STR_LIT:type>' in self and isinstance ( self [ u'<STR_LIT:type>' ] , list ) : <EOL> out . write ( u'<STR_LIT>' ) <EOL> for item in self [ u'<STR_LIT:type>' ] : <EOL> out . write ( '<STR_LIT>' % wrapper . fill ( '<STR_LIT:%s>' % item ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> elif u'<STR_LIT:type>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> elif u'<STR_LIT>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> if u'<STR_LIT>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> elif u'<STR_LIT>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> out . write ( u'<STR_LIT>' ) <EOL> try : <EOL> for possibleval in self . enum : <EOL> out . write ( '<STR_LIT>' % possibleval ) <EOL> except Exception : <EOL> for possibleval in self . Value : <EOL> out . write ( '<STR_LIT>' % possibleval ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> class BoolValidator ( BaseValidator ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , d ) : <EOL> super ( BoolValidator , self ) . __init__ ( d ) <EOL> @ staticmethod <EOL> def is_type ( attrentry ) : <EOL> """<STR_LIT>""" <EOL> if u'<STR_LIT:type>' in attrentry : <EOL> if isinstance ( attrentry [ u'<STR_LIT:type>' ] , list ) : <EOL> for item in attrentry [ u'<STR_LIT:type>' ] : <EOL> if item . lower ( ) == u'<STR_LIT>' : <EOL> return True <EOL> elif attrentry [ u'<STR_LIT:type>' ] == "<STR_LIT>" : <EOL> for key , value in attrentry [ u'<STR_LIT>' ] . iteritems ( ) : <EOL> if key . lower ( ) == "<STR_LIT:type>" and value . lower ( ) == u'<STR_LIT>' : <EOL> return True <EOL> else : <EOL> if attrentry [ u'<STR_LIT:type>' ] . lower ( ) == u'<STR_LIT>' : <EOL> return True <EOL> elif u'<STR_LIT>' in attrentry : <EOL> if attrentry [ u'<STR_LIT>' ] . lower ( ) == u'<STR_LIT>' : <EOL> return True <EOL> return False <EOL> def validate ( self , newval , name ) : <EOL> """<STR_LIT>""" <EOL> result = list ( ) <EOL> if newval is False or newval is True : <EOL> return result <EOL> result . append ( <EOL> RegistryValidationError ( <EOL> u"<STR_LIT>" % ( newval , name ) , <EOL> regentry = self <EOL> ) <EOL> ) <EOL> return result <EOL> def print_help ( self , name , out = sys . stdout ) : <EOL> """<STR_LIT>""" <EOL> wrapper = textwrap . TextWrapper ( ) <EOL> wrapper . initial_indent = '<STR_LIT:U+0020>' * <NUM_LIT:4> <EOL> wrapper . subsequent_indent = '<STR_LIT:U+0020>' * <NUM_LIT:4> <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT:%s>' % name ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> if u'<STR_LIT>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> if u'<STR_LIT:description>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> if u'<STR_LIT>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> if u'<STR_LIT>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> if u'<STR_LIT:type>' in self and isinstance ( self [ u'<STR_LIT:type>' ] , list ) : <EOL> out . write ( u'<STR_LIT>' ) <EOL> for item in self [ u'<STR_LIT:type>' ] : <EOL> out . write ( '<STR_LIT>' % wrapper . fill ( '<STR_LIT:%s>' % item ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> elif u'<STR_LIT:type>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> elif u'<STR_LIT>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> if u'<STR_LIT>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> elif u'<STR_LIT>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> class StringValidator ( BaseValidator ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , d ) : <EOL> super ( StringValidator , self ) . __init__ ( d ) <EOL> @ staticmethod <EOL> def is_type ( attrentry ) : <EOL> """<STR_LIT>""" <EOL> if u'<STR_LIT:type>' in attrentry : <EOL> if isinstance ( attrentry [ u'<STR_LIT:type>' ] , list ) : <EOL> for item in attrentry [ u'<STR_LIT:type>' ] : <EOL> if item . lower ( ) == u'<STR_LIT:string>' : <EOL> return True <EOL> elif attrentry [ u'<STR_LIT:type>' ] == "<STR_LIT>" : <EOL> for key , value in attrentry [ u'<STR_LIT>' ] . iteritems ( ) : <EOL> if key . lower ( ) == "<STR_LIT:type>" and u'<STR_LIT:string>' in value : <EOL> return True <EOL> else : <EOL> if attrentry [ u'<STR_LIT:type>' ] . lower ( ) == u'<STR_LIT:string>' : <EOL> return True <EOL> elif u'<STR_LIT>' in attrentry : <EOL> if attrentry [ u'<STR_LIT>' ] . lower ( ) == u'<STR_LIT:string>' : <EOL> return True <EOL> return False <EOL> def validate ( self , newval , name ) : <EOL> """<STR_LIT>""" <EOL> result = list ( ) <EOL> if u'<STR_LIT>' in self : <EOL> if len ( newval ) < int ( self [ u'<STR_LIT>' ] ) : <EOL> result . append ( RegistryValidationError ( <EOL> u"<STR_LIT>" % <EOL> ( self . Name , int ( self [ u'<STR_LIT>' ] ) ) , regentry = self ) ) <EOL> if u'<STR_LIT>' in self : <EOL> if len ( newval ) > int ( self [ u'<STR_LIT>' ] ) : <EOL> result . append ( RegistryValidationError ( <EOL> u"<STR_LIT>" % <EOL> ( self . Name , int ( self [ u'<STR_LIT>' ] ) ) , regentry = self ) ) <EOL> if u'<STR_LIT>' in self : <EOL> if self [ u'<STR_LIT>' ] : <EOL> pat = re . compile ( self [ u'<STR_LIT>' ] ) <EOL> if newval and not pat . match ( newval ) : <EOL> result . append ( RegistryValidationError ( <EOL> u"<STR_LIT>" <EOL> "<STR_LIT>" % ( self ) , regentry = self ) ) <EOL> return result <EOL> def print_help ( self , name , out = sys . stdout ) : <EOL> """<STR_LIT>""" <EOL> wrapper = textwrap . TextWrapper ( ) <EOL> wrapper . initial_indent = '<STR_LIT:U+0020>' * <NUM_LIT:4> <EOL> wrapper . subsequent_indent = '<STR_LIT:U+0020>' * <NUM_LIT:4> <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT:%s>' % name ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> if u'<STR_LIT>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> if u'<STR_LIT:description>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> if u'<STR_LIT>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> if u'<STR_LIT>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> if u'<STR_LIT:type>' in self and isinstance ( self [ u'<STR_LIT:type>' ] , list ) : <EOL> out . write ( u'<STR_LIT>' ) <EOL> for item in self [ u'<STR_LIT:type>' ] : <EOL> out . write ( '<STR_LIT>' % wrapper . fill ( '<STR_LIT:%s>' % item ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> elif u'<STR_LIT:type>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> elif u'<STR_LIT>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> if u'<STR_LIT>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> if u'<STR_LIT>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> if u'<STR_LIT>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> elif u'<STR_LIT>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> class IntegerValidator ( BaseValidator ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , d ) : <EOL> super ( IntegerValidator , self ) . __init__ ( d ) <EOL> @ staticmethod <EOL> def is_type ( attrentry ) : <EOL> """<STR_LIT>""" <EOL> if u'<STR_LIT:type>' in attrentry : <EOL> if isinstance ( attrentry [ u'<STR_LIT:type>' ] , list ) : <EOL> for item in attrentry [ u'<STR_LIT:type>' ] : <EOL> if item . lower ( ) == u'<STR_LIT>' or item . lower ( ) == u'<STR_LIT>' : <EOL> return True <EOL> elif attrentry [ u'<STR_LIT:type>' ] == "<STR_LIT>" : <EOL> for key , value in attrentry [ u'<STR_LIT>' ] . iteritems ( ) : <EOL> if key . lower ( ) == "<STR_LIT:type>" : <EOL> if value . lower ( ) == u'<STR_LIT>' or value . lower ( ) == u'<STR_LIT>' : <EOL> return True <EOL> else : <EOL> if attrentry [ u'<STR_LIT:type>' ] . lower ( ) == u'<STR_LIT>' or attrentry [ u'<STR_LIT:type>' ] . lower ( ) . lower ( ) == u'<STR_LIT>' : <EOL> return True <EOL> elif u'<STR_LIT>' in attrentry : <EOL> if attrentry [ u'<STR_LIT>' ] . lower ( ) == u'<STR_LIT>' : <EOL> return True <EOL> return False <EOL> def validate ( self , newval , name ) : <EOL> """<STR_LIT>""" <EOL> result = list ( ) <EOL> intval = int ( newval ) <EOL> pat = re . compile ( r'<STR_LIT>' ) <EOL> if newval and not pat . match ( intval ) : <EOL> result . append ( <EOL> RegistryValidationError ( <EOL> u"<STR_LIT>" % ( self ) , <EOL> regentry = self <EOL> ) <EOL> ) <EOL> return result <EOL> if u'<STR_LIT>' in self : <EOL> if intval < int ( self [ u'<STR_LIT>' ] ) : <EOL> result . append ( RegistryValidationError ( u"<STR_LIT>" "<STR_LIT>" % ( self . Name , int ( self [ u'<STR_LIT>' ] ) ) , regentry = self ) ) <EOL> if u'<STR_LIT>' in self : <EOL> if intval > int ( self [ u'<STR_LIT>' ] ) : <EOL> result . append ( RegistryValidationError ( u"<STR_LIT>" "<STR_LIT>" % ( self . Name , int ( self [ u'<STR_LIT>' ] ) ) , regentry = self ) ) <EOL> return result <EOL> def print_help ( self , name , out = sys . stdout ) : <EOL> """<STR_LIT>""" <EOL> wrapper = textwrap . TextWrapper ( ) <EOL> wrapper . initial_indent = '<STR_LIT:U+0020>' * <NUM_LIT:4> <EOL> wrapper . subsequent_indent = '<STR_LIT:U+0020>' * <NUM_LIT:4> <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT:%s>' % name ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> if u'<STR_LIT>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> if u'<STR_LIT:description>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> if u'<STR_LIT>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> if u'<STR_LIT>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> if u'<STR_LIT:type>' in self and isinstance ( self [ u'<STR_LIT:type>' ] , list ) : <EOL> out . write ( u'<STR_LIT>' ) <EOL> for item in self [ u'<STR_LIT:type>' ] : <EOL> out . write ( '<STR_LIT>' % wrapper . fill ( '<STR_LIT:%s>' % item ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> elif u'<STR_LIT:type>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> elif u'<STR_LIT>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> if u'<STR_LIT>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> elif u'<STR_LIT>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> class ObjectValidator ( BaseValidator ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , d ) : <EOL> super ( ObjectValidator , self ) . __init__ ( d ) <EOL> @ staticmethod <EOL> def is_type ( attrentry ) : <EOL> """<STR_LIT>""" <EOL> if u'<STR_LIT:type>' in attrentry : <EOL> if isinstance ( attrentry [ u'<STR_LIT:type>' ] , list ) : <EOL> for item in attrentry [ u'<STR_LIT:type>' ] : <EOL> if item . lower ( ) == u'<STR_LIT:object>' : <EOL> return True <EOL> elif attrentry [ u'<STR_LIT:type>' ] == "<STR_LIT>" : <EOL> for key , value in attrentry [ u'<STR_LIT>' ] . iteritems ( ) : <EOL> if key . lower ( ) == "<STR_LIT:type>" and value . lower ( ) == u'<STR_LIT:object>' : <EOL> return True <EOL> elif key . lower ( ) == "<STR_LIT>" : <EOL> try : <EOL> if value [ <NUM_LIT:0> ] [ u'<STR_LIT:type>' ] == u'<STR_LIT:object>' : <EOL> return True <EOL> except Exception : <EOL> continue <EOL> else : <EOL> if attrentry [ u'<STR_LIT:type>' ] . lower ( ) == u'<STR_LIT:object>' : <EOL> return True <EOL> elif u'<STR_LIT>' in attrentry : <EOL> if attrentry [ u'<STR_LIT>' ] . lower ( ) == u'<STR_LIT:object>' : <EOL> return True <EOL> return False <EOL> def validate ( self , newval , name ) : <EOL> """<STR_LIT>""" <EOL> result = list ( ) <EOL> return result <EOL> def print_help ( self , name , out = sys . stdout ) : <EOL> """<STR_LIT>""" <EOL> wrapper = textwrap . TextWrapper ( ) <EOL> wrapper . initial_indent = '<STR_LIT:U+0020>' * <NUM_LIT:4> <EOL> wrapper . subsequent_indent = '<STR_LIT:U+0020>' * <NUM_LIT:4> <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT:%s>' % name ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> if u'<STR_LIT>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> if u'<STR_LIT:description>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> if u'<STR_LIT>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> if u'<STR_LIT>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> if u'<STR_LIT:type>' in self and isinstance ( self [ u'<STR_LIT:type>' ] , list ) : <EOL> out . write ( u'<STR_LIT>' ) <EOL> for item in self [ u'<STR_LIT:type>' ] : <EOL> out . write ( '<STR_LIT>' % wrapper . fill ( '<STR_LIT:%s>' % item ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> elif u'<STR_LIT:type>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> elif u'<STR_LIT>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> if u'<STR_LIT>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> elif u'<STR_LIT>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> class PasswordValidator ( BaseValidator ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , d ) : <EOL> super ( PasswordValidator , self ) . __init__ ( d ) <EOL> @ staticmethod <EOL> def is_type ( attrentry ) : <EOL> """<STR_LIT>""" <EOL> if u'<STR_LIT:type>' in attrentry : <EOL> if isinstance ( attrentry [ u'<STR_LIT:type>' ] , list ) : <EOL> for item in attrentry [ u'<STR_LIT:type>' ] : <EOL> if item . lower ( ) == u'<STR_LIT:password>' : <EOL> return True <EOL> elif attrentry [ u'<STR_LIT:type>' ] == "<STR_LIT>" : <EOL> for key , value in attrentry [ u'<STR_LIT>' ] . iteritems ( ) : <EOL> if key . lower ( ) == "<STR_LIT:type>" and value . lower ( ) == u'<STR_LIT:password>' : <EOL> return True <EOL> else : <EOL> if attrentry [ u'<STR_LIT:type>' ] . lower ( ) == u'<STR_LIT:password>' : <EOL> return True <EOL> elif u'<STR_LIT>' in attrentry : <EOL> if attrentry [ u'<STR_LIT>' ] . lower ( ) == u'<STR_LIT:password>' : <EOL> return True <EOL> return False <EOL> def validate ( self , newval , name ) : <EOL> """<STR_LIT>""" <EOL> result = list ( ) <EOL> if newval is None : <EOL> return result <EOL> if u'<STR_LIT>' in self : <EOL> if len ( newval ) < int ( self [ u'<STR_LIT>' ] ) : <EOL> result . append ( RegistryValidationError ( u"<STR_LIT>" "<STR_LIT>" % ( self . Name , int ( self [ u'<STR_LIT>' ] ) ) , regentry = self ) ) <EOL> if u'<STR_LIT>' in self : <EOL> if len ( newval ) > int ( self [ u'<STR_LIT>' ] ) : <EOL> result . append ( RegistryValidationError ( u"<STR_LIT>" "<STR_LIT>" % ( self . Name , int ( self [ u'<STR_LIT>' ] ) ) , regentry = self ) ) <EOL> if u'<STR_LIT>' in self : <EOL> if self [ u'<STR_LIT>' ] : <EOL> pat = re . compile ( self [ u'<STR_LIT>' ] ) <EOL> if newval and not pat . match ( newval ) : <EOL> result . append ( RegistryValidationError ( u"<STR_LIT>" "<STR_LIT>" "<STR_LIT>" % ( self ) , regentry = self ) ) <EOL> return result <EOL> def print_help ( self , name , out = sys . stdout ) : <EOL> """<STR_LIT>""" <EOL> wrapper = textwrap . TextWrapper ( ) <EOL> wrapper . initial_indent = '<STR_LIT:U+0020>' * <NUM_LIT:4> <EOL> wrapper . subsequent_indent = '<STR_LIT:U+0020>' * <NUM_LIT:4> <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT:%s>' % name ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> if u'<STR_LIT>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> if u'<STR_LIT:description>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> if u'<STR_LIT>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> if u'<STR_LIT>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> if u'<STR_LIT:type>' in self and isinstance ( self [ u'<STR_LIT:type>' ] , list ) : <EOL> out . write ( u'<STR_LIT>' ) <EOL> for item in self [ u'<STR_LIT:type>' ] : <EOL> out . write ( '<STR_LIT>' % wrapper . fill ( '<STR_LIT:%s>' % item ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> elif u'<STR_LIT:type>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> elif u'<STR_LIT>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> if u'<STR_LIT>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> if u'<STR_LIT>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> if u'<STR_LIT>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) <EOL> elif u'<STR_LIT>' in self : <EOL> out . write ( u'<STR_LIT>' ) <EOL> out . write ( '<STR_LIT:%s>' % wrapper . fill ( '<STR_LIT>' % self ) ) <EOL> out . write ( '<STR_LIT:\n>' ) </s>
