当前位置: 首页>>代码示例>>Python>>正文


Python text.unicode_quote函数代码示例

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


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

示例1: abs_href

 def abs_href(self):
     """The application URL"""
     if not self.base_url:
         urlpattern = MultiProductSystem(self.parent).product_base_url
         if not urlpattern:
             self.log.warn("product_base_url option not set in "
                           "configuration, generated links may be "
                           "incorrect")
             urlpattern = 'products/$(prefix)s'
         envname = os.path.basename(self.parent.path)
         prefix = unicode_quote(self.product.prefix, safe="")
         name = unicode_quote(self.product.name, safe="")
         url = urlpattern.replace('$(', '%(') \
                         .replace('%(envname)s', envname) \
                         .replace('%(prefix)s', prefix) \
                         .replace('%(name)s', name)
         if urlsplit(url).netloc:
             #  Absolute URLs
             _abs_href = Href(url)
         else:
             # Relative URLs
             parent_href = Href(self.parent.abs_href(),
                                path_safe="/!~*'()%",
                                query_safe="!~*'()%")
             _abs_href = Href(parent_href(url))
     else:
         _abs_href = Href(self.base_url)
     return _abs_href
开发者ID:mohsadki,项目名称:dargest,代码行数:28,代码来源:env.py

示例2: __add__

 def __add__(self, rhs):
     if not rhs:
         return self.base or '/'
     if rhs.startswith('?'):
         return (self.base or '/') + \
                unicode_quote(rhs, self._printable_safe)
     if not rhs.startswith('/'):
         rhs = '/' + rhs
     return self.base + unicode_quote(rhs, self._printable_safe)
开发者ID:pkdevbox,项目名称:trac,代码行数:9,代码来源:href.py

示例3: _path_to_url

 def _path_to_url(self, path):
     '''Encode a path in the repos as a fully qualified URL.
     '''
     repos = self._get_repos_direct_object()
     url_parts =  ['file:///', 
                   unicode_quote(repos.path.lstrip('/')),
                   '/',
                   unicode_quote(path.lstrip('/')),
                   ]
     return ''.join(url_parts)
开发者ID:lkraav,项目名称:trachacks,代码行数:10,代码来源:svn_fs.py

示例4: login_as

 def login_as(self, username, password=None):
     if not password:
         password = username
     
     assert 'http://' == self.url[:7]
     unused, protocol, host_and_rest = self.url.partition('http://')
     new_url = "%s%s:%[email protected]%s/login" % (protocol, unicode_quote(username), unicode_quote(password), host_and_rest)
     self.windmill.open(url=new_url)
     self.windmill.waits.forPageLoad()
     self.windmill.waits.forElement(jquery="('ul.metanav li:contains(Logged in as %s)')[0]" % username)
     
     self.windmill.asserts.assertText(
         xpath="//*[contains(@class, 'metanav')]/li[1]", 
         validator='Logged in as %s' % username)
开发者ID:djangsters,项目名称:agilo,代码行数:14,代码来源:windmill_tester.py

示例5: import_wiki_attachments

    def import_wiki_attachments(self, template_path):
        """Imports wiki attachments from template using the Attachment API."""

        # check that there are attachments to import
        template_attachment_path = os.path.join(template_path, 'attachments', 'wiki')
        if os.path.isdir(template_attachment_path):

            # clear the wiki attachment table
            @self.env.with_transaction()
            def clear_attachments(db):
                """Clears any wiki attachments from the current attachment table."""

                cursor = db.cursor()
                cursor.execute("DELETE FROM attachment WHERE type='wiki'")

            # move attachment file into the env and insert database row
            filepath = os.path.join(template_path, 'attachment.xml')
            tree = ET.ElementTree(file=filepath)
            for att in tree.getroot():
                attachment = Attachment(self.env, 'wiki', att.attrib['parent_id'])
                attachment.description = att.text
                try:
                    fileobj = open(os.path.join(template_attachment_path, 
                               att.attrib['parent_id'], unicode_quote(att.attrib['name'])))
                    attachment.insert(att.attrib['name'], fileobj, att.attrib['size'])
                except IOError:
                    self.log.info("Unable to import attachment %s", att.attrib['name'])
开发者ID:CGI-define-and-primeportal,项目名称:trac-plugin-createtemplate,代码行数:27,代码来源:importer.py

示例6: create_milestone

    def create_milestone(self, name=None, due=None):
        """Creates the specified milestone, with a random name if none is
        provided.  Returns the name of the milestone.
        """
        if name == None:
            name = random_unique_camel()
        milestone_url = self.url + "/admin/ticket/milestones"
        tc.go(milestone_url)
        tc.url(milestone_url)
        tc.formvalue('addmilestone', 'name', name)
        if due:
            # TODO: How should we deal with differences in date formats?
            tc.formvalue('addmilestone', 'duedate', due)
        tc.submit()
        tc.notfind(internal_error)
        tc.notfind('Milestone .* already exists')
        tc.url(milestone_url)
        tc.find(name)

        # Make sure it's on the roadmap.
        tc.follow('Roadmap')
        tc.url(self.url + "/roadmap")
        tc.find('Milestone:.*%s' % name)
        tc.follow(name)
        tc.url('%s/milestone/%s' % (self.url, unicode_quote(name)))
        if not due:
            tc.find('No date set')

        return name
开发者ID:Stackato-Apps,项目名称:bloodhound,代码行数:29,代码来源:tester.py

示例7: web_upload

 def web_upload(self, req):
     # TODO: handle file upload when POSTing
     files = []
     for fname in sorted(os.listdir(self._dump_path())):
         fpath = os.path.join(self._dump_path(), fname)
         fstat = os.stat(fpath)
         files.append({"name": fname, "url": unicode_quote(fname), "size": fstat.st_size, "date": fstat.st_mtime})
     return {"max_size": self.max_size, "files": files, "action": "upload"}
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:8,代码来源:PlanetForgeImport.py

示例8: download_as_csv

 def download_as_csv(self):
     url_template = '%(prefix)s/%(backlog)s'
     backlog_path = url_template % dict(prefix=BACKLOG_URL, backlog='Product Backlog')
     url = self.tester.url + unicode_quote(backlog_path) + '?format=csv'
     tc.go(url)
     tc.code(200)
     csv_export = tc.show()
     csvfile = CSVFile(StringIO(csv_export), None, 'UTF-8')
     return csvfile
开发者ID:djangsters,项目名称:agilo,代码行数:9,代码来源:backlog_csv_export.py

示例9: move_attachment_file

def move_attachment_file(env, parent_realm, parent_id, filename):
    old_path = os.path.join(env.path, 'attachments', parent_realm,
                            unicode_quote(parent_id))
    if filename:
        old_path = os.path.join(old_path, unicode_quote(filename))
    old_path = os.path.normpath(old_path)
    if os.path.isfile(old_path):
        new_path = Attachment._get_path(env.path, parent_realm, parent_id,
                                        filename)
        try:
            os.renames(old_path, new_path)
        except OSError:
            printerr(_("Unable to move attachment from:\n\n"
                       "  %(old_path)s\n\nto:\n\n  %(new_path)s\n",
                       old_path=old_path, new_path=new_path))
            raise
    else:
        env.log.warning("Can't find file for 'attachment:%s:%s:%s', ignoring",
                        filename, parent_realm, parent_id)
开发者ID:Stackato-Apps,项目名称:bloodhound,代码行数:19,代码来源:db28.py

示例10: runTest

 def runTest(self):
     tc.go(self.tester.url + '/admin/ticket/milestones/' + unicode_quote(self.milestone_name()))
     new_name = self.milestone_name() + 'Renamed'
     tc.formvalue('modifymilestone', 'name', new_name)
     tc.submit('save')
     tc.code(200)
     # Now we expect that the ticket and the sprint have updated milestone
     ticket_page = self.tester.navigate_to_ticket_page(self.tkt_id)
     self.assert_equals(new_name, ticket_page.milestone())
     self.tester.go_to_sprint_edit_page("SprintFor" + self.milestone_name())
     tc.find('for milestone %s</h1>' % new_name)
开发者ID:djangsters,项目名称:agilo,代码行数:11,代码来源:rename_milestone_test.py

