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

Python yattag.indent函数代码示例

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

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



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

示例1: show_help

def show_help(message = None):
    import yattag
    doc, tag, text = yattag.Doc().tagtext()
    assert isinstance(doc, yattag.Doc)
    with tag("html"):
        with tag("head"):
            with tag("title"):
                text("BatchProfiler: view text file")
        with tag("body"):
            with tag("div"):
                text("This page is designed to be used by ")
                with tag("a", href="ViewBatch.py"):
                    text("View Batch")
                if message is not None:
                    text("The page reports the following error: \"%s\"" %
                         message)
                text(". Most likely you have reached this page in error. ")
                text("If you feel that's not the case, you can contact your ")
                text("sysadmin and if you are the sysadmin, you can post to ")
                text("the ")
                with tag("a", href="http://cellprofiler.org/forum"):
                    text("CellProfiler forum")
                text(".")
    print "Content-Type: text/html"
    print
    print yattag.indent(doc.getvalue())
开发者ID:AnneCarpenter,项目名称:BatchProfiler,代码行数:26,代码来源:ViewTextFile.py


示例2: 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


示例3: session_info

def session_info(request, data):
    try:
        sk = data['sk']
        api_key = data['api_key']
        output_format = data.get('format', 'xml')
        username = data['username']
    except KeyError:
        raise InvalidAPIUsage(CompatError.INVALID_PARAMETERS, output_format=output_format)        # Missing Required Params

    session = Session.load(sk)
    if (not session) or User.load_by_name(username).id != session.user.id:
        raise InvalidAPIUsage(CompatError.INVALID_SESSION_KEY, output_format=output_format)       # Invalid Session KEY

    print("SESSION INFO for session %s, user %s" % (session.id, session.user.name))

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

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


示例4: get_session

def get_session(request, data):
    """ Create new session after validating the API_key and token.
    """
    output_format = data.get('format', 'xml')
    try:
        api_key = data['api_key']
        token = Token.load(data['token'], api_key)
    except KeyError:
        raise InvalidAPIUsage(CompatError.INVALID_PARAMETERS, output_format=output_format)   # Missing Required Params

    if not token:
        if not Token.is_valid_api_key(api_key):
            raise InvalidAPIUsage(CompatError.INVALID_API_KEY, output_format=output_format)  # Invalid API_key
        raise InvalidAPIUsage(CompatError.INVALID_TOKEN, output_format=output_format)        # Invalid token
    if token.has_expired():
        raise InvalidAPIUsage(CompatError.TOKEN_EXPIRED, output_format=output_format)        # Token expired
    if not token.user:
        raise InvalidAPIUsage(CompatError.UNAUTHORIZED_TOKEN, output_format=output_format)   # Unauthorized token

    session = Session.create(token)

    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.sid)
            with tag('subscriber'):
                text('0')

    return format_response('<?xml version="1.0" encoding="utf-8"?>\n' + yattag.indent(doc.getvalue()),
                           data.get('format', "xml"))
开发者ID:Uditgulati,项目名称:listenbrainz-server,代码行数:33,代码来源:api_compat.py


示例5: __to_html

    def __to_html(self, pmid, title, abstract, output_dir):
        """Generate HTML file for Anndoc

        Write a HTML file required for Anndoc, formatted according to TagTog's
        standards that can be viewed at the link below.
        https://github.com/jmcejuela/tagtog-doc/wiki

        By default, the MEDLINE identifier will be used as the title, unless
        something else is specified.

        Args:
            title (str): Title of the paper
            abstract (str): Abstract contents of the paper
            output_file (Optional[str]): Path to the output file. Defaults to
                                        none.

        """
        from yattag import Doc
        from yattag import indent
        from os.path import join

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

        # Compute hashId (TODO find out what hashing is used, currently random)
        hashId = self.__random_hashId(pmid)

        # Use Yattag to generate HTML syntax
        doc.asis('<!DOCTYPE html>')
        with tag('html',
                ('data-origid', pmid),
                ('data-anndoc-version', "2.0"),
                ('lang', ""), ('xml:lang', ""),
                ('xmlns', "http://www.w3.org/1999/xhtml"),
                klass='anndoc',
                id=hashId):
            with tag('head'):
                doc.stag('meta', charset='UTF-8')
                doc.stag('meta', name='generator', content='org.rostlab.relna')
                with tag('title'):
                    text(hashId)
            with tag('body'):
                with tag('article'):
                    with tag('section', ('data-type', 'title')):
                        with tag('h2', id='s1h1'):
                            text(title)
                    with tag('section', ('data-type', 'abstract')):
                        with tag('h3', id='s2h1'):
                            text("Abstract")
                        with tag('div', klass='content'):
                            with tag('p', id='s2p1'):
                                text(abstract)

        # Write to file
        result = indent(doc.getvalue())
        try:
            with open(join(output_dir, pmid+'.html'), 'w') as fw:
                fw.write(result)
        except IOError as e:
            print('I/O Error({0}): {1}'.format(e.errno, e.strerror))
            raise
开发者ID:ashishbaghudana,项目名称:PubTator2Anndoc,代码行数:60,代码来源:pubtator.py


示例6: 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


示例7: as_xml

    def as_xml(self):
        doc, tag, text = Doc().tagtext()
        doc.asis("<?xml version='1.0' encoding='UTF-8'?>")
        with tag('workflow-app', ('xmlns:sla', 'uri:oozie:sla:0.2'), name=self.name, xmlns="uri:oozie:workflow:0.5"):
            doc.stag('start', to=self.actions[0].name)
            for index, action in enumerate(self.actions):
                with tag("action", name=action.name):
                    doc.asis(action.as_xml(indent))
                    if index + 1 < len(self.actions):
                        next_action = self.actions[index+1]
                        doc.stag("ok", to=next_action.name)
                    else: 
                        doc.stag("ok", to="end")
                    doc.stag("error", to="notify")

            with tag("action", name="notify"):
                with tag("email", xmlns="uri:oozie:email-action:0.1"):
                    with tag("to"):
                        text(self.email)
                    with tag("subject"):
                        text("WF ${wf:name()} failed at ${wf:lastErrorNode()}")
                    with tag("body"):
                        text("http://hue.data.shopify.com/oozie/list_oozie_workflow/${wf:id()}")
                doc.stag("ok", to="kill")
                doc.stag("error", to="kill")

            with tag("kill", name="kill"):
                with tag("message"):
                    text("${wf:lastErrorNode()} - ${wf:id()}")
            doc.stag('end', name="end")

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


示例8: write_junit_xml

def write_junit_xml(report, tests_file, dataset_dir, dataset_name=None):
    # use a different file name depending on whether this is a
    # single dataset report or not (``dataset_name=None``)
    junit_filename_parts = [
        stem(tests_file),
        basename(dataset_dir),
        # can't use `.isoformat()` here because otherwise the `:`
        # separating the time part make the first part of the file
        # name look like an (invalid) protocol specifier in
        # relative links
        datetime.now().strftime('%Y-%m-%d-%H.%M.%S')
    ]
    if dataset_name:
        junit_filename_parts.insert(2, dataset_name)

    # `junit2html` has a bug: it will lowercase target file names in
    # links, but still create those files with the case they're given,
    # resulting in broken links.  Try to prevent it by ensuring our
    # JUnit XML files have lowercase names...
    junit_file = (
        '-'.join(junit_filename_parts) + '.xml'
    ).lower()
    logging.debug("Writing XML test report to file: `%s`", junit_file)

    with open(junit_file, 'w') as output:
        output.write(indent(report.as_junit_xml()))
开发者ID:dvischi,项目名称:TissueMAPS,代码行数:26,代码来源:test_datasets.py


示例9: 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


示例10: html_from_tree

def html_from_tree(tree):
    """Generate indented HTML from VOTL Object tree.

    Params:
        tree (Object): A VOTL Object containing the tree, from which HTML will
                       be generated.

    Returns: String containing a pretty-formatted HTML document.
    """
    doc, tag, text = Doc().tagtext()

    doc.asis("<!DOCTYPE html>")

    first = tree.children[0]
    if first.object_type == "header":
        title = first.first_line
    else:
        title = "Untitled"

    with tag("html"):
        with tag("head"):
            with tag("title"):
                text(title)
            doc.stag("meta", charset="utf-8")
        with tag("body"):
            _recurse_tags(tree, doc, tag, text)

    return indent(doc.getvalue())
开发者ID:fennekki,项目名称:unikko,代码行数:28,代码来源:html.py


示例11: 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


示例12: 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


示例13: 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


示例14: send_batch_submission_email

    def send_batch_submission_email(self, batch, vb_url):
        doc, tag, text = yattag.Doc().tagtext()
        with tag("html"):
            with tag("head"):
                with tag("title"):
                    text("Batch # %d" % batch.batch_id)
                with tag("style", type="text/css"):
                    doc.asis("""
table {
    border-spacing: 0px;
    border-collapse: collapse;
}
td {
    text-align: left;
    vertical-align: baseline;
    padding: 0.1em 0.5em;
    border: 1px solid #666666;
}
""")
            with tag("body"):
                with tag("h1"):
                    text("Results for batch # ")
                    with tag("a", href = vb_url):
                        text(str(batch.batch_id))
                with tag("div"):
                    text("Data Directory: %s" % 
                         BATCHPROFILER_DEFAULTS[DATA_DIR])
        email_text = yattag.indent(doc.getvalue())
        send_html_mail(recipient=BATCHPROFILER_DEFAULTS[EMAIL],
                       subject = "Batch %d submitted"%(batch.batch_id),
                       html=email_text)
开发者ID:LeeKamentsky,项目名称:CellProfiler,代码行数:31,代码来源:NewBatch.py


示例15: to_html

  def to_html(self, config):
    """Generate a html stream of the whole presentation.

    Parameters
    ----------
    config : MatisseConfig
      MaTiSSe configuration
    """
    doc, tag, text = Doc().tagtext()
    doc.asis('<!DOCTYPE html>')
    with tag('html'):
      # doc.attr(title=self.metadata['title'].value)
      self.__put_html_tag_head(doc=doc, tag=tag, text=text, config=config)
      with tag('body', onload="resetCountdown(" + str(self.metadata['max_time'].value) + ");"):
        doc.attr(klass='impress-not-supported')
        with tag('div', id='impress'):
          # numbering: [local_chap, local_sec, local_subsec, local_slide]
          current = [0, 0, 0, 0]
          for chapter in self.chapters:
            current[0] += 1
            current[1] = 0
            current[2] = 0
            current[3] = 0
            self.metadata['chaptertitle'].update_value(value=chapter.title)
            self.metadata['chapternumber'].update_value(value=chapter.number)
            for section in chapter.sections:
              current[1] += 1
              current[2] = 0
              current[3] = 0
              self.metadata['sectiontitle'].update_value(value=section.title)
              self.metadata['sectionnumber'].update_value(value=section.number)
              for subsection in section.subsections:
                current[2] += 1
                current[3] = 0
                self.metadata['subsectiontitle'].update_value(value=subsection.title)
                self.metadata['subsectionnumber'].update_value(value=subsection.number)
                for slide in subsection.slides:
                  current[3] += 1
                  self.metadata['slidetitle'].update_value(value=slide.title)
                  self.metadata['slidenumber'].update_value(value=slide.number)
                  with doc.tag('div'):
                    chapter.put_html_attributes(doc=doc)
                    section.put_html_attributes(doc=doc)
                    subsection.put_html_attributes(doc=doc)
                    slide.put_html_attributes(doc=doc)
                    self.__put_html_slide_decorators(tag=tag, doc=doc, decorator='header', current=current, overtheme=slide.overtheme)
                    # with doc.tag('div'):
                      # doc.attr(style='clear: both;')
                    self.__put_html_slide_decorators(tag=tag, doc=doc, decorator='sidebar', position='L', current=current, overtheme=slide.overtheme)
                    slide.to_html(doc=doc, parser=self.parser, metadata=self.metadata, theme=self.theme, current=current)
                    self.__put_html_slide_decorators(tag=tag, doc=doc, decorator='sidebar', position='R', current=current, overtheme=slide.overtheme)
                    # with doc.tag('div'):
                      # doc.attr(style='clear: both;')
                    self.__put_html_slide_decorators(tag=tag, doc=doc, decorator='footer', current=current, overtheme=slide.overtheme)
        self.__put_html_tags_scripts(doc=doc, tag=tag, config=config)
    # source = re.sub(r"<li>(?P<item>.*)</li>", r"<li><span>\g<item></span></li>", source)
    html = indent(doc.getvalue())
    return html
开发者ID:szaghi,项目名称:MaTiSSe,代码行数:58,代码来源:presentation.py


示例16: 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


示例17: 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


示例18: record_listens

def record_listens(request, data):
    """ Submit the listen in the lastfm format to be inserted in db.
        Accepts listens for both track.updateNowPlaying and track.scrobble methods.
    """
    output_format = data.get('format', 'xml')
    try:
        sk, api_key = data['sk'], data['api_key']
    except KeyError:
        raise InvalidAPIUsage(CompatError.INVALID_PARAMETERS, output_format=output_format)    # Invalid parameters

    session = Session.load(sk)
    if not session:
        if not Token.is_valid_api_key(api_key):
            raise InvalidAPIUsage(CompatError.INVALID_API_KEY, output_format=output_format)   # Invalid API_KEY
        raise InvalidAPIUsage(CompatError.INVALID_SESSION_KEY, output_format=output_format)   # Invalid Session KEY

    lookup = defaultdict(dict)
    for key, value in data.items():
        if key in ["sk", "token", "api_key", "method", "api_sig"]:
            continue
        matches = re.match('(.*)\[(\d+)\]', key)
        if matches:
            key = matches.group(1)
            number = matches.group(2)
        else:
            number = 0
        lookup[number][key] = value

    if request.form['method'].lower() == 'track.updatenowplaying':
        for i, listen in lookup.items():
            if 'timestamp' not in listen:
                listen['timestamp'] = calendar.timegm(datetime.now().utctimetuple())

    # Convert to native payload then submit 'em after validation.
    listen_type, native_payload = _to_native_api(lookup, data['method'], output_format)
    for listen in native_payload:
        validate_listen(listen, listen_type)

    user = db_user.get(session.user_id)
    augmented_listens = insert_payload(native_payload, user, listen_type=listen_type)

    # With corrections than the original submitted listen.
    doc, tag, text = Doc().tagtext()
    with tag('lfm', status='ok'):
        if listen_type == 'playing_now':
            doc.asis(create_response_for_single_listen(list(lookup.values())[0], augmented_listens[0], listen_type))
        else:
            accepted_listens = len(lookup.values())
            # Currently LB accepts all the listens and ignores none
            with tag('scrobbles', accepted=accepted_listens, ignored='0'):
                for original_listen, augmented_listen in zip(list(lookup.values()), augmented_listens):
                    doc.asis(create_response_for_single_listen(original_listen, augmented_listen, listen_type))

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


示例19: scrobble

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

    # FUUUUUUU PHP ARRAYS
    lookup = defaultdict(dict)
    for key, value in data.items():
        matches = re.match('(.*)\[(\d+)\]', key)
        if matches:
            key = matches.group(1)
            number = matches.group(2)
        else:
            number = 0
        lookup[number][key] = value

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

            for _, dataset in lookup.items():
                if 'track' not in dataset:
                    continue

                artist      = dataset['artist']
                track       = dataset['track']
                album       = dataset['album']
                albumArtist = dataset['albumArtist']
                timestamp   = dataset['timestamp']

                print "SCROBBLE- User: %s, Artist: %s, Track: %s, Album: %s"  \
                    % (session.user.name, artist, track, album)

                session.user.scrobble(timestamp, artist, track, album, albumArtist)

                with tag('scrobble'):
                    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('timestamp', corrected="0"):
                        text(timestamp)
                    with tag('ignoredMessage', code="0"):
                        text('')

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


示例20: handle_get

def handle_get():
    '''Display a form for fixing the permissions'''
    batch_id_id = "input_%s" % BATCH_ID
    button_id = "button_%s" % BATCH_ID
    fix_permissions_action = "on_click_%s()" % button_id
    doc, tag, text = yattag.Doc().tagtext()
    assert isinstance(doc, yattag.Doc)
    with tag("html"):
        with tag("head"):
            with tag("title"):
                text(TITLE)
            with tag("script", language="JavaScript"):
                doc.asis(FIX_PERMISSIONS_AJAX_JAVASCRIPT)
                doc.asis("""
function on_click_%s() {
   fix_permissions(document.getElementById('%s')); 
}""" % (button_id, button_id))
        with tag("body"):
            with tag("h1"):
                text(TITLE)
            with tag("div", style="width: 6in; margin-bottom: 24pt"):
                text("""
This webpage fixes permission problems for the files and folders in your batch
that were created outside BatchProfiler's control. It will grant read
permission for the job script folder, the text output folder, the text and 
error output files and the measurements file.""")
            with tag("div"):
                with tag("label", **{ "for":batch_id_id }):
                    text("Batch ID")
                doc.input(name=BATCH_ID, id=batch_id_id, type="text")
                with tag("button", id=button_id,
                         onclick=fix_permissions_action):
                    text("Fix permissions")
    print "Content-Type: text/html"
    print
    print '<!DOCTYPE html PUBLIC ' \
          '"-//W3C//DTD XHTML 1.0 Transitional//EN"' \
          '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
    print yattag.indent(doc.getvalue())
开发者ID:dettmering,项目名称:CellProfiler,代码行数:39,代码来源:FixPermissions.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python yattag.Doc类代码示例发布时间:2022-05-26
下一篇:
Python yate.start_response函数代码示例发布时间: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