davemds pushed a commit to branch master.

commit fcac9e23ada2ec8551c32d70addd4863c4f9be63
Author: davemds <[email protected]>
Date:   Sun May 12 20:08:31 2013 +0200

    Python-EFL: docs for ecore.FileMonitor
---
 doc/ecore/class-filemonitor.rst      |  4 +++
 doc/ecore/ecore.rst                  | 19 ++++++++++++++
 efl/ecore/efl.ecore.pyx              | 38 ++++++++++++++++++++++++++++
 efl/ecore/efl.ecore_file_monitor.pxi | 48 +++++++++++++++++++++++++++++++++---
 4 files changed, 106 insertions(+), 3 deletions(-)

diff --git a/doc/ecore/class-filemonitor.rst b/doc/ecore/class-filemonitor.rst
new file mode 100644
index 0000000..d9bc773
--- /dev/null
+++ b/doc/ecore/class-filemonitor.rst
@@ -0,0 +1,4 @@
+:class:`efl.ecore.FileMonitor` Class
+=====================================
+
+.. autoclass:: efl.ecore.FileMonitor
diff --git a/doc/ecore/ecore.rst b/doc/ecore/ecore.rst
index d66453f..30d232f 100644
--- a/doc/ecore/ecore.rst
+++ b/doc/ecore/ecore.rst
@@ -55,6 +55,24 @@ error. Any valid file descriptor can be used with this API, 
regardless of if
 was gotten with an OS specific API or from ecore.
 see :py:class:`FdHandler<efl.ecore.FdHandler>`
 
+File download
+-------------
+
+Ecore provide the :py:class:`FileDownload<efl.ecore.FileDownload>` class
+to perform asyncronous download of files from the net. Two callbacks are
+used to inform the user while progress occurs and when the download has
+finished.
+
+
+File monitor
+------------
+
+Using the :py:class:`FileMonitor<efl.ecore.FileMonitor>` class you can monitor
+a directory for changes, a single calback will be called when events occur.
+Events will be generatd everytime a file or directory (that live in the
+give path) is created/deleted/modified.
+
+
 
 Reference
 ---------
@@ -70,6 +88,7 @@ Reference
    class-exe
    class-fdhandler
    class-filedownload
+   class-filemonitor
 
 
 Inheritance diagram
diff --git a/efl/ecore/efl.ecore.pyx b/efl/ecore/efl.ecore.pyx
index 67b9e40..fb40296 100644
--- a/efl/ecore/efl.ecore.pyx
+++ b/efl/ecore/efl.ecore.pyx
@@ -160,6 +160,44 @@ Timing sources for animators
     A custom animator trigger that you need to call ecore_animator_trigger() 
to make it tick
 
 
+.. Ecore_File_Event:
+
+File monitor events
+===================
+
+.. data:: ECORE_FILE_EVENT_NONE
+
+    No event
+
+.. data:: ECORE_FILE_EVENT_CREATED_FILE
+
+    A file has been created
+
+.. data:: ECORE_FILE_EVENT_CREATED_DIRECTORY
+
+    A directory has been created
+
+.. data:: ECORE_FILE_EVENT_DELETED_FILE
+
+    A file has been deleted
+
+.. data:: ECORE_FILE_EVENT_DELETED_DIRECTORY
+
+    A directory has been deleted
+
+.. data:: ECORE_FILE_EVENT_DELETED_SELF
+
+    The monitored path itself has been deleted
+
+.. data:: ECORE_FILE_EVENT_MODIFIED
+
+    A file has changed
+
+.. data:: ECORE_FILE_EVENT_CLOSED
+
+    A file has been closed
+
+
 """
 
 import traceback
diff --git a/efl/ecore/efl.ecore_file_monitor.pxi 
b/efl/ecore/efl.ecore_file_monitor.pxi
index 3d9436d..015f321 100644
--- a/efl/ecore/efl.ecore_file_monitor.pxi
+++ b/efl/ecore/efl.ecore_file_monitor.pxi
@@ -27,7 +27,40 @@ cdef void _file_monitor_cb(void *data, Ecore_File_Monitor 
*em, Ecore_File_Event
 
 
 cdef class FileMonitor(object):
-    """ TODOC """
+    """ Monitor the given path for changes.
+
+    The callback signatures is::
+
+        monitor_cb(event, path, *args, **kargs)
+
+    Example::
+
+        def monitor_cb(event, path, tmp_path):
+            if event == ecore.ECORE_FILE_EVENT_MODIFIED:
+                print("EVENT_MODIFIED: '%s'" % path)
+            elif event == ecore.ECORE_FILE_EVENT_CLOSED:
+                print("EVENT_CLOSED: '%s'" % path)
+            elif event == ecore.ECORE_FILE_EVENT_CREATED_FILE:
+                print("ECORE_FILE_EVENT_CREATED_FILE: '%s'" % path)
+            elif event == ecore.ECORE_FILE_EVENT_CREATED_DIRECTORY:
+                print("ECORE_FILE_EVENT_CREATED_DIRECTORY: '%s'" % path)
+            elif event == ecore.ECORE_FILE_EVENT_DELETED_FILE:
+                print("ECORE_FILE_EVENT_DELETED_FILE: '%s'" % path)
+            elif event == ecore.ECORE_FILE_EVENT_DELETED_DIRECTORY:
+                print("ECORE_FILE_EVENT_DELETED_DIRECTORY: '%s'" % path)
+            elif event == ecore.ECORE_FILE_EVENT_DELETED_SELF:
+                print("ECORE_FILE_EVENT_DELETED_SELF: '%s'" % path)
+    
+        ecore.FileMonitor("/tmp", monitor_cb)
+        ecore.main_loop_begin()
+    
+
+    :param path: The complete path of the folder you want to monitor.
+    :type path: str
+    :param monitor_cb: A callback called when something change in `path`
+    :type monitor_cb: callable
+
+    """
     def __init__(self, path, monitor_cb, *args, **kargs):
 
         if not callable(monitor_cb):
@@ -69,13 +102,22 @@ cdef class FileMonitor(object):
         return 0
 
     def delete(self):
-        """ TODOC """
+        """ Delete the monitor
+
+        Stop the monitoring process, all the internal resource will be freed
+        and no more callbacks will be called.
+
+         """
         if self.mon != NULL:
             ecore_file_monitor_del(self.mon)
             self.mon = NULL
             Py_DECREF(self)
 
     property path:
-        """ TODOC """
+        """ The path actully monitored.
+
+        :type: str (readonly)
+
+        """
         def __get__(self):
             return _ctouni(ecore_file_monitor_path_get(self.mon))

-- 

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and 
their applications. This 200-page book is written by three acclaimed 
leaders in the field. The early access version is available now. 
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may

Reply via email to