-
Notifications
You must be signed in to change notification settings - Fork 9
/
pywu
executable file
·42 lines (35 loc) · 1.5 KB
/
pywu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2011 Ciaran Farrell, Juergen Weigert
# All Rights Reserved.
# This program is free software; you can redistribute it and/ormodify
# it under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, see the followig website:
# https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
import sys
from pywumanber import WuManber
from optparse import OptionParser
parser = OptionParser()
parser.add_option("-c", "--case", dest="case", action="store_true",
help="Use this flag to force case sensitive matching.")
parser.add_option("-v", "--verbose",
action="store_true", dest="verbose", default=False,
help="Print the results of the search")
(options, args) = parser.parse_args()
if len(args) != 2:
parser.error("Expected exactly 2 arguments (keywords and text)")
wu = WuManber(args[0],args[1])
if options.case:
nocase = 0
else:
nocase = 1
count = wu.search_text(nocase=nocase,verbose=options.verbose)
sys.stdout.write("Matches found: %d\n"%count)
for k in wu.keydict.keys():
print "%s: %s"%(wu.keywords[k],wu.keydict[k])