def LoadFromLines(self, lines): ''' Helper function, used only in "Album.LoadFromFile" :param line: list list of strings. List is divided into parts referring to corresponding tracks. ''' first_line, rest = lines[0], lines[1:] linesPerSingleCarRecord, blackboxesPerTrack = BuiltInTypesConverter.StringToInts( first_line) # Read one track record per single iteration while len(rest) >= 1: firstLineFromNextTrack = rest[0] numberOfRocsInNextTrack = BuiltInTypesConverter.StringToInts( firstLineFromNextTrack)[1] # Comment about line below: # " + blackboxesPerTrack" results from fact, that black box need one additional line with information which # are necessary for properly loading. We have "blackboxesPerTrack" black boxes in next track, so that # addition. # " + 1" results from fact, that track also requires one additional line. numberOfLinesForNextTrack = linesPerSingleCarRecord * numberOfRocsInNextTrack + blackboxesPerTrack + 1 track = Track() track.LoadFromLines(rest[:numberOfLinesForNextTrack]) self.AddTrack(track) # Remove already read data from rest of data to read. rest = rest[numberOfLinesForNextTrack:]
def LoadFromLines(self, lines): ''' Helper function, used only in "Album.LoadFromLines" :param line: list list of strings. List is divided into parts referring to corresponding black boxes. ''' first_line, rest = lines[0], lines[1:] linesPerSingleCarRecord = BuiltInTypesConverter.StringToInts( first_line)[0] # Read one black box record per single iteration while len(rest) >= 1: numberOfCarRecordsInNextBlackBox = BuiltInTypesConverter.StringToInts( rest[0])[0] # Comment: " + 1" on the end of next line of code results from fact, that black box need one additional line # with information which are necessary to properly loading. numberOfLinesForNextBlackBox = numberOfCarRecordsInNextBlackBox * linesPerSingleCarRecord + 1 blackbox = BlackBox() blackbox.LoadFromLines(rest[:numberOfLinesForNextBlackBox]) self.AddBlackBox(blackbox) # Remove already read data from rest of data to read. rest = rest[numberOfLinesForNextBlackBox:]
def LoadFromLine(self, line): ''' Helper function, used only in RadarRecord.LoadFromLines() :param line: str string which contains data about rangefinder in specific order ''' self.pos.x, self.pos.y, self.rot, self.posOfBarrier.x, self.posOfBarrier.y = BuiltInTypesConverter.StringToInts( line)
def LoadFromLines(self, lines): first_line, rest = lines[0], lines[1:] linesPerSingleCarRecord = BuiltInTypesConverter.StringToInts(first_line)[0] # Read one black box record per single iteration while len(rest) >= 1: numberOfCarRecordsInNextBlackBox = BuiltInTypesConverter.StringToInts(rest[0])[0] # Comment: " + 1" on the end of next line of code results from fact, that black box need one additional line # with information which are necessary to properly loading. numberOfLinesForNextBlackBox = numberOfCarRecordsInNextBlackBox * linesPerSingleCarRecord + 1 blackbox = BlackBox() blackbox.LoadFromLines(rest[:numberOfLinesForNextBlackBox]) self.AddBlackBox(blackbox) # Remove already read data from rest of data to read. rest = rest[numberOfLinesForNextBlackBox:]
def LoadFromLines(self, lines): first_line, rest = lines[0], lines[1:] # Load data about car exclusively self.pos.x, self.pos.y, self.rot = BuiltInTypesConverter.StringToInts(first_line) # Load data about radar self.radarRecord.LoadFromLines(rest)
def LoadFromLines(self, lines): first_line, rest = lines[0], lines[1:] # Load data about radar exclusively self.pos.x, self.pos.y, self.rot = BuiltInTypesConverter.StringToInts(first_line) # Load data about rangefinders for _, line in zip(range(self.__class__.numberOfRangefinderRecords), rest): rangefinderRecord = RangefinderRecord() rangefinderRecord.LoadFromLine(line) self.listOfRangefinderRecords[_] = rangefinderRecord
def LoadFromLines(self, lines): first_line, rest = lines[0], lines[1:] numberOfCarRecords = BuiltInTypesConverter.StringToInts(first_line)[0] linesPerSingleCarRecord = int(len(rest)/numberOfCarRecords) #Read one car record per single iteration while len(rest) >= 1: carRecord = CarRecord() carRecord.LoadFromLines(rest[:linesPerSingleCarRecord]) self.AddCarRecord(carRecord) #Remove already read data from rest of data to read. rest = rest[linesPerSingleCarRecord:]
def LoadFromLines(self, lines): ''' Helper function, used only in "BlackBox.LoadFromLines()" :param line: list list of strings which contains data about car in specific order ''' first_line, rest = lines[0], lines[1:] # Load data about car exclusively self.pos.x, self.pos.y, self.rot = BuiltInTypesConverter.StringToInts( first_line) # Load data about radar self.radarRecord.LoadFromLines(rest)
def LoadFromLines(self, lines): ''' Helper function, used only in CarRecord.LoadFromLines() :param lines: list list of strings which contains data about radar in specific order ''' first_line, rest = lines[0], lines[1:] # Load data about radar exclusively self.pos.x, self.pos.y, self.rot = BuiltInTypesConverter.StringToInts( first_line) # Load data about rangefinders for _, line in zip(range(self.__class__.numberOfRangefinderRecords), rest): rangefinderRecord = RangefinderRecord() rangefinderRecord.LoadFromLine(line) self.listOfRangefinderRecords[_] = rangefinderRecord
def LoadFromLines(self, lines): ''' Helper function, used only in "Track.LoadFromLines()" :param line: list list of strings. List is divided into parts referring to corresponding car records. ''' first_line, rest = lines[0], lines[1:] numberOfCarRecords = BuiltInTypesConverter.StringToInts(first_line)[0] linesPerSingleCarRecord = int(len(rest) / numberOfCarRecords) #Read one car record per single iteration while len(rest) >= 1: carRecord = CarRecord() carRecord.LoadFromLines(rest[:linesPerSingleCarRecord]) self.AddCarRecord(carRecord) #Remove already read data from rest of data to read. rest = rest[linesPerSingleCarRecord:]
def test_1(self): line = "122 123 124" self.assertEqual(BuiltInTypesConverter.StringToInts(line), [122, 123, 124])
def LoadFromLine(self, line): self.pos.x, self.pos.y, self.rot, self.posOfBarrier.x, self.posOfBarrier.y = BuiltInTypesConverter.StringToInts(line)