<s> import os <EOL> import sys <EOL> from string import Template <EOL> from subprocess import Popen , PIPE <EOL> from model import cache <EOL> def get_template ( template_path ) : <EOL> fin = open ( template_path , "<STR_LIT:r>" ) <EOL> text = fin . read ( ) . decode ( '<STR_LIT:utf-8>' ) <EOL> return Template ( text ) <EOL> def cache_author ( graph , config ) : <EOL> cache_key = "<STR_LIT>" % config . username <EOL> author = graph . people . index . get_unique ( "<STR_LIT:username>" , config . username ) <EOL> cache . put ( cache_key , author . eid ) if author else None <EOL> return author <EOL> def execute ( command ) : <EOL> pipe = Popen ( command , shell = True , cwd = "<STR_LIT:.>" , stdout = PIPE , stderr = PIPE ) <EOL> ( out , error ) = pipe . communicate ( ) <EOL> pipe . wait ( ) <EOL> return out <EOL> def get_working_dir ( ) : <EOL> working_dir = execute ( "<STR_LIT>" ) . strip ( ) <EOL> validate_git_repo ( working_dir ) <EOL> return os . path . abspath ( working_dir ) <EOL> def get_git_dir ( ) : <EOL> git_dir = execute ( "<STR_LIT>" ) . strip ( ) <EOL> validate_git_repo ( git_dir ) <EOL> return os . path . abspath ( git_dir ) <EOL> def validate_git_repo ( dirname ) : <EOL> if dirname == "<STR_LIT>" : <EOL> print "<STR_LIT>" <EOL> sys . exit ( <NUM_LIT:1> ) </s>
