Skip to content

Instantly share code, notes, and snippets.

@yassu
Last active August 29, 2015 14:18
Show Gist options
  • Save yassu/1a4221aaa9544f776bd4 to your computer and use it in GitHub Desktop.
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
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