def readSubmodules(self): submodules = [] if self.ref: submodules = resolver.readSubmodules() print 'DEPS file provides the following submodules:' for submodule in submodules: print '{:<80}'.format(submodule.path) + '{:<120}'.format( submodule.url) + submodule.ref else: # Try .gitmodules since no ref has been specified if not os.path.isfile('.gitmodules'): return [] gitmodules_file = open('.gitmodules') gitmodules_lines = gitmodules_file.readlines() gitmodules_file.close() submodules = [] currentSubmodule = None for line in gitmodules_lines: if line.find('[submodule') == 0: if currentSubmodule: submodules.append(currentSubmodule) currentSubmodule = Submodule() tokens = line.split('=') if len(tokens) >= 2: key = tokens[0].strip() value = tokens[1].strip() if key == 'path': currentSubmodule.path = value elif key == 'url': currentSubmodule.url = value elif key == 'os': currentSubmodule.os = value.split(',') if currentSubmodule: submodules.append(currentSubmodule) return submodules
def readSubmodules(self): submodules = [] if self.ref: submodules = resolver.readSubmodules() print 'DEPS file provides the following submodules:' for submodule in submodules: print '{:<80}'.format(submodule.path) + '{:<120}'.format(submodule.url) + submodule.ref else: # Try .gitmodules since no ref has been specified if not os.path.isfile('.gitmodules'): return [] gitmodules_file = open('.gitmodules') gitmodules_lines = gitmodules_file.readlines() gitmodules_file.close() submodules = [] currentSubmodule = None for line in gitmodules_lines: if line.find('[submodule') == 0: if currentSubmodule: submodules.append(currentSubmodule) currentSubmodule = Submodule() tokens = line.split('=') if len(tokens) >= 2: key = tokens[0].strip() value = tokens[1].strip() if key == 'path': currentSubmodule.path = value elif key == 'url': currentSubmodule.url = value elif key == 'os': currentSubmodule.os = value.split(',') if currentSubmodule: submodules.append(currentSubmodule) return submodules
def readSubmodules(self, use_deps=False): submodules = [] if use_deps: submodules = resolver.readSubmodules() print 'DEPS file provides the following submodules:' for submodule in submodules: print '{:<80}'.format( submodule.pathRelativeToTopMostSupermodule( )) + '{:<120}'.format(submodule.url) + submodule.ref else: # Try .gitmodules instead gitmodules_file_name = '.gitmodules' submodules = self.readSubmodulesFromGitModules( self, gitmodules_file_name, self.path) return submodules
def readSubmodules(self): submodules = [] if self.ref: submodules = resolver.readSubmodules() print 'DEPS file provides the following submodules:' for submodule in submodules: print '{:<80}'.format( submodule.pathRelativeToTopMostSupermodule( )) + '{:<120}'.format(submodule.url) + submodule.ref else: # Try .gitmodules since no ref has been specified gitmodules_file_name = '.gitmodules' submodules = self.readSubmodulesFromGitModules( self, gitmodules_file_name, self.path) return submodules