@staticmethod<EOL><INDENT>def write_log(log_path, data, allow_append=True):<DEDENT>
append = os.path.isfile(log_path)<EOL>islist = isinstance(data, list)<EOL>if append and not allow_append:<EOL><INDENT>raise Exception('<STR_LIT>'<EOL>'<STR_LIT>' % log_path)<EOL><DEDENT>if not (islist or isinstance(data, Args)):<EOL><INDENT>raise Exception('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>specs = data if islist else data.specs<EOL>if not all(isinstance(el,dict) for el in specs):<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>log_file = open(log_path, '<STR_LIT>') if append else open(log_path, '<STR_LIT:w>')<EOL>start = int(log_file.readlines()[-<NUM_LIT:1>].split()[<NUM_LIT:0>])+<NUM_LIT:1> if append else <NUM_LIT:0><EOL>ascending_indices = range(start, start+len(data))<EOL>log_str = '<STR_LIT:\n>'.join(['<STR_LIT>' % (tid, json.dumps(el))<EOL>for (tid, el) in zip(ascending_indices,specs)])<EOL>log_file.write("<STR_LIT:\n>"+log_str if append else log_str)<EOL>log_file.close()<EOL>
Writes the supplied specifications to the log path. The data
may be supplied as either as a an Args or as a list of
dictionaries.

By default, specifications will be appropriately appended to
an existing log file. This can be disabled by setting
allow_append to False.