Skip to content

Commit

Permalink
Merge pull request #5 from dekoza/py3_only
Browse files Browse the repository at this point in the history
Drop Python <3.5
  • Loading branch information
Matthieu Berthomé authored Jul 14, 2020
2 parents c3f7bb9 + f0ed78d commit 842c507
Show file tree
Hide file tree
Showing 22 changed files with 105 additions and 221 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ apt:
packages:
- dos2unix
python:
- 2.7
- 3.5
- 3.6
- 3.7
Expand All @@ -31,4 +30,4 @@ deploy:
on:
tags: true
distributions: sdist bdist_wheel
condition: $TRAVIS_PYTHON_VERSION = "2.7"
condition: $TRAVIS_PYTHON_VERSION = "3.7"
1 change: 1 addition & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ pytest-cov
mock
setuptools_scm
tox
ipdb
2 changes: 0 additions & 2 deletions examples/brothers.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from __future__ import print_function

from ldraw.figure import *
from ldraw.library.colours import *
from ldraw.library.parts.minifig.accessories import GunRevolver, CapWithLongFlatPeak
Expand Down
2 changes: 0 additions & 2 deletions examples/buggy.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from __future__ import print_function

from ldraw.figure import *
from ldraw.geometry import YAxis
from ldraw.library.colours import *
Expand Down
1 change: 0 additions & 1 deletion examples/diver.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from __future__ import print_function
from ldraw.library.colours import *
from ldraw.figure import *
from ldraw.library.parts.minifig.accessories import DiverMask, HairMale, Airtanks, Flipper, CameraMovie
Expand Down
1 change: 0 additions & 1 deletion examples/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from __future__ import print_function
from ldraw.library.colours import *
from ldraw.figure import *
from ldraw.library.parts.minifig.accessories import HairMale
Expand Down
1 change: 0 additions & 1 deletion examples/figures.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from __future__ import print_function
from ldraw.library.colours import *
from ldraw.figure import *
from ldraw.library.parts.minifig.accessories import HelmetClassicWithThickChinGuardAndVisorDimples as HelmetClassic, Torch, MetalDetector
Expand Down
1 change: 0 additions & 1 deletion examples/mandelbrot.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from __future__ import print_function
from ldraw.library.colours import (Blue_Violet, Blue, Light_Blue,
Light_Green, Green, Yellow,
Orange, Red, Magenta, Purple,
Expand Down
2 changes: 0 additions & 2 deletions examples/moon_landing.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from __future__ import print_function

from ldraw.figure import *
from ldraw.library.colours import *
from ldraw.library.parts.antenna import Antenna4HWithRoundedTop
Expand Down
1 change: 0 additions & 1 deletion examples/spaceman.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from __future__ import print_function
import random

from ldraw.geometry import Identity, XAxis, YAxis, ZAxis, Vector
Expand Down
1 change: 0 additions & 1 deletion examples/stairs.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from __future__ import print_function
from ldraw.figure import *
from ldraw.geometry import Identity
from ldraw.library.colours import *
Expand Down
17 changes: 6 additions & 11 deletions ldraw/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,20 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from __future__ import print_function

import hashlib
import shutil
import sys
import imp

import os
import shutil
import sys
import zipfile
from distutils.dir_util import copy_tree
from urllib.request import urlretrieve

from mklist.generate import generate_parts_lst
from pkg_resources import get_distribution, DistributionNotFound

from ldraw.config import get_config, write_config
from ldraw.compat import urlretrieve, PY2
from ldraw.dirs import get_data_dir, get_config_dir, get_cache_dir

from pkg_resources import get_distribution, DistributionNotFound

from ldraw.generation.colours import gen_colours
from ldraw.generation.parts import gen_parts
from ldraw.parts import Parts
Expand Down Expand Up @@ -94,7 +89,7 @@ def try_download_generate_lib():
return data_dir


class CustomImporter(object):
class CustomImporter:
""" Added to sys.meta_path as an import hook """
virtual_module = 'ldraw.library'

Expand All @@ -105,7 +100,7 @@ def valid_module(cls, fullname):
if not rest or rest.startswith('.'):
return True

def find_module(self, fullname, path=None): # pylint:disable=unused-argument
def find_module(self, fullname, path=None): # pylint:disable=unused-argument
"""
This method is called by Python if this class
is on sys.path. fullname is the fully-qualified
Expand Down
22 changes: 4 additions & 18 deletions ldraw/compat.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
""" compatibility module for python 2/3 """
import sys

PY2 = sys.version_info[0] == 2

if PY2:
from urllib import urlretrieve
from StringIO import StringIO
from __builtin__ import reduce

do_execfile = execfile
else:
from io import StringIO
from urllib.request import urlretrieve
from functools import reduce

def do_execfile(script, global_vars, local_vars):
with open(script) as f:
code = compile(f.read(), script, 'exec')
exec(code, global_vars, local_vars)

def do_execfile(script, global_vars, local_vars):
with open(script) as f:
code = compile(f.read(), script, 'exec')
exec (code, global_vars, local_vars)
1 change: 0 additions & 1 deletion ldraw/generation/colours.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"""
Called by ldraw.library_gen to generate the ldraw/library/colours.py file
"""
from __future__ import print_function
import codecs
import os

Expand Down
1 change: 0 additions & 1 deletion ldraw/generation/parts.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"""
Generates the ldraw.library.parts namespace
"""
from __future__ import print_function
import codecs
import os
import itertools
Expand Down
2 changes: 1 addition & 1 deletion ldraw/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import copy
import math
from numbers import Number
from ldraw.compat import reduce
from functools import reduce


class MatrixError(Exception):
Expand Down
6 changes: 3 additions & 3 deletions ldraw/pieces.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
# pylint: disable=too-many-arguments, too-few-public-methods
from ldraw.compat import reduce
from functools import reduce
from ldraw.geometry import Identity, Vector


class Piece(object):
class Piece:
"""
a Piece, which is a Part with a certain colour
at a certain position and rotation
Expand Down Expand Up @@ -51,7 +51,7 @@ def __repr__(self):
("%s.DAT" % self.part)


class Group(object):
class Group:
""" a Group of Pieces """
def __init__(self, position=Vector(0, 0, 0), matrix=Identity()):
self.position = position
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def get_readme():
maintainer="Matthieu Berthomé <rienafairefr@gmail.com>",
author_email="rienairefr@gmail.com, david@boddie.org.uk",
version=os.environ.get("TAG_NAME", os.environ.get("TRAVIS_TAG", "dev")),
python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, <3.9",
python_requires=">=3.5, <3.9",
packages=find_packages(),
package_data={"ldraw": ["templates/*.mustache"]},
use_scm_version=True,
Expand Down
Loading

0 comments on commit 842c507

Please sign in to comment.