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


Python text.printout函数代码示例

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


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

示例1: do_import

 def do_import(db):
     cursor = db.cursor()
     # Make sure we don't insert the exact same page twice
     cursor.execute("SELECT text FROM wiki WHERE name=%s "
                    "ORDER BY version DESC LIMIT 1",
                    (title,))
     old = list(cursor)
     if old and title in create_only:
         printout(_('  %(title)s already exists', title=title))
         result[0] = False
         return
     if old and data == old[0][0]:
         printout(_('  %(title)s is already up to date', title=title))
         result[0] = False
         return
 
     if replace and old:
         cursor.execute("UPDATE wiki SET text=%s WHERE name=%s "
                        "  AND version=(SELECT max(version) FROM wiki "
                        "               WHERE name=%s)",
                        (data, title, title))
     else:
         cursor.execute("INSERT INTO wiki(version,name,time,author,"
                        "                 ipnr,text) "
                        "SELECT 1+COALESCE(max(version),0),%s,%s,"
                        "       'trac','127.0.0.1',%s FROM wiki "
                        "WHERE name=%s",
                        (title, to_utimestamp(datetime.now(utc)), data,
                         title))
     if not old:
         del WikiSystem(self.env).pages
开发者ID:wiraqutra,项目名称:photrackjp,代码行数:31,代码来源:admin.py

示例2: main

def main():
    options, args = parse_args()
    names = sorted(name for name in resource_listdir('trac.wiki',
                                                     'default-pages')
                        if not name.startswith('.'))
    if args:
        args = sorted(set(names) & set(map(os.path.basename, args)))
    else:
        args = names

    if options.download:
        download_default_pages(args, options.prefix)

    env = EnvironmentStub()
    load_components(env)
    with env.db_transaction:
        for name in names:
            wiki = WikiPage(env, name)
            wiki.text = resource_string('trac.wiki', 'default-pages/' +
                                        name).decode('utf-8')
            if wiki.text:
                wiki.save('trac', '')
            else:
                printout('%s: Skipped empty page' % name)

    req = Mock(href=Href('/'), abs_href=Href('http://localhost/'),
               perm=MockPerm())
    for name in args:
        wiki = WikiPage(env, name)
        if not wiki.exists:
            continue
        context = web_context(req, wiki.resource)
        out = DummyIO()
        DefaultWikiChecker(env, context, name).format(wiki.text, out)
开发者ID:exocad,项目名称:exotrac,代码行数:34,代码来源:checkwiki.py

示例3: _do_changeset_modified

 def _do_changeset_modified(self, reponame, *revs):
     if is_default(reponame):
         reponame = ''
     rm = RepositoryManager(self.env)
     errors = rm.notify('changeset_modified', reponame, revs)
     for error in errors:
         printout(error)
开发者ID:exocad,项目名称:exotrac,代码行数:7,代码来源:admin.py

示例4: _do_changeset_added

 def _do_changeset_added(self, reponame, *revs):
     if is_default(reponame):
         reponame = ""
     rm = RepositoryManager(self.env)
     errors = rm.notify("changeset_added", reponame, revs)
     for error in errors:
         printout(error)
开发者ID:pkdevbox,项目名称:trac,代码行数:7,代码来源:admin.py

示例5: _do_wiki_upgrade

 def _do_wiki_upgrade(self):
     """Move all wiki pages starting with Trac prefix to unbranded user
     guide pages.
     """
     wiki_admin = WikiAdmin(self.env)
     pages = wiki_admin.get_wiki_list()
     for old_name in pages:
         if old_name.startswith('Trac'):
             new_name = wiki.new_name(old_name)
             if not new_name:
                 continue
             if new_name in pages:
                 printout(_('Ignoring %(page)s : '
                            'The page %(new_page)s already exists',
                            page=old_name, new_page=new_name))
                 continue
             try:
                 wiki_admin._do_rename(old_name, new_name)
             except AdminCommandError, exc:
                 printout(_('Error moving %(page)s : %(message)s',
                            page=old_name, message=unicode(exc)))
             else:
                 # On success, rename links in other pages
                 self._do_wiki_rename_links(old_name, new_name)
                 # On success, insert redirection page
                 redirection = WikiPage(self.env, old_name)
                 redirection.text = _('See [wiki:"%(name)s"].', name=new_name)
                 comment = 'Bloodhound guide update'
                 redirection.save('bloodhound', comment, '0.0.0.0')
