def codex_list(module):
 codex = {}
 cmd_scribe = ('%s index' % SORCERY['scribe'])
 (rc, stdout, stderr) = module.run_command(cmd_scribe)
 if (rc != 0):
  module.fail_json('unable to list grimoire collection, fix your Codex')
 rex = re.compile('^\\s*\\[\\d+\\] : (?P<grim>[\\w\\-\\+\\.]+) : [\\w\\-\\+\\./]+(?: : (?P<ver>[\\w\\-\\+\\.]+))?\\s*$')
 for line in stdout.splitlines()[4:(-1)]:
  match = rex.match(line)
  if match:
   codex[match.group('grim')] = match.group('ver')
 if (not codex):
  module.fail_json(msg='no grimoires to operate on; add at least one')
 return codex

def codex_list ( module ) : codex = { } cmd_scribe = ( '%s index' % SORCERY [ 'scribe' ] ) ( rc , stdout , stderr ) = module . run_command ( cmd_scribe ) if ( rc != 0 ) : module . fail_json ( 'unable to list grimoire collection, fix your Codex' ) rex = re . compile ( '^\\s*\\[\\d+\\] : (?P<grim>[\\w\\-\\+\\.]+) : [\\w\\-\\+\\./]+(?: : (?P<ver>[\\w\\-\\+\\.]+))?\\s*$' ) for line in stdout . splitlines ( ) [ 4 : ( - 1 ) ] : match = rex . match ( line ) if match : codex [ match . group ( 'grim' ) ] = match . group ( 'ver' ) if ( not codex ) : module . fail_json ( msg = 'no grimoires to operate on; add at least one' ) return codex
list valid grimoire collection .