| Home | Trees | Indices | Help |
|
|---|
|
|
1 # Copyright (c) 2004-2008 rPath, Inc. 2 # 3 # This program is distributed under the terms of the Common Public License, 4 # version 1.0. A copy of this license should have been distributed with this 5 # source file in a file called LICENSE. If it is not present, the license 6 # is always available at http://www.rpath.com/permanent/licenses/CPL-1.0. 7 # 8 # This program is distributed in the hope that it will be useful, but 9 # without any warranty; without even the implied warranty of merchantability 10 # or fitness for a particular purpose. See the Common Public License for 11 # full details. 12 # 13 """ 14 Implements conaryrc handling. 15 """ 16 import fnmatch 17 import os 18 import sys 19 import xml 20 import re 21 import traceback 22 import pwd 23 24 from conary.deps import deps, arch 25 from conary.lib import util 26 from conary.lib.cfg import * 27 from conary import errors 28 from conary import versions 29 from conary import flavorcfg 30 31 # ----------- conary specific types 3234 35 multipleMatches = False 369838 l = [] 39 for (serverGlob, item) in ServerGlobList.__iter__(self): 40 # this is case insensitve, which is perfect for hostnames 41 if fnmatch.fnmatch(server, serverGlob): 42 if not self.multipleMatches: 43 return item 44 l.append(item) 45 46 if not self.multipleMatches: 47 return None 48 49 return l5052 # Comparison function 53 # Equal elements 54 if a[0] == b[0]: 55 return 0 56 if fnmatch.fnmatch(a[0], b[0]): 57 return -1 58 return 15961 # Look for the first item which globs to this, and insert the new 62 # item before it. That makes sure find always matches on the 63 # most-specific instance 64 for newItem in reversed(itemList): 65 self.append(newItem)6668 """Extend the current list with the new items, categorizing them and 69 eliminating duplicates""" 70 nlist = sorted(self + [ x for x in reversed(itemList)], self._fncmp) 71 # Walk the list, remove duplicates 72 del self[:] 73 74 lasti = None 75 for ent in nlist: 76 if lasti is not None and lasti[0] == ent[0]: 77 self[-1] = ent 78 else: 79 list.append(self, ent) 80 lasti = ent8183 location = None 84 removeOld = False 85 for i, (serverGlob, info) in enumerate(ServerGlobList.__iter__(self)): 86 if fnmatch.fnmatch(newItem[0], serverGlob): 87 if not self.multipleMatches and serverGlob == newItem[0]: 88 removeOld = True 89 location = i 90 break 91 92 if location is None: 93 list.append(self, newItem) 94 elif removeOld: 95 self[location] = newItem 96 else: 97 self.insert(location, newItem)100 104106 # handle (glob, name, passwd) and transform to (glob, (name, passwd))a 107 if len(args) == 3: 108 args = args[0], (args[1], args[2]) 109 ServerGlobList.append(self, args)110 113 117119 self.addServerGlob(*item)120122 if len(item) == 3: 123 item = (item[0], (item[1], item[2])) 124 ServerGlobList.remove(self, item)125127 if len(item) == 3: 128 item = (item[0], (item[1], item[2])) 129 ServerGlobList.insert(self, pos, item)130