Top-rated recipes tagged "meta:requires=io"http://code.activestate.com/recipes/tags/meta:requires=io/top/2013-09-23T06:44:23-07:00ActiveState Code RecipesInMemoryZip class (Python)
2013-09-23T06:44:23-07:00Thomas Lehmannhttp://code.activestate.com/recipes/users/4174477/http://code.activestate.com/recipes/578667-inmemoryzip-class/
<p style="color: grey">
Python
recipe 578667
by <a href="/recipes/users/4174477/">Thomas Lehmann</a>
(<a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/memory/">memory</a>, <a href="/recipes/tags/path/">path</a>, <a href="/recipes/tags/zip/">zip</a>).
</p>
<p><strong>Why implementing this?</strong></p>
<ul>
<li>transfering a file or a folder (including sub folders) to another machine</li>
<li>therefore zipping content to one compressed buffer</li>
<li>keeping the relating ZIP in memory only but ...</li>
<li>being able to save or load too</li>
<li>and being able to unzip again at target destination</li>
</ul>
Funny text generator (Python)
2011-12-25T11:14:39-08:00Pierre Quentelhttp://code.activestate.com/recipes/users/1552957/http://code.activestate.com/recipes/577988-funny-text-generator/
<p style="color: grey">
Python
recipe 577988
by <a href="/recipes/users/1552957/">Pierre Quentel</a>
(<a href="/recipes/tags/generation/">generation</a>, <a href="/recipes/tags/random/">random</a>, <a href="/recipes/tags/text/">text</a>).
Revision 4.
</p>
<p>This class takes a text (preferably long enough) and generates another text that "looks like" the original. It won't mean anything, or just by chance ;-)</p>
<p>For example, taking Hamlet, Act I, the program generates things like :</p>
<p>Hamlet</p>
<blockquote>
<p>And vanish'd from our watch; <br />
His further. Fare third nights of the flushing immortal as it draw you into the flushing thy complete steel <br />
'Tis sweet and each new-hatch'd: <br />
A country's father; <br />
To business and is prodigal thee! <br />
Have of crowing more the should I have heaven, <br />
Forward, therefore as ourself in the business it, Horatio <br />
To what is't that your watch, bid this here! </p>
</blockquote>
<p>Usage :</p>
<pre class="prettyprint"><code>generator = TextGenerator(txt)
result = generator.random_text(3000)
</code></pre>
(Yet another) Assignment in expression Recipe (Python)
2011-12-17T20:03:26-08:00harish anandhttp://code.activestate.com/recipes/users/4180291/http://code.activestate.com/recipes/577987-yet-another-assignment-in-expression-recipe/
<p style="color: grey">
Python
recipe 577987
by <a href="/recipes/users/4180291/">harish anand</a>
(<a href="/recipes/tags/expression/">expression</a>, <a href="/recipes/tags/shortcuts/">shortcuts</a>).
Revision 3.
</p>
<p>Python does not support assignment in if and while statements such as "if (x=func()):". This is an attempt to bring similar functionality to python by injecting bytecode to all functions and methods in a module.
This recipe is inspired from recipes <a href="http://code.activestate.com/recipes/66061">66061</a>, <a href="http://code.activestate.com/recipes/202234-assignment-in-expression">202234</a> and <a href="http://code.activestate.com/recipes/277940-decorator-for-bindingconstants-at-compile-time">277940</a>.</p>
Shell-like data processing, using Popen, pipes, and Thread (Python)
2009-05-15T03:30:43-07:00Massimo Santinihttp://code.activestate.com/recipes/users/4170290/http://code.activestate.com/recipes/576757-shell-like-data-processing-using-popen-pipes-and-t/
<p style="color: grey">
Python
recipe 576757
by <a href="/recipes/users/4170290/">Massimo Santini</a>
.
</p>
<p>This module is inspired by <a href="http://code.activestate.com/recipes/276960/">recipe 276960</a> and shows how external processes (istantiated with Popen) can be combined with a pipe-like syntax. Some support is added for having in the pipe also local functions (by caching their results in a ByteIO, or using operating system pipes). A similar approach, using generators, is presented in <a href="http://code.activestate.com/recipes/576756/">recipe 576756</a>.</p>
Interpret Unicode escape escape sequences written to stdout and stderr (Python)
2008-04-16T14:47:48-07:00Nick Coghlanhttp://code.activestate.com/recipes/users/2035254/http://code.activestate.com/recipes/570089-interpret-unicode-escape-escape-sequences-written-/
<p style="color: grey">
Python
recipe 570089
by <a href="/recipes/users/2035254/">Nick Coghlan</a>
(<a href="/recipes/tags/text/">text</a>).
Revision 3.
</p>
<p>Python 2.6 and 3.0 make it practical to implicitly convert hexadecimal Unicode escape sequences sent to stdout or stderr (or other text files) back to the original Unicode characters.</p>
File Share Messenger 2.5 (Python)
2011-04-06T02:45:15-07:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/577638-file-share-messenger-25/
<p style="color: grey">
Python
recipe 577638
by <a href="/recipes/users/2608421/">Stephen Chappell</a>
(<a href="/recipes/tags/file_io/">file_io</a>, <a href="/recipes/tags/file_share/">file_share</a>, <a href="/recipes/tags/gui/">gui</a>, <a href="/recipes/tags/messenger/">messenger</a>, <a href="/recipes/tags/network/">network</a>, <a href="/recipes/tags/workaround/">workaround</a>).
</p>
<p>After writing the limited program shown in <a href="http://code.activestate.com/recipes/577637/">recipe 577637</a>, the following program was written with a better yet incompatible I/O system designed not to fill up a file share with many, separate files. This program had five revisions as outlined within the source code. To access settings within this program, use the "F2" key. Documentation may be accessed via the "F1" key (with future plans cut).</p>
<p>If anyone wishes to comment or vote this recipe down, please provide your insight into the fault(s) of the program and provide a suggestion as to what solution you would implement to fix the problems.</p>
ElementTree Wrapper (Python)
2008-09-05T13:20:42-07:00David Pokornyhttp://code.activestate.com/recipes/users/4166601/http://code.activestate.com/recipes/576445-elementtree-wrapper/
<p style="color: grey">
Python
recipe 576445
by <a href="/recipes/users/4166601/">David Pokorny</a>
(<a href="/recipes/tags/web/">web</a>, <a href="/recipes/tags/xml/">xml</a>).
Revision 12.
</p>
<p>This class wraps cElementTree.Element to make creating and serializing xml elements easier.</p>