Save the training trace to :py:attr:`CXF_TRACE_FILE` file under the specified directory.

        :raise ValueError: if no output directory was specified
493995
def save(self) -> None:
        
        if self._output_dir is None:
            raise ValueError('Can not save TrainingTrace without output dir.')
        yaml_to_file(self._trace, self._output_dir, CXF_TRACE_FILE)
167482
def save(self, path, verbose=False):
        
        path = os.path.realpath(path)
        if os.path.exists(path):
            if self.load_path and self.load_path == path:
                if verbose:
                    print "saving over previous suite..."
                for context_name in self.context_names:
                    self.context(context_name)  # load before dir deleted
                shutil.rmtree(path)
            else:
                raise SuiteError("Cannot save, path exists: %r" % path)

        contexts_path = os.path.join(path, "contexts")
        os.makedirs(contexts_path)

        # write suite data
        data = self.to_dict()
        filepath = os.path.join(path, "suite.yaml")
        with open(filepath, "w") as f:
            f.write(dump_yaml(data))

        # write contexts
        for context_name in self.context_names:
            context = self.context(context_name)
            context._set_parent_suite(path, context_name)
            filepath = self._context_path(context_name, path)
            if verbose:
                print "writing %r..." % filepath
            context.save(filepath)

        # create alias wrappers
        tools_path = os.path.join(path, "bin")
        os.makedirs(tools_path)
        if verbose:
            print "creating alias wrappers in %r..." % tools_path

        tools = self.get_tools()
        for tool_alias, d in tools.iteritems():
            tool_name = d["tool_name"]
            context_name = d["context_name"]

            data = self._context(context_name)
            prefix_char = data.get("prefix_char")

            if verbose:
                print ("creating %r -> %r (%s context)..."
                       % (tool_alias, tool_name, context_name))
            filepath = os.path.join(tools_path, tool_alias)

            create_forwarding_script(filepath,
                                     module="suite",
                                     func_name="_FWD__invoke_suite_tool_alias",
                                     context_name=context_name,
                                     tool_name=tool_name,
                                     prefix_char=prefix_char)
1004808
def dump_to_pyc(co, python_version, output_dir):
    """"""
    # assume Windows path information from the .exe
    pyc_basename = ntpath.basename(co.co_filename)
    pyc_name = pyc_basename + '.pyc'

    if pyc_name not in IGNORE:
        logging.info("Extracting %s", pyc_name)
        pyc_header = _generate_pyc_header(python_version, len(co.co_code))
        destination = os.path.join(output_dir, pyc_name)
        pyc = open(destination, 'wb')
        pyc.write(pyc_header)
        marshaled_code = marshal.dumps(co)
        pyc.write(marshaled_code)
        pyc.close()
    else:
        logging.info("Skipping %s", pyc_name)
893196
def export_csv_file(self, directory, filename):
        
        bpmn_csv_export.BpmnDiagramGraphCsvExport.export_process_to_csv(self, directory, filename)
443335
def from_file(filepath: str):
        
        trace = TrainingTrace()
        trace._trace = load_config(filepath)
        return trace
512079
def save(self, filename=None, tc=None):
        
        if filename is None:
            filename = self.filename

        for sub in self.sub_workflows:
            sub.save()

        # FIXME this is ugly as pegasus 4.9.0 does not support the full
        # transformation catalog in the DAX. I have asked Karan to fix this so
        # that executables and containers can be specified in the DAX itself.
        # Karan says that XML is going away in Pegasus 5.x and so this code
        # will need to be re-written anyway.
        #
        # the transformation catalog is written in the same directory as the
        # DAX.  pycbc_submit_dax needs to know this so that the right
        # transformation catalog is used when the DAX is planned.
        if tc is None:
            tc = '{}.tc.txt'.format(filename)
        p = os.path.dirname(tc)
        f = os.path.basename(tc)
        if not p:
            p = '.'

        tc = TransformationCatalog(p, f)

        for e in self._adag.executables.copy():
            tc.add(e)
            try:
                tc.add_container(e.container)
            except:
                pass
            self._adag.removeExecutable(e)

        f = open(filename, "w")
        self._adag.writeXML(f)
        tc.write()
377252
def save_analysis(self, filepath=None, **kwargs):
        
        # We pass a copy of the analysis attribute dictionary.
        dict_obj = deepcopy(self.analysis_output)
        # If no filepath is provided we create one.
        if filepath is None:
            filepath = "_".join(
                (str(self.system_id), "pywindow_analysis")
            )
            filepath = '/'.join((os.getcwd(), filepath))
        # Dump the dictionary to json file.
        Output().dump2json(dict_obj, filepath, default=to_list, **kwargs)
        return
1067252
def save_file(key, file_path, *refs):
    
    if not os.path.isfile(file_path):
        return error("Output '{}' set to a missing file: '{}'.".format(key, file_path))

    result = {key: {"file": file_path}}

    if refs:
        missing_refs = [
            ref for ref in refs if not (os.path.isfile(ref) or os.path.isdir(ref))
        ]
        if len(missing_refs) > 0:
            return error(
                "Output '{}' set to missing references: '{}'.".format(
                    key, ', '.join(missing_refs)
                )
            )
        result[key]['refs'] = refs

    return json.dumps(result)
477250
def save_model(self, file_name='model.cx'):
        
        with open(file_name, 'wt') as fh:
            cx_str = self.print_cx()
            fh.write(cx_str)
884536
def save(self, directory=None):
        
        from subprocess import call

        # If user did not supply a new directory, use the one loaded (default: tabledata)
        if isinstance(directory, type(None)):
            directory = self.directory

        # Create the .sql file is it doesn't exist, i.e. if the Database class called a .db file initially
        if not os.path.isfile(self.sqlpath):
            self.sqlpath = self.dbpath.replace('.db', '.sql')
            os.system('touch {}'.format(self.sqlpath))

        # # Write the data to the .sql file
        # with open(self.sqlpath, 'w') as f:
        #     for line in self.conn.iterdump():
        #         f.write('%s\n' % line)

        # Alternatively...
        # Write the schema
        os.system("echo '.output {}\n.schema' | sqlite3 {}".format(self.sqlpath, self.dbpath))

        # Write the table files to the tabledata directory
        os.system("mkdir -p {}".format(directory))
        tables = self.query("select tbl_name from sqlite_master where type='table'")['tbl_name']
        tablepaths = [self.sqlpath]
        for table in tables:
            print('Generating {}...'.format(table))
            tablepath = '{0}/{1}.sql'.format(directory, table)
            tablepaths.append(tablepath)
            with open(tablepath, 'w') as f:
                for line in self.conn.iterdump():
                    line = line.strip()
                    if line.startswith('INSERT INTO "{}"'.format(table)):
                        if sys.version_info.major == 2:
                            f.write(u'{}\n'.format(line).encode('utf-8'))
                        else:
                            f.write(u'{}\n'.format(line))

        print("Tables saved to directory {}/".format(directory))
        print("""=======================================================================================
You can now run git to commit and push these changes, if needed.
For example, if on the master branch you can do the following:
  git add {0} {1}/*.sql
  git commit -m "COMMIT MESSAGE HERE"
  git push origin master
You can then issue a pull request on GitHub to have these changes reviewed and accepted
======================================================================================="""
              .format(self.sqlpath, directory))
1174567
def sample_out_dir(self):
        
        if self._sample_out_dir is None:
            self._sample_out_dir = os.path.join(
                self.output_dir, self._sample_name
            )
        return self._sample_out_dir
448811
def save_feedback(rdict):
    
    # Check for output folder
    if not os.path.exists(_feedback_dir):
        os.makedirs(_feedback_dir)
    
    jcont = json.dumps(rdict)
    f = open(_feedback_file, 'w')
    f.write(jcont)
    f.close()
1324716
def do_save(self, line):
        
        config_file = self._split_args(line, 0, 1)[0]
        self._command_processor.get_session().save(config_file)
        if config_file is None:
            config_file = (
                self._command_processor.get_session().get_default_pickle_file_path()
            )
        self._print_info_if_verbose("Saved session to file: {}".format(config_file))
909350
def save(self, out_path):
        

        out = {
            'selectors': [str(x) for x in self.selectors],
            'trace': [{'stream': str(DataStream.FromEncoded(x.stream)), 'time': x.raw_time, 'value': x.value, 'reading_id': x.reading_id} for x in self]
        }

        with open(out_path, "wb") as outfile:
            json.dump(out, outfile, indent=4)
1341572
def dump_directory_structure(out = sys.stdout):
    

    "Dumping Installation Directory Structure for Debugging: "

    import sys, os
    from os.path import split, abspath, join
    from itertools import chain
    main_dir = split(abspath(sys.modules[__name__].__file__))[0]

    visited_files = []

    def on_error(err):
        visited_files.append( ("  ERROR", str(err)) )

    for path, dirs, files in os.walk(main_dir, onerror = on_error):
        for fn in chain(files, dirs):
            name = join(path, fn)
            try:
                visited_files.append( (name, repr(os.lstat(name))) )
            except:
                visited_files.append( (name, "ERROR calling os.lstat.") )

    def strip_name(n):
        if n[:len(main_dir)] == main_dir:
            return "<root>/" + n[len(main_dir):]
        else:
            return n

    out.write("\n".join( ("  %s: %s" % (strip_name(name), stats))
                     for name, stats in sorted(visited_files)))

    out.flush()
731291
def outputSaveCallback(self, at_data, **kwargs):
        
        path                = at_data[0]
        d_outputInfo        = at_data[1]
        other.mkdir(self.str_outputDir)
        filesSaved          = 0
        other.mkdir(path)
        if not self.testType:
            str_outfile         = '%s/file-ls.txt'      % path
        else:
            str_outfile         = '%s/file-count.txt'   % path

        with open(str_outfile, 'w') as f:
            self.dp.qprint("saving: %s" % (str_outfile), level = 5)
            if not self.testType:
                f.write('%s`' % self.pp.pformat(d_outputInfo['l_file']))
            else:
                f.write('%d\n' % d_outputInfo['filesAnalyzed'])
        filesSaved += 1
        
        return {
            'status':       True,
            'outputFile':   str_outfile,
            'filesSaved':   filesSaved
        }
630429
def save(self):
        
        try:
            with open(self._filename, 'wb') as session_file:
                session_file.write(self.dumps())
        except IOError as error:
            LOGGER.error('Session file error: %s', error)
            raise error