Skip to content

Commit b4495eb

Browse files
committed
- full PEP-8 compliance with the exception of import sorting
1 parent 2da2c2c commit b4495eb

File tree

101 files changed

+573
-559
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+573
-559
lines changed

CHANGES.rst

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ Features
1818
which are deprecated in Python 3.8.
1919
(`#476 <https://github.com/zopefoundation/Zope/pull/476>`_)
2020

21+
Other changes
22+
+++++++++++++
23+
- full PEP-8 compliance with the exception of import sorting
24+
2125

2226
4.0b10 (2019-03-08)
2327
-------------------

setup.cfg

+1-2
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@ ignore =
3434
# We should remove the following ignored check codes:
3535
T000,
3636
C103,
37-
3837
no-accept-encodings = True
39-
38+
doctests = True
4039
exclude =
4140
bootstrap.py
4241

src/App/ApplicationManager.py

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ def __bobo_traverse__(self, request, name):
7878
return self[name]
7979
return getattr(self, name)
8080

81+
8182
InitializeClass(DatabaseChooser)
8283

8384

src/App/Extensions.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ def __init__(self, f, im=0):
3333
def __eq__(self, other):
3434
if not isinstance(other, FuncCode):
3535
return False
36-
return ((self.co_argcount, self.co_varnames) ==
37-
(other.co_argcount, other.co_varnames))
36+
return (self.co_argcount, self.co_varnames) == \
37+
(other.co_argcount, other.co_varnames)
3838

3939
def __lt__(self, other):
4040
if not isinstance(other, FuncCode):
4141
return False
42-
return ((self.co_argcount, self.co_varnames) <
43-
(other.co_argcount, other.co_varnames))
42+
return (self.co_argcount, self.co_varnames) < \
43+
(other.co_argcount, other.co_varnames)
4444

4545

4646
def _getPath(home, prefix, name, suffixes):
@@ -151,6 +151,7 @@ def getPath(prefix, name, checkProduct=1, suffixes=('',), cfg=None):
151151

152152
_modules = {} # cache
153153

154+
154155
def getObject(module, name, reload=0):
155156
# The use of _modules here is not thread safe, however, there is
156157
# no real harm in a race condition here. If two threads
@@ -180,7 +181,7 @@ def getObject(module, name, reload=0):
180181
execsrc = f.read()
181182
except Exception:
182183
raise NotFound("The specified module, '%s', "
183-
"couldn't be opened." % module)
184+
"couldn't be opened." % module)
184185
module_dict = {}
185186
exec_(execsrc, module_dict)
186187

src/App/FactoryDispatcher.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
from Acquisition import aq_base
2525
from Acquisition import Implicit
2626
from ExtensionClass import Base
27-
from zExceptions import Redirect
2827

2928
from OFS.metaconfigure import get_registered_packages
3029

@@ -61,11 +60,12 @@ class Product(Base):
6160
def __init__(self, id):
6261
self.id = id
6362

64-
security.declarePublic('Destination')
63+
@security.public
6564
def Destination(self):
6665
"Return the destination for factory output"
6766
return self
6867

68+
6969
InitializeClass(Product)
7070

7171

@@ -117,15 +117,15 @@ def __init__(self, product, dest, REQUEST=None):
117117
v = v[:v.rfind('/')]
118118
self._u = v[:v.rfind('/')]
119119

120-
security.declarePublic('Destination')
120+
@security.public
121121
def Destination(self):
122122
"Return the destination for factory output"
123123
return self.__dict__['_d'] # we don't want to wrap the result!
124124

125-
security.declarePublic('this')
125+
security.declarePublic('this') # NOQA: D001
126126
this = Destination
127127

128-
security.declarePublic('DestinationURL')
128+
@security.public
129129
def DestinationURL(self):
130130
"Return the URL for the destination for factory output"
131131
url = getattr(self, '_u', None)

src/App/ImageFile.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def index_html(self, REQUEST, RESPONSE):
120120
return filestream_iterator(self.path, mode='rb')
121121

122122
if bbb.HAS_ZSERVER:
123-
security.declarePublic('HEAD')
123+
@security.public
124124
def HEAD(self, REQUEST, RESPONSE):
125125
""" """
126126
RESPONSE.setHeader('Content-Type', self.content_type)
@@ -134,4 +134,5 @@ def __len__(self):
134134
def __str__(self):
135135
return '<img src="%s" alt="" />' % self.__name__
136136

137+
137138
InitializeClass(ImageFile)

src/App/Management.py

+17-13
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
from App.special_dtml import DTMLFile
2424
from ExtensionClass import Base
2525
from six.moves.urllib.parse import quote, unquote
26-
from zExceptions import Redirect
2726
from zope.interface import implementer
2827
import itertools
2928
import six
@@ -40,12 +39,12 @@ class Tabs(Base):
4039

