| |
- __builtin__.object
-
- LslEntries
- LslEntry
class LslEntries(__builtin__.object) |
|
parse a list of lines returned by "ls -l".
Here is an example:
>>> txt='''
... drwxr-xr-x. 2 pfeiffer pfeiffer 4096 2009-07-07 10:08 Public
... lrwxrwxrwx 1 pfeiffer pfeiffer 18 2009-07-09 11:38 pylib -> devel/python/pylib
... -rw-rw-r-- 1 pfeiffer pfeiffer 5464500 2009-07-28 13:35 python2.ps
... '''
>>> e= LslEntries(text=txt)
>>> print e
drwxr-xr-x. 2 pfeiffer pfeiffer 4096 2009-07-07 10:08 Public
lrwxrwxrwx 1 pfeiffer pfeiffer 18 2009-07-09 11:38 pylib -> devel/python/pylib
-rw-rw-r-- 1 pfeiffer pfeiffer 5464500 2009-07-28 13:35 python2.ps |
|
Methods defined here:
- __init__(self, text='', lines=None, year=None)
- create the LslEntries object.
parameters:
text -- the text to parse (optional)
lines -- the lines to parse (optional).
Note that either text or lines but not both
should be specified.
year -- the year that is used when the file date
doesn't contain a year. This parameter is
also optional. If this parameter is not given
and the file date does not contain a year, the
default of the unix time library is used which
is "1900".
- __repr__(self)
- return repr-string of the object.
- __str__(self)
- print contents like "ls -l" would do.
- append(self, entry)
- append a single LslEntry to the list.
- items(self)
- return items.
- names(self)
- return names.
- parse(self, text='', lines=None, year=None)
- parse a text.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class LslEntry(__builtin__.object) |
|
a class that contains all the information of a single "ls -l" line.
This class is used to parse a single line of the
output of the "ls -l" command under unix. |
|
Methods defined here:
- __init__(self, text='', year=None)
- parses a single line of the output of "ls -l"
parameters:
text -- the text to parse, optional
year -- the year that is used when the file date
doesn't contain a year. This parameter is
also optional. If this parameter is not given
and the file date does not contain a year, the
default of the unix time library is used which
is "1900".
Here are some examples:
>>> l= LslEntry("lrwxr-xr-x 1 idadm expermt 27 Oct 9 13:14 idcp13 -> ../dist/2006-10-09T10:33:09", 1900)
>>> print l
lrwxr-xr-x 1 idadm expermt 27 1900-10-09 13:14 idcp13 -> ../dist/2006-10-09T10:33:09
>>> l= LslEntry("lrwxr-xr-x 1 idadm expermt 27 Oct 9 2007 13:14 idcp13 -> ../dist/2006-10-09T10:33:09")
>>> print l
lrwxr-xr-x 1 idadm expermt 27 2007-10-09 00:00 13:14 idcp13 -> ../dist/2006-10-09T10:33:09
>>> l= LslEntry("lrwxrwxrwx 1 iocadm iocadm 47 2009-03-16 14:46 idcp8 -> /opt/IOC/Releases/idcp/dist/2009-03-16T14:46:04")
>>> print l
lrwxrwxrwx 1 iocadm iocadm 47 2009-03-16 14:46 idcp8 -> /opt/IOC/Releases/idcp/dist/2009-03-16T14:46:04
>>> l.is_symlink()
True
>>> l.is_dir()
False
>>> l= LslEntry("-rwxr-xr-x 1 idadm expermt 27 Oct 9 13:14 idcp13", 1900)
>>> print l
-rwxr-xr-x 1 idadm expermt 27 1900-10-09 13:14 idcp13
>>> l.is_symlink()
False
>>> l.is_dir()
False
>>> l= LslEntry("drwxr-xr-x 1 idadm expermt 27 Oct 9 13:14 dist", 1900)
>>> print l
drwxr-xr-x 1 idadm expermt 27 1900-10-09 13:14 dist
>>> l.is_symlink()
False
>>> l.is_dir()
True
- __repr__(self)
- __str__(self)
- converts the data to a string.
- is_dir(self)
- return True if it is a directory.
- is_symlink(self)
- return True if it is a symlink.
- parse(self, str_, year=None)
- parses a line of the output of the "ls -l" command.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
| |