Writes data to tempfile and sets -i parameter

        data -- list of lines
324437
def _input_as_multiline_string(self, data):
        
        if data:
            self.Parameters['-i']\
                    .on(super(CD_HIT,self)._input_as_multiline_string(data))
        return ''
1105147
def save_lines(lines, filename):
    

    with open(filename, 'w', encoding='utf-8') as f:
        f.write('\n'.join(lines))
973347
public static void writeFile( List<String> lines, String filePath ) throws IOException {
        writeFile(lines, new File(filePath));
    }
1221591
def writeline(self, fmt, *args):
        
        fmt = self.endian + fmt
        size = struct.calcsize(fmt)

        fix = struct.pack(self.endian + 'i', size)
        line = struct.pack(fmt, *args)

        self.write(fix)
        self.write(line)
        self.write(fix)
579995
function(line) {
		var dataArray = [];
		var tempString="";
		var lineLength = line.length;
		var index=0;
		while(index<lineLength) {
			if(line[index]=='"') {
				var index2 = index+1;
				while(line[index2]!='"') {
					tempString+=line[index2];
					index2++;
				}
				dataArray.push(tempString);
				tempString = "";
				index = index2+2;
				continue;
			}
			if(line[index]!=",") {
				tempString += line[index];
				index++; continue;
			} 
			if(line[index]==",") {
				dataArray.push(tempString);
				tempString = "";
				index++;continue;
			}

		}
		dataArray.push(tempString);
		return dataArray;
	}
1358010
public static File writeToTempFile(List<byte[]> bytesList, String prefix, String suffix) throws IOException {
        File tmpOutputFile = null;

        try (RandomAccessFile outputRaf = new RandomAccessFile(tmpOutputFile, "rw")) {
            // Create temporary file
            tmpOutputFile = File.createTempFile(prefix, "." + suffix);
            FileChannel outputChannel = outputRaf.getChannel();

            for (byte[] bytes : bytesList) {
                ByteArrayInputStream is = null;
                try {
                    is = new ByteArrayInputStream(bytes);
                    ReadableByteChannel inputChannel = Channels.newChannel(is);
                    fastChannelCopy(inputChannel, outputChannel);
                } catch (Exception e) {
                    String info = "Failed to write to temporary file: " + e.getMessage();
                    throw new IOException(info, e);
                } finally {
                    if (null != is) is.close();
                }
            }
        } catch (IOException ioe) {
            String info = "Failed to write to temporary file: " + ioe.getMessage();
            throw new IOException(info, ioe);
        }
        return tmpOutputFile;
    }
54839
def _tempfilepager(generator, cmd, color):
    """"""
    import tempfile
    filename = tempfile.mktemp()
    # TODO: This never terminates if the passed generator never terminates.
    text = "".join(generator)
    if not color:
        text = strip_ansi(text)
    encoding = get_best_encoding(sys.stdout)
    with open_stream(filename, 'wb')[0] as f:
        f.write(text.encode(encoding))
    try:
        os.system(cmd + ' "' + filename + '"')
    finally:
        os.unlink(filename)
1078603
public void write(Parameter parameter) throws IOException {
        if (parameter.getParameterValueType() == ParameterValueType.PARAMETERS) {
            if (parameter.isArray()) {
                List<Parameters> list = parameter.getValueAsParametersList();
                if (list != null) {
                    if (parameter.isBracketed()) {
                        writeName(parameter);
                        openSquareBracket();
                        for (Parameters p : list) {
                            indent();
                            openCurlyBracket();
                            write(p);
                            closeCurlyBracket();
                        }
                        closeSquareBracket();
                    } else {
                        for (Parameters p : list) {
                            writeName(parameter);
                            openCurlyBracket();
                            write(p);
                            closeCurlyBracket();
                        }
                    }
                }
            } else {
                if (nullWritable || parameter.getValueAsParameters() != null) {
                    writeName(parameter);
                    openCurlyBracket();
                    write(parameter.getValueAsParameters());
                    closeCurlyBracket();
                }
            }
        } else if (parameter.getParameterValueType() == ParameterValueType.VARIABLE) {
            if (parameter.isArray()) {
                List<?> list = parameter.getValueList();
                if (list != null) {
                    if (parameter.isBracketed()) {
                        writeName(parameter);
                        openSquareBracket();
                        for (Object value : list) {
                            indent();
                            if (value instanceof Parameters) {
                                write((Parameters)value);
                            } else if (value != null) {
                                writeString(value.toString());
                            } else {
                                writeNull();
                            }
                        }
                        closeSquareBracket();
                    } else {
                        for (Object value : list) {
                            writeName(parameter);
                            if (value instanceof Parameters) {
                                write((Parameters)value);
                            } else if (value != null) {
                                writeString(value.toString());
                            } else {
                                writeNull();
                            }
                        }
                    }
                }
            } else {
                Object value = parameter.getValue();
                if (nullWritable || value != null) {
                    writeName(parameter);
                    openCurlyBracket();
                    if (value instanceof Parameters) {
                        write((Parameters)value);
                    } else if (value != null) {
                        writeString(value.toString());
                    } else {
                        writeNull();
                    }
                    closeCurlyBracket();
                }
            }
        } else if (parameter.getParameterValueType() == ParameterValueType.STRING) {
            if (parameter.isArray()) {
                List<String> list = parameter.getValueAsStringList();
                if (list != null) {
                    if (parameter.isBracketed()) {
                        writeName(parameter);
                        openSquareBracket();
                        for (String value : list) {
                            indent();
                            writeString(value);
                        }
                        closeSquareBracket();
                    } else {
                        for (String value : list) {
                            writeName(parameter);
                            writeString(value);
                        }
                    }
                }
            } else {
                String s = parameter.getValueAsString();
                if (nullWritable || s != null) {
                    writeName(parameter);
                    writeString(s);
                }
            }
        } else if (parameter.getParameterValueType() == ParameterValueType.TEXT) {
            if (parameter.isArray()) {
                List<String> list = parameter.getValueAsStringList();
                if (list != null) {
                    if (parameter.isBracketed()) {
                        writeName(parameter);
                        openSquareBracket();
                        for (String text : list) {
                            indent();
                            openRoundBracket();
                            writeText(text);
                            closeRoundBracket();
                        }
                        closeSquareBracket();
                    } else {
                        for (String text : list) {
                            writeName(parameter);
                            openRoundBracket();
                            writeText(text);
                            closeRoundBracket();
                        }
                    }
                }
            } else {
                String text = parameter.getValueAsString();
                if (text != null) {
                    writeName(parameter);
                    openRoundBracket();
                    writeText(text);
                    closeRoundBracket();
                } else if (nullWritable) {
                    writeName(parameter);
                    writeNull();
                }
            }
        } else {
            if (parameter.isArray()) {
                List<?> list = parameter.getValueList();
                if (list != null) {
                    if (parameter.isBracketed()) {
                        writeName(parameter);
                        openSquareBracket();
                        for (Object value : list) {
                            indent();
                            write(value);
                        }
                        closeSquareBracket();
                    } else {
                        for (Object value : list) {
                            writeName(parameter);
                            write(value);
                        }
                    }
                }
            } else {
                if (nullWritable || parameter.getValue() != null) {
                    writeName(parameter);
                    write(parameter.getValue());
                }
            }
        }
    }
723836
def prepend(line, path):
    
    if isinstance(line, str):
        line = line.encode('utf-8')
    if not line.endswith(b'\n'):
        line += b'\n'
    temp = tempfile.NamedTemporaryFile('wb')
    temp_name = temp.name # We really only need a random path-safe name
    temp.close()
    with open(temp_name, 'wb') as temp:
        temp.write(line)
        with open(path, 'rb') as r:
            temp.write(r.read())
    # Now replace the original with the modified version
    shutil.move(temp_name, path)
267087
def write_lines_to_file(cls_name, filename, lines, metadata_dict):
  """"""
  metadata_dict = metadata_dict or {}
  header_line = "%s%s" % (_HEADER_PREFIX, cls_name)
  metadata_line = "%s%s" % (_METADATA_PREFIX,
                            json.dumps(metadata_dict, sort_keys=True))
  with tf.io.gfile.GFile(filename, "wb") as f:
    for line in [header_line, metadata_line]:
      f.write(tf.compat.as_bytes(line))
      f.write(tf.compat.as_bytes("\n"))
    if lines:
      f.write(tf.compat.as_bytes("\n".join(lines)))
      f.write(tf.compat.as_bytes("\n"))
1137668
def _writen(fd, data):
    """"""
    while data:
        n = os.write(fd, data)
        data = data[n:]
