aboutsummaryrefslogtreecommitdiff
path: root/license_summary.py
diff options
context:
space:
mode:
authorDafydd Harries <daf@rhydd.org>2013-03-18 01:53:29 -0400
committerDafydd Harries <daf@rhydd.org>2013-03-18 01:53:29 -0400
commitd152ed13ec0b99e1969da3ee37fec6e41b2172e2 (patch)
tree4d7e03ad7807bd7c2c52a90ec13a503feb3aa487 /license_summary.py
parent97e0bc2e76ee25633944de3d62eaa00380fcb6c4 (diff)
make scripts import-safe
Diffstat (limited to 'license_summary.py')
-rw-r--r--license_summary.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/license_summary.py b/license_summary.py
index 7e7899c..e5edaba 100644
--- a/license_summary.py
+++ b/license_summary.py
@@ -2,9 +2,6 @@
import pandas as pd
-store = pd.HDFStore('cp.h5')
-cpf = store['cp_files']
-
def histogram(values):
hist = {}
@@ -14,8 +11,12 @@ def histogram(values):
return hist
-licenses = histogram(cpf['_license'])
+if __name__ == '__main__':
+ store = pd.HDFStore('cp.h5')
+ cpf = store['cp_files']
+
+ licenses = list(histogram(cpf['_license']))
-for (k, v) in sorted(licenses.iteritems(), key=lambda x: x[1], reverse=True):
- print '%-40s %6d' % (k.encode('utf8'), v)
+ for (k, v) in sorted(licenses, key=lambda x: x[1], reverse=True):
+ print '%-40s %6d' % (k.encode('utf8'), v)