The mdfmonitor can monitoring the file modification.
Project description
mdfmonitor - Monitor the file moification
#####################################
The **mdfmonitor** is Python module about monitoring files modification using timestamp and body.
The **mdfmonitor** contains:
+ **FileModificationMonitor**
+ **URLModificationMonitor**
FileModificationMonitor
=================
This FileModificationMonitor (call this *monitor* from now) can monitor to a **file** or files modification.
Monitor has the repository of file's **timestamp** data and **body** data.
And monitor appends each data, then monitor **compare** new data to old data.
If new data **differ** to old data, monitor **regard** this difference to **modification**.
Then monitor create instance of FileModificationObject, yield this.
How to Use
------------
It's simple.
1. Import this module.
2. Create `FileModificationMonitor` class's instance.
3. Append file or files to instance using add_file method.
4. using Python for sentence, You can write anything under for sentence.
::
#!/usr/bin/python
import os
from mdfmonitor import FileModificationMonitor
files = os.listdir(".") # >>> ['sample.txt', 'sample.py']
# create Watcher instnce
monitor = FileModificationMonitor()
# append file to mdfmonitor instance
monitor.add_file("sample.txt")
# or
# append files to mdfmonitor instance
monitor.add_files(os.listdir("."))
for mdf in monitor.monitor():
print mdf.file.center(30, "=")
print "Catch the Modification!!"
print "Old timestamp: %s" % mdf.old_mtime
print "New timestamp: %s" % mdf.new_mtime
print "manager: %s" % str(mdf.manager.o_repository)
print "Diff".center(30,"=")
print mdf.diff
URLModificationMonitor
=================
This URLModificationMonitor (call this *monitor* from now) can monitor to **body of url** or urls modification.
This monitor's structure **almost same** to FileModificationMonitor.
Both monitor just difference is to time data what compare.
FileModificationMonitor gets a file **timestamp**, URLModificationMonitor gets the `Date` header's **date** of server.
How to Use
-------------
It's simple too.
1. Import this module.
2. Create `URLModificationMonitor` class's instance.
3. Append url string or url string's list to instance using add_url method.
4. using Python for sentence, You can write anything under for sentence.
::
#!/usr/bin/python
import os
from mdfmonitor import URLModificationMonitor
files = os.listdir(".") # >>> ['sample.txt', 'sample.py']
# create Watcher instnce
monitor = URLModificationMonitor()
# append file to mdfmonitor instance
monitor.add_url("http://sampe.com/path/")
for mdf in monitor.monitor():
print mdf.url.center(30, "=")
print "Catch the Modification!!"
print "Old timestamp: %s" % mdf.old_dtime
print "New timestamp: %s" % mdf.new_dtime
print "manager: %s" % str(mdf.manager.o_repository)
print "Diff".center(30,"=")
print mdf.diff
#####################################
The **mdfmonitor** is Python module about monitoring files modification using timestamp and body.
The **mdfmonitor** contains:
+ **FileModificationMonitor**
+ **URLModificationMonitor**
FileModificationMonitor
=================
This FileModificationMonitor (call this *monitor* from now) can monitor to a **file** or files modification.
Monitor has the repository of file's **timestamp** data and **body** data.
And monitor appends each data, then monitor **compare** new data to old data.
If new data **differ** to old data, monitor **regard** this difference to **modification**.
Then monitor create instance of FileModificationObject, yield this.
How to Use
------------
It's simple.
1. Import this module.
2. Create `FileModificationMonitor` class's instance.
3. Append file or files to instance using add_file method.
4. using Python for sentence, You can write anything under for sentence.
::
#!/usr/bin/python
import os
from mdfmonitor import FileModificationMonitor
files = os.listdir(".") # >>> ['sample.txt', 'sample.py']
# create Watcher instnce
monitor = FileModificationMonitor()
# append file to mdfmonitor instance
monitor.add_file("sample.txt")
# or
# append files to mdfmonitor instance
monitor.add_files(os.listdir("."))
for mdf in monitor.monitor():
print mdf.file.center(30, "=")
print "Catch the Modification!!"
print "Old timestamp: %s" % mdf.old_mtime
print "New timestamp: %s" % mdf.new_mtime
print "manager: %s" % str(mdf.manager.o_repository)
print "Diff".center(30,"=")
print mdf.diff
URLModificationMonitor
=================
This URLModificationMonitor (call this *monitor* from now) can monitor to **body of url** or urls modification.
This monitor's structure **almost same** to FileModificationMonitor.
Both monitor just difference is to time data what compare.
FileModificationMonitor gets a file **timestamp**, URLModificationMonitor gets the `Date` header's **date** of server.
How to Use
-------------
It's simple too.
1. Import this module.
2. Create `URLModificationMonitor` class's instance.
3. Append url string or url string's list to instance using add_url method.
4. using Python for sentence, You can write anything under for sentence.
::
#!/usr/bin/python
import os
from mdfmonitor import URLModificationMonitor
files = os.listdir(".") # >>> ['sample.txt', 'sample.py']
# create Watcher instnce
monitor = URLModificationMonitor()
# append file to mdfmonitor instance
monitor.add_url("http://sampe.com/path/")
for mdf in monitor.monitor():
print mdf.url.center(30, "=")
print "Catch the Modification!!"
print "Old timestamp: %s" % mdf.old_dtime
print "New timestamp: %s" % mdf.new_dtime
print "manager: %s" % str(mdf.manager.o_repository)
print "Diff".center(30,"=")
print mdf.diff
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
mdfmonitor-0.1.2b.tar.gz
(3.8 kB
view details)
File details
Details for the file mdfmonitor-0.1.2b.tar.gz
.
File metadata
- Download URL: mdfmonitor-0.1.2b.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 05eb5463e3b1e21a6a6ccdf962c67dbd2b70095ce56251bef2bc5642375801b8 |
|
MD5 | b6c8328b9693e6556908ac455069b68e |
|
BLAKE2b-256 | 198fae60ff0108e18478189885ab6c3e47b0b6ed87af9057ecb2f5844466b6ef |