# HG changeset patch # User Ludovic Chabant # Date 1499059198 25200 # Node ID f13d618cfec69ab4992efafe5e9518107d01cc8d # Parent f77f9dcba072c08b0b976cc759dd1df54c49e5d2 themes: Allow keeping local overrides when copying a theme locally. diff -r f77f9dcba072 -r f13d618cfec6 piecrust/commands/builtin/themes.py --- a/piecrust/commands/builtin/themes.py Sun Jul 02 22:15:47 2017 -0700 +++ b/piecrust/commands/builtin/themes.py Sun Jul 02 22:19:58 2017 -0700 @@ -103,24 +103,24 @@ dst_path = os.path.join(app_dir, rel_dirpath, name) copies.append((src_path, dst_path)) - conflicts = [] + conflicts = set() for c in copies: if os.path.exists(c[1]): - conflicts.append(c[1]) + conflicts.add(c[1]) if conflicts: - logger.warning("Some website files will be overwritten:") + logger.warning("Some website files override theme files:") for c in conflicts: logger.warning(os.path.relpath(c, app_dir)) - logger.warning("Are you sure? [Y/n]") - ans = input() - if len(ans) > 0 and ans.lower() not in ['y', 'yes']: - return 1 + logger.warning("") + logger.warning("The local website files will be preserved, and " + "the conflicting theme files won't be copied " + "locally.") for c in copies: - logger.info(os.path.relpath(c[1], app_dir)) - if not os.path.exists(os.path.dirname(c[1])): - os.makedirs(os.path.dirname(c[1])) - shutil.copy2(c[0], c[1]) + if not c[1] in conflicts: + logger.info(os.path.relpath(c[1], app_dir)) + os.makedirs(os.path.dirname(c[1]), exist_ok=True) + shutil.copy2(c[0], c[1]) def _linkTheme(self, ctx): if not os.path.isdir(ctx.args.theme_dir):