<s> """<STR_LIT>""" <EOL> from __future__ import print_function <EOL> import click <EOL> import webbrowser <EOL> import turnstile . common . config as config <EOL> import turnstile . common . git as git <EOL> import turnstile . common . github as github <EOL> import turnstile . models . specifications as specifications <EOL> @ click . command ( '<STR_LIT>' ) <EOL> @ click . argument ( '<STR_LIT>' , required = False ) <EOL> def cmd ( reference = '<STR_LIT>' ) : <EOL> """<STR_LIT>""" <EOL> repository = git . get_repository ( ) <EOL> if not repository : <EOL> click . secho ( '<STR_LIT>' , fg = '<STR_LIT>' , bold = True ) <EOL> raise click . Abort <EOL> options = config . load_repository_configuration ( repository . working_dir ) . get ( '<STR_LIT>' , { } ) <EOL> allowed_schemes = options . get ( '<STR_LIT>' , [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> allowed_formats = options . get ( '<STR_LIT>' , { '<STR_LIT>' } ) <EOL> try : <EOL> commit = repository . commit ( reference ) <EOL> except git . BadName : <EOL> click . secho ( "<STR_LIT>" . format ( reference = reference ) , fg = '<STR_LIT>' , bold = True ) <EOL> raise click . Abort <EOL> specification = specifications . get_specification ( commit . message , allowed_formats , allowed_schemes ) <EOL> specification_format = specification . format <EOL> if not specification_format : <EOL> click . secho ( "<STR_LIT>" , fg = '<STR_LIT>' , bold = True ) <EOL> raise click . Abort <EOL> if specification_format == '<STR_LIT>' : <EOL> url = specification . identifier <EOL> elif specification_format == '<STR_LIT>' : <EOL> origin = repository . remote ( '<STR_LIT>' ) <EOL> git_url = origin . config_reader . get ( '<STR_LIT:url>' ) <EOL> repository = github . extract_repository_from_url ( git_url ) <EOL> if repository : <EOL> issue = github . extract_issue_number ( specification . identifier ) <EOL> url = '<STR_LIT>' . format ( ** locals ( ) ) <EOL> else : <EOL> click . secho ( "<STR_LIT>" . format ( git_url ) , fg = '<STR_LIT>' , bold = True ) <EOL> raise click . Abort <EOL> else : <EOL> url = None <EOL> if url : <EOL> click . secho ( '<STR_LIT>' . format ( url ) ) <EOL> webbrowser . open ( url ) <EOL> else : <EOL> click . secho ( "<STR_LIT>" . format ( specification_format ) , fg = '<STR_LIT>' , bold = True ) <EOL> raise click . Abort </s>