开发者ID:Stackato-Apps,项目名称:bloodhound,代码行数:29,代码来源:admin.py

示例6: get_repository_id

    def get_repository_id(self, repository):
        """
        Returns the repository id inside Trac. This is needed to support
        multi-repository since v0.12. However, in lower versions of Trac, by simply
        using 'default' as repository name, it should work just fine :)
        """
        # The default repository is the one that has no "name" value in repository table
        if (repository == "default"):
            sql_string = """
                SELECT id
                 FROM repository 
                 WHERE name = 'name' AND value = '';
            """
            self.cursor.execute(sql_string)
            row = self.cursor.fetchone()
            # Default is an special situation, we need to handle different
            # Default dir could be specified in repository table or in trac.ini
            self.default = True
            return row[0]

        # The repository can be a path to the root of the repository
        if os.path.isdir(repository):
            # The default repository is not in the repository table
            # We need to check it apart, against the Trac's config file
            default_repository_path = self.config.get("trac", "repository_dir", "") 
            contains = re.compile(repository)
            if contains.match(default_repository_path):
                self.default = True
                return 1

            sql_string = """
                SELECT id
                 FROM repository
                 WHERE name = 'dir' AND value LIKE %s
            """
            self.cursor.execute(sql_string, ("%%%s%%" % repository,))
            row = self.cursor.fetchone()
            
            # If the repository is not controlled by Trac
            # We exit with successful execution. This way we can make a generic 
            # Mercurial hook that will work with all repositories in the machine
            if not row:
                printout("[E] Path",repository,"was not found in repository table, neither in Trac's config. Sync will not be executed")
                sys.exit(0)

        # Otherwise it should be the name of the repository
        else:
            sql_string = """
                SELECT id
                 FROM repository
                 WHERE name = 'name' AND value LIKE %s
            """
            self.cursor.execute(sql_string, (repository,))
            row = self.cursor.fetchone()
        
            if not row:
                printout("[E] Sorry, repository name not found")
                sys.exit(1)
        
        return row[0]
开发者ID:bkocherov,项目名称:TracMercurialChangesetPlugin,代码行数:60,代码来源:admin.py

示例7: main

def main():
    names = sorted(name for name in resource_listdir('trac.wiki',
                                                     'default-pages')
                        if not name.startswith('.'))

    env = EnvironmentStub()
    load_components(env)
    with env.db_transaction:
        for name in names:
            wiki = WikiPage(env, name)
            wiki.text = resource_string('trac.wiki', 'default-pages/' +
                                        name).decode('utf-8')
            if wiki.text:
                wiki.save('trac', '')
            else:
                printout('%s: Skipped empty page' % name)

    req = Mock(href=Href('/'), abs_href=Href('http://trac.edgewall.org/'),
               perm=MockPerm(), chrome={})
    for name in sys.argv[1:]:
        name = os.path.basename(name)
        wiki = WikiPage(env, name)
        if not wiki.exists:
            continue
        context = web_context(req, wiki.resource, absurls=True)
        rst = wiki2rest(env, context, wiki)
        sys.stdout.write(rst)
开发者ID:pkdevbox,项目名称:trac,代码行数:27,代码来源:wiki2rst.py

示例8: run

def run(args=None):
    """Main entry point."""
    if args is None:
        args = sys.argv[1:]
    if has_babel:
        translation.activate(get_console_locale())
    warn_setuptools_issue()
    admin = TracAdmin()
    if len(args) > 0:
        if args[0] in ('-h', '--help', 'help'):
            return admin.onecmd(' '.join(['help'] + args[1:]))
        elif args[0] in ('-v','--version'):
            printout(os.path.basename(sys.argv[0]), TRAC_VERSION)
        else:
            env_path = os.path.abspath(args[0])
            try:
                unicode(env_path, 'ascii')
            except UnicodeDecodeError:
                printerr(_("Non-ascii environment path '%(path)s' not "
                           "supported.", path=to_unicode(env_path)))
                sys.exit(2)
            admin.env_set(env_path)
            if len(args) > 1:
                s_args = ' '.join(["'%s'" % c for c in args[2:]])
                command = args[1] + ' ' + s_args
                return admin.onecmd(command)
            else:
                while True:
                    try:
                        admin.run()
                    except KeyboardInterrupt:
                        admin.do_quit('')
    else:
        return admin.onecmd("help")
