当前位置: 首页>>代码示例>>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;未经允许,请勿转载。