Skip to content
Merged
Show file tree
Hide file tree
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion recreate_v4_files_listing.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
import os.path
from glob import glob


REPO_MAIN_DIRPATH = os.path.dirname(os.path.abspath(__file__))
V4_DIR = os.sep.join([REPO_MAIN_DIRPATH, 'images', 'v4'])
V4_LISTFILE_NAME = 'v4_files_listing.txt'
V4_LISTFILE_PATH = os.sep.join([REPO_MAIN_DIRPATH, V4_LISTFILE_NAME])


def get_v4_imagefile_names(search_dirpath=V4_DIR, filespec='*.png'):
"""Return a list of the current image files in the v4 subdirectory."""
files_spec = os.path.join(search_dirpath, filespec)
Expand All @@ -20,7 +22,7 @@ def create_v4_images_listfile(search_dirpath=V4_DIR, filespec='*.png',
output_filepath=V4_LISTFILE_PATH):
file_names = get_v4_imagefile_names(search_dirpath, filespec)
with open(output_filepath, 'w') as f_out:
for file_name in file_names:
for file_name in sorted(file_names):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorting ensures that a newly generated v4_files_listing.txt file is ordered, making PR changes easier to review - otherwise it's not guaranteed that the same v4_files_listing.txt can be recreated.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will make things much easier!

f_out.write('{}\n'.format(file_name))


Expand Down
1 change: 1 addition & 0 deletions run_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class TestListing(unittest.TestCase):
def test(self):
# Check that the image listing file contents are up to date.
import recreate_v4_files_listing as v4list

file_names = set(v4list.get_v4_imagefile_names())
listing_filepath = v4list.V4_LISTFILE_NAME
self.assertTrue(os.path.exists(listing_filepath))
Expand Down
Loading