Skip to content

Commit

Permalink
Removing internal use of 'import *'
Browse files Browse the repository at this point in the history
Even if users want to do this, we should not be
using this idiom within PyUtilib.
  • Loading branch information
whart222 committed Apr 25, 2016
1 parent 18561fa commit 3a39363
Show file tree
Hide file tree
Showing 44 changed files with 144 additions and 124 deletions.
10 changes: 5 additions & 5 deletions doc/workflow/examples/example10.py
@@ -1,9 +1,9 @@
from pyutilib.workflow import *
from pyutilib.workflow import Resource, Task, Workflow

class BusyResource(Resource):

def __init__(self, name=None):
resource.Resource.__init__(self)
Resource.__init__(self)
self._counter = 1

def available(self):
Expand All @@ -13,10 +13,10 @@ def available(self):
return False
return True

class TaskA(pyutilib.workflow.Task):
class TaskA(Task):

def __init__(self, *args, **kwds):
pyutilib.workflow.Task.__init__(self, *args, **kwds)
Task.__init__(self, *args, **kwds)
self.inputs.declare('x')
self.outputs.declare('x', self.inputs.x)

Expand All @@ -25,7 +25,7 @@ def execute(self):

A = TaskA()
A.add_resource(BusyResource())
w = pyutilib.workflow.Workflow()
w = Workflow()
w.add(A)

print(w(x=1))
6 changes: 3 additions & 3 deletions examples/autotest/example.py
Expand Up @@ -9,7 +9,7 @@
#

import pyutilib.autotest
from pyutilib.component.core import *
from pyutilib.component.core import alias
import pyutilib.subprocess


