[entropy.tools] introduce expand_plain_database_mirror()
This follows the previously introduced expand_plain_package_mirror() method. Now both methods can expand repository and package mirror URLs read from Entropy repository configuration files adding product, arch and branch information.
This commit is contained in:
@@ -1373,9 +1373,11 @@ class SystemSettings(Singleton, EntropyPluginStore):
|
||||
raise AttributeError("invalid repository database URL")
|
||||
mydata['plain_database'] = repodatabase
|
||||
|
||||
mydata['database'] = repodatabase + os.path.sep + product + \
|
||||
os.path.sep + reponame + "/database/" + etpConst['currentarch'] + \
|
||||
os.path.sep + branch
|
||||
database = entropy.tools.expand_plain_database_mirror(
|
||||
repodatabase, product, reponame, branch)
|
||||
if database is None:
|
||||
database = const_convert_to_unicode("")
|
||||
mydata['database'] = database
|
||||
|
||||
mydata['notice_board'] = mydata['database'] + os.path.sep + \
|
||||
etpConst['rss-notice-board']
|
||||
@@ -1419,9 +1421,6 @@ class SystemSettings(Singleton, EntropyPluginStore):
|
||||
repopackages = [x.strip() for x in repopackages.split() if x.strip()]
|
||||
|
||||
for repo_package in repopackages:
|
||||
if not entropy.tools.is_valid_uri(repo_package):
|
||||
# filter out
|
||||
continue
|
||||
new_repo_package = entropy.tools.expand_plain_package_mirror(
|
||||
repo_package, product, reponame)
|
||||
if new_repo_package is None:
|
||||
|
||||
@@ -2490,16 +2490,34 @@ def expand_plain_package_mirror(mirror, product, repository_id):
|
||||
@type product: string
|
||||
@param repository_id: repository identifier
|
||||
@type repository_id: string
|
||||
@return: expanded URL or None, if mirror url is invalid
|
||||
@return: expanded URL or None if invalid
|
||||
@rtype: string or None
|
||||
"""
|
||||
if not is_valid_uri(mirror):
|
||||
return None
|
||||
try:
|
||||
mirror = str(mirror)
|
||||
except (UnicodeDecodeError, UnicodeEncodeError,):
|
||||
sep = const_convert_to_unicode("/")
|
||||
return mirror + sep + product + sep + repository_id
|
||||
|
||||
def expand_plain_database_mirror(mirror, product, repository_id, branch):
|
||||
"""
|
||||
Expand plain database mirror URL adding product, repository identifier
|
||||
and branch data to it.
|
||||
|
||||
@param mirror: mirror URL
|
||||
@type mirror: string
|
||||
@param product: Entropy repository product
|
||||
@type product: string
|
||||
@param repository_id: repository identifier
|
||||
@type repository_id: string
|
||||
@return: expanded URL or None if invalid
|
||||
@rtype: string or None
|
||||
"""
|
||||
if not is_valid_uri(mirror):
|
||||
return None
|
||||
return mirror + os.path.sep + product + os.path.sep + repository_id
|
||||
sep = const_convert_to_unicode("/")
|
||||
return mirror + sep + product + sep + repository_id + sep + \
|
||||
etpConst['databaserelativepath_basedir'] + sep + \
|
||||
etpConst['currentarch'] + sep + branch
|
||||
|
||||
_repo_re = re.compile("^(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])$", re.IGNORECASE)
|
||||
def validate_repository_id(repository_id):
|
||||
|
||||
Reference in New Issue
Block a user