mgedmin / objgraph

Visually explore Python object graphs
http://mg.pov.lt/objgraph/
MIT License
753 stars 72 forks source link

Make show_graph accept a file-like object #9

Closed pcostell closed 9 years ago

pcostell commented 9 years ago

This adds an output parameter to show_graph which accepts any file-like object (in this case something that supports write()). If output is specified, show_graph will write to this object instead of creating its own file.

If output is specified then it is illegal to specify filename.

coveralls commented 9 years ago

Coverage Status

Coverage decreased (-2.01%) to 95.31% when pulling 1ff09817969b464b0c29483d86449df2f1cc386f on pcostell:file-output into 95017a8c37dc1e6f3f70a27fd675eefb650add6b on mgedmin:master.

coveralls commented 9 years ago

Coverage Status

Coverage decreased (-0.25%) to 97.07% when pulling b974268a49cd2264b4321e10867169ee379838c3 on pcostell:file-output into 95017a8c37dc1e6f3f70a27fd675eefb650add6b on mgedmin:master.

coveralls commented 9 years ago

Coverage Status

Coverage decreased (-0.25%) to 97.07% when pulling b974268a49cd2264b4321e10867169ee379838c3 on pcostell:file-output into 95017a8c37dc1e6f3f70a27fd675eefb650add6b on mgedmin:master.

mgedmin commented 9 years ago

Thank you, this is a useful feature to have. I'll try not to take too long to review it; please ping me if I get distracted.

I've a vague feeling of deja vu about a similar patch/bug where there was talk of making filename accept a file-like object (e.g. a StringIO), but I can't find it! Was it merely a comment on an unrelated bug?

pcostell commented 9 years ago

Ya I saw another pull request with something similar but it looks like it didn't get pulled through because it had some outstanding issues that were never addressed.

mgedmin commented 9 years ago

Oh, right, that was #8.

coveralls commented 9 years ago

Coverage Status

Coverage increased (+0.05%) to 97.36% when pulling ed6aaa103c7c914299b52285d4abfba8567345e4 on pcostell:file-output into 95017a8c37dc1e6f3f70a27fd675eefb650add6b on mgedmin:master.

coveralls commented 9 years ago

Coverage Status

Coverage increased (+0.05%) to 97.36% when pulling ed6aaa103c7c914299b52285d4abfba8567345e4 on pcostell:file-output into 95017a8c37dc1e6f3f70a27fd675eefb650add6b on mgedmin:master.

mgedmin commented 9 years ago

Looks good to me. I think I'll merge and fix the two remaining nitpicks myself.

pcostell commented 9 years ago

Awesome. Please do nitpick!

mgedmin commented 9 years ago

On Python 3 I see extra warnings:

tests.py:51: DeprecationWarning: Please use assertRegex instead.
  self.assertRegexpMatches(output_value, r'digraph ObjectGraph')

any ideas about getting rid of them?

Would a global search & replace of assertRegexpMatches to assertRegex suffice?

pcostell commented 9 years ago

Ya that would probably work -- we can name the one in the Py25 compatibility mix-in to assertRegex.

mgedmin commented 9 years ago

Python 3.1 is a special case that makes things interesting, but I think I got it (commit 807a940).