• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python
2# Copyright 2017 The Chromium Authors
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6import json
7import shutil
8import sys
9
10import merge_api
11
12
13def noop_merge(output_json, jsons_to_merge):
14  """Use the first supplied JSON as the output JSON.
15
16  Primarily intended for unsharded tasks.
17
18  Args:
19    output_json: A path to a JSON file to which the results should be written.
20    jsons_to_merge: A list of paths to JSON files.
21  """
22  if len(jsons_to_merge) > 1:
23    print('Multiple JSONs provided: %s' % (','.join(jsons_to_merge)),
24          file=sys.stderr)
25    return 1
26  if jsons_to_merge:
27    shutil.copyfile(jsons_to_merge[0], output_json)
28  else:
29    with open(output_json, 'w') as f:
30      json.dump({}, f)
31  return 0
32
33
34def main(raw_args):
35  parser = merge_api.ArgumentParser()
36  args = parser.parse_args(raw_args)
37
38  return noop_merge(args.output_json, args.jsons_to_merge)
39
40
41if __name__ == '__main__':
42  sys.exit(main(sys.argv[1:]))
43