-
Notifications
You must be signed in to change notification settings - Fork 0
Home
shak-mar edited this page Aug 29, 2014
·
4 revisions
Welcome to the push_analyzer
wiki!
The push_analyzer
project is a library for analyzing pushes to git
repositories. As an example, you can use it to generate data that an irc bot
broadcasts. This wiki gives you an overview of the push_analyzer
design.
To start a project using this library:
mkdir myproject && cd myproject
git clone https://github.com/firecoders/push_analyzer.git
You can now start programming. This example main.py would poll the
push_analyzer
project every 20 seconds and print the changes in python dict
format:
#!/usr/bin/env python3
from push_analyzer.utils.git import extract_repo_name
from push_analyzer.utils.system import cd
from push_analyzer.utils.misc import home_directory
from push_analyzer.poller import Poller
from push_analyzer.analyzer import analyze_push
url = 'https://github.com/firecoders/push_analyzer.git'
repo_name = extract_repo_name ( url )
directory = home_directory + '/myproject/'
poller = Poller ( url, work_dir = directory )
def analyze ( stamp_pre, stamp_post ):
refs_pre = poller.revisions [ stamp_pre ]
refs_post = poller.revisions [ stamp_post ]
with cd ( directory + repo_name ):
changes = analyze_push ( refs_pre, refs_post )
for change in changes:
print ( change )
poller.ref_change.subscribe ( analyze )
if __name__ == "__main__":
poller.loop ()