开发者ID:pkdevbox,项目名称:trac,代码行数:34,代码来源:console.py

示例9: globally_get_command_help

    def globally_get_command_help(self, *args):
        sys_home_project_name = self.config.get('multiproject', 'sys_home_project_name')
        for env_name, in self.projects_iterator(['env_name'], batch_size=1):
            if env_name == sys_home_project_name:
                continue
            env = None

            try:
                env_path = safe_path(self.config.get('multiproject', 'sys_projects_root'),
                    env_name)
                env = open_environment(env_path, True)
            except TracError as e:
                printout(_('ERROR: Opening environment %(env_name)s failed', env_name=env_name))
                continue

            try:
                command_manager = AdminCommandManager(env)
                helps = command_manager.get_command_help(list(args))
                if not args:
                    TracAdmin.print_doc(helps, short=True)
                elif len(helps) == 1:
                    TracAdmin.print_doc(helps, long=True)
                else:
                    TracAdmin.print_doc(helps)

            except AdminCommandError as e:
                printout(_('ERROR: Getting command help in environment %(env_name)s failed: ',
                    env_name=env_name) + e)
            break
开发者ID:alvabai,项目名称:trac-multiproject,代码行数:29,代码来源:console.py

示例10: _load_fixture_from_file

 def _load_fixture_from_file(self, fname):
     """Calls _load_fixture with an open file"""
     try:
         fp = open(fname, mode='r')
         self._load_fixture(fp)
         fp.close()
     except IOError:
         printout(_("The file '%(fname)s' does not exist", fname=fname))
开发者ID:Stackato-Apps,项目名称:bloodhound,代码行数:8,代码来源:admin.py

示例11: _do_remove

 def _do_remove(self, number):
     try:
         number = int(number)
     except ValueError:
         raise AdminCommandError(_('<number> must be a number'))
     with self.env.db_transaction:
         model.Ticket(self.env, number).delete()
     printout(_('Ticket #%(num)s and all associated data removed.',
                num=number))
开发者ID:Stackato-Apps,项目名称:bloodhound,代码行数:9,代码来源:admin.py

示例12: do_load

 def do_load(db):
     for page in os.listdir(dir):
         if page in ignore:
             continue
         filename = os.path.join(dir, page)
         page = unicode_unquote(page.encode('utf-8'))
         if os.path.isfile(filename):
             if self.import_page(filename, page, create_only, replace):
                 printout(_("  %(page)s imported from %(filename)s",
                            filename=filename, page=page))
开发者ID:wiraqutra,项目名称:photrackjp,代码行数:10,代码来源:admin.py

示例13: _add_comment

    def _add_comment(self, ticket_id, user, comment):
        """Add a comment to a ticket"""

        try:
            ticket = Ticket(self.env, ticket_id)
            self._save_ticket(ticket, user, comment)
            printout('Added comment to ticket %s' % ticket_id)
        except:
            # if no such ticket then add comment.
            printout('Unable to add comment.')
开发者ID:leihog,项目名称:TracTicketAdmin,代码行数:10,代码来源:api.py

示例14: do_transaction

 def do_transaction(db):
     for path in paths:
         if os.path.isdir(path):
             self.load_pages(path, replace=replace)
         else:
             page = os.path.basename(path)
             page = unicode_unquote(page.encode('utf-8'))
             if self.import_page(path, page, replace=replace):
                 printout(_("  %(page)s imported from %(filename)s",
                            filename=path, page=page))
开发者ID:wiraqutra,项目名称:photrackjp,代码行数:10,代码来源:admin.py

示例15: _do_remove

 def _do_remove(self, number):
     try:
         number = int(number)
     except ValueError:
         raise AdminCommandError(_('<number> must be a number'))
     @self.env.with_transaction()
     def do_remove(db):
         ticket = model.Ticket(self.env, number, db=db)
         ticket.delete()
     printout(_('Ticket #%(num)s and all associated data removed.',
                num=number))
开发者ID:zjj,项目名称:trac_hack,代码行数:11,代码来源:admin.py


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