tools/translation/upload_screenshots.py
def find_screenshots(repo_root, translation_expectations):
  """Returns a list of translation related .png files in the repository."""
  translatable_grds = translation_helper.get_translatable_grds(
      repo_root, git_helper.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_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(
        os.path.dirname(grd_path), repo_root)
    screenshots_dir = os.path.realpath(
        os.path.join(repo_root,
                     os.path.join(relative_screenshots_dir,
                                  name + ext.replace('.', '_'))))
    # Grab all the .png files under the screenshot directory. On a clean
    # checkout this should be an empty list, as the repo should only contain
    # .sha1 files of previously uploaded screenshots.
    if not os.path.exists(screenshots_dir):
      continue
    for f in os.listdir(screenshots_dir):
      if f in ('OWNERS', 'README.md', 'DIR_METADATA') or f.endswith('.sha1'):
        continue
      if not f.endswith('.png'):
        print('File with unexpected extension: %s in %s' % (f, screenshots_dir))
        continue
      screenshots.append(os.path.join(screenshots_dir, f))
  return screenshots
Returns a list of translation related .png files in the repository.
Returns a list of translation related .png files in the repository.
Returns a list of translation related . png files in the repository .
def find_screenshots(repo_root, translation_expectations):
  translatable_grds = translation_helper.get_translatable_grds(
      repo_root, git_helper.list_grds_in_repository(repo_root),
      translation_expectations)
  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_path in src_paths:
    name, ext = os.path.splitext(os.path.basename(grd_path))
    relative_screenshots_dir = os.path.relpath(
        os.path.dirname(grd_path), repo_root)
    screenshots_dir = os.path.realpath(
        os.path.join(repo_root,
                     os.path.join(relative_screenshots_dir,
                                  name + ext.replace('.', '_'))))
    if not os.path.exists(screenshots_dir):
      continue
    for f in os.listdir(screenshots_dir):
      if f in ('OWNERS', 'README.md', 'DIR_METADATA') or f.endswith('.sha1'):
        continue
      if not f.endswith('.png'):
        print('File with unexpected extension: %s in %s' % (f, screenshots_dir))
        continue
      screenshots.append(os.path.join(screenshots_dir, f))
  return screenshots
def find_screenshots ( repo_root , translation_expectations ) : translatable_grds = translation_helper . get_translatable_grds ( repo_root , git_helper . list_grds_in_repository ( repo_root ) , translation_expectations ) 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_path in src_paths : name , ext = os . path . splitext ( os . path . basename ( grd_path ) ) relative_screenshots_dir = os . path . relpath ( os . path . dirname ( grd_path ) , repo_root ) screenshots_dir = os . path . realpath ( os . path . join ( repo_root , os . path . join ( relative_screenshots_dir , name + ext . replace ( '.' , '_' ) ) ) ) if not os . path . exists ( screenshots_dir ) : continue for f in os . listdir ( screenshots_dir ) : if f in ( 'OWNERS' , 'README.md' , 'DIR_METADATA' ) or f . endswith ( '.sha1' ) : continue if not f . endswith ( '.png' ) : print ( 'File with unexpected extension: %s in %s' % ( f , screenshots_dir ) ) continue screenshots . append ( os . path . join ( screenshots_dir , f ) ) return screenshots
Returns a list of translation related .png files in the repository.
Returns a list of translation related . png files in the repository .
"""Returns a list of translation related .png files in the repository.""" # Add the paths of grds and any files they include. This includes grdp files # and files included via <structure> elements. # Convert grd_path.grd to grd_path_grd/ directory. # Grab all the .png files under the screenshot directory. On a clean # checkout this should be an empty list, as the repo should only contain # .sha1 files of previously uploaded screenshots.
repo_root
translation_expectations