# Path: modules/myhyphen.py
# class MyHyphen:
#     def __init__(self, language):
#         self.hyphenator = hyphen.Hyphenator(language=language, directory=DICTIONARIES_DIR)
# 
#     def process_text(self, text, replace_nbsp, separators):
#         if not separators:
#             if len(text) >= 100:
#                 return text
#             syl = self.hyphenator.syllables(text)
#             return text if not syl else SOFT_HYPHEN.join(syl)
#         else:
#             res = []
#             head, *tail = separators
#             for part in str.split(text, head):
#                 res.append(self.process_text(part, replace_nbsp, tail))
#             head = head if not replace_nbsp or not head == NON_BREAKING_SPACE else ' '
#             return head.join(res)
# 
#     def set_language(self, language):
#         self.hyphenator = hyphen.Hyphenator(language=language, directory=DICTIONARIES_DIR)
# 
#     def hyphenate_text(self, text, replace_nbsp=False):
#         return self.process_text(text, replace_nbsp, WORD_SEPARATORS)


import os
import html
import uuid
from lxml import etree
from slugify import slugify
from modules.myhyphen import MyHyphen
# -*- coding: utf-8 -*-




def save_html(string):
    if string:
        return html.escape(string, quote=False)
    else:
        return ''


class EpubProc:
    def __init__(self, opffile, config):
        self.buff = []

        self.book_title = ''  # Название книги
        self.book_author = ''  # Автор
        self.book_series = ''  # Книжная серия
        self.book_series_num = ''  # Номер в книжной серии

        self.book_lang = 'ru'

        self.hyphenate = config.current_profile['hyphens']
        if self.hyphenate:
            self.replaceNBSP = config.current_profile['hyphensReplaceNBSP']
            self.hyphenator = MyHyphen(self.book_lang)


# Path: modules/myhyphen.py
# class MyHyphen:
#     def __init__(self, language):
#         self.hyphenator = hyphen.Hyphenator(language=language, directory=DICTIONARIES_DIR)
# 
#     def process_text(self, text, replace_nbsp, separators):
#         if not separators:
#             if len(text) >= 100:
#                 return text
#             syl = self.hyphenator.syllables(text)
#             return text if not syl else SOFT_HYPHEN.join(syl)
#         else:
#             res = []
#             head, *tail = separators
#             for part in str.split(text, head):
#                 res.append(self.process_text(part, replace_nbsp, tail))
#             head = head if not replace_nbsp or not head == NON_BREAKING_SPACE else ' '
#             return head.join(res)
# 
#     def set_language(self, language):
#         self.hyphenator = hyphen.Hyphenator(language=language, directory=DICTIONARIES_DIR)
# 
#     def hyphenate_text(self, text, replace_nbsp=False):
#         return self.process_text(text, replace_nbsp, WORD_SEPARATORS)


# Path: modules/epub.py
import os
import html
import uuid
from lxml import etree
from slugify import slugify
from modules.myhyphen import MyHyphen

# -*- coding: utf-8 -*-




def save_html(string):
    if string:
        return html.escape(string, quote=False)
    else:
        return ''


class EpubProc:
    def __init__(self, opffile, config):
        self.buff = []

        self.book_title = ''  # Название книги
        self.book_author = ''  # Автор
        self.book_series = ''  # Книжная серия
        self.book_series_num = ''  # Номер в книжной серии

        self.book_lang = 'ru'

        self.hyphenate = config.current_profile['hyphens']
        if self.hyphenate:
            self.replaceNBSP = config.current_profile['hyphensReplaceNBSP']
            self.hyphenator = MyHyphen(self.book_lang)


        self.opffile = opffile