Commit a4181d40 authored by Mustafa Emre Acer's avatar Mustafa Emre Acer Committed by Commit Bot

Translation screenshot uploader: Find images associated with grdp files

Screenshots can be added for both grd and grdp files. The current
upload tool only finds screenshots for grd files. This CL adds
support for grdp files and files added via <structure> tags.

Bug: 814901
Change-Id: I2cb427b502e050c1b3ee6e39fa7bd94f26e54060
Reviewed-on: https://chromium-review.googlesource.com/974657Reviewed-by: default avatarMustafa Emre Acer <meacer@chromium.org>
Reviewed-by: default avataranthonyvd <anthonyvd@chromium.org>
Commit-Queue: Mustafa Emre Acer <meacer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#545142}
parent c730d60a
......@@ -97,12 +97,20 @@ def git_add(files, repo_root):
def find_screenshots(repo_root, translation_expectations):
grd_files = translation_helper.get_translatable_grds(
"""Returns a list of translation related .png files in the repository."""
translatable_grds = translation_helper.get_translatable_grds(
repo_root, list_grds_in_repository(repo_root), translation_expectations)
# Add the paths of grds and any files they include. This includes grdp files
# and files included via <structure> elements.
src_paths = []
for grd in translatable_grds:
src_paths.append(grd.path)
src_paths.extend(grd.grdp_paths)
src_paths.extend(grd.structure_paths)
screenshots = []
for grd_file in grd_files:
grd_path = grd_file.path
for grd_path in src_paths:
# Convert grd_path.grd to grd_path_grd/ directory.
name, ext = os.path.splitext(os.path.basename(grd_path))
relative_screenshots_dir = os.path.relpath(
......
......@@ -19,10 +19,13 @@ class UploadTests(unittest.TestCase):
screenshots = upload_screenshots.find_screenshots(
testdata_path,
os.path.join(testdata_path, 'translation_expectations.pyl'))
self.assertEquals(1, len(screenshots))
self.assertEquals(2, len(screenshots))
self.assertEquals(
os.path.join(testdata_path, 'test_grd', 'IDS_TEST_STRING1.png'),
screenshots[0])
self.assertEquals(
os.path.join(testdata_path, 'part_grdp', 'IDS_PART_STRING2.png'),
screenshots[1])
if __name__ == '__main__':
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment