Skip to content

Commit 5c76224

Browse files
author
Tom Reitz
committed
implement case flexibility for data discovery
1 parent 0d8caf9 commit 5c76224

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

lightbeam/lightbeam.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,21 @@ def meets_process_criteria(self, tuple):
145145
def get_data_files_for_endpoint(self, endpoint):
146146
file_list = []
147147
for ext in self.DATA_FILE_EXTENSIONS:
148-
possible_file = os.path.join(self.config["data_dir"], endpoint + "." + ext)
149-
if os.path.isfile(possible_file):
150-
file_list.append(possible_file)
151-
possible_dir = os.path.join(self.config["data_dir"] + endpoint)
152-
if os.path.isdir(possible_dir):
153-
for file in os.listdir(possible_dir):
154-
if file.endswith("." + ext):
155-
file_list.append(os.path.join(self.config["data_dir"], endpoint, file))
148+
# check for (for example):
149+
# - studentSchoolAssociations (default case from Ed-Fi Swagger)
150+
# - StudentSchoolAssociations (camelcase)
151+
# - studentschoolassociations (lowercase)
152+
# - STUDENTSCHOOLASSOCIATIONS (uppercase)
153+
camelcase_endpoint = endpoint[0].upper() + endpoint[1:]
154+
for cased_endpoint in [endpoint, camelcase_endpoint, endpoint.lower(), endpoint.upper()]:
155+
possible_file = os.path.join(self.config["data_dir"], cased_endpoint + "." + ext)
156+
if os.path.isfile(possible_file):
157+
file_list.append(possible_file)
158+
possible_dir = os.path.join(self.config["data_dir"] + cased_endpoint)
159+
if os.path.isdir(possible_dir):
160+
for file in os.listdir(possible_dir):
161+
if file.endswith("." + ext):
162+
file_list.append(os.path.join(self.config["data_dir"], cased_endpoint, file))
156163
return file_list
157164

158165
# Prunes the list of endpoints down to those for which .jsonl files exist in the config.data_dir

0 commit comments

Comments
 (0)