-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
V03 issue745 Improve poll cod deriveKey & refactor to remove code dup…
…lication (#746) * refactor deriveKey into parent class. change key for cod #745 * update unit tests to reflect refactor and deriveKey change. #745
- Loading branch information
1 parent
59dbc7d
commit 5afe909
Showing
7 changed files
with
107 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
|
||
|
||
import logging | ||
|
||
from sarracenia.flowcb import FlowCB | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class NoDupe(FlowCB): | ||
""" | ||
duplicate suppression family of modules. | ||
invoked with: | ||
callback sarracenia.flowcb.nodupe.disk | ||
or: | ||
callback sarracenia.flowcb.nodupe.redis | ||
with default being loaded depdending on the presence of a | ||
nodupe_driver "redis" | ||
setting (defaults to disk.) | ||
""" | ||
|
||
|
||
def deriveKey(self, msg) -> str: | ||
|
||
key=None | ||
if ('nodupe_override' in msg) and ('key' in msg['nodupe_override']): | ||
key = msg['nodupe_override']['key'] | ||
elif 'fileOp' in msg : | ||
if 'link' in msg['fileOp']: | ||
key = msg['fileOp']['link'] | ||
elif 'directory' in msg['fileOp']: | ||
if 'remove' not in msg['fileOp']: | ||
key = msg['relPath'] | ||
elif ('identity' in msg) and not (msg['identity']['method'] in ['cod']): | ||
key = msg['identity']['method'] + ',' + msg['identity']['value'].replace('\n', '') | ||
|
||
if not key: | ||
if 'mtime' in msg: | ||
t = msg['mtime'] | ||
else: | ||
t = msg['pubTime'] | ||
if 'size' in msg: | ||
key = f"{msg['relPath']},{t},{msg['size']}" | ||
else: | ||
key = f"{msg['relPath']},{t}" | ||
|
||
return key | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.