Skip to content
Snippets Groups Projects
Commit 08008fdd authored by Sebastien Luttringer's avatar Sebastien Luttringer
Browse files

repository name checking moved inside reposiory class

parent 20259050
No related branches found
No related tags found
No related merge requests found
...@@ -28,6 +28,19 @@ class Repository(object): ...@@ -28,6 +28,19 @@ class Repository(object):
Repository class Repository class
''' '''
@staticmethod
def is_repository_name(name):
return re.match("^[-_\w]+$", name) is not None
@staticmethod
def check_repository_name(name):
'''
Raise exception is repository name is invalid
'''
if not Repository.is_repository_name(name):
raise Exception("Invalid repository name %s" % name)
return name
@classmethod @classmethod
def diff(cls, repo1, repo2): def diff(cls, repo1, repo2):
''' '''
...@@ -694,18 +707,9 @@ class RepositoryConfig(object): ...@@ -694,18 +707,9 @@ class RepositoryConfig(object):
Repository configuration container Repository configuration container
''' '''
@staticmethod
def check_repository_name(name):
'''
Raise exception is repository name is invalid
'''
if re.match("^[-_\w]+$", name) is None:
raise Exception("Invalid repository name %s" % name)
return name
def __init__(self, name, **kwargs): def __init__(self, name, **kwargs):
# set default value for arguments # set default value for arguments
self.name = self.check_repository_name(name) self.name = Repository.check_repository_name(name)
self.path = "" self.path = ""
self._offline = False self._offline = False
self._dbpath = None self._dbpath = None
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment