summaryrefslogtreecommitdiffstats
path: root/third_party/polymer/v1_0/create_components_summary.py
blob: a5df89c052aec9276454183c54803e1ee0e13193 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import os
import json

COMPONENTS_DIR = 'components-chromium'
COMPONENT_SUMMARY =\
"""Name: %(name)s
Version: %(version)s
Repository: %(repository)s
Tag: %(tag)s
Revision: %(revision)s
Tree link: %(tree)s
"""

for entry in sorted(os.listdir(COMPONENTS_DIR)):
  component_path = os.path.join(COMPONENTS_DIR, entry)
  if not os.path.isdir(component_path):
    continue
  bower_path = os.path.join(component_path, '.bower.json')
  if not os.path.isfile(bower_path):
    raise Exception('%s is not a file.' % bower_path)
  with open(bower_path) as stream:
    info = json.load(stream)
  repository = info['_source']
  tree = 'https%s/tree/%s' % (repository[3:-4], info['_resolution']['tag'])
  print COMPONENT_SUMMARY % {
    'name': info['name'],
    'version': info['version'],
    'repository': repository,
    'tag': info['_resolution']['tag'],
    'revision': info['_resolution']['commit'],
    'tree': tree
  }