Export the function to a dot file
        Args:
            filename (str)
183751
def slithir_cfg_to_dot(self, filename):
        
        from slither.core.cfg.node import NodeType
        with open(filename, 'w', encoding='utf8') as f:
            f.write('digraph{\n')
            for node in self.nodes:
                label = 'Node Type: {} {}\n'.format(NodeType.str(node.type), node.node_id)
                if node.expression:
                    label += '\nEXPRESSION:\n{}\n'.format(node.expression)
                if node.irs:
                    label += '\nIRs:\n' + '\n'.join([str(ir) for ir in node.irs])
                f.write('{}[label="{}"];\n'.format(node.node_id, label))
                for son in node.sons:
                    f.write('{}->{};\n'.format(node.node_id, son.node_id))

            f.write("}\n")
392275
def filename_to_module(filename):
    
    find = re.compile(r"^[^.|-]*")
    name = re.search(find, filename).group(0)
    return name
1303852
def dot(src, **kw):
    
    cmd = "dot -T%s" % kw.pop('T', 'svg')
    for k, v in list(kw.items()):
        if v is True:
            cmd += " -%s" % k
        else:
            cmd += " -%s%s" % (k, v)

    return pipe(cmd, to_bytes(src))
685180
def save_dot(self, fd):
        
        from pylon.io import DotWriter
        DotWriter(self).write(fd)
1142585
def exportProfile(self, filename=''):
        
        if not (filename and isinstance(filename, basestring)):
            filename = QtGui.QFileDialog.getSaveFileName(self,
                                                         'Export Layout as...',
                                                         QtCore.QDir.currentPath(),
                                                         'XView (*.xview)')
            
            if type(filename) == tuple:
                filename = filename[0]
        
        filename = nativestring(filename)
        if not filename:
            return
        
        if not filename.endswith('.xview'):
            filename += '.xview'
        
        profile = self.saveProfile()
        profile.save(filename)
713204
def writeToFile(self, filename, saveOpts=False):
        '''
        
        '''
        try:
            if not filename.endswith('.%s' % self.ftype):
                filename += '.%s' % self.ftype
            s = {'coeffs': self.coeffs}
            if saveOpts:
                s['opts'] = self.opts
#             else:
#                 s['opts':{}]
            np.savez(filename, **s)
            return filename
        except AttributeError:
            raise Exception(
                'need to calibrate camera before calibration can be saved to file')
1120433
def save_to_file(self, fname):
        
        with open(fname, 'w') as f:
            f.write(str(self))
42462
def output(self, _filename):
        

        for c in self.contracts:
            (name, inheritance, var, func_summaries, modif_summaries) = c.get_summary()
            txt = "\nContract %s"%name
            txt += '\nContract vars: '+str(var)
            txt += '\nInheritance:: '+str(inheritance)
            table = PrettyTable(["Function",
                                 "Visibility",
                                 "Modifiers",
                                 "Read",
                                 "Write",
                                 "Internal Calls",
                                 "External Calls"])
            for (_c_name, f_name, visi, modifiers, read, write, internal_calls, external_calls) in func_summaries:
                read = self._convert(read)
                write = self._convert(write)
                internal_calls = self._convert(internal_calls)
                external_calls = self._convert(external_calls)
                table.add_row([f_name, visi, modifiers, read, write, internal_calls, external_calls])
            txt += "\n \n"+str(table)
            table = PrettyTable(["Modifiers",
                                 "Visibility",
                                 "Read",
                                 "Write",
                                 "Internal Calls",
                                 "External Calls"])
            for (_c_name, f_name, visi, _, read, write, internal_calls, external_calls) in modif_summaries:
                read = self._convert(read)
                write = self._convert(write)
                internal_calls = self._convert(internal_calls)
                external_calls = self._convert(external_calls)
                table.add_row([f_name, visi, read, write, internal_calls, external_calls])
            txt += "\n\n"+str(table)
            txt += "\n"
            self.info(txt)
1096130
def cfg_to_dot(self, filename):
        
        with open(filename, 'w', encoding='utf8') as f:
            f.write('digraph{\n')
            for node in self.nodes:
                f.write('{}[label="{}"];\n'.format(node.node_id, str(node)))
                for son in node.sons:
                    f.write('{}->{};\n'.format(node.node_id, son.node_id))

            f.write("}\n")
584943
def dump(filename, options, out=sys.stdout):
    """"""
    with open(filename, 'rb') as file_obj:
        return _dump(file_obj, options=options, out=out)
383674
def export_json(self, filename):
        
        json_graph = self.to_json()
        with open(filename, 'wb') as f:
            f.write(json_graph.encode('utf-8'))
193173
def export(self, filename, fmt="DER"):
        
        f = open(filename, "wb")
        if fmt == "DER":
            f.write(self.der)
        elif fmt == "PEM":
            f.write(self.pem)
        f.close()
22490
def print_functions(self, d):
        
        for c in self.contracts:
            for f in c.functions:
                f.cfg_to_dot(os.path.join(d, '{}.{}.dot'.format(c.name, f.name)))
312130
def ExportTextFile(self, fname, title='unknown plot'):
        ""

        buff = ["# Plot Data for %s" % title,
                "#---------------------------------"]

        out = []
        labels = []
        itrace = 0
        for ax in self.panel.fig.get_axes():
            for line in ax.lines:
                itrace += 1
                x = line.get_xdata()
                y = line.get_ydata()
                ylab = line.get_label()

                if len(ylab) < 1:
                    ylab = 'Y%i' % itrace
                for c in ' .:";|/\\(){}[]\'&^%*$+=-?!@#':
                    ylab = ylab.replace(c, '_')
                xlab = (' X%d' % itrace + ' '*3)[:4]
                ylab = ' '*(18-len(ylab)) + ylab + '  '
                out.extend([x, y])
                labels.extend([xlab, ylab])

        if itrace == 0:
            return

        buff.append('# %s' % (' '.join(labels)))

        npts = [len(a) for a in out]
        for i in range(max(npts)):
            oline = []
            for a in out:
                d = np.nan
                if i < len(a):
                    d = a[i]
                oline.append(gformat(d, 12))
            buff.append(' '.join(oline))

        buff.append('')
        with open(fname, 'w') as fout:
            fout.write("\n".join(buff))
        fout.close()
        self.write_message("Exported data to '%s'" % fname, panel=0)
1373431
def _write_member_markdown_to_file(self, f, prefix, name, member):
    """"""
    if (inspect.isfunction(member) or inspect.ismethod(member) or
        isinstance(member, property)):
      print("- - -", file=f)
      print("", file=f)
      self._print_function(f, prefix, name, member)
      print("", file=f)
    elif inspect.isclass(member):
      print("- - -", file=f)
      print("", file=f)
      print("%s `class %s` {#%s}" % (prefix, name,
                                     _get_anchor(self._module_to_name, name)),
            file=f)
      print("", file=f)
      self._write_class_markdown_to_file(f, name, member)
      print("", file=f)
    else:
      raise RuntimeError("Member %s has unknown type %s" % (name, type(member)))
955412
def source(fname):
    '''
    
    '''
    rex = re.compile('(?:export |declare -x )?(.*?)="(.*?)"')
    out = call_out('source {} && export'.format(fname))
    out = [x for x in out if 'export' in x or 'declare' in x]
    out = {k: v for k, v in [rex.match(x).groups() for x in out if rex.match(x)]}
    for k, v in out.items():
        os.environ[k] = v
1199964
def to_dot(self, name='EXPR'): # pragma: no cover
        """"""
        parts = ['graph', name, '{', 'rankdir=BT;']
        for ex in self.iter_dfs():
            exid = ex.node.id()
            if ex is Zero:
                parts += ["n{} [label=0,shape=box];".format(exid)]
            elif ex is One:
                parts += ["n{} [label=1,shape=box];".format(exid)]
            elif isinstance(ex, Literal):
                parts += ['n{} [label="{}",shape=box];'.format(exid, ex)]
            else:
                parts += ["n{0} [label={1.ASTOP},shape=circle];".format(exid, ex)]
        for ex in self.iter_dfs():
            exid = ex.node.id()
            if isinstance(ex, NotOp):
                parts += ["n{} -- n{};".format(ex.x.node.id(), exid)]
            elif isinstance(ex, ImpliesOp):
                p, q = ex.xs
                parts += ["n{} -- n{} [label=p];".format(p.node.id(), exid)]
                parts += ["n{} -- n{} [label=q];".format(q.node.id(), exid)]
            elif isinstance(ex, IfThenElseOp):
                s, d1, d0 = ex.xs
                parts += ["n{} -- n{} [label=s];".format(s.node.id(), exid)]
                parts += ["n{} -- n{} [label=d1];".format(d1.node.id(), exid)]
                parts += ["n{} -- n{} [label=d0];".format(d0.node.id(), exid)]
            elif isinstance(ex, NaryOp):
                for x in ex.xs:
                    parts += ["n{} -- n{};".format(x.node.id(), exid)]
        parts.append('}')
        return " ".join(parts)