Multipurpose module used to access filesystem items
Project description
Short module description
=========================
Module pd.find present simple way use filesystem
to search and read files on it. File system using
showed as simple as using ordinal dict::
>>> import pd.find
>>> f=pd.find.file.File("/etc/sysconfig")
>>> f
'/etc/sysconfig'
>>> f.keys()
['harddisk', 'lm_sensors', 'ipw3945d~', 'syscheckerrc', 'mouse']
>>> f['lm_sensors']
'/etc/sysconfig/lm_sensors'
>>> print str(f['lm_sensors'])
# /etc/sysconfig/lm_sensors - Defines modules loaded by
Other important pakage mission is find files by the way similar
to command line find utility::
>>> import pd.find
>>> pd.find.find("/etc/sysconfig",lambda x : x.isreg() and x.check_regex(".*rc"))
<generator object at 0xb7cca7cc>
>>> for item in pd.find.find("/etc/sysconfig",lambda x : x.isreg() and x.check_regex(".*rc$")) :
... print item.path
...
/etc/sysconfig/xinitrc
/etc/sysconfig/syscheckerrc
>>>
Using pd.find.file.File
--------------------------
Constructor issued as in example above, with one required
argument - path to file or directory. There are other
arguments:
dereference
Follow symlinks (is False by default)
The File object to provide some useful methods and attributes:
path
Attribute present absolute file path;
__str__()
Method returns file body if it can;
Other attributes do condition check and will be described bellow.
Issue pd.find.find utility
--------------------------
The pd.find.find utility issued to reqursive search files to satisfy
some conditions. Utility accept followed arguments:
path
Directory path to search begin with;
condition
Condition checked on scanned files and directories. If condition satisfy - object
yielded by utility;
precondition
Condition checked before subdirectory scan. If condition does not satisfy,
subdirectory will not be scaned;
dereference
On true value of this argument searhing will be followed by symbolic
link.
Utility return generator of list object find by them.
Tests provided by File Object
-----------------------------
mtime
Return modification time
atime
Return last access time
ctime
Return creation time """
return self.__checktime_(stat.ST_CTIME)
newer
Return true if object is more newer then input path
check_name
Return true if object name are equal to input name
check_path
Return true if object path are equal to input path
check_path_regex
Return true if regexp matched object path
check_regex
Return true if regexp matched object name
check_iregex
Return true if regexp matched object name
depth
Return current depth on file tree
dele
Delete file by path of current object
execute
Frm will be substituted by substring "{}" on path and executed
by os.system() call
Ho-ho. Sorry my English :)
* Sat Nov 10 2007 Andrey Orlov <cray@neural.ru> 0.0.3
- Some documentation wrote
* Wed Nov 9 2007 Andrey Orlov <cray@neural.ru> 0.0.2
- first official release
=========================
Module pd.find present simple way use filesystem
to search and read files on it. File system using
showed as simple as using ordinal dict::
>>> import pd.find
>>> f=pd.find.file.File("/etc/sysconfig")
>>> f
'/etc/sysconfig'
>>> f.keys()
['harddisk', 'lm_sensors', 'ipw3945d~', 'syscheckerrc', 'mouse']
>>> f['lm_sensors']
'/etc/sysconfig/lm_sensors'
>>> print str(f['lm_sensors'])
# /etc/sysconfig/lm_sensors - Defines modules loaded by
Other important pakage mission is find files by the way similar
to command line find utility::
>>> import pd.find
>>> pd.find.find("/etc/sysconfig",lambda x : x.isreg() and x.check_regex(".*rc"))
<generator object at 0xb7cca7cc>
>>> for item in pd.find.find("/etc/sysconfig",lambda x : x.isreg() and x.check_regex(".*rc$")) :
... print item.path
...
/etc/sysconfig/xinitrc
/etc/sysconfig/syscheckerrc
>>>
Using pd.find.file.File
--------------------------
Constructor issued as in example above, with one required
argument - path to file or directory. There are other
arguments:
dereference
Follow symlinks (is False by default)
The File object to provide some useful methods and attributes:
path
Attribute present absolute file path;
__str__()
Method returns file body if it can;
Other attributes do condition check and will be described bellow.
Issue pd.find.find utility
--------------------------
The pd.find.find utility issued to reqursive search files to satisfy
some conditions. Utility accept followed arguments:
path
Directory path to search begin with;
condition
Condition checked on scanned files and directories. If condition satisfy - object
yielded by utility;
precondition
Condition checked before subdirectory scan. If condition does not satisfy,
subdirectory will not be scaned;
dereference
On true value of this argument searhing will be followed by symbolic
link.
Utility return generator of list object find by them.
Tests provided by File Object
-----------------------------
mtime
Return modification time
atime
Return last access time
ctime
Return creation time """
return self.__checktime_(stat.ST_CTIME)
newer
Return true if object is more newer then input path
check_name
Return true if object name are equal to input name
check_path
Return true if object path are equal to input path
check_path_regex
Return true if regexp matched object path
check_regex
Return true if regexp matched object name
check_iregex
Return true if regexp matched object name
depth
Return current depth on file tree
dele
Delete file by path of current object
execute
Frm will be substituted by substring "{}" on path and executed
by os.system() call
Ho-ho. Sorry my English :)
* Sat Nov 10 2007 Andrey Orlov <cray@neural.ru> 0.0.3
- Some documentation wrote
* Wed Nov 9 2007 Andrey Orlov <cray@neural.ru> 0.0.2
- first official release
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pd.find-0.0.3.tar.gz
(6.7 kB
view details)
File details
Details for the file pd.find-0.0.3.tar.gz
.
File metadata
- Download URL: pd.find-0.0.3.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0bf826f95d7eee1fc2f6b506e510e9e4fd505e174bb1dd15b2784fd50aabbe57 |
|
MD5 | 5993baf3b630852689c17317b405fc30 |
|
BLAKE2b-256 | 91fb4d43680848a1a00b6bcf26e01cb333ad14d7ac025cee852b17f8b79075eb |