Skip to content

Commit

Permalink
Add PEP691 Format support
Browse files Browse the repository at this point in the history
- Move to 6.0.0.dev0 version
- Add config for setting formats to save to storage
  - `simple-format`
  - Valid options: ALL, HTML or JSON
- Move `mirror` simple generation functions to new simple module
- Add new tests to test_simple.py
  - Made tests be included with install by adding an __init__.py

Tests
- Add unittest coverage to SimpleAPI object
  - Test valid and invalid format requests
  - Test the JSON output for PEP691 compliance
    - Per pacakge
    - Global index
- Add check to Integration test to expect json index ...
  • Loading branch information
cooperlees committed Jul 27, 2022
1 parent 6c8243d commit 39fde3e
Show file tree
Hide file tree
Showing 27 changed files with 729 additions and 203 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# x.x.x (2022-MM-DD)

- Add PEP691 simple index support `PR #1154`
- Replace pyup with dependabot

# 5.2.0 (2022-05-02)
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ project_urls =
Source Code = https://github.com/pypa/bandersnatch
Change Log = https://github.com/pypa/bandersnatch/blob/master/CHANGES.md
url = https://github.com/pypa/bandersnatch/
version = 5.2.0
version = 6.0.0.dev0

[options]
install_requires =
Expand Down
6 changes: 3 additions & 3 deletions src/bandersnatch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ def version_str(self) -> str:


__version_info__ = _VersionInfo(
major=5,
minor=2,
major=6,
minor=0,
micro=0,
releaselevel="",
releaselevel="dev0",
serial=0, # Not currently in use with Bandersnatch versioning
)
__version__ = __version_info__.version_str
11 changes: 10 additions & 1 deletion src/bandersnatch/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from pathlib import Path
from typing import Any, Dict, List, NamedTuple, Optional, Type

from .simple import SimpleFormat, get_format_value

logger = logging.getLogger("bandersnatch")


Expand All @@ -22,6 +24,7 @@ class SetConfigValues(NamedTuple):
compare_method: str
download_mirror: str
download_mirror_no_fallback: bool
simple_format: SimpleFormat


class Singleton(type): # pragma: no cover
Expand Down Expand Up @@ -75,7 +78,6 @@ def load_configuration(self) -> None:
self.config.read(config_file)


# 11-15, 84-89, 98-99, 117-118, 124-126, 144-149
def validate_config_values( # noqa: C901
config: configparser.ConfigParser,
) -> SetConfigValues:
Expand Down Expand Up @@ -205,6 +207,12 @@ def validate_config_values( # noqa: C901
+ "is not set in config."
)

try:
simple_format = get_format_value(config.get("mirror", "simple-format"))
except configparser.NoOptionError:
logger.debug("Storing all Simple Formats by default ...")
simple_format = SimpleFormat.ALL

return SetConfigValues(
json_save,
root_uri,
Expand All @@ -217,4 +225,5 @@ def validate_config_values( # noqa: C901
compare_method,
download_mirror,
download_mirror_no_fallback,
simple_format,
)
4 changes: 4 additions & 0 deletions src/bandersnatch/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ workers = 3
; Recommended setting: the default of false for full pip/pypi compatibility.
hash-index = false

; Format for simple API to be stored in
; Since PEP691 we have HTML and JSON
simple-format = ALL

; Whether to stop a sync quickly after an error is found or whether to continue
; syncing but not marking the sync as successful. Value should be "true" or
; "false".
Expand Down
Loading

0 comments on commit 39fde3e

Please sign in to comment.