<s> from __future__ import unicode_literals <EOL> from pullreqsreviewcomments import PullReviewComments <EOL> from . . messages import PullRequest <EOL> from . . messages import CommitMessage <EOL> from . . requests import PullRequestResponse <EOL> from . . requests import PullRequestListResponse <EOL> class PullRequests : <EOL> def __init__ ( self , client ) : <EOL> self . client = client <EOL> self . reviewcomments = PullReviewComments ( self . client ) <EOL> def list ( self , repo , state = None , user = None ) : <EOL> query = None <EOL> if state : <EOL> query = { '<STR_LIT:state>' : state } <EOL> return self . client . get ( '<STR_LIT>' % ( self . client . user ( user ) , <EOL> repo ) , query = query , msg_type = PullRequestListResponse ) <EOL> def get ( self , repo , id , user = None ) : <EOL> return self . client . get ( <EOL> '<STR_LIT>' % ( <EOL> self . client . user ( user ) , repo , id ) , msg_type = PullRequestResponse ) <EOL> def create ( self , repo , title , base , head , body = None , user = None ) : <EOL> msg = PullRequest ( <EOL> title = title , <EOL> base = base , <EOL> head = head , <EOL> body = body ) <EOL> return self . _create ( repo = repo , msg = msg , user = user ) <EOL> def _create ( self , repo , msg , user = None ) : <EOL> return self . client . post ( <EOL> '<STR_LIT>' % ( self . client . user ( user ) , repo ) , data = msg , <EOL> msg_type = PullRequestResponse ) <EOL> def create_from_issue ( self , repo , issue , base , head , user = None ) : <EOL> msg = PullRequest ( <EOL> issue = issue , <EOL> base = base , <EOL> head = head ) <EOL> return self . client . post ( <EOL> '<STR_LIT>' % ( <EOL> self . client . user ( user ) , repo ) , data = msg , msg_type = PullRequestResponse ) <EOL> def list_commits ( self , repo , id , user = None ) : <EOL> return self . client . get ( <EOL> '<STR_LIT>' % ( <EOL> self . client . user ( user ) , repo , id ) , msg_type = None ) <EOL> def list_files ( self , repo , id , user = None ) : <EOL> return self . client . get ( <EOL> '<STR_LIT>' % ( <EOL> self . client . user ( user ) , repo , id ) , msg_type = None ) <EOL> def get_if_merged ( self , repo , id , user = None ) : <EOL> return self . client . get ( <EOL> '<STR_LIT>' % ( <EOL> self . client . user ( user ) , repo , id ) , msg_type = None ) <EOL> def merge ( self , repo , id , commit_message = None , user = None ) : <EOL> if commit_message : <EOL> msg = CommitMessage ( <EOL> commit_message = commit_message ) <EOL> return self . client . put ( <EOL> '<STR_LIT>' % ( <EOL> self . client . user ( user ) , repo , id ) , data = msg ) <EOL> else : <EOL> return self . client . put ( <EOL> '<STR_LIT>' % ( <EOL> self . client . user ( user ) , repo , id ) ) </s>
