Create a file an MEF fits file called filename.  Generate a random
    filename if None given
354492
def create_mef(filename=None):
    
    import pyfits, time

    if not filename:
        ### here I know what filename is to start with.
        import tempfile
        filename=tempfile.mktemp(suffix='.fits')
    else:
        import string, re
        ### filenames gotta be a string and no lead/trailing space
        filename=string.strip(str(filename))
        ### require that the filename ends in .fits
        suffix=re.match(r'^.*.fits$',filename)
        if not suffix:
            filename = filename+'.fits'

    ### create an HDU list
    temp = pyfits.HDUList()

    ### create a primary HDU
    prihdu = pyfits.PrimaryHDU()

    ### build the header
    h=prihdu.header
    h.update('EXTEND',pyfits.TRUE,after='NAXIS')
    h.update('NEXTEND',0,after='EXTEND')
    h.add_comment('MEF created at CADC')
    h.add_comment('Created using '+__name__+' '+__Version__)
    h.add_comment('Extensions may not be in CCD order')
    #h.update('cfh12k',__Version__,comment='split2mef software at CADC')
    h.add_comment('Use the EXTNAME keyword')
    h.add_history('Primary HDU created on '+time.asctime())

    ### stick the HDU onto the HDU list and write to file
    temp.append(prihdu)
    temp.writeto(filename)
    temp.close()

    return(filename)
1135706
def FromFile(cls, filename, mime_type=None, auto_transfer=True,
                 gzip_encoded=False, **kwds):
        """"""
        path = os.path.expanduser(filename)
        if not os.path.exists(path):
            raise exceptions.NotFoundError('Could not find file %s' % path)
        if not mime_type:
            mime_type, _ = mimetypes.guess_type(path)
            if mime_type is None:
                raise exceptions.InvalidUserInputError(
                    'Could not guess mime type for %s' % path)
        size = os.stat(path).st_size
        return cls(open(path, 'rb'), mime_type, total_size=size,
                   close_stream=True, auto_transfer=auto_transfer,
                   gzip_encoded=gzip_encoded, **kwds)
1087923
def create_from_file(cls, filename):
        """"""
        obj = cls()
        obj.object_file = filename
        obj.load()
        return obj
599131
def generate_tensor_filename(self, field_name, file_num, compressed=True):
        
        file_ext = TENSOR_EXT
        if compressed:
            file_ext = COMPRESSED_TENSOR_EXT
        filename = os.path.join(self.filename, 'tensors', '%s_%05d%s' %(field_name, file_num, file_ext))
        return filename
851693
function createFile(file) {
    fs.ensureFileSync(file.name);
    fs.writeFileSync(file.name, file.source);
    return;
}
1334889
def buildNewRootname(filename, extn=None, extlist=None):
    

    # Search known suffixes to replace ('_crj.fits',...)
    _extlist = copy.deepcopy(EXTLIST)
    # Also, add a default where '_dth.fits' replaces
    # whatever extension was there ('.fits','.c1h',...)
    #_extlist.append('.')
    # Also append any user-specified extensions...
    if extlist:
        _extlist += extlist

    if isinstance(filename, fits.HDUList):
        try:
            filename = filename.filename()
        except:
            raise ValueError("Can't determine the filename of an waivered HDUList object.")
    for suffix in _extlist:
        _indx = filename.find(suffix)
        if _indx > 0: break

    if _indx < 0:
         # default to entire rootname
        _indx = len(filename)

    if extn is None:
        extn = ''

    return filename[:_indx] + extn
822605
def random_filename(path=None):
    """"""
    filename = uuid4().hex
    if path is not None:
        filename = os.path.join(path, filename)
    return filename
930700
def GenerateFile(self, input_filename=None, output_filename=None):
    """"""
    if input_filename is None:
      input_filename = output_filename + ".in"
    if output_filename[-3:] == ".in":
      output_filename = output_filename[:-3]
    logging.debug("Generating file %s from %s", output_filename, input_filename)

    with io.open(input_filename, "r") as fd:
      data = fd.read()

    with io.open(output_filename, "w") as fd:
      fd.write(config.CONFIG.InterpolateValue(data, context=self.context))
619397
def init_file(self, filename, lines, expected, line_offset):
        """"""
        self.filename = filename
        self.lines = lines
        self.expected = expected or ()
        self.line_offset = line_offset
        self.file_errors = 0
        self.counters['files'] += 1
        self.counters['physical lines'] += len(lines)
377472
def create(self, name):
        """"""
        if not os.path.exists(self.directory):
            os.makedirs(self.directory)

        filename = self.get_new_filename(name)
        with open(os.path.join(self.directory, filename), 'w') as fp:
            fp.write("def up(db): pass\n\n\n")
            fp.write("def down(db): pass\n")
            logger.info(filename)
1244896
def create_existing_folder(help_string=NO_HELP, default=NO_DEFAULT, suffixes=None):
        # type: (str, Union[str, NO_DEFAULT_TYPE], Union[List[str], None]) -> str
        
        # noinspection PyTypeChecker
        return ParamFilename(
            help_string=help_string,
            default=default,
            type_name="existing_folder",
            suffixes=suffixes,
        )
1084426
def new(filename: str, *, file_attrs: Optional[Dict[str, str]] = None) -> LoomConnection:
	
	if filename.startswith("~/"):
		filename = os.path.expanduser(filename)
	if file_attrs is None:
		file_attrs = {}

	# Create the file (empty).
	# Yes, this might cause an exception, which we prefer to send to the caller
	f = h5py.File(name=filename, mode='w')
	f.create_group('/layers')
	f.create_group('/row_attrs')
	f.create_group('/col_attrs')
	f.create_group('/row_graphs')
	f.create_group('/col_graphs')
	f.flush()
	f.close()

	ds = connect(filename, validate=False)
	for vals in file_attrs:
		ds.attrs[vals] = file_attrs[vals]
	# store creation date
	currentTime = time.localtime(time.time())
	ds.attrs['CreationDate'] = timestamp()
	ds.attrs["LOOM_SPEC_VERSION"] = loompy.loom_spec_version
	return ds
963190
def new_file(self):
        

        file = self.get_untitled_file_name()
        LOGGER.debug("> Creating '{0}' file.".format(file))
        self.set_file(file, is_modified=False, is_untitled=True)
        self.__set_document_signals()
        return file
963066
def from_file(filename, mime=False):
    "
    m = _get_magic_type(mime)
    return m.from_file(filename)
173116
def __create_file_name(self, message_no):
        
        cwd = os.getcwd()
        filename = '{0}_{1}.xml'.format(self.output_prefix, message_no)
        return os.path.join(cwd, filename)
1211367
def from_file(self, fname):
        """"""
        f = open(fname, "rb")
        data = f.read()
        self.update(data)
        f.close()
1302788
def create_existing_file(help_string=NO_HELP, default=NO_DEFAULT, suffixes=None):
        # type: (str, Union[str, NO_DEFAULT_TYPE], Union[List[str], None]) -> str
        
        # noinspection PyTypeChecker
        return ParamFilename(
            help_string=help_string,
            default=default,
            type_name="existing_file",
            suffixes=suffixes,
        )