Skip to content

Commit

Permalink
Add --post flag and pass to mobilesync.rebuild(...)
Browse files Browse the repository at this point in the history
  • Loading branch information
chbrown committed Dec 13, 2020
1 parent 0e8596d commit 547d2b4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions iospy/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,15 @@ def files(ctx: click.Context, domain: str):

@cli.command()
@click.option("--domain", type=str, help="Limit to specific domain.")
@click.option("--post/--raw", help="Run postprocessing on written files.")
@click.option(
"--output",
type=click.Path(exists=True, file_okay=False),
help="Directory to write file structure into. [defaults to current directory]",
default=".",
)
@click.pass_context
def rebuild(ctx: click.Context, domain: str, output: str):
def rebuild(ctx: click.Context, domain: str, post: bool, output: str):
"""
Copy and rename files from backup into `output`.
Expand All @@ -97,7 +98,7 @@ def rebuild(ctx: click.Context, domain: str, output: str):
"""
manifest = ctx.obj["manifest"]
logger.info("Rebuilding file structure from manifest at %s", manifest)
mobilesync.rebuild(manifest, domain=domain, target=output)
mobilesync.rebuild(manifest, domain=domain, target=output, postprocess_files=post)


main = cli.main
Expand Down
5 changes: 4 additions & 1 deletion iospy/mobilesync.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import appdirs

from .util import query
from .util import query, postprocess

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -67,6 +67,7 @@ def rebuild(
manifest: Union[bytes, str, os.PathLike],
domain: str = None,
target: Union[bytes, str, os.PathLike] = ".",
postprocess_files: bool = False,
):
"""
Rebuild the deep structure (creating directories as needed) specified in the
Expand All @@ -86,5 +87,7 @@ def rebuild(
dst.parent.mkdir(parents=True, exist_ok=True)
shutil.copy2(src, dst)
logger.info("Copied %s -> %s", fileID, dst)
if postprocess_files:
postprocess(dst)
else:
logger.debug("Skipping missing file %s -> %s", fileID, relativePath)

0 comments on commit 547d2b4

Please sign in to comment.