From cef0bd3e62f2cf323a3c8dae46cbe7dcd3d37d8d Mon Sep 17 00:00:00 2001 From: Alex Koshelev Date: Sun, 22 Feb 2015 00:14:28 +0300 Subject: [PATCH] Mutable list of platforms for extensibility --- giturlparse/platforms/__init__.py | 6 ++---- giturlparse/result.py | 12 +++++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/giturlparse/platforms/__init__.py b/giturlparse/platforms/__init__.py index bb51ac5..42cb426 100644 --- a/giturlparse/platforms/__init__.py +++ b/giturlparse/platforms/__init__.py @@ -8,7 +8,7 @@ # Supported platforms -PLATFORMS = ( +PLATFORMS = [ # name -> Platform object ('github', GitHubPlatform()), ('bitbucket', BitbucketPlatform()), @@ -18,6 +18,4 @@ # Match url ('base', BasePlatform()), -) - -PLATFORMS_MAP = dict(PLATFORMS) +] diff --git a/giturlparse/result.py b/giturlparse/result.py index 4ecb243..6f6ae71 100644 --- a/giturlparse/result.py +++ b/giturlparse/result.py @@ -1,5 +1,5 @@ # Imports -from .platforms import PLATFORMS, PLATFORMS_MAP +from .platforms import PLATFORMS # Possible values to extract from a Git Url @@ -17,6 +17,12 @@ def __init__(self, parsed_info): for k, v in parsed_info.items(): setattr(self, k, v) + for name, platform in PLATFORMS: + if name == self.platform: + self._platform_obj = platform + + break + def _valid_attrs(self): return all([ getattr(self, attr, None) @@ -29,10 +35,6 @@ def valid(self): self._valid_attrs(), ]) - @property - def _platform_obj(self): - return PLATFORMS_MAP[self.platform] - ## # Alias properties ##