Skip to content

Commit

Permalink
Propagate verbosity to dump script
Browse files Browse the repository at this point in the history
Summary:
When debugging migration script it's very useful to see the debug script
diagnostic as well.

Test Plan: run migration script locally

Reviewed By: styurin

fbshipit-source-id: 4928f61
  • Loading branch information
ttsugriy authored and facebook-github-bot committed Oct 4, 2017
1 parent e01a80a commit f28fd22
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions scripts/migrations/migrate_include_defs_to_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,17 @@ def load_cell_roots(repo_dir: str) -> Dict[str, str]:
return cell_roots


def load_export_map(repo: str, cell_roots: Dict[str, str], build_file: str):
def load_export_map(repo: str, cell_roots: Dict[str, str], build_file: str, verbose: bool = False):
"""Returns a dictionary with import string keys and all symbols they export as values."""
cell_root_args = []
for cell, root in cell_roots.items():
cell_root_args.extend(['--cell_root', cell + '=' + root])
return json.loads(subprocess.check_output([
os.path.join(MY_DIR, 'dump.py'), '--json',
'--repository', repo] + cell_root_args + [
'export_map',
'--use_load_function_import_string_format',
build_file
]).decode().strip())
dump_script = os.path.join(MY_DIR, 'dump.py')
verbosity_flags = ['-v'] if verbose else []
export_map_flags = ['export_map', '--use_load_function_import_string_format']
dump_command = [dump_script, '--json', '--repository',
repo] + verbosity_flags + cell_root_args + export_map_flags + [build_file]
return json.loads(subprocess.check_output(dump_command).decode().strip())


class Buildozer:
Expand Down Expand Up @@ -104,7 +103,7 @@ def main():
buildozer = Buildozer(args.buildozer, args.repository)
package_dir = os.path.dirname(args.build_file)
package = str(pathlib.Path(package_dir).relative_to(args.repository))
load_funcs = load_export_map(args.repository, cell_roots, args.build_file)
load_funcs = load_export_map(args.repository, cell_roots, args.build_file, args.verbose)
logging.debug(load_funcs)
add_load_funcs(buildozer, load_funcs, package)
remove_include_defs(buildozer, package)
Expand Down

0 comments on commit f28fd22

Please sign in to comment.