OLD | NEW |
| (Empty) |
1 file = os.path.join('/var/www/awstatsdata', '<%= title %>', | |
2 'awstats%s%s.%s.txt' % (month, year, '<%= title %>')) | |
3 if os.path.exists(file): | |
4 with open(file, 'rb+') as f: | |
5 mapstarted = False | |
6 seekpos = None | |
7 for line in f: | |
8 if not mapstarted: | |
9 if line.startswith('BEGIN_MAP '): | |
10 mapstarted = True | |
11 else: | |
12 match = re.search(r'^POS_VISITOR (\d+)', line) | |
13 if match: | |
14 seekpos = int(match.group(1)) | |
15 break | |
16 | |
17 f.seek(seekpos) | |
18 data = f.readline() # BEGIN_VISITOR line | |
19 for line in f: | |
20 if line.startswith("END_VISITOR"): | |
21 break | |
22 parts = line.split(' ') | |
23 parts[0] = re.sub(r'\w', 'x', parts[0]) | |
24 data += ' '.join(parts) | |
25 | |
26 f.seek(seekpos) | |
27 f.write(data) | |
OLD | NEW |