<s> from __future__ import ( absolute_import , division , generators , nested_scopes , print_function , <EOL> unicode_literals , with_statement ) <EOL> import json <EOL> from hashlib import sha1 <EOL> from pants . base . payload_field import PayloadField <EOL> class PythonArtifact ( PayloadField ) : <EOL> """<STR_LIT>""" <EOL> class MissingArgument ( Exception ) : pass <EOL> class UnsupportedArgument ( Exception ) : pass <EOL> UNSUPPORTED_ARGS = frozenset ( [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] ) <EOL> def __init__ ( self , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> self . _kw = kwargs <EOL> self . _binaries = { } <EOL> def has ( name ) : <EOL> value = self . _kw . get ( name ) <EOL> if value is None : <EOL> raise self . MissingArgument ( '<STR_LIT>' . format ( name ) ) <EOL> return value <EOL> def misses ( name ) : <EOL> if name in self . _kw : <EOL> raise self . UnsupportedArgument ( '<STR_LIT>' . format ( name ) ) <EOL> self . _version = has ( '<STR_LIT:version>' ) <EOL> self . _name = has ( '<STR_LIT:name>' ) <EOL> for arg in self . UNSUPPORTED_ARGS : <EOL> misses ( arg ) <EOL> @ property <EOL> def name ( self ) : <EOL> return self . _name <EOL> @ property <EOL> def version ( self ) : <EOL> return self . _version <EOL> @ property <EOL> def key ( self ) : <EOL> return '<STR_LIT>' . format ( self . _name , self . _version ) <EOL> @ property <EOL> def setup_py_keywords ( self ) : <EOL> return self . _kw <EOL> @ property <EOL> def binaries ( self ) : <EOL> return self . _binaries <EOL> def _compute_fingerprint ( self ) : <EOL> return sha1 ( json . dumps ( ( self . _kw , self . _binaries ) , <EOL> ensure_ascii = True , <EOL> allow_nan = False , <EOL> sort_keys = True ) ) . hexdigest ( ) <EOL> def with_binaries ( self , * args , ** kw ) : <EOL> """<STR_LIT>""" <EOL> for arg in args : <EOL> if isinstance ( arg , dict ) : <EOL> self . _binaries . update ( arg ) <EOL> self . _binaries . update ( kw ) <EOL> return self </s>
