docs/enterprise/extension_query.py
def ExtensionListAsCsv(extensions_list, csv_filename, sort_column='name'):
  """Saves an extensions list to a CSV file.

  Args:
    extensions_list: an extensions list as returned by ComputeExtensionsList
    csv_filename: the name of the CSV file to save
    sort_column: the name of the column by which to sort the data
  """
  all_columns = set()
  flattened_list = list(Flatten(DictToList(extensions_list), all_columns))

  desired_column_order = [
      'id', 'name', 'num_permissions', 'num_installed', 'num_disabled',
      'num_forced', 'permissions', 'installed', 'disabled', 'forced'
  ]

  # Order the columns as desired. Columns other than those in
  # |desired_column_order| will be in an unspecified order after these columns.
  ordered_fieldnames = []
  for c in desired_column_order:
    matching_columns = []
    for f in all_columns:
      if f == c or f.startswith(c):
        matching_columns.append(f)
    ordered_fieldnames.extend(sorted(matching_columns))

  ordered_fieldnames.extend(
      [x for x in desired_column_order if x not in ordered_fieldnames])
  with open(csv_filename, mode='w', newline='', encoding='utf-8') as csv_file:
    writer = csv.DictWriter(csv_file, fieldnames=ordered_fieldnames)
    writer.writeheader()
    for row in sorted(flattened_list, key=lambda ext: ext[sort_column]):
      writer.writerow(row)
Saves an extensions list to a CSV file.

  Args:
    extensions_list: an extensions list as returned by ComputeExtensionsList
    csv_filename: the name of the CSV file to save
    sort_column: the name of the column by which to sort the data
  
Saves an extensions list to a CSV file.
Saves an extensions list to a CSV file .
def ExtensionListAsCsv(extensions_list, csv_filename, sort_column='name'):
  all_columns = set()
  flattened_list = list(Flatten(DictToList(extensions_list), all_columns))
  desired_column_order = [
      'id', 'name', 'num_permissions', 'num_installed', 'num_disabled',
      'num_forced', 'permissions', 'installed', 'disabled', 'forced'
  ]
  ordered_fieldnames = []
  for c in desired_column_order:
    matching_columns = []
    for f in all_columns:
      if f == c or f.startswith(c):
        matching_columns.append(f)
    ordered_fieldnames.extend(sorted(matching_columns))
  ordered_fieldnames.extend(
      [x for x in desired_column_order if x not in ordered_fieldnames])
  with open(csv_filename, mode='w', newline='', encoding='utf-8') as csv_file:
    writer = csv.DictWriter(csv_file, fieldnames=ordered_fieldnames)
    writer.writeheader()
    for row in sorted(flattened_list, key=lambda ext: ext[sort_column]):
      writer.writerow(row)
def ExtensionListAsCsv ( extensions_list , csv_filename , sort_column = 'name' ) : all_columns = set ( ) flattened_list = list ( Flatten ( DictToList ( extensions_list ) , all_columns ) ) desired_column_order = [ 'id' , 'name' , 'num_permissions' , 'num_installed' , 'num_disabled' , 'num_forced' , 'permissions' , 'installed' , 'disabled' , 'forced' ] ordered_fieldnames = [ ] for c in desired_column_order : matching_columns = [ ] for f in all_columns : if f == c or f . startswith ( c ) : matching_columns . append ( f ) ordered_fieldnames . extend ( sorted ( matching_columns ) ) ordered_fieldnames . extend ( [ x for x in desired_column_order if x not in ordered_fieldnames ] ) with open ( csv_filename , mode = 'w' , newline = '' , encoding = 'utf-8' ) as csv_file : writer = csv . DictWriter ( csv_file , fieldnames = ordered_fieldnames ) writer . writeheader ( ) for row in sorted ( flattened_list , key = lambda ext : ext [ sort_column ] ) : writer . writerow ( row )
Saves an extensions list to a CSV file.
Saves an extensions list to a CSV file .
"""Saves an extensions list to a CSV file.

  Args:
    extensions_list: an extensions list as returned by ComputeExtensionsList
    csv_filename: the name of the CSV file to save
    sort_column: the name of the column by which to sort the data
  """ # Order the columns as desired. Columns other than those in # |desired_column_order| will be in an unspecified order after these columns.
extensions_list
an extensions list as returned by ComputeExtensionsList
an extensions list as returned by ComputeExtensionsList
csv_filename
the name of the CSV file to save
the name of the CSV file to save
sort_column
the name of the column by which to sort the data
the name of the column by which to sort the data