Fixed problem
This commit is contained in:
parent
574f89a4cd
commit
a96c23c9c8
|
@ -1,8 +1,9 @@
|
||||||
import urllib2, datetime, mmap, re, sys
|
import urllib2, datetime, mmap, re, os, sys
|
||||||
|
|
||||||
## GLOBAL VAR ##
|
## GLOBAL VAR ##
|
||||||
|
dir = os.path.dirname(__file__)
|
||||||
processed_rules = set()
|
processed_rules = set()
|
||||||
exclusions_file = open('exclusions.txt', 'r').read().split('\n')
|
exclusions_file = open(os.path.join(dir, 'exclusions.txt'), 'r').read().split('\n')
|
||||||
# Remove comments
|
# Remove comments
|
||||||
exclusions = filter(lambda line : not line.startswith('!'), exclusions_file)
|
exclusions = filter(lambda line : not line.startswith('!'), exclusions_file)
|
||||||
|
|
||||||
|
@ -58,18 +59,19 @@ def save_url_rule(line, f):
|
||||||
|
|
||||||
def save_file_rule(line, f):
|
def save_file_rule(line, f):
|
||||||
file_name = line.replace('file', '').strip()
|
file_name = line.replace('file', '').strip()
|
||||||
with open(file_name, 'r') as rf:
|
with open(os.path.join(dir, file_name), 'r') as rf:
|
||||||
for rule in rf:
|
for rule in rf:
|
||||||
write_rule(rule.rstrip(), f)
|
write_rule(rule.rstrip(), f)
|
||||||
|
|
||||||
## MAIN ##
|
## MAIN ##
|
||||||
with open('filter.template', 'r') as tmpl:
|
with open(os.path.join(dir, 'filter.template'), 'r') as tmpl:
|
||||||
with open('filter.txt', 'w') as f:
|
with open(os.path.join(dir, 'filter.txt'), 'w') as f:
|
||||||
for line in tmpl:
|
for line in tmpl:
|
||||||
if line.startswith('!'):
|
if line.startswith('!'):
|
||||||
save_comment(line, f)
|
save_comment(line, f)
|
||||||
if line.startswith('url'):
|
if line.startswith('url'):
|
||||||
save_url_rule(line, f)
|
save_url_rule(line, f)
|
||||||
if line.startswith('file'):
|
if line.startswith('file'):
|
||||||
save_file_rule(line, f)
|
save_file_rule(line, f)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue