Admin/lib/scripts/churn_pie
author haftmann
Wed, 11 Jan 2017 21:32:46 +0100
changeset 64879 58525e7f721f
parent 56427 5cbaf18d0dfb
child 64881 9eff4c62579a
permissions -rwxr-xr-x
proper treatment of utf-8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
56427
5cbaf18d0dfb more standard hash-bang (python *is* canonical according to Admin/PLATFORMS);
wenzelm
parents: 56417
diff changeset
     1
#!/usr/bin/env python
56417
04d0083cb9e5 churning pie charts (with non-canonical prerequisites!)
haftmann
parents:
diff changeset
     2
04d0083cb9e5 churning pie charts (with non-canonical prerequisites!)
haftmann
parents:
diff changeset
     3
import re
04d0083cb9e5 churning pie charts (with non-canonical prerequisites!)
haftmann
parents:
diff changeset
     4
from pychart import theme, pie_plot, area, fill_style, arrow, legend
04d0083cb9e5 churning pie charts (with non-canonical prerequisites!)
haftmann
parents:
diff changeset
     5
import sys
04d0083cb9e5 churning pie charts (with non-canonical prerequisites!)
haftmann
parents:
diff changeset
     6
04d0083cb9e5 churning pie charts (with non-canonical prerequisites!)
haftmann
parents:
diff changeset
     7
re_entry = re.compile(R'^(.*\S+)\s+(\d+)\s*\**\s*$')
04d0083cb9e5 churning pie charts (with non-canonical prerequisites!)
haftmann
parents:
diff changeset
     8
04d0083cb9e5 churning pie charts (with non-canonical prerequisites!)
haftmann
parents:
diff changeset
     9
theme.get_options()
04d0083cb9e5 churning pie charts (with non-canonical prerequisites!)
haftmann
parents:
diff changeset
    10
04d0083cb9e5 churning pie charts (with non-canonical prerequisites!)
haftmann
parents:
diff changeset
    11
data = []
04d0083cb9e5 churning pie charts (with non-canonical prerequisites!)
haftmann
parents:
diff changeset
    12
04d0083cb9e5 churning pie charts (with non-canonical prerequisites!)
haftmann
parents:
diff changeset
    13
for line in sys.stdin.readlines():
64879
58525e7f721f proper treatment of utf-8
haftmann
parents: 56427
diff changeset
    14
    match = re_entry.match(unicode(line, 'utf-8'))
56417
04d0083cb9e5 churning pie charts (with non-canonical prerequisites!)
haftmann
parents:
diff changeset
    15
    data.append((match.group(1), int(match.group(2))))
04d0083cb9e5 churning pie charts (with non-canonical prerequisites!)
haftmann
parents:
diff changeset
    16
04d0083cb9e5 churning pie charts (with non-canonical prerequisites!)
haftmann
parents:
diff changeset
    17
plot = pie_plot.T(data = data, arc_offsets = [],
04d0083cb9e5 churning pie charts (with non-canonical prerequisites!)
haftmann
parents:
diff changeset
    18
  shadow = (2, -2, fill_style.gray50), label_offset = 10, arrow_style = arrow.a3)
04d0083cb9e5 churning pie charts (with non-canonical prerequisites!)
haftmann
parents:
diff changeset
    19
04d0083cb9e5 churning pie charts (with non-canonical prerequisites!)
haftmann
parents:
diff changeset
    20
ar = area.T(size = (500, 500), legend = legend.T(), x_grid_style = None, y_grid_style = None)
04d0083cb9e5 churning pie charts (with non-canonical prerequisites!)
haftmann
parents:
diff changeset
    21
ar.add_plot(plot)
04d0083cb9e5 churning pie charts (with non-canonical prerequisites!)
haftmann
parents:
diff changeset
    22
04d0083cb9e5 churning pie charts (with non-canonical prerequisites!)
haftmann
parents:
diff changeset
    23
ar.draw()