Git repository of Karesansui.
Revision | 5b091f0b7ce8a3abab661e1c704805560e74ea0a (tree) |
---|---|
Time | 2011-05-06 14:07:13 |
Author | ![]() |
Commiter | Junichi Shinohara |
modified to change the hosts file path.
@@ -29,7 +29,7 @@ class hostsParser: | ||
29 | 29 | |
30 | 30 | _module = "hosts" |
31 | 31 | |
32 | - def __init__(self): | |
32 | + def __init__(self, paths=None): | |
33 | 33 | self.dop = DictOp() |
34 | 34 | self.dop.addconf(self._module,{}) |
35 | 35 |
@@ -38,20 +38,24 @@ class hostsParser: | ||
38 | 38 | self.parser.set_new_delim("\t") |
39 | 39 | self.parser.set_comment("#") |
40 | 40 | self.base_parser_name = self.parser.__class__.__name__ |
41 | - pass | |
41 | + | |
42 | + if paths is None: | |
43 | + self.paths = PARSER_HOSTS_CONF | |
44 | + else: | |
45 | + self.paths = paths | |
42 | 46 | |
43 | 47 | def source_file(self): |
44 | - retval = [PARSER_HOSTS_CONF] | |
48 | + retval = [self.paths] | |
45 | 49 | |
46 | 50 | return retval |
47 | 51 | |
48 | 52 | def read_conf(self,extra_args=None): |
49 | 53 | retval = {} |
50 | 54 | |
51 | - self.parser.set_source_file([PARSER_HOSTS_CONF]) | |
55 | + self.parser.set_source_file([self.paths]) | |
52 | 56 | conf_arr = self.parser.read_conf() |
53 | 57 | try: |
54 | - self.dop.addconf(self._module,conf_arr[PARSER_HOSTS_CONF]['value']) | |
58 | + self.dop.addconf(self._module,conf_arr[self.paths]['value']) | |
55 | 59 | except: |
56 | 60 | pass |
57 | 61 |
@@ -64,7 +68,7 @@ class hostsParser: | ||
64 | 68 | |
65 | 69 | try: |
66 | 70 | self.dop.addconf("parser",{}) |
67 | - self.dop.set("parser",[PARSER_HOSTS_CONF],conf_arr) | |
71 | + self.dop.set("parser",[self.paths],conf_arr) | |
68 | 72 | #self.dop.preprint_r("parser") |
69 | 73 | arr = self.dop.getconf("parser") |
70 | 74 | self.parser.write_conf(arr,dryrun=dryrun) |