File tree Expand file tree Collapse file tree 1 file changed +86
-0
lines changed
Expand file tree Collapse file tree 1 file changed +86
-0
lines changed Original file line number Diff line number Diff line change 1+ #!usr/bin/env python
2+ #-*- coding:utf-8 -*-
3+
4+ '''
5+ 1.Usage: DeFence.py -c content
6+
7+ 2.Usage: DeFence.py -c content -n (A number)
8+
9+ '''
10+
11+ from optparse import OptionParser
12+
13+
14+ def ArgsModule ():
15+
16+ Arg = OptionParser ()
17+
18+ Arg .add_option ('-c' ,dest = 'content' ,help = 'Input the passwd' )
19+
20+ Arg .add_option ('-n' ,dest = 'num' ,help = 'Number of Fence,deault is half of content' )
21+
22+ options ,args = Arg .parse_args ()
23+
24+ if options .content is None :
25+
26+ print 'Please input \' -h\' to get help'
27+
28+ exit (0 )
29+
30+ return options
31+
32+
33+ def exp (content ,num ,quote ):
34+
35+ result = []
36+
37+ key = ''
38+
39+ for i in range (quote ):
40+
41+ result .append (content [i * num :(i + 1 )* num ])
42+
43+ for n in range (num ):
44+
45+ for string in result :
46+
47+ key = key + string [n :n + 1 ]
48+
49+ print key
50+
51+
52+
53+
54+
55+
56+ def DealArgs (options ):
57+
58+ if options .num is not None :
59+
60+ quote = len (options .content )/ int (options .num )
61+
62+ exp (options .content ,int (options .num ),quote )
63+
64+ else :
65+
66+ num = len (options .content )/ 2
67+
68+ for i in range (2 ,num + 1 ):
69+
70+ if len (options .content )% i == 0 :
71+
72+ quote = len (options .content )/ i
73+
74+ exp (options .content ,i ,quote )
75+
76+
77+ def main ():
78+
79+ options = ArgsModule ()
80+
81+ DealArgs (options )
82+
83+
84+ if __name__ == '__main__' :
85+
86+ main ()
You can’t perform that action at this time.
0 commit comments