Expand All @@ -28,8 +28,8 @@ def run_test(self, testcase, name, options):
if not options.cat_options is None:
cmd += options.cat_options+' '
cmd += options.file
print "Running test suite '%s' test '%s' command '%s'" % \
(options.suite, name, cmd)
print( "Running test suite '%s' test '%s' command '%s'" % \
(options.suite, name, cmd))
pyutilib.subprocess.run(cmd, outfile=options.currdir+'test_'+name+".out")
testcase.failUnlessFileEqualsBaseline(
options.currdir+'test_'+name+".out",
Expand Down
4 changes: 2 additions & 2 deletions pyutilib/autotest/__init__.py
Expand Up @@ -13,10 +13,10 @@
import pyutilib.component.core
pyutilib.component.core.PluginGlobals.add_env('pyutilib.autotest')

from pyutilib.autotest.plugins import *
from pyutilib.autotest.plugins import ITestDriver, TestDriverFactory, ITestParser, TestDriverBase
from pyutilib.autotest.driver import run, main, create_test_suites
import pyutilib.autotest.yaml_plugin
import pyutilib.autotest.json_plugin
from pyutilib.autotest.driver import *
import pyutilib.autotest.default_testdriver

pyutilib.component.core.PluginGlobals.pop_env()
2 changes: 1 addition & 1 deletion pyutilib/autotest/default_testdriver.py
Expand Up @@ -9,7 +9,7 @@
#

import sys
from pyutilib.component.core import *
from pyutilib.component.core import Plugin, implements, alias
from pyutilib.autotest import plugins


Expand Down
2 changes: 1 addition & 1 deletion pyutilib/autotest/json_plugin.py
Expand Up @@ -13,7 +13,7 @@
json_available=True
except: #pragma:nocover
json_available=False
from pyutilib.component.core import *
from pyutilib.component.core import SingletonPlugin, implements
from pyutilib.autotest import plugins


Expand Down
3 changes: 2 additions & 1 deletion pyutilib/autotest/plugins.py
Expand Up @@ -10,7 +10,8 @@

__all__ = ['ITestDriver', 'TestDriverFactory', 'ITestParser', 'TestDriverBase']

from pyutilib.component.core import *
from pyutilib.component.core import Interface, implements, Plugin, CreatePluginFactory


class ITestParser(Interface):

Expand Down
5 changes: 2 additions & 3 deletions pyutilib/autotest/yaml_plugin.py
Expand Up @@ -13,10 +13,9 @@
using_yaml=True
except ImportError: #pragma:nocover
using_yaml=False

import pyutilib.misc
from pyutilib.component.core import *
from pyutilib.component.core import SingletonPlugin, implements
from pyutilib.autotest import plugins
import pyutilib.misc


class YamlTestParser(SingletonPlugin):
Expand Down
4 changes: 1 addition & 3 deletions pyutilib/common/__init__.py
Expand Up @@ -8,6 +8,4 @@
# _________________________________________________________________________
#

# The only compatible way to import packages in both 2.4 and 3.x is to
# use absolute package names:
from pyutilib.common._exceptions import *
from pyutilib.common._exceptions import ConfigurationError, ApplicationError, BadDebuggingValue
2 changes: 1 addition & 1 deletion pyutilib/component/app/__init__.py
Expand Up @@ -12,4 +12,4 @@
simplify the use of the PyUtilib Component Architecture.
"""

from pyutilib.component.app.simple import *
from pyutilib.component.app.simple import SimpleApplication
1 change: 1 addition & 0 deletions pyutilib/component/app/simple.py
Expand Up @@ -17,6 +17,7 @@
import pyutilib.component.config
import os


class SimpleApplication(object):

def __init__(self, name, filename=None):
Expand Down
12 changes: 6 additions & 6 deletions pyutilib/component/config/__init__.py
Expand Up @@ -16,12 +16,12 @@
from pyutilib.component.core import PluginGlobals
PluginGlobals.add_env("pca")

from pyutilib.component.config.options import *
from pyutilib.component.config.managed_plugin import *
from pyutilib.component.config.configuration import *
from pyutilib.component.config.logging_config import *
from pyutilib.component.config.env_config import *
from pyutilib.component.config.tempfiles import *
from pyutilib.component.config.env_config import EnvironmentConfig
from pyutilib.component.config.options import ExecutableOption, declare_option, Option
from pyutilib.component.config.managed_plugin import ManagedPlugin, ManagedSingletonPlugin
from pyutilib.component.config.configuration import Configuration, ConfigurationError
from pyutilib.component.config.logging_config import LoggingConfig
from pyutilib.component.config.tempfiles import ITempfileManager, TempfileManagerPlugin, TempfileManager
import pyutilib.component.config.plugin_ConfigParser

PluginGlobals.pop_env()
4 changes: 2 additions & 2 deletions pyutilib/component/config/configuration.py
Expand Up @@ -16,9 +16,9 @@
A key role of this class is to support initialization of Option objects.
"""

from pyutilib.component.core import *
from pyutilib.component.config.options import *
import os.path
from pyutilib.component.core import PluginError, Interface, Plugin, ExtensionPoint, implements, IOptionDataProvider
from pyutilib.component.config.options import IOption, IFileOption, IUpdatedOptionsAction


class ConfigurationError(PluginError):
Expand Down
3 changes: 2 additions & 1 deletion pyutilib/component/config/env_config.py
Expand Up @@ -14,7 +14,8 @@
import re
import logging

from pyutilib.component.config.options import *
from pyutilib.component.core import Interface, IPluginLoadPath, Plugin, implements
from pyutilib.component.config.options import DictOption, declare_option

logger = logging.getLogger('pyutilib.component.core.pca')

Expand Down
6 changes: 4 additions & 2 deletions pyutilib/component/config/logging_config.py
Expand Up @@ -9,12 +9,14 @@

"""A plugin that supports global configuration of logging options for pyutilib.component.core."""

import sys
import os.path
import logging
import logging.handlers as handlers

from pyutilib.component.config.env_config import *
from pyutilib.component.config.options import *
from pyutilib.component.core import Plugin, implements, ExtensionPoint, PluginGlobals
from pyutilib.component.config.env_config import IEnvironmentConfig
from pyutilib.component.config.options import IUpdatedOptionsAction, declare_option


class LoggingConfig(Plugin):
Expand Down
4 changes: 3 additions & 1 deletion pyutilib/component/config/managed_plugin.py
Expand Up @@ -11,7 +11,8 @@

__all__ = ['ManagedPlugin', 'ManagedSingletonPlugin']

from pyutilib.component.config.options import *
from pyutilib.component.core import Plugin, SingletonPlugin
from pyutilib.component.config.options import declare_option, BoolOption


class ManagedPlugin(Plugin):
Expand All @@ -30,6 +31,7 @@ def __del__(self):
# clean up the attached BoolOption, which is a plugin - otherwise, a memory leak will result.
self._enable.deactivate()


class ManagedSingletonPlugin(SingletonPlugin):
"""A singleton plugin that has an option supports configuration of this service."""

Expand Down
2 changes: 1 addition & 1 deletion pyutilib/component/config/options.py
Expand Up @@ -28,7 +28,7 @@ def __init__(self):
import re
import os
import os.path
from pyutilib.component.core import *
from pyutilib.component.core import PluginError, Interface, implements, Plugin, PluginGlobals, ExtensionPoint, IOptionDataProvider
try:
unicode
except:
Expand Down
7 changes: 5 additions & 2 deletions pyutilib/component/config/plugin_ConfigParser.py
Expand Up @@ -11,6 +11,7 @@

__all__ = ['Configuration_ConfigParser']

import sys
import os.path
try:
import ConfigParser
Expand All @@ -20,8 +21,10 @@
from ordereddict import OrderedDict
except:
OrderedDict = dict
from pyutilib.component.config.configuration import *
from pyutilib.component.config.managed_plugin import *
from pyutilib.component.core import implements
from pyutilib.component.config.configuration import ConfigurationError, IConfiguration
from pyutilib.component.config.managed_plugin import ManagedSingletonPlugin
from pyutilib.component.config.options import declare_option

#
# Force the config file option manager to be case sensitive
Expand Down
6 changes: 4 additions & 2 deletions pyutilib/component/config/tempfiles.py
Expand Up @@ -17,8 +17,9 @@
import logging
import shutil

from pyutilib.component.config.options import *
from pyutilib.component.config.managed_plugin import *
from pyutilib.component.core import Interface, implements
from pyutilib.component.config.managed_plugin import ManagedSingletonPlugin
from pyutilib.component.config.options import declare_option


deletion_errors_are_fatal = True
Expand Down Expand Up @@ -51,6 +52,7 @@ def push(self):
def pop(self, remove=True):
"""Pop tempfiles onto a stack. Tempfiles that are popped off the stack are deleted."""


class TempfileManagerPlugin(ManagedSingletonPlugin):
"""A plugin that manages temporary files."""

Expand Down
5 changes: 3 additions & 2 deletions pyutilib/component/config/tests/test_config.py
Expand Up @@ -9,8 +9,9 @@
currdir = dirname(abspath(__file__))+os.sep

from nose.tools import nottest
from pyutilib.component.core import ExtensionPoint
from pyutilib.component.config import *
from pyutilib.component.core import ExtensionPoint, Plugin, PluginGlobals
from pyutilib.component.config.options import FileOption, declare_option
from pyutilib.component.config import Configuration, ConfigurationError
import pyutilib.th as unittest
import pyutilib.misc

Expand Down
5 changes: 3 additions & 2 deletions pyutilib/component/config/tests/test_options.py
@@ -1,12 +1,13 @@

import os
import re
import sys
from os.path import abspath, dirname
currdir = dirname(abspath(__file__))+os.sep

import unittest
from pyutilib.component.core import *
from pyutilib.component.config import *
from pyutilib.component.core import Interface, PluginGlobals, ExtensionPoint, implements, Plugin
from pyutilib.component.config.options import Option, OptionError, IOption, declare_option, FileOption, IntOption, FloatOption, DictOption, BoolOption


PluginGlobals.add_env("testing.options")
Expand Down
6 changes: 5 additions & 1 deletion pyutilib/component/core/__init__.py
Expand Up @@ -20,7 +20,11 @@
this package can be independently used in other projects.
"""

from pyutilib.component.core.core import *
from pyutilib.component.core.core import Plugin, implements, Interface, CreatePluginFactory, \
PluginMeta, alias, ExtensionPoint, SingletonPlugin, \
PluginFactory, PluginError, PluginGlobals, with_metaclass, \
IPluginLoader, IPluginLoadPath, IIgnorePluginWhenLoading, \
IOptionDataProvider, PluginEnvironment

PluginGlobals.add_env("pca")

Expand Down
2 changes: 1 addition & 1 deletion pyutilib/component/executables/__init__.py
Expand Up @@ -10,6 +10,6 @@
from pyutilib.component.core import PluginGlobals
PluginGlobals.add_env("pca")

from pyutilib.component.executables.executable import *
from pyutilib.component.executables.executable import IExternalExecutable, ExternalExecutable

PluginGlobals.pop_env()
3 changes: 2 additions & 1 deletion pyutilib/component/executables/executable.py
Expand Up @@ -8,9 +8,10 @@
# _________________________________________________________________________

import pyutilib.misc
from pyutilib.component.core import *
from pyutilib.component.core import Interface, Plugin, implements
from pyutilib.component.config import ExecutableOption, declare_option


class IExternalExecutable(Interface):
"""Interface for plugins that define an external executable"""

Expand Down
4 changes: 2 additions & 2 deletions pyutilib/component/loader/__init__.py
Expand Up @@ -10,7 +10,7 @@
from pyutilib.component.core import PluginGlobals
PluginGlobals.add_env("pca")

from pyutilib.component.loader.plugin_importLoader import *
from pyutilib.component.loader.plugin_eggLoader import *
from pyutilib.component.loader.plugin_importLoader import ImportLoader
from pyutilib.component.loader.plugin_eggLoader import EggLoader

PluginGlobals.pop_env()
4 changes: 2 additions & 2 deletions pyutilib/component/loader/plugin_eggLoader.py
Expand Up @@ -15,8 +15,8 @@
import os
import sys
import logging
from pyutilib.component.core import *
from pyutilib.component.config import *
from pyutilib.component.config import ManagedPlugin
from pyutilib.component.core import implements, ExtensionPoint, IPluginLoader

try:
if not 'pkg_resources' in sys.modules:
Expand Down
5 changes: 3 additions & 2 deletions pyutilib/component/loader/plugin_importLoader.py
Expand Up @@ -19,8 +19,9 @@
import sys
import logging

from pyutilib.component.config import *
from pyutilib.component.core import *
from pyutilib.component.config import ManagedSingletonPlugin
from pyutilib.component.core import implements, ExtensionPoint, IIgnorePluginWhenLoading, IPluginLoader, Plugin


class ImportLoader(ManagedSingletonPlugin):
"""Loader that looks for Python source files in the plugins directories,
Expand Down
4 changes: 2 additions & 2 deletions pyutilib/component/loader/tests/plugins2/test3.py
@@ -1,8 +1,8 @@
#
# This generates a load error
#
from pyutilib.component.core import *
from pyutilib.component.config import *
from pyutilib.component.core import Plugin
from pyutilib.component.config import Option

class test3_foo(Plugin):

Expand Down
2 changes: 0 additions & 2 deletions pyutilib/component/loader/tests/plugins2/test4.py
@@ -1,8 +1,6 @@
#
# This generates a load error
#
#from pyutilib.component.core import *
#from pyutilib.component.config import *

class test4_foo(Plugin):

Expand Down
2 changes: 1 addition & 1 deletion pyutilib/enum/__init__.py
Expand Up @@ -8,4 +8,4 @@
# _________________________________________________________________________
#

from pyutilib.enum.enum import *
from pyutilib.enum.enum import Enum
4 changes: 2 additions & 2 deletions pyutilib/math/__init__.py
Expand Up @@ -8,5 +8,5 @@
# _________________________________________________________________________
#

from pyutilib.math.numtypes import *
from pyutilib.math.util import *
from pyutilib.math.numtypes import infinity, nan, is_nan, is_finite
from pyutilib.math.util import approx_equal, as_number, isint, argmax, argmin, mean, median, factorial, perm

0 comments on commit 3a39363

Please sign in to comment.