Commit 2a025909 by Ned Batchelder

Change imports from path to use the stablest name.

The old line:

    from path import path

produced pylint errors because of the baroque way that path.py defined
"path".  We tried to get them to change how they defined it, but they
deleted the name instead: https://github.com/jaraco/path.py/issues/102

(Jason then changed his mind, but this is a better way to use path.py,
it avoids the pylint error at least.)
parent 3c400783
...@@ -5,7 +5,7 @@ to the archive format used by a different version of export. ...@@ -5,7 +5,7 @@ to the archive format used by a different version of export.
Sample invocation: ./manage.py export_convert_format mycourse.tar.gz ~/newformat/ Sample invocation: ./manage.py export_convert_format mycourse.tar.gz ~/newformat/
""" """
import os import os
from path import path from path import Path as path
from django.core.management.base import BaseCommand, CommandError from django.core.management.base import BaseCommand, CommandError
from django.conf import settings from django.conf import settings
......
...@@ -6,7 +6,7 @@ from django.core.management import call_command, CommandError ...@@ -6,7 +6,7 @@ from django.core.management import call_command, CommandError
from django.conf import settings from django.conf import settings
from tempfile import mkdtemp from tempfile import mkdtemp
import shutil import shutil
from path import path from path import Path as path
from contentstore.management.commands.export_convert_format import Command, extract_source from contentstore.management.commands.export_convert_format import Command, extract_source
from xmodule.tests.helpers import directories_equal from xmodule.tests.helpers import directories_equal
......
...@@ -3,7 +3,7 @@ Unittests for importing a course via management command ...@@ -3,7 +3,7 @@ Unittests for importing a course via management command
""" """
import os import os
from path import path from path import Path as path
import shutil import shutil
import tempfile import tempfile
......
...@@ -11,7 +11,7 @@ import ddt ...@@ -11,7 +11,7 @@ import ddt
from datetime import timedelta from datetime import timedelta
from fs.osfs import OSFS from fs.osfs import OSFS
from json import loads from json import loads
from path import path from path import Path as path
from textwrap import dedent from textwrap import dedent
from uuid import uuid4 from uuid import uuid4
from functools import wraps from functools import wraps
......
...@@ -8,7 +8,7 @@ import os ...@@ -8,7 +8,7 @@ import os
import re import re
import shutil import shutil
import tarfile import tarfile
from path import path from path import Path as path
from tempfile import mkdtemp from tempfile import mkdtemp
from django.conf import settings from django.conf import settings
......
...@@ -9,7 +9,7 @@ import os ...@@ -9,7 +9,7 @@ import os
import shutil import shutil
import tarfile import tarfile
import tempfile import tempfile
from path import path from path import Path as path
from uuid import uuid4 from uuid import uuid4
from django.test.utils import override_settings from django.test.utils import override_settings
......
...@@ -18,7 +18,7 @@ from .common import * ...@@ -18,7 +18,7 @@ from .common import *
from openedx.core.lib.logsettings import get_logger_config from openedx.core.lib.logsettings import get_logger_config
import os import os
from path import path from path import Path as path
from xmodule.modulestore.modulestore_settings import convert_module_store_setting_if_needed from xmodule.modulestore.modulestore_settings import convert_module_store_setting_if_needed
# SERVICE_VARIANT specifies name of the variant used, which decides what JSON # SERVICE_VARIANT specifies name of the variant used, which decides what JSON
......
...@@ -11,7 +11,7 @@ from the same directory. ...@@ -11,7 +11,7 @@ from the same directory.
""" """
import os import os
from path import path from path import Path as path
# Pylint gets confused by path.py instances, which report themselves as class # Pylint gets confused by path.py instances, which report themselves as class
# objects. As a result, pylint applies the wrong regex in validating names, # objects. As a result, pylint applies the wrong regex in validating names,
......
...@@ -46,7 +46,7 @@ from lms.envs.common import ( ...@@ -46,7 +46,7 @@ from lms.envs.common import (
# display credit eligibility table on the CMS or not. # display credit eligibility table on the CMS or not.
ENABLE_CREDIT_ELIGIBILITY, YOUTUBE_API_KEY ENABLE_CREDIT_ELIGIBILITY, YOUTUBE_API_KEY
) )
from path import path from path import Path as path
from warnings import simplefilter from warnings import simplefilter
from lms.djangoapps.lms_xblock.mixin import LmsBlockMixin from lms.djangoapps.lms_xblock.mixin import LmsBlockMixin
......
...@@ -20,7 +20,7 @@ sessions. Assumes structure: ...@@ -20,7 +20,7 @@ sessions. Assumes structure:
from .common import * from .common import *
import os import os
from path import path from path import Path as path
from warnings import filterwarnings, simplefilter from warnings import filterwarnings, simplefilter
from uuid import uuid4 from uuid import uuid4
......
...@@ -21,7 +21,7 @@ from openedx.core.lib.logsettings import get_logger_config ...@@ -21,7 +21,7 @@ from openedx.core.lib.logsettings import get_logger_config
from util.config_parse import convert_tokens from util.config_parse import convert_tokens
import os import os
from path import path from path import Path as path
from xmodule.modulestore.modulestore_settings import convert_module_store_setting_if_needed from xmodule.modulestore.modulestore_settings import convert_module_store_setting_if_needed
# https://stackoverflow.com/questions/2890146/how-to-force-pyyaml-to-load-strings-as-unicode-objects # https://stackoverflow.com/questions/2890146/how-to-force-pyyaml-to-load-strings-as-unicode-objects
......
...@@ -7,7 +7,7 @@ from __future__ import unicode_literals ...@@ -7,7 +7,7 @@ from __future__ import unicode_literals
import argparse import argparse
import logging import logging
import sys import sys
from path import path from path import Path as path
from cStringIO import StringIO from cStringIO import StringIO
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
Test for asset XML generation / parsing. Test for asset XML generation / parsing.
""" """
from path import path from path import Path as path
from lxml import etree from lxml import etree
from contracts import ContractNotRespected from contracts import ContractNotRespected
import unittest import unittest
......
...@@ -5,7 +5,7 @@ import logging ...@@ -5,7 +5,7 @@ import logging
from cStringIO import StringIO from cStringIO import StringIO
from math import exp from math import exp
from lxml import etree from lxml import etree
from path import path # NOTE (THK): Only used for detecting presence of syllabus from path import Path as path
import requests import requests
from datetime import datetime from datetime import datetime
import dateutil.parser import dateutil.parser
......
...@@ -5,7 +5,7 @@ import copy ...@@ -5,7 +5,7 @@ import copy
import logging import logging
import textwrap import textwrap
from lxml import etree from lxml import etree
from path import path from path import Path as path
from fs.errors import ResourceNotFoundError from fs.errors import ResourceNotFoundError
from pkg_resources import resource_string from pkg_resources import resource_string
......
...@@ -23,7 +23,7 @@ from bson.son import SON ...@@ -23,7 +23,7 @@ from bson.son import SON
from datetime import datetime from datetime import datetime
from fs.osfs import OSFS from fs.osfs import OSFS
from mongodb_proxy import MongoProxy, autoretry_read from mongodb_proxy import MongoProxy, autoretry_read
from path import path from path import Path as path
from pytz import UTC from pytz import UTC
from contracts import contract, new_contract from contracts import contract, new_contract
......
""" """
Performance test for asset metadata in the modulestore. Performance test for asset metadata in the modulestore.
""" """
from path import path from path import Path as path
import unittest import unittest
from tempfile import mkdtemp from tempfile import mkdtemp
import itertools import itertools
......
...@@ -60,7 +60,7 @@ import logging ...@@ -60,7 +60,7 @@ import logging
from contracts import contract, new_contract from contracts import contract, new_contract
from importlib import import_module from importlib import import_module
from mongodb_proxy import autoretry_read from mongodb_proxy import autoretry_read
from path import path from path import Path as path
from pytz import UTC from pytz import UTC
from bson.objectid import ObjectId from bson.objectid import ObjectId
......
...@@ -130,18 +130,18 @@ class TestContentstore(unittest.TestCase): ...@@ -130,18 +130,18 @@ class TestContentstore(unittest.TestCase):
Test export Test export
""" """
self.set_up_assets(deprecated) self.set_up_assets(deprecated)
root_dir = path.path(mkdtemp()) root_dir = path.Path(mkdtemp())
try: try:
self.contentstore.export_all_for_course( self.contentstore.export_all_for_course(
self.course1_key, root_dir, self.course1_key, root_dir,
path.path(root_dir / "policy.json"), path.Path(root_dir / "policy.json"),
) )
for filename in self.course1_files: for filename in self.course1_files:
filepath = path.path(root_dir / filename) filepath = path.Path(root_dir / filename)
self.assertTrue(filepath.isfile(), "{} is not a file".format(filepath)) self.assertTrue(filepath.isfile(), "{} is not a file".format(filepath))
for filename in self.course2_files: for filename in self.course2_files:
if filename not in self.course1_files: if filename not in self.course1_files:
filepath = path.path(root_dir / filename) filepath = path.Path(root_dir / filename)
self.assertFalse(filepath.isfile(), "{} is unexpected exported a file".format(filepath)) self.assertFalse(filepath.isfile(), "{} is unexpected exported a file".format(filepath))
finally: finally:
shutil.rmtree(root_dir) shutil.rmtree(root_dir)
......
...@@ -14,7 +14,7 @@ and then for each combination of modulestores, performing the sequence: ...@@ -14,7 +14,7 @@ and then for each combination of modulestores, performing the sequence:
from contextlib import contextmanager, nested from contextlib import contextmanager, nested
import itertools import itertools
import os import os
from path import path from path import Path as path
import random import random
from shutil import rmtree from shutil import rmtree
from tempfile import mkdtemp from tempfile import mkdtemp
......
...@@ -7,7 +7,7 @@ Unit tests for the Mongo modulestore ...@@ -7,7 +7,7 @@ Unit tests for the Mongo modulestore
from nose.tools import assert_equals, assert_raises, \ from nose.tools import assert_equals, assert_raises, \
assert_not_equals, assert_false, assert_true, assert_greater, assert_is_instance, assert_is_none assert_not_equals, assert_false, assert_true, assert_greater, assert_is_instance, assert_is_none
# pylint: enable=E0611 # pylint: enable=E0611
from path import path from path import Path as path
import pymongo import pymongo
import logging import logging
import shutil import shutil
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
from mock import patch from mock import patch
import datetime import datetime
from importlib import import_module from importlib import import_module
from path import path from path import Path as path
import random import random
import re import re
import unittest import unittest
......
...@@ -12,7 +12,7 @@ from cStringIO import StringIO ...@@ -12,7 +12,7 @@ from cStringIO import StringIO
from fs.osfs import OSFS from fs.osfs import OSFS
from importlib import import_module from importlib import import_module
from lxml import etree from lxml import etree
from path import path from path import Path as path
from contextlib import contextmanager from contextlib import contextmanager
from lazy import lazy from lazy import lazy
......
...@@ -17,7 +17,7 @@ from fs.osfs import OSFS ...@@ -17,7 +17,7 @@ from fs.osfs import OSFS
from json import dumps from json import dumps
import json import json
import os import os
from path import path from path import Path as path
import shutil import shutil
from xmodule.modulestore.draft_and_published import DIRECT_ONLY_CATEGORIES from xmodule.modulestore.draft_and_published import DIRECT_ONLY_CATEGORIES
from opaque_keys.edx.locator import CourseLocator, LibraryLocator from opaque_keys.edx.locator import CourseLocator, LibraryLocator
......
...@@ -25,7 +25,7 @@ from abc import abstractmethod ...@@ -25,7 +25,7 @@ from abc import abstractmethod
from opaque_keys.edx.locator import LibraryLocator from opaque_keys.edx.locator import LibraryLocator
import os import os
import mimetypes import mimetypes
from path import path from path import Path as path
import json import json
import re import re
from lxml import etree from lxml import etree
......
...@@ -11,7 +11,7 @@ import errno ...@@ -11,7 +11,7 @@ import errno
import sys import sys
from collections import defaultdict from collections import defaultdict
from docopt import docopt from docopt import docopt
from path import path from path import Path as path
from xmodule.x_module import XModuleDescriptor from xmodule.x_module import XModuleDescriptor
......
...@@ -20,7 +20,7 @@ from functools import wraps ...@@ -20,7 +20,7 @@ from functools import wraps
from lazy import lazy from lazy import lazy
from mock import Mock, patch from mock import Mock, patch
from operator import attrgetter from operator import attrgetter
from path import path from path import Path as path
from opaque_keys.edx.locations import SlashSeparatedCourseKey from opaque_keys.edx.locations import SlashSeparatedCourseKey
from xblock.field_data import DictFieldData from xblock.field_data import DictFieldData
......
...@@ -3,7 +3,7 @@ Utility methods for unit tests. ...@@ -3,7 +3,7 @@ Utility methods for unit tests.
""" """
import filecmp import filecmp
from path import path from path import Path as path
def directories_equal(directory1, directory2): def directories_equal(directory1, directory2):
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
import os import os
import unittest import unittest
import ddt import ddt
from path import path from path import Path as path
from xmodule.contentstore.content import StaticContent, StaticContentStream from xmodule.contentstore.content import StaticContent, StaticContentStream
from xmodule.contentstore.content import ContentStore from xmodule.contentstore.content import ContentStore
from opaque_keys.edx.locations import SlashSeparatedCourseKey, AssetLocation from opaque_keys.edx.locations import SlashSeparatedCourseKey, AssetLocation
......
...@@ -14,7 +14,7 @@ import uuid ...@@ -14,7 +14,7 @@ import uuid
from datetime import datetime, timedelta, tzinfo from datetime import datetime, timedelta, tzinfo
from fs.osfs import OSFS from fs.osfs import OSFS
from path import path from path import Path as path
from tempfile import mkdtemp from tempfile import mkdtemp
from textwrap import dedent from textwrap import dedent
......
...@@ -9,7 +9,7 @@ import datetime ...@@ -9,7 +9,7 @@ import datetime
from textwrap import dedent from textwrap import dedent
from collections import namedtuple from collections import namedtuple
from path import path from path import Path as path
from opaque_keys.edx.keys import CourseKey from opaque_keys.edx.keys import CourseKey
......
...@@ -3,7 +3,7 @@ Course Textbooks page. ...@@ -3,7 +3,7 @@ Course Textbooks page.
""" """
import requests import requests
from path import path # pylint: disable=no-name-in-module from path import Path as path
from .course_page import CoursePage from .course_page import CoursePage
from .utils import click_css from .utils import click_css
......
...@@ -12,7 +12,7 @@ import os ...@@ -12,7 +12,7 @@ import os
import urlparse import urlparse
from contextlib import contextmanager from contextlib import contextmanager
from datetime import datetime from datetime import datetime
from path import path from path import Path as path
from bok_choy.javascript import js_defined from bok_choy.javascript import js_defined
from bok_choy.web_app_test import WebAppTest from bok_choy.web_app_test import WebAppTest
from bok_choy.promise import EmptyPromise, Promise from bok_choy.promise import EmptyPromise, Promise
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
# pylint: disable=unused-argument # pylint: disable=unused-argument
import os import os
from path import path from path import Path as path
import sys import sys
import mock import mock
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
# pylint: disable=unused-argument # pylint: disable=unused-argument
import os import os
from path import path from path import Path as path
import sys import sys
import mock import mock
......
...@@ -5,8 +5,7 @@ from django.core.files.images import ImageFile ...@@ -5,8 +5,7 @@ from django.core.files.images import ImageFile
from django.test import TestCase from django.test import TestCase
from django.test.utils import override_settings from django.test.utils import override_settings
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
# pylint: disable=no-name-in-module from path import Path as path
from path import path
from opaque_keys.edx.locator import CourseLocator from opaque_keys.edx.locator import CourseLocator
from certificates.models import ( from certificates.models import (
......
...@@ -3,7 +3,7 @@ from fs.errors import ResourceNotFoundError ...@@ -3,7 +3,7 @@ from fs.errors import ResourceNotFoundError
import logging import logging
import inspect import inspect
from path import path from path import Path as path
from django.http import Http404 from django.http import Http404
from django.conf import settings from django.conf import settings
......
...@@ -4,7 +4,7 @@ import sys ...@@ -4,7 +4,7 @@ import sys
import traceback import traceback
from fs.osfs import OSFS from fs.osfs import OSFS
from path import path from path import Path as path
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
......
...@@ -12,7 +12,7 @@ import tarfile ...@@ -12,7 +12,7 @@ import tarfile
from tempfile import mktemp, mkdtemp from tempfile import mktemp, mkdtemp
from textwrap import dedent from textwrap import dedent
from path import path from path import Path as path
from django.core.management.base import BaseCommand, CommandError from django.core.management.base import BaseCommand, CommandError
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
import json import json
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
from path import path from path import Path as path
import shutil import shutil
from StringIO import StringIO from StringIO import StringIO
import tarfile import tarfile
......
...@@ -28,7 +28,7 @@ from django.views.decorators.http import condition ...@@ -28,7 +28,7 @@ from django.views.decorators.http import condition
from django.views.decorators.csrf import ensure_csrf_cookie from django.views.decorators.csrf import ensure_csrf_cookie
from edxmako.shortcuts import render_to_response from edxmako.shortcuts import render_to_response
import mongoengine import mongoengine
from path import path from path import Path as path
from courseware.courses import get_course_by_id from courseware.courses import get_course_by_id
import dashboard.git_import as git_import import dashboard.git_import as git_import
......
...@@ -10,7 +10,7 @@ of each of its fields (including those fields that are set as default values). ...@@ -10,7 +10,7 @@ of each of its fields (including those fields that are set as default values).
from __future__ import print_function from __future__ import print_function
import json import json
from path import path from path import Path as path
from django.core.management.base import BaseCommand, CommandError from django.core.management.base import BaseCommand, CommandError
from django.conf import settings from django.conf import settings
......
...@@ -9,7 +9,7 @@ import os ...@@ -9,7 +9,7 @@ import os
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
from django.conf import settings from django.conf import settings
from django.contrib.auth.models import Group from django.contrib.auth.models import Group
from path import path from path import Path as path
from lxml import etree from lxml import etree
......
...@@ -23,7 +23,7 @@ from .common import * ...@@ -23,7 +23,7 @@ from .common import *
from openedx.core.lib.logsettings import get_logger_config from openedx.core.lib.logsettings import get_logger_config
import os import os
from path import path from path import Path as path
from xmodule.modulestore.modulestore_settings import convert_module_store_setting_if_needed from xmodule.modulestore.modulestore_settings import convert_module_store_setting_if_needed
# SERVICE_VARIANT specifies name of the variant used, which decides what JSON # SERVICE_VARIANT specifies name of the variant used, which decides what JSON
......
...@@ -11,7 +11,7 @@ from the same directory. ...@@ -11,7 +11,7 @@ from the same directory.
""" """
import os import os
from path import path from path import Path as path
from tempfile import mkdtemp from tempfile import mkdtemp
# Pylint gets confused by path.py instances, which report themselves as class # Pylint gets confused by path.py instances, which report themselves as class
......
...@@ -33,7 +33,7 @@ import sys ...@@ -33,7 +33,7 @@ import sys
import os import os
import imp import imp
from path import path from path import Path as path
from warnings import simplefilter from warnings import simplefilter
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
......
...@@ -20,7 +20,7 @@ sessions. Assumes structure: ...@@ -20,7 +20,7 @@ sessions. Assumes structure:
from .common import * from .common import *
import os import os
from path import path from path import Path as path
from uuid import uuid4 from uuid import uuid4
from warnings import filterwarnings, simplefilter from warnings import filterwarnings, simplefilter
......
...@@ -20,7 +20,7 @@ from openedx.core.lib.logsettings import get_logger_config ...@@ -20,7 +20,7 @@ from openedx.core.lib.logsettings import get_logger_config
from util.config_parse import convert_tokens from util.config_parse import convert_tokens
import os import os
from path import path from path import Path as path
# https://stackoverflow.com/questions/2890146/how-to-force-pyyaml-to-load-strings-as-unicode-objects # https://stackoverflow.com/questions/2890146/how-to-force-pyyaml-to-load-strings-as-unicode-objects
from yaml import Loader, SafeLoader from yaml import Loader, SafeLoader
......
...@@ -3,7 +3,7 @@ Internationalization tasks ...@@ -3,7 +3,7 @@ Internationalization tasks
""" """
import sys import sys
import subprocess import subprocess
from path import path from path import Path as path
from paver.easy import task, cmdopts, needs, sh from paver.easy import task, cmdopts, needs, sh
try: try:
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
Tests for paver quality tasks Tests for paver quality tasks
""" """
import os import os
from path import path # pylint: disable=no-name-in-module from path import Path as path
import tempfile import tempfile
import unittest import unittest
from mock import patch, MagicMock, mock_open from mock import patch, MagicMock, mock_open
......
...@@ -6,7 +6,7 @@ import os ...@@ -6,7 +6,7 @@ import os
import sys import sys
import json import json
from lazy import lazy from lazy import lazy
from path import path from path import Path as path
import memcache import memcache
......
...@@ -14,7 +14,7 @@ import json ...@@ -14,7 +14,7 @@ import json
import getpass import getpass
try: try:
from path import path from path import Path as path
from git import Repo, Commit from git import Repo, Commit
from git.refs.symbolic import SymbolicReference from git.refs.symbolic import SymbolicReference
from dateutil.parser import parse as parse_datestring from dateutil.parser import parse as parse_datestring
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment