diff options
Diffstat (limited to 'mastodon')
-rw-r--r-- | mastodon/Mastodon.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index 896d87d..d98289d 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py | |||
@@ -470,6 +470,17 @@ class Mastodon: | |||
470 | if ratelimit_method not in ["throw", "wait", "pace"]: | 470 | if ratelimit_method not in ["throw", "wait", "pace"]: |
471 | raise MastodonIllegalArgumentError("Invalid ratelimit method.") | 471 | raise MastodonIllegalArgumentError("Invalid ratelimit method.") |
472 | 472 | ||
473 | def __normalize_version_string(self, version_string): | ||
474 | # Split off everything after the first space, to take care of Pleromalikes so that the parser doesn't get confused in case those have a + somewhere in their version | ||
475 | version_string = version_string.split(" ")[0] | ||
476 | try: | ||
477 | # Attempt to split at + and check if the part after parses as a version string, to account for hometown | ||
478 | parse_version_string(version_string.split("+")[1]) | ||
479 | return version_string.split("+")[1] | ||
480 | except: | ||
481 | # If this fails, assume that if there is a +, what is before that is the masto version (or that there is no +) | ||
482 | return version_string.split("+")[0] | ||
483 | |||
473 | def retrieve_mastodon_version(self): | 484 | def retrieve_mastodon_version(self): |
474 | """ | 485 | """ |
475 | Determine installed Mastodon version and set major, minor and patch (not including RC info) accordingly. | 486 | Determine installed Mastodon version and set major, minor and patch (not including RC info) accordingly. |
@@ -477,7 +488,7 @@ class Mastodon: | |||
477 | Returns the version string, possibly including rc info. | 488 | Returns the version string, possibly including rc info. |
478 | """ | 489 | """ |
479 | try: | 490 | try: |
480 | version_str = self.__instance()["version"].split('+')[0] | 491 | version_str = self.__normalize_version_string(self.__instance()["version"]) |
481 | self.version_check_worked = True | 492 | self.version_check_worked = True |
482 | except: | 493 | except: |
483 | # instance() was added in 1.1.0, so our best guess is 1.0.0. | 494 | # instance() was added in 1.1.0, so our best guess is 1.0.0. |