<s> """<STR_LIT>""" <EOL> import os <EOL> import re <EOL> import sys <EOL> import requests <EOL> from docopt import docopt <EOL> from clint import args <EOL> from clint . textui import colored , puts , indent <EOL> from . core import ( get_issues , get_single_issue , create_repository , <EOL> close_issue , view_issue , create_issue , find_github_remote ) <EOL> from . config import login , create_config , commit_changes , CONFIG_FILE <EOL> GIT_REPO_ENDPOINT = '<STR_LIT>' <EOL> def version ( ) : <EOL> from . import __version__ <EOL> return "<STR_LIT:.>" . join ( str ( x ) for x in __version__ ) <EOL> def get_help ( ) : <EOL> puts ( '<STR_LIT>' . format ( <EOL> colored . blue ( '<STR_LIT>' ) , <EOL> version ( ) , <EOL> colored . green ( '<STR_LIT>' ) ) ) <EOL> puts ( '<STR_LIT>' . format ( colored . yellow ( '<STR_LIT:source>' ) ) ) <EOL> puts ( '<STR_LIT>' . format ( colored . cyan ( '<STR_LIT>' ) ) ) <EOL> with indent ( <NUM_LIT:4> ) : <EOL> puts ( colored . green ( '<STR_LIT>' ) ) <EOL> puts ( colored . green ( "<STR_LIT>" ) ) <EOL> puts ( colored . green ( "<STR_LIT>" ) ) <EOL> puts ( colored . green ( '<STR_LIT>' ) ) <EOL> puts ( colored . green ( '<STR_LIT>' ) ) <EOL> puts ( colored . green ( "<STR_LIT>" ) ) <EOL> puts ( colored . green ( '<STR_LIT>' ) ) <EOL> puts ( colored . green ( '<STR_LIT>' ) ) <EOL> puts ( colored . green ( '<STR_LIT>' ) ) <EOL> puts ( '<STR_LIT:\n>' ) <EOL> def get_parent_repository ( username_repo ) : <EOL> username , repo = username_repo <EOL> url = GIT_REPO_ENDPOINT % ( username , repo ) <EOL> response = requests . get ( url ) <EOL> data = response . json ( ) <EOL> try : <EOL> parent = data [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> username_repo = parent . split ( '<STR_LIT:/>' ) <EOL> except KeyError : <EOL> pass <EOL> return username_repo <EOL> def get_username_and_repo ( url ) : <EOL> m = re . match ( "<STR_LIT>" , url ) <EOL> if m : <EOL> return m . groups ( ) <EOL> else : <EOL> username_repo = url . split ( '<STR_LIT::>' ) [ <NUM_LIT:1> ] . replace ( '<STR_LIT>' , '<STR_LIT>' ) . split ( '<STR_LIT:/>' ) <EOL> if username_repo [ <NUM_LIT:0> ] == '<STR_LIT>' : <EOL> username_repo = username_repo [ <NUM_LIT:1> : ] <EOL> if len ( username_repo ) == <NUM_LIT:2> : <EOL> info = username_repo <EOL> else : <EOL> username_repo = url . split ( '<STR_LIT:/>' ) [ <NUM_LIT:3> : ] <EOL> username_repo [ <NUM_LIT:1> ] = username_repo [ <NUM_LIT:1> ] . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> info = username_repo <EOL> parent_repo = get_parent_repository ( info ) <EOL> return parent_repo <EOL> def begin ( ) : <EOL> """<STR_LIT>""" <EOL> if os . path . exists ( CONFIG_FILE ) : <EOL> pass <EOL> else : <EOL> create_config ( ) <EOL> commit_changes ( ) <EOL> arguments = docopt ( begin . __doc__ , help = None ) <EOL> if arguments [ '<STR_LIT>' ] or arguments [ '<STR_LIT>' ] : <EOL> puts ( version ( ) ) <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> elif arguments [ '<STR_LIT>' ] or arguments [ '<STR_LIT>' ] or arguments [ '<STR_LIT>' ] : <EOL> get_help ( ) <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> elif arguments [ '<STR_LIT>' ] : <EOL> if arguments [ '<STR_LIT>' ] == None : <EOL> puts ( '<STR_LIT>' . format ( colored . blue ( '<STR_LIT>' ) , <EOL> colored . red ( '<STR_LIT>' ) ) ) <EOL> else : <EOL> project_name = arguments [ '<STR_LIT>' ] <EOL> description = arguments [ '<STR_LIT>' ] or '<STR_LIT>' <EOL> organization = arguments [ '<STR_LIT>' ] or None <EOL> create_repository ( project_name , description , organization = organization ) <EOL> sys . exit ( ) <EOL> elif arguments [ '<STR_LIT>' ] or arguments [ '<STR_LIT>' ] or arguments [ '<STR_LIT>' ] : <EOL> url = find_github_remote ( ) <EOL> username , url = get_username_and_repo ( url ) <EOL> if arguments [ '<STR_LIT>' ] : <EOL> if [ '<STR_LIT>' ] == None : <EOL> puts ( '<STR_LIT>' . format ( colored . blue ( '<STR_LIT>' ) , <EOL> colored . red ( '<STR_LIT>' ) ) ) <EOL> sys . exit ( - <NUM_LIT:1> ) <EOL> else : <EOL> issue_name = arguments [ '<STR_LIT>' ] <EOL> description = arguments [ '<STR_LIT>' ] <EOL> create_issue ( username , url , issue_name , description ) <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> issue_number = arguments [ '<STR_LIT>' ] <EOL> if issue_number is not None : <EOL> if issue_number . startswith ( '<STR_LIT:#>' ) : <EOL> issue_number = issue_number [ <NUM_LIT:1> : ] <EOL> if arguments [ '<STR_LIT>' ] : <EOL> close_issue ( username , url , issue_number ) <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> elif arguments [ '<STR_LIT>' ] : <EOL> view_issue ( username , url , issue_number ) <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> elif arguments [ '<STR_LIT>' ] : <EOL> get_issues ( username , url , ( arguments [ '<STR_LIT>' ] or arguments [ '<STR_LIT>' ] ) ) <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> else : <EOL> get_single_issue ( username , url , issue_number ) <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> else : <EOL> get_issues ( username , url , False ) <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> elif arguments [ '<STR_LIT>' ] or arguments [ '<STR_LIT>' ] or arguments [ '<STR_LIT>' ] : <EOL> username = arguments [ '<STR_LIT:username>' ] or None <EOL> if username is None : <EOL> username = raw_input ( "<STR_LIT>" ) <EOL> if len ( username ) == <NUM_LIT:0> : <EOL> puts ( "<STR_LIT>" . format ( <EOL> colored . blue ( "<STR_LIT>" ) , <EOL> colored . red ( "<STR_LIT>" ) ) ) <EOL> password = arguments [ '<STR_LIT:password>' ] or None <EOL> if password is None : <EOL> import getpass <EOL> password = getpass . getpass ( "<STR_LIT>" % username ) <EOL> login ( username , password ) <EOL> else : <EOL> get_help ( ) <EOL> sys . exit ( <NUM_LIT:0> ) </s>
