Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
wikibot
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Magnus Giesbert
wikibot
Commits
c86c9403
Commit
c86c9403
authored
2 years ago
by
Magnus Giesbert
Browse files
Options
Downloads
Patches
Plain Diff
Update wikibot.py
parent
e25ac65d
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
wikibot.py
+11
-1
11 additions, 1 deletion
wikibot.py
with
11 additions
and
1 deletion
wikibot.py
+
11
−
1
View file @
c86c9403
...
@@ -2,9 +2,10 @@
...
@@ -2,9 +2,10 @@
import
config
import
config
from
xmlrpc.client
import
ServerProxy
as
Proxy
,
Error
as
wikiError
from
xmlrpc.client
import
ServerProxy
as
Proxy
,
Error
as
wikiError
import
re
import
re
import
datetime
# rename/move a page
def
move_page
(
original_page
,
new_page
,
delete
=
False
):
def
move_page
(
original_page
,
new_page
,
delete
=
False
):
"""
Moves a page, updates link to new page and flags or deletes the old one
"""
with
Proxy
(
config
.
WIKI_API_URL
)
as
proxy
:
with
Proxy
(
config
.
WIKI_API_URL
)
as
proxy
:
# create new page with identical content #
# create new page with identical content #
page_content
=
proxy
.
wiki
.
getPage
(
original_page
)
page_content
=
proxy
.
wiki
.
getPage
(
original_page
)
...
@@ -25,3 +26,12 @@ def move_page(original_page, new_page, delete=False):
...
@@ -25,3 +26,12 @@ def move_page(original_page, new_page, delete=False):
{
"
sum
"
:
"
Moved to
"
+
new_page
+
"
and marked page for deletion
"
})
{
"
sum
"
:
"
Moved to
"
+
new_page
+
"
and marked page for deletion
"
})
else
:
else
:
proxy
.
wiki
.
putPage
(
original_page
,
""
,
{
"
sum
"
:
"
Moved to
"
+
new_page
})
# deletes original page
proxy
.
wiki
.
putPage
(
original_page
,
""
,
{
"
sum
"
:
"
Moved to
"
+
new_page
})
# deletes original page
def
find_old_pages
(
timedelta
,
namespace
=
""
):
"""
Returns all pages whose rev is older than the given timedelta
"""
with
Proxy
(
config
.
WIKI_API_URL
)
as
proxy
:
pages
=
proxy
.
dokuwiki
.
getPagelist
(
namespace
)
proxy_time
=
proxy
.
dokuwiki
.
getTime
()
old_pages
=
[
page
for
page
in
pages
if
(
proxy_time
-
page
.
get
(
'
rev
'
)
>
timedelta
.
total_seconds
())]
return
old_pages
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment