tools/metrics/histograms/generate_expired_histograms_array.py
def _GetExpiredHistograms(histograms, base_date, current_milestone):
  """Filters histograms to find expired ones if date format is used.

  Args:
    histograms(Dict[str, Dict]): Histogram descriptions in the form
      {name: content}.
    base_date(datetime.date): A date to check expiry dates against.

  Returns:
    List of strings with names of expired histograms.

  Raises:
    Error if there is an expiry date that doesn't match expected format.
  """
  expired_histograms_names = []
  for name, content in histograms.items():
    if "obsolete" in content or "expires_after" not in content:
      continue
    expiry_str = content["expires_after"]
    if expiry_str == "never":
      continue

    match = _MILESTONE_EXPIRY_RE.search(expiry_str)
    if match:
      # if there is match then expiry is in Chrome milsetone format.
      if int(match.group(1)) < current_milestone:
        expired_histograms_names.append(name)
    else:
      # if no match then we try the date format.
      try:
        expiry_date = datetime.datetime.strptime(
            expiry_str, extract_histograms.EXPIRY_DATE_PATTERN).date()
      except ValueError:
        raise Error(_DATE_FORMAT_ERROR.
                    format(date=expiry_str, name=name))
      if expiry_date < base_date:
        expired_histograms_names.append(name)
  return expired_histograms_names
Filters histograms to find expired ones if date format is used.

  Args:
    histograms(Dict[str, Dict]): Histogram descriptions in the form
      {name: content}.
    base_date(datetime.date): A date to check expiry dates against.

  Returns:
    List of strings with names of expired histograms.

  Raises:
    Error if there is an expiry date that doesn't match expected format.
  
Filters histograms to find expired ones if date format is used.
Args:
histograms(Dict[str, Dict]): Histogram descriptions in the form
{name: content}.
base_date(datetime.date): A date to check expiry dates against.

List of strings with names of expired histograms.

Error if there is an expiry date that doesn't match expected format.
Filters histograms to find expired ones if date format is used . Args : histograms ( Dict [ str Dict ] ) : Histogram descriptions in the form { name : content } . base_date ( datetime . date ) : A date to check expiry dates against . List of strings with names of expired histograms . Error if there is an expiry date that doesn ' t match expected format .
def _GetExpiredHistograms(histograms, base_date, current_milestone):
  expired_histograms_names = []
  for name, content in histograms.items():
    if "obsolete" in content or "expires_after" not in content:
      continue
    expiry_str = content["expires_after"]
    if expiry_str == "never":
      continue
    match = _MILESTONE_EXPIRY_RE.search(expiry_str)
    if match:
      if int(match.group(1)) < current_milestone:
        expired_histograms_names.append(name)
    else:
      try:
        expiry_date = datetime.datetime.strptime(
            expiry_str, extract_histograms.EXPIRY_DATE_PATTERN).date()
      except ValueError:
        raise Error(_DATE_FORMAT_ERROR.
                    format(date=expiry_str, name=name))
      if expiry_date < base_date:
        expired_histograms_names.append(name)
  return expired_histograms_names
def _GetExpiredHistograms ( histograms , base_date , current_milestone ) : expired_histograms_names = [ ] for name , content in histograms . items ( ) : if "obsolete" in content or "expires_after" not in content : continue expiry_str = content [ "expires_after" ] if expiry_str == "never" : continue match = _MILESTONE_EXPIRY_RE . search ( expiry_str ) if match : if int ( match . group ( 1 ) ) < current_milestone : expired_histograms_names . append ( name ) else : try : expiry_date = datetime . datetime . strptime ( expiry_str , extract_histograms . EXPIRY_DATE_PATTERN ) . date ( ) except ValueError : raise Error ( _DATE_FORMAT_ERROR . format ( date = expiry_str , name = name ) ) if expiry_date < base_date : expired_histograms_names . append ( name ) return expired_histograms_names
Filters histograms to find expired ones if date format is used.
Filters histograms to find expired ones if date format is used .
"""Filters histograms to find expired ones if date format is used.

  Args:
    histograms(Dict[str, Dict]): Histogram descriptions in the form
      {name: content}.
    base_date(datetime.date): A date to check expiry dates against.

  Returns:
    List of strings with names of expired histograms.

  Raises:
    Error if there is an expiry date that doesn't match expected format.
  """ # if there is match then expiry is in Chrome milsetone format. # if no match then we try the date format.
histograms
base_date
current_milestone