Best Python code snippet using autotest_python
data_dir.py
Source:data_dir.py
...13class SubdirList(list):14 """15 List of all non-hidden subdirectories beneath basedir16 """17 def __in_filter__(self, item):18 if self.filterlist:19 for _filter in self.filterlist:20 if item.count(str(_filter)):21 return True22 return False23 else:24 return False25 def __set_initset__(self):26 for dirpath, dirnames, filenames in os.walk(self.basedir):27 del filenames # not used28 # Don't modify list while in use29 del_list = []30 for _dirname in dirnames:31 if _dirname.startswith('.') or self.__in_filter__(_dirname):32 # Don't descend into filtered or hidden directories33 del_list.append(_dirname)34 else:35 self.initset.add(os.path.join(dirpath, _dirname))36 # Remove items in del_list from dirnames list37 for _dirname in del_list:38 del dirnames[dirnames.index(_dirname)]39 def __init__(self, basedir, filterlist=None):40 self.basedir = os.path.abspath(str(basedir))41 self.initset = set([self.basedir]) # enforce unique items42 self.filterlist = filterlist43 self.__set_initset__()44 super(SubdirList, self).__init__(self.initset)45class SubdirGlobList(SubdirList):46 """47 List of all files matching glob in all non-hidden basedir subdirectories48 """49 def __initset_to_globset__(self):50 globset = set()51 for dirname in self.initset: # dirname is absolute52 pathname = os.path.join(dirname, self.globstr)53 for filepath in glob.glob(pathname):54 if not self.__in_filter__(filepath):55 globset.add(filepath)56 self.initset = globset57 def __set_initset__(self):58 super(SubdirGlobList, self).__set_initset__()59 self.__initset_to_globset__()60 def __init__(self, basedir, globstr, filterlist=None):61 self.globstr = str(globstr)62 super(SubdirGlobList, self).__init__(basedir, filterlist)63def get_root_dir():64 return ROOT_DIR65def get_data_dir():66 return DATA_DIR67def get_tmp_dir(public=True):68 """...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!