def copy_static_persample(self): """Copy statics file that are spearately produced by each sample. It reads the result information to be embedded from attribute :attr:`embed_result_persample`. For each description dict, say **desc**, in the list *embed_result_persample*, it finds files with each globbing patterns for each *sample*:: <self.result_root>/desc['src']/sample.full_name/desc['patterns'] and copies them to:: <self.report_root>/static/desc['dest']/sample.full_name/ Examples -------- If we have samples with full name: *A_R1*, and *B*. For stage .. code-block:: python3 class PerSampleStage(Stage): embed_result_persample = [{ 'src': 'from', 'patterns': ['foo', 'bar'], 'dest': 'to' }] the static files are mapped:: <result_root>/from/A_R1/foo -> <report>/static/to/A_R1/foo <result_root>/from/A_R1/bar -> <report>/static/to/A_R1/bar <result_root>/from/B/foo -> <report>/static/to/B/foo <result_root>/from/B/bar -> <report>/static/to/B/bar .. versionadded:: 0.3 """ for desc in self.embed_result_persample: all_src_root = self.result_root / desc['src'] all_dest_root = self.report_root / 'static' for sample in self.job_info.sample_list: # TODO: fuzzy match sample.name sp_src_root = all_src_root / sample.full_name sp_dest_root = all_dest_root / desc['dest'] / sample.full_name sp_dest_root.mkdir(parents=True) file_list = discover_file_by_patterns( sp_src_root, desc['patterns']) for fp in file_list: copy(fp, sp_dest_root)
def copy_static_joint(self): """Copy static files that are jointly produced from all samples. It reads the result information to be embedded from attribute :attr:`embed_result_joint`. For each description dict, say `desc`, in the list **embed_result_joint**, it finds files with each globbing pattern:: <self.result_root>/desc['src']/desc['patterns'] and copies them to:: <self.report_root>/static/desc['dest']/ Examples -------- For stage .. code-block:: python3 class JointStage(Stage): embed_result_joint = [{ 'src': 'from', 'patterns': ['*.jpg', 'sub_dir/bar'], 'dest': 'to' }, { 'src': 'deep/src', 'patterns': 'foo', 'dest': 'deeper/alt' }] the static files are mapped:: <result_root>/from/*.jpg -> <report>/static/to/*.jpg <result_root>/from/sub_dir/bar -> <report>/static/to/bar <result_root>/deep/src/foo -> <report>/static/deeper/alt/foo .. versionadded:: 0.3 """ for desc in self.embed_result_joint: src_root = self.result_root / desc['src'] dest_root = self.report_root / 'static' / desc['dest'] if not dest_root.exists(): dest_root.mkdir(parents=True) file_list = discover_file_by_patterns(src_root, desc['patterns']) for fp in file_list: copy(fp, dest_root)