⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 graph-dav-servers.py

📁 subversion-1.4.3-1.tar.gz 配置svn的源码
💻 PY
字号:
#!/usr/bin/env python## graph-svn-dav.py by Brian W. Fitzpatrick <fitz@red-bean.com>## This was originally a quick hack to make a pretty picture of svn DAV servers.## I've dropped it in Subversion's repository at the request of Karl Fogel.## Be warned this this script has many dependencies that don't ship with Python.import sysimport fileinputimport datetimeimport timefrom datetime import datetimefrom matplotlib.dates import date2numimport matplotlibmatplotlib.use('Agg')from matplotlib.pylab import *OUTPUT_FILE = '../../www/images/svn-dav-securityspace-survey.png'STATS = """1/1/2003       702/1/2003                 1583/1/2003                 2224/1/2003                 2505/1/2003                 3086/1/2003                 3697/1/2003                 4488/1/2003                 5229/1/2003                 66510/1/2003                78211/1/2003                96912/1/2003               10091/1/2004                11622/1/2004                13073/1/2004                14244/1/2004                17925/1/2004                21136/1/2004                25027/1/2004                29418/1/2004                38639/1/2004                417410/1/2004               418711/1/2004               478312/1/2004               49951/1/2005                55652/1/2005                65053/1/2005                78974/1/2005                87515/1/2005                97936/1/2005               115347/1/2005               128088/1/2005               135459/1/2005               1523310/1/2005              1758811/1/2005              1889312/1/2005              202781/1/2006               210842/1/2006               23861"""def get_date(raw_date):  date = time.strptime(raw_date, "%m/%d/%Y")  date = datetime(date[0], date[1], date[2], date[3])  return datedef get_ordinal_date(date):  # This is the only way I can get matplotlib to do the dates right.  return date2num(date)def parse_stats(str):  dates = []  counts = []  lines = str.split('\n')  for line in lines:    key, val = line.split(' ', 1)    dates.append(int(get_ordinal_date(get_date(key))))    counts.append(int(val.lstrip()))  return dates, countsdef draw_graph(dates, counts):  ###########################################################  # Drawing takes place here.  ax = subplot(111)  ax.xaxis.set_major_formatter( DateFormatter('%b,%y') )  ax.yaxis.set_major_formatter( FormatStrFormatter('%d') )  line = bar(dates, counts,  color='r', width=24)  ylabel('Total # of Public DAV Servers')  lastdate = datetime.fromordinal(dates[len(dates) - 1]).strftime("%B %Y")  xlabel("Data as of " + lastdate)  title('Security Space Survey of Public Subversion DAV Servers')  # End drawing  ###########################################################  png = open(OUTPUT_FILE, 'w')  savefig(png)  png.close()  close()if __name__ == '__main__':  dates, counts = parse_stats(STATS);  draw_graph(dates, counts)  print "Don't forget to update ../../www/svn-dav-securityspace-survey.html!"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -