Popular recipes tagged "line" but not "generation"http://code.activestate.com/recipes/tags/line-generation/2014-06-30T20:30:57-07:00ActiveState Code RecipesNon-blocking readlines() (Python)
2014-06-30T20:30:57-07:00Zack Weinberghttp://code.activestate.com/recipes/users/4190298/http://code.activestate.com/recipes/578900-non-blocking-readlines/
<p style="color: grey">
Python
recipe 578900
by <a href="/recipes/users/4190298/">Zack Weinberg</a>
(<a href="/recipes/tags/concurrency/">concurrency</a>, <a href="/recipes/tags/input/">input</a>, <a href="/recipes/tags/line/">line</a>, <a href="/recipes/tags/nonblocking/">nonblocking</a>).
</p>
<p>A generator function which takes a file object (assumed to be some sort of pipe or socket, open for reading), and yields lines from it without blocking. If there is no input available, it will yield an endless stream of empty strings until input becomes available again; caller is responsible for not going into a busy loop. (Newlines are normalized but not stripped, so if there is actually a blank line in the input, the value yielded will be <code>'\n'</code>.) The intended use case is a thread which must respond promptly to input from a pipe, and also something else which cannot be fed to <code>select</code> (e.g. a <code>queue.Queue</code>). Note that the file object is ignored except for its <code>fileno</code>.</p>
<p>Only tested on Unix. Only tested on 3.4; ought to work with any python that has <code>bytearray</code>, <code>locale.getpreferredencoding</code>, and <code>fcntl</code>.</p>
Find a line of text in another file (Python)
2012-06-15T15:45:18-07:00sami janhttp://code.activestate.com/recipes/users/4064232/http://code.activestate.com/recipes/578164-find-a-line-of-text-in-another-file/
<p style="color: grey">
Python
recipe 578164
by <a href="/recipes/users/4064232/">sami jan</a>
(<a href="/recipes/tags/line/">line</a>, <a href="/recipes/tags/search/">search</a>).
Revision 2.
</p>
<p>This is a simple recipe - it reads a line in file, removes the line-ending and attempts to search throughout another file for the same line, anywhere in the file</p>
<p>In case a line is missing, the line number is printed to stdout</p>
Calculation of total number of lines (Bash)
2011-05-23T10:55:45-07:00Shao-chuan Wanghttp://code.activestate.com/recipes/users/4168519/http://code.activestate.com/recipes/577717-calculation-of-total-number-of-lines/
<p style="color: grey">
Bash
recipe 577717
by <a href="/recipes/users/4168519/">Shao-chuan Wang</a>
(<a href="/recipes/tags/line/">line</a>).
</p>
<p>This bash script enables you to calculate the total number of lines of source code.</p>
<p>Example usage:
1. calculate total number of lines of java source files.
$ line.sh java</p>
<ol>
<li>calculate total number of lines of python source files.
$ line.sh py</li>
</ol>
Simple Regular Expression Tester (Python)
2010-12-25T00:12:44-08:00Sunjay Varmahttp://code.activestate.com/recipes/users/4174115/http://code.activestate.com/recipes/577517-simple-regular-expression-tester/
<p style="color: grey">
Python
recipe 577517
by <a href="/recipes/users/4174115/">Sunjay Varma</a>
(<a href="/recipes/tags/command/">command</a>, <a href="/recipes/tags/debugging/">debugging</a>, <a href="/recipes/tags/line/">line</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/quick/">quick</a>, <a href="/recipes/tags/re/">re</a>, <a href="/recipes/tags/regex/">regex</a>, <a href="/recipes/tags/testing/">testing</a>).
Revision 2.
</p>
<p><strong><em>Is it possible to create a simple command line program that I can use to quickly test my regular expressions?</em></strong></p>
<p>Yes it is. This simple regular expression tester uses Python's re module as well as others to quickly allow you to test your regular expression in one go.</p>
<p>TODO:</p>
<ul>
<li>Add Support For Multiple Regular Expression Input</li>
</ul>
<p>Recent Changes:</p>
<ul>
<li>Made the output prettier with a little more whitespace. More bytes, but at least it's easier to read!</li>
</ul>
Send Email (Python)
2012-08-26T11:23:54-07:00sfwgeekhttp://code.activestate.com/recipes/users/4170734/http://code.activestate.com/recipes/576807-send-email/
<p style="color: grey">
Python
recipe 576807
by <a href="/recipes/users/4170734/">sfwgeek</a>
(<a href="/recipes/tags/argparse/">argparse</a>, <a href="/recipes/tags/cli/">cli</a>, <a href="/recipes/tags/command/">command</a>, <a href="/recipes/tags/email/">email</a>, <a href="/recipes/tags/interface/">interface</a>, <a href="/recipes/tags/line/">line</a>, <a href="/recipes/tags/mail/">mail</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/send/">send</a>, <a href="/recipes/tags/smtplib/">smtplib</a>).
Revision 5.
</p>
<p>A Command Line Interface (CLI) program to send email.</p>