forked from fr4z40/words
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwords.py
More file actions
117 lines (106 loc) · 3.2 KB
/
words.py
File metadata and controls
117 lines (106 loc) · 3.2 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# -*- coding: utf-8 -*-
'''
Developed by: Eduardo Frazão (fr4z40)
https://github.com/fr4z40
On jan,18,2015
A Class: Combinations generator
and a function: file_filter
'''
def file_filter(f_in, f_out):
'''
Removes repetitions.
>> this "word" isn't the same as "word " or " word".
>> be careful with large files.
-----------------------------
>> Char-Encoders:
{
latin: iso-8859-1
UTF-8: utf8, utf-8
}
'''
with open(f_in, 'r', encoding='utf8') as filein:
cntd = filein.readlines()
filein.close()
cntd_out = []
for x in cntd:
cntd_out.append(((x.replace('\r', '')).replace('\t', '')).strip('\n'))
cntd_out = list(set(cntd_out))
cntd_out.sort()
with open(f_out, 'w', encoding='utf8') as fileout:
for x in cntd_out:
fileout.write('%s\n' % x)
fileout.close()
class gen:
'''
Combinations generator, based on dates and tel. numbers
'''
def pos(pre, sep):
'''
{
Generate a list of tel. numbers, with a prefix inputed by user.
example:
pos('2668', '-')
>>2668-0001...
>>2668-0002...
}
'''
posfixo = []
pos = '9999'
for x in range(10000):
if len(pos) == 4:
posfixo.append(pre + sep + pos)
pos = str(int(pos) - 1)
else:
pos = (('0' * (4 - len(pos))) + pos)
posfixo.append(pre + sep + pos)
pos = str(int(pos) - 1)
posfixo = list(set(posfixo))
posfixo.sort()
return(posfixo)
def wordlist_dates_dma(ano):
'''{
Generate a list of date-lists...
something like: [[d, m, y], [m, d, y], [y, m, d] ... ]
example:
wordlist_dates_dma('2000')
>>>[[2000, m, d], [d, m, 2000] ... ]
}
'''
dias = []
meses = []
back = []
for x in range(1,13):
if len(str(x)) == 1:
meses.append('0%s' % str(x))
meses.append(str(x))
else:
meses.append(str(x))
for x in range(1, 32):
if len(str(x)) == 1:
dias.append('0%s' % str(x))
dias.append(str(x))
else:
dias.append(str(x))
for d in dias:
for m in meses:
var = (list((d, m, ano)))
if var not in back:
back.append(var)
var = (list((d, ano, m)))
if var not in back:
back.append(var)
var = (list((m, d, ano)))
if var not in back:
back.append(var)
var = (list((m, ano, d)))
if var not in back:
back.append(var)
var = (list((ano, d, m)))
if var not in back:
back.append(var)
var = (list((ano, m, d)))
if var not in back:
back.append(var)
del meses
del dias
return back