Skip to content

Commit

Permalink
Add doc test for walk_sheets.
Browse files Browse the repository at this point in the history
  • Loading branch information
markpbaggett committed May 15, 2024
1 parent d20b5fc commit 57cadd7
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions utk_exodus/checksum/checksum.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@ def __init__(self, path, output):

@staticmethod
def walk_sheets(path):
"""Walk through a directory and return a list of all files.
Args:
path (str): The path to the directory to walk through.
Returns:
list: A list of all files in the directory.
Examples:
>>> hs = HashSheet("tests/fixtures/bad_imports", "example.csv")
>>> hs.walk_sheets("tests/fixtures/bad_imports")
['https://digital.lib.utk.edu/migration/mpaekefauver/mpaekefauver:248_MODS.xml', 'https://digital.lib.utk.edu/migration/mpaekefauver/mpaekefauver:309_MODS.xml', 'https://digital.lib.utk.edu/migration/mpaekefauver/mpaekefauver:118_OBJ.jp2', 'https://digital.lib.utk.edu/migration/mpaekefauver/mpaekefauver:99_MODS.xml', 'https://digital.lib.utk.edu/migration/mpaekefauver/mpaekefauver:374_MODS.xml', 'https://digital.lib.utk.edu/migration/mpaekefauver/mpaekefauver:465_OBJ.jp2', 'https://digital.lib.utk.edu/migration/mpaekefauver/mpaekefauver:356_MODS.xml', 'https://digital.lib.utk.edu/migration/mpaekefauver/mpaekefauver:254_OBJ.jp2', 'https://digital.lib.utk.edu/migration/mpaekefauver/mpaekefauver:451_OBJ.jp2', 'https://digital.lib.utk.edu/migration/mpaekefauver/mpaekefauver:104_MODS.xml', 'https://digital.lib.utk.edu/migration/mpaekefauver/mpaekefauver:419_MODS.xml', 'https://digital.lib.utk.edu/migration/mpaekefauver/mpaekefauver:318_OBJ.jp2', 'https://digital.lib.utk.edu/migration/mpaekefauver/mpaekefauver:463_MODS.xml', 'https://digital.lib.utk.edu/migration/mpaekefauver/mpaekefauver:350_MODS.xml', 'https://digital.lib.utk.edu/migration/mpaekefauver/mpaekefauver:108_OBJ.jp2', 'https://digital.lib.utk.edu/migration/mpaekefauver/mpaekefauver:420_MODS.xml']
"""
all_files = []
for path, directories, files in os.walk(path):
for filename in files:
Expand All @@ -23,6 +37,15 @@ def walk_sheets(path):
return all_files

def checksum(self):
"""Calculate the sha1 checksum of all files listed in csvs in a directory.
Returns:
list: A list of dictionaries with the url and checksum of each file.
Examples:
No example to keep tests running quickly.
"""
files_with_checksums = []
for file in tqdm(self.all_files):
hash = self.checksum_file(file)
Expand Down

0 comments on commit 57cadd7

Please sign in to comment.