-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
modules.hpi.twitter_android: initial experimental module via object n…
…ormaliser using HPI also see #28
- Loading branch information
Showing
3 changed files
with
62 additions
and
3 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,41 @@ | ||
# NOTE: this is experimental for now, best to use the corresponding module bleanser.modules.* instead | ||
import os | ||
from pathlib import Path | ||
from typing import Any, Iterator | ||
|
||
from bleanser.core.modules.extract import ExtractObjectsNormaliser | ||
|
||
from my.core.cfg import tmp_config | ||
|
||
## disable cache, otherwise it's gonna flush it all the time | ||
# TODO this should be in some sort of common module | ||
os.environ['CACHEW_DISABLE'] = '*' | ||
os.environ.pop('ENLIGHTEN_ENABLE', None) | ||
os.environ['LOGGING_LEVEL_my_twitter_android'] = 'WARNING' | ||
## | ||
|
||
import my.twitter.android as twitter_android | ||
|
||
|
||
class Normaliser(ExtractObjectsNormaliser): | ||
MULTIWAY = True | ||
PRUNE_DOMINATED = True | ||
|
||
def extract_objects(self, path: Path) -> Iterator[Any]: | ||
class config: | ||
class twitter: | ||
class android: | ||
export_path = path | ||
|
||
with tmp_config(modules=twitter_android.__name__, config=config): | ||
assert len(twitter_android.inputs()) == 1 # sanity check to make sure tmp_config worked as expected | ||
for x in twitter_android.bookmarks(): | ||
yield 'bookmark', x | ||
for x in twitter_android.likes(): | ||
yield 'like', x | ||
for x in twitter_android.tweets(): | ||
yield 'tweet', x | ||
|
||
|
||
if __name__ == '__main__': | ||
Normaliser.main() |
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