nodes: 0, module; 1, function_definition; 2, function_name:to_molden; 3, parameters; 4, block; 5, identifier:cartesian_list; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, expression_statement; 11, if_statement; 12, expression_statement; 13, expression_statement; 14, expression_statement; 15, expression_statement; 16, expression_statement; 17, expression_statement; 18, expression_statement; 19, if_statement; 20, identifier:buf; 21, None; 22, identifier:sort_index; 23, True; 24, identifier:overwrite; 25, True; 26, identifier:float_format; 27, attribute; 28, comment:"""Write a list of Cartesians into a molden file.
  
      .. note:: Since it permamently writes a file, this function
          is strictly speaking **not sideeffect free**.
          The list to be written is of course not changed.
  
      Args:
          cartesian_list (list):
          buf (str): StringIO-like, optional buffer to write to
          sort_index (bool): If sort_index is true, the Cartesian
              is sorted by the index before writing.
          overwrite (bool): May overwrite existing files.
          float_format (one-parameter function): Formatter function
              to apply to column’s elements if they are floats.
              The result of this function must be a unicode string.
  
      Returns:
          formatted : string (or unicode, depending on data and options)
      """; 29, identifier:sort_index; 30, block; 31, assignment; 32, assignment; 33, assignment; 34, assignment; 35, assignment; 36, assignment; 37, assignment; 38, comparison_operator:buf is not None; 39, block; 40, else_clause; 41, string; 42, identifier:format; 43, expression_statement; 44, identifier:give_header; 45, attribute; 46, identifier:values; 47, binary_operator:len(cartesian_list) * '1\n'; 48, identifier:energy; 49, list_comprehension; 50, identifier:energy; 51, binary_operator:'\n'.join(energy) + '\n'; 52, identifier:header; 53, call; 54, identifier:coordinates; 55, list_comprehension; 56, identifier:output; 57, binary_operator:header + '\n'.join(coordinates); 58, identifier:buf; 59, None; 60, if_statement; 61, block; 62, string_content:{:.6f}; 63, assignment; 64, parenthesized_expression; 65, identifier:format; 66, call; 67, string; 68, call; 69, for_in_clause; 70, call; 71, string; 72, identifier:give_header; 73, argument_list; 74, call; 75, for_in_clause; 76, identifier:header; 77, call; 78, identifier:overwrite; 79, block; 80, else_clause; 81, return_statement; 82, identifier:cartesian_list; 83, list_comprehension; 84, binary_operator:"[MOLDEN FORMAT]\n"
                     + "[N_GEO]\n"
                     + str(len(cartesian_list)) + "\n"
                     + '[GEOCONV]\n'
                     + 'energy\n{energy}'
                     + 'max-force\n{max_force}'
                     + 'rms-force\n{rms_force}'
                     + '[GEOMETRIES] (XYZ)\n'; 85, identifier:len; 86, argument_list; 87, string_content; 88, identifier:str; 89, argument_list; 90, identifier:m; 91, identifier:cartesian_list; 92, attribute; 93, argument_list; 94, string_content; 95, keyword_argument; 96, keyword_argument; 97, keyword_argument; 98, attribute; 99, argument_list; 100, identifier:x; 101, identifier:cartesian_list; 102, attribute; 103, argument_list; 104, with_statement; 105, block; 106, identifier:output; 107, call; 108, for_in_clause; 109, binary_operator:"[MOLDEN FORMAT]\n"
                     + "[N_GEO]\n"
                     + str(len(cartesian_list)) + "\n"
                     + '[GEOCONV]\n'
                     + 'energy\n{energy}'
                     + 'max-force\n{max_force}'
                     + 'rms-force\n{rms_force}'; 110, string; 111, identifier:cartesian_list; 112, escape_sequence:\n; 113, call; 114, string; 115, identifier:join; 116, identifier:energy; 117, escape_sequence:\n; 118, identifier:energy; 119, identifier:energy; 120, identifier:max_force; 121, identifier:values; 122, identifier:rms_force; 123, identifier:values; 124, identifier:x; 125, identifier:to_xyz; 126, keyword_argument; 127, keyword_argument; 128, string; 129, identifier:join; 130, identifier:coordinates; 131, with_clause; 132, block; 133, with_statement; 134, attribute; 135, argument_list; 136, identifier:molecule; 137, identifier:cartesian_list; 138, binary_operator:"[MOLDEN FORMAT]\n"
                     + "[N_GEO]\n"
                     + str(len(cartesian_list)) + "\n"
                     + '[GEOCONV]\n'
                     + 'energy\n{energy}'
                     + 'max-force\n{max_force}'; 139, string; 140, string_content; 141, attribute; 142, argument_list; 143, string_content; 144, identifier:sort_index; 145, identifier:sort_index; 146, identifier:float_format; 147, identifier:float_format; 148, string_content; 149, with_item; 150, expression_statement; 151, with_clause; 152, block; 153, identifier:molecule; 154, identifier:sort_index; 155, binary_operator:"[MOLDEN FORMAT]\n"
                     + "[N_GEO]\n"
                     + str(len(cartesian_list)) + "\n"
                     + '[GEOCONV]\n'
                     + 'energy\n{energy}'; 156, string; 157, string_content; 158, escape_sequence:\n; 159, attribute; 160, identifier:get; 161, string; 162, integer:1; 163, escape_sequence:\n; 164, escape_sequence:\n; 165, as_pattern; 166, call; 167, with_item; 168, expression_statement; 169, binary_operator:"[MOLDEN FORMAT]\n"
                     + "[N_GEO]\n"
                     + str(len(cartesian_list)) + "\n"
                     + '[GEOCONV]\n'; 170, string; 171, string_content; 172, escape_sequence:\n; 173, identifier:m; 174, identifier:metadata; 175, string_content:energy; 176, call; 177, as_pattern_target; 178, attribute; 179, argument_list; 180, as_pattern; 181, call; 182, binary_operator:"[MOLDEN FORMAT]\n"
                     + "[N_GEO]\n"
                     + str(len(cartesian_list)) + "\n"; 183, string; 184, string_content; 185, escape_sequence:\n; 186, identifier:open; 187, argument_list; 188, identifier:f; 189, identifier:f; 190, identifier:write; 191, identifier:output; 192, call; 193, as_pattern_target; 194, attribute; 195, argument_list; 196, binary_operator:"[MOLDEN FORMAT]\n"
                     + "[N_GEO]\n"
                     + str(len(cartesian_list)); 197, string:"\n"; 198, string_content; 199, escape_sequence:\n; 200, identifier:buf; 201, keyword_argument; 202, identifier:open; 203, argument_list; 204, identifier:f; 205, identifier:f; 206, identifier:write; 207, identifier:output; 208, binary_operator:"[MOLDEN FORMAT]\n"
                     + "[N_GEO]\n"; 209, call; 210, escape_sequence:\n; 211, identifier:mode; 212, string; 213, identifier:buf; 214, keyword_argument; 215, string:"[MOLDEN FORMAT]\n"; 216, string:"[N_GEO]\n"; 217, identifier:str; 218, argument_list; 219, string_content:w; 220, identifier:mode; 221, string; 222, call; 223, string_content:x; 224, identifier:len; 225, argument_list; 226, identifier:cartesian_list
