Skip to content

Commit d22170e

Browse files
authored
Merge pull request #31 from edanalytics/feature/endpoints_case_insensitive
implement case flexibility for data discovery
2 parents 5c899b4 + 5c76224 commit d22170e

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
@@ -254,14 +254,21 @@ def confirm_truncate(self, endpoints):
254254
def get_data_files_for_endpoint(self, endpoint):
255255
file_list = []
256256
for ext in self.DATA_FILE_EXTENSIONS:
257-
possible_file = os.path.join(self.config["data_dir"], endpoint + "." + ext)
258-
if os.path.isfile(possible_file):
259-
file_list.append(possible_file)
260-
possible_dir = os.path.join(self.config["data_dir"] + endpoint)
261-
if os.path.isdir(possible_dir):
262-
for file in os.listdir(possible_dir):
263-
if file.endswith("." + ext):
264-
file_list.append(os.path.join(self.config["data_dir"], endpoint, file))
257+
# check for (for example):
258+
# - studentSchoolAssociations (default case from Ed-Fi Swagger)
259+
# - StudentSchoolAssociations (camelcase)
260+
# - studentschoolassociations (lowercase)
261+
# - STUDENTSCHOOLASSOCIATIONS (uppercase)
262+
camelcase_endpoint = endpoint[0].upper() + endpoint[1:]
263+
for cased_endpoint in [endpoint, camelcase_endpoint, endpoint.lower(), endpoint.upper()]:
264+
possible_file = os.path.join(self.config["data_dir"], cased_endpoint + "." + ext)
265+
if os.path.isfile(possible_file):
266+
file_list.append(possible_file)
267+
possible_dir = os.path.join(self.config["data_dir"] + cased_endpoint)
268+
if os.path.isdir(possible_dir):
269+
for file in os.listdir(possible_dir):
270+
if file.endswith("." + ext):
271+
file_list.append(os.path.join(self.config["data_dir"], cased_endpoint, file))
265272
return file_list
266273

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

0 commit comments

Comments
 (0)