def __get_mo_obj(self, class_id): """ Internal methods to create managed object from class_id """ import inspect mo_class = ucscoreutils.load_class(class_id) mo_class_params = inspect.getargspec(mo_class.__init__)[0][2:] mo_class_param_dict = {} for param in mo_class_params: mo_param = mo_class.prop_meta[param].xml_attribute if mo_param not in self.__properties: if 'rn' in self.__properties: rn_str = self.__properties['rn'] elif 'dn' in self.__properties: rn_str = os.path.basename(self.__properties['dn']) rn_pattern = mo_class.mo_meta.rn np_dict = ucscoreutils.get_naming_props(rn_str, rn_pattern) if param not in np_dict: mo_class_param_dict[param] = "" else: mo_class_param_dict[param] = np_dict[param] else: mo_class_param_dict[param] = self.__properties[mo_param] p_dn = "" if 'topRoot' in mo_class.mo_meta.parents: mo_obj = mo_class(**mo_class_param_dict) else: mo_obj = mo_class(parent_mo_or_dn=p_dn, **mo_class_param_dict) return mo_obj
def parse_filter_obj(sstr, loc, toks): """ Supporting class to parse filter expression. """ # print toks[0] #logger prop_ = toks[0]["prop"] value_ = toks[0]["value"] type_ = "re" if "type_exp" in toks[0]: type_ = toks[0]["type_exp"]["types"] flag_ = "C" if "flag_exp" in toks[0]: flag_ = toks[0]["flag_exp"]["flags"] # print prop_, value_, type_, flag_ #logger if flag_ == "I": value_ = re.sub(r"[a-zA-Z]", lambda x: "[" + x.group().upper() + x.group().lower() + "]", value_) if ParseFilter.is_meta_classid: class_obj = ucscoreutils.load_class(ParseFilter.class_id) prop_mo_meta = class_obj.prop_meta[prop_] if prop_mo_meta: prop_ = prop_mo_meta.xml_attribute sub_filter = create_basic_filter(types[type_], class_=ucsgenutils.word_l( ParseFilter.class_id), property=prop_, value=value_) return sub_filter