• Skip to sidebar navigation
  • Skip to content

Bitbucket

  • More
    ProjectsRepositories
  • Help
    • Online help
    • Learn Git
    • Welcome to Bitbucket
    • Keyboard shortcuts
  • Log In
Alexander Dahl
  1. Alexander Dahl

buildroot

Public
Actions
  • Clone
  • Compare

Learn more about cloning repositories

You have read-only access

Navigation
  • Source
  • Commits
  • Branches
  • All Branches Graph
  • Forks
  1. Alexander Dahl
  2. buildroot

Source

buildroot/utils/size-stats-compare
Thomas PetazzoniThomas Petazzoni committed 7ca9fc3170d01 Jul 2017
Raw file
Source viewDiff to previous
# main #########################################################################
 
1
#!/usr/bin/env python
2
​
3
# Copyright (C) 2016 Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
4
​
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
9
#
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
# General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
​
19
# TODO (improvements)
20
# - support K,M,G size suffixes for threshold
21
# - output CSV file in addition to stdout reporting
22
​
23
import csv
24
import argparse
25
import sys
26
​
27
def read_file_size_csv(inputf, detail=None):
28
    """Extract package or file sizes from CSV file into size dictionary"""
29
    sizes = {}
30
    reader = csv.reader(inputf)
31
​
32
    header = next(reader)
33
    if (header[0] != 'File name' or header[1] != 'Package name' or
34
        header[2] != 'File size' or header[3] != 'Package size'):
35
        print(("Input file %s does not contain the expected header. Are you "
36
               "sure this file corresponds to the file-size-stats.csv "
37
               "file created by 'make graph-size'?") % inputf.name)
38
        sys.exit(1)
39
​
40
    for row in reader:
41
        if detail:
42
            sizes[row[0]] = int(row[2])
43
        else:
44
            sizes[row[1]] = int(row[3])
45
​
46
    return sizes
47
​
48
def compare_sizes(old, new):
49
    """Return delta/added/removed dictionaries based on two input size
50
    dictionaries"""
51
    delta = {}
52
    oldkeys = set(old.keys())
53
    newkeys = set(new.keys())
54
​
55
    # packages/files in both
56
    for entry in newkeys.intersection(oldkeys):
57
        delta[entry] = ('', new[entry] - old[entry])
58
    # packages/files only in new
59
    for entry in newkeys.difference(oldkeys):
60
        delta[entry] = ('added', new[entry])
61
    # packages/files only in old
62
    for entry in oldkeys.difference(newkeys):
63
        delta[entry] = ('removed', -old[entry])
  • Git repository management for enterprise teams powered by Atlassian Bitbucket
  • Atlassian Bitbucket v6.7.2
  • Documentation
  • Request a feature
  • About
  • Contact Atlassian
Atlassian

Everything looks good. We'll let you know here if there's anything you should know about.