Latest recipes tagged "pyc"http://code.activestate.com/recipes/tags/pyc/new/2011-09-29T20:07:10-07:00ActiveState Code RecipesInspect a PYC File (Python)
2011-09-29T20:07:10-07:00Eric Snowhttp://code.activestate.com/recipes/users/4177816/http://code.activestate.com/recipes/577880-inspect-a-pyc-file/
<p style="color: grey">
Python
recipe 577880
by <a href="/recipes/users/4177816/">Eric Snow</a>
(<a href="/recipes/tags/bytecode/">bytecode</a>, <a href="/recipes/tags/inspection/">inspection</a>, <a href="/recipes/tags/pyc/">pyc</a>).
Revision 3.
</p>
<p>This is a revamp of a recipe that Ned Batchelder <a href="http://nedbatchelder.com/blog/200804/the_structure_of_pyc_files.html">posted on his blog</a> a few years ago (thanks Ned!). That page is pretty insightful, recipe aside.</p>
<p>This recipe works for all versions of Python back to 2.4 (at least). Warning: using one version of Python to inspect a pyc file from another Python version may not work too well.</p>
Recursive file/folder cleaner (Python)
2011-02-12T20:30:59-08:00Alia Khourihttp://code.activestate.com/recipes/users/4169084/http://code.activestate.com/recipes/576643-recursive-filefolder-cleaner/
<p style="color: grey">
Python
recipe 576643
by <a href="/recipes/users/4169084/">Alia Khouri</a>
(<a href="/recipes/tags/cleaner/">cleaner</a>, <a href="/recipes/tags/cleaning/">cleaning</a>, <a href="/recipes/tags/files/">files</a>, <a href="/recipes/tags/folder/">folder</a>, <a href="/recipes/tags/pyc/">pyc</a>, <a href="/recipes/tags/recursion/">recursion</a>, <a href="/recipes/tags/svn/">svn</a>).
Revision 24.
</p>
<p>This script recursively scans a given path and applies a cleaning 'action'
to matching files and folders. By default files and folders matching the
specified (.endswith) patterns are deleted. Alternatively, _quoted_ glob
patterns can used with the '-g' or '--glob' option.</p>
<p>By design, the script lists targets and asks permission before applying
cleaning actions. It should be easy to extend this script with further
actions and also more intelligent pattern matching functions.</p>
<p>The getch (single key confirmation) functionality comes courtesy of
<a href="http://code.activestate.com/recipes/134892/" rel="nofollow">http://code.activestate.com/recipes/134892/</a></p>
<p>To use it, place the script in your path and call it something like 'clean':</p>
<pre class="prettyprint"><code>Usage: clean [options] patterns
deletes files/folder patterns:
clean .svn .pyc
clean -p /tmp/folder .svn .csv .bzr .pyc
clean -g "*.pyc"
clean -ng "*.py"
converts line endings from windows to unix:
clean -e .py
clean -e -p /tmp/folder .py
Options:
-h, --help show this help message and exit
-p PATH, --path=PATH set path
-n, --negated clean everything except specified patterns
-e, --endings clean line endings
-g, --glob clean with glob patterns
-v, --verbose
</code></pre>