def create_guide(self): guide = Guide() has_start = False for ref_type, ref_title, pos_fid in self.guide: try: if len(pos_fid) != 2: continue except TypeError: continue # thumbnailstandard record, ignore it linktgt, idtext = self.get_id_tag_by_pos_fid(*pos_fid) if idtext: linktgt += b'#' + idtext g = Guide.Reference(linktgt, os.getcwdu()) g.title, g.type = ref_title, ref_type if g.title == 'start' or g.type == 'text': has_start = True guide.append(g) so = self.header.exth.start_offset if so not in {None, NULL_INDEX} and not has_start: fi = self.get_file_info(so) if fi.filename is not None: idtext = self.get_id_tag(so).decode(self.header.codec) linktgt = fi.filename if idtext: linktgt += '#' + idtext g = Guide.Reference('%s/%s'%(fi.type, linktgt), os.getcwdu()) g.title, g.type = 'start', 'text' guide.append(g) return guide
def create_guide(self): guide = Guide() has_start = False for ref_type, ref_title, pos_fid in self.guide: try: if len(pos_fid) != 2: continue except TypeError: continue # thumbnailstandard record, ignore it linktgt, idtext = self.get_id_tag_by_pos_fid(*pos_fid) if idtext: linktgt += b'#' + idtext g = Guide.Reference(linktgt, os.getcwdu()) g.title, g.type = ref_title, ref_type if g.title == 'start' or g.type == 'text': has_start = True guide.append(g) so = self.header.exth.start_offset if so not in {None, NULL_INDEX} and not has_start: fi = self.get_file_info(so) if fi.filename is not None: idtext = self.get_id_tag(so).decode(self.header.codec) linktgt = fi.filename if idtext: linktgt += '#' + idtext g = Guide.Reference('%s/%s' % (fi.type, linktgt), os.getcwdu()) g.title, g.type = 'start', 'text' guide.append(g) return guide