style changes, variable renames

* PEP8 conformity
* rename run_post_consume_external_script to run_post_consume_script
* rename run_pre_consume_external_script to run_pre_consume_script
* change order of declaration and use from post...pre to pre...post
This commit is contained in:
Lenz Weber 2016-06-24 16:49:32 +02:00
parent c728b1dd21
commit e7566d2b1c
3 changed files with 19 additions and 17 deletions

View File

@ -7,15 +7,16 @@ class DocumentsConfig(AppConfig):
def ready(self):
from .signals import document_consumption_finished
from .signals import document_consumption_started
from .signals import document_consumption_finished
from .signals.handlers import (
set_correspondent, set_tags, run_post_consume_external_script, run_pre_consume_external_script)
set_correspondent, set_tags, run_pre_consume_script,
run_post_consume_script)
document_consumption_started.connect(run_pre_consume_script)
document_consumption_finished.connect(set_tags)
document_consumption_finished.connect(set_correspondent)
document_consumption_finished.connect(run_post_consume_external_script)
document_consumption_started.connect(run_pre_consume_external_script)
document_consumption_finished.connect(run_post_consume_script)
AppConfig.ready(self)

View File

@ -57,7 +57,18 @@ def set_tags(sender, document=None, logging_group=None, **kwargs):
document.tags.add(*relevant_tags)
def run_post_consume_external_script(sender, document, **kwargs):
def run_pre_consume_script(sender, filename, **kwargs):
if not settings.PRE_CONSUME_SCRIPT:
return
Popen((
settings.PRE_CONSUME_SCRIPT,
filename
)).wait()
def run_post_consume_script(sender, document, **kwargs):
if not settings.POST_CONSUME_SCRIPT:
return
@ -73,13 +84,3 @@ def run_post_consume_external_script(sender, document, **kwargs):
str(document.correspondent),
str(",".join(document.tags.all().values_list("slug", flat=True)))
)).wait()
def run_pre_consume_external_script(sender, filename, **kwargs):
if not settings.PRE_CONSUME_SCRIPT:
return
Popen((
settings.PRE_CONSUME_SCRIPT,
filename
)).wait()

View File

@ -229,8 +229,8 @@ PASSPHRASE = os.getenv("PAPERLESS_PASSPHRASE")
SHARED_SECRET = os.getenv("PAPERLESS_SHARED_SECRET", "")
# Trigger a script after every successful document consumption?
POST_CONSUME_SCRIPT = os.getenv("PAPERLESS_POST_CONSUME_SCRIPT")
PRE_CONSUME_SCRIPT = os.getenv("PAPERLESS_PRE_CONSUME_SCRIPT")
POST_CONSUME_SCRIPT = os.getenv("PAPERLESS_POST_CONSUME_SCRIPT")
#
# TODO: Remove after 0.2