Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67a
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Libraries

    iterpipes 0.4

    Download button

    No screenshots available
    Downloads: 298  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Andrey Vlasovskikh | More programs
    MIT/X Consortium Lic... / FREE
    March 11th, 2010, 13:11 GMT [view history]
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    iterpipes description

    A library for running shell pipelines using shell-like syntax

    iterpipes is a Python library that may be changed significantly. Comments are welcome.

    Facts:

     * Enables piping infinite streams through shell pipelines in Python
     * Represents a shell command as an ordinary function Iterable -> Iterable
     * Allows mixing shell commands and Python functions in a single pipeline
     * Uses standard interprocessing modules subprocess, threading
     * Allows doing things marked as red warning boxes at the subprocess help page
     * 0.2 KLOC, tests included

    Basic Usage

    Get the iterable of files in /path/to/dir:

    >>> from iterpipes import linecmd, run, strip
    >>> files = run(linecmd('ls {}', '/path/to/dir') | strip('
    '))
    >>> list(files)[:3]
    [u'bin', u'boot', u'dev']


    Pipe 100 000 lines through wc -l, join the resulting iterable into a single string and convert it to an int:

    >>> from iterpipes import cmd, join
    >>> wc = cmd('wc -l') | strip() | join | int
    >>> numbers = ('%d
    ' % i for i in xrange(100000))
    >>> wc(numbers) # or run(wc, numbers)
    100000


    Delete /path/to/dir and all the files under it, get the return code or check for exceptions:

    >>> from iterpipes import call, check_call
    >>> call(cmd('rm -fr {}', '/path/to/dir'))
    0
    >>> check_call(cmd('rm -fr {}', '/path/to/dir'))


    Total lines in *.py files under /path/to/dir, use safe shell parameters formatting:

    >>> total = cmd(
    ... 'find {} -name {} -print0 | xargs -0 wc -l | tail -1 | awk {}',
    ... '/path/to/dir', '*.py', '{print $1}')
    >>> run(total | strip() | join | int)
    315


    Load an Atom feed of the iterpipes source code repository using curl:

    >>> from iterpipes import bincmd
    >>> from xml.etree import ElementTree as etree
    >>> e = run(bincmd('curl -s {}', url) | join | etree.fromstring)
    >>> e.tag
    '{http://www.w3.org/2005/Atom}feed'



    Product's homepage

    Requirements:

    · Python

    What's New in This Release: [ read full changelog ]

    · Enables piping infinite streams through shell pipelines in Python
    · Represents a shell command as an ordinary function from stdin iterable to stdout iterable
    · Uses standard interprocessing modules subprocess, threading Allows
    · doing things marked as red warning boxes at the subprocess help page
    · 0.2 KLOC, or 0.6 KLOC with documentation and tests

      


    TAGS:

    shell pipelines | shell-like syntax | Python library | shell | pipelines | library

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM