tools/metrics/histograms/update_editor_commands.py
def ReadHistogramValues(filename):
  """Returns a list of pairs (label, value) corresponding to HistogramValue.

  Reads the EditorCommand.cpp file, locates the
  HistogramValue enum definition and returns a pair for each entry.
  """

  # Read the file as a list of lines
  with open(path_util.GetInputFile(filename)) as f:
    content = f.readlines()

  # Locate the enum definition and collect all entries in it
  inside_enum = False # We haven't found the enum definition yet
  result = []
  for line in content:
    if inside_enum:
      # Exit condition: we reached last enum value
      if re.match(ENUM_END_MARKER, line):
        inside_enum = False
      else:
        # Inside enum: generate new xml entry
        m = re.match("^{ \"([\w]+)\", \{([\w]+)", line.strip())
        if m:
          result.append((m.group(1), int(m.group(2))))
    else:
      if re.match(ENUM_START_MARKER, line):
        inside_enum = True
        enum_value = 0 # Start at 'UNKNOWN'
  return sorted(result, key=lambda pair: pair[1])
Returns a list of pairs (label, value) corresponding to HistogramValue.

  Reads the EditorCommand.cpp file, locates the
  HistogramValue enum definition and returns a pair for each entry.
  
Returns a list of pairs (label, value) corresponding to HistogramValue.
Reads the EditorCommand.cpp file, locates the
HistogramValue enum definition and returns a pair for each entry.
Returns a list of pairs ( label value ) corresponding to HistogramValue . Reads the EditorCommand . cpp file locates the HistogramValue enum definition and returns a pair for each entry .
def ReadHistogramValues(filename):
  with open(path_util.GetInputFile(filename)) as f:
    content = f.readlines()
  inside_enum = False 
  result = []
  for line in content:
    if inside_enum:
      if re.match(ENUM_END_MARKER, line):
        inside_enum = False
      else:
        m = re.match("^{ \"([\w]+)\", \{([\w]+)", line.strip())
        if m:
          result.append((m.group(1), int(m.group(2))))
    else:
      if re.match(ENUM_START_MARKER, line):
        inside_enum = True
        enum_value = 0 
  return sorted(result, key=lambda pair: pair[1])
def ReadHistogramValues ( filename ) : with open ( path_util . GetInputFile ( filename ) ) as f : content = f . readlines ( ) inside_enum = False result = [ ] for line in content : if inside_enum : if re . match ( ENUM_END_MARKER , line ) : inside_enum = False else : m = re . match ( "^{ \"([\w]+)\", \{([\w]+)" , line . strip ( ) ) if m : result . append ( ( m . group ( 1 ) , int ( m . group ( 2 ) ) ) ) else : if re . match ( ENUM_START_MARKER , line ) : inside_enum = True enum_value = 0 return sorted ( result , key = lambda pair : pair [ 1 ] )
Returns a list of pairs (label, value) corresponding to HistogramValue.
Returns a list of pairs ( label value ) corresponding to HistogramValue .
"""Returns a list of pairs (label, value) corresponding to HistogramValue.

  Reads the EditorCommand.cpp file, locates the
  HistogramValue enum definition and returns a pair for each entry.
  """ # Read the file as a list of lines # Locate the enum definition and collect all entries in it # We haven't found the enum definition yet # Exit condition: we reached last enum value # Inside enum: generate new xml entry # Start at 'UNKNOWN'
filename