<html><body>
<p>3 new commits in yt:</p>
<p><a href="https://bitbucket.org/yt_analysis/yt/commits/81dc5b3d5633/">https://bitbucket.org/yt_analysis/yt/commits/81dc5b3d5633/</a> Changeset: 81dc5b3d5633 Branch: yt User: ngoldbaum Date: 2016-03-31 02:52:12+00:00 Summary: logging: don't create a StreamHandler unless we will use it. Closes #1024 Affected #: 1 file</p>
<p>diff -r ac130eab01032636d00b9de431b8e5f1b4b788d6 -r 81dc5b3d563331842988e4a09e42232e833ddb14 yt/utilities/logger.py --- a/yt/utilities/logger.py +++ b/yt/utilities/logger.py @@ -54,36 +54,43 @@</p>
<pre>ytLogger = logging.getLogger("yt")
</pre>
<p>-yt_sh = logging.StreamHandler(stream=stream) -# create formatter and add it to the handlers -formatter = logging.Formatter(ufstring) -yt_sh.setFormatter(formatter) -# add the handler to the logger -ytLogger.addHandler(yt_sh) -ytLogger.setLevel(level) -ytLogger.propagate = False –</p>
<pre>def disable_stream_logging():</pre>
<ul><li><p>ytLogger.removeHandler(ytLogger.handlers[0])</p></li></ul>
<p>+ if len(ytLogger.handlers) > 0: + ytLogger.removeHandler(ytLogger.handlers[0])</p>
<pre> h = logging.NullHandler()
ytLogger.addHandler(h)
</pre>
<p>-original_emitter = yt_sh.emit –</p>
<pre>def colorize_logging():
f = logging.Formatter(cfstring)
ytLogger.handlers[0].setFormatter(f)
yt_sh.emit = add_coloring_to_emit_ansi(yt_sh.emit)
def uncolorize_logging():</pre>
<ul><li><p>f = logging.Formatter(ufstring)</p></li>
<li><p>ytLogger.handlers[0].setFormatter(f)</p></li>
<li><p>yt_sh.emit = original_emitter</p></li></ul>
<p>– -if ytcfg.getboolean("yt", "coloredlogs"):</p>
<ul><li><p>colorize_logging()</p></li></ul>
<p>+ try: + f = logging.Formatter(ufstring) + ytLogger.handlers[0].setFormatter(f) + yt_sh.emit = original_emitter + except NameError: + # yt_sh and original_emitter are not defined because + # suppressStreamLogging is True, so we continue since there is nothing + # to uncolorize + pass</p>
<pre>if ytcfg.getboolean("yt", "suppressStreamLogging"):
disable_stream_logging()</pre>
<p>+else: + yt_sh = logging.StreamHandler(stream=stream) + # create formatter and add it to the handlers + formatter = logging.Formatter(ufstring) + yt_sh.setFormatter(formatter) + # add the handler to the logger + ytLogger.addHandler(yt_sh) + ytLogger.setLevel(level) + ytLogger.propagate = False + + original_emitter = yt_sh.emit + + if ytcfg.getboolean("yt", "coloredlogs"): + colorize_logging()</p>
<pre>ytLogger.debug("Set log level to %s", level)</pre>
<p><a href="https://bitbucket.org/yt_analysis/yt/commits/def617b415de/">https://bitbucket.org/yt_analysis/yt/commits/def617b415de/</a> Changeset: def617b415de Branch: yt User: ngoldbaum Date: 2016-03-31 14:43:16+00:00 Summary: Merging with mainline Affected #: 14 files</p>
<p>diff -r 81dc5b3d563331842988e4a09e42232e833ddb14 -r def617b415dec95ac24052fd0d378a3700fcd092 doc/source/analyzing/mesh_filter.ipynb --- a/doc/source/analyzing/mesh_filter.ipynb +++ b/doc/source/analyzing/mesh_filter.ipynb @@ -143,13 +143,13 @@</p>
<pre>"source": [
"ph1 = yt.PhasePlot(ad, 'density', 'temperature', 'cell_mass', weight_field=None)\n",
"ph1.set_xlim(3e-31, 3e-27)\n",</pre>
<ul><li><p>“ph1.set_title('cell_mass', 'No Cuts')\n”,</p></li></ul>
<p>+ “ph1.annotate_title('No Cuts')\n”,</p>
<pre>"ph1.set_figure_size(5)\n",
"ph1.show()\n",
"\n",
"ph1 = yt.PhasePlot(dense_ad, 'density', 'temperature', 'cell_mass', weight_field=None)\n",
"ph1.set_xlim(3e-31, 3e-27)\n",</pre>
<ul><li><p>“ph1.set_title('cell_mass', 'Dense Gas')\n”,</p></li></ul>
<p>+ “ph1.annotate_title('Dense Gas')\n”,</p>
<pre> "ph1.set_figure_size(5)\n",
"ph1.show()"
]</pre>
<p>diff -r 81dc5b3d563331842988e4a09e42232e833ddb14 -r def617b415dec95ac24052fd0d378a3700fcd092 doc/source/cookbook/tests/test_cookbook.py --- a/doc/source/cookbook/tests/test_cookbook.py +++ b/doc/source/cookbook/tests/test_cookbook.py @@ -11,16 +11,22 @@</p>
<pre>"""
import glob
import os</pre>
<p>+import sys</p>
<pre>import subprocess
PARALLEL_TEST = {"rockstar_nest.py": "3"}</pre>
<p>+BLACKLIST = ["opengl_ipython.py", “opengl_vr.py”]</p>
<p>+if sys.version_info >= (3,0,0): + BLACKLIST.append("rockstar_nest.py")</p>
<pre>def test_recipe():
'''Dummy test grabbing all cookbook's recipes'''
for fname in glob.glob("doc/source/cookbook/*.py"):
recipe = os.path.basename(fname)</pre>
<p>+ if recipe in BLACKLIST: + continue</p>
<pre> check_recipe.description = "Testing recipe: %s" % recipe
if recipe in PARALLEL_TEST:
yield check_recipe, \</pre>
<p>diff -r 81dc5b3d563331842988e4a09e42232e833ddb14 -r def617b415dec95ac24052fd0d378a3700fcd092 doc/source/reference/api/api.rst --- a/doc/source/reference/api/api.rst +++ b/doc/source/reference/api/api.rst @@ -743,6 +743,7 @@</p>
<pre>~yt.visualization.plot_window.PWViewerMPL.annotate_clear
~yt.visualization.plot_modifications.ArrowCallback</pre>
<p>+ ~yt.visualization.plot_modifications.CellEdgesCallback</p>
<pre>~yt.visualization.plot_modifications.ClumpContourCallback
~yt.visualization.plot_modifications.ContourCallback
~yt.visualization.plot_modifications.CuttingQuiverCallback</pre>
<p>diff -r 81dc5b3d563331842988e4a09e42232e833ddb14 -r def617b415dec95ac24052fd0d378a3700fcd092 doc/source/visualizing/callbacks.rst --- a/doc/source/visualizing/callbacks.rst +++ b/doc/source/visualizing/callbacks.rst @@ -273,6 +273,31 @@</p>
<pre> slc.annotate_grids()
slc.save()
</pre>
<p>+.. _annotate-cell-edges: + +Overplot Cell Edges +~~~~~~~~~~~~~~~~~~~ + +.. function:: annotate_cell_edges(line_width=1.0, alpha = 1.0, + color = (0.0, 0.0, 0.0)) + + (This is a proxy for + :class:`~yt.visualization.plot_modifications.CellEdgesCallback`.) + + Annotate the edges of cells, where the ``line_width`` in pixels is specified. + The ``alpha`` of the overlaid image and the ``color`` of the lines are also + specifiable. Note that because the lines are drawn from both sides of a + cell, the image sometimes has the effect of doubling the line width. + Color here is in RGB float values (0 to 1). + +.. python-script:: + + import yt + ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030") + slc = yt.SlicePlot(ds, ‘z’, ‘density’, width=(10,'kpc'), center='max') + slc.annotate_cell_edges() + slc.save() +</p>
<pre>.. _annotate-halos:
Overplot Halo Annotations</pre>
<p>diff -r 81dc5b3d563331842988e4a09e42232e833ddb14 -r def617b415dec95ac24052fd0d378a3700fcd092 tests/tests_2.7.yaml --- a/tests/tests_2.7.yaml +++ b/tests/tests_2.7.yaml @@ -42,7 +42,7 @@</p>
<pre>local_tipsy_270:
- yt/frontends/tipsy/tests/test_outputs.py
</pre>
<ul><li><p>local_varia_273:</p></li></ul>
<p>+ local_varia_274:</p>
<pre>- yt/analysis_modules/radmc3d_export
- yt/frontends/moab/tests/test_c5.py
- yt/analysis_modules/photon_simulator/tests/test_spectra.py</pre>
<p>diff -r 81dc5b3d563331842988e4a09e42232e833ddb14 -r def617b415dec95ac24052fd0d378a3700fcd092 tests/tests_3.5.yaml --- a/tests/tests_3.5.yaml +++ b/tests/tests_3.5.yaml @@ -25,6 +25,8 @@</p>
<pre>local_halos_350:
- yt/frontends/owls_subfind/tests/test_outputs.py</pre>
<p>+ – yt/frontends/gadget_fof/tests/test_outputs.py:test_fields_g5 + – yt/frontends/gadget_fof/tests/test_outputs.py:test_fields_g42</p>
<pre>local_owls_350:
- yt/frontends/owls/tests/test_outputs.py</pre>
<p>@@ -40,7 +42,7 @@</p>
<pre>local_tipsy_350:
- yt/frontends/tipsy/tests/test_outputs.py
</pre>
<ul><li><p>local_varia_350:</p></li></ul>
<p>+ local_varia_351:</p>
<pre>- yt/analysis_modules/radmc3d_export
- yt/frontends/moab/tests/test_c5.py
- yt/analysis_modules/photon_simulator/tests/test_spectra.py</pre>
<p>diff -r 81dc5b3d563331842988e4a09e42232e833ddb14 -r def617b415dec95ac24052fd0d378a3700fcd092 yt/frontends/gadget_fof/tests/test_outputs.py --- a/yt/frontends/gadget_fof/tests/test_outputs.py +++ b/yt/frontends/gadget_fof/tests/test_outputs.py @@ -62,7 +62,7 @@</p>
<pre>for hid in range(0, ds.index.particle_count["Group"]):
my_h = ds.halo("Group", hid)
h_ids = my_h["ID"]</pre>
<ul><li><p>for sid in range(my_h["subhalo_number"]):</p></li></ul>
<p>+ for sid in range(int(my_h["subhalo_number"][0])):</p>
<pre>my_s = ds.halo("Subhalo", (my_h.particle_identifier, sid))
total_sub += my_s["ID"].size
total_int += np.intersect1d(h_ids, my_s["ID"]).size</pre>
<p>diff -r 81dc5b3d563331842988e4a09e42232e833ddb14 -r def617b415dec95ac24052fd0d378a3700fcd092 yt/utilities/lib/grid_traversal.pyx --- a/yt/utilities/lib/grid_traversal.pyx +++ b/yt/utilities/lib/grid_traversal.pyx @@ -31,6 +31,8 @@</p>
<pre>from cython.parallel import prange, parallel, threadid
from vec3_ops cimport dot, subtract, L2_norm, fma
</pre>
<p>+from cpython.exc cimport PyErr_CheckSignals +</p>
<pre>DEF Nch = 4
cdef class PartitionedGrid:</pre>
<p>@@ -458,6 +460,7 @@</p>
<pre>size = nx * ny
cdef ImageAccumulator *idata
cdef np.float64_t width[3]</pre>
<p>+ cdef int chunksize = 100</p>
<pre> for i in range(3):
width[i] = self.width[i]
with nogil, parallel(num_threads = num_threads):</pre>
<p>@@ -465,7 +468,7 @@</p>
<pre>idata.supp_data = self.supp_data
v_pos = <np.float64_t *> malloc(3 * sizeof(np.float64_t))
v_dir = <np.float64_t *> malloc(3 * sizeof(np.float64_t))</pre>
<ul><li><p>for j in prange(size, schedule="static", chunksize=100):</p></li></ul>
<p>+ for j in prange(size, schedule="static", chunksize=chunksize):</p>
<pre>vj = j % ny
vi = (j - vj) / ny + iter[0]
vj = vj + iter[2]</pre>
<p>@@ -476,6 +479,9 @@</p>
<pre>max_t = fclip(im.zbuffer[vi, vj], 0.0, 1.0)
walk_volume(vc, v_pos, v_dir, self.sampler,
(<void *> idata), NULL, max_t)</pre>
<p>+ if (j % (10*chunksize)) == 0: + with gil: + PyErr_CheckSignals()</p>
<pre> for i in range(Nch):
im.image[vi, vj, i] = idata.rgba[i]
free(idata)</pre>
<p>diff -r 81dc5b3d563331842988e4a09e42232e833ddb14 -r def617b415dec95ac24052fd0d378a3700fcd092 yt/utilities/lib/pixelization_routines.pyx --- a/yt/utilities/lib/pixelization_routines.pyx +++ b/yt/utilities/lib/pixelization_routines.pyx @@ -61,10 +61,12 @@</p>
<pre>int cols, int rows, bounds,
int antialias = 1,
period = None,</pre>
<ul><li><p>int check_period = 1):</p></li></ul>
<p>+ int check_period = 1, + np.float64_t line_width = 0.0):</p>
<pre>cdef np.float64_t x_min, x_max, y_min, y_max
cdef np.float64_t period_x = 0.0, period_y = 0.0
cdef np.float64_t width, height, px_dx, px_dy, ipx_dx, ipx_dy</pre>
<p>+ cdef np.float64_t ld_x, ld_y, cx, cy</p>
<pre>cdef int i, j, p, xi, yi
cdef int lc, lr, rc, rr
cdef np.float64_t lypx, rypx, lxpx, rxpx, overlap1, overlap2</pre>
<p>@@ -170,13 +172,29 @@</p>
<pre>for j in range(lc, rc):
lxpx = px_dx * j + x_min
rxpx = px_dx * (j+1) + x_min</pre>
<ul><li><p>if antialias == 1:</p></li></ul>
<p>+ if line_width > 0: + # Here, we figure out if we're within + # line_width*px_dx of the cell edge + # Midpoint of x: + cx = (rxpx+lxpx)*0.5 + ld_x = fmin(fabs(cx – (xsp+dxsp)), + fabs(cx – (xsp-dxsp))) + ld_x *= ipx_dx + # Midpoint of y: + cy = (rypx+lypx)*0.5 + ld_y = fmin(fabs(cy – (ysp+dysp)), + fabs(cy – (ysp-dysp))) + ld_y *= ipx_dy + if ld_x <= line_width or ld_y <= line_width: + my_array[j,i] = 1.0 + elif antialias == 1:</p>
<pre> overlap1 = ((fmin(rxpx, xsp+dxsp)
- fmax(lxpx, (xsp-dxsp)))*ipx_dx)
if overlap1 < 0.0: continue
my_array[j,i] += (dsp * overlap1) * overlap2
else:
my_array[j,i] = dsp</pre>
<p>+</p>
<pre> return my_array
@cython.cdivision(True)</pre>
<p>diff -r 81dc5b3d563331842988e4a09e42232e833ddb14 -r def617b415dec95ac24052fd0d378a3700fcd092 yt/visualization/plot_modifications.py --- a/yt/visualization/plot_modifications.py +++ b/yt/visualization/plot_modifications.py @@ -36,7 +36,8 @@</p>
<pre>from yt.visualization.image_writer import apply_colormap
from yt.utilities.lib.geometry_utils import triangle_plane_intersect
from yt.utilities.lib.pixelization_routines import \</pre>
<ul><li><p>pixelize_element_mesh, pixelize_off_axis_cartesian</p></li></ul>
<p>+ pixelize_element_mesh, pixelize_off_axis_cartesian, \ + pixelize_cartesian</p>
<pre>from yt.analysis_modules.cosmological_observation.light_ray.light_ray import \
periodic_ray
from yt.utilities.lib.line_integral_convolution import \</pre>
<p>@@ -2361,3 +2362,68 @@</p>
<pre> plot._axes.hold(False)
return plot</pre>
<p>+ +class CellEdgesCallback(PlotCallback): + """ + annotate_cell_edges(line_width=1.0, alpha = 1.0, color = (0.0, 0.0, 0.0)) + + Annotate cell edges. This is done through a second call to pixelize, where + the distance from a pixel to a cell boundary in pixels is compared against + the `line_width` argument. The secondary image is colored as `color` and + overlaid with the `alpha` value. + + Parameters + ---------- + line_width : float + Distance, in pixels, from a cell edge that will mark a pixel as being + annotated as a cell edge. Default is 1.0. + alpha : float + When the second image is overlaid, it will have this level of alpha + transparency. Default is 1.0 (fully-opaque). + color : tuple of three floats + This is the color of the cell edge values. It defaults to black. + + Examples + -------- + + >>> import yt + >>> ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030') + >>> s = yt.SlicePlot(ds, ‘z’, ‘density’) + >>> s.annotate_cell_edges() + >>> s.save() + """ + _type_name = “cell_edges” + def __init__(self, line_width=1.0, alpha = 1.0, color=(0.0, 0.0, 0.0)): + PlotCallback.__init__(self) + self.line_width = line_width + self.alpha = alpha + self.color = (np.array(color) * 255).astype("uint8") + + def __call__(self, plot): + x0, x1 = plot.xlim + y0, y1 = plot.ylim + xx0, xx1 = plot._axes.get_xlim() + yy0, yy1 = plot._axes.get_ylim() + plot._axes.hold(True) + nx = plot.image._A.shape[0] + ny = plot.image._A.shape[1] + im = pixelize_cartesian(plot.data['px'], + plot.data['py'], + plot.data['pdx'], + plot.data['pdy'], + plot.data['px'], # dummy field + int(nx), int(ny), + (x0, x1, y0, y1), + line_width=self.line_width).transpose() + # New image: + im_buffer = np.zeros((nx, ny, 4), dtype="uint8") + im_buffer[im>0,3] = 255 + im_buffer[im>0,:3] = self.color + plot._axes.imshow(im_buffer, origin='lower', + interpolation='nearest', + extent = [xx0, xx1, yy0, yy1], + alpha = self.alpha) + plot._axes.set_xlim(xx0,xx1) + plot._axes.set_ylim(yy0,yy1) + plot._axes.hold(False) +</p>
<p>diff -r 81dc5b3d563331842988e4a09e42232e833ddb14 -r def617b415dec95ac24052fd0d378a3700fcd092 yt/visualization/profile_plotter.py --- a/yt/visualization/profile_plotter.py +++ b/yt/visualization/profile_plotter.py @@ -462,7 +462,7 @@</p>
<pre> """
if field == "all":
self.x_log = log</pre>
<ul><li><p>for field in self.profiles[0].field_data.keys():</p></li></ul>
<p>+ for field in list(self.profiles[0].field_data.keys()):</p>
<pre> self.y_log[field] = log
else:
field, = self.profiles[0].data_source._determine_fields([field])</pre>
<p>@@ -578,7 +578,7 @@</p>
<pre>"""
if field is 'all':</pre>
<ul><li><p>fields = self.axes.keys()</p></li></ul>
<p>+ fields = list(self.axes.keys())</p>
<pre> else:
fields = ensure_list(field)
for profile in self.profiles:</pre>
<p>@@ -697,7 +697,7 @@</p>
<pre>>>> # Change plot properties.
>>> plot.set_cmap("cell_mass", "jet")
>>> plot.set_zlim("cell_mass", 1e8, 1e13)</pre>
<ul><li><blockquote><blockquote><blockquote><p>plot.set_title("cell_mass", “This is a phase plot”)</p></blockquote></blockquote></blockquote></li></ul>
<p>+ >>> plot.annotate_title("This is a phase plot")</p>
<pre>"""
x_log = None</pre>
<p>@@ -971,7 +971,7 @@</p>
<pre> >>> plot.annotate_text(1e-15, 5e4, "Hello YT")
"""</pre>
<ul><li><p>for f in self.data_source._determine_fields(self.plots.keys()):</p></li></ul>
<p>+ for f in self.data_source._determine_fields(list(self.plots.keys())):</p>
<pre>if self.plots[f].figure is not None and text is not None:
self.plots[f].axes.text(xpos, ypos, text,
fontproperties=self._font_properties,</pre>
<p>@@ -1061,6 +1061,27 @@</p>
<pre> return self
@invalidate_plot</pre>
<p>+ def annotate_title(self, title): + """Set a title for the plot. + + Parameters + ---------- + title : str + The title to add. + + Examples + -------- + + >>> plot.annotate_title("This is a phase plot") + + """ + for f in self.profile.field_data: + if isinstance(f, tuple): + f = f[1] + self.plot_title[self.data_source._determine_fields(f)[0]] = title + return self + + @invalidate_plot</p>
<pre>def reset_plot(self):
self.plots = {}
return self</pre>
<p>diff -r 81dc5b3d563331842988e4a09e42232e833ddb14 -r def617b415dec95ac24052fd0d378a3700fcd092 yt/visualization/tests/test_callbacks.py --- a/yt/visualization/tests/test_callbacks.py +++ b/yt/visualization/tests/test_callbacks.py @@ -341,6 +341,25 @@</p>
<pre> max_level=3, cmap="gist_stern")
p.save(prefix)
</pre>
<p>+def test_cell_edges_callback(): + with _cleanup_fname() as prefix: + ds = fake_amr_ds(fields = ("density",)) + for ax in ‘xyz’: + p = ProjectionPlot(ds, ax, “density”) + p.annotate_cell_edges() + yield assert_fname, p.save(prefix)[0] + p = ProjectionPlot(ds, ax, “density”, weight_field="density") + p.annotate_cell_edges() + yield assert_fname, p.save(prefix)[0] + p = SlicePlot(ds, ax, “density”) + p.annotate_cell_edges() + yield assert_fname, p.save(prefix)[0] + # Now we'll check a few additional minor things + p = SlicePlot(ds, “x”, “density”) + p.annotate_cell_edges(alpha=0.7, line_width=0.9, + color=(0.0, 1.0, 1.0)) + p.save(prefix) +</p>
<pre>def test_line_integral_convolution_callback():
with _cleanup_fname() as prefix:
ds = fake_amr_ds(fields =</pre>
<p>diff -r 81dc5b3d563331842988e4a09e42232e833ddb14 -r def617b415dec95ac24052fd0d378a3700fcd092 yt/visualization/volume_rendering/lens.py --- a/yt/visualization/volume_rendering/lens.py +++ b/yt/visualization/volume_rendering/lens.py @@ -277,8 +277,8 @@</p>
<pre> dz = np.dot(pos - position, camera.unit_vectors[2])
# Transpose into image coords.</pre>
<ul><li><p>px = (res[0] * 0.5 + res[0] / camera.width[0].d * dx).astype('int')</p></li>
<li><p>py = (res[1] * 0.5 + res[1] / camera.width[1].d * dy).astype('int')</p></li></ul>
<p>+ px = (res[0] * 0.5 + res[0] / width[0] * dx).astype('int64') + py = (res[1] * 0.5 + res[1] / width[1] * dy).astype('int64')</p>
<pre> return px, py, dz
</pre>
<p>diff -r 81dc5b3d563331842988e4a09e42232e833ddb14 -r def617b415dec95ac24052fd0d378a3700fcd092 yt/visualization/volume_rendering/tests/test_mesh_render.py --- a/yt/visualization/volume_rendering/tests/test_mesh_render.py +++ b/yt/visualization/volume_rendering/tests/test_mesh_render.py @@ -52,6 +52,7 @@</p>
<pre> def mesh_render_image_func(filename_prefix):
return im.write_image(filename_prefix)
</pre>
<p>+ mesh_render_image_func.__name__ = "func_{}".format(test_prefix)</p>
<pre>test = GenericImageTest(ds, mesh_render_image_func, decimals)
test.prefix = test_prefix
return test</pre>
<p><a href="https://bitbucket.org/yt_analysis/yt/commits/c55b7a1e36bf/">https://bitbucket.org/yt_analysis/yt/commits/c55b7a1e36bf/</a> Changeset: c55b7a1e36bf Branch: yt User: jzuhone Date: 2016-04-06 18:09:47+00:00 Summary: Merged in ngoldbaum/yt (pull request #2102)</p>
<p>logging: don't create a StreamHandler unless we will use it. Closes #1024 Affected #: 1 file</p>
<p>diff -r 068a53069cdff7da3ad9597a7bb868fcafabecb2 -r c55b7a1e36bf638dffa73074a047cc5c2e245bf7 yt/utilities/logger.py --- a/yt/utilities/logger.py +++ b/yt/utilities/logger.py @@ -54,36 +54,43 @@</p>
<pre>ytLogger = logging.getLogger("yt")
</pre>
<p>-yt_sh = logging.StreamHandler(stream=stream) -# create formatter and add it to the handlers -formatter = logging.Formatter(ufstring) -yt_sh.setFormatter(formatter) -# add the handler to the logger -ytLogger.addHandler(yt_sh) -ytLogger.setLevel(level) -ytLogger.propagate = False –</p>
<pre>def disable_stream_logging():</pre>
<ul><li><p>ytLogger.removeHandler(ytLogger.handlers[0])</p></li></ul>
<p>+ if len(ytLogger.handlers) > 0: + ytLogger.removeHandler(ytLogger.handlers[0])</p>
<pre> h = logging.NullHandler()
ytLogger.addHandler(h)
</pre>
<p>-original_emitter = yt_sh.emit –</p>
<pre>def colorize_logging():
f = logging.Formatter(cfstring)
ytLogger.handlers[0].setFormatter(f)
yt_sh.emit = add_coloring_to_emit_ansi(yt_sh.emit)
def uncolorize_logging():</pre>
<ul><li><p>f = logging.Formatter(ufstring)</p></li>
<li><p>ytLogger.handlers[0].setFormatter(f)</p></li>
<li><p>yt_sh.emit = original_emitter</p></li></ul>
<p>– -if ytcfg.getboolean("yt", "coloredlogs"):</p>
<ul><li><p>colorize_logging()</p></li></ul>
<p>+ try: + f = logging.Formatter(ufstring) + ytLogger.handlers[0].setFormatter(f) + yt_sh.emit = original_emitter + except NameError: + # yt_sh and original_emitter are not defined because + # suppressStreamLogging is True, so we continue since there is nothing + # to uncolorize + pass</p>
<pre>if ytcfg.getboolean("yt", "suppressStreamLogging"):
disable_stream_logging()</pre>
<p>+else: + yt_sh = logging.StreamHandler(stream=stream) + # create formatter and add it to the handlers + formatter = logging.Formatter(ufstring) + yt_sh.setFormatter(formatter) + # add the handler to the logger + ytLogger.addHandler(yt_sh) + ytLogger.setLevel(level) + ytLogger.propagate = False + + original_emitter = yt_sh.emit + + if ytcfg.getboolean("yt", "coloredlogs"): + colorize_logging()</p>
<pre>ytLogger.debug("Set log level to %s", level)</pre>
<p>Repository URL: <a href="https://bitbucket.org/yt_analysis/yt/">https://bitbucket.org/yt_analysis/yt/</a></p>
<p>—</p>
<p>This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.</p>
<img src="http://link.bitbucket.org/wf/open?upn=ll4ctv0L-2ByeRZFC1LslHcg6aJmnQ70VruLbmeLQr27AvBUiTCuAmroc7O4UGtoabtdj1NNWI-2FHY55Vb6OCNELBpoymoYwEkyvkFRDl5ZvJlbabAeIwqkmpb9bWJreHHxh9wj2y-2BzNgnax3vqyn39BGwet6qq7O3bYxziOzXoRyx-2FywcOB5CG1zKmE-2BG7IjhMqS4VJ6ZqcoA3Am24WTRS9Izo7wZfO6cB7HUnALzfyeo-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;"/>
</body></html>