| OLD | NEW |
| (Empty) |
| 1 from buildbot.util import now, safeTranslate | |
| 2 | |
| 3 | |
| 4 class BuilderConfig: | |
| 5 """ | |
| 6 | |
| 7 Used in config files to specify a builder - this can be subclassed by users | |
| 8 to add extra config args, set defaults, or whatever. It is converted to a | |
| 9 dictionary for consumption by the buildmaster at config time. | |
| 10 | |
| 11 """ | |
| 12 | |
| 13 def __init__(self, | |
| 14 name=None, | |
| 15 slavename=None, | |
| 16 slavenames=None, | |
| 17 builddir=None, | |
| 18 slavebuilddir=None, | |
| 19 factory=None, | |
| 20 category=None, | |
| 21 nextSlave=None, | |
| 22 nextBuild=None, | |
| 23 locks=None, | |
| 24 env=None): | |
| 25 | |
| 26 # name is required, and can't start with '_' | |
| 27 if not name or type(name) is not str: | |
| 28 raise ValueError("builder's name is required") | |
| 29 if name[0] == '_': | |
| 30 raise ValueError("builder names must not start with an " | |
| 31 "underscore: " + name) | |
| 32 self.name = name | |
| 33 | |
| 34 # factory is required | |
| 35 if factory is None: | |
| 36 raise ValueError("builder's factory is required") | |
| 37 self.factory = factory | |
| 38 | |
| 39 # slavenames can be a single slave name or a list, and should also | |
| 40 # include slavename, if given | |
| 41 if type(slavenames) is str: | |
| 42 slavenames = [ slavenames ] | |
| 43 if slavenames: | |
| 44 if type(slavenames) is not list: | |
| 45 raise TypeError("slavenames must be a list or a string") | |
| 46 else: | |
| 47 slavenames = [] | |
| 48 if slavename: | |
| 49 if type(slavename) != str: | |
| 50 raise TypeError("slavename must be a string") | |
| 51 slavenames = slavenames + [ slavename ] | |
| 52 if not slavenames: | |
| 53 raise ValueError("at least one slavename is required") | |
| 54 self.slavenames = slavenames | |
| 55 | |
| 56 # builddir defaults to name | |
| 57 if builddir is None: | |
| 58 builddir = safeTranslate(name) | |
| 59 self.builddir = builddir | |
| 60 | |
| 61 # slavebuilddir defaults to builddir | |
| 62 if slavebuilddir is None: | |
| 63 slavebuilddir = builddir | |
| 64 self.slavebuilddir = slavebuilddir | |
| 65 | |
| 66 # remainder are optional | |
| 67 self.category = category | |
| 68 self.nextSlave = nextSlave | |
| 69 self.nextBuild = nextBuild | |
| 70 self.locks = locks | |
| 71 self.env = env | |
| 72 | |
| 73 def getConfigDict(self): | |
| 74 rv = { | |
| 75 'name': self.name, | |
| 76 'slavenames': self.slavenames, | |
| 77 'factory': self.factory, | |
| 78 'builddir': self.builddir, | |
| 79 'slavebuilddir': self.slavebuilddir, | |
| 80 } | |
| 81 if self.category: | |
| 82 rv['category'] = self.category | |
| 83 if self.nextSlave: | |
| 84 rv['nextSlave'] = self.nextSlave | |
| 85 if self.nextBuild: | |
| 86 rv['nextBuild'] = self.nextBuild | |
| 87 if self.locks: | |
| 88 rv['locks'] = self.locks | |
| 89 if self.env: | |
| 90 rv['env'] = self.env | |
| 91 return rv | |
| OLD | NEW |