當前位置: 首頁>>代碼示例>>Python>>正文


Python dominate.document方法代碼示例

本文整理匯總了Python中dominate.document方法的典型用法代碼示例。如果您正苦於以下問題:Python dominate.document方法的具體用法?Python dominate.document怎麽用?Python dominate.document使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在dominate的用法示例。


在下文中一共展示了dominate.document方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: import dominate [as 別名]
# 或者: from dominate import document [as 別名]
def __init__(self, web_dir, title, refresh=0):
        """Initialize the HTML classes

        Parameters:
            web_dir (str) -- a directory that stores the webpage. HTML file will be created at <web_dir>/index.html; images will be saved at <web_dir/images/
            title (str)   -- the webpage name
            refresh (int) -- how often the website refresh itself; if 0; no refreshing
        """
        self.title = title
        self.web_dir = web_dir
        self.img_dir = os.path.join(self.web_dir, 'images')
        if not os.path.exists(self.web_dir):
            os.makedirs(self.web_dir)
        if not os.path.exists(self.img_dir):
            os.makedirs(self.img_dir)

        self.doc = dominate.document(title=title)
        if refresh > 0:
            with self.doc.head:
                meta(http_equiv="refresh", content=str(refresh)) 
開發者ID:Mingtzge,項目名稱:2019-CCF-BDCI-OCR-MCZJ-OCR-IdentificationIDElement,代碼行數:22,代碼來源:html.py

示例2: __init__

# 需要導入模塊: import dominate [as 別名]
# 或者: from dominate import document [as 別名]
def __init__(self, web_dir, title, image_subdir='', reflesh=0):
        self.title = title
        self.web_dir = web_dir
        # self.img_dir = os.path.join(self.web_dir, )
        self.img_subdir = image_subdir
        self.img_dir = os.path.join(self.web_dir, image_subdir)
        if not os.path.exists(self.web_dir):
            os.makedirs(self.web_dir)
        if not os.path.exists(self.img_dir):
            os.makedirs(self.img_dir)
        # print(self.img_dir)

        self.doc = dominate.document(title=title)
        if reflesh > 0:
            with self.doc.head:
                meta(http_equiv="reflesh", content=str(reflesh)) 
開發者ID:richzhang,項目名稱:PerceptualSimilarity,代碼行數:18,代碼來源:html.py

示例3: generate_html

# 需要導入模塊: import dominate [as 別名]
# 或者: from dominate import document [as 別名]
def generate_html(paragraphs, title_text):
    doc = dominate.document(title='Summary: {}'.format(title_text))

    with doc.head:
        style("""\
            body {
                background-color: #F9F8F1;
                color: #2C232A;
                font-family: sans-serif;
                font-size: 1.2em;
            }

        """)

    with doc:
        div(id='header').add(h1(title_text))
        with div():
            attr(cls='body')
            for para in paragraphs:
                tb = TextBlob(para)
                with p():
                    for sentence in tb.sentences:
                        span(sentence, style="color: {}".format(get_polarity_color(sentence.polarity)))
    return doc 
開發者ID:hiway,項目名稱:python-qutescript,代碼行數:26,代碼來源:sentimark.py

示例4: generate_html

# 需要導入模塊: import dominate [as 別名]
# 或者: from dominate import document [as 別名]
def generate_html(sentences, title_text):
    doc = dominate.document(title='Summary: {}'.format(title_text))

    with doc.head:
        style("""\
            body {
                background-color: #F9F8F1;
                color: #2C232A;
                font-family: sans-serif;
                font-size: 2.6em;
                margin: 3em 1em;
            }
            
        """)

    with doc:
        div(id='header').add(h1(title_text))
        with div():
            attr(cls='body')
            for sentence in sentences:
                p(sentence)

    return doc 
開發者ID:hiway,項目名稱:python-qutescript,代碼行數:25,代碼來源:summarize.py

示例5: summarize_text

