Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-wiki
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
django-wiki
Commits
4ec26b2d
Commit
4ec26b2d
authored
Oct 01, 2014
by
Luke Plant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Python 3 compatibility (or at least correct syntax) for mediawikimport command
parent
7c10ab9d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
+8
-6
wiki/plugins/mediawikiimport/management/commands/mediawiki_import.py
+8
-6
No files found.
wiki/plugins/mediawikiimport/management/commands/mediawiki_import.py
View file @
4ec26b2d
from
__future__
import
print_function
from
django.core.management.base
import
BaseCommand
,
CommandError
import
getpass
...
...
@@ -87,7 +89,7 @@ class Command(BaseCommand):
self
.
articles_worked_on
.
append
(
urltitle
)
print
"Working on
%
s (
%
s)"
%
(
title
,
urltitle
)
print
(
"Working on
%
s (
%
s)"
%
(
title
,
urltitle
)
)
# Check if the URL path already exists
try
:
...
...
@@ -96,10 +98,10 @@ class Command(BaseCommand):
self
.
matching_old_link_new_link
[
page
.
title
]
=
urlp
.
article
.
get_absolute_url
()
if
not
replace_existing
:
print
"
\t
Already existing, skipping..."
print
(
"
\t
Already existing, skipping..."
)
return
print
"
\t
Destorying old version of the article"
print
(
"
\t
Destorying old version of the article"
)
urlp
.
article
.
delete
()
except
URLPath
.
DoesNotExist
:
...
...
@@ -116,7 +118,7 @@ class Command(BaseCommand):
else
:
user
=
get_user_model
()
.
objects
.
get
(
username
=
history_page
[
'user'
])
except
get_user_model
()
.
DoesNotExist
:
print
"
\t
Cannot found user with username=
%
s. Use --user-matching
\"
%
s:<user_pk>
\"
to manualy set it"
%
(
history_page
[
'user'
],
history_page
[
'user'
],
)
print
(
"
\t
Cannot found user with username=
%
s. Use --user-matching
\"
%
s:<user_pk>
\"
to manualy set it"
%
(
history_page
[
'user'
],
history_page
[
'user'
],
)
)
user
=
None
article_revision
=
ArticleRevision
()
...
...
@@ -149,9 +151,9 @@ class Command(BaseCommand):
# TODO: nsquare is bad
for
(
article
,
article_revision
)
in
self
.
articles_imported
:
print
"Updating links of
%
s"
%
(
article_revision
.
title
,
)
print
(
"Updating links of
%
s"
%
(
article_revision
.
title
,
)
)
for
id_from
,
id_to
in
self
.
matching_old_link_new_link
.
iteritems
():
print
"Replacing (
%
s
\"
wikilink
\"
) with (
%
s)"
%
(
id_from
,
id_to
)
print
(
"Replacing (
%
s
\"
wikilink
\"
) with (
%
s)"
%
(
id_from
,
id_to
)
)
article_revision
.
content
=
article_revision
.
content
.
replace
(
"(
%
s
\"
wikilink
\"
)"
%
(
id_from
,
),
"(
%
s)"
%
(
id_to
,))
article_revision
.
save
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment