Show More
@@ -5,7 +5,7 b' General purpose utilities.' | |||||
5 | This is a grab-bag of stuff I find useful in most programs I write. Some of |
|
5 | This is a grab-bag of stuff I find useful in most programs I write. Some of | |
6 | these things are also convenient when working at the command line. |
|
6 | these things are also convenient when working at the command line. | |
7 |
|
7 | |||
8 |
$Id: genutils.py 10 |
|
8 | $Id: genutils.py 1028 2006-01-16 21:42:33Z vivainio $""" | |
9 |
|
9 | |||
10 | #***************************************************************************** |
|
10 | #***************************************************************************** | |
11 | # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu> |
|
11 | # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu> | |
@@ -36,7 +36,7 b' import types' | |||||
36 | # Other IPython utilities |
|
36 | # Other IPython utilities | |
37 | from IPython.Itpl import Itpl,itpl,printpl |
|
37 | from IPython.Itpl import Itpl,itpl,printpl | |
38 | from IPython import DPyGetOpt |
|
38 | from IPython import DPyGetOpt | |
39 |
|
39 | from IPython.path import path | ||
40 | if os.name == "nt": |
|
40 | if os.name == "nt": | |
41 | from IPython.winconsole import get_console_size |
|
41 | from IPython.winconsole import get_console_size | |
42 |
|
42 | |||
@@ -900,6 +900,16 b' class LSString(str):' | |||||
900 |
|
900 | |||
901 | n = nlstr = property(get_nlstr) |
|
901 | n = nlstr = property(get_nlstr) | |
902 |
|
902 | |||
|
903 | def get_paths(self): | |||
|
904 | try: | |||
|
905 | return self.__paths | |||
|
906 | except AttributeError: | |||
|
907 | self.__paths = [path(p) for p in self.split('\n') if os.path.exists(p)] | |||
|
908 | return self.__paths | |||
|
909 | ||||
|
910 | p = paths = property(get_paths) | |||
|
911 | ||||
|
912 | ||||
903 | #---------------------------------------------------------------------------- |
|
913 | #---------------------------------------------------------------------------- | |
904 | class SList(list): |
|
914 | class SList(list): | |
905 | """List derivative with a special access attributes. |
|
915 | """List derivative with a special access attributes. | |
@@ -935,6 +945,15 b' class SList(list):' | |||||
935 | return self.__nlstr |
|
945 | return self.__nlstr | |
936 |
|
946 | |||
937 | n = nlstr = property(get_nlstr) |
|
947 | n = nlstr = property(get_nlstr) | |
|
948 | ||||
|
949 | def get_paths(self): | |||
|
950 | try: | |||
|
951 | return self.__paths | |||
|
952 | except AttributeError: | |||
|
953 | self.__paths = [path(p) for p in self if os.path.exists(p)] | |||
|
954 | return self.__paths | |||
|
955 | ||||
|
956 | p = paths = property(get_paths) | |||
938 |
|
957 | |||
939 | #---------------------------------------------------------------------------- |
|
958 | #---------------------------------------------------------------------------- | |
940 | def esc_quotes(strng): |
|
959 | def esc_quotes(strng): |
@@ -4,7 +4,11 b'' | |||||
4 | that returns file contents on exit. |
|
4 | that returns file contents on exit. | |
5 |
|
5 | |||
6 | * IPython/path.py: Added Jason Orendorff's "path" module to |
|
6 | * IPython/path.py: Added Jason Orendorff's "path" module to | |
7 | IPython tree, http://www.jorendorff.com/articles/python/path/ |
|
7 | IPython tree, http://www.jorendorff.com/articles/python/path/. | |
|
8 | You can get path objects conveniently through %sc, and !!, e.g.: | |||
|
9 | sc files=ls | |||
|
10 | for p in files.paths: # or files.p | |||
|
11 | print p,p.mtime | |||
8 |
|
12 | |||
9 | * Ipython/iplib.py:"," and ";" autoquoting-upon-autocall |
|
13 | * Ipython/iplib.py:"," and ";" autoquoting-upon-autocall | |
10 | now work again without considering the exclusion regexp - |
|
14 | now work again without considering the exclusion regexp - |
General Comments 0
You need to be logged in to leave comments.
Login now