Skip to content

Mutable list of platforms for extensibility #8

New issue

Have a question about this project? No Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “No Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? No Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions giturlparse/platforms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


# Supported platforms
PLATFORMS = (
PLATFORMS = [
# name -> Platform object
('github', GitHubPlatform()),
('bitbucket', BitbucketPlatform()),
Expand All @@ -18,6 +18,4 @@

# Match url
('base', BasePlatform()),
)

PLATFORMS_MAP = dict(PLATFORMS)
]
12 changes: 7 additions & 5 deletions giturlparse/result.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Imports
from .platforms import PLATFORMS, PLATFORMS_MAP
from .platforms import PLATFORMS


# Possible values to extract from a Git Url
Expand All @@ -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)
Expand All @@ -29,10 +35,6 @@ def valid(self):
self._valid_attrs(),
])

@property
def _platform_obj(self):
return PLATFORMS_MAP[self.platform]

##
# Alias properties
##
Expand Down