code: def to_molden(cartesian_list, buf=None, sort_index=True,
                overwrite=True, float_format='{:.6f}'.format):
      """Write a list of Cartesians into a molden file.
  
      .. note:: Since it permamently writes a file, this function
          is strictly speaking **not sideeffect free**.
          The list to be written is of course not changed.
  
      Args:
          cartesian_list (list):
          buf (str): StringIO-like, optional buffer to write to
          sort_index (bool): If sort_index is true, the Cartesian
              is sorted by the index before writing.
          overwrite (bool): May overwrite existing files.
          float_format (one-parameter function): Formatter function
              to apply to column’s elements if they are floats.
              The result of this function must be a unicode string.
  
      Returns:
          formatted : string (or unicode, depending on data and options)
      """
      if sort_index:
          cartesian_list = [molecule.sort_index() for molecule in cartesian_list]
  
      give_header = ("[MOLDEN FORMAT]\n"
                     + "[N_GEO]\n"
                     + str(len(cartesian_list)) + "\n"
                     + '[GEOCONV]\n'
                     + 'energy\n{energy}'
                     + 'max-force\n{max_force}'
                     + 'rms-force\n{rms_force}'
                     + '[GEOMETRIES] (XYZ)\n').format
  
      values = len(cartesian_list) * '1\n'
      energy = [str(m.metadata.get('energy', 1)) for m in cartesian_list]
      energy = '\n'.join(energy) + '\n'
  
      header = give_header(energy=energy, max_force=values, rms_force=values)
  
      coordinates = [x.to_xyz(sort_index=sort_index, float_format=float_format)
                     for x in cartesian_list]
      output = header + '\n'.join(coordinates)
  
      if buf is not None:
          if overwrite:
              with open(buf, mode='w') as f:
                  f.write(output)
          else:
              with open(buf, mode='x') as f:
                  f.write(output)
      else:
          return output