Utility files_crawl
Utility that allow to search files in folders and where paths are indexed in an object. Objects can be added and iterated.
Container of classes and function of the files object.
Example of usage:
module files_crawl
- files_crawl.load_obj_files()[source]
- Synopsis:
Returns empty files object
- Dependences:
None
- Args:
None
- Optional parameters:
None
- Returns:
Empty files object
- Error:
Not handle
Note
None
- files_crawl.read_folder_list_file_multi(folder, extNoPoint=[''], prefix='', max_recursive_level=0, data=False)[source]
- Synopsis:
Returns a list of paths to images in a folder
Filtered by extension images and / or filter by a prefix
- Dependences:
None
- Args:
folder: folder to crawl
- Optional parameters:
extNoPoint = [“”]: list or extension or single extension to filter. Example extNoPoint = [“jpg”, “png”] or extNoPoint = “jpg”
prefix = “”: prefix to filter. Example prefix = “000”
max_recursive_level = 0: maximum hycherarchy level of recursivity form folder to look in subfolders
data = False: populate extra data
- Returns:
List of object images (see obj_files())
- Error:
Not handle
Note
Attributes of object images:
obj_images[index].path
obj_images[index].folder
obj_images[index].file_name
obj_images[index].extension
obj_images[index].file_name_noExt
obj_images[index].path_noExt
Is iterable
- files_crawl.read_folder_list_files(folder, extNoPoint, prefix='', max_recursive_level=0, data=False, case_sensitive=False)[source]
- Synopsis:
Returns a list of paths to files in a folder
Filtered by extension images and / or filter by a prefix
- Dependences:
None
- Args:
folder: folder to look in
extNoPoint: single extension to filter, for example extNoPoint = “jpg”
- Optional parameters:
prefix = “”: prefix of files to filter with
max_recursive_level = 0: maximum hycherarchy level of recursivity from starting folder to look in subfolders
data = False: populet extra data
- Returns:
List of object images (see obj_files())
- Error:
Not handle
Note
Attributes of object images:
obj_images[index].path
obj_images[index].folder
obj_images[index].file_name
obj_images[index].extension
obj_images[index].file_name_noExt
obj_images[index].path_noExt
Is iterable
Is case sensitive
See Example 1
sub-class object files
- class files_crawl._files[source]
Object files
- Platform:
Unix, Windows
- Synopsis:
Container of files paths names
- Get:
obj[index].path: return the full path to the file
- Get:
obj[index].folder: return the folder of the file
- Get:
obj[index].file_name: return the file name
- Get:
obj[index].extension: return the file extension
- Get:
obj[index].file_name_noExt: return file name without extension basename
- Get:
obj[index].path_noExt: return path without extension
- Get:
obj.folders: list of folders indexed
Note
Paths are indexed as a list so it can be use as a list
Use obj[index].property or obj[index].function
Is iterable (not reversed)
Methods as len and print emulates lists behaviour
Objects can be added
See also
- get_index_by_path(path)[source]
- Synopsis:
Get index by path, if is not indexed return -1
- Args:
path: full path to file
- Returns:
Index of the path