def generate(self, menuhandler): rv = [] for p in menuhandler.config['recent_profiles']: filename = find_profile(p) if filename: menuitem = MenuItem("generated", p) menuitem.filename = filename menuitem.callback = ProfileListMenuGenerator.callback rv.append(menuitem) if len(rv) >= self.rows: break return rv
def generate(self, menuhandler): # TODO: Cannot load directory content asynchronously here and I'm # TODO: not happy about it rv, all_profiles = [], {} for d in (get_default_profiles_path(), get_profiles_path()): for x in os.listdir(d): if x.endswith(".sccprofile") and not x.startswith("."): all_profiles[x] = os.path.join(d, x) for p in sorted(all_profiles, key=lambda s: s.lower()): menuitem = MenuItem("generated", p[0:-11]) # strips ".sccprofile" menuitem.filename = all_profiles[p] menuitem.callback = self.callback rv.append(menuitem) return rv