Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement case flexibility for data discovery #31

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions lightbeam/lightbeam.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,21 @@ def meets_process_criteria(self, tuple):
def get_data_files_for_endpoint(self, endpoint):
file_list = []
for ext in self.DATA_FILE_EXTENSIONS:
possible_file = os.path.join(self.config["data_dir"], endpoint + "." + ext)
if os.path.isfile(possible_file):
file_list.append(possible_file)
possible_dir = os.path.join(self.config["data_dir"] + endpoint)
if os.path.isdir(possible_dir):
for file in os.listdir(possible_dir):
if file.endswith("." + ext):
file_list.append(os.path.join(self.config["data_dir"], endpoint, file))
# check for (for example):
# - studentSchoolAssociations (default case from Ed-Fi Swagger)
# - StudentSchoolAssociations (camelcase)
# - studentschoolassociations (lowercase)
# - STUDENTSCHOOLASSOCIATIONS (uppercase)
camelcase_endpoint = endpoint[0].upper() + endpoint[1:]
for cased_endpoint in [endpoint, camelcase_endpoint, endpoint.lower(), endpoint.upper()]:
possible_file = os.path.join(self.config["data_dir"], cased_endpoint + "." + ext)
if os.path.isfile(possible_file):
file_list.append(possible_file)
possible_dir = os.path.join(self.config["data_dir"] + cased_endpoint)
if os.path.isdir(possible_dir):
for file in os.listdir(possible_dir):
if file.endswith("." + ext):
file_list.append(os.path.join(self.config["data_dir"], cased_endpoint, file))
return file_list

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