def selectMap(name=None, excludeName=False, closestMatch=True, **tags):
matches = filterMapAttrs(**tags)<EOL>if not matches: raise c.InvalidMapSelection("<STR_LIT>"%tags)<EOL>if name: <EOL><INDENT>matches = filterMapNames(name, excludeRegex=excludeName, closestMatch=closestMatch, records=matches)<EOL><DEDENT>try:<EOL><INDENT>if closestMatch:    return random.choice(matches) <EOL>elif matches:       return matches<EOL><DEDENT>except IndexError: pass <EOL>raise c.InvalidMapSelection("<STR_LIT>""<STR_LIT>""<STR_LIT>"%(<EOL>name, c.PATH_MAP_INSTALL))<EOL>
select a map by name and/or critiera