Changeset 1f6a573 for fedd/federation/access.py
- Timestamp:
- Nov 30, 2010 4:45:00 PM (13 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master
- Children:
- 4692a16
- Parents:
- c002cb2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/federation/access.py
rc002cb2 r1f6a573 53 53 self.value = value 54 54 self.priority = pri 55 def __str__(self): 56 return "%s: %s (%d)" % (self.attr, self.value, self.priority) 55 57 56 58 def __init__(self, config=None, auth=None): … … 140 142 """ 141 143 142 map_re = re.compile("(\S+)\s+->\s+(.*)"); 144 map_re = re.compile("(\S+)\s+->\s+(.*)") 145 priority_re = re.compile("([^,]+),\s*(\d+)") 146 143 147 if access_obj is None: 144 148 access_obj = lambda(x): "%s" % x 145 149 146 150 self.access = [] 151 priorities = { } 147 152 148 153 f = open(fn, 'r') … … 160 165 continue 161 166 167 # If a priority is found, collect them 168 m = priority_re.match(line) 169 if m: 170 try: 171 priorities[m.group(1)] = int(m.group(2)) 172 except ValueError, e: 173 if self.log: 174 self.log.debug("Bad priority in %s line %d" % \ 175 (fn, lineno)) 176 continue 177 162 178 # Nothing matched to here: unknown line - raise exception 163 179 # (finally will close f) … … 167 183 finally: 168 184 if f: f.close() 185 186 # Set priorities 187 for a in self.access: 188 if a.attr in priorities: 189 a.priority = priorities[a.attr] 169 190 170 191 def write_state(self):
Note: See TracChangeset
for help on using the changeset viewer.