def make_nikaya(sutra_urls): nikaya = MyNikaya() nikaya.title_chinese = '相應部' nikaya.title_pali = 'Saṃyutta Nikāya', nikaya.abbreviation = 'SN' for url in sutra_urls: chinese, pali, modified = read_text(url) header_lines, main_lines = split_chinese_lines(chinese) info = analyse_header(header_lines) if info.pian_serial is not None: if not nikaya.subs or nikaya.subs[-1].serial != info.pian_serial: pian = Pian() pian.serial = info.pian_serial pian.title = info.pian_title nikaya.subs.append(pian) if info.xiangying_serial is not None: if not nikaya.subs[-1].subs or nikaya.subs[-1].subs[-1].serial != info.xiangying_serial: xiangying = XiangYing() xiangying.serial = info.xiangying_serial xiangying.title = info.xiangying_title xiangying.sec_title = '{} {}'.format(xiangying.serial, xiangying.title) nikaya.subs[-1].subs.append(xiangying) if info.pin_serial is not None: if not nikaya.subs[-1].subs[-1].subs or nikaya.subs[-1].subs[-1].subs[-1].serial != info.pin_serial: pin = Pin() pin.serial = info.pin_serial pin.title = info.pin_title nikaya.subs[-1].subs[-1].subs.append(pin) if not nikaya.pians[-1].xiangyings[-1].pins: pin = Pin() pin.serial = 1 pin.title = '(未分品)' nikaya.pians[-1].xiangyings[-1].pins.append(pin) sutra = Sutra() sutra.serial_start = info.sutra_serial_start sutra.serial_end = info.sutra_serial_end sutra.pali = pali sutra.chinese = chinese sutra.main_lines = main_lines sutra.modified = modified if sutra.serial_start == sutra.serial_end: sutra.serial = sutra.serial_start else: sutra.serial = '{}-{}'.format(sutra.serial_start, sutra.serial_end) if info.sutra_title: sutra.title = info.sutra_title else: sutra.title = '' if sutra.title: sutra.sec_title = sutra.serial + ' ' + sutra.title else: sutra.sec_title = sutra.serial sutra.abbreviation = '{}.{}.{}'.format(nikaya.abbreviation, nikaya.pians[-1].xiangyings[-1].serial, sutra.serial) nikaya.pians[-1].xiangyings[-1].pins[-1].sutras.append(sutra) return nikaya
def make_nikaya(sutra_urls): nikaya = _MyNikaya() nikaya.title_chinese = '中部' nikaya.title_pali = 'Majjhima Nikāya', nikaya.abbreviation = 'MN' for url in sutra_urls: chinese, pali, modified = read_text(url) header_lines, main_lines = split_chinese_lines(chinese) info = analyse_header(header_lines) if info.pin_serial is not None: if not nikaya.pins or nikaya.pins[-1].serial != info.pin_serial: pin = _Pin() pin.serial = info.pin_serial pin.title = info.pin_title nikaya.pins.append(pin) sutra = Sutra() sutra.serial_start = info.sutra_serial_start sutra.serial_end = info.sutra_serial_end sutra.pali = pali sutra.chinese = chinese sutra.main_lines = main_lines sutra.modified = modified sutra.serial = sutra.serial_start sutra.title = info.sutra_title sutra.sec_title = sutra.serial + ' ' + sutra.title sutra.abbreviation = '{}.{}'.format(nikaya.abbreviation, sutra.serial) nikaya.pins[-1].sutras.append(sutra) return nikaya
def make_nikaya(sutra_urls): nikaya = MyNikaya() nikaya.title_chinese = "增支部" nikaya.title_pali = ("Aṅguttara nikāya",) nikaya.abbreviation = "AN" for url in sutra_urls: chinese, pali, modified = read_text(url) header_lines, main_lines = split_chinese_lines(chinese) info = analyse_header(header_lines) if info.ji_serial is not None: if not nikaya.jis or nikaya.jis[-1].serial != info.ji_serial: ji = Ji() ji.serial = info.ji_serial nikaya.jis.append(ji) if info.pin_serial is not None: if not nikaya.jis[-1].pins or nikaya.jis[-1].pins[-1].serial != info.pin_serial: pin = Pin() pin.serial = info.pin_serial pin.title = info.pin_title nikaya.jis[-1].pins.append(pin) sutra = Sutra() sutra.serial_start = info.sutra_serial_start sutra.serial_end = info.sutra_serial_end sutra.pali = pali sutra.chinese = chinese sutra.main_lines = main_lines sutra.modified = modified if sutra.serial_start == sutra.serial_end: sutra.serial = sutra.serial_start else: sutra.serial = "{}-{}".format(sutra.serial_start, sutra.serial_end) if info.sutra_title: sutra.title = info.sutra_title else: sutra.title = "" if sutra.title: sutra.sec_title = sutra.serial + " " + sutra.title else: sutra.sec_title = sutra.serial sutra.abbreviation = "{}.{}.{}".format(nikaya.abbreviation, nikaya.jis[-1].serial, sutra.serial) nikaya.jis[-1].pins[-1].sutras.append(sutra) return nikaya