Skip to content

Commit cef0bd3

Browse files
committed
Mutable list of platforms for extensibility
1 parent effa08f commit cef0bd3

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

giturlparse/platforms/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
# Supported platforms
11-
PLATFORMS = (
11+
PLATFORMS = [
1212
# name -> Platform object
1313
('github', GitHubPlatform()),
1414
('bitbucket', BitbucketPlatform()),
@@ -18,6 +18,4 @@
1818

1919
# Match url
2020
('base', BasePlatform()),
21-
)
22-
23-
PLATFORMS_MAP = dict(PLATFORMS)
21+
]

giturlparse/result.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Imports
2-
from .platforms import PLATFORMS, PLATFORMS_MAP
2+
from .platforms import PLATFORMS
33

44

55
# Possible values to extract from a Git Url
@@ -17,6 +17,12 @@ def __init__(self, parsed_info):
1717
for k, v in parsed_info.items():
1818
setattr(self, k, v)
1919

20+
for name, platform in PLATFORMS:
21+
if name == self.platform:
22+
self._platform_obj = platform
23+
24+
break
25+
2026
def _valid_attrs(self):
2127
return all([
2228
getattr(self, attr, None)
@@ -29,10 +35,6 @@ def valid(self):
2935
self._valid_attrs(),
3036
])
3137

32-
@property
33-
def _platform_obj(self):
34-
return PLATFORMS_MAP[self.platform]
35-
3638
##
3739
# Alias properties
3840
##

0 commit comments

Comments
 (0)