-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqsearch.py
75 lines (55 loc) · 1.85 KB
/
qsearch.py
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env python
import argparse
import codecs
import random
import struct
import sys
#//**********************************************************************
#//
#// globals/constants
#//
#//**********************************************************************
PROGRAM_NAME = "qsearch"
VERSION = "0.0.0"
COPYRIGHT_MESSAGE = "copyright (c) 2015, Rick Gutleber ([email protected])"
#//**********************************************************************
#//
#// main
#//
#//**********************************************************************
def main( ):
#print( PROGRAM_NAME + ' ' + VERSION, end='\n', file=sys.stderr )
#print( " Quote file must consist of ASCII quotes, each separated by a line containing", end='\n', file=sys.stderr )
#print( " only \"%\".", end='\n', file=sys.stderr )
parser = argparse.ArgumentParser( prog=PROGRAM_NAME, description=PROGRAM_NAME + ' - ' + VERSION + ' - ' + COPYRIGHT_MESSAGE )
#parser.add_argument( '-f', '--fortune', action='store_true', help="output fortune(6) format" )
parser.add_argument( 'quoteFile', default='quote.txt' )
args = parser.parse_args( )
quoteFile = args.quoteFile
offset = 0
quoteCount = 1
dash = False
lineCount = 1
for line in codecs.open( quoteFile, 'rU', 'ascii', 'replace' ):
line = line.strip( )
if len( line ) > 1:
if line[ 0 ] == '-':
if dash:
print( lineCount )
else:
dash = True
else:
dash = False
else:
dash = False
lineCount += 1
#//**********************************************************************
#//
#// __main__
#//
#//**********************************************************************
if __name__ == '__main__':
#try:
main( )
#except:
# pass