Creates a new workbook.

    Raises:
      IOError: if the specified output file already exists.
      OSError: if the specified output file already exists.
      ValueError: if the filename is not set.
182939
def Open(self):
    
    if not self._filename:
      raise ValueError('Missing filename.')

    if os.path.isfile(self._filename):
      raise IOError((
          'Unable to use an already existing file for output '
          '[{0:s}]').format(self._filename))

    options = {
        'constant_memory': True,
        'strings_to_urls': False,
        'strings_to_formulas': False,
        'default_date_format': self._timestamp_format}
    self._workbook = xlsxwriter.Workbook(self._filename, options)
    self._sheet = self._workbook.add_worksheet('Sheet')
    self._current_row = 0
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
53539
def run(self, output):
        '''
        '''
        # Ensure folder exists.
        if self.folder_id not in self.folders.folders(self.user):
            print("E: folder not found: %s" % self.folder_name,
                  file=sys.stderr)
            return

        # Create workbook.
        wb = self.workbook = xlsxwriter.Workbook(output)

        # Create the different styles used by this report generator.
        self.formats['title'] = wb.add_format({'font_size': '18',
                                               'bold': True})

        self.formats['default'] = wb.add_format({'align': 'top'})
        self.formats['bold'] = wb.add_format({'bold': True})

        self.formats['header'] = wb.add_format({
            'bold': True,
            'align': 'center',
            'valign': 'top',
            'font_size': '14',
            'font_color': '#506050',
            'bg_color': '#f5f5f5',
            'right': 1,
            'border_color': 'white'})

        self.formats['pre'] = wb.add_format({'font_name': 'Courier',
                                             'valign': 'top'})

        self.formats['link'] = wb.add_format({'valign': 'top',
                                              'font_color': 'blue',
                                              'underline': True})

        self.formats['type_text'] = wb.add_format({
            'font_color': '#BF8645',
            'valign': 'top',
            'align': 'center'})

        self.formats['type_image'] = wb.add_format({
            'font_color': '#84BF45',
            'valign': 'top',
            'align': 'center'})

        # Generate report for a specific subfolder or *all* subfolders of
        # self.folder .
        if self.subfolder_id is None:
            self._generate_report_all()
        else:
            self._generate_report_single(self.subfolder_id)

        # done and outta here
        self.workbook.close()
1073847
def _setup_output_file(self, output_filename, args, write_header=True):
        """"""
        # write command line into outputFile
        # (without environment variables, they are documented by benchexec)
        try:
            output_file = open(output_filename, 'w') # override existing file
        except IOError as e:
            sys.exit(e)

        if write_header:
            output_file.write(' '.join(map(util.escape_string_shell, self._build_cmdline(args)))
                              + '\n\n\n' + '-' * 80 + '\n\n\n')
            output_file.flush()

        return output_file
508422
def new(self):
        # type: () -> None
        '''
        
        '''
        if self._initialized:
            raise pycdlibexception.PyCdlibInternalError('This XARecord is already initialized!')

        # FIXME: we should allow the user to set these
        self._group_id = 0
        self._user_id = 0
        self._attributes = 0
        self._filenum = 0
        self._initialized = True
1019693
def write(self, file_or_filename):
        
        if isinstance(file_or_filename, basestring):
            file = None
            try:
                file = open(file_or_filename, "wb")
            except Exception, detail:
                logger.error("Error opening %s." % detail)
            finally:
                if file is not None:
                    self._write_data(file)
                    file.close()
        else:
            file = file_or_filename
            self._write_data(file)

        return file
789650
def create_file(self, filename, indented_data=None):
        
        filedir, filename = os.path.split(filename)
        if filedir:
            self.create_directory(filedir)
        path = os.path.join(self.path, filedir, filename)
        data = indented_data
        if isinstance(data, bytes) and not isinstance(data, str):
            # This is binary data rather than text.
            mode = 'wb'
        else:
            mode = 'w'
            if data:
                data = textwrap.dedent(data)
        with open(path, mode) as fi:
            if data:
                fi.write(data)
        return path
1281762
def open(self, file_path):
        

        if self.is_opened() and self.workbook.file_path == file_path:
            self._logger.logger.debug("workbook already opened: {}".format(self.workbook.file_path))
            return

        self.close()
        self._open(file_path)
1354521
private void createOutputFile() throws IOException {
        this.fileChannel = Files.newByteChannel(Paths.get(filePath), StandardOpenOption.CREATE, StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING);
    }
1272243
def write_file(name, text, opts):
    """"""
    fname = path.join(opts.destdir, '%s.%s' % (name, opts.suffix))
    if opts.dryrun:
        print 'Would create file %s.' % fname
        return
    if not opts.force and path.isfile(fname):
        print 'File %s already exists, skipping.' % fname
    else:
        print 'Creating file %s.' % fname
        f = open(fname, 'w')
        try:
            f.write(text)
        finally:
            f.close()
277356
def write(self, file_or_filename, prog=None, format='xdot'):
        
        if prog is None:
            file = super(DotWriter, self).write(file_or_filename)
        else:
            buf = StringIO.StringIO()
            super(DotWriter, self).write(buf)
            buf.seek(0)
            data = self.create(buf.getvalue(), prog, format)

            if isinstance(file_or_filename, basestring):
                file = None
                try:
                    file = open(file_or_filename, "wb")
                except:
                    logger.error("Error opening %s." % file_or_filename)
                finally:
                    if file is not None:
                        file.write(data)
                        file.close()
            else:
                file = file_or_filename
                file.write(data)

        return file
824446
def _create(self):
        
        # Create new file
        with _handle_azure_exception():
            self._create_from_size(
                content_length=self._content_length, **self._client_kwargs)
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
396740
def add_worksheet(name = nil)
      if name.nil? then
        n = 0

        begin
          name = SHEET_NAME_TEMPLATE % (n += 1)
        end until self[name].nil?
      end

      new_worksheet = Worksheet.new(:workbook => self, :sheet_name => name)
      worksheets << new_worksheet
      new_worksheet
    end
1081784
def new_file(new_name=false, body)
      f_name = new_name || file_name_with_path
      File.open(f_name, "w") { |line|
        line.write(body)
        line
      }
    end
422884
def save_as(self, new_filename):
        
        xfile._save_file(
            self._filename, self._workbookTree, new_filename)
1188380
def try_create_dir(self, path):
        
        if not os.path.exists(path):
            os.mkdir(path)
        elif not os.path.isdir(path):
            ValueError("Unable to create directory:" + path + " because a file already exists with the same name.")