本文整理汇总了Python中trac.wiki.model.WikiPage.text方法的典型用法代码示例。如果您正苦于以下问题:Python WikiPage.text方法的具体用法?Python WikiPage.text怎么用?Python WikiPage.text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trac.wiki.model.WikiPage
的用法示例。
在下文中一共展示了WikiPage.text方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: wiki_setup
# 需要导入模块: from trac.wiki.model import WikiPage [as 别名]
# 或者: from trac.wiki.model.WikiPage import text [as 别名]
def wiki_setup(tc):
wiki1 = WikiPage(tc.env)
wiki1.name = 'TestPage'
wiki1.text = '--'
wiki1.save('joe', 'normal WikiPageNames', '::1', 42)
wiki2 = WikiPage(tc.env)
wiki2.name = 'Space 1 23'
wiki2.text = '--'
wiki2.save('joe', 'not a WikiPageNames', '::1', 42)
wiki3 = WikiPage(tc.env)
wiki3.name = u"C'est l'\xe9t\xe9"
wiki3.text = '--'
wiki3.save('joe', 'unicode WikiPageNames', '::1', 42)
imt = WikiPage(tc.env)
imt.name = u"InterMapTxt"
imt.text = """
This is the InterMapTxt
----
{{{
MeatBall http://www.usemod.com/cgi-bin/mb.pl? # $1 in MeatBall...
tsvn tsvn:
complex http://server/$1/page/$2?format=txt # resource $2 in $1
}}}
----
{{{
nolink http://noweb
}}}
"""
imt.save('joe', 'test InterWiki links', '::1', 42)
示例2: _render_editor
# 需要导入模块: from trac.wiki.model import WikiPage [as 别名]
# 或者: from trac.wiki.model.WikiPage import text [as 别名]
def _render_editor(self, req, page, action='edit', has_collision=False):
if has_collision:
if action == 'merge':
page = WikiPage(self.env, page.name, version=None)
req.perm(page.resource).require('WIKI_VIEW')
else:
action = 'collision'
if page.readonly:
req.perm(page.resource).require('WIKI_ADMIN')
else:
req.perm(page.resource).require('WIKI_MODIFY')
original_text = page.text
if 'text' in req.args:
page.text = req.args.get('text')
elif 'template' in req.args:
template = self.PAGE_TEMPLATES_PREFIX + req.args.get('template')
template_page = WikiPage(self.env, template)
if template_page and template_page.exists and \
'WIKI_VIEW' in req.perm(template_page.resource):
page.text = template_page.text
if action == 'preview':
page.readonly = 'readonly' in req.args
author = get_reporter_id(req, 'author')
comment = req.args.get('comment', '')
editrows = req.args.get('editrows')
if editrows:
pref = req.session.get('wiki_editrows', '20')
if editrows != pref:
req.session['wiki_editrows'] = editrows
else:
editrows = req.session.get('wiki_editrows', '20')
data = self._page_data(req, page, action)
data.update({
'author': author,
'comment': comment,
'edit_rows': editrows,
'scroll_bar_pos': req.args.get('scroll_bar_pos', ''),
'diff': None,
})
if action in ('diff', 'merge'):
old_text = original_text and original_text.splitlines() or []
new_text = page.text and page.text.splitlines() or []
diff_data, changes = self._prepare_diff(
req, page, old_text, new_text, page.version, '')
data.update({'diff': diff_data, 'changes': changes,
'action': 'preview', 'merge': action == 'merge',
'longcol': 'Version', 'shortcol': 'v'})
self._wiki_ctxtnav(req, page)
return 'wiki_edit.html', data, None
示例3: wiki_setup
# 需要导入模块: from trac.wiki.model import WikiPage [as 别名]
# 或者: from trac.wiki.model.WikiPage import text [as 别名]
def wiki_setup(tc):
tc.env.config.set('wiki', 'render_unsafe_content', True) # for #9712
now = datetime.now(utc)
wiki0 = WikiPage(tc.env)
wiki0.name = 'Main/Sub'
wiki0.text = '--'
wiki0.save('joe', 'subpage', '::1', now)
wiki1 = WikiPage(tc.env)
wiki1.name = 'TestPage'
wiki1.text = '--'
wiki1.save('joe', 'normal WikiPageNames', '::1', now)
wiki2 = WikiPage(tc.env)
wiki2.name = 'Space 1 23'
wiki2.text = '--'
wiki2.save('joe', 'not a WikiPageNames', '::1', now)
wiki3 = WikiPage(tc.env)
wiki3.name = u"C'est l'\xe9t\xe9"
wiki3.text = '--'
wiki3.save('joe', 'unicode WikiPageNames', '::1', now)
imt = WikiPage(tc.env)
imt.name = u"InterMapTxt"
imt.text = """
This is the InterMapTxt
----
{{{
MeatBall http://www.usemod.com/cgi-bin/mb.pl? # $1 in MeatBall...
tsvn tsvn:
complex http://server/$1/page/$2?format=txt # resource $2 in $1
}}}
----
{{{
nolink http://noweb
}}}
"""
imt.save('joe', 'test InterWiki links', '::1', now)
w = WikiPage(tc.env)
w.name = 'FirstLevel'
w.text = '--'
w.save('joe', 'first level of hierarchy', '::1', now)
w = WikiPage(tc.env)
w.name = 'FirstLevel/SecondLevel'
w.text = '--'
w.save('joe', 'second level of hierarchy', '::1', now)
w = WikiPage(tc.env)
w.name = 'FirstLevel/SecondLevel/ThirdLevel'
w.text = '--'
w.save('joe', 'third level of hierarchy', '::1', now)
w = WikiPage(tc.env)
w.name = 'FirstLevel/SecondLevel/OtherThirdLevel'
w.text = '--'
w.save('joe', 'other third level of hierarchy', '::1', now)
示例4: test_index_wikis
# 需要导入模块: from trac.wiki.model import WikiPage [as 别名]
# 或者: from trac.wiki.model.WikiPage import text [as 别名]
def test_index_wikis(self):
self._insert_component('comp16')
self._insert_component('comp20')
wiki1 = WikiPage(self.env, name="Testwiki1", version="1")
wiki1.text = "This is the wiki <comp20 open door> text content."
wiki1.save('adeponte', 'My comment', '192.168.1.2')
wiki2 = WikiPage(self.env, name="Testwiki2", version="1")
wiki2.text = "This is the wiki <comp16 close door> text content."
wiki2.save('bob', 'His Comment', '182.123.321.456')
req_cache_sys = RequirementCacheSystem(self.env)
req_cache_sys.index_wikis()
req_wiki_cache = RequirementWikiCache(self.env, 'comp20', 'open', 'door', 'Testwiki1', '1')
self.assertEqual(req_wiki_cache.exists, True)
req_wiki_cache = RequirementWikiCache(self.env, 'comp16', 'close', 'door', 'Testwiki2', '1')
self.assertEqual(req_wiki_cache.exists, True)
示例5: add_pages
# 需要导入模块: from trac.wiki.model import WikiPage [as 别名]
# 或者: from trac.wiki.model.WikiPage import text [as 别名]
def add_pages(tc, names):
now = datetime.now(utc)
for name in names:
w = WikiPage(tc.env)
w.name = name
w.text = '--'
w.save('joe', 'the page ' + name, '::1', now)
示例6: set_password
# 需要导入模块: from trac.wiki.model import WikiPage [as 别名]
# 或者: from trac.wiki.model.WikiPage import text [as 别名]
def set_password(self, user, password):
import re
if len(user) < 3:
raise TracError("user name must be at least 3 characters long")
if not re.match(r"^\w+$", user):
raise TracError("user name must consist only of alpha-numeric characters")
if user not in self.get_users():
from trac.wiki.model import WikiPage
db = self.env.get_db_cnx()
page = WikiPage(self.env, user, db=db)
# User creation with existing page
if page.exists:
raise TracError('wiki page "%s" already exists' % user)
else:
from tractags.api import TagEngine
tagspace = TagEngine(self.env).tagspace.wiki
tagspace.add_tags(None, user, ["user"])
page.text = """= %(user)s =\n\n[[ListTagged(%(user)s)]]\n\n[[TagIt(user)]]""" % {"user": user}
page.save(user, "New user %s registered" % user, None)
self.env.log.debug("New user %s registered" % user)
HtPasswdStore.set_password(self, user, password)
示例7: import_wiki_pages
# 需要导入模块: from trac.wiki.model import WikiPage [as 别名]
# 或者: from trac.wiki.model.WikiPage import text [as 别名]
def import_wiki_pages(self, template_path):
"""Creates wiki pages from wiki.xml template file.
Creates wiki pages inside the project using data extracted from
an wiki.ml file. We don't set the author or version as that wouldn't
be applicable to a new project.
"""
# open the wiki XML file, parse the data and create wiki pages
full_path = os.path.join(template_path, 'wiki.xml')
try:
tree = ET.ElementTree(file=full_path)
for page in tree.getroot():
if page.text:
wikipage = WikiPage(self.env, page.attrib['name'])
wikipage.readonly = int(page.attrib['readonly']) # we store as a string in xml
wikipage.text = page.text
wikipage.save(None, None, None)
self.log.info("Wiki page %s created", page.attrib['name'])
else:
self.log.debug("Cannot create wiki pages with no text. "
"Unable to import %s", wikipage)
except IOError as exception:
if exception.errno == errno.ENOENT:
self.log.info("Path to wiki.xml file %s does not exist. Unable "
"to import wiki pages from template.", full_path)
示例8: initialize_agilo
# 需要导入模块: from trac.wiki.model import WikiPage [as 别名]
# 或者: from trac.wiki.model.WikiPage import text [as 别名]
def initialize_agilo(self, project_name, db_url, svn_repo, demo=False):
try:
self.do_initenv('%s %s %s %s' % (project_name,
db_url, 'svn',
svn_repo or 'somewhere'))
# Now add agilo and the template path
env = Environment(self.envname)
ac = AgiloConfig(env)
if not svn_repo:
# remove the fake from the config
ac.change_option('repository_dir', '', 'trac')
# sets the restric_owner option
ac.change_option('restrict_owner',
'true',
'ticket')
# this is also saving the config
ac.enable_agilo()
# update wiki
wiki = WikiPage(env, name='WikiStart')
wiki.text = agilo_wiki
wiki.save('admin', 'Updated to Agilo', '127.0.0.1')
# reset the env
self.env_set(envname=self.envname, env=env)
# Now initialize Agilo
self.do_upgrade('upgrade --no-backup')
# Now create the demo if needed
if demo:
try:
from create_demo_data import _create_demo_data
_create_demo_data(env)
except ImportError, e:
env.log.error(exception_to_unicode(e))
except:
pass
示例9: main
# 需要导入模块: from trac.wiki.model import WikiPage [as 别名]
# 或者: from trac.wiki.model.WikiPage import text [as 别名]
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)
示例10: do_upgrade_environment
# 需要导入模块: from trac.wiki.model import WikiPage [as 别名]
# 或者: from trac.wiki.model.WikiPage import text [as 别名]
def do_upgrade_environment(db):
for realm in self.SCHEMA:
realm_schema = self.SCHEMA[realm]
if need_db_create_for_realm(self.env, realm, realm_schema, db):
create_db_for_realm(self.env, realm, realm_schema, db)
elif need_db_upgrade_for_realm(self.env, realm, realm_schema, db):
upgrade_db_for_realm(self.env, 'testmanager.upgrades', realm, realm_schema, db)
# Create default values for configuration properties and initialize counters
db_insert_or_ignore(self.env, 'testconfig', 'NEXT_CATALOG_ID', '0', db)
db_insert_or_ignore(self.env, 'testconfig', 'NEXT_TESTCASE_ID', '0', db)
db_insert_or_ignore(self.env, 'testconfig', 'NEXT_PLAN_ID', '0', db)
db.commit()
# Fix templates with a blank id
if self._check_blank_id_templates(db):
self._fix_blank_id_templates(db)
db.commit()
self.env.log.info(_("""
Test Manager templates with blank IDs have been fixed.\n
Please go to the Administration panel, in the Test Manager Templates
section, and check the associations between templates and Test Cases
and Test Catalogs.\n
You will have to manually fix any misconfiguration you should find.
"""))
# Create the basic "TC" Wiki page, used as the root test catalog
tc_page = WikiPage(self.env, 'TC')
if not tc_page.exists:
tc_page.text = ' '
tc_page.save('System', '', '127.0.0.1')
db.commit()
if self._need_upgrade(db):
# Set custom ticket field to hold related test case
custom = self.config['ticket-custom']
config_dirty = False
if 'testcaseid' not in custom:
custom.set('testcaseid', 'text')
custom.set('testcaseid.label', _("Test Case"))
config_dirty = True
if 'planid' not in custom:
custom.set('planid', 'text')
custom.set('planid.label', _("Test Plan"))
config_dirty = True
# Set config section for test case outcomes
if 'test-outcomes' not in self.config:
self.config.set('test-outcomes', 'green.SUCCESSFUL', _("Successful"))
self.config.set('test-outcomes', 'yellow.TO_BE_TESTED', _("Untested"))
self.config.set('test-outcomes', 'red.FAILED', _("Failed"))
self.config.set('test-outcomes', 'default', 'TO_BE_TESTED')
config_dirty = True
if config_dirty:
self.config.save()
示例11: main
# 需要导入模块: from trac.wiki.model import WikiPage [as 别名]
# 或者: from trac.wiki.model.WikiPage import text [as 别名]
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)
示例12: setUp
# 需要导入模块: from trac.wiki.model import WikiPage [as 别名]
# 或者: from trac.wiki.model.WikiPage import text [as 别名]
def setUp(self):
wiki = WikiPage(self.env)
wiki.name = 'WikiStart'
wiki.text = '--'
wiki.save('joe', 'Entry page', '::1', datetime.now(utc))
if self._setup:
self._setup(self)
示例13: _do_wiki_upgrade
# 需要导入模块: from trac.wiki.model import WikiPage [as 别名]
# 或者: from trac.wiki.model.WikiPage import text [as 别名]
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')
示例14: save_wiki_data
# 需要导入模块: from trac.wiki.model import WikiPage [as 别名]
# 或者: from trac.wiki.model.WikiPage import text [as 别名]
def save_wiki_data(self, req):
page = WikiPage(self.env, self.name)
if not page.exists:
self.log.error('Wiki page "%s" doesn\'t exist' % self.name)
return None
lines = page.text.split('\n')
first = -1
last = -1
new_lines = []
for index, line in enumerate(lines):
if first < 0:
new_lines.append(line)
if self.data_start_regexp.match(line):
first = index + 1
new_lines.append(self.get_json(False, True))
elif last < 0:
if self.data_end_regexp.match(line):
last = index - 1
new_lines.append(line)
else:
new_lines.append(line)
if last > 0:
page.text = '\n'.join(new_lines)
try:
page.save(req.authname, 'Kanban board data changed', req.remote_addr)
except TracError as e:
self.log.error('TracError: "%s"' % e.message)
示例15: _process_page
# 需要导入模块: from trac.wiki.model import WikiPage [as 别名]
# 或者: from trac.wiki.model.WikiPage import text [as 别名]
def _process_page(self, page, author = None, comment = None, ipnr = None):
if self.boilerplate_start_re.search( page.text ) != None:
# If the audit info isn't available, grab it from the boilerplate page.
if author == None or comment == None:
page = WikiPage( self.env, page.name )
if author == None:
author = page.author
if comment == None:
comment = page.comment
if ipnr == None:
ipnr = '127.0.0.1' # I don't know what else to do here.
# Extract the boilerplate text and the wanted pages.
buf = StringIO()
page_list = {}
inboilerplate = False
for line in page.text.splitlines():
if inboilerplate:
if self.boilerplate_end_re.search( line ) != None:
inboilerplate = False
else:
buf.write( line )
buf.write( '\n' )
else:
if self.boilerplate_start_re.search( line ) != None:
inboilerplate = True
else:
if line.startswith('||') and line.endswith('||') and line[3] != "'":
try:
descriptor = ([i.strip() for i in line.strip('||').split('||')])
name = descriptor[0]
arguments = descriptor[1:]
m = self.extractpagename_re.search( name )
if m != None:
name = m.string[m.start(1):m.end(1)]
self.env.log.warning("extracted name = " + name )
page_list[ name ] = arguments
except Exception, e:
self.env.log.warning("Invalid page line: %s (%s)", line, e)
# Generate the derived pages as instructed.
page_names = page_list.keys()
page_names.sort()
for name in page_names:
text = buf.getvalue()
args = page_list[ name ]
text = text.replace( '{{0}}', name )
i = 0
for arg in args:
text = text.replace('{{%d}}' % (i+1), args[i])
i += 1
newpage = WikiPage( self.env, name )
if newpage.text != text:
newpage.text = text
newpage.save( author, comment, ipnr )