|
2 | 2 | # -*- coding: utf-8 -*-
|
3 | 3 | import random
|
4 | 4 | import string
|
| 5 | +from os.path import dirname, join |
5 | 6 |
|
6 |
| -FirstNames = './Names/FirstNames.txt' |
7 |
| -MiddleNames = './Names/MiddleNames.txt' |
8 |
| -LastNames = './Names/LastNames.txt' |
9 |
| -CountyNames = './Names/CountyNames.txt' |
10 |
| -PlaceNames = './Names/PlaceNames.txt' |
11 |
| -StateNames = './Names/StateNames.txt' |
12 |
| -CountryNames = './Names/CountryNames.txt' |
13 |
| -CompanyNames = './Names/CompanyNames.txt' |
| 7 | +script_dir = dirname(__file__) |
| 8 | +names_dir = join(script_dir, 'Names') |
14 | 9 |
|
| 10 | +FirstNames = join(names_dir, 'FirstNames.txt') |
| 11 | +MiddleNames = join(names_dir, 'MiddleNames.txt') |
| 12 | +LastNames = join(names_dir, 'LastNames.txt') |
| 13 | +CountyNames = join(names_dir, 'CountyNames.txt') |
| 14 | +PlaceNames = join(names_dir, 'PlaceNames.txt') |
| 15 | +StateNames = join(names_dir, 'StateNames.txt') |
| 16 | +CountryNames = join(names_dir, 'CountryNames.txt') |
| 17 | +CompanyNames = join(names_dir, 'CompanyNames.txt') |
15 | 18 |
|
16 | 19 |
|
17 | 20 | def Number(start=0, end=100000):
|
@@ -49,6 +52,9 @@ def rawCount(filename):
|
49 | 52 |
|
50 | 53 |
|
51 | 54 | def randomLine(filename):
|
| 55 | + """ |
| 56 | + Read the given text file and return a random line |
| 57 | + """ |
52 | 58 | num = int(random.uniform(0, rawCount(filename)))
|
53 | 59 | with open(filename, 'r', encoding="UTF-8") as f:
|
54 | 60 | for i, line in enumerate(f, 1):
|
|
0 commit comments