-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP - pluggy plugins pluggy wuggy #2111
Open
dgtlmoon
wants to merge
16
commits into
master
Choose a base branch
from
pluggy-2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
432ee12
WIP
dgtlmoon 774923f
add pluggy
dgtlmoon f6c667b
fix import
dgtlmoon 8563126
tweaks
dgtlmoon 690b16b
rename
dgtlmoon 2769abf
maybe
dgtlmoon 494740e
Merge branch 'master' into pluggy-2
dgtlmoon b88998f
Merge branch 'master' into pluggy-2
dgtlmoon 25778a8
Add plugins to pip
dgtlmoon ce97d67
Merge branch 'pluggy-2' of github.com:dgtlmoon/changedetection.io int…
dgtlmoon c643381
add filter
dgtlmoon 06744db
wrap form
dgtlmoon 42c6f8f
some plugin config
dgtlmoon 0ab3a83
Merge branch 'master' into pluggy-2
dgtlmoon 1aa0070
remove example hooks
dgtlmoon 65bc76f
add comments
dgtlmoon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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,6 @@ | ||
import pluggy | ||
|
||
hookimpl = pluggy.HookimplMarker("changedetectionio_plugin") | ||
"""Marker to be imported and used in plugins (and for own implementations)""" | ||
|
||
x=1 |
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,20 @@ | ||
import pluggy | ||
from changedetectionio.store import ChangeDetectionStore | ||
|
||
hookspec = pluggy.HookspecMarker("changedetectionio_plugin") | ||
|
||
|
||
@hookspec | ||
def extra_processor(): | ||
"""Defines a new fetch method | ||
|
||
:return: a tuples, (machine_name, description) | ||
""" | ||
|
||
@hookspec(firstresult=True) | ||
def processor_call(processor_name: str, datastore: ChangeDetectionStore, watch_uuid: str): | ||
""" | ||
Call processors with processor name | ||
:param processor_name: as defined in extra_processors | ||
:return: data? | ||
""" |
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,53 @@ | ||
""" | ||
Whois information lookup | ||
- Fetches using whois | ||
- Extends the 'text_json_diff' so that text filters can still be used with whois information | ||
|
||
@todo publish to pypi and github as a separate plugin | ||
""" | ||
|
||
from ..plugins import hookimpl | ||
import changedetectionio.processors.text_json_diff as text_json_diff | ||
from changedetectionio import content_fetcher | ||
|
||
# would be changedetectionio.plugins in other apps | ||
|
||
class text_json_filtering_whois(text_json_diff.perform_site_check): | ||
|
||
def __init__(self, *args, datastore, watch_uuid, **kwargs): | ||
super().__init__(*args, datastore=datastore, watch_uuid=watch_uuid, **kwargs) | ||
|
||
def call_browser(self): | ||
import whois | ||
# the whois data | ||
self.fetcher = content_fetcher.Fetcher() | ||
self.fetcher.is_plaintext = True | ||
|
||
from urllib.parse import urlparse | ||
parsed = urlparse(self.watch.link) | ||
w = whois.whois(parsed.hostname) | ||
self.fetcher.content= w.text | ||
|
||
@hookimpl | ||
def extra_processor(): | ||
""" | ||
Advertise a new processor | ||
:return: | ||
""" | ||
from changedetectionio.processors import default_processor_config | ||
processor_config = dict(default_processor_config) | ||
# Which UI elements are not used | ||
processor_config['needs_request_fetch_method'] = False | ||
processor_config['needs_browsersteps'] = False | ||
processor_config['needs_visualselector'] = False | ||
return ('plugin_processor_whois', "Whois domain information fetch", processor_config) | ||
|
||
# @todo When a watch chooses this extra_process processor, the watch should ONLY use this one. | ||
# (one watch can only have one extra_processor) | ||
@hookimpl | ||
def processor_call(processor_name, datastore, watch_uuid): | ||
if processor_name == 'plugin_processor_whois': # could be removed, see above note | ||
x = text_json_filtering_whois(datastore=datastore, watch_uuid=watch_uuid) | ||
return x | ||
return None | ||
|
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
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test this when running multiple different plugins :/