Skip to content

Commit

Permalink
- apply suggestions from mgedmin
Browse files Browse the repository at this point in the history
  • Loading branch information
dataflake committed Sep 27, 2024
1 parent 85934f9 commit 0a2ec18
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 62 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ Change log

1.0 (unreleased)
----------------

- Converted to an installable Python package.
30 changes: 3 additions & 27 deletions docs/hacking.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,7 @@ cover the code:
$ coverage report -i -m --fail-under=100
Name Stmts Miss Branch BrPart Cover Missing
----------------------------------------------------------------------------------
src/zope/meta/__init__.py 4 0 0 0 100.00%
src/zope/meta/message.py 52 0 18 0 100.00%
src/zope/meta/tests.py 189 0 38 0 100.00%
----------------------------------------------------------------------------------
TOTAL 245 0 56 0 100.00%
...
Building the documentation
Expand Down Expand Up @@ -156,30 +152,10 @@ as well as installing ``tox``:
Running zope.testrunner.layer.UnitTests tests:
Set up zope.testrunner.layer.UnitTests in 0.000 seconds.
Running:
.........................................
Ran 41 tests with 0 failures, 0 errors, 0 skipped in 0.003 seconds.
Tearing down left over layers:
Tear down zope.testrunner.layer.UnitTests in 0.000 seconds.
.....
Running ``tox`` with no arguments runs all the configured environments,
including building the docs and testing their snippets:

.. code-block:: sh
$ tox
lint: commands[0]> isort --check-only --diff /home/tseaver/projects/Zope/Z3/zope.meta/src /home/tseaver/projects/Zope/Z3/zope.meta/setup.py
lint: commands[1]> flake8 src setup.py
lint: OK (0.50=setup[0.02]+cmd[0.19,0.28] seconds)
congratulations :) (0.73 seconds)
...
__________________________________ summary ____________________________________
lint: commands succeeded
py37: commands succeeded
...
pypy3: commands succeeded
docs: commands succeeded
coverage: commands succeeded
congratulations :)
including building the docs and testing their snippets.


Contributing to :mod:`zope.meta`
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# Generated from:
# https://github.com/zopefoundation/meta/tree/master/config/c-code
# https://github.com/zopefoundation/meta/tree/master/config/pure-python

[build-system]
requires = ["setuptools<74"]
Expand Down
10 changes: 6 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ def read(*rnames):
url='https://github.com/zopefoundation/zope.meta',
project_urls={
'Documentation': 'https://zopemeta.readthedocs.io',
'Issue Tracker': 'https://github.com/zopefoundation/meta/issues',
'Sources': 'https://github.com/zopefoundation/meta',
'Issue Tracker': 'https://github.com/zopefoundation/zope.meta/issues',
'Sources': 'https://github.com/zopefoundation/zope.meta',
},
packages=find_packages('src'),
package_dir={'': 'src'},
Expand Down Expand Up @@ -87,8 +87,10 @@ def read(*rnames):
'config-package=zope.meta.config_package:main',
'multi-call=zope.meta.multi_call:main',
're-enable-actions=zope.meta.re_enable_actions:main',
'set-branch-protection-rules='
'zope.meta.set_branch_protection_rules:main',
(
'set-branch-protection-rules='
'zope.meta.set_branch_protection_rules:main'
),
'update-python-support=zope.meta.update_python_support:main',
],
},
Expand Down
37 changes: 18 additions & 19 deletions src/zope/meta/multi_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,26 @@
from .shared.path import path_factory


parser = argparse.ArgumentParser(
description='Call a script on all repositories listed in a packages.txt.',
epilog='Additional optional arguments are passed directly to the script.')
parser.add_argument(
'script', type=path_factory('script', has_extension='.py'),
help='path to the Python script to be called')
parser.add_argument(
'packages_txt', type=path_factory('packages.txt', has_extension='.txt'),
help='path to the packages.txt; script is called on each repository listed'
' inside', metavar='packages.txt')
parser.add_argument(
'clones', type=path_factory('clones', is_dir=True),
help='path to the directory where the clones of the repositories are'
' stored')

# idea from https://stackoverflow.com/a/37367814/8531312
args, sub_args = parser.parse_known_args()
packages = list_packages(args.packages_txt)
def main():
parser = argparse.ArgumentParser(
description='Call a script on all repositories listed in a packages.txt.',
epilog='Additional optional arguments are passed directly to the script.')
parser.add_argument(
'script', type=path_factory('script', has_extension='.py'),
help='path to the Python script to be called')
parser.add_argument(
'packages_txt', type=path_factory('packages.txt', has_extension='.txt'),
help='path to the packages.txt; script is called on each repository listed'
' inside', metavar='packages.txt')
parser.add_argument(
'clones', type=path_factory('clones', is_dir=True),
help='path to the directory where the clones of the repositories are'
' stored')

# idea from https://stackoverflow.com/a/37367814/8531312
args, sub_args = parser.parse_known_args()
packages = list_packages(args.packages_txt)

def main():
for package in packages:
print(f'*** Running {args.script.name} on {package} ***')
if (args.clones / package).exists():
Expand Down
21 changes: 10 additions & 11 deletions src/zope/meta/re_enable_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,6 @@
BASE_PATH = pathlib.Path(__file__).parent


parser = argparse.ArgumentParser(
description='Re-enable GitHub Actions for all repos in a packages.txt'
' files.')
parser.add_argument(
'--force-run',
help='Run workflow even it is already enabled.',
action='store_true')

args = parser.parse_args()


def run_workflow(base_url, org, repo):
"""Manually start the tests.yml workflow of a repository."""
result = call('gh', 'workflow', 'run', 'tests.yml', '-R', f'{org}/{repo}')
Expand All @@ -47,6 +36,16 @@ def run_workflow(base_url, org, repo):


def main():
parser = argparse.ArgumentParser(
description='Re-enable GitHub Actions for all repos in a packages.txt'
' files.')
parser.add_argument(
'--force-run',
help='Run workflow even it is already enabled.',
action='store_true')

args = parser.parse_args()

for repo in ALL_REPOS:
print(repo)
wfs = call(
Expand Down

0 comments on commit 0a2ec18

Please sign in to comment.