<s> __author__ = '<STR_LIT>' <EOL> __all__ = ( '<STR_LIT>' , ) <EOL> from . base import BaseAdapter <EOL> from aero . __version__ import __version__ , enc <EOL> class Gem ( BaseAdapter ) : <EOL> """<STR_LIT>""" <EOL> def search ( self , query ) : <EOL> response = self . command ( '<STR_LIT>' , query ) [ <NUM_LIT:0> ] . decode ( * enc ) <EOL> from re import match <EOL> lst = { } <EOL> desc = False <EOL> blank = False <EOL> for line in [ l for l in response . splitlines ( ) if not match ( '<STR_LIT>' , l ) ] : <EOL> if not desc and match ( '<STR_LIT>' , line ) : <EOL> key , val = match ( '<STR_LIT>' , line ) . groups ( ) <EOL> lst [ self . package_name ( key ) ] = '<STR_LIT>' + val + '<STR_LIT:\n>' <EOL> desc = True <EOL> elif desc and not blank and not line : <EOL> blank = True <EOL> elif desc and '<STR_LIT>' in line : <EOL> lst [ self . package_name ( key ) ] += line . replace ( '<STR_LIT>' , '<STR_LIT>' ) . strip ( ) + '<STR_LIT:\n>' <EOL> elif desc and blank and line : <EOL> lst [ self . package_name ( key ) ] += line . strip ( ) + '<STR_LIT:U+0020>' <EOL> elif desc and blank and not line : <EOL> desc = False <EOL> blank = False <EOL> return lst <EOL> def install ( self , query ) : <EOL> return self . shell ( '<STR_LIT>' , query ) <EOL> def info ( self , query ) : <EOL> import yaml <EOL> class Timestamp ( yaml . YAMLObject , dict ) : <EOL> yaml_tag = '<STR_LIT>' <EOL> def __setstate__ ( self , state ) : <EOL> self [ '<STR_LIT>' ] = state [ '<STR_LIT>' ] [ : state [ '<STR_LIT>' ] . index ( '<STR_LIT:U+0020>' ) ] <EOL> class Version ( yaml . YAMLObject , dict ) : <EOL> yaml_tag = '<STR_LIT>' <EOL> def __setstate__ ( self , state ) : <EOL> self [ '<STR_LIT:version>' ] = state [ '<STR_LIT:version>' ] <EOL> class Requirement ( yaml . YAMLObject , dict ) : <EOL> yaml_tag = '<STR_LIT>' <EOL> def __setstate__ ( self , state ) : <EOL> r = state [ '<STR_LIT>' ] . pop ( ) <EOL> self [ '<STR_LIT>' ] = '<STR_LIT>' . format ( r . pop ( <NUM_LIT:0> ) , r . pop ( <NUM_LIT:0> ) [ '<STR_LIT:version>' ] ) <EOL> class Dependency ( yaml . YAMLObject , dict ) : <EOL> yaml_tag = '<STR_LIT>' <EOL> def __setstate__ ( self , state ) : <EOL> for require in [ r for r in state . keys ( ) if '<STR_LIT>' in r ] : <EOL> try : <EOL> self [ '<STR_LIT>' ] = state [ require ] [ '<STR_LIT>' ] <EOL> break <EOL> except KeyError : <EOL> continue <EOL> self [ '<STR_LIT:name>' ] = state [ '<STR_LIT:name>' ] <EOL> self [ '<STR_LIT:type>' ] = state [ '<STR_LIT:type>' ] <EOL> class GemSpec ( yaml . YAMLObject , dict ) : <EOL> yaml_tag = '<STR_LIT>' <EOL> def __setstate__ ( self , state ) : <EOL> for k , v in [ st for st in state . items ( ) if st [ <NUM_LIT:1> ] ] : <EOL> if isinstance ( v , list ) : <EOL> if k == '<STR_LIT>' : <EOL> s = [ ] <EOL> mx = <NUM_LIT:0> <EOL> for dep in v : <EOL> mx = max ( len ( dep [ '<STR_LIT:name>' ] ) , mx ) <EOL> s . append ( ( dep [ '<STR_LIT:name>' ] , dep [ '<STR_LIT:type>' ] , dep [ '<STR_LIT>' ] ) ) <EOL> mx += <NUM_LIT:1> <EOL> s = '<STR_LIT:\n>' . join ( [ '<STR_LIT>' . format ( t [ <NUM_LIT:0> ] , mx , t [ <NUM_LIT:1> ] , t [ <NUM_LIT:2> ] ) for t in s ] ) <EOL> v = s <EOL> else : <EOL> v = '<STR_LIT:U+002CU+0020>' . join ( v ) <EOL> if isinstance ( v , Timestamp ) : <EOL> v = v [ '<STR_LIT>' ] <EOL> if isinstance ( v , Version ) : <EOL> v = v [ '<STR_LIT:version>' ] <EOL> if isinstance ( v , Requirement ) : <EOL> v = v [ '<STR_LIT>' ] <EOL> if not isinstance ( v , str ) : <EOL> v = str ( v ) <EOL> self . update ( [ ( k , v ) ] ) <EOL> response = self . command ( '<STR_LIT>' , query ) [ <NUM_LIT:0> ] . decode ( * enc ) <EOL> if '<STR_LIT>' in response : <EOL> return [ '<STR_LIT>' . format ( response ) ] <EOL> from re import sub <EOL> result = yaml . load ( sub ( r'<STR_LIT>' , r'<STR_LIT>' , response ) ) <EOL> try : <EOL> return sorted ( result . items ( ) ) <EOL> except AttributeError : <EOL> return [ '<STR_LIT>' . format ( query ) ] </s>
