Changeset View
Changeset View
Standalone View
Standalone View
bin/utils.py
Show First 20 Lines • Show All 844 Lines • ▼ Show 20 Line(s) | 837 | if CraftCore.compiler.isMacOS: | |||
---|---|---|---|---|---|
845 | lines.pop(0)# name of the library | 845 | lines.pop(0)# name of the library | ||
846 | for line in lines: | 846 | for line in lines: | ||
847 | match = infoRe.match(line) | 847 | match = infoRe.match(line) | ||
848 | if match: | 848 | if match: | ||
849 | deps.append(match[1]) | 849 | deps.append(match[1]) | ||
850 | return deps | 850 | return deps | ||
851 | 851 | | |||
852 | 852 | | |||
853 | def regexFileFilter(filename : os.DirEntry, root : str, pattern : [re]=None) -> bool: | ||||
854 | """ return False if file does not match pattern""" | ||||
855 | relFilePath = os.path.relpath(filename.path, root) | ||||
856 | for pattern in pattern: | ||||
857 | if pattern.search(relFilePath): | ||||
858 | CraftCore.log.debug(f"regExDirFilter: {relFilePath} matches: {pattern.pattern}") | ||||
859 | return True | ||||
860 | return False | ||||
861 | | ||||
853 | def filterDirectoryContent(root, whitelist=lambda f, root: True, blacklist=lambda g, root: False): | 862 | def filterDirectoryContent(root, whitelist=lambda f, root: True, blacklist=lambda g, root: False): | ||
854 | """ | 863 | """ | ||
855 | Traverse through a directory tree and return every | 864 | Traverse through a directory tree and return every | ||
856 | filename that the function whitelist returns as true and | 865 | filename that the function whitelist returns as true and | ||
857 | which do not match blacklist entries | 866 | which do not match blacklist entries | ||
858 | """ | 867 | """ | ||
859 | dirs = [root] | 868 | dirs = [root] | ||
860 | while dirs: | 869 | while dirs: | ||
Show All 15 Lines |