def is_object_in(dict_obj, key, cl_val): """ Check object """ ## If is dictionary get the obj_vlauess for the key ## if the if object is not dictionary or ## key obj_vlaues is not string return false # return True if hasattr(dict_obj, 'get'): ## if val we are lookin for is a list, then convet obj_vlaues to list as well if isinstance(cl_val, list): obj_vlaues = [dict_obj.get(key)] ## if dictionary returns None which meance no emlement found if None in obj_vlaues: return False else: # If key dosn't exist return -1 if dict_obj.get(key, -1) == -1: return False obj_vlaues = dict_obj.get(key) ## Check if the obj_vlaues is list or string and is lookup string we ## Are looking for. If yes return True if not retrun False ## If val is a list then check for each element in list ## that is present in the list of the objects properties, if isinstance(cl_val, list): flag = compare_lists(cl_val, obj_vlaues) return flag ## if val in obj_vlaues will return True, if not False return cl_val in obj_vlaues
def test_employee_ATI_WebAlias_sls1231(self): # Set drivers from selenium framework driver = self.driver self.driver.get( "https://idm-prov-dev.humboldt.edu/identity/self-service/hsu/login.jsf" ) # Login as a user and navigate to Requests and Request Accesss setup_login.fischer_login(driver, "sls1231") dashboard_navigate.gotoRequestAccess(driver) dashboard_navigate.selectIncludeSelf(driver) dynamicPermisons = dashboard_navigate.DropdownOptionsListCreate(driver) knownPermisons = user_permissions["sls1231"] boolpermisontest = compare_lists(knownPermisons, dynamicPermisons, "sls1231") if boolpermisontest: pass else: assert 2 == 1
#!/usr/bin/env python from jnpr_devices import srx2 from jnpr.junos import Device from jnpr.junos.utils.config import Config from gather_routes import gather_routes from print_output import print_output from check_connected import check_connected from compare_lists import compare_lists device = Device(**srx2) device.open() if check_connected(device): rtable_b = gather_routes(device) print_output(device, rtable_b, 'ROUTE_TABLE') cfg = Config(device) cfg.lock() cfg.load(path='routes.conf', format='text', merge=True) print(cfg.diff()) cfg.commit() rtable_a = gather_routes(device) print_output(device, rtable_a, 'ROUTE_TABLE') routes_added = compare_lists(rtable_b, rtable_a) print('******* ROUTES_ADDED *******') print(routes_added) cfg.unlock() device.close()
res = prod / (n1 * n2) except ZeroDivisionError: res = "nan" return res if __name__ == '__main__': fname = 'C:\\Users\\navi_\\Dropbox\\NLP\\Corpus\\e960401.htm' text_string = get_text_string(fname) raw_tokens = get_raw_tokens(text_string) clean_tokens = clean_tokens(raw_tokens) writeList( clean_tokens, 'C:\\Users\\navi_\\Dropbox\\NLP\\Programas\\e960401_clean_tokens.txt') difference = compare_lists(raw_tokens, clean_tokens) writeList( sorted(difference), 'C:\\Users\\navi_\\Dropbox\\NLP\\Programas\\e960401_difference.txt') """bag_e = context_word(clean_tokens, 'empresa', 8) bag_c = context_word(clean_tokens, 'compañía', 8) bag_a = context_word(clean_tokens, 'agua', 8) voc=set(clean_tokens) vectore = np.array(vsm(bag_e, list(voc))) vectorc = np.array(vsm(bag_c, list(voc))) vectora = np.array(vsm(bag_a, list(voc))) simec = cosv(vectore, vectorc) simea = cosv(vectore, vectora)