nodes: 0, module; 1, function_definition; 2, function_name:_add_meta; 3, parameters; 4, block; 5, identifier:xs; 6, default_parameter; 7, default_parameter; 8, expression_statement; 9, expression_statement; 10, for_statement; 11, return_statement; 12, identifier:sample; 13, None; 14, identifier:config; 15, None; 16, comment:"""Add top level information about the sample or flowcell to output.
  
      Sorts outputs into sample names (sample input) and project (config input).
      """; 17, assignment; 18, identifier:x; 19, identifier:xs; 20, block; 21, identifier:out; 22, identifier:out; 23, list; 24, if_statement; 25, expression_statement; 26, if_statement; 27, if_statement; 28, expression_statement; 29, boolean_operator; 30, block; 31, assignment; 32, identifier:sample; 33, block; 34, identifier:config; 35, block; 36, call; 37, not_operator; 38, not_operator; 39, raise_statement; 40, subscript; 41, call; 42, expression_statement; 43, if_statement; 44, expression_statement; 45, expression_statement; 46, expression_statement; 47, attribute; 48, argument_list; 49, call; 50, call; 51, call; 52, identifier:x; 53, string:"mtime"; 54, attribute; 55, argument_list; 56, assignment; 57, comparison_operator:"sample" not in x; 58, block; 59, elif_clause; 60, assignment; 61, assignment; 62, assignment; 63, identifier:out; 64, identifier:append; 65, identifier:x; 66, identifier:isinstance; 67, argument_list; 68, attribute; 69, argument_list; 70, identifier:ValueError; 71, argument_list; 72, identifier:shared; 73, identifier:get_file_timestamp; 74, subscript; 75, identifier:sample_name; 76, call; 77, string:"sample"; 78, identifier:x; 79, expression_statement; 80, comparison_operator:x["sample"] != sample_name; 81, block; 82, identifier:fc_name; 83, boolean_operator; 84, identifier:fc_date; 85, boolean_operator; 86, subscript; 87, binary_operator:"%s_%s" % (fc_date, fc_name); 88, subscript; 89, attribute; 90, attribute; 91, identifier:exists; 92, subscript; 93, binary_operator:"Unexpected path for upload: %s" % x; 94, identifier:x; 95, string:"path"; 96, attribute; 97, argument_list; 98, assignment; 99, subscript; 100, identifier:sample_name; 101, expression_statement; 102, call; 103, string:"project"; 104, call; 105, call; 106, identifier:x; 107, string:"run"; 108, string:"%s_%s"; 109, tuple; 110, identifier:x; 111, string:"path"; 112, identifier:six; 113, identifier:string_types; 114, identifier:os; 115, identifier:path; 116, identifier:x; 117, string:"path"; 118, string:"Unexpected path for upload: %s"; 119, identifier:x; 120, identifier:dd; 121, identifier:get_sample_name; 122, identifier:sample; 123, subscript; 124, identifier:sample_name; 125, identifier:x; 126, string:"sample"; 127, assignment; 128, attribute; 129, argument_list; 130, attribute; 131, argument_list; 132, attribute; 133, argument_list; 134, identifier:fc_date; 135, identifier:fc_name; 136, identifier:x; 137, string:"sample"; 138, subscript; 139, identifier:sample_name; 140, identifier:config; 141, identifier:get; 142, string:"fc_name"; 143, identifier:config; 144, identifier:get; 145, string:"fc_date"; 146, call; 147, identifier:strftime; 148, string:"%Y-%m-%d"; 149, identifier:x; 150, string:"run"; 151, attribute; 152, argument_list; 153, attribute; 154, identifier:now; 155, identifier:datetime; 156, identifier:datetime
code: def _add_meta(xs, sample=None, config=None):
      """Add top level information about the sample or flowcell to output.
  
      Sorts outputs into sample names (sample input) and project (config input).
      """
      out = []
      for x in xs:
          if not isinstance(x["path"], six.string_types) or not os.path.exists(x["path"]):
              raise ValueError("Unexpected path for upload: %s" % x)
          x["mtime"] = shared.get_file_timestamp(x["path"])
          if sample:
              sample_name = dd.get_sample_name(sample)
              if "sample" not in x:
                  x["sample"] = sample_name
              elif x["sample"] != sample_name:
                  x["run"] = sample_name
          if config:
              fc_name = config.get("fc_name") or "project"
              fc_date = config.get("fc_date") or datetime.datetime.now().strftime("%Y-%m-%d")
              x["run"] = "%s_%s" % (fc_date, fc_name)
          out.append(x)
      return out