Last active
August 29, 2015 14:18
-
-
Save yassu/1a4221aaa9544f776bd4 to your computer and use it in GitHub Desktop.
statics for reading vimrc of vim-jp by using archive file at https://github.com/vim-jp/reading-vimrc/blob/gh-pages/_data/archives.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from yaml import load as _yaml_load | |
from sys import argv | |
from numpy import std | |
archives = _yaml_load(open('archives.yml')) | |
class VimrcStat(): | |
def __init__(self, member_name): | |
member = self._member = member_name | |
self.enter_ids = [] | |
for archive in archives: | |
if member in archive['members']: | |
self.enter_ids.append(archive['id']) | |
self.ids = {_id: int(bool(_id in self.enter_ids)) for _id in | |
range(min(self.enter_ids), max(self.enter_ids) + 1)} | |
@property | |
def start(self): | |
return archives[min(self.enter_ids) - 1]['date'].split()[0] | |
@property | |
def end(self): | |
return archives[max(self.enter_ids) - 1]['date'].split()[0] | |
@property | |
def average(self): | |
return len(self.enter_ids) / (max(self.enter_ids) - min(self.enter_ids) + 1.0) | |
@property | |
def std(self): | |
return std(self.ids.values()) | |
def __str__(self): | |
return ( | |
"start: {start}\n" | |
"end: {end}\n" | |
"average: {ave}\n" | |
"std: {std}\n" | |
).format( | |
start=self.start, end=self.end, ave=self.average, std=self.std) | |
if __name__ == '__main__': | |
usrname = argv[1] | |
stat = VimrcStat(usrname) | |
print(stat) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment