Every line of 'open all files in directory python' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
301 def list_all_files(dir): 302 try: 303 filenames = [name for name in os.listdir(dir) if os.path.isfile(os.path.join(dir, name))] 304 return filenames 305 except Exception as e: 306 if DEBUG_FLAG: 307 sys.stderr.write("Naked Framework Error: unable to generate directory file list with the list_all_files() function (Naked.toolshed.system).") 308 raise e
83 def _find_files(dir_, regex='*.*'): 84 """Walk recursively through all dirs in 'dir_'. 85 Yield all files in 'dir_' matching 'regex' with absolute path 86 """ 87 abs_path = os.path.abspath(dir_) 88 if not os.path.isdir(abs_path): 89 logging.warning('does not exist/is not a directory: ' + abs_path) 90 for root, dirnames, filenames in os.walk(abs_path): 91 for filename in fnmatch.filter(filenames, regex): 92 yield os.path.join(root, filename)
55 def open_dir(d): 56 """From: http://stackoverflow.com/a/1795849/965332""" 57 if sys.platform == 'win32': 58 os.startfile(d) 59 elif sys.platform == 'darwin': 60 subprocess.Popen(['open', d]) 61 else: 62 subprocess.Popen(['xdg-open', d])
45 def files_in(*dirs): 46 dir = os.path.join(*dirs) 47 files = os.listdir(dir) 48 return [os.path.join(dir, f) for f in files]
1181 def loadDir(self, path): 1182 """ Create a project with the dir's name and add all files 1183 contained in the directory to it. 1184 extensions is a komma separated list of extenstions of files 1185 to accept... 1186 """ 1187 1188 # if the path does not exist, stop 1189 path = os.path.abspath(path) 1190 if not os.path.isdir(path): 1191 print("ERROR loading dir: the specified directory does not exist!") 1192 return 1193 1194 # get extensions 1195 extensions = pyzo.config.advanced.fileExtensionsToLoadFromDir 1196 extensions = extensions.replace(',',' ').replace(';',' ') 1197 extensions = ["."+a.lstrip(".").strip() for a in extensions.split(" ")] 1198 1199 # init item 1200 item = None 1201 1202 # open all qualified files... 1203 self._tabs.setUpdatesEnabled(False) 1204 try: 1205 filelist = os.listdir(path) 1206 for filename in filelist: 1207 filename = os.path.join(path, filename) 1208 ext = os.path.splitext(filename)[1] 1209 if str(ext) in extensions: 1210 item = self.loadFile(filename, False) 1211 finally: 1212 self._tabs.setUpdatesEnabled(True) 1213 self._tabs.updateItems() 1214 1215 # return lastopened item 1216 return item
17 def getFiles(dir): 18 base = dir 19 subs = [] 20 21 for node in os.listdir(dir): 22 print 'looking at "', 23 print node, 24 print '"', 25 if os.path.isfile(node): 26 print '...yielding' 27 yield node 28 else: 29 print '...appending' 30 subs.append(os.path.join(base, node)) 31 32 for subdir in subs: 33 print 'inspecting ' 34 print subdir 35 for thing in getFiles(subdir): 36 yield thing
221 def recurse_find_python_files(folder_io, except_paths=()): 222 for folder_io, file_io in recurse_find_python_folders_and_files(folder_io, except_paths): 223 if file_io is not None: 224 yield file_io
30 def walk_files(directory, match='*'): 31 """Generator function to iterate through all files in a directory 32 recursively which match the given filename match parameter. 33 """ 34 for root, dirs, files in os.walk(directory): 35 for filename in fnmatch.filter(files, match): 36 yield os.path.join(root, filename)
328 def _walk_files(): 329 # Check for a shortcut when running the tests interactively. 330 # If a BOTOCORE_TEST env var is defined, that file is used as the 331 # only test to run. Useful when doing feature development. 332 single_file = os.environ.get('BOTOCORE_TEST') 333 if single_file is not None: 334 yield os.path.abspath(single_file) 335 else: 336 for root, _, filenames in os.walk(TEST_DIR): 337 for filename in filenames: 338 yield os.path.join(root, filename)
108 def search_for_files(self, name): 109 res_filewrappers = [] 110 if self._validate_file_query_input(name): 111 path_name = self._root + "%" + name 112 for row in self._db_wrapper.select_on_filename(path_name): 113 res_filewrappers.append(FileWrapper(name, self._root, 114 row[0], row[1])) 115 return res_filewrappers