Skip to content

Commit

Permalink
Add use option to sources, and default-use to the settings.
Browse files Browse the repository at this point in the history
`default-use` is true by default.  When false, the source is not
checked out, and the version for this package is not overridden.

Part of plone/Products.CMFPlone#3670
  • Loading branch information
mauritsvanrees committed Feb 6, 2023
1 parent a871075 commit 73ada88
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
5 changes: 4 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ Changes
3.0.0b2 (unreleased)
--------------------

- Nothing changed yet.
- Add ``use`` option to sources, and ``default-use`` to the settings.
``default-use`` is true by default. When false, the source is not
checked out, and the version for this package is not overridden.
[maurits]


3.0.0b1 (2022-11-21)
Expand Down
9 changes: 9 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ In the main sections the input and output files are defined.
somefancypackage
otherpackage
``default-use``:
True by default. When false, the source is not checked out,
and the version for this package is not overridden.

Additional, custom variables can be defined as ``key = value`` pair.
Those can be referenced in other values as ``${settings:key}`` and will be expanded there.

Expand Down Expand Up @@ -158,6 +162,11 @@ All other sections are defining the sources to be used.

Defaults to default mode configured in main section ``[settings]`` ``default-install-mode =`` value.

``use``:
True by default, unless ``default-use`` in the general settings is false.
When false, the source is not checked out,
and the version for this package is not overridden.

``submodules``
There are 3 different options

Expand Down
6 changes: 6 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,9 @@ universal = 1
# TODO: Remove current max-line-lengh ignore in follow-up and adopt black limit.
# max-line-length = 88
ignore = D001


[check-manifest]
ignore =
Makefile
mx.ini
14 changes: 13 additions & 1 deletion src/mxdev/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
from .hooks import Hook


def to_bool(value):
if not isinstance(value, str):
return bool(value)
if value.lower() in ("true", "on", "yes", "1"):
return True
return False


class Configuration:
settings: typing.Dict[str, str]
overrides: typing.Dict[str, str]
Expand Down Expand Up @@ -48,6 +56,7 @@ def __init__(
if mode not in ["direct", "skip"]:
raise ValueError("default-install-mode must be one of 'direct' or 'skip'")

default_use = to_bool(settings.get("default-use", True))
raw_overrides = settings.get("version-overrides", "").strip()
self.overrides = {}
for line in raw_overrides.split("\n"):
Expand Down Expand Up @@ -80,7 +89,10 @@ def is_ns_member(name):
self.hooks[name] = self._read_section(data, name)
continue
logger.debug(f"Section '{name}' belongs to package")
package = self.packages[name] = self._read_section(data, name)
package = self._read_section(data, name)
if not to_bool(package.get("use", default_use)):
continue
self.packages[name] = package
if settings.get("offline", False):
package.setdefault("offline", True)
# XXX: name should not be necessary in WorkingCopies
Expand Down

0 comments on commit 73ada88

Please sign in to comment.