def _copy_resources_from_zip(self, list, dir, pack): wiki_dir = Path(os.path.join(settings.MEDIA_ROOT, settings.WIKI_CACHE_DIR)) nonwiki_dir = Path(pack.user.profile.media_path) for f in list: f = Path(f).name f = Path(os.path.join(dir, f)) if f.name.startswith("wiki__"): f2 = Path.joinpath(wiki_dir, Path(f.name)) if Path.exists(wiki_dir) is False: wiki_dir.mkdir() if Path.exists(f2) is False: Path.copyfile(f, f2) else: f2 = Path.joinpath(nonwiki_dir, Path(f.name)) if Path.exists(nonwiki_dir) is False: nonwiki_dir.mkdir() if Path.exists(f2) is False: try: Path.copyfile(f, f2) except FileNotFoundError: # some icons may be missing pass
def _copy_resources_from_zip(self, list, dir, pack): wiki_dir = Path( os.path.join(settings.MEDIA_ROOT, settings.WIKI_CACHE_DIR)) nonwiki_dir = Path(pack.user.profile.media_path) for f in list: f = Path(f).name f = Path(os.path.join(dir, f)) if f.name.startswith("wiki__"): f2 = Path.joinpath(wiki_dir, Path(f.name)) if Path.exists(wiki_dir) is False: wiki_dir.mkdir() if Path.exists(f2) is False: Path.copyfile(f, f2) else: f2 = Path.joinpath(nonwiki_dir, Path(f.name)) if Path.exists(nonwiki_dir) is False: nonwiki_dir.mkdir() if Path.exists(f2) is False: try: Path.copyfile(f, f2) except FileNotFoundError: # some icons may be missing pass
def copy_json(self): self.create_json() Path.copyfile(self.json_file, Path.joinpath(self.output_dir, Path("a.json")))