Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F31740384
raw.txt
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
hnowlan
Apr 7 2020, 1:36 PM
2020-04-07 13:36:00 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
raw.txt
View Options
#!/usr/bin/env python3
import argparse
import datetime
import json
import uuid
BASE_MSG = {
"$schema":"/resource_change/1.0.0",
"meta": {
"stream":"resource_change"
}
}
DEFAULT_DOMAIN = "en.wikipedia.org"
MSG_TYPES = {
"mw_purge": { "tags": ["purge"] },
"null_edit": { "tags": ["null_edit"] }
}
def parse_args() -> argparse.Namespace:
""" Parse command line arguments """
parser = argparse.ArgumentParser(
description='Generate test messages for kafka topics consumed by changeprop')
parser.add_argument("--domain", "-d", dest="domain", action="store",
default=DEFAULT_DOMAIN,
help="Domain to set in metadata")
parser.add_argument("rule", action="store",
help="The rule to generate",
choices=MSG_TYPES.keys())
parser.add_argument("--uri", dest="uri", action="store", required=True,
help="The URL to execute the query against")
args = parser.parse_args()
return args
def main():
args = parse_args()
test_message = BASE_MSG
test_message["meta"]["id"] = str(uuid.uuid1())
test_message["meta"]["dt"] = datetime.datetime.now().isoformat()
test_message["meta"]["domain"] = args.domain
test_message["meta"]["uri"] = args.uri
test_message.update(MSG_TYPES[args.rule])
print(test_message)
if __name__ == "__main__":
main()
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
8375081
Default Alt Text
raw.txt (1 KB)
Attached To
Mode
P10934 changeprop_msg.py
Attached
Detach File
Event Timeline
Log In to Comment