# 需要導入模塊: import dominate [as 別名]
# 或者: from dominate import document [as 別名]
def summarize_text(request):
    if request.html:
        parser = HtmlParser.from_file(file_path=request.html,
                                      url=request.url,
                                      tokenizer=Tokenizer(LANGUAGE))
    else:
        parser = PlaintextParser.from_file(file_path=request.html,
                                           tokenizer=Tokenizer(LANGUAGE))

    stemmer = Stemmer(LANGUAGE)

    summarizer = Summarizer(stemmer)
    summarizer.stop_words = get_stop_words(LANGUAGE)
    sentences = [fix_text(str(s)) for s in summarizer(parser.document, SENTENCES_COUNT)]
    html = generate_html(sentences, fix_text(request.title)).render()
    request.send_html(html) 
開發者ID:hiway,項目名稱:python-qutescript,代碼行數:18,代碼來源:summarize.py

示例6: __init__

# 需要導入模塊: import dominate [as 別名]
# 或者: from dominate import document [as 別名]
def __init__(self, web_dir, title, reflesh=0):
        self.title = title
        self.web_dir = web_dir
        self.img_dir = os.path.join(self.web_dir, 'images')
        if not os.path.exists(self.web_dir):
            os.makedirs(self.web_dir)
        if not os.path.exists(self.img_dir):
            os.makedirs(self.img_dir)
        # print(self.img_dir)

        self.doc = dominate.document(title=title)
        if reflesh > 0:
            with self.doc.head:
                meta(http_equiv="reflesh", content=str(reflesh)) 
開發者ID:ozan-oktay,項目名稱:Attention-Gated-Networks,代碼行數:16,代碼來源:html.py

示例7: __init__

# 需要導入模塊: import dominate [as 別名]
# 或者: from dominate import document [as 別名]
def __init__(self, web_fold, t):
        self.title = t
        self.web_fold = web_fold
        self.img_fold = os.path.join(self.web_fold, 'images')
        if not os.path.exists(self.web_fold):
            os.makedirs(self.web_fold)
        if not os.path.exists(self.img_fold):
            os.makedirs(self.img_fold)
        print(self.img_fold)
        self.doc = dominate.document(title=t) 
開發者ID:junyanz,項目名稱:iGAN,代碼行數:12,代碼來源:html.py

示例8: __init__

# 需要導入模塊: import dominate [as 別名]
# 或者: from dominate import document [as 別名]
def __init__(self, web_dir, title, refresh=0):
        self.title = title
        self.web_dir = web_dir
        self.img_dir = os.path.join(self.web_dir, 'images')
        if not os.path.exists(self.web_dir):
            os.makedirs(self.web_dir)
        if not os.path.exists(self.img_dir):
            os.makedirs(self.img_dir)

        self.doc = dominate.document(title=title)
        if refresh > 0:
            with self.doc.head:
                meta(http_equiv="refresh", content=str(refresh)) 
開發者ID:laughtervv,項目名稱:DepthAwareCNN,代碼行數:15,代碼來源:html.py

示例9: __init__

# 需要導入模塊: import dominate [as 別名]
# 或者: from dominate import document [as 別名]
def __init__(self, html_file='./index.html', refresh=0):
        self.html_file = html_file
        self.doc = dominate.document(title='simple_html')
        if refresh > 0:
            with self.doc.head:
                meta(http_equiv="reflesh", content=str(refresh)) 
開發者ID:liruilong940607,項目名稱:Pose2Seg,代碼行數:8,代碼來源:html.py

示例10: __init__

# 需要導入模塊: import dominate [as 別名]
# 或者: from dominate import document [as 別名]
def __init__(self, web_dir, title, reflesh=0):
        self.title = title
        self.web_dir = web_dir
        self.img_dir = os.path.join(self.web_dir, 'images')
        if not os.path.exists(self.web_dir):
            os.makedirs(self.web_dir)
        if not os.path.exists(self.img_dir):
            os.makedirs(self.img_dir)
        # print(self.img_dir)

        self.doc = dominate.document(title=title)
        if reflesh > 0:
            with self.doc.head:
                meta(http_equiv="reflesh", content=str(reflesh))
        self.t = None 
開發者ID:alexlee-gk,項目名稱:video_prediction,代碼行數:17,代碼來源:html.py


注:本文中的dominate.document方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。