<s> import sys <EOL> import json <EOL> from dateutil . tz import tzlocal <EOL> from datetime import datetime <EOL> from time import time <EOL> import pygit2 <EOL> from . import path <EOL> if <NUM_LIT> <= sys . hexversion < <NUM_LIT> : <EOL> json . encoder . c_make_encoder = None <EOL> __all__ = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:path>' ] <EOL> def make_signature ( name , email , timestamp = None , offset = None , <EOL> default_offset = None ) : <EOL> """<STR_LIT>""" <EOL> if timestamp is None : <EOL> timestamp = time ( ) <EOL> if offset is None and default_offset is None : <EOL> dt = datetime . fromtimestamp ( timestamp ) <EOL> aware = datetime ( dt . year , dt . month , dt . day , dt . hour , dt . minute , <EOL> dt . second , dt . microsecond , tzinfo = tzlocal ( ) ) <EOL> seconds = aware . utcoffset ( ) . days * <NUM_LIT> <EOL> seconds += aware . utcoffset ( ) . seconds <EOL> offset = seconds / <NUM_LIT> <EOL> elif offset is None : <EOL> offset = default_offset <EOL> return pygit2 . Signature ( name , email , timestamp , offset ) <EOL> def treeish_to_tree ( repo , obj ) : <EOL> try : <EOL> obj = repo . revparse_single ( obj ) <EOL> except : <EOL> pass <EOL> if isinstance ( obj , pygit2 . Commit ) : <EOL> return obj . tree <EOL> elif isinstance ( obj , pygit2 . Reference ) : <EOL> oid = obj . resolve ( ) . target <EOL> return repo [ oid ] </s>
