Ori.livneh has uploaded a new change for review. https://gerrit.wikimedia.org/r/117647
Change subject: mwgrep: add '--user' option for searching NS_USER ...................................................................... mwgrep: add '--user' option for searching NS_USER When mwgrep is invoked with the '--user' command-line argument, search NS_USER rather than NS_MEDIAWIKI. I chose to make this a flag rather than allow the exact namespace to be specified via an argument because: * it minimizes the chances of an accidental NS_MAIN search * searching NS_MEDIAWIKI is a sensible default * though not prohibitively expensive, searching NS_USER is onerous enough that it should only be performed if explicitly required Change-Id: Idaad02b78bc43c191b1fa8a877a08acd97bb52a5 --- M files/misc/scripts/mwgrep 1 file changed, 9 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/operations/puppet refs/changes/47/117647/1 diff --git a/files/misc/scripts/mwgrep b/files/misc/scripts/mwgrep index e256cf0..12b1a7e 100755 --- a/files/misc/scripts/mwgrep +++ b/files/misc/scripts/mwgrep @@ -3,8 +3,8 @@ """ mwgrep ~~~~~~ - Grep for CSS or JS code in the MediaWiki NS of Wikimedia Wikis - Usage: mwgrep [--max-results N] TERM + Grep for CSS or JS code in wiki pages + Usage: mwgrep [--user] [--max-results N] TERM """ import argparse @@ -13,14 +13,19 @@ BASE_URI = 'http://search.svc.eqiad.wmnet:9200/_all/page/_search' +NS_MEDIAWIKI = 8 +NS_USER = 2 -ap = argparse.ArgumentParser(description='Grep for CSS/JS in MediaWiki: NS') +ap = argparse.ArgumentParser(description='Grep for CSS/JS in wiki pages') ap.add_argument('term', help='text to search for') ap.add_argument('--max-results', type=int, default=100) +ap.add_argument('--user', action='store_const', const=NS_USER, + default=NS_MEDIAWIKI, dest='ns', + help='search NS_USER rather than NS_MEDIAWIKI') args = ap.parse_args() filters = [ - {'term': {'namespace': '8'}}, + {'term': {'namespace': str(args.ns)}}, {'regexp': {'title.keyword': '.*\\.(js|css)'}}, {'script': {'script': "_source['text'].contains('%s')" % args.term}}, ] -- To view, visit https://gerrit.wikimedia.org/r/117647 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Idaad02b78bc43c191b1fa8a877a08acd97bb52a5 Gerrit-PatchSet: 1 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: Ori.livneh <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
