@@ -829,23 +829,33 @@ def main():
829
829
# Eventually, the rest of the code will be updated to use the new object
830
830
# directly, but this will glue the two pieces together.
831
831
site_data_all = {site .name : site .information for site in sites }
832
- if args .site_list == [] :
832
+ if not args .site_list :
833
833
# Not desired to look at a sub-set of sites
834
834
site_data = site_data_all
835
835
else :
836
836
# User desires to selectively run queries on a sub-set of the site list.
837
837
# Make sure that the sites are supported & build up pruned site database.
838
838
site_data = {}
839
839
site_missing = []
840
- for site in args .site_list :
841
- counter = 0
842
- for existing_site in site_data_all :
843
- if site .lower () == existing_site .lower ():
844
- site_data [existing_site ] = site_data_all [existing_site ]
845
- counter += 1
846
- if counter == 0 :
847
- # Build up list of sites not supported for future error message.
848
- site_missing .append (f"'{ site } '" )
840
+
841
+ # Create a mapping from all site names and aliases (in lowercase) to their proper names
842
+ site_map = {}
843
+ for site_name , site_info in site_data_all .items ():
844
+ site_map [site_name .lower ()] = site_name
845
+ if "aliases" in site_info :
846
+ for alias in site_info ["aliases" ]:
847
+ site_map [alias .lower ()] = site_name
848
+
849
+ for site_name_from_user in args .site_list :
850
+ # Find the proper site name from the user's input (which could be an alias)
851
+ proper_site_name = site_map .get (site_name_from_user .lower ())
852
+
853
+ if proper_site_name :
854
+ # If a match was found, add the site's data to our list
855
+ site_data [proper_site_name ] = site_data_all [proper_site_name ]
856
+ else :
857
+ # If no match was found for the name or any alias
858
+ site_missing .append (f"'{ site_name_from_user } '" )
849
859
850
860
if site_missing :
851
861
print (f"Error: Desired sites not found: { ', ' .join (site_missing )} ." )
0 commit comments