code: def abbreviate_paths(pathspec,named_paths):
      
      from os.path import commonprefix, dirname, sep
  
      prefix = commonprefix([dirname(name)+sep for name in named_paths.keys()]+[pathspec])
      return OrderedDict([(name[len(prefix):],path) for name,path in named_paths.items()])
docs: Given a dict of (pathname,path) pairs, removes any prefix shared by all pathnames.
      Helps keep menu items short yet unambiguous.