Commit 33b5fee8 authored by David Danier's avatar David Danier

Cleanup of URL check and fitting changes into normal b5 coding style

parent ca36c09b
......@@ -5,27 +5,29 @@ from urllib.error import URLError
class Skeleton:
NON_URL_SKELETON = re.compile('^[A-Za-z0-9_-]+$')
def __init__(self, skeleton):
self._skeleton = skeleton
def __init__(self, skeleton_identified):
self._skeleton_identified = skeleton_identified
def get_url(self):
if not self._url:
non_url_skeleton = re.compile('^[A-Za-z0-9_-]+$')
if non_url_skeleton.match(self._skeleton):
self._url = '{skeleton}.git'.format(skeleton=self._skeleton)
'''if it's not a public repository, clone using ssh in order to allow ssh key file auth'''
if not self.__is_public_repository(self._url):
self._url = '{skeleton}.git'.format(skeleton=self._skeleton)
self._url = self._skeleton
return self._url
return self._url
except AttributeError:
skeleton_url = self._skeleton_identified
if self.NON_URL_SKELETON.match(skeleton_url):
skeleton_url = '{skeleton}.git'.format(skeleton=self._skeleton_identified)
# If it's not a public repository, clone using ssh in order to allow ssh key file auth
if not self.__is_public_repository(skeleton_url):
skeleton_url = '{skeleton}.git'.format(skeleton=self._skeleton_identified)
self._url = skeleton_url
return self._url
def __is_public_repository(self, url):
request = urllib.request.urlopen(self._url)
request = urllib.request.urlopen(url)
request_url = request.geturl()
if self._url == request_url or os.path.splitext(self._url)[0] == request_url:
if url == request_url or url.rsplit('.', 1)[0] == request_url:
if request.getcode() == 200:
return True
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment