예제 #1
0
class xtriage_output(printed_output):
    def __init__(self, out):
        super(xtriage_output, self).__init__(out)
        self.gui_output = True
        self._out_orig = self.out
        self.out = StringIO()
        self._sub_header_to_out = {}

    def show_big_header(self, text):
        pass

    def show_header(self, text):
        self._out_orig.write(self.out.getvalue())
        self.out = StringIO()
        super(xtriage_output, self).show_header(text)

    def show_sub_header(self, title):
        self._out_orig.write(self.out.getvalue())
        self.out = StringIO()
        self._current_sub_header = title
        assert title not in self._sub_header_to_out
        self._sub_header_to_out[title] = self.out

    def flush(self):
        self._out_orig.write(self.out.getvalue())
        self.out.flush()
        self._out_orig.flush()
예제 #2
0
def colorize(source):
    """
    write colorized version to "[filename].py.html"
    """
    html = StringIO()
    Parser(source, html).format(None, None)
    html.flush()
    html.seek(0)
    return html.read()
예제 #3
0
def colorize(source):
    """
    write colorized version to "[filename].py.html"
    """
    html = StringIO()
    Parser(source, html).format(None, None)
    html.flush()
    html.seek(0)
    return html.read()
예제 #4
0
파일: __init__.py 프로젝트: dials/cctbx
class LoggingFramework:
  def __init__(self):
    self.k = StringIO()
    self.current_out = sys.stdout
    self.current_err = sys.stderr
    sys.stdout = self.k
    sys.stderr = self.k

  def __del__(self):
    sys.stdout = self.current_out
    sys.stderr = self.current_err
    self.k.flush()
    self.k.close()

  def getvalue(self): return self.k.getvalue()
def run_call_back(flags,
                  space_group_info,
                  max_n_indices=5,
                  anomalous_flag=True):
    if (not flags.Verbose):
        out = StringIO()
    else:
        out = sys.stdout
    if (flags.chunk):
        chunk_n, chunk_i = [int(i) for i in flags.chunk.split(",")]
    else:
        chunk_n = 1
        chunk_i = 0
    if (flags.tag):
        if (flags.tag == "internal"):
            strudat_contents = strudat.read_all_entries(StringIO(zeolite_edi))
            strudat_entries = strudat_contents.entries
        else:
            atlas_file = libtbx.env.find_in_repositories(
                relative_path="phenix_regression/misc/strudat_zeolite_atlas",
                test=os.path.isfile)
            assert atlas_file is not None
            strudat_contents = strudat.read_all_entries(open(atlas_file))
            if (not isinstance(flags.tag, str)):
                strudat_entries = strudat_contents.entries
            else:
                strudat_entries = [strudat_contents.get(tag=flags.tag)]
                assert strudat_entries[0] is not None
    if (flags.isotropic):
        use_u_aniso_flags = [False]
    elif (flags.anisotropic):
        use_u_aniso_flags = [True]
    else:
        use_u_aniso_flags = [False, True]
    if (not flags.tag):
        for n_scatterers in range(2, 3 + 1):
            for use_u_aniso in use_u_aniso_flags:
                xray_structure = random_structure.xray_structure(
                    space_group_info=space_group_info,
                    n_scatterers=n_scatterers,
                    elements="random",
                    volume_per_atom=100,
                    general_positions_only=False,
                    random_f_prime_d_min=1,
                    random_f_double_prime=anomalous_flag,
                    use_u_aniso=use_u_aniso,
                    use_u_iso=not (use_u_aniso),
                    random_u_iso=True,
                    random_u_iso_scale=0.3,
                    random_occupancy=True)
                exercise(xray_structure=xray_structure,
                         anomalous_flag=anomalous_flag,
                         max_n_indices=max_n_indices,
                         out=out)
                out.flush()
    else:
        i_structure = count()
        for entry in strudat_entries:
            if (next(i_structure) % chunk_n != chunk_i): continue
            # XXX Not sure why this stderr output is necessary. Disabling to clean
            # up t96 output.
            # print >> sys.stderr, "strudat tag:", entry.tag
            # sys.stderr.flush()
            print("strudat tag:", entry.tag, file=out)
            out.flush()
            for use_u_aniso in use_u_aniso_flags:
                xray_structure = entry.as_xray_structure()
                xray_structure = random_structure.xray_structure(
                    space_group_info=xray_structure.space_group_info(),
                    unit_cell=xray_structure.unit_cell(),
                    sites_frac=xray_structure.sites_frac(),
                    elements="random",
                    random_f_prime_d_min=1,
                    random_f_double_prime=anomalous_flag,
                    use_u_aniso=use_u_aniso,
                    use_u_iso=not (use_u_aniso),
                    random_u_iso=True,
                    random_u_iso_scale=0.3,
                    random_occupancy=True)
                exercise(xray_structure=xray_structure,
                         anomalous_flag=anomalous_flag,
                         max_n_indices=max_n_indices,
                         out=out)
                out.flush()
    if (flags.tag):
        return False