mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-13 07:47:14 +03:00
Change config.appversion() to return semantic_version.Version
As we're changing it to a function at this stage anyway, it might as well return this type, not a str.
This commit is contained in:
parent
b841d434e5
commit
5de4950fba
15
PLUGINS.md
15
PLUGINS.md
@ -180,26 +180,23 @@ import semantic_version
|
||||
from config import appversion
|
||||
|
||||
...
|
||||
# Up until 5.0.0-beta1 config.appversion is a string
|
||||
if isinstance(appversion, str):
|
||||
core_version = appversion # Up until 5.0.0-beta1 this is a string
|
||||
core_version = semantic_version.Version(appversion)
|
||||
|
||||
elif callable(appversion):
|
||||
core_version = appversion() # From 5.0.0-beta1 it's a function
|
||||
# From 5.0.0-beta1 it's a function, returning semantic_version.Version
|
||||
core_version = appversion()
|
||||
|
||||
else:
|
||||
core_version = '<UNKNOWN!>' # Paranoia
|
||||
# Yes, just blow up if config.appverison is neither str or callable
|
||||
|
||||
# Either way you now have a string
|
||||
logger.info(f'Core EDMC version: {core_version}')
|
||||
# The easiest way to compare is using semantic_version, so convert
|
||||
core_version_sv = semantic_version.Version(core_version)
|
||||
# And then compare like this
|
||||
if core_version_sv < semantic_version.Version('5.0.0-beta1'):
|
||||
if core_version < semantic_version.Version('5.0.0-beta1'):
|
||||
logger.info('EDMC core version is before 5.0.0-beta1')
|
||||
|
||||
else:
|
||||
logger.info('EDMC core version is at least 5.0.0-beta1')
|
||||
|
||||
```
|
||||
|
||||
---
|
||||
|
@ -126,7 +126,7 @@ def git_shorthash_from_head() -> str:
|
||||
return shorthash
|
||||
|
||||
|
||||
def appversion() -> str:
|
||||
def appversion() -> semantic_version.Version:
|
||||
"""
|
||||
Determine app version including git short hash if possible.
|
||||
|
||||
@ -145,10 +145,10 @@ def appversion() -> str:
|
||||
if shorthash is None:
|
||||
shorthash = 'UNKNOWN'
|
||||
|
||||
return f'{_static_appversion}+{shorthash}'
|
||||
return semantic_version.Version(f'{_static_appversion}+{shorthash}')
|
||||
|
||||
|
||||
def appversion_nobuild() -> str:
|
||||
def appversion_nobuild() -> semantic_version.Version:
|
||||
"""
|
||||
Determine app version without *any* build meta data.
|
||||
|
||||
@ -157,7 +157,7 @@ def appversion_nobuild() -> str:
|
||||
|
||||
:return: str - App version without any build meta data.
|
||||
"""
|
||||
return str(semantic_version.Version(appversion()).truncate('prerelease'))
|
||||
return appversion().truncate('prerelease')
|
||||
###########################################################################
|
||||
|
||||
|
||||
|
@ -93,26 +93,24 @@ def plugin_start3(plugin_dir: str) -> str:
|
||||
:param plugin_dir:
|
||||
:return: 'Pretty' name of this plugin.
|
||||
"""
|
||||
# Up until 5.0.0-beta1 config.appversion is a string
|
||||
if isinstance(appversion, str):
|
||||
core_version = appversion # Up until 5.0.0-beta1 this is a string
|
||||
core_version = semantic_version.Version(appversion)
|
||||
|
||||
elif callable(appversion):
|
||||
core_version = appversion() # From 5.0.0-beta1 it's a function
|
||||
# From 5.0.0-beta1 it's a function, returning semantic_version.Version
|
||||
core_version = appversion()
|
||||
|
||||
else:
|
||||
core_version = '<UNKNOWN!>' # Paranoia
|
||||
|
||||
# Either way you now have a string
|
||||
logger.info(f'Core EDMC version: {core_version}')
|
||||
# The easiest way to compare is using semantic_version, so convert
|
||||
core_version_sv = semantic_version.Version(core_version)
|
||||
# And then compare like this
|
||||
if core_version_sv < semantic_version.Version('5.0.0-beta1'):
|
||||
if core_version < semantic_version.Version('5.0.0-beta1'):
|
||||
logger.info('EDMC core version is before 5.0.0-beta1')
|
||||
|
||||
else:
|
||||
logger.info('EDMC core version is at least 5.0.0-beta1')
|
||||
|
||||
# Yes, just blow up if config.appverison is neither str or callable
|
||||
|
||||
logger.info(f'Folder is {plugin_dir}')
|
||||
this.plugin_test = PluginTest(plugin_dir)
|
||||
|
||||
|
@ -11,7 +11,7 @@ logger = EDMCLogging.get_main_logger()
|
||||
|
||||
DEFAULT_KILLSWITCH_URL = 'https://raw.githubusercontent.com/EDCD/EDMarketConnector/releases/killswitches.json'
|
||||
|
||||
_current_version: semantic_version.Version = semantic_version.Version(config.appversion_nobuild())
|
||||
_current_version: semantic_version.Version = config.appversion_nobuild()
|
||||
|
||||
|
||||
class KillSwitch(NamedTuple):
|
||||
|
@ -177,7 +177,7 @@ class Updater(object):
|
||||
)
|
||||
|
||||
# Look for any remaining version greater than appversion
|
||||
simple_spec = semantic_version.SimpleSpec('>' + appversion_nobuild())
|
||||
simple_spec = semantic_version.SimpleSpec(f'>{appversion_nobuild()}')
|
||||
newversion = simple_spec.select(items.keys())
|
||||
|
||||
if newversion:
|
||||
|
Loading…
x
Reference in New Issue
Block a user