def add_file(self, folder_list: list, file_block: QPCBlock) -> None: for file_path in file_block.get_list(): file_path = self.replace_macros(file_path) if check_file_path_glob(file_path): self._add_file_glob(folder_list, file_path, file_block) else: self._add_file_internal(folder_list, file_path, file_block)
def _parse_files(self, files_block: QPCBlock, project: ProjectPass, folder_list: list) -> None: if files_block.solve_condition(project.macros): for block in files_block.items: if not block.solve_condition(project.macros): continue if block.key == "folder": folder_list.append(block.values[0]) self._parse_files(block, project, folder_list) folder_list.remove(block.values[0]) elif block.key == "-": project.remove_file(folder_list, block) else: project.add_file(folder_list, block) if block.items: for file_path in block.get_list(): if check_file_path_glob(file_path): [ self._source_file(block, project, found_file) for found_file in glob.glob(file_path) ] else: self._source_file(block, project, file_path)
def _parse_build_step_glob(self, step: list, event: QPCBlock, item: QPCBlock, *arg_list): event_args = replace_macros_list(self._proj.macros, *arg_list) for index, event_macro in enumerate(event_args): if check_file_path_glob(event_macro): files = glob.glob(event_macro, recursive=True) [self._parse_build_step_call(step, event, file) for file in files] else: self._parse_build_step_call(step, event, event_macro)
def remove_file(self, folder_list: list, file_block: QPCBlock) -> None: for file_path in file_block.values: file_path = self.replace_macros(file_path) if check_file_path_glob(file_path): self._remove_file_glob(folder_list, file_path, file_block) else: self._remove_file_internal(folder_list, file_path, file_block)
def add_project_by_script(self, project_path: str) -> bool: if check_file_path_glob(project_path): for found_file in glob.glob(project_path): self.add_project( os.path.splitext(os.path.basename(found_file))[0], found_file) return True elif os.path.isfile(project_path): self.add_project( os.path.splitext(os.path.basename(project_path))[0], project_path) return True # elif not self.is_project_added(project_path) and project_path not in self.shared.groups: return False
def add_item(item_list: list, _item: str): if check_file_path_glob(_item): item_list.extend(glob.glob(_item)) else: item_list.append(_item)