Skip to content

Commit

Permalink
Set correct rank for versions
Browse files Browse the repository at this point in the history
  • Loading branch information
konstin committed Jan 1, 2017
1 parent 30c00ed commit 7cc3aef
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from cachecontrol.caches import FileCache
from cachecontrol.heuristics import LastModified
from pywikibot.data import sparql

from distutils.version import LooseVersion

class Settings:
do_update_wikidata = True
Expand Down Expand Up @@ -305,16 +305,27 @@ def update_wikidata(properties):
get_or_create_sources(repo, claim, github_repo_to_api(url_normalized), properties["retrieved"])

# Add all stable releases
latest_version = None # Mute warning
if len(properties["stable_release"]) > 0:
print("Adding all {} stable releases:".format(len(properties["stable_release"])))
latest_version = max(properties["stable_release"], key=lambda x: LooseVersion(x["version"]))
latest_version = latest_version["version"]
print(latest_version)

for release in properties["stable_release"]:
print(" - '{}'".format(release["version"]))
claim = get_or_create_claim(repo, item, Settings.properties["software version"], release["version"])

get_or_create_qualifiers(repo, claim, Settings.properties["publication date"], release["date"])
get_or_create_sources(repo, claim, github_repo_to_api_releases(url_normalized), properties["retrieved"])

# TODO give the latest release the preferred rank
# Give the latest release the preferred rank
if release["version"] == latest_version:
if claim.getRank() != 'preferred':
claim.changeRank('preferred')
else:
if claim.getRank() != 'normal':
claim.changeRank('normal')


def update_wikipedia(combined_properties):
Expand Down

0 comments on commit 7cc3aef

Please sign in to comment.