Skip to content
Draft
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
52 changes: 0 additions & 52 deletions .github/workflows/ironpython.yml

This file was deleted.

30 changes: 1 addition & 29 deletions src/compas/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from __future__ import print_function
# ruff: noqa: F401

import os

Expand Down Expand Up @@ -103,34 +103,6 @@
pass


__all__ = [
"WINDOWS",
"LINUX",
"OSX",
"MONO",
"IPY",
"RHINO",
"BLENDER",
"PY2",
"PY3",
"devday",
"is_windows",
"is_linux",
"is_osx",
"is_mono",
"is_ironpython",
"is_rhino",
"is_blender",
"is_grasshopper",
"get",
"json_dump",
"json_load",
"json_dumps",
"json_dumpz",
"json_loads",
"json_loadz",
]

__all_plugins__ = [
"compas.geometry.booleans_shapely",
"compas.scene",
Expand Down
6 changes: 1 addition & 5 deletions src/compas/_iotools.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

import io
from contextlib import contextmanager

try:
from urllib.request import urlopen
except ImportError:
from urllib2 import urlopen
from urllib.request import urlopen


@contextmanager
Expand Down
7 changes: 1 addition & 6 deletions src/compas/colors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@
This package defines a color and color map class,
that can be used to work wihth colors in a consistent way across color spaces.
"""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
# ruff: noqa: F401

from .color import Color
from .colormap import ColorMap
from .colordict import ColorDict

__all__ = ["Color", "ColorMap", "ColorDict"]
18 changes: 3 additions & 15 deletions src/compas/colors/color.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

try:
basestring # type: ignore
except NameError:
basestring = str

import colorsys
import re

Expand All @@ -16,10 +7,7 @@

BASE16 = "0123456789abcdef"

try:
HEX_DEC = {v: int(v, base=16) for v in [x + y for x in BASE16 for y in BASE16]}
except Exception:
HEX_DEC = {v: int(v, 16) for v in [x + y for x in BASE16 for y in BASE16]}
HEX_DEC = {v: int(v, base=16) for v in [x + y for x in BASE16 for y in BASE16]}


class ColorError(Exception):
Expand Down Expand Up @@ -567,7 +555,7 @@ def from_unknown(cls, unknown):
if Color._is_rgb1(unknown):
return cls(*list(unknown))

if isinstance(unknown, basestring):
if isinstance(unknown, str):
return cls.from_name(unknown)

raise ColorError
Expand Down Expand Up @@ -633,7 +621,7 @@ def _is_hex(color):
bool

"""
if isinstance(color, basestring):
if isinstance(color, str):
match = re.search(r"^#(?:[0-9a-fA-F]{3}){1,2}$", color)
if match:
return True
Expand Down
4 changes: 0 additions & 4 deletions src/compas/colors/colordict.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from compas.data import Data

from .color import Color
Expand Down
4 changes: 0 additions & 4 deletions src/compas/colors/colormap.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import os

from compas.itertools import linspace
Expand Down
20 changes: 1 addition & 19 deletions src/compas/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
This package defines the core infrastructure for data serialisation in the COMPAS framework.
It provides a base class for data objects, a JSON encoder and decoder, serialisers and deserialisers, and schema validation.
"""

from __future__ import absolute_import
# ruff: noqa: F401

from .exceptions import DecoderError
from .encoders import DataEncoder
Expand All @@ -12,20 +11,3 @@
from .json import json_load, json_loads, json_loadz, json_dump, json_dumps, json_dumpz
from .schema import dataclass_dataschema, dataclass_typeschema, dataclass_jsonschema
from .schema import compas_dataclasses

__all__ = [
"Data",
"DataEncoder",
"DataDecoder",
"DecoderError",
"json_load",
"json_loads",
"json_loadz",
"json_dump",
"json_dumps",
"json_dumpz",
"dataclass_dataschema",
"dataclass_typeschema",
"dataclass_jsonschema",
"compas_dataclasses",
]
4 changes: 0 additions & 4 deletions src/compas/data/coercion.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from .validators import is_item_iterable


Expand Down
33 changes: 7 additions & 26 deletions src/compas/data/data.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,15 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

try:
from typing import TypeVar # noqa: F401

D = TypeVar("D", bound="Data")
except ImportError:
pass

import hashlib
from copy import deepcopy
from typing import TypeVar
from uuid import UUID
from uuid import uuid4

import compas

# ==============================================================================
# If you ever feel tempted to use ABCMeta in your code: don't, just DON'T.
# Assigning __metaclass__ = ABCMeta to a class causes a severe memory leak/performance
# degradation on IronPython 2.7.

# See these issues for more details:
# - https://github.com/compas-dev/compas/issues/562
# - https://github.com/compas-dev/compas/issues/649

# ==============================================================================
D = TypeVar("D", bound="Data")


class Data(object):
class Data:
"""Abstract base class for all COMPAS data objects.

Parameters
Expand Down Expand Up @@ -145,7 +126,7 @@ def __setstate__(self, state):
self.name = state["name"]

@classmethod
def __from_data__(cls, data): # type: (dict) -> Data
def __from_data__(cls, data) -> "Data":
"""Construct an object of this type from the provided data.

Parameters
Expand Down Expand Up @@ -190,7 +171,7 @@ def name(self, name):
self._name = name

@classmethod
def from_json(cls, filepath): # type: (...) -> Data
def from_json(cls, filepath) -> "Data":
"""Construct an object of this type from a JSON file.

Parameters
Expand Down Expand Up @@ -232,7 +213,7 @@ def to_json(self, filepath, pretty=False, compact=False, minimal=False):
compas.json_dump(self, filepath, pretty=pretty, compact=compact, minimal=minimal)

@classmethod
def from_jsonstring(cls, string): # type: (...) -> Data
def from_jsonstring(cls, string) -> "Data":
"""Construct an object of this type from a JSON string.

Parameters
Expand Down Expand Up @@ -276,7 +257,7 @@ def to_jsonstring(self, pretty=False, compact=False, minimal=False):
"""
return compas.json_dumps(self, pretty=pretty, compact=compact, minimal=minimal)

def copy(self, cls=None, copy_guid=False): # type: (...) -> D
def copy(self, cls=None, copy_guid=False) -> D: # type: ignore
"""Make an independent copy of the data object.

Parameters
Expand Down
Loading
Loading