Skip to content

Commit 1b4f7a4

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

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-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: 5 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,10 @@ 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+
2024
def _valid_attrs(self):
2125
return all([
2226
getattr(self, attr, None)
@@ -29,10 +33,6 @@ def valid(self):
2933
self._valid_attrs(),
3034
])
3135

32-
@property
33-
def _platform_obj(self):
34-
return PLATFORMS_MAP[self.platform]
35-
3636
##
3737
# Alias properties
3838
##

0 commit comments

Comments
 (0)