components/vector_icons/aggregate_vector_icons.py
def ExtractIconReps(icon_file_name):
  """Reads the contents of the given icon file and returns a dictionary of icon
     sizes to vector commands for different icon representations stored in that
     file.

  Args:
      icon_file_name: The file path of the icon file to read.
  """
  with open(icon_file_name, "r") as icon_file:
    icon_file_contents = icon_file.readlines()

  current_icon_size = REFERENCE_SIZE_DIP
  icon_sizes = []
  current_icon_representation = []
  icon_representations = {}
  for line in icon_file_contents:
    # Strip comments and empty lines.
    line = line.partition(CPP_COMMENT_DELIMITER)[0].strip()
    if not line:
      continue
    # Retrieve sizes specified by CANVAS_DIMENSIONS to ensure icons are added in
    # sorted order by size descending.
    if line.startswith(CANVAS_DIMENSIONS):
      sizes = re.findall(r"\d+", line)
      if len(sizes) != 1:
        Error("Malformed {} line in {} - it should specify exactly one size."
              .format(CANVAS_DIMENSIONS, icon_file_name))
      icon_sizes.append(int(sizes[0]))

      # All icons except the first / default icon must start with
      # "CANVAS_DIMENSIONS", so rely on it here as a icon delimiter.
      if current_icon_representation:
        icon_representations = AddIconToDictionary(
            icon_file_name, current_icon_representation, current_icon_size,
            icon_representations)
        current_icon_representation = []
      current_icon_size = icon_sizes[-1]

    current_icon_representation.append(line)
  if current_icon_representation:
    icon_representations = AddIconToDictionary(
        icon_file_name, current_icon_representation, current_icon_size,
        icon_representations)

  if not icon_representations:
    Error("Didn't find any icons in {}.".format(icon_file_name))

  if len(icon_representations) != len(icon_sizes):
    icon_sizes.insert(0, REFERENCE_SIZE_DIP)
  if sorted(icon_sizes, reverse=True) != icon_sizes:
    Error("The icons in {} should be sorted in descending order of size."
          .format(icon_file_name))
  return icon_representations
Reads the contents of the given icon file and returns a dictionary of icon
     sizes to vector commands for different icon representations stored in that
     file.

  Args:
      icon_file_name: The file path of the icon file to read.
  
Reads the contents of the given icon file and returns a dictionary of icon
sizes to vector commands for different icon representations stored in that
file.
Reads the contents of the given icon file and returns a dictionary of icon sizes to vector commands for different icon representations stored in that file .
def ExtractIconReps(icon_file_name):
  with open(icon_file_name, "r") as icon_file:
    icon_file_contents = icon_file.readlines()
  current_icon_size = REFERENCE_SIZE_DIP
  icon_sizes = []
  current_icon_representation = []
  icon_representations = {}
  for line in icon_file_contents:
    line = line.partition(CPP_COMMENT_DELIMITER)[0].strip()
    if not line:
      continue
    if line.startswith(CANVAS_DIMENSIONS):
      sizes = re.findall(r"\d+", line)
      if len(sizes) != 1:
        Error("Malformed {} line in {} - it should specify exactly one size."
              .format(CANVAS_DIMENSIONS, icon_file_name))
      icon_sizes.append(int(sizes[0]))
      if current_icon_representation:
        icon_representations = AddIconToDictionary(
            icon_file_name, current_icon_representation, current_icon_size,
            icon_representations)
        current_icon_representation = []
      current_icon_size = icon_sizes[-1]
    current_icon_representation.append(line)
  if current_icon_representation:
    icon_representations = AddIconToDictionary(
        icon_file_name, current_icon_representation, current_icon_size,
        icon_representations)
  if not icon_representations:
    Error("Didn't find any icons in {}.".format(icon_file_name))
  if len(icon_representations) != len(icon_sizes):
    icon_sizes.insert(0, REFERENCE_SIZE_DIP)
  if sorted(icon_sizes, reverse=True) != icon_sizes:
    Error("The icons in {} should be sorted in descending order of size."
          .format(icon_file_name))
  return icon_representations
def ExtractIconReps ( icon_file_name ) : with open ( icon_file_name , "r" ) as icon_file : icon_file_contents = icon_file . readlines ( ) current_icon_size = REFERENCE_SIZE_DIP icon_sizes = [ ] current_icon_representation = [ ] icon_representations = { } for line in icon_file_contents : line = line . partition ( CPP_COMMENT_DELIMITER ) [ 0 ] . strip ( ) if not line : continue if line . startswith ( CANVAS_DIMENSIONS ) : sizes = re . findall ( r"\d+" , line ) if len ( sizes ) != 1 : Error ( "Malformed {} line in {} - it should specify exactly one size." . format ( CANVAS_DIMENSIONS , icon_file_name ) ) icon_sizes . append ( int ( sizes [ 0 ] ) ) if current_icon_representation : icon_representations = AddIconToDictionary ( icon_file_name , current_icon_representation , current_icon_size , icon_representations ) current_icon_representation = [ ] current_icon_size = icon_sizes [ - 1 ] current_icon_representation . append ( line ) if current_icon_representation : icon_representations = AddIconToDictionary ( icon_file_name , current_icon_representation , current_icon_size , icon_representations ) if not icon_representations : Error ( "Didn't find any icons in {}." . format ( icon_file_name ) ) if len ( icon_representations ) != len ( icon_sizes ) : icon_sizes . insert ( 0 , REFERENCE_SIZE_DIP ) if sorted ( icon_sizes , reverse = True ) != icon_sizes : Error ( "The icons in {} should be sorted in descending order of size." . format ( icon_file_name ) ) return icon_representations
Reads the contents of the given icon file and returns a dictionary of icon
sizes to vector commands for different icon representations stored in that
file.
Reads the contents of the given icon file and returns a dictionary of icon sizes to vector commands for different icon representations stored in that file .
"""Reads the contents of the given icon file and returns a dictionary of icon
     sizes to vector commands for different icon representations stored in that
     file.

  Args:
      icon_file_name: The file path of the icon file to read.
  """ # Strip comments and empty lines. # Retrieve sizes specified by CANVAS_DIMENSIONS to ensure icons are added in # sorted order by size descending. # All icons except the first / default icon must start with # "CANVAS_DIMENSIONS", so rely on it here as a icon delimiter.
icon_file_name
The file path of the icon file to read.
The file path of the icon file to read .