#!/usr/bin/python3 # # list_screens - list Anaconda screen names relevant for the # user interaction config file # # Copyright (C) 2016 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published # by the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this program. If not, see . import os import re # make it possible to run the script from outside of the scripts directory os.chdir(os.path.dirname(os.path.abspath(__file__))) # for now we only list the GUI spokes GUI_SPOKES = "../pyanaconda/ui/gui/spokes" BASE_SPOKES = ["StandaloneSpoke", "NormalSpoke"] SPOKE_DETECTION_RE = r"class\s*(?P\w+)[(].*Spoke.*[)]" compiled_re = re.compile(SPOKE_DETECTION_RE) # iterate over all files in the spokes folder for dirpath, _dirnames, filenames in os.walk(GUI_SPOKES): for filename in filenames: # we only care about Python code if os.path.splitext(filename)[1] == ".py": full_path = os.path.join(dirpath, filename) with open(full_path, "rt") as f: # look for all GUI spoke classes file_content = f.read() matches = compiled_re.finditer(file_content) for m in matches: spoke_name = m.group("spoke_name") if spoke_name and spoke_name not in BASE_SPOKES: print(spoke_name)