{ "info": { "author": "Scott Hendrickson", "author_email": "scott@drskippy.net", "bugtrack_url": null, "classifiers": [], "description": "Gnip-Python-PowerTrack-Rules\n============================\n\nGnip PowerTrack rules management library and utilities.\n\nInstall with:\n pip install gnip-powertrack-rules\n\nEdit the sample_config.cfg file with your credentials and your favorite stream rule management\nurl. Copy or move to .gnip.\n\nUtilities will check the local directory for .gnip. If you want to use a different location\ntry:\n\n export GNIP_CONFIG_FILE=... in your environment.\n\n\nEXAMPLES:\n=========\n\n\nCommand line scripts:\n\n create_rules.py delete_rules.py list_rules.py update_rules.py\n\nExample files:\n \n example0.rules example1.rules example2_updates.rules example3.json example4_updates.rules\n\nScripts have parameter descriptions that can be viewed with the -h flag. E.g.,\n\n>>~/Gnip-Python-PowerTrack-Rules/src$ ./list_rules.py -h\nUsage: list_rules.py [options]\n\nOptions:\n -h, --help show this help message and exit\n -u URL, --url=URL Rules end point url\n -p, --pretty-print Prettier printing of output.\n -e PATTERN, --regex-match-rule=PATTERN\n List only rules matching pattern (Python REs)\n -x TAGPATTERN, --regex-match-tag=TAGPATTERN\n List only rules with tag matching pattern (Python REs)\n -m RULE, --match-rule=RULE\n List only rules matching rule (Exact)\n -t TAG, --match-tag=TAG\n List only rules with tags matching tag (Exact)\n -c, --csv Csv printing of output (with tab delimiter)\n\nTo delete all of your rules:\n\n>>~/Gnip-Python-PowerTrack-Rules/src$ ./delete_rules.py -d\n=== Deleting rules ===\nOK - 3 rules deleted,\n\nTo retrieve rules from the Gnip servers:\n\n>>~/Gnip-Python-PowerTrack-Rules/src$ ./list_rules.py \n{\"rules\": []}\n\nLet's make some simple rules, first off, with not tags,\n\n>>~/Gnip-Python-PowerTrack-Rules/src$ cat example0.rules \nbieber lang:ja\ngaga lang:es\nobama\n\n>>~/Gnip-Python-PowerTrack-Rules/src$ ./create_rules.py example0.rules \nOK - 3 rules created,\n\n>>~/Gnip-Python-PowerTrack-Rules/src$ ./list_rules.py -p\n{\n \"rules\": [\n {\n \"tag\": null, \n \"value\": \"bieber lang:ja\"\n }, \n {\n \"tag\": null, \n \"value\": \"gaga lang:es\"\n }, \n {\n \"tag\": null, \n \"value\": \"obama\"\n }\n ]\n}\n\nNow make some slightly more complicated rules with tags. The rules file uses tabs to\nseparate rules and tags:\n\n>>~/Gnip-Python-PowerTrack-Rules/src$ ./create_rules.py -d example1.rules \nOK - 8 rules created,\n\n>>~/Gnip-Python-PowerTrack-Rules/src$ ./list_rules.py -p\n{\n \"rules\": [\n {\n \"tag\": \"musician\", \n \"value\": \"bieber\"\n }, \n {\n \"tag\": \"musician\", \n \"value\": \"gaga\"\n }, \n {\n \"tag\": \"POTUS\", \n \"value\": \"obama\"\n }, \n {\n \"tag\": \"POTUS\", \n \"value\": \"taft\"\n }, \n {\n \"tag\": null, \n \"value\": \"dog OR doggy OR dogs\"\n }, \n {\n \"tag\": \"pets\", \n \"value\": \"canary OR parrot OR parakeet\"\n }, \n {\n \"tag\": \"pets\", \n \"value\": \"cat OR kitty OR kitten\"\n }, \n {\n \"tag\": \"pets\", \n \"value\": \"ground OR hog -day\"\n }\n ]\n}\n\n\nOops, we don't want ground OR hog--those are pets, we wanted ground (AND) hog. Also,\nwe want to tag the dog rule with \"pets\" as well. Here is the update file (columns are\nexisting rule(tab)replacement rule(tab)new tag):\n\n>>~/Gnip-Python-PowerTrack-Rules/src$ cat example2_updates.rules \ndog OR doggy OR dogs dog OR doggy OR dogs pets\nground OR hog -day ground hog -day pets\n\n>>~/Gnip-Python-PowerTrack-Rules/src$ ./update_rules.py example2_updates.rules \nOK - Successfully updated dog OR doggy OR dogs OR GNIPNULLRULE to dog OR doggy OR dogs.\nOK - Successfully updated ground OR hog -day to ground hog -day.\n\n>>~/Gnip-Python-PowerTrack-Rules/src$ ./list_rules.py -p\n{\n \"rules\": [\n {\n \"tag\": \"musician\", \n \"value\": \"bieber\"\n }, \n {\n \"tag\": \"musician\", \n \"value\": \"gaga\"\n }, \n {\n \"tag\": \"POTUS\", \n \"value\": \"obama\"\n }, \n {\n \"tag\": \"POTUS\", \n \"value\": \"taft\"\n }, \n {\n \"tag\": \"pets\", \n \"value\": \"canary OR parrot OR parakeet\"\n }, \n {\n \"tag\": \"pets\", \n \"value\": \"cat OR kitty OR kitten\"\n }, \n {\n \"tag\": \"pets\", \n \"value\": \"dog OR doggy OR dogs\"\n }, \n {\n \"tag\": \"pets\", \n \"value\": \"ground hog -day\"\n }\n ]\n}\n\nLet's use JSON formated rules instead:\n\n>>~/Gnip-Python-PowerTrack-Rules/src$ cat example3.json \n{\"rules\": [{\"tag\": \"teen idol\", \"value\": \"bieber\"}, {\"tag\": \"teen idol\", \"value\": \"gaga\"}, {\"tag\": \"teen idol:POTUS\", \"value\": \"obama\"}, {\"tag\": \"candidate\", \"value\": \"romney\"}, {\"tag\": \"pets\", \"value\": \"dog\"}, {\"tag\": \"pets\", \"value\": \"cat -mouse -mice -rat\"}]}\n\nLet's make a new set of rules (and use the -d flag to delete all of the old rules):\n\n>>~/Gnip-Python-PowerTrack-Rules/src$ ./create_rules.py -dj example3.json \nOK - 6 rules created,\n\n>>~/Gnip-Python-PowerTrack-Rules/src$ ./list_rules.py -p\n{\n \"rules\": [\n {\n \"tag\": \"teen idol\", \n \"value\": \"bieber\"\n }, \n {\n \"tag\": \"teen idol\", \n \"value\": \"gaga\"\n }, \n {\n \"tag\": \"teen idol:POTUS\", \n \"value\": \"obama\"\n }, \n {\n \"tag\": \"candidate\", \n \"value\": \"romney\"\n }, \n {\n \"tag\": \"pets\", \n \"value\": \"dog\"\n }, \n {\n \"tag\": \"pets\", \n \"value\": \"cat -mouse -mice -rat\"\n }\n ]\n}\n\nThis time, create the same new rule set (deleting the old with -d) and append a\nuniversal negation clause to every rule on creation. In this case, we want to remove\nactivities with the term \"hate\":\n\n>>~/Gnip-Python-PowerTrack-Rules/src$ ./create_rules.py -dj example3.json -a\"-hate\"\nOK - 6 rules created,\n\n>>~/Gnip-Python-PowerTrack-Rules/src$ ./list_rules.py -p\n{\n \"rules\": [\n {\n \"tag\": \"teen idol\", \n \"value\": \"bieber -hate\"\n }, \n {\n \"tag\": \"teen idol\", \n \"value\": \"gaga -hate\"\n }, \n {\n \"tag\": \"teen idol:POTUS\", \n \"value\": \"obama -hate\"\n }, \n {\n \"tag\": \"candidate\", \n \"value\": \"romney -hate\"\n }, \n {\n \"tag\": \"pets\", \n \"value\": \"dog -hate\"\n }, \n {\n \"tag\": \"pets\", \n \"value\": \"cat -mouse -mice -rat -hate\"\n }\n ]\n}\n\nNow do it with version number \"V1\" and the creation date appended to the tags:\n\n>>~/Gnip-Python-PowerTrack-Rules/src$ ./create_rules.py -dj example3.json -a\"-hate\" -b\"V1:$(date +%Y-%m-%d)\"\nOK - 6 rules created,\n\n>>~/Gnip-Python-PowerTrack-Rules/src$ ./list_rules.py -p\n{\n \"rules\": [\n {\n \"tag\": \"teen idol:V1:2013-05-15\", \n \"value\": \"bieber -hate\"\n }, \n {\n \"tag\": \"teen idol:V1:2013-05-15\", \n \"value\": \"gaga -hate\"\n }, \n {\n \"tag\": \"teen idol:POTUS:V1:2013-05-15\", \n \"value\": \"obama -hate\"\n }, \n {\n \"tag\": \"candidate:V1:2013-05-15\", \n \"value\": \"romney -hate\"\n }, \n {\n \"tag\": \"pets:V1:2013-05-15\", \n \"value\": \"dog -hate\"\n }, \n {\n \"tag\": \"pets:V1:2013-05-15\", \n \"value\": \"cat -mouse -mice -rat -hate\"\n }\n ]\n}\n\nWe can also delete rules selected by partial match of the rule or tag:\n\n>>~/Gnip-Python-PowerTrack-Rules/src$ ./delete_rules.py -h\nUsage: delete_rules.py [options]\n\nOptions:\n -h, --help show this help message and exit\n -u URL, --url=URL Input url\n -e PATTERN, --regex-match-rule=PATTERN\n List only rules matching pattern (Python REs)\n -x TAGPATTERN, --regex-match-tag=TAGPATTERN\n List only rules with tag matching pattern (Python REs)\n -m RULE, --match-rule=RULE\n List only rules matching rule (Exact)\n -t TAG, --match-tag=TAG\n List only rules with tags matching tag (Exact)\n -d, --delete Set this flag to delete, without -d, prospective\n changes are shown but not executed.\n\nBy rule match is too strict unless we type in the whole rule,\n\n>>~/Gnip-Python-PowerTrack-Rules/src$ ./delete_rules.py -tcandidate\n=== Proposed rule deletions shown but not executed, use -d to execute ===\n\n>>>===SHOWING LOCAL RULES -- May NOT RELECT SERVER STATUS===<<<\n{\"rules\": []}\n\nBut by regex, we get a match,\n\n>>~/Gnip-Python-PowerTrack-Rules/src$ ./delete_rules.py -xcandidate\n=== Proposed rule deletions shown but not executed, use -d to execute ===\n\n>>>===SHOWING LOCAL RULES -- May NOT RELECT SERVER STATUS===<<<\n{\"rules\": [{\"tag\": \"candidate:V1:2013-05-15\", \"value\": \"romney -hate\"}]}\n\nAdd the -d flag to execute the change on the Gnip servers,\n\n>>~/Gnip-Python-PowerTrack-Rules/src$ ./delete_rules.py -dxcandidate\n=== Deleting rules ===\nOK - 1 rules deleted,\n\n>>~/Gnip-Python-PowerTrack-Rules/src$ ./list_rules.py -p\n{\n \"rules\": [\n {\n \"tag\": \"teen idol:V1:2013-05-15\", \n \"value\": \"bieber -hate\"\n }, \n {\n \"tag\": \"teen idol:V1:2013-05-15\", \n \"value\": \"gaga -hate\"\n }, \n {\n \"tag\": \"teen idol:POTUS:V1:2013-05-15\", \n \"value\": \"obama -hate\"\n }, \n {\n \"tag\": \"pets:V1:2013-05-15\", \n \"value\": \"dog -hate\"\n }, \n {\n \"tag\": \"pets:V1:2013-05-15\", \n \"value\": \"cat -mouse -mice -rat -hate\"\n }\n ]\n}\n\n==\nGnip-Python-PowerTrack-Rule by Scott Hendrickson see LICENSE.txt for details.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://pypi.python.org/pypi/twacs/", "keywords": null, "license": "LICENSE.txt", "maintainer": null, "maintainer_email": null, "name": "gnip-powertrack-rules", "package_url": "https://pypi.org/project/gnip-powertrack-rules/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/gnip-powertrack-rules/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://pypi.python.org/pypi/twacs/" }, "release_url": "https://pypi.org/project/gnip-powertrack-rules/0.2.2/", "requires_dist": null, "requires_python": null, "summary": "Gnip PowerTrack rules libarary and command scripts.", "version": "0.2.2" }, "last_serial": 3452412, "releases": { "0.2.0": [ { "comment_text": "", "digests": { "md5": "ab21f9308231c1903bcb856dd48752f2", "sha256": "5638f132aadc1133cf0c384737263f51f9a2080c53fceef47963501f9ebbffc7" }, "downloads": -1, "filename": "gnip-powertrack-rules-0.2.0.tar.gz", "has_sig": false, "md5_digest": "ab21f9308231c1903bcb856dd48752f2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7432, "upload_time": "2013-05-14T21:01:05", "url": "https://files.pythonhosted.org/packages/ab/cc/226b18e103617ade0bea26a5a1a82580c532ed111a78cb0a2afdc2e64046/gnip-powertrack-rules-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "df5a5e9da050505bc266e9d715ed21ac", "sha256": "ccc49219425f4fddb1a3972b3e17719f851d810b1a084a31c111a0512a9dbb13" }, "downloads": -1, "filename": "gnip-powertrack-rules-0.2.1.tar.gz", "has_sig": false, "md5_digest": "df5a5e9da050505bc266e9d715ed21ac", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8567, "upload_time": "2013-05-15T18:42:00", "url": "https://files.pythonhosted.org/packages/f3/e7/f2b81a2f2053e697c26928a53bdca20bdc7c6bfce7d8ee3f25cc4a80d692/gnip-powertrack-rules-0.2.1.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "b95a16ffc5a7b9e6c456b0ff619565ae", "sha256": "4e6c257cb6c72ab082a174ea2cc99d9e397db6c95ce346dd4d88493ba163a1f6" }, "downloads": -1, "filename": "gnip-powertrack-rules-0.2.2.tar.gz", "has_sig": false, "md5_digest": "b95a16ffc5a7b9e6c456b0ff619565ae", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8656, "upload_time": "2014-01-08T16:53:12", "url": "https://files.pythonhosted.org/packages/4b/98/f6d0237de815e84d03fbbbeecd1e15f7be3132ef02b499fdc2c2885641e1/gnip-powertrack-rules-0.2.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b95a16ffc5a7b9e6c456b0ff619565ae", "sha256": "4e6c257cb6c72ab082a174ea2cc99d9e397db6c95ce346dd4d88493ba163a1f6" }, "downloads": -1, "filename": "gnip-powertrack-rules-0.2.2.tar.gz", "has_sig": false, "md5_digest": "b95a16ffc5a7b9e6c456b0ff619565ae", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8656, "upload_time": "2014-01-08T16:53:12", "url": "https://files.pythonhosted.org/packages/4b/98/f6d0237de815e84d03fbbbeecd1e15f7be3132ef02b499fdc2c2885641e1/gnip-powertrack-rules-0.2.2.tar.gz" } ] }