本文整理汇总了Python中MoinMoin.PageEditor.PageEditor.current_rev方法的典型用法代码示例。如果您正苦于以下问题:Python PageEditor.current_rev方法的具体用法?Python PageEditor.current_rev怎么用?Python PageEditor.current_rev使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MoinMoin.PageEditor.PageEditor
的用法示例。
在下文中一共展示了PageEditor.current_rev方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_addattachment
# 需要导入模块: from MoinMoin.PageEditor import PageEditor [as 别名]
# 或者: from MoinMoin.PageEditor.PageEditor import current_rev [as 别名]
def do_addattachment(self, zipname, filename, pagename, author=u"Scripting Subsystem", comment=u""):
"""
Installs an attachment
@param pagename: Page where the file is attached. Or in 2.0, the file itself.
@param zipname: Filename of the attachment from the zip file
@param filename: Filename of the attachment (just applicable for MoinMoin < 2.0)
"""
if self.request.user.may.write(pagename):
_ = self.request.getText
attachments = Page(self.request, pagename).getPagePath("attachments", check_create=1)
filename = wikiutil.taintfilename(filename)
zipname = wikiutil.taintfilename(zipname)
target = os.path.join(attachments, filename)
page = PageEditor(self.request, pagename, do_editor_backup=0, uid_override=author)
rev = page.current_rev()
path = page.getPagePath(check_create=0)
if not os.path.exists(target):
self._extractToFile(zipname, target)
if os.path.exists(target):
os.chmod(target, config.umask )
action = 'ATTNEW'
edit_logfile_append(self, pagename, path, rev, action, logname='edit-log',
comment=u'%(filename)s' % {"filename": filename}, author=author)
self.msg += u"%(filename)s attached \n" % {"filename": filename}
else:
self.msg += u"%(filename)s not attached \n" % {"filename": filename}
else:
self.msg += u"action add attachment: not enough rights - nothing done \n"
示例2: do_delattachment
# 需要导入模块: from MoinMoin.PageEditor import PageEditor [as 别名]
# 或者: from MoinMoin.PageEditor.PageEditor import current_rev [as 别名]
def do_delattachment(self, filename, pagename, author=u"Scripting Subsystem", comment=u""):
"""
Removes an attachment
@param pagename: Page where the file is attached. Or in 2.0, the file itself.
@param filename: Filename of the attachment (just applicable for MoinMoin < 2.0)
"""
if self.request.user.may.write(pagename):
_ = self.request.getText
attachments = Page(self.request, pagename).getPagePath("attachments", check_create=1)
filename = wikiutil.taintfilename(filename)
target = os.path.join(attachments, filename)
page = PageEditor(self.request, pagename, do_editor_backup=0, uid_override=author)
rev = page.current_rev()
path = page.getPagePath(check_create=0)
if os.path.exists(target):
os.remove(target)
action = 'ATTDEL'
edit_logfile_append(self, pagename, path, rev, action, logname='edit-log',
comment=u'%(filename)s' % {"filename": filename}, author=author)
self.msg += u"%(filename)s removed \n" % {"filename": filename}
else:
self.msg += u"%(filename)s does not exist \n" % {"filename": filename}
else:
self.msg += u"action delete attachment: not enough rights - nothing done \n"
示例3: execute
# 需要导入模块: from MoinMoin.PageEditor import PageEditor [as 别名]
# 或者: from MoinMoin.PageEditor.PageEditor import current_rev [as 别名]
def execute (pagename, request):
# get the etherpad instance and related information:
(ep, padname, padURL) = etherpadConnect (pagename)
# teh moinmoin data:
pe = PageEditor(request, pagename)
currev = pe.current_rev()
request.reset()
try:
padtext = ep.getText (padname)[u'text']
try:
pe.saveText (padtext, currev)
msg = "Text has been successfully obtained from Etherpad."
except Exception as e:
msg = "Text has been obtained from Etherpad, but an error occured when saving it to Wiki. "
except Exception as e:
msg = "An error occured when trying to obtain text from Etherpad."
request.theme.add_msg(msg, "info")
pe.send_page()
示例4: addcomment
# 需要导入模块: from MoinMoin.PageEditor import PageEditor [as 别名]
# 或者: from MoinMoin.PageEditor.PageEditor import current_rev [as 别名]
def addcomment(macro, comicon, comauthor, comtext, compasswd, comrev, comautopass, commarkup):
# Add a comment with inputs
request = Globs.macro.request
cfg = request.cfg
_ = request.getText
datapagename = Globs.datapagename
pg = PageEditor( request, datapagename )
pagetext = pg.get_raw_body()
# HACK for despam
try:
if not request.user.may.save( pg, comtext, pg.current_rev()):
#message("No permission to save this text.")
#return 0
pass
except pg.SaveError, msg:
message(msg)
return 0
示例5: processWeapon
# 需要导入模块: from MoinMoin.PageEditor import PageEditor [as 别名]
# 或者: from MoinMoin.PageEditor.PageEditor import current_rev [as 别名]
def processWeapon(j, context, is_sub, dry_run):
status_map = j.get(u'subStatusMap' if is_sub else u'statusMap', {}) or {}
weapon_name = j.get(u'subWeaponName' if is_sub else u'weaponName', u'').strip()
level = j.get(u'subWeaponLevel' if is_sub else u'weaponLevel', 0)
if not status_map or not weapon_name or not level:
print u'Weapon %s is missing critical params.' % weapon_name
return
page = PageEditor(context, weapon_name)
body_pre = u''
body_json = {}
body_post = u''
if page.isStandardPage():
match = RE_WEAPON_PAGE.match(page.get_body())
if match:
body_pre = match.group(u'pre')
body_post = match.group(u'post')
try:
body_json = json.loads(match.group(u'body'))
except Error:
pass
diff_dst_json = statusMapToAttrs(status_map)
if not is_sub and j.get(u'subStatusMap', {}):
diff_dst_json[u'サブウェポン'] = {
u'名称': j[u'subWeaponName'].strip(),
u'レベル': int(j[u'subWeaponLevel']),
}
if not body_json:
body_pre = WEAPON_PAGE_DEFAULT_BODY_PRE
body_post = WEAPON_PAGE_DEFAULT_BODY_POST
body_json = {
u'名称': weapon_name,
u'レベル': {},
u'弾種': j.get(u'subBulletTypeName' if is_sub else u'bulletTypeName', u''),
}
levels_json = body_json.get(u'レベル', {})
if not levels_json:
levels_json = {}
body_json[u'レベル'] = levels_json
dst_json = levels_json.get(u'%d' % level, {})
if not dst_json:
dst_json = {}
levels_json[u'%d' % level] = dst_json
dst_json.update(diff_dst_json)
# clenup legacy attrs
if u'爆発半径' in dst_json:
del dst_json[u'爆発半径']
if u'発射準備時間' in dst_json:
del dst_json[u'発射準備時間']
output = (body_pre + u'\n'
+ json_printer.print_json(body_json, indent=2) + u'\n'
+ body_post)
try:
if not dry_run:
page.saveText(output, page.current_rev())
print u'Processed weapon %s correctly.' % weapon_name
else:
differ = difflib.Differ(charjunk=lambda c:c.isspace())
l = map(lambda s: s.strip(), page.get_body().splitlines())
r = map(lambda s: s.strip(), output.splitlines())
if l != r:
d = u'\n'.join(filter(lambda s: s and s[0] in u'+-?', differ.compare(l, r)))
print((u'#### Diff in %s ####' % weapon_name).encode('utf-8'))
print(d.encode('utf-8'))
except PageEditor.Unchanged:
pass
if not is_sub and j.get(u'subStatusMap', {}):
processWeapon(j, context, True, dry_run)
示例6: processWeaponPack
# 需要导入模块: from MoinMoin.PageEditor import PageEditor [as 别名]
# 或者: from MoinMoin.PageEditor.PageEditor import current_rev [as 别名]
def processWeaponPack(j, context, dry_run):
wp_name = j.get(u'weaponPackName', None)
if not wp_name:
return
page = PageEditor(context, wp_name)
body_pre = u''
body_json = {}
body_post = u''
if page.isStandardPage():
match = RE_WP_PAGE.match(page.get_body())
if match:
body_pre = match.group(u'pre')
body_post = match.group(u'post')
try:
body_json = json.loads(match.group(u'body'))
except Error:
pass
def getBriefWeaponJson(weapon):
return {
u'名称': weapon.get(u'weaponName').strip(),
u'レベル': weapon.get(u'weaponLevel'),
}
w_map = j.get(u'weaponMap', {})
json_diff = {
u'コスト': j.get(u'cost', 0),
u'耐久力': j.get(u'hitPoint', 0),
u'格闘補正': j.get(u'grappleUp', 1.0),
u'右手武器': getBriefWeaponJson(w_map.get(u'right', {})),
u'左手武器': getBriefWeaponJson(w_map.get(u'left', {})),
u'サイド武器': getBriefWeaponJson(w_map.get(u'side', {})),
u'タンデム武器': getBriefWeaponJson(w_map.get(u'tandem', {})),
}
if not body_json:
body_pre = WP_PAGE_DEFAULT_BODY_PRE
body_json = {
u'名称': wp_name,
u'入手条件': u'',
u'タイプ': u''
}
body_post = WP_PAGE_DEFAULT_BODY_POST
body_json.update(json_diff)
output = (body_pre + u'\n'
+ json_printer.print_json(body_json, indent=2) + u'\n'
+ body_post)
try:
if not dry_run:
page.saveText(output, page.current_rev())
print u'Processed %s correctly.' % wp_name
else:
differ = difflib.Differ()
l = map(lambda s: s.strip(), page.get_body().splitlines())
r = map(lambda s: s.strip(), output.splitlines())
if l != r:
d = u'\n'.join(filter(lambda s: s and s[0] in u'+-?', differ.compare(l, r)))
print((u'#### Diff in %s ####' % wp_name).encode('utf-8'))
print(d.encode('utf-8'))
except PageEditor.Unchanged:
pass
示例7: ScriptContext
# 需要导入模块: from MoinMoin.PageEditor import PageEditor [as 别名]
# 或者: from MoinMoin.PageEditor.PageEditor import current_rev [as 别名]
import argparse
from MoinMoin.PageEditor import PageEditor
from MoinMoin.web.contexts import ScriptContext
from MoinMoin.web.request import TestRequest
from MoinMoin.Page import RootPage
from macro.utils import json_printer, json_loader
COMMENTS = u"""==== コメント ====
<<AddComment>>
<<Comments>>"""
RE_COMMENTS = re.compile(ur"====\s*コメント\s*====\s*<<AddComment>>\s*<<Comments>>")
if __name__ == "__main__":
from MoinMoin import config
context = ScriptContext()
context.remote_addr = "127.0.0.1"
root_page = RootPage(context)
for page_name in root_page.getPageList(user=""):
page = PageEditor(context, page_name)
data = page.get_raw_body()
match = RE_COMMENTS.search(data)
if match:
data = RE_COMMENTS.sub(u"", data)
data += COMMENTS
page.saveText(data, page.current_rev())