20615
def integrate_to_file(what, filename, start_line, end_line):
    

    try:
        with open(filename) as f:
            lines = f.readlines()
    except IOError:
        lines = []

    tmp_file = tempfile.NamedTemporaryFile(delete=False)

    lines.reverse()

    # first copy before start line
    while lines:
        line = lines.pop()

        if line == start_line:
            break

        tmp_file.write(line)

    # insert content
    tmp_file.write(start_line)
    tmp_file.write(what)
    tmp_file.write(end_line)

    # skip until end line
    while lines:
        line = lines.pop()

        if line == end_line:
            break

    # copy rest
    tmp_file.writelines(lines)
    tmp_file.close()

    os.rename(tmp_file.name, filename)
484695
def write_data(self, data, file_datetime):
        
        with self.__lock:
            assert data is not None
            absolute_file_path = self.__file_path
            #logging.debug("WRITE data file %s for %s", absolute_file_path, key)
            make_directory_if_needed(os.path.dirname(absolute_file_path))
            properties = self.read_properties() if os.path.exists(absolute_file_path) else dict()
            write_zip(absolute_file_path, data, properties)
            # convert to utc time.
            tz_minutes = Utility.local_utcoffset_minutes(file_datetime)
            timestamp = calendar.timegm(file_datetime.timetuple()) - tz_minutes * 60
            os.utime(absolute_file_path, (time.time(), timestamp))
425025
public void writeIntData(int i, int position) {

        int temp = count;

        count = position;

        writeInt(i);

        if (count < temp) {
            count = temp;
        }
    }
1008054
def write(self, outfile='../parameters/EQcorrscan_parameters.txt',
              overwrite=False):
        
        outpath = os.sep.join(outfile.split(os.sep)[0:-1])
        if len(outpath) > 0 and not os.path.isdir(outpath):
            msg = ' '.join([os.path.join(outfile.split(os.sep)[0:-1]),
                            'does not exist, check path.'])
            raise IOError(msg)
        # Make sure that the user wants to overwrite the old parameters
        if os.path.isfile(outfile) and not overwrite:
            responding = True
            while responding:
                print(' '.join([outfile, 'exists.  Overwrite? [y/N]']))
                option = raw_input()
                if option.upper() == 'N':
                    raise IOError('File exists, will not overwrite')
                elif option.upper() == 'Y':
                    responding = False
                else:
                    print('Must respond with y or n')
        f = open(outfile, 'w')
        # Write creation info.
        header = ' '.join(['# User:', getpass.getuser(),
                           '\n# Creation date:', str(UTCDateTime()),
                           '\n# EQcorrscan version:',
                           str(eqcorrscan.__version__),
                           '\n\n\n'])
        f.write(header)
        # Write parameter info in a user readable, and parsable format.
        parameters = self.__str__().split('\n')[1:]
        f.write('[eqcorrscan_pars]\n')
        for parameter in parameters:
            f.write(parameter.lstrip() + '\n')
        f.close()
        print('Written parameter file: ' + outfile)
655305
private static void writeParam(Object v, DataOutput writer) throws IOException {
		if (v instanceof Byte) {
			writer.write(BYTE_ID);
			writer.writeByte(((Byte) v).byteValue());
		} else if (v instanceof Short) {
			writer.write(SHORT_ID);
			writer.writeShort(((Short) v).shortValue());
		} else if (v instanceof Integer) {
			writer.write(INTEGER_ID);
			writer.writeInt(((Integer) v).intValue());
		} else if (v instanceof Character) {
			writer.write(CHAR_ID);
			writer.writeChar(((Character) v).charValue());
		} else if (v instanceof Long) {
			writer.write(LONG_ID);
			writer.writeLong(((Long) v).longValue());
		} else if (v instanceof Float) {
			writer.write(FLOAT_ID);
			writer.writeFloat(((Float) v).floatValue());
		} else if (v instanceof Double) {
			writer.write(DOUBLE_ID);
			writer.writeDouble(((Double) v).doubleValue());
		} else if (v instanceof Date) {
			writer.write(DATE_ID);
			writer.writeLong(((Date) v).getTime());
		} else if (v != null) {
			writer.write(STRING_ID);
			writeString(v.toString(), writer);
		} else {
			writer.write(NULL_ID);
		}
	}
782171
def write(self, data, method='w'):
        
        # Create list of lists from flat list
        data = data if isinstance(data[0], (list, set, tuple)) else [[d] for d in data]

        # Open file and write rows
        with open(self.file_path, method) as write:
            wr = csv_builtin.writer(write)
            wr.writerows(data)
        return self.file_path