示例11: insert

    def insert(self, filename, fileobj, size, t=None, db=None):
        # FIXME: `t` should probably be switched to `datetime` too
        if not db:
            db = self.env.get_db_cnx()
            handle_ta = True
        else:
            handle_ta = False

        self.size = size and int(size) or 0
        timestamp = int(t or time.time())
        self.date = datetime.fromtimestamp(timestamp, utc)

        # Make sure the path to the attachment is inside the environment
        # attachments directory
        attachments_dir = os.path.join(os.path.normpath(self.env.path),
                                       'attachments')
        commonprefix = os.path.commonprefix([attachments_dir, self.path])
        assert commonprefix == attachments_dir

        if not os.access(self.path, os.F_OK):
            os.makedirs(self.path)
        filename = unicode_quote(filename)
        path, targetfile = create_unique_file(os.path.join(self.path,
                                                           filename))
        try:
            # Note: `path` is an unicode string because `self.path` was one.
            # As it contains only quoted chars and numbers, we can use `ascii`
            basename = os.path.basename(path).encode('ascii')
            filename = unicode_unquote(basename)

            cursor = db.cursor()
            cursor.execute("INSERT INTO attachment "
                           "VALUES (%s,%s,%s,%s,%s,%s,%s,%s)",
                           (self.parent_realm, self.parent_id, filename,
                            self.size, timestamp, self.description,
                            self.author, self.ipnr))
            shutil.copyfileobj(fileobj, targetfile)
            self.resource.id = self.filename = filename

            self.env.log.info('New attachment: %s by %s', self.title,
                              self.author)

            if handle_ta:
                db.commit()

            targetfile.close()

            for listener in AttachmentModule(self.env).change_listeners:
                listener.attachment_added(self)

        finally:
            if not targetfile.closed:
                targetfile.close()
开发者ID:twisted-infra,项目名称:twisted-trac-source,代码行数:53,代码来源:attachment.py

示例12: files

def files(pgc,myc,users):

    print "Starting files"

    pgc.execute("""SELECT * FROM files""");
    count = 0
    while (1):
        row = pgc.fetchone()
        if row == None:
            break
        
        # create the file
        attached_to_pagename = row[6]
        file_blob = str(row[1])
        file_blob.decode('latin1')
        
        path = ATTACHMENTS+'/'+unicode_quote(attached_to_pagename)
        if not os.access(path, os.F_OK):
            os.makedirs(path)
        filename = path+'/'+row[0]
        outfile = open(filename,'w')
        outfile.write(file_blob)
        outfile.close()
        print "Wrote %s \n" % filename

        # insert into database
        upload_time = int(row[2])
        if users.has_key(row[3]):
            username = users[row[3]]
        else:
            username = ''
        
        sql = "INSERT INTO attachment VALUES ('wiki',%s,%s,%s,%s,%s,%s,%s)"
        try:
            myc.execute(sql,(attached_to_pagename,
                             row[0],
                             len(file_blob),
                             upload_time,
                             '',
                             username,
                             row[5]))
        except:
            print "Error inserting "+row[0]+"\n"
            continue
        count += 1

    mydb.commit()
    print "Finished %d rows of files" % count
开发者ID:lkraav,项目名称:trachacks,代码行数:48,代码来源:sycamore2trac.py

示例13: render_macro

    def render_macro(self, req, name, content):
        args = content.split(",")

        part = model.BlogPart(self.env, args[0])
        if part:
            body = part.body
            argnum = int(part.argnum)
            i = 1
            for arg in args[1:]:
                a = unicode_quote(arg)
                body = body.replace("%" + "arg_%d" % (i) + "%", a)
                i = i + 1

            return body
        else:
            return "Not Impremented %s" % args[0]
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:16,代码来源:macro.py

示例14: _do_dump

 def _do_dump(self, directory, *names):
     if not names:
         names = ['*']
     pages = self.get_wiki_list()
     if not os.path.isdir(directory):
         if not os.path.exists(directory):
             os.mkdir(directory)
         else:
             raise AdminCommandError(_("'%(name)s' is not a directory",
                                       name=path_to_unicode(directory)))
     for p in pages:
         if any(p == name or (name.endswith('*')
                              and p.startswith(name[:-1]))
                for name in names):
             dst = os.path.join(directory, unicode_quote(p, ''))
             printout(' %s => %s' % (p, dst))
             self.export_page(p, dst)
开发者ID:pkdevbox,项目名称:trac,代码行数:17,代码来源:admin.py

示例15: go_to_report

    def go_to_report(self, id, args=None):
        """Surf to the specified report.

        Assumes the report exists. Report variables will be appended if
        specified.

        :param id: id of the report
        :param args: may optionally specify a dictionary of arguments to
                     be encoded as a query string
        """
        report_url = self.url + "/report/%s" % id
        if args:
            arglist = []
            for param, value in args.items():
                arglist.append('%s=%s' % (param.upper(), unicode_quote(value)))
            report_url += '?' + '&'.join(arglist)
        tc.go(report_url)
        tc.url(report_url.encode('string-escape').replace('?', '\?'))
开发者ID:dafrito,项目名称:trac-mirror,代码行数:18,代码来源:tester.py


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