INCR-337 Python 3 compatibility (#20993)
* ran python-modernize and isort on files specified in INCR-337 * changes made to comply with pylint
This commit is contained in:
@@ -1,18 +1,19 @@
|
||||
"""
|
||||
Django management command to create a course in a specific modulestore
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
from six import text_type
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from six import text_type
|
||||
|
||||
from contentstore.management.commands.utils import user_from_str
|
||||
from contentstore.views.course import create_new_course_in_store
|
||||
from xmodule.modulestore import ModuleStoreEnum
|
||||
from xmodule.modulestore.exceptions import DuplicateCourseError
|
||||
|
||||
|
||||
MODULESTORE_CHOICES = (ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split)
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"""Script for deleting orphans"""
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import, print_function
|
||||
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from opaque_keys import InvalidKeyError
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
"""
|
||||
Script for exporting courseware from Mongo to a tar.gz file
|
||||
"""
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import, print_function
|
||||
|
||||
import os
|
||||
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
"""
|
||||
Script for fixing the item not found errors in a course
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
|
||||
from xmodule.modulestore import ModuleStoreEnum
|
||||
from xmodule.modulestore.django import modulestore
|
||||
|
||||
|
||||
# To run from command line: ./manage.py cms fix_not_found course-v1:org+course+run
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
"""
|
||||
Script for force publishing a course
|
||||
"""
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import, print_function
|
||||
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from opaque_keys import InvalidKeyError
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
@@ -12,7 +13,6 @@ from xmodule.modulestore.django import modulestore
|
||||
from .prompt import query_yes_no
|
||||
from .utils import get_course_versions
|
||||
|
||||
|
||||
# To run from command line: ./manage.py cms force_publish course-v1:org+course+run
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
"""
|
||||
Django management command to generate a test course from a course config json
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
import json
|
||||
import logging
|
||||
from six import text_type
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from six import text_type
|
||||
|
||||
from contentstore.management.commands.utils import user_from_str
|
||||
from contentstore.views.course import create_new_course_in_store
|
||||
@@ -73,7 +75,7 @@ class Command(BaseCommand):
|
||||
|
||||
def _process_course_fields(self, fields):
|
||||
""" Returns a validated list of course fields """
|
||||
all_fields = CourseFields.__dict__.keys()
|
||||
all_fields = list(CourseFields.__dict__.keys())
|
||||
non_course_fields = [
|
||||
"__doc__",
|
||||
"__module__",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""
|
||||
Script for importing a content library from a tar.gz file
|
||||
"""
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import, print_function
|
||||
|
||||
import base64
|
||||
import os
|
||||
@@ -14,15 +14,16 @@ from django.core.management.base import BaseCommand, CommandError
|
||||
from lxml import etree
|
||||
from opaque_keys.edx.locator import LibraryLocator
|
||||
from path import Path
|
||||
from six.moves import input
|
||||
|
||||
from cms.djangoapps.contentstore.utils import add_instructor
|
||||
from openedx.core.lib.extract_tar import safetar_extractall
|
||||
from xmodule.contentstore.django import contentstore
|
||||
from xmodule.modulestore import ModuleStoreEnum
|
||||
from xmodule.modulestore.django import modulestore
|
||||
from xmodule.modulestore.exceptions import DuplicateCourseError
|
||||
from xmodule.modulestore.xml_importer import import_library_from_xml
|
||||
|
||||
from cms.djangoapps.contentstore.utils import add_instructor
|
||||
from openedx.core.lib.extract_tar import safetar_extractall
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
"""
|
||||
@@ -76,7 +77,7 @@ class Command(BaseCommand):
|
||||
# Check if data would be overwritten
|
||||
ans = ''
|
||||
while not created and ans not in ['y', 'yes', 'n', 'no']:
|
||||
inp = raw_input(u'Library "{0}" already exists, overwrite it? [y/n] '.format(courselike_key))
|
||||
inp = input(u'Library "{0}" already exists, overwrite it? [y/n] '.format(courselike_key))
|
||||
ans = inp.lower()
|
||||
if ans.startswith('n'):
|
||||
print(u'Aborting import of "{0}"'.format(courselike_key))
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
""" Management command to update libraries' search index """
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import, print_function
|
||||
|
||||
from textwrap import dedent
|
||||
|
||||
from django.core.management import BaseCommand, CommandError
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from opaque_keys.edx.locator import LibraryLocator
|
||||
from six.moves import map
|
||||
|
||||
from contentstore.courseware_index import LibrarySearchIndexer
|
||||
from xmodule.modulestore.django import modulestore
|
||||
@@ -58,7 +60,7 @@ class Command(BaseCommand):
|
||||
else:
|
||||
return
|
||||
else:
|
||||
library_keys = map(self._parse_library_key, options['library_ids'])
|
||||
library_keys = list(map(self._parse_library_key, options['library_ids']))
|
||||
|
||||
for library_key in library_keys:
|
||||
print(u"Indexing library {}".format(library_key))
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
"""Management command to restore assets from trash"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
from xmodule.contentstore.utils import restore_asset_from_trashcan
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
"""Command class to handle asset restore"""
|
||||
help = '''Restore a deleted asset from the trashcan back to it's original course'''
|
||||
|
||||
def add_arguments(self, parser):
|
||||
|
||||
Reference in New Issue
Block a user