Commit 965e26ee authored by Emanuel Jacob's avatar Emanuel Jacob

build(gitlab#3): Add new Skeleton class

parent 2975bf3c
import os
import re
import urllib.request
NON_URL_SKELETON = re.compile('^[A-Za-z0-9_-]+$')
class Skeleton:
def __init__(self, skeleton):
self._skeleton = skeleton
if NON_URL_SKELETON.match(skeleton):
self._url = '{skeleton}.git'.format(skeleton=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 = '{skeleton}.git'.format(skeleton=skeleton)
self._url = skeleton
def __is_public_repository(self):
req = urllib.request.urlopen(self._url)
req_url = req.geturl()
if self._url == req_url or os.path.splitext(self._url)[0] == req_url :
if req.getcode() == 200 :
return True
except Exception:
return False
return False
def url(self):
return self._url
def skeleton(self):
return self._skeleton
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