def get_metadata(self, image_file, names={}):
metadata = dict()<EOL>if image_file is not None:<EOL><INDENT>if not os.path.exists(image_file):<EOL><INDENT>bot.error('<STR_LIT>' %image_file)<EOL>return names or metadata<EOL><DEDENT><DEDENT>if not names:<EOL><INDENT>names = parse_image_name(remove_uri(image_file))<EOL><DEDENT>singularity = which('<STR_LIT>')['<STR_LIT:message>']<EOL>if os.path.exists(singularity) and image_file is not None:<EOL><INDENT>from spython.main import Client as Singularity<EOL>try:<EOL><INDENT>Singularity.quiet = True<EOL>updates = Singularity.inspect(image=image_file)<EOL><DEDENT>except:<EOL><INDENT>bot.warning('<STR_LIT>')<EOL>updates = None<EOL><DEDENT>if updates is not None:<EOL><INDENT>try:<EOL><INDENT>updates = json.loads(updates)<EOL>metadata.update(updates)<EOL><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT><DEDENT><DEDENT>metadata.update(names)<EOL>return metadata<EOL>
extract metadata using Singularity inspect, if the executable is found.
       If not, return a reasonable default (the parsed image name)

       Parameters
       ==========
       image_file: the full path to a Singularity image
       names: optional, an extracted or otherwise created dictionary of
              variables for the image, likely from utils.parse_image_name