in cdk-project/lib/images/codebuild-image/python/src/notebooks/parse.py [0:0]
def check_file_references(name):
"""Check whether a given file is referenced in the repo.
Args:
name: The filename to check.
Returns:
bool: Whether the given file has been referenced in the repo or not.
"""
references = []
for root, dirs, files in walk(Path(".")):
for file_name in files:
if is_notebook(file_name):
nb_markdown_cells = markdown_cells(os.path.join(root, file_name))
for cell in nb_markdown_cells:
for line in cell:
if name in line:
references.append(file_name)
else:
with open(os.path.join(root, file_name), encoding="utf8", errors='ignore') as non_nb_file:
if name in non_nb_file.read():
references.append(file_name)
return references