Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions apptools/io/h5/table_node.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import numpy as np

import six
from tables.table import Table as PyTablesTable


Expand Down Expand Up @@ -96,7 +95,7 @@ def __getitem__(self, col_or_cols):
An array of column data with the column order matching that of
`col_or_cols`.
"""
if isinstance(col_or_cols, six.string_types):
if isinstance(col_or_cols, str):
return self._h5_table.col(col_or_cols)

column_data = [self._h5_table.col(name) for name in col_or_cols]
Expand Down
5 changes: 2 additions & 3 deletions apptools/io/h5/tests/test_dict_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import numpy as np
from numpy.testing import assert_allclose
import six

from ..dict_node import H5DictNode
from .utils import open_h5file, temp_h5_file, temp_file
Expand Down Expand Up @@ -161,14 +160,14 @@ def test_basic_dtypes(self):
h5dict = H5DictNode.add_to_h5file(h5, NODE, data)
assert isinstance(h5dict["a_int"], int)
assert isinstance(h5dict["a_float"], float)
assert isinstance(h5dict["a_str"], six.string_types)
assert isinstance(h5dict["a_str"], str)

def test_mixed_type_list(self):
with temp_h5_file() as h5:
data = dict(a=[1, 1.0, "abc"])
h5dict = H5DictNode.add_to_h5file(h5, NODE, data)
for value, dtype in zip(
h5dict["a"], (int, float, six.string_types)
h5dict["a"], (int, float, str)
):
assert isinstance(value, dtype)

Expand Down
2 changes: 1 addition & 1 deletion apptools/logger/log_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import inspect

# Third-party library imports.
from six import StringIO
from io import StringIO


def log_point(msg="\n"):
Expand Down
4 changes: 1 addition & 3 deletions apptools/naming/pyfs_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
import logging
import os
from os.path import join, splitext

# Third-party library imports.
import six.moves.cPickle as pickle
import pickle

# Enthought library imports.
from apptools.io.api import File
Expand Down
8 changes: 3 additions & 5 deletions apptools/naming/trait_defs/naming_traits.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

import sys

import six

from traits.api import Trait, TraitHandler, TraitFactory

from traits.trait_base import class_of, get_module_name
Expand Down Expand Up @@ -62,12 +60,12 @@ def __init__(self, aClass, or_none, module):
self.module = module
self.aClass = aClass
if (aClass is not None) and (
not isinstance(aClass, (six.string_types, type))
not isinstance(aClass, (str, type))
):
self.aClass = aClass.__class__

def validate(self, object, name, value):
if isinstance(value, six.string_types):
if isinstance(value, str):
if value == "":
if self.or_none:
return ""
Expand All @@ -78,7 +76,7 @@ def validate(self, object, name, value):
except:
self.validate_failed(object, name, value)

if isinstance(self.aClass, six.string_types):
if isinstance(self.aClass, str):
self.resolve_class(object, name, value)

if isinstance(value, Binding) and (
Expand Down
5 changes: 1 addition & 4 deletions apptools/preferences/preference_binding.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
from traits.api import Any, HasTraits, Instance, Str, Undefined
from traits.api import Str

# Third-party librart imports.
import six

# Local imports.
from .i_preferences import IPreferences
from .package_globals import get_default_preferences
Expand Down Expand Up @@ -104,7 +101,7 @@ def _get_value(self, trait_name, value):

# If the trait type is 'Str' then we convert the raw value.
elif type(handler) is Str:
value = six.text_type(value)
value = str(value)

# Otherwise, we eval it!
else:
Expand Down
5 changes: 1 addition & 4 deletions apptools/preferences/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
# Standard library imports.
import logging, threading

# Third-party library imports.
import six

# Enthought library imports.
from traits.api import Any, Callable, Dict, HasTraits, Instance, List
from traits.api import Property, Str, Undefined, provides
Expand Down Expand Up @@ -548,7 +545,7 @@ def _set(self, key, value):
# everything must be unicode encoded so that ConfigObj configuration
# can properly serialize the data. Python str are supposed to be ASCII
# encoded.
value = six.text_type(value)
value = str(value)

self._lk.acquire()
old = self._preferences.get(key)
Expand Down
4 changes: 1 addition & 3 deletions apptools/preferences/tests/py_config_file.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
""" A Python based configuration file with hierarchical sections. """
from __future__ import print_function

import six


class PyConfigFile(dict):
""" A Python based configuration file with hierarchical sections. """
Expand Down Expand Up @@ -118,7 +116,7 @@ def _get_file(self, file_or_filename, mode="r"):

"""

if isinstance(file_or_filename, six.string_types):
if isinstance(file_or_filename, str):
f = open(file_or_filename, mode)

else:
Expand Down
16 changes: 5 additions & 11 deletions apptools/scripting/recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@
# Copyright (c) 2008-2015, Enthought, Inc.
# License: BSD Style.

import builtins
import warnings

import six
import six.moves.builtins

from traits.api import (
HasTraits,
List,
Expand Down Expand Up @@ -404,10 +402,7 @@ def save(self, file):
"""Save the recorded lines to the given file. It does not close
the file.
"""
if six.PY3:
file.write(self.get_code())
else:
file.write(six.text_type(self.get_code(), encoding="utf-8"))
file.write(self.get_code())
file.flush()

def record_function(self, func, args, kw):
Expand Down Expand Up @@ -535,7 +530,7 @@ def _get_unique_name(self, obj):
nm = self._name_map
result = ""
builtin = False
if cname in six.moves.builtins.__dict__:
if cname in builtins.__dict__:
builtin = True
if hasattr(obj, "__name__"):
cname = obj.__name__
Expand Down Expand Up @@ -721,8 +716,7 @@ def _object_as_string(self, object):
def _return_as_string(self, object):
"""Return a string given a returned object from a function."""
result = ""
long_type = long if six.PY2 else int
ignore = (float, complex, bool, int, long_type, str)
ignore = (float, complex, bool, int, str)
if object is not None and type(object) not in ignore:
# If object is not know, register it.
registry = self._registry
Expand All @@ -739,7 +733,7 @@ def _import_class_string(self, cls):
"""Import a class if needed."""
cname = cls.__name__
result = ""
if cname not in six.moves.builtins.__dict__:
if cname not in builtins.__dict__:
mod = cls.__module__
typename = "%s.%s" % (mod, cname)
if typename not in self._known_types:
Expand Down
6 changes: 3 additions & 3 deletions apptools/sweet_pickle/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,20 +124,20 @@ def loads(str, max_pass=-1):

# We don't customize the Python pickler, though we do use the cPickle module
# for improved performance.
from six.moves.cPickle import Pickler
from pickle import Pickler

# Implement the dump and dumps methods so that all traits in a HasTraits object
# get included in the pickle.
def dump(obj, file, protocol=2):
_flush_traits(obj)
from six.moves.cPickle import dump as d
from pickle import dump as d

return d(obj, file, protocol)


def dumps(obj, protocol=2):
_flush_traits(obj)
from six.moves.cPickle import dumps as ds
from pickle import dumps as ds

return ds(obj, protocol)

Expand Down
4 changes: 2 additions & 2 deletions apptools/sweet_pickle/global_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ class instances into the project.
"""

try:
import six.moves._thread as _thread
import _thread
except ImportError:
import six.moves._dummy_thread as _thread
import _dummy_thread


##############################################################################
Expand Down
5 changes: 1 addition & 4 deletions apptools/type_manager/adapter_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
# Standard library imports
import warnings

# Third-party imports
import six

# Enthought library imports.
from traits.api import Dict, HasTraits, Instance, Property

Expand Down Expand Up @@ -146,7 +143,7 @@ def register_type_adapters(self, factory, adaptee_class):

"""

if isinstance(adaptee_class, six.string_types):
if isinstance(adaptee_class, str):
adaptee_class_name = adaptee_class

else:
Expand Down
4 changes: 1 addition & 3 deletions apptools/type_registry/tests/dummies.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import abc

import six


class A(object):
pass
Expand All @@ -23,7 +21,7 @@ class Mixed(A, D):
pass


class Abstract(six.with_metaclass(abc.ABCMeta, object)):
class Abstract(metaclass=abc.ABCMeta):
pass


Expand Down
7 changes: 2 additions & 5 deletions apptools/type_registry/type_registry.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import six


def get_mro(obj_class):
"""Get a reasonable method resolution order of a class and its
superclasses for both old-style and new-style classes.
Expand Down Expand Up @@ -56,7 +53,7 @@ def push(self, typ, obj):
obj : object
The object to register.
"""
if isinstance(typ, six.string_types):
if isinstance(typ, str):
Comment thread
aaronayres35 marked this conversation as resolved.
# Check the cached types.
for cls in self.type_map:
if _mod_name_key(cls) == typ:
Expand Down Expand Up @@ -99,7 +96,7 @@ def pop(self, typ):
------
KeyError if the type is not registered.
"""
if isinstance(typ, six.string_types):
if isinstance(typ, str):
if typ not in self.name_map:
# We may have it cached in the type map. We will have to
# iterate over all of the types to check.
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,6 @@ def get_long_description():
},
install_requires=[
'configobj',
'six',
'traitsui',
],
extras_require={
Expand Down