Skip to content

Commit

Permalink
Fix linting errors
Browse files Browse the repository at this point in the history
Also, do not generate `doc.txt` any more. We have a README.txt, that is
enough.

modified:   setup.py
modified:   src/zc/zodbrecipes/__init__.py
modified:   src/zc/zodbrecipes/tests.py
  • Loading branch information
jugmac00 committed May 15, 2020
1 parent 5682afe commit 3454cbb
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 48 deletions.
30 changes: 15 additions & 15 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import os
from setuptools import setup, find_packages


def read(*rnames):
return open(os.path.join(os.path.dirname(__file__), *rnames)).read()


long_description = (
read('README.txt')
+ '\n' +
Expand All @@ -16,8 +18,6 @@ def read(*rnames):
'**********************\n'
)

open('doc.txt', 'w').write(long_description)

tests_require = [
'zdaemon',
'ZEO',
Expand All @@ -30,34 +30,34 @@ def read(*rnames):

name = "zc.zodbrecipes"
setup(
name = name,
name=name,
version='2.1.0.dev0',
author = "Jim Fulton",
author_email = "jim@zope.com",
description = "ZC Buildout recipes for ZODB",
license = "ZPL 2.1",
keywords = "zodb buildout",
author="Jim Fulton",
author_email="jim@zope.com",
description="ZC Buildout recipes for ZODB",
license="ZPL 2.1",
keywords="zodb buildout",
url='http://svn.zope.org/'+name,
long_description=long_description,

packages = find_packages('src'),
packages=find_packages('src'),
package_dir={'': 'src'},
include_package_data = True,
namespace_packages = ['zc'],
install_requires = [
include_package_data=True,
namespace_packages=['zc'],
install_requires=[
'zc.buildout',
'setuptools',
'six',
'zc.recipe.egg',
'ZConfig >=2.4'
],
extras_require = dict(test=tests_require),
entry_points = {
extras_require=dict(test=tests_require),
entry_points={
'zc.buildout': [
'server = %s:StorageServer' % name,
]
},
classifiers = [
classifiers=[
'Framework :: Buildout',
'Intended Audience :: Developers',
'License :: OSI Approved :: Zope Public License',
Expand Down
44 changes: 24 additions & 20 deletions src/zc/zodbrecipes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
import ZConfig.schemaless
import logging
import os
import shutil
import zc.buildout
import zc.recipe.egg

logger = logging.getLogger('zc.zodbrecipes')


class StorageServer:

def __init__(self, buildout, name, options):
Expand All @@ -38,8 +38,8 @@ def __init__(self, buildout, name, options):
options['log-directory'] = buildout[deployment]['log-directory']
options['etc-directory'] = buildout[deployment]['etc-directory']
logrotate = options.get('logrotate',
buildout[deployment].get('logrotate',''))
if logrotate.lower()=='false':
buildout[deployment].get('logrotate', ''))
if logrotate.lower() == 'false':
options['logrotate'] = ''
else:
options['logrotate'] = os.path.join(
Expand All @@ -56,7 +56,7 @@ def __init__(self, buildout, name, options):
)

options['scripts'] = ''
options['eggs'] = options.get('eggs','') + '\nzdaemon\nsetuptools'
options['eggs'] = options.get('eggs', '') + '\nzdaemon\nsetuptools'
self.egg = zc.recipe.egg.Egg(buildout, name, options)

options['runzeo'] = os.path.join(
Expand Down Expand Up @@ -146,7 +146,7 @@ def install(self):
zeo_conf = ZConfig.schemaless.loadConfigFile(StringIO(zeo_conf))
except ConfigurationSyntaxError as e:
raise zc.buildout.UserError(
'%s in:\n%s' % (e,zeo_conf)
'%s in:\n%s' % (e, zeo_conf)
)

zeo_section = [s for s in zeo_conf.sections if s.type == 'zeo']
Expand All @@ -155,7 +155,7 @@ def install(self):
if len(zeo_section) > 1:
raise zc.buildout.UserError('Too many zeo sections.')
zeo_section = zeo_section[0]
if not 'address' in zeo_section:
if 'address' not in zeo_section:
raise zc.buildout.UserError('No ZEO address was specified.')

storages = [s.name or '1' for s in zeo_conf.sections
Expand All @@ -169,14 +169,15 @@ def install(self):
zeo_conf.sections.append(event_log('STDOUT'))

zdaemon_conf = options.get('zdaemon.conf', '')+'\n'
zdaemon_conf = ZConfig.schemaless.loadConfigFile(StringIO(zdaemon_conf))
zdaemon_conf = ZConfig.schemaless.loadConfigFile(
StringIO(zdaemon_conf))

defaults = {
'program': "%s -C %s" % (options['runzeo'], zeo_conf_path),
'daemon': 'on',
'transcript': event_log_path,
'socket-name': socket_path,
'directory' : run_directory,
'directory': run_directory,
}
if deployment:
defaults['user'] = options['user']
Expand Down Expand Up @@ -208,13 +209,13 @@ def install(self):
logger.warn(no_zdaemon % options['zdaemon'])

contents = "%(zdaemon)s -C '%(conf)s' $*" % dict(
zdaemon = options['zdaemon'],
conf = zdaemon_conf_path,
zdaemon=options['zdaemon'],
conf=zdaemon_conf_path,
)
if options.get('user'):
contents = 'su %(user)s -c \\\n "%(contents)s"' % dict(
user = options['user'],
contents = contents,
user=options['user'],
contents=contents,
)
contents = "#!/bin/sh\n%s\n" % contents

Expand All @@ -230,13 +231,13 @@ def install(self):
zc.buildout.easy_install.scripts(
[(rc, 'zdaemon.zdctl', 'main')],
ws, options['executable'], options['rc-directory'],
arguments = ('['
'\n %r, %r,'
'\n ]+sys.argv[1:]'
'\n '
% ('-C', zdaemon_conf_path,
)
),
arguments=('['
'\n %r, %r,'
'\n ]+sys.argv[1:]'
'\n '
% ('-C', zdaemon_conf_path,
)
),
)

if pack:
Expand All @@ -247,7 +248,7 @@ def install(self):
else:
try:
port = int(address)
except:
except: # noqa: E722
address = '-U '+address
else:
address = '-p '+address
Expand All @@ -273,6 +274,7 @@ def install(self):

update = install


no_runzeo = """
A runzeo script couldn't be found at:
Expand All @@ -292,11 +294,13 @@ def install(self):
zc.recipe.eggs:script recipe and the zdaemon egg.
"""


def event_log(path, *data):
return ZConfig.schemaless.Section(
'eventlog', '', None,
[ZConfig.schemaless.Section('logfile', '', dict(path=[path]))])


logrotate_template = """%(logfile)s {
rotate 5
weekly
Expand Down
21 changes: 8 additions & 13 deletions src/zc/zodbrecipes/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,10 @@
from zope.testing import renormalizing

import doctest
import os
import pkg_resources
import re
import shutil
import sys
import tempfile
import unittest
import zc.buildout.testing
import zope.testing
import zope.testing # noqa: F401

try:
from zc.buildout.testing import not_found
Expand Down Expand Up @@ -58,18 +53,17 @@ def setUp(test):
checker = renormalizing.RENormalizing([
zc.buildout.testing.normalize_path,
(re.compile(
"Couldn't find index page for '[a-zA-Z0-9.]+' "
"\(maybe misspelled\?\)"
"\n"
), ''),
r"Couldn't find index page for '[a-zA-Z0-9.]+' "
r"\(maybe misspelled\?\)"
"\n"), ''),
(re.compile('#![^\n]+\n'), ''),
(re.compile('-\S+-py\d[.]\d(-\S+)?.egg'),
'-pyN.N.egg',
),
(re.compile(r'-\S+-py\d[.]\d(-\S+)?.egg'),
'-pyN.N.egg',),
not_found,
setuptools_or_distribute,
])


def test_suite():
return unittest.TestSuite((
doctest.DocFileSuite(
Expand All @@ -80,5 +74,6 @@ def test_suite():

))


if __name__ == '__main__':
unittest.main(defaultTest='test_suite')

0 comments on commit 3454cbb

Please sign in to comment.