Eric Gazoni avatar Eric Gazoni committed ecd03e4

[named range] reverting extremeley non-smart refactoring

Comments (0)

Files changed (1)

openpyxl/reader/workbook.py

             if name_node.get("hidden", '0') == '1':
                 continue
 
+            valid = True
+
             for discarded_range in DISCARDED_RANGES:
                 if discarded_range in range_name:
-                    continue
+                    valid = False
 
             for bad_range in BUGGY_NAMED_RANGES:
                 if bad_range in name_node.text:
-                    continue
+                    valid = False
 
-            destinations = split_named_range(name_node.text)
+            if valid:
+                destinations = split_named_range(name_node.text)
 
-            new_destinations = []
-            for worksheet, cells_range in destinations:
+                new_destinations = []
+                for worksheet, cells_range in destinations:
 
-                # it can happen that a valid named range references
-                # a missing worksheet, when Excel didn't properly maintain
-                # the named range list
-                #
-                # we just ignore them here
-                worksheet = workbook.get_sheet_by_name(worksheet)
-                if worksheet:
-                    new_destinations.append((worksheet, cells_range))
+                    # it can happen that a valid named range references
+                    # a missing worksheet, when Excel didn't properly maintain
+                    # the named range list
+                    #
+                    # we just ignore them here
+                    worksheet = workbook.get_sheet_by_name(worksheet)
+                    if worksheet:
+                        new_destinations.append((worksheet, cells_range))
 
-            named_range = NamedRange(range_name, new_destinations)
-            named_ranges.append(named_range)
+                named_range = NamedRange(range_name, new_destinations)
+                named_ranges.append(named_range)
 
     return named_ranges
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.