##// END OF EJS Templates
Use "::" to get proper literal blocks in the docstrings....
walter.doerwald -
Show More
@@ -6,7 +6,7 b''
6 objects imported this way starts with ``i`` to minimize collisions.
6 objects imported this way starts with ``i`` to minimize collisions.
7
7
8 ``ipipe`` supports "pipeline expressions", which is something resembling Unix
8 ``ipipe`` supports "pipeline expressions", which is something resembling Unix
9 pipes. An example is:
9 pipes. An example is::
10
10
11 >>> ienv | isort("key.lower()")
11 >>> ienv | isort("key.lower()")
12
12
@@ -45,8 +45,9 b' three extensions points (all of them optional):'
45
45
46 * Objects that can be iterated by ``Pipe``s must iterable. For special cases,
46 * Objects that can be iterated by ``Pipe``s must iterable. For special cases,
47 where iteration for display is different than the normal iteration a special
47 where iteration for display is different than the normal iteration a special
48 implementation can be registered with the generic function ``xiter``. This makes
48 implementation can be registered with the generic function ``xiter``. This
49 it possible to use dictionaries and modules in pipeline expressions, for example:
49 makes it possible to use dictionaries and modules in pipeline expressions,
50 for example::
50
51
51 >>> import sys
52 >>> import sys
52 >>> sys | ifilter("isinstance(value, int)") | idump
53 >>> sys | ifilter("isinstance(value, int)") | idump
@@ -61,16 +62,16 b' three extensions points (all of them optional):'
61
62
62 Note: The expression strings passed to ``ifilter()`` and ``isort()`` can
63 Note: The expression strings passed to ``ifilter()`` and ``isort()`` can
63 refer to the object to be filtered or sorted via the variable ``_`` and to any
64 refer to the object to be filtered or sorted via the variable ``_`` and to any
64 of the attributes of the object, i.e.:
65 of the attributes of the object, i.e.::
65
66
66 >>> sys.modules | ifilter("_.value is not None") | isort("_.key.lower()")
67 >>> sys.modules | ifilter("_.value is not None") | isort("_.key.lower()")
67
68
68 does the same as
69 does the same as::
69
70
70 >>> sys.modules | ifilter("value is not None") | isort("key.lower()")
71 >>> sys.modules | ifilter("value is not None") | isort("key.lower()")
71
72
72 In addition to expression strings, it's possible to pass callables (taking
73 In addition to expression strings, it's possible to pass callables (taking
73 the object as an argument) to ``ifilter()``, ``isort()`` and ``ieval()``:
74 the object as an argument) to ``ifilter()``, ``isort()`` and ``ieval()``::
74
75
75 >>> sys | ifilter(lambda _:isinstance(_.value, int)) \
76 >>> sys | ifilter(lambda _:isinstance(_.value, int)) \
76 ... | ieval(lambda _: (_.key, hex(_.value))) | idump
77 ... | ieval(lambda _: (_.key, hex(_.value))) | idump
@@ -639,14 +640,18 b' def xrepr(item, mode="default"):'
639 There are four different possible values for ``mode`` depending on where
640 There are four different possible values for ``mode`` depending on where
640 the ``Display`` object will display ``item``:
641 the ``Display`` object will display ``item``:
641
642
642 * ``"header"``: ``item`` will be displayed in a header line (this is used by
643 ``"header"``
643 ``ibrowse``).
644 ``item`` will be displayed in a header line (this is used by ``ibrowse``).
644 * ``"footer"``: ``item`` will be displayed in a footer line (this is used by
645
645 ``ibrowse``).
646 ``"footer"``
646 * ``"cell"``: ``item`` will be displayed in a table cell/list.
647 ``item`` will be displayed in a footer line (this is used by ``ibrowse``).
647 * ``"default"``: default mode. If an ``xrepr`` implementation recursively
648
648 outputs objects, ``"default"`` must be passed in the recursive calls to
649 ``"cell"``
649 ``xrepr``.
650 ``item`` will be displayed in a table cell/list.
651
652 ``"default"``
653 default mode. If an ``xrepr`` implementation recursively outputs objects,
654 ``"default"`` must be passed in the recursive calls to ``xrepr``.
650
655
651 If no implementation is registered for ``item``, ``xrepr`` will try the
656 If no implementation is registered for ``item``, ``xrepr`` will try the
652 ``__xrepr__`` method on ``item``. If ``item`` doesn't have an ``__xrepr__``
657 ``__xrepr__`` method on ``item``. If ``item`` doesn't have an ``__xrepr__``
@@ -874,10 +879,12 b' def xattrs(item, mode="default"):'
874
879
875 There are two possible modes:
880 There are two possible modes:
876
881
877 * ``"detail"``: The ``Display`` object wants to display a detailed list
882 ``"detail"``
878 of the object attributes.
883 The ``Display`` object wants to display a detailed list of the object
879 * ``"default"``: The ``Display`` object wants to display the object in a
884 attributes.
880 list view.
885
886 ``"default"``
887 The ``Display`` object wants to display the object in a list view.
881
888
882 If no implementation is registered for the object ``item`` ``xattrs`` falls
889 If no implementation is registered for the object ``item`` ``xattrs`` falls
883 back to trying the ``__xattrs__`` method of the object. If this doesn't
890 back to trying the ``__xattrs__`` method of the object. If this doesn't
@@ -1200,7 +1207,7 b' class ils(Table):'
1200 """
1207 """
1201 List the current (or a specified) directory.
1208 List the current (or a specified) directory.
1202
1209
1203 Examples:
1210 Examples::
1204
1211
1205 >>> ils
1212 >>> ils
1206 >>> ils("/usr/local/lib/python2.4")
1213 >>> ils("/usr/local/lib/python2.4")
@@ -1238,7 +1245,7 b' class iglob(Table):'
1238 List all files and directories matching a specified pattern.
1245 List all files and directories matching a specified pattern.
1239 (See ``glob.glob()`` for more info.).
1246 (See ``glob.glob()`` for more info.).
1240
1247
1241 Examples:
1248 Examples::
1242
1249
1243 >>> iglob("*.py")
1250 >>> iglob("*.py")
1244 """
1251 """
@@ -1263,7 +1270,7 b' class iglob(Table):'
1263
1270
1264 class iwalk(Table):
1271 class iwalk(Table):
1265 """
1272 """
1266 List all files and directories in a directory and it's subdirectory.
1273 List all files and directories in a directory and it's subdirectory::
1267
1274
1268 >>> iwalk
1275 >>> iwalk
1269 >>> iwalk("/usr/local/lib/python2.4")
1276 >>> iwalk("/usr/local/lib/python2.4")
@@ -1368,7 +1375,7 b' class ipwd(Table):'
1368 """
1375 """
1369 List all entries in the Unix user account and password database.
1376 List all entries in the Unix user account and password database.
1370
1377
1371 Example:
1378 Example::
1372
1379
1373 >>> ipwd | isort("uid")
1380 >>> ipwd | isort("uid")
1374 """
1381 """
@@ -1552,7 +1559,7 b' class ienv(Table):'
1552 """
1559 """
1553 List environment variables.
1560 List environment variables.
1554
1561
1555 Example:
1562 Example::
1556
1563
1557 >>> ienv
1564 >>> ienv
1558 """
1565 """
@@ -1573,7 +1580,7 b' class ihist(Table):'
1573 """
1580 """
1574 IPython input history
1581 IPython input history
1575
1582
1576 Example:
1583 Example::
1577
1584
1578 >>> ihist
1585 >>> ihist
1579 >>> ihist(True) (raw mode)
1586 >>> ihist(True) (raw mode)
@@ -1593,7 +1600,7 b' class ihist(Table):'
1593
1600
1594 class icsv(Pipe):
1601 class icsv(Pipe):
1595 """
1602 """
1596 This ``Pipe`` lists turn the input (with must be a pipe outputting lines
1603 This ``Pipe`` turns the input (with must be a pipe outputting lines
1597 or an ``ifile``) into lines of CVS columns.
1604 or an ``ifile``) into lines of CVS columns.
1598 """
1605 """
1599 def __init__(self, **csvargs):
1606 def __init__(self, **csvargs):
@@ -1642,7 +1649,7 b' class ix(Table):'
1642 Execute a system command and list its output as lines
1649 Execute a system command and list its output as lines
1643 (similar to ``os.popen()``).
1650 (similar to ``os.popen()``).
1644
1651
1645 Examples:
1652 Examples::
1646
1653
1647 >>> ix("ps x")
1654 >>> ix("ps x")
1648 >>> ix("find .") | ifile
1655 >>> ix("find .") | ifile
@@ -1681,7 +1688,7 b' class ifilter(Pipe):'
1681 Filter an input pipe. Only objects where an expression evaluates to true
1688 Filter an input pipe. Only objects where an expression evaluates to true
1682 (and doesn't raise an exception) are listed.
1689 (and doesn't raise an exception) are listed.
1683
1690
1684 Examples:
1691 Examples::
1685
1692
1686 >>> ils | ifilter("_.isfile() and size>1000")
1693 >>> ils | ifilter("_.isfile() and size>1000")
1687 >>> igrp | ifilter("len(mem)")
1694 >>> igrp | ifilter("len(mem)")
@@ -1696,16 +1703,21 b' class ifilter(Pipe):'
1696 user namespace). ``errors`` specifies how exception during evaluation
1703 user namespace). ``errors`` specifies how exception during evaluation
1697 of ``expr`` are handled:
1704 of ``expr`` are handled:
1698
1705
1699 * ``drop``: drop all items that have errors;
1706 ``"drop"``
1707 drop all items that have errors;
1700
1708
1701 * ``keep``: keep all items that have errors;
1709 ``"keep"``
1710 keep all items that have errors;
1702
1711
1703 * ``keeperror``: keep the exception of all items that have errors;
1712 ``"keeperror"``
1713 keep the exception of all items that have errors;
1704
1714
1705 * ``raise``: raise the exception;
1715 ``"raise"``
1716 raise the exception;
1706
1717
1707 * ``raiseifallfail``: raise the first exception if all items have errors;
1718 ``"raiseifallfail"``
1708 otherwise drop those with errors (this is the default).
1719 raise the first exception if all items have errors; otherwise drop
1720 those with errors (this is the default).
1709 """
1721 """
1710 self.expr = expr
1722 self.expr = expr
1711 self.globals = globals
1723 self.globals = globals
@@ -1768,7 +1780,7 b' class ieval(Pipe):'
1768 """
1780 """
1769 Evaluate an expression for each object in the input pipe.
1781 Evaluate an expression for each object in the input pipe.
1770
1782
1771 Examples:
1783 Examples::
1772
1784
1773 >>> ils | ieval("_.abspath()")
1785 >>> ils | ieval("_.abspath()")
1774 >>> sys.path | ieval(ifile)
1786 >>> sys.path | ieval(ifile)
@@ -1840,7 +1852,7 b' class ienum(Pipe):'
1840 Enumerate the input pipe (i.e. wrap each input object in an object
1852 Enumerate the input pipe (i.e. wrap each input object in an object
1841 with ``index`` and ``object`` attributes).
1853 with ``index`` and ``object`` attributes).
1842
1854
1843 Examples:
1855 Examples::
1844
1856
1845 >>> xrange(20) | ieval("_,_*_") | ienum | ifilter("index % 2 == 0") | ieval("object")
1857 >>> xrange(20) | ieval("_,_*_") | ienum | ifilter("index % 2 == 0") | ieval("object")
1846 """
1858 """
@@ -1854,7 +1866,7 b' class isort(Pipe):'
1854 """
1866 """
1855 Sorts the input pipe.
1867 Sorts the input pipe.
1856
1868
1857 Examples:
1869 Examples::
1858
1870
1859 >>> ils | isort("size")
1871 >>> ils | isort("size")
1860 >>> ils | isort("_.isdir(), _.lower()", reverse=True)
1872 >>> ils | isort("_.isdir(), _.lower()", reverse=True)
@@ -2012,7 +2024,7 b' class icap(Table):'
2012 """
2024 """
2013 Execute a python string and capture any output to stderr/stdout.
2025 Execute a python string and capture any output to stderr/stdout.
2014
2026
2015 Examples:
2027 Examples::
2016
2028
2017 >>> import time
2029 >>> import time
2018 >>> icap("for i in range(10): print i, time.sleep(0.1)")
2030 >>> icap("for i in range(10): print i, time.sleep(0.1)")
General Comments 0
You need to be logged in to leave comments. Login now