4140
security = ClassSecurityInfo()
4241

43-
security.declarePublic('manage_tabs')
42+
security.declarePublic('manage_tabs') # NOQA: D001
4443
manage_tabs = DTMLFile('dtml/manage_tabs', globals())
4544

4645
manage_options = ()
4746

48-
security.declarePublic('filtered_manage_options')
47+
@security.public
4948
def filtered_manage_options(self, REQUEST=None):
5049
result = []
5150
try:
@@ -60,7 +59,7 @@ def filtered_manage_options(self, REQUEST=None):
6059

6160
path = d.get('path', None)
6261
if path is None:
63-
path = d['action']
62+
path = d['action']
6463

6564
o = self.restrictedTraverse(path, None)
6665
if o is None:
@@ -133,6 +132,7 @@ def tabs_path_info(self, script, path):
133132
out.append(last)
134133
return '/'.join(out)
135134

135+
136136
InitializeClass(Tabs)
137137

138138

@@ -142,16 +142,18 @@ class Navigation(Base):
142142

143143
security = ClassSecurityInfo()
144144

145-
security.declareProtected(view_management_screens, 'manage')
145+
security.declareProtected(view_management_screens, 'manage') # NOQA: D001
146146
manage = DTMLFile('dtml/manage', globals())
147147

148-
security.declareProtected(view_management_screens, 'manage_menu')
148+
security.declareProtected(view_management_screens, # NOQA: D001
149+
'manage_menu')
149150
manage_menu = DTMLFile('dtml/menu', globals())
150151

151-
security.declareProtected(view_management_screens, 'manage_page_footer')
152+
security.declareProtected(view_management_screens, # NOQA: D001
153+
'manage_page_footer')
152154
manage_page_footer = DTMLFile('dtml/manage_page_footer', globals())
153155

154-
security.declarePublic('manage_form_title')
156+
security.declarePublic('manage_form_title') # NOQA: D001
155157
manage_form_title = DTMLFile('dtml/manage_form_title', globals(),
156158
form_title='Add Form',
157159
help_product=None,
@@ -160,7 +162,8 @@ class Navigation(Base):
160162
varnames=('form_title', 'help_product', 'help_topic'))
161163

162164
_manage_page_header = DTMLFile('dtml/manage_page_header', globals())
163-
security.declareProtected(view_management_screens, 'manage_page_header')
165+
166+
@security.protected(view_management_screens)
164167
def manage_page_header(self, *args, **kw):
165168
"""manage_page_header."""
166169
kw['css_urls'] = itertools.chain(
@@ -171,13 +174,14 @@ def manage_page_header(self, *args, **kw):
171174
self._get_zmi_additionals('zmi_additional_js_paths'))
172175
return self._manage_page_header(*args, **kw)
173176

174-
security.declareProtected(view_management_screens, 'manage_navbar')
177+
security.declareProtected(view_management_screens, # NOQA: D001
178+
'manage_navbar')
175179
manage_navbar = DTMLFile('dtml/manage_navbar', globals())
176180

177-
security.declarePublic('zope_copyright')
181+
security.declarePublic('zope_copyright') # NOQA: D001
178182
zope_copyright = DTMLFile('dtml/copyright', globals())
179183

180-
security.declarePublic('manage_zmi_logout')
184+
@security.public
181185
def manage_zmi_logout(self, REQUEST, RESPONSE):
182186
"""Logout current user"""
183187
p = getattr(REQUEST, '_logout_path', None)
@@ -204,7 +208,7 @@ def _get_zmi_additionals(self, attrib):
204208
additionals = (additionals, )
205209
return additionals
206210

211+
207212
# Navigation doesn't have an inherited __class_init__ so doesn't get
208213
# initialized automatically.
209-
210214
InitializeClass(Navigation)

src/App/Undo.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class UndoSupport(Tabs, Implicit):
3434
{'label': 'Undo', 'action': 'manage_UndoForm'},
3535
)
3636

