def get_external_base_image(self, image, stack=None):
if stack is None:<EOL><INDENT>stack = list()<EOL><DEDENT>mydef = self.ymldefs[image]<EOL>if image in stack:<EOL><INDENT>stack.append(image)<EOL>raise errors.CircularDependencyError('<STR_LIT>' + '<STR_LIT>'.join(stack))<EOL><DEDENT>stack.append(image)<EOL>if '<STR_LIT>' in mydef and '<STR_LIT>' in mydef:<EOL><INDENT>raise errors.MultipleBaseError(<EOL>'<STR_LIT>' % image +<EOL>'<STR_LIT>')<EOL><DEDENT>if '<STR_LIT>' in mydef:<EOL><INDENT>externalbase = mydef['<STR_LIT>']<EOL><DEDENT>elif '<STR_LIT>' in mydef:<EOL><INDENT>path = mydef['<STR_LIT>']<EOL>if path not in self._external_dockerfiles:<EOL><INDENT>self._external_dockerfiles[path] = ExternalDockerfile(path)<EOL><DEDENT>externalbase = self._external_dockerfiles[path]<EOL><DEDENT>else:<EOL><INDENT>externalbase = None<EOL><DEDENT>requires = mydef.get('<STR_LIT>', [])<EOL>if not isinstance(requires, list):<EOL><INDENT>raise errors.InvalidRequiresList('<STR_LIT>' % image)<EOL><DEDENT>for base in requires:<EOL><INDENT>try:<EOL><INDENT>otherexternal = self.get_external_base_image(base, stack)<EOL><DEDENT>except ValueError:<EOL><INDENT>continue<EOL><DEDENT>if externalbase is None:<EOL><INDENT>externalbase = otherexternal<EOL><DEDENT>elif otherexternal is None:<EOL><INDENT>continue<EOL><DEDENT>elif externalbase != otherexternal:<EOL><INDENT>raise errors.ConflictingBaseError(<EOL>'<STR_LIT>' % image +<EOL>'<STR_LIT>' % (image, externalbase) +<EOL>'<STR_LIT>' % (base, otherexternal))<EOL><DEDENT><DEDENT>assert stack.pop() == image<EOL>return externalbase<EOL>
Makes sure that this image has exactly one unique external base image