Skip to content

Commit

Permalink
more linting
Browse files Browse the repository at this point in the history
  • Loading branch information
loechel committed Oct 5, 2018
1 parent 309ea8d commit efed7ac
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 26 deletions.
4 changes: 4 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ ignore =
N805,
N806,
N812,
# We should remove the following ignored check codes:
E301,
T000,
C103,

no-accept-encodings = True

exclude =
Expand Down
27 changes: 17 additions & 10 deletions src/OFS/FindSupport.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,44 +31,51 @@

@implementer(IFindSupport)
class FindSupport(Base):
"""Find support for Zope Folders"""
"""Find support for Zope Folders."""

manage_options = ()
security = ClassSecurityInfo()

security.declareProtected(view_management_screens, 'manage_findForm')
manage_findForm = DTMLFile('dtml/findForm', globals(),
management_view='Find')
security.declareProtected(view_management_screens, 'manage_findForm') # NOQA: D001,E501
manage_findForm = DTMLFile(
'dtml/findForm',
globals(),
management_view='Find',
)

manage_options = (
{'label': 'Find', 'action': 'manage_findForm'},
{
'label': 'Find',
'action': 'manage_findForm',
},
)

security.declareProtected(view_management_screens, 'ZopeFind')
@security.protected(view_management_screens)
def ZopeFind(self, obj, obj_ids=None, obj_metatypes=None,
obj_searchterm=None, obj_expr=None,
obj_mtime=None, obj_mspec=None,
obj_permission=None, obj_roles=None,
search_sub=0,
REQUEST=None, result=None, pre=''):
"""Zope Find interface"""
"""Zope Find interface."""
return self.ZopeFindAndApply(
obj, obj_ids=obj_ids,
obj_metatypes=obj_metatypes, obj_searchterm=obj_searchterm,
obj_expr=obj_expr, obj_mtime=obj_mtime, obj_mspec=obj_mspec,
obj_permission=obj_permission, obj_roles=obj_roles,
search_sub=search_sub, REQUEST=REQUEST, result=result,
pre=pre, apply_func=None, apply_path='')
pre=pre, apply_func=None, apply_path=''
)

security.declareProtected(view_management_screens, 'ZopeFindAndApply')
@security.protected(view_management_screens)
def ZopeFindAndApply(self, obj, obj_ids=None, obj_metatypes=None,
obj_searchterm=None, obj_expr=None,
obj_mtime=None, obj_mspec=None,
obj_permission=None, obj_roles=None,
search_sub=0,
REQUEST=None, result=None, pre='',
apply_func=None, apply_path=''):
"""Zope Find interface and apply"""
"""Zope Find interface and apply."""

if result is None:
result = []
Expand Down
3 changes: 3 additions & 0 deletions src/OFS/misc_.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class misc_(object):
security = ClassSecurityInfo()
security.declareObjectPublic()


InitializeClass(misc_)


Expand All @@ -35,6 +36,7 @@ class p_(object):
app_dir = dirname(App.__file__)
zopelogo_png = ImageFile('www/zopelogo.png', app_dir)


InitializeClass(p_)


Expand All @@ -56,4 +58,5 @@ def __getitem__(self, name):
def __setitem__(self, name, v):
self._d[name] = v


InitializeClass(Misc_)
40 changes: 24 additions & 16 deletions src/OFS/tests/testRanges.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ def createBigFile():

return file


TESTFOLDER_NAME = 'RangesTestSuite_testFolder'
BIGFILE = createBigFile()


class TestRequestRange(unittest.TestCase):

# Test case setup and teardown
def setUp(self):
import io
Expand Down Expand Up @@ -193,9 +195,10 @@ def expectMultipleRanges(self, range, sets, draft=0):
# Decode the multipart message and force a latin-1 encoding,
# revert that later after the email was parsed
bodyfile = io.StringIO(
'Content-Type: ' +
rsp.getHeader('content-type') +
'\n\n' + body.decode('latin-1'))
'Content-Type: '
+ rsp.getHeader('content-type')
+ '\n\n' + body.decode('latin-1')
)

# This needs text, hence the forced latin-1 decoding.
msg = email.message_from_file(bodyfile)
Expand Down Expand Up @@ -249,16 +252,16 @@ def testOpenEndedRange(self):
self.expectSingleRange('3-', 3, len(self.data))

def testSuffixRange(self):
l = len(self.data)
self.expectSingleRange('-3', l - 3, l)
length = len(self.data)
self.expectSingleRange('-3', length - 3, length)

def testWithNegativeZero(self):
# A satisfiable and an unsatisfiable range
self.expectSingleRange('-0,3-23', 3, 24)

def testEndOverflow(self):
l = len(self.data)
start, end = l - 10, l + 10
length = len(self.data)
start, end = length - 10, length + 10
range = '%d-%d' % (start, end)
self.expectSingleRange(range, start, len(self.data))

Expand All @@ -274,8 +277,8 @@ def testBigFile(self):

def testBigFileEndOverflow(self):
self.uploadBigFile()
l = len(self.data)
start, end = l - 100, l + 100
length = len(self.data)
start, end = length - 100, length + 100
range = '%d-%d' % (start, end)
self.expectSingleRange(range, start, len(self.data))

Expand Down Expand Up @@ -304,8 +307,8 @@ def testMultipleRangesBigFileOutOfOrder(self):

def testMultipleRangesBigFileEndOverflow(self):
self.uploadBigFile()
l = len(self.data)
start, end = l - 100, l + 100
length = len(self.data)
start, end = length - 100, length + 100
self.expectMultipleRanges(
'3-700,%s-%s' % (start, end),
[(3, 701), (len(self.data) - 100, len(self.data))])
Expand All @@ -319,24 +322,29 @@ def testIllegalIfRange(self):
def testEqualIfRangeDate(self):
self.expectSingleRange(
'10-25', 10, 26,
if_range=self.createLastModifiedDate())
if_range=self.createLastModifiedDate()
)

def testIsModifiedIfRangeDate(self):
self.expectOK(
'21-25,10-20',
if_range=self.createLastModifiedDate(offset=-100))
if_range=self.createLastModifiedDate(offset=-100)
)

def testIsNotModifiedIfRangeDate(self):
self.expectSingleRange(
'10-25', 10, 26,
if_range=self.createLastModifiedDate(offset=100))
if_range=self.createLastModifiedDate(offset=100)
)

def testEqualIfRangeEtag(self):
self.expectSingleRange(
'10-25', 10, 26,
if_range=self.file.http__etag())
if_range=self.file.http__etag()
)

def testNotEqualIfRangeEtag(self):
self.expectOK(
'10-25',
if_range=self.file.http__etag() + 'bar')
if_range=self.file.http__etag() + 'bar'
)
1 change: 1 addition & 0 deletions src/OFS/tests/test_registerpackage.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
##############################################################################
"""Unit tests for the registerPackage directive.
"""

# need to add the testing package to the pythonpath in order to
# test python-packages-as-products
from Products.Five.tests import testing
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ deps =

commands =
isort --apply --recursive {toxinidir}/src setup.py {posargs}
#isort --apply --recursive {toxinidir}/src/OFS {posargs}

[testenv:autopep8]
basepython = python2.7
Expand Down

0 comments on commit efed7ac

Please sign in to comment.