37-
security.declareProtected(undo_changes, 'manage_UndoForm')
37+
security.declareProtected(undo_changes, 'manage_UndoForm') # NOQA: D001
3838
manage_UndoForm = DTMLFile(
3939
'dtml/undo',
4040
globals(),
@@ -61,7 +61,7 @@ def _get_request_var_or_attr(self, name, default):
6161
v = default
6262
return v
6363

64-
security.declareProtected(undo_changes, 'undoable_transactions')
64+
@security.protected(undo_changes)
6565
def undoable_transactions(self, first_transaction=None,
6666
last_transaction=None,
6767
PrincipiaUndoBatchSize=None):
@@ -98,7 +98,7 @@ def undoable_transactions(self, first_transaction=None,
9898

9999
return r
100100

101-
security.declareProtected(undo_changes, 'manage_undo_transactions')
101+
@security.protected(undo_changes)
102102
def manage_undo_transactions(self, transaction_info=(), REQUEST=None):
103103
"""
104104
"""

src/App/special_dtml.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
##############################################################################
1313

1414
import os
15-
import sys
1615
from logging import getLogger
1716

1817
import DocumentTemplate
@@ -93,6 +92,7 @@ def __call__(self, *args, **kw):
9392
return HTMLFile.inheritedAttribute('__call__')(
9493
*(self,) + args[1:], **kw)
9594

95+
9696
defaultBindings = {'name_context': 'context',
9797
'name_container': 'container',
9898
'name_m_self': 'self',

src/App/tests/test_getZopeVersion.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
from pkg_resources import get_distribution
1919
from App.version_txt import getZopeVersion
2020

21+
2122
class Test(unittest.TestCase):
2223
def test_major(self):
2324
self.assertEqual(
2425
getZopeVersion().major,
25-
int(get_distribution("Zope").version.split(".")[0])
26-
)
26+
int(get_distribution("Zope").version.split(".")[0]))
2727

2828
def test_types(self):
2929
zv = getZopeVersion()

src/App/version_txt.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121

2222
ZopeVersion = collections.namedtuple(
2323
"ZopeVersion",
24-
["major", "minor", "micro", "status", "release"]
25-
)
24+
["major", "minor", "micro", "status", "release"])
2625

2726

2827
def _prep_version_data():
@@ -42,16 +41,14 @@ def _prep_version_data():
4241
int(version_dict.get('minor') or -1),
4342
int(version_dict.get('micro') or -1),
4443
version_dict.get('status') or '',
45-
int(version_dict.get('release') or -1),
46-
)
47-
48-
44+
int(version_dict.get('release') or -1))
4945

5046

5147
def version_txt():
5248
_prep_version_data()
5349
return '(%s)' % _version_string
5450

51+
5552
def getZopeVersion():
5653
"""return information about the Zope version as a named tuple.
5754

src/OFS/Application.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,9 @@ def _is_package(product_dir, product_name):
339339
return False
340340

341341
init_py = os.path.join(package_dir, '__init__.py')
342-
if (not os.path.exists(init_py) and
343-
not os.path.exists(init_py + 'c') and
344-
not os.path.exists(init_py + 'o')):
342+
if not os.path.exists(init_py) and \
343+
not os.path.exists(init_py + 'c') and \
344+
not os.path.exists(init_py + 'o'):
345345
return False
346346
return True
347347

src/OFS/Cache.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ def filterCacheManagers(orig, container, name, value, extra):
5858
It causes objects to be found only if they are
5959
in the list of cache managers.
6060
"""
61-
if (hasattr(aq_base(container), ZCM_MANAGERS) and
62-
name in getattr(container, ZCM_MANAGERS)):
61+
if hasattr(aq_base(container), ZCM_MANAGERS) and \
62+
name in getattr(container, ZCM_MANAGERS):
6363
return 1
6464
return 0
6565

src/OFS/DTMLDocument.py

+4-10
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,7 @@
2424
from OFS.DTMLMethod import safe_file_data
2525
from OFS.PropertyManager import PropertyManager
2626
from six import binary_type
27-
from six import PY2
28-
from six import PY3
29-
from six import text_type
3027
from six.moves.urllib.parse import quote
31-
from zExceptions import ResourceLockedError
3228
from zExceptions.TracebackSupplement import PathTracebackSupplement
3329
from zope.contenttype import guess_content_type
3430

@@ -45,15 +41,13 @@ class DTMLDocument(PropertyManager, DTMLMethod):
4541
zmi_icon = 'far fa-file-alt'
4642
_locked_error_text = 'This document has been locked.'
4743

48-
manage_options = (
49-
DTMLMethod.manage_options[:2] +
50-
PropertyManager.manage_options +
51-
DTMLMethod.manage_options[2:]
52-
)
44+
manage_options = (DTMLMethod.manage_options[:2]
45+
+ PropertyManager.manage_options
46+
+ DTMLMethod.manage_options[2:])
5347

5448
# Replace change_dtml_methods by change_dtml_documents
5549
__ac_permissions__ = tuple([
56-
(perms[0] == change_dtml_methods) and
50+
(perms[0] == change_dtml_methods) and # NOQA: W504
5751
(change_dtml_documents, perms[1]) or perms
5852
for perms in DTMLMethod.__ac_permissions__])
5953

0 commit comments

Comments
 (0)