Popular recipes tagged "meta:requires=glob"http://code.activestate.com/recipes/tags/meta:requires=glob/2016-12-06T20:37:30-08:00ActiveState Code RecipesConvert wildcard text files to PDF with xtopdf (e.g. report*.txt) (Python)
2016-12-06T20:37:30-08:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/580727-convert-wildcard-text-files-to-pdf-with-xtopdf-eg-/
<p style="color: grey">
Python
recipe 580727
by <a href="/recipes/users/4173351/">Vasudev Ram</a>
(<a href="/recipes/tags/conversion/">conversion</a>, <a href="/recipes/tags/files/">files</a>, <a href="/recipes/tags/globbing/">globbing</a>, <a href="/recipes/tags/patterns/">patterns</a>, <a href="/recipes/tags/pdf/">pdf</a>, <a href="/recipes/tags/pdfwriter/">pdfwriter</a>, <a href="/recipes/tags/pdf_generation/">pdf_generation</a>, <a href="/recipes/tags/text_processing/">text_processing</a>, <a href="/recipes/tags/wildcard/">wildcard</a>, <a href="/recipes/tags/xtopdf/">xtopdf</a>).
</p>
<p>This recipe shows how to convert all text files matching a filename wildcard to PDF, using the xtopdf PDF creation toolkit. For example, if you specify report<em>.txt as the wildcard, all files in the current directory that match report</em>.txt, will be converted to PDF, each in a separate PDF file. The original text files are not changed.</p>
<p>Here is a guide to installing and using xtopdf:</p>
<p><a href="http://jugad2.blogspot.in/2012/07/guide-to-installing-and-using-xtopdf.html" rel="nofollow">http://jugad2.blogspot.in/2012/07/guide-to-installing-and-using-xtopdf.html</a></p>
<p>More details on running the program, and sample output, are available here:</p>
<p><a href="http://jugad2.blogspot.in/2016/12/xtopdf-wildcard-text-files-to-pdf-with.html" rel="nofollow">http://jugad2.blogspot.in/2016/12/xtopdf-wildcard-text-files-to-pdf-with.html</a></p>
Lines Of Code (LOC) (Python)
2016-10-25T17:53:01-07:00Jean Brouwershttp://code.activestate.com/recipes/users/2984142/http://code.activestate.com/recipes/580709-lines-of-code-loc/
<p style="color: grey">
Python
recipe 580709
by <a href="/recipes/users/2984142/">Jean Brouwers</a>
(<a href="/recipes/tags/count/">count</a>, <a href="/recipes/tags/lines/">lines</a>, <a href="/recipes/tags/python2/">python2</a>, <a href="/recipes/tags/python3/">python3</a>, <a href="/recipes/tags/source/">source</a>).
Revision 3.
</p>
<p>Count the number of lines (code, comment, blank) in one or several Python source files.</p>
Simple directory list command with filename wildcard support (Python)
2016-12-02T20:52:56-08:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/580724-simple-directory-list-command-with-filename-wildca/
<p style="color: grey">
Python
recipe 580724
by <a href="/recipes/users/4173351/">Vasudev Ram</a>
(<a href="/recipes/tags/commandline/">commandline</a>, <a href="/recipes/tags/directory/">directory</a>, <a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/filesystem/">filesystem</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/utilities/">utilities</a>).
</p>
<p>This recipe shows a simple directory listing program. It can accept multiple command-line arguments specifying filenames. These filenames can include wildcard characters like * (asterisk) and ? (question mark), as is common in OS command shells like bash (Unix) and CMD (Windows). Tested on Windows but should work on Unix too, since it uses no OS-specific functions, or rather, it does use them, but that happens under the hood, within the libraries used.</p>
convert hierarchy of data files into a convenient Python dictionary (Python)
2016-06-29T20:09:44-07:00Brian Fiedlerhttp://code.activestate.com/recipes/users/4194196/http://code.activestate.com/recipes/580687-convert-hierarchy-of-data-files-into-a-convenient-/
<p style="color: grey">
Python
recipe 580687
by <a href="/recipes/users/4194196/">Brian Fiedler</a>
(<a href="/recipes/tags/pickle/">pickle</a>).
Revision 2.
</p>
<p>Converts the CRUTEM text data files into a convenient Python dictionary.
The data files are at:
<a href="http://www.metoffice.gov.uk/hadobs/crutem4/data/station_files/CRUTEM.4.4.0.0.station_files.zip" rel="nofollow">http://www.metoffice.gov.uk/hadobs/crutem4/data/station_files/CRUTEM.4.4.0.0.station_files.zip</a></p>
Persistent Queue (Python)
2015-11-12T06:45:12-08:00zhangkaizhaohttp://code.activestate.com/recipes/users/4189594/http://code.activestate.com/recipes/579124-persistent-queue/
<p style="color: grey">
Python
recipe 579124
by <a href="/recipes/users/4189594/">zhangkaizhao</a>
(<a href="/recipes/tags/sysadmin/">sysadmin</a>).
</p>
<p>A class for persistent queues.</p>
pack multiple images of different sizes into one image (Python)
2013-06-27T14:50:37-07:00Hugohttp://code.activestate.com/recipes/users/4183663/http://code.activestate.com/recipes/578585-pack-multiple-images-of-different-sizes-into-one-i/
<p style="color: grey">
Python
recipe 578585
by <a href="/recipes/users/4183663/">Hugo</a>
(<a href="/recipes/tags/graphics/">graphics</a>).
</p>
<p>Packing images of different sizes into one image is often required in order to efficiently use hardware accelerated texture mapping functions of 3D video cards.</p>
Use PIL to make a "contact sheet" montage of images (Python)
2012-09-21T11:06:58-07:00Hugohttp://code.activestate.com/recipes/users/4183663/http://code.activestate.com/recipes/578267-use-pil-to-make-a-contact-sheet-montage-of-images/
<p style="color: grey">
Python
recipe 578267
by <a href="/recipes/users/4183663/">Hugo</a>
(<a href="/recipes/tags/graphics/">graphics</a>).
Revision 2.
</p>
<p>The Python Imaging Library (PIL) makes many tasks easy in digital photography. This recipe shows how to make a "contact sheet" of images, a single image with thumbnails of many different pictures. It's limited in that it will only work with pictures of the same shape, but you can make some really fun images.</p>
Bash completed man and info pages generation (Python)
2011-08-24T03:14:13-07:00Josh Dhttp://code.activestate.com/recipes/users/4179060/http://code.activestate.com/recipes/577854-bash-completed-man-and-info-pages-generation/
<p style="color: grey">
Python
recipe 577854
by <a href="/recipes/users/4179060/">Josh D</a>
(<a href="/recipes/tags/a/">a</a>, <a href="/recipes/tags/all/">all</a>, <a href="/recipes/tags/and/">and</a>, <a href="/recipes/tags/bash/">bash</a>, <a href="/recipes/tags/be/">be</a>, <a href="/recipes/tags/command/">command</a>, <a href="/recipes/tags/completed/">completed</a>, <a href="/recipes/tags/consume/">consume</a>, <a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/first/">first</a>, <a href="/recipes/tags/generation/">generation</a>, <a href="/recipes/tags/get/">get</a>, <a href="/recipes/tags/in/">in</a>, <a href="/recipes/tags/info/">info</a>, <a href="/recipes/tags/line/">line</a>, <a href="/recipes/tags/man/">man</a>, <a href="/recipes/tags/modify/">modify</a>, <a href="/recipes/tags/must/">must</a>, <a href="/recipes/tags/only/">only</a>, <a href="/recipes/tags/pages/">pages</a>, <a href="/recipes/tags/possibilties/">possibilties</a>, <a href="/recipes/tags/possiblities/">possiblities</a>, <a href="/recipes/tags/py/">py</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/run/">run</a>, <a href="/recipes/tags/script/">script</a>, <a href="/recipes/tags/so/">so</a>, <a href="/recipes/tags/tab/">tab</a>, <a href="/recipes/tags/terminal/">terminal</a>, <a href="/recipes/tags/the/">the</a>, <a href="/recipes/tags/this/">this</a>, <a href="/recipes/tags/to/">to</a>).
Revision 6.
</p>
<p>The script it self is very self explaining - the task is simple.
*NIX only unless with cygwin perhaps?</p>
<p>To start this open a terminal and strike the "Tab" key to get all possibilities (strike y, and strike the space key alot). Select all then Copy and save in "comms.txt"
Modify the file so ONLY the possiblities consume a line; no prompts or extra newlines.
(first line must be a command, the last line must be a command)</p>
<p>Save the file ("~/Documents/bashing/comms.txt" is my path) then run this script in "~/Documents/bashing/".</p>
<p>This generates two (2) files: "bash_help_man.sh", "bash_help_info.sh".</p>
<p>Then it runs these files: "bash bash_help_man.sh", "bash bash_help_info.sh".</p>
<p>This produces 2 files for every command (every line) in "comms.txt".
All manpages are wrote in "mans/", all infopages are wrote in "infos/"</p>
<p>There is now alot of files to read and organize; lets separate these by size.
Directories are under1kb, under2kb, etc.</p>
<p>Once complete do as you wish the files less than 128 kb;
these files are COPIED into there new respective home, I repeat COPIED.</p>
<p>The files 128 kb and higher ARE NOT copied to anywhere!</p>
Rename non-ASCII filenames to readable ASCII, i.e. replace accented characters, etc (Python)
2011-11-03T17:50:55-07:00ccpizzahttp://code.activestate.com/recipes/users/4170754/http://code.activestate.com/recipes/577226-rename-non-ascii-filenames-to-readable-ascii-ie-re/
<p style="color: grey">
Python
recipe 577226
by <a href="/recipes/users/4170754/">ccpizza</a>
(<a href="/recipes/tags/conversion/">conversion</a>, <a href="/recipes/tags/renaming/">renaming</a>, <a href="/recipes/tags/unicode/">unicode</a>).
Revision 3.
</p>
<p>The script converts any accented characters in filenames to their ASCII equivalents. e.g.:</p>
<p>Example:</p>
<pre class="prettyprint"><code>â > a
ä > a
à > a
á > a
é > e
í > i
ó > o
ú > u
ñ > n
ü > u
...
</code></pre>
<p>Before-and-after example:</p>
<pre class="prettyprint"><code>01_Antonín_Dvořák_Allegro.mp3 >>> 01_Antonin_Dvorak_Allegro.mp3
</code></pre>
<p>Usage:</p>
<pre class="prettyprint"><code>Running the script without arguments will rename all files in the current folder.
!!!WARNING!!! ***No*** backups are created.
</code></pre>
Find the oldest (or yougest) of a list of files (Python)
2009-06-10T16:08:13-07:00Micah Elliotthttp://code.activestate.com/recipes/users/2649403/http://code.activestate.com/recipes/576804-find-the-oldest-or-yougest-of-a-list-of-files/
<p style="color: grey">
Python
recipe 576804
by <a href="/recipes/users/2649403/">Micah Elliott</a>
(<a href="/recipes/tags/age/">age</a>, <a href="/recipes/tags/files/">files</a>, <a href="/recipes/tags/find/">find</a>, <a href="/recipes/tags/queue/">queue</a>).
</p>
<p>Sometimes you need to perform an operation on the oldest of a set of files. Using <em>get_oldest_file</em> you could implement an age-based priority queue that processes files from oldest to newest. The list of files you pass in may be from a <em>glob</em> of a single directory or some more elaborate search routine.</p>
SPOJ backup script (Python)
2010-02-09T08:50:44-08:00Shashwat Anandhttp://code.activestate.com/recipes/users/4172995/http://code.activestate.com/recipes/577036-spoj-backup-script/
<p style="color: grey">
Python
recipe 577036
by <a href="/recipes/users/4172995/">Shashwat Anand</a>
(<a href="/recipes/tags/algorithm/">algorithm</a>, <a href="/recipes/tags/algorithms/">algorithms</a>, <a href="/recipes/tags/spoj/">spoj</a>, <a href="/recipes/tags/tools/">tools</a>).
Revision 3.
</p>
<h4>Introduction</h4>
<p>At Sphere Online Judge (<a href="http://www.spoj.pl" rel="nofollow">http://www.spoj.pl</a>) you are given the capability of trying out the
challenging problems given. It also gives you the capability of viewing
and downloading your own solution.</p>
<p>The tool spojbackup tends to automatically backup all your Accepted
submissions and save them on the desired location of your computer. The
basic idea is to automate the process which can be used as a backup and
an offline reference tool of your own codes.</p>
<h4>Features</h4>
<ul>
<li><p>Resume downloads.
spojbackup currently supports resuming of the solutions if internet
connection is disrupted</p></li>
<li><p>Incremental backup facility
it'll not download the code already present on your machine. Only newer
code added in your signedlist will be downloaded</p></li>
<li><p>User-defined destination
all codes are saved at user-defined destination
if no option is given by user it saves in the folder from where command is
run</p></li>
<li><p>Proxy support
Proxy support is provided as SPOJ users are generally university students
and they are generally behind a proxy and university firewall.</p></li>
</ul>
<h4>Bugs</h4>
<p>In case of finding a bug please drop a mail to the authors. We will try to sort
out the problems.</p>
A Moderately Simple Buttonbar Program (Python)
2010-02-10T02:08:37-08:00Phil Risthttp://code.activestate.com/recipes/users/4171119/http://code.activestate.com/recipes/577039-a-moderately-simple-buttonbar-program/
<p style="color: grey">
Python
recipe 577039
by <a href="/recipes/users/4171119/">Phil Rist</a>
(<a href="/recipes/tags/command_execution/">command_execution</a>, <a href="/recipes/tags/user_interface/">user_interface</a>).
</p>
<p>This buttonbar program is similar to my ButtonBarV1 <a href="http://code.activestate.com/recipes/577038/">recipe 577038</a> except a file pattern such as c:\source\python\new*.py can be entered instead of a single file. This will allow you to scroll through a list of matching files selecting the files you want to process. You must still select the command separately for each file. Besides the file pattern or file a menu file and an optional list of section names are specified on the command line.</p>
TwitterCmd - Interactive console for twittering (Python)
2009-10-08T02:15:19-07:00Anandhttp://code.activestate.com/recipes/users/760763/http://code.activestate.com/recipes/576923-twittercmd-interactive-console-for-twittering/
<p style="color: grey">
Python
recipe 576923
by <a href="/recipes/users/760763/">Anand</a>
(<a href="/recipes/tags/command/">command</a>, <a href="/recipes/tags/microblogging/">microblogging</a>, <a href="/recipes/tags/shortcuts/">shortcuts</a>, <a href="/recipes/tags/twitter/">twitter</a>).
Revision 4.
</p>
<p>TwitterCmd is an interactive console for twitter built on top of python-twitter library. It provides short, easy to remember commands for most twitter actions and provides a one-way interaction with the Python interpreter, exposing its objects to further inspection by the python-twitter API.</p>
CMS page range validator. (Python)
2009-08-21T11:14:13-07:00Joseph Reaglehttp://code.activestate.com/recipes/users/4171494/http://code.activestate.com/recipes/576889-cms-page-range-validator/
<p style="color: grey">
Python
recipe 576889
by <a href="/recipes/users/4171494/">Joseph Reagle</a>
(<a href="/recipes/tags/formatting/">formatting</a>, <a href="/recipes/tags/page_ranges/">page_ranges</a>, <a href="/recipes/tags/writing/">writing</a>).
</p>
<p>Specification and validator for Chicago Manual of Style page ranges.</p>
Redate pictures with EXIF (Python)
2009-06-29T03:06:01-07:00Ivan Koblikhttp://code.activestate.com/recipes/users/4168407/http://code.activestate.com/recipes/576822-redate-pictures-with-exif/
<p style="color: grey">
Python
recipe 576822
by <a href="/recipes/users/4168407/">Ivan Koblik</a>
(<a href="/recipes/tags/creation_date/">creation_date</a>, <a href="/recipes/tags/date/">date</a>, <a href="/recipes/tags/exif/">exif</a>, <a href="/recipes/tags/modification_date/">modification_date</a>, <a href="/recipes/tags/picture/">picture</a>, <a href="/recipes/tags/video/">video</a>).
Revision 2.
</p>
<p>Reads creation date from EXIF picture/video file header, and sets it to the file's creation and modification dates. This script differs from other recipes in its ability to work with the creation date in Windows.
The script depends on several libraries: Win32 Extensions, pyexif, exif. <a href="http://koblik.blogspot.com/2009/06/exif-with-python.html">Here's</a> description of what they do and where to get them.</p>
Interleaving file lines using iterators (Python)
2009-02-23T04:07:37-08:00David Mosshttp://code.activestate.com/recipes/users/4124829/http://code.activestate.com/recipes/576665-interleaving-file-lines-using-iterators/
<p style="color: grey">
Python
recipe 576665
by <a href="/recipes/users/4124829/">David Moss</a>
(<a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/generators/">generators</a>, <a href="/recipes/tags/iterators/">iterators</a>, <a href="/recipes/tags/manipulation/">manipulation</a>).
</p>
<p>Accepts one of more files and/or globs and interleaves the lines from each writing the result to stdout.</p>
Illustration: Writing a TappedIn.com calendar item from FeedDemon to Google Calendar (Python)
2009-01-03T17:13:46-08:00Bill Bellhttp://code.activestate.com/recipes/users/4168674/http://code.activestate.com/recipes/576604-illustration-writing-a-tappedincom-calendar-item-f/
<p style="color: grey">
Python
recipe 576604
by <a href="/recipes/users/4168674/">Bill Bell</a>
(<a href="/recipes/tags/blog_publisher/">blog_publisher</a>, <a href="/recipes/tags/feeddemon/">feeddemon</a>, <a href="/recipes/tags/google_calendar/">google_calendar</a>, <a href="/recipes/tags/tappedin/">tappedin</a>).
</p>
<p>This recipe is for reference purposes. It indicates how the FeedDemon RSS reader supplies information about a post to a blog publisher application under the default arrangements (ie, without specifying XML), and then how this information can be reformatted for a <a href="http://TappedIn.com" rel="nofollow">TappedIn.com</a> calendar item for submission to the Google Calendar. Nothing unusual but might be useful to people who use FeedDemon and want to record TappedIn sessions on Google (obviously).</p>
Changing shortcut on a usb key V2 (Python)
2008-08-22T13:34:57-07:00bussiere bussierehttp://code.activestate.com/recipes/users/4050557/http://code.activestate.com/recipes/576437-changing-shortcut-on-a-usb-key-v2/
<p style="color: grey">
Python
recipe 576437
by <a href="/recipes/users/4050557/">bussiere bussiere</a>
(<a href="/recipes/tags/key/">key</a>, <a href="/recipes/tags/raccourcis/">raccourcis</a>, <a href="/recipes/tags/shortcut/">shortcut</a>, <a href="/recipes/tags/usb/">usb</a>, <a href="/recipes/tags/windows/">windows</a>).
Revision 2.
</p>
<p>i've made some shortcut on my usb key for launchy and i had always to change them if on one pc the usb drive was i: on an other it was k: it was such a pain each time.
Now it change all the shortcut automatically.</p>
TimedCompressedRotatingFileHandler (Python)
2007-02-28T08:16:44-08:00Angel Freirehttp://code.activestate.com/recipes/users/4037917/http://code.activestate.com/recipes/502265-timedcompressedrotatingfilehandler/
<p style="color: grey">
Python
recipe 502265
by <a href="/recipes/users/4037917/">Angel Freire</a>
(<a href="/recipes/tags/debugging/">debugging</a>).
</p>
<p>Python has really nice logging framework, it has too a zipfile library in the default installation that makes you able to write compressed files.</p>
<p>Several of the logging handlers "rotate" files, by size, date, etc. Here is an example of handler class for the logging framework that, when the file is rotated, it will make a .zip of the old file.</p>
Persistent Queue (Python)
2007-06-27T11:43:13-07:00Kjetil Jacobsenhttp://code.activestate.com/recipes/users/2518557/http://code.activestate.com/recipes/501154-persistent-queue/
<p style="color: grey">
Python
recipe 501154
by <a href="/recipes/users/2518557/">Kjetil Jacobsen</a>
(<a href="/recipes/tags/sysadmin/">sysadmin</a>).
Revision 2.
</p>
<p>A class for persistent queues.</p>