Skip to content

Commit

Permalink
Add a plugin logo and improve parsing of the CHANGELOG.md file (GeoNo…
Browse files Browse the repository at this point in the history
  • Loading branch information
Ricardo Garcia Silva authored Jan 14, 2022
1 parent 3c49f88 commit d745a2a
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 16 deletions.
37 changes: 24 additions & 13 deletions pluginadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,7 @@ def _get_metadata() -> typing.Dict:
"description": poetry_conf["description"],
"version": poetry_conf["version"],
"tags": ", ".join(metadata.get("tags", [])),
"changelog": _parse_changelog(
_read_file("CHANGELOG.md"), poetry_conf["version"]
),
"changelog": _parse_changelog(),
}
)
return metadata
Expand All @@ -318,16 +316,29 @@ def _parse_pyproject():
return toml.load(fh)


def _parse_changelog(changelog: str, version: str) -> str:
usable_fragment = changelog.partition(f"[{version}]")[-1].partition("[unreleased]")[
0
]
if usable_fragment != "":
no_square_brackets = re.sub(r"(\[(\d+.\d+.\d+)\])", "\g<2>", usable_fragment)
result = f"{version} {no_square_brackets}".replace("# ", "").replace("#", "")
else:
result = ""
return result
def _parse_changelog() -> str:
contents = _read_file("CHANGELOG.md")
usable_fragment = contents.rpartition(f"## [Unreleased]")[-1].partition(
"[unreleased]"
)[0]
release_parts = usable_fragment.split("\n## ")
result = []
current_change_type = "unreleased"
for release_fragment in release_parts:
lines: typing.List[str] = [li for li in release_fragment.splitlines()]
for line in lines:
if line.startswith("["):
release, release_date = line.partition(" - ")[::2]
release = release.strip("[]")
result.append(f"\n{release} ({release_date})")
elif line.startswith("### "):
current_change_type = line.strip("### ").strip().lower()
elif line.startswith("-"):
message = line.strip("- ")
result.append(f"- ({current_change_type}) {message}")
else:
pass
return "\n".join(result)


def _read_file(relative_path: str):
Expand Down
9 changes: 6 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.poetry]
name = "qgis_geonode"
version = "1.0.0-dev"
description = "A QGIS plugin for integrating with GeoNode"
description = "A QGIS plugin for integrating with modern GeoNode"
authors = ["Kartoza <[email protected]>"]
license = "GPL-3.0-or-later"

Expand Down Expand Up @@ -37,7 +37,7 @@ exclude = """\
[tool.qgis-plugin.metadata]
name = "QGIS GeoNode"
qgisMinimumVersion = "3.18"
icon = "mIconGeonode.svg"
icon = "plugin-logo.png"
experimental = "True"
deprecated = "False"
homepage = "https://kartoza.github.io/qgis_geonode"
Expand All @@ -52,7 +52,10 @@ tags = [
category = "plugins"
hasProcessingProvider = "no"
about = """\
This plugin adds GeoNode client functionality to QGIS - Search, load and manage GeoNode resources from inside QGIS\
This plugin adds GeoNode client functionality to QGIS - Search, load and manage GeoNode resources from inside QGIS.\
It is actively maintained and aims to keep up to date with changes in the GeoNode API. Check the plugin website for \
more detail.\
"""
# changelog: dynamically pulled from the README.md file
# description: dynamically pulled from the tool.poetry.description section
Expand Down
Binary file added resources/plugin-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions resources/resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@
<qresource prefix="/plugins/qgis_geonode" >
<file>icon_wms.svg</file>
</qresource>
<qresource prefix="/plugins/qgis_geonode" >
<file>plugin-logo.png</file>
</qresource>

</RCC>

0 comments on commit d745a2a

Please sign in to comment.