예제 #1
0
def write_report(directory, report):
    io.write(report) # write to screen for convenience?

    pathname = os.path.basename(os.path.abspath(directory))
    fp = io.get_tmpfile('%s.explore_codebase' % pathname, noclobber=True)
    open(fp, 'w').write(report)
    io.write_result("Wrote file %s ." % fp)
예제 #2
0
def trace_file(fp, filetype):
    try:
        projview = False
        if filetype == FileTypes.DelphiProjectGroup:
            projview = True
        return trace_program.DepTracer().trace_write(fp, projview=projview,
                                                  noclobber=True)
    except:
        s = traceback.format_exc()
        f = os.path.basename(fp)
        open(io.get_tmpfile('%s.explore_errors' % f,), 'a').write(s)
예제 #3
0
파일: mixins.py 프로젝트: numerodix/delpy
    def to_file(self, noclobber=None):
        filename = self.get_serialized_name()
        filepath = io.get_tmpfile('%s%s' % (filename,
                                            self.serialize_extension),
                                 noclobber=noclobber)

        flatobj = self.get_serialized_obj()

        # XXX use older pickle format for mixing with different python versions
#        pickle.dump(flatobj, open(filepath, 'wb'), pickle.HIGHEST_PROTOCOL)
        # open to write as binary to preempt win/lin portability bug
        pickle.dump(flatobj, open(filepath, 'wb'))

        io.write_result("Wrote file %s ." % filepath)
        return filepath
예제 #4
0
    def show_dot(self, tred=True):
        format = 'pdf'
        file_src = io.get_tmpfile(self.delphifile.filename)
        file_target = io.get_tmpfile('%s.%s' % (self.delphifile.filename, format))

        # split up
        tmpdir = os.path.dirname(file_src)
        file_src = os.path.basename(file_src)
        file_target = os.path.basename(file_target)

        self.write_dot(tmpdir, file_src)

        self.compile_dot(tmpdir, file_src, file_target, format,
                         transitive_reduction=tred)

        try:
            reader = io.find_pdf_reader()
            io.invoke([reader, file_target], cwd=tmpdir)
        except:
            import traceback
            traceback.print_exc()
        finally:
            os.unlink(os.path.join(tmpdir, file_src))
            os.unlink(os.path.join(tmpdir, file_target))
예제 #5
0
파일: prof.py 프로젝트: numerodix/delpy
def main(args):
    prog = args.pop(0)
    # try to locate prog on same path as sys.argv[0]
    if not os.path.exists(prog):
        path = os.path.dirname(os.path.abspath(sys.argv[0]))
        prog = os.path.join(path, prog)
        if not os.path.exists(prog):
            io.write_result('Not found: %s' % os.path.basename(prog),
                            error=True)
            return

    fp = io.get_tmpfile(os.path.basename(prog) + '.profile')

    args = ['python', '-m', 'cProfile', '-o', fp, prog] + args
    io.invoke(args)

    strip_dirs(fp)
    output(fp)
예제 #6
0
def do_preprocess(filelist, is_directive_on, dipp_conditionals):
    dipp_bin = get_dipp()

    for fp in filelist:
        filename = os.path.basename(fp)
        directory = os.path.dirname(fp)

        tmpfile = io.get_tmpfile(filename)
        if io.platform_is_cygwin():
            tmpfile = io.path_cygwin_to_win(tmpfile)

        ### PASS 1
        flags = ['-o', '-PD2006', '-li']

        exitcode = io.run_win32app('Preprocessing includes in %s' % fp,
                                   directory,
                                   [dipp_bin, filename, tmpfile]
                                   + flags)
        if not exitcode:
            io.rename(tmpfile, fp)
        else:
            return exitcode

        ### PASS 1.5
        prepare_to_preprocess(is_directive_on, fp)

        ### PASS 2
        flags = ['-o', '-PD2006', '-c', '-h', dipp_conditionals]

        exitcode = io.run_win32app('Preprocessing conditionals in %s' % fp,
                                   directory,
                                   [dipp_bin, filename, tmpfile]
                                   + flags)
        if not exitcode:
            io.rename(tmpfile, fp)
        else:
            return exitcode

        ### PASS 2.5
        do_after_preprocess(fp)

    return exitcode