Generate empty image in temporary file for testing
180765
def dummy_image(filetype='gif'):
    
    # 1x1px Transparent GIF
    GIF = 'R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'
    tmp_file = tempfile.NamedTemporaryFile(suffix='.%s' % filetype)
    tmp_file.write(base64.b64decode(GIF))
    return open(tmp_file.name, 'rb')
338708
def make_tempfile(data=None):
    ""
    with tempfile.NamedTemporaryFile(mode='w', delete=False) as temp:
        temp.write(six.text_type(data if data is not None else os.getpid()))
        return temp.name
1018794
def _temporary_filenames(total):
    """"""
    temp_files = [_get_temporary_filename('optimage-') for i in range(total)]
    yield temp_files
    for temp_file in temp_files:
        try:
            os.remove(temp_file)
        except OSError:
            # Continue in case we could not remove the file. One reason is that
            # the fail was never created.
            pass
732343
private void createTempFile() throws IOException {
        _tempfilef = File.createTempFile("org.browsermob.proxy.jetty.util.TempByteHolder-",".tmp",_temp_directory).getCanonicalFile();
        _tempfilef.deleteOnExit();
        _tempfile = new RandomAccessFile(_tempfilef,"rw");
    }
66622
def named_temporary_file(*args, **kwargs):
  
  assert 'delete' not in kwargs
  kwargs['delete'] = False
  fp = tempfile.NamedTemporaryFile(*args, **kwargs)
  try:
    with fp:
      yield fp
  finally:
    os.remove(fp.name)
1226192
def image_create(cmptparms, cspace):
    
    lst = [ctypes.c_int, ctypes.POINTER(ImageComptParmType), ctypes.c_int]
    OPENJPEG.opj_image_create.argtypes = lst
    OPENJPEG.opj_image_create.restype = ctypes.POINTER(ImageType)

    image = OPENJPEG.opj_image_create(len(cmptparms), cmptparms, cspace)
    return(image)
1039713
def generate(self, chars, format='png'):
        
        im = self.generate_image(chars)
        out = BytesIO()
        im.save(out, format=format)
        out.seek(0)
        return out
455869
def gen_image(img, width, height, outfile, img_type='grey'):
    """"""
    assert len(img) == width * height or len(img) == width * height * 3

    if img_type == 'grey':
        misc.imsave(outfile, img.reshape(width, height))

    elif img_type == 'color':
        misc.imsave(outfile, img.reshape(3, width, height))
852095
def __prepare(self, filestem, pos, neg, b):
        
        posFile = open('%s/%s.f' % (self.tmpdir, filestem), 'w')
        negFile = open('%s/%s.n' % (self.tmpdir, filestem), 'w')
        bFile = open('%s/%s.b' % (self.tmpdir, filestem), 'w')

        posFile.write(pos)
        negFile.write(neg)
        bFile.write(b)

        posFile.close()
        negFile.close()
        bFile.close()
120100
def temporary_dir():
    
    d = tempfile.mkdtemp()
    try:
        with cd(d):
            yield d
    finally:
        if os.path.exists(d):
            shutil.rmtree(d)
877476
def dump_img(fname):
    
    img = Image.open(fname)
    width, _ = img.size
    txt = ''
    pixels = list(img.getdata())
    for col in range(width):
        txt += str(pixels[col:col+width])
    return txt
1225941
function dump() {
		$args=func_get_args();
		$format=$args?array_shift($args):'png';
		ob_start();
		call_user_func_array(
			'image'.$format,
			array_merge([$this->data,NULL],$args)
		);
		return ob_get_clean();
	}
113516
function empty(arg0, datatype) {
    var A;
    if (Array.isArray(arg0)) {
        A = new ndarray_1.NDArray({ shape: arg0, datatype: datatype });
    }
    else {
        A = new ndarray_1.NDArray({ shape: [arg0], datatype: datatype });
    }
    return A;
}
419666
def main(args):
  """"""
  random.seed()
  temp_dir = tempfile.mkdtemp()
  logging.info('Created temporary directory: %s', temp_dir)
  validator = SubmissionValidator(
      source_dir=args.source_dir,
      target_dir=args.target_dir,
      temp_dir=temp_dir,
      do_copy=args.copy,
      use_gpu=args.use_gpu,
      containers_file=args.containers_file)
  validator.run()
  logging.info('Deleting temporary directory: %s', temp_dir)
  subprocess.call(['rm', '-rf', temp_dir])
689543
def empty_directory(path=None):
    
    install_dir = tempfile.mkdtemp(dir=path)
    try:
        yield install_dir
    finally:
        shutil.rmtree(install_dir)
1316317
def TEST(fname):
    
    #fname = os.path.join(os.getcwd(), '..','..',  # os.path.join(os.path.getcwd(), '
    m = MapObject(fname, os.path.join(os.getcwd(), 'img_prog_results'))
    m.add_layer(ImagePathFollow('border'))
    m.add_layer(ImagePathFollow('river'))
    m.add_layer(ImagePathFollow('road'))
    
    m.add_layer(ImageArea('sea', col='Blue', density='light'))
    m.add_layer(ImageArea('desert', col='Yellow', density='med'))
    m.add_layer(ImageArea('forest', col='Drak Green', density='light'))
    m.add_layer(ImageArea('fields', col='Green', density='light'))
    
    m.add_layer(ImageObject('mountains'))
    m.add_layer(ImageObject('trees'))
    m.add_layer(ImageObject('towns'))
863181
def save_to_temp(content, file_name=None):
    """"""

    #output = "results.html"
    temp_dir = tempfile.gettempdir()
    #tempfile.TemporaryDirectory()
    #tempfile.NamedTemporaryFile(mode='w+t') as f:
    out_file = os.path.join(temp_dir, file_name)
    #if os.path.exists(output) and os.path.isfile(output):
    file = open(out_file, 'w')
    file.write(content)
    file.close()
    #print("results saved in results.html file.")
    #return output
    #output = str(pathlib.Path(f.name))
    return out_file