forked from jan/fatamorgana
style fixes (per flake8)
This commit is contained in:
parent
4a878aa7bf
commit
60f879a1ad
29
.flake8
Normal file
29
.flake8
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
[flake8]
|
||||||
|
ignore =
|
||||||
|
# E501 line too long
|
||||||
|
E501,
|
||||||
|
# W391 newlines at EOF
|
||||||
|
W391,
|
||||||
|
# E241 multiple spaces after comma
|
||||||
|
E241,
|
||||||
|
# E302 expected 2 newlines
|
||||||
|
E302,
|
||||||
|
# W503 line break before binary operator (to be deprecated)
|
||||||
|
W503,
|
||||||
|
# E265 block comment should start with '# '
|
||||||
|
E265,
|
||||||
|
# E123 closing bracket does not match indentation of opening bracket's line
|
||||||
|
E123,
|
||||||
|
# E124 closing bracket does not match visual indentation
|
||||||
|
E124,
|
||||||
|
# E221 multiple spaces before operator
|
||||||
|
E221,
|
||||||
|
# E201 whitespace after '['
|
||||||
|
E201,
|
||||||
|
# E741 ambiguous variable name 'I'
|
||||||
|
E741,
|
||||||
|
|
||||||
|
|
||||||
|
per-file-ignores =
|
||||||
|
# F401 import without use
|
||||||
|
*/__init__.py: F401,
|
@ -27,10 +27,12 @@
|
|||||||
import pathlib
|
import pathlib
|
||||||
|
|
||||||
from .main import OasisLayout, Cell, XName
|
from .main import OasisLayout, Cell, XName
|
||||||
from .basic import NString, AString, Validation, OffsetTable, OffsetEntry, \
|
from .basic import (
|
||||||
EOFError, SignedError, InvalidDataError, InvalidRecordError, \
|
NString, AString, Validation, OffsetTable, OffsetEntry,
|
||||||
UnfilledModalError, \
|
EOFError, SignedError, InvalidDataError, InvalidRecordError,
|
||||||
|
UnfilledModalError,
|
||||||
ReuseRepetition, GridRepetition, ArbitraryRepetition
|
ReuseRepetition, GridRepetition, ArbitraryRepetition
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
__author__ = 'Jan Petykiewicz'
|
__author__ = 'Jan Petykiewicz'
|
||||||
|
@ -13,7 +13,7 @@ import warnings
|
|||||||
try:
|
try:
|
||||||
import numpy
|
import numpy
|
||||||
_USE_NUMPY = True
|
_USE_NUMPY = True
|
||||||
except:
|
except ImportError:
|
||||||
_USE_NUMPY = False
|
_USE_NUMPY = False
|
||||||
|
|
||||||
|
|
||||||
@ -1491,9 +1491,10 @@ class ArbitraryRepetition:
|
|||||||
for x, y in zip(self.x_displacements, self.y_displacements))
|
for x, y in zip(self.x_displacements, self.y_displacements))
|
||||||
return size
|
return size
|
||||||
|
|
||||||
|
|
||||||
def __eq__(self, other: Any) -> bool:
|
def __eq__(self, other: Any) -> bool:
|
||||||
return isinstance(other, type(self)) and self.x_displacements == other.x_displacements and self.y_displacements == other.y_displacements
|
return (isinstance(other, type(self))
|
||||||
|
and self.x_displacements == other.x_displacements
|
||||||
|
and self.y_displacements == other.y_displacements)
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return 'ArbitraryRepetition: x{} y{})'.format(self.x_displacements, self.y_displacements)
|
return 'ArbitraryRepetition: x{} y{})'.format(self.x_displacements, self.y_displacements)
|
||||||
|
@ -9,9 +9,11 @@ import logging
|
|||||||
|
|
||||||
from . import records
|
from . import records
|
||||||
from .records import Modals, Record
|
from .records import Modals, Record
|
||||||
from .basic import OffsetEntry, OffsetTable, NString, AString, real_t, Validation, \
|
from .basic import (
|
||||||
read_magic_bytes, write_magic_bytes, read_uint, EOFError, \
|
OffsetEntry, OffsetTable, NString, AString, real_t, Validation,
|
||||||
InvalidDataError, InvalidRecordError
|
read_magic_bytes, write_magic_bytes, read_uint, EOFError,
|
||||||
|
InvalidRecordError,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
__author__ = 'Jan Petykiewicz'
|
__author__ = 'Jan Petykiewicz'
|
||||||
|
@ -19,12 +19,14 @@ import io
|
|||||||
import logging
|
import logging
|
||||||
import pprint
|
import pprint
|
||||||
from warnings import warn
|
from warnings import warn
|
||||||
from .basic import AString, NString, repetition_t, property_value_t, real_t, \
|
from .basic import (
|
||||||
ReuseRepetition, OffsetTable, Validation, read_point_list, read_property_value, \
|
AString, NString, repetition_t, property_value_t, real_t,
|
||||||
read_bstring, read_uint, read_sint, read_real, read_repetition, read_interval, \
|
ReuseRepetition, OffsetTable, Validation, read_point_list, read_property_value,
|
||||||
write_bstring, write_uint, write_sint, write_real, write_interval, write_point_list, \
|
read_bstring, read_uint, read_sint, read_real, read_repetition, read_interval,
|
||||||
write_property_value, read_bool_byte, write_bool_byte, read_byte, write_byte, \
|
write_bstring, write_uint, write_sint, write_real, write_interval, write_point_list,
|
||||||
InvalidDataError, UnfilledModalError, PathExtensionScheme, _USE_NUMPY
|
write_property_value, read_bool_byte, write_bool_byte, read_byte, write_byte,
|
||||||
|
InvalidDataError, UnfilledModalError, PathExtensionScheme, _USE_NUMPY,
|
||||||
|
)
|
||||||
|
|
||||||
if _USE_NUMPY:
|
if _USE_NUMPY:
|
||||||
import numpy
|
import numpy
|
||||||
@ -119,6 +121,7 @@ def verify_modal(var: Optional[T]) -> T:
|
|||||||
raise UnfilledModalError
|
raise UnfilledModalError
|
||||||
return var
|
return var
|
||||||
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
Records
|
Records
|
||||||
@ -487,7 +490,7 @@ class End(Record):
|
|||||||
offset_table: Optional[OffsetTable] = OffsetTable.read(stream)
|
offset_table: Optional[OffsetTable] = OffsetTable.read(stream)
|
||||||
else:
|
else:
|
||||||
offset_table = None
|
offset_table = None
|
||||||
_padding_string = read_bstring(stream)
|
_padding_string = read_bstring(stream) # noqa
|
||||||
validation = Validation.read(stream)
|
validation = Validation.read(stream)
|
||||||
record = End(validation, offset_table)
|
record = End(validation, offset_table)
|
||||||
logger.debug('Record ending at 0x{:x}:\n {}'.format(stream.tell(), record))
|
logger.debug('Record ending at 0x{:x}:\n {}'.format(stream.tell(), record))
|
||||||
@ -591,8 +594,8 @@ class CBlock(Record):
|
|||||||
if compression_type == 0:
|
if compression_type == 0:
|
||||||
count = len(decompressed_bytes)
|
count = len(decompressed_bytes)
|
||||||
compressor = zlib.compressobj(wbits=-zlib.MAX_WBITS, **compression_args)
|
compressor = zlib.compressobj(wbits=-zlib.MAX_WBITS, **compression_args)
|
||||||
compressed_bytes = compressor.compress(decompressed_bytes) + \
|
compressed_bytes = (compressor.compress(decompressed_bytes)
|
||||||
compressor.flush()
|
+ compressor.flush())
|
||||||
else:
|
else:
|
||||||
raise InvalidDataError('Unknown compression type: '
|
raise InvalidDataError('Unknown compression type: '
|
||||||
'{}'.format(compression_type))
|
'{}'.format(compression_type))
|
||||||
@ -617,8 +620,8 @@ class CBlock(Record):
|
|||||||
decompression_args = {}
|
decompression_args = {}
|
||||||
if self.compression_type == 0:
|
if self.compression_type == 0:
|
||||||
decompressor = zlib.decompressobj(wbits=-zlib.MAX_WBITS, **decompression_args)
|
decompressor = zlib.decompressobj(wbits=-zlib.MAX_WBITS, **decompression_args)
|
||||||
decompressed_bytes = decompressor.decompress(self.compressed_bytes) + \
|
decompressed_bytes = (decompressor.decompress(self.compressed_bytes)
|
||||||
decompressor.flush()
|
+ decompressor.flush())
|
||||||
if len(decompressed_bytes) != self.decompressed_byte_count:
|
if len(decompressed_bytes) != self.decompressed_byte_count:
|
||||||
raise InvalidDataError('Decompressed data length does not match!')
|
raise InvalidDataError('Decompressed data length does not match!')
|
||||||
else:
|
else:
|
||||||
@ -1420,8 +1423,9 @@ class Placement(Record):
|
|||||||
r = self.repetition is not None
|
r = self.repetition is not None
|
||||||
f = self.flip
|
f = self.flip
|
||||||
|
|
||||||
if (self.magnification == 1 and
|
if (self.magnification == 1
|
||||||
self.angle is not None and abs(self.angle % 90.0) < 1e-14):
|
and self.angle is not None
|
||||||
|
and abs(self.angle % 90.0) < 1e-14):
|
||||||
aa = int((self.angle / 90) % 4.0)
|
aa = int((self.angle / 90) % 4.0)
|
||||||
bools = (c, n, x, y, r, aa & 0b10, aa & 0b01, f)
|
bools = (c, n, x, y, r, aa & 0b10, aa & 0b01, f)
|
||||||
m = False
|
m = False
|
||||||
@ -2084,11 +2088,11 @@ class Trapezoid(Record, GeometryMixin):
|
|||||||
if self.is_vertical:
|
if self.is_vertical:
|
||||||
if height is not None and delta_b - delta_a > height:
|
if height is not None and delta_b - delta_a > height:
|
||||||
raise InvalidDataError('Trapezoid: h < delta_b - delta_a'
|
raise InvalidDataError('Trapezoid: h < delta_b - delta_a'
|
||||||
' ({} < {} - {})'.format(height, delta_b, delta_a))
|
+ ' ({} < {} - {})'.format(height, delta_b, delta_a))
|
||||||
else:
|
else:
|
||||||
if width is not None and delta_b - delta_a > width:
|
if width is not None and delta_b - delta_a > width:
|
||||||
raise InvalidDataError('Trapezoid: w < delta_b - delta_a'
|
raise InvalidDataError('Trapezoid: w < delta_b - delta_a'
|
||||||
' ({} < {} - {})'.format(width, delta_b, delta_a))
|
+ ' ({} < {} - {})'.format(width, delta_b, delta_a))
|
||||||
|
|
||||||
def get_is_vertical(self) -> bool:
|
def get_is_vertical(self) -> bool:
|
||||||
return verify_modal(self.is_vertical)
|
return verify_modal(self.is_vertical)
|
||||||
@ -2191,7 +2195,7 @@ class Trapezoid(Record, GeometryMixin):
|
|||||||
|
|
||||||
|
|
||||||
class CTrapezoid(Record, GeometryMixin):
|
class CTrapezoid(Record, GeometryMixin):
|
||||||
"""
|
r"""
|
||||||
CTrapezoid record (ID 26)
|
CTrapezoid record (ID 26)
|
||||||
|
|
||||||
Compact trapezoid formats.
|
Compact trapezoid formats.
|
||||||
|
Loading…
Reference in New Issue
Block a user