formatted docstrings. fixed decorator with functools
This commit is contained in:
parent
2e54fd64d3
commit
10a6a4d541
2 changed files with 11 additions and 13 deletions
|
@ -1,6 +1,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import pyinotify
|
import pyinotify
|
||||||
from pydispatch import dispatcher
|
from pydispatch import dispatcher
|
||||||
|
from functools import wraps
|
||||||
|
|
||||||
import media.monitor.pure as mmp
|
import media.monitor.pure as mmp
|
||||||
from media.monitor.pure import IncludeOnly
|
from media.monitor.pure import IncludeOnly
|
||||||
|
@ -31,6 +32,7 @@ class FileMediator(object):
|
||||||
def unignore(path): FileMediator.ignored_set.remove(path)
|
def unignore(path): FileMediator.ignored_set.remove(path)
|
||||||
|
|
||||||
def mediate_ignored(fn):
|
def mediate_ignored(fn):
|
||||||
|
@wraps(fn)
|
||||||
def wrapped(self, event, *args,**kwargs):
|
def wrapped(self, event, *args,**kwargs):
|
||||||
event.pathname = unicode(event.pathname, "utf-8")
|
event.pathname = unicode(event.pathname, "utf-8")
|
||||||
if FileMediator.is_ignored(event.pathname):
|
if FileMediator.is_ignored(event.pathname):
|
||||||
|
|
|
@ -10,14 +10,12 @@ from os.path import dirname
|
||||||
import os.path
|
import os.path
|
||||||
|
|
||||||
class Organizer(ReportHandler,Loggable):
|
class Organizer(ReportHandler,Loggable):
|
||||||
"""
|
""" Organizer is responsible to to listening to OrganizeListener
|
||||||
Organizer is responsible to to listening to OrganizeListener events
|
events and committing the appropriate changes to the filesystem.
|
||||||
and committing the appropriate changes to the filesystem. It does
|
It does not in any interact with WatchSyncer's even when the the
|
||||||
not in any interact with WatchSyncer's even when the the WatchSyncer
|
WatchSyncer is a "storage directory". The "storage" directory picks
|
||||||
is a "storage directory". The "storage" directory picks up all of
|
up all of its events through pyinotify. (These events are fed to it
|
||||||
its events through pyinotify. (These events are fed to it through
|
through StoreWatchListener) """
|
||||||
StoreWatchListener)
|
|
||||||
"""
|
|
||||||
|
|
||||||
# Commented out making this class a singleton because it's just a band aid
|
# Commented out making this class a singleton because it's just a band aid
|
||||||
# for the real issue. The real issue being making multiple Organizer
|
# for the real issue. The real issue being making multiple Organizer
|
||||||
|
@ -41,11 +39,9 @@ class Organizer(ReportHandler,Loggable):
|
||||||
super(Organizer, self).__init__(signal=self.channel, weak=False)
|
super(Organizer, self).__init__(signal=self.channel, weak=False)
|
||||||
|
|
||||||
def handle(self, sender, event):
|
def handle(self, sender, event):
|
||||||
"""
|
""" Intercept events where a new file has been added to the
|
||||||
Intercept events where a new file has been added to the organize
|
organize directory and place it in the correct path (starting
|
||||||
directory and place it in the correct path (starting with
|
with self.target_path) """
|
||||||
self.target_path)
|
|
||||||
"""
|
|
||||||
# Only handle this event type
|
# Only handle this event type
|
||||||
assert isinstance(event, OrganizeFile), \
|
assert isinstance(event, OrganizeFile), \
|
||||||
"Organizer can only handle OrganizeFile events.Given '%s'" % event
|
"Organizer can only handle OrganizeFile events.Given '%s'" % event
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue