• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python yattag.Doc类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中yattag.Doc的典型用法代码示例。如果您正苦于以下问题:Python Doc类的具体用法?Python Doc怎么用?Python Doc使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Doc类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: as_xml

    def as_xml(self, indentation=False):
        doc, tag, text = Doc().tagtext()
        with tag('shell', xmlns="uri:oozie:shell-action:0.2"):
            #do we actually need these even if we dont use them?
            with tag('job-tracker'):
                text(os.environ["JOBTRACKER"])
            with tag('name-node'):
                text(os.environ["NAMENODE"])

            with tag('exec'):
                text(self.command)
            for argument in self.arguments:
                with tag('argument'):
                    text(argument)
            for env in self.environment_vars:
                with tag('env-var'):
                    text(env)
            for archive in self.archives:
                with tag('archive'):
                    text(archive)
            for f in self.files:
                with tag('file'):
                    text(f)

        xml = doc.getvalue()
        if indentation:
            return indent(xml)
        else:
            return xml
开发者ID:orenmazor,项目名称:oozie.py,代码行数:29,代码来源:actions.py


示例2: submit

    def submit(self, bund, files=[]):
        hdfs = PyWebHdfsClient(host=os.environ["WEBHDFS_HOST"], port='14000', user_name='oozie')

        for f in files:
            hdfs.create_file("{}/{}".format(bund.path, f.name), f.read())  

        doc, tag, text = Doc().tagtext()
        with tag("configuration"):
            with tag("property"):
                with tag("name"):
                    text("user.name")
                with tag("value"):
                    text("oozie")

            with tag("property"):
                with tag("name"):
                    text("oozie.bundle.application.path")
                with tag("value"):
                    text("/"+bund.path + "/" + bund.name)

        configuration = doc.getvalue()
        response = post("{0}/oozie/v1/jobs".format(self.url), data=configuration, headers={'Content-Type': 'application/xml'})

        if response.status_code > 399:
            print response.headers["oozie-error-message"]
        print response.status_code
        print response.content
开发者ID:orenmazor,项目名称:oozie.py,代码行数:27,代码来源:oozie_server.py


示例3: _repr_html_

 def _repr_html_(self):
     doc, tag, txt = Doc().tagtext()
     with tag("div", klass="tree-node tree-leaf"):
         self._label_html(doc)
         with tag("span", klass="tree-text"):
             txt(self.text)
     return doc.getvalue()
开发者ID:aecay,项目名称:lovett,代码行数:7,代码来源:tree.py


示例4: now_playing

def now_playing(request, data):
    sk = data['sk']
    session = Session.load(sk)
    if not session:
        print "Invalid session"
        return "NOPE"

    track   = data['track']
    artist  = data['artist']
    album   = data['album']
    albumArtist   = data['albumArtist']
    
    print "NOW PLAYING- User: %s, Artist: %s, Track: %s, Album: %s"  \
        % (session.user.name, artist, track, album)

    doc, tag, text = Doc().tagtext()
    with tag('lfm', status="ok"):
        with tag('nowplaying'):
            with tag('track', corrected="0"):
                text(track)
            with tag('artist', corrected="0"):
                text(artist)
            with tag('album', corrected="0"):
                text(album)
            with tag('albumArtist', corrected="0"):
                text(albumArtist)
            with tag('ignoredMessage', code="0"):
                text('')

    return '<?xml version="1.0" encoding="utf-8"?>\n' + yattag.indent(doc.getvalue())
开发者ID:pinkeshbadjatiya,项目名称:scrobbleproxy,代码行数:30,代码来源:scrobbleproxy.py


示例5: show_xml

def show_xml():
    pages = [ f for f in os.listdir(CACHEDIR) if os.path.isdir(os.path.join(CACHEDIR,f)) ]

    doc, tag, text = Doc().tagtext()
    doc.asis('<?xml version="1.0" encoding="utf-8" ?>')

    # xml tags
    with tag('sac_uo'):
        for p in pages:
            item = get_data_from_page('%s/latest' % p)
            if item:
                with tag('item'):
                    with tag('id'):
                        text(item['id'])
                    with tag('nom'):
                        text(item['nom'])
                    with tag('resp'):
                        text(item['resp']) # mini hack
                    with tag('iddep'):
                        text(item['iddep'])
                    with tag('dep'):
                        text(item['dep'])
                    with tag('centers'):
                        text(item['centers'])

    return indent(
        doc.getvalue(),
        indentation = ' ' * 4,
        newline = '\r\n'
    )
开发者ID:opengovcat,项目名称:seismometer,代码行数:30,代码来源:getty.py


示例6: saveRelease

    def saveRelease(self, release):
        """
        Create an XML file of release metadata that Dalet will be happy with

        :param release: Processed release metadata from MusicBrainz
        """

        output_dir = self.release_meta_dir

        doc, tag, text = Doc().tagtext()

        doc.asis('<?xml version="1.0" encoding="UTF-8"?>')
        with tag('Titles'):
            with tag('GlossaryValue'):
                with tag('GlossaryType'):
                    text('Release')
                with tag('Key1'):
                    text(release.mbID)
                with tag('ItemCode'):
                    text(release.mbID)
                with tag('KEXPReviewRich'):
                    text(release.review)
        formatted_data = indent(doc.getvalue())

        output_file = path.join(output_dir, 'r' + release.mbID + ".xml")
        with open(output_file, "wb") as f:
            f.write(formatted_data.encode("UTF-8"))
开发者ID:hidat,项目名称:mryates,代码行数:27,代码来源:serializer.py


示例7: media_player

def media_player(request, media_src=''):
    doc, tag, text = Doc().tagtext()
    types = {'video':'V', 'audio':'A'}
    requested_type = media_src.split('/')[0]
    media_servers = MediaServer.objects.filter(media_type=types[requested_type])
    image_src = ''
    next_path = ''
    if len(media_src.split('/')) >= 2:
        requested_server = media_src.split('/')[1]
    else:
        requested_server = ''
    for server in media_servers:
        if server.name == requested_server:
            media_src = server.server_url + media_src[len(requested_type + '/' + requested_server):]
            parent_dir = server.directory_path + os.path.split(media_src)[0][len(server.server_url):]
            plist = sorted(os.listdir(parent_dir))
            media_path = server.directory_path + media_src[len(server.server_url):]
            media_base = os.path.basename(media_path)
            for item in os.listdir(parent_dir):
                if os.path.splitext(item)[1].lower() in ['.jpg','.png']:
                    image_src = os.path.join(os.path.split(media_src)[0],item)
            if len(plist)-1 > plist.index(media_base):
                next_path = urlpath(server, os.path.join(parent_dir, plist[plist.index(media_base)+1]))
        display_directory(server.directory_path, server, doc)
    ml = media_src.split('/')
    context = { 'medialisting':doc.getvalue(), 
                'mediasource':media_src, 
                'mediatype':requested_type, 
                'imagesource':image_src,
                'heading':os.path.splitext(ml[len(ml)-1])[0],
                'nextmedia': next_path,
              }
    return render(request, 'media_player/media_player.html', context)
开发者ID:GaopanHuang,项目名称:django-html5-media-player,代码行数:33,代码来源:views.py


示例8: getSession

def getSession(request, data):
    token = Token.load(data['token'])
    if not token:
        print "Invalid token"
        return "NOPE"

    if not token.user:
        print "Token not validated"
        return "NOPE"

    print "GRANTING SESSION for token %s" % token.token
    token.consume()
    session = Session.create(token.user)

    doc, tag, text = Doc().tagtext()
    with tag('lfm', status="ok"):
        with tag('session'):
            with tag('name'):
                text(session.user.name)
            with tag('key'):
                text(session.id)
            with tag('subscriber'):
                text('0')

    return '<?xml version="1.0" encoding="utf-8"?>\n' + yattag.indent(doc.getvalue())
开发者ID:pinkeshbadjatiya,项目名称:scrobbleproxy,代码行数:25,代码来源:scrobbleproxy.py


示例9: handle_list

 def handle_list(self, tag: QqTag, type):
     doc, html, text = Doc().tagtext()
     with html(type):
         for item in tag("item"):
             with html("li"):
                 doc.asis(self.format(item))
     return doc.getvalue()
开发者ID:ischurov,项目名称:qqmbr,代码行数:7,代码来源:qqhtml.py


示例10: environment_begin_end

def environment_begin_end(env, label=None, number=None, optional=None):
    if env == "document":
        return '<html><meta charset="UTF-8">' + mathjax_snipped, "</html>\n"

    doc, tag, text = Doc().tagtext()
    stop_sign = "!!!chahpieXeiDu3zeer3Ki"

    if env == "itemize" or env == "enumerate":
        with tag(list_envs[env]):
            text(stop_sign)
    else:
        with tag("div", klass="env_" + mk_safe_css_ident(env)):
            if label:
                doc.attr(id="label_" + mk_safe_css_ident(label))
            if env in named_envs:
                with tag("span", klass="env__name"):
                    text(named_envs[env])
            text(" ")
            if number:
                with tag("span", klass="env__number"):
                    text(number)
            text(" ")
            if optional:
                with tag("span", klass="env__opt_text"):
                    text(optional)
            text(stop_sign)
    ret = doc.getvalue()
    index = ret.index(stop_sign)
    begin = ret[:index] + "\n"
    end = ret[index + len(stop_sign) :] + "\n"

    return (begin, end)
开发者ID:ischurov,项目名称:prettyt2h,代码行数:32,代码来源:prettyt2h.py


示例11: handle_proof

    def handle_proof(self, tag: QqTag) -> str:
        """
        Uses tags: proof, label, outline, of

        Examples:

            \proof
                Here is the proof

            \proof \of theorem \ref{thm:1}
                Now we pass to proof of theorem \ref{thm:1}

        :param tag:
        :return: HTML of proof
        """
        doc, html, text = Doc().tagtext()
        with html("div", klass="env env__proof"):
            if tag.find("label"):
                doc.attr(id=self.label2id(tag._label.value))
            with html("span", klass="env-title env-title__proof"):
                if tag.exists("outline"):
                    proofline = 'Proof outline'
                else:
                    proofline = 'Proof'
                doc.asis(join_nonempty(self.localize(proofline),
                                       self.format(tag.find("of"), blanks_to_pars=False)).rstrip()+".")
            doc.asis(rstrip_p(" " + self.format(tag, blanks_to_pars=True)))
            doc.asis("<span class='end-of-proof'>&#8718;</span>")
        return doc.getvalue()+"\n<p>"
开发者ID:ischurov,项目名称:qqmbr,代码行数:29,代码来源:qqhtml.py


示例12: __init__

 def __init__(self, projectname = None):
     if projectname is None: # Used for just an empty html page with the same style and template
         self.doc, self.tag, self.text = Doc().tagtext()
         self.this_is_a_log_html_page = True
     else:
         Htmlpage.htmlpages[projectname] = self
         self.doc, self.tag, self.text = Doc().tagtext()
开发者ID:thelordofcode3,项目名称:StaCoAn,代码行数:7,代码来源:html_page.py


示例13: handle_h

    def handle_h(self, tag: QqTag) -> str:
        """
        Uses tags: h1, h2, h3, h4, label, number

        Example:

            \h1 This is first header

            \h2 This is the second header \label{sec:second}

        :param tag:
        :return:
        """
        doc, html, text = Doc().tagtext()
        with html(tag.name):
            doc.attr(id=self.tag_id(tag))
            if tag.find("number"):
                with html("span", klass="section__number"):
                    with html("a", href="#"+self.tag_id(tag), klass="section__number"):
                        text(tag._number.value)
            text(self.format(tag, blanks_to_pars=False))
        ret = doc.getvalue()
        if tag.next() and isinstance(tag.next(), str):
            ret += "<p>"
        return doc.getvalue()
开发者ID:ischurov,项目名称:qqmbr,代码行数:25,代码来源:qqhtml.py


示例14: test_list_jobs

  def test_list_jobs(self):
    project_name = 'test_project'
    jobs = [
      {'name': 'job 1', 'id': '1', 'project': project_name, 'description': 'job 1 description'}]

    doc, tag, text = Doc().tagtext()

    with tag('jobs', count=len(jobs)):
      for job in jobs:
        with tag('job'):
          with tag('name'):
            text(job['name'])
          with tag('project'):
            text(job['project'])
          with tag('description'):
            text(job['description'])

    responses.add(responses.GET,
                  'http://rundeck.host/api/11/jobs?project=test_project',
                  match_querystring=True,
                  body=self.rundeck_success(doc.getvalue()),
                  content_type='text/xml', status=200)

    project_jobs = self.rundeck_api.list_jobs(project_name)

    self.assertEquals(len(project_jobs), len(jobs))
    self.assertEquals(project_jobs[0]['name'], jobs[0]['name'])
开发者ID:Antillion,项目名称:arundeckrun,代码行数:27,代码来源:test_client.py


示例15: process_dump_file

 def process_dump_file(self, p):
     add_event = 0
     main_doc, main_tag, main_text = Doc().tagtext()
     for line in iter(p.stdout.readline, b''):
         # Compares first with timestamp regex. Timestamp regex indicates a new packet
         m = reg_timestamp.match(line.decode())
         if m:
             # add_event indicates if there is a processed event already
             if add_event == 1:
                 events.append(event)
                 self.add_event_to_html(event, main_doc, main_tag, main_text)
             add_event = 1
             event = Event(m.group('timestamp'), m.group('protocol'))
             m = reg_ip_1.search(line.decode())
             if m:
                 event.id = m.group('id')
                 event.t_protocol = m.group('transport_protocol')
                 event.length = m.group('length')
         else:
             m = reg_ip_2.search(line.decode())
             if m:
                 event.src = m.group('src')
                 event.src_port = m.group('src_port')
                 event.dst = m.group('dst')
                 event.dst_port = m.group('dst_port')
                 m = reg_length.search(line.decode())
                 # If TCP data is not 0, the packet gets further processing
                 if m and m.group('length') != 0:
                     length = int(m.group('length'))
                     self.process_host(event, length)
             # If there is a port unreachable error, event gets discarded
             m = reg_port_error.search(line.decode())
             if m:
                 add_event = 0
     return indent(main_doc.getvalue())
开发者ID:jnoziglia,项目名称:networkAnalyzer,代码行数:35,代码来源:analyzer.py


示例16: print_subsection

  def print_subsection(section,subsection,html=False,current=None):
    """Method for printing subsection data.

    Parameters
    ----------
    section: list
      section data
    subsection: list
      subsection data
    html: bool, optional
      activate html tags
    current: list, optional
      list containing current section, subsection and slide number used
      for highlighting current slide into the TOC

    Returns
    -------
    str
      string containing the pretty printed subsection data
    """
    if html:
      doc, tag, text = Doc().tagtext()
      with tag('a',href='#slide-'+str(subsection[4])):
        if current and current[0] == section[0] and current[1] == subsection[0]:
          with tag('span',klass='toc-subsection emph'):
            text('  '+str(section[0])+'.'+str(subsection[3])+' '+subsection[1])
        else:
          with tag('span',klass='toc-subsection'):
            text('  '+str(section[0])+'.'+str(subsection[3])+' '+subsection[1])
      string = '\n'+doc.getvalue()
    else:
      string = '\n'+'  '+str(section[0])+'.'+str(subsection[3])+' '+subsection[1]
    return string
开发者ID:nunb,项目名称:MaTiSSe,代码行数:33,代码来源:toc.py


示例17: handle_paragraph

 def handle_paragraph(self, tag: QqTag):
     """
     :param tag:
     :return:
     """
     doc, html, text = Doc().tagtext()
     with html("span", klass="paragraph"):
         doc.asis(self.format(tag, blanks_to_pars=False).strip() + ".")
     return "<p>" + doc.getvalue()+" "
开发者ID:ischurov,项目名称:qqmbr,代码行数:9,代码来源:qqhtml.py


示例18: test_input_no_slash

 def test_input_no_slash(self):
     doc = Doc(stag_end = '>')
     doc.input('passw', type="password")
     self.assertTrue(
         doc.getvalue() in (
             '<input name="passw" type="password">',
             '<input type="password" name="passw">'
         )
     )
开发者ID:leforestier,项目名称:yattag,代码行数:9,代码来源:tests_doc.py


示例19: as_xml

    def as_xml(self):
        doc, tag, text = Doc().tagtext()
        doc.asis("<?xml version='1.0' encoding='UTF-8'?>")
        with tag('bundle-app', name=self.name, xmlns="uri:oozie:bundle:0.1"):
            for coordinator in self.coordinators:
                with tag("coordinator", name=coordinator.name):
                    with tag("app-path"):
                        text("/"+coordinator.path + "/" + coordinator.name)

        return indent(doc.getvalue())
开发者ID:orenmazor,项目名称:oozie.py,代码行数:10,代码来源:bundle.py


示例20: getToken

def getToken(request, data):
    token = Token.generate()
    print "ISSUING TOKEN %s" % token.token

    doc, tag, text = Doc().tagtext()
    with tag('lfm', status="ok"):
        with tag('token'):
            text(token.token)

    return '<?xml version="1.0" encoding="utf-8"?>\n' + yattag.indent(doc.getvalue())
开发者ID:pinkeshbadjatiya,项目名称:scrobbleproxy,代码行数:10,代码来源:scrobbleproxy.py



注:本文中的yattag.Doc类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python ycbcr.YCbCr类代码示例发布时间:2022-05-26
下一篇:
Python yattag.indent函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap