#NEWLINE# def show( module ) : #NEWLINE# #INDENT# "\n    Show information about a specific Perl module\n\n    CLI Example:\n\n    .. code-block:: bash\n\n        salt '*' cpan.show Template::Alloy\n    " #NEWLINE# ret = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# ret [ 'name' ] = module #NEWLINE# cmd = 'cpan -D {0}' . format ( module ) #NEWLINE# out = __salt__ [ 'cmd.run' ] ( cmd ) . splitlines ( ) #NEWLINE# mode = 'skip' #NEWLINE# info = [ ] #NEWLINE# for line in out : #NEWLINE# #INDENT# if line . startswith ( '-------------' ) : #NEWLINE# #INDENT# mode = 'parse' #NEWLINE# continue #NEWLINE# #UNINDENT# if ( info == 'skip' ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# info . append ( line ) #NEWLINE# #UNINDENT# if ( len ( info ) == 6 ) : #NEWLINE# #INDENT# info . insert ( 2 , '' ) #NEWLINE# #UNINDENT# if ( len ( info ) < 6 ) : #NEWLINE# #INDENT# ret [ 'error' ] = 'This package does not seem to exist' #NEWLINE# return ret #NEWLINE# #UNINDENT# ret [ 'description' ] = info [ 0 ] . strip ( ) #NEWLINE# ret [ 'cpan file' ] = info [ 1 ] . strip ( ) #NEWLINE# if info [ 2 ] . strip ( ) : #NEWLINE# #INDENT# ret [ 'installed file' ] = info [ 2 ] . strip ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ret [ 'installed file' ] = None #NEWLINE# #UNINDENT# comps = info [ 3 ] . split ( ':' ) #NEWLINE# if ( len ( comps ) > 1 ) : #NEWLINE# #INDENT# ret [ 'installed version' ] = comps [ 1 ] . strip ( ) #NEWLINE# #UNINDENT# if ( ( 'installed version' not in ret ) or ( not ret [ 'installed version' ] ) ) : #NEWLINE# #INDENT# ret [ 'installed version' ] = None #NEWLINE# #UNINDENT# comps = info [ 4 ] . split ( ':' ) #NEWLINE# comps = comps [ 1 ] . split ( ) #NEWLINE# ret [ 'cpan version' ] = comps [ 0 ] . strip ( ) #NEWLINE# ret [ 'author name' ] = info [ 5 ] . strip ( ) #NEWLINE# ret [ 'author email' ] = info [ 6 ] . strip ( ) #NEWLINE# config = show_config ( ) #NEWLINE# build_dir = config . get ( 'build_dir' , None ) #NEWLINE# if ( build_dir is not None ) : #NEWLINE# #INDENT# ret [ 'cpan build dirs' ] = [ ] #NEWLINE# builds = os . listdir ( build_dir ) #NEWLINE# pfile = module . replace ( '::' , '-' ) #NEWLINE# for file_ in builds : #NEWLINE# #INDENT# if file_ . startswith ( pfile ) : #NEWLINE# #INDENT# ret [ 'cpan build dirs' ] . append ( os . path . join ( build_dir , file_ ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return ret