Added parse_arrow for parsing source lists in arrow notation

parent da74d44c
Pipeline #63137670 (#66) passed with stages
in 2 minutes and 17 seconds
......@@ -6,7 +6,6 @@ from typing import AbstractSet, List
import os
import sys
import shutil
from urllib.parse import urlparse
from pathlib import Path
from distutils.dir_util import copy_tree
from portmod.util import patch_dir
......@@ -17,11 +16,11 @@ from portmod.repo.use import get_use, use_reduce, check_required_use
from portmod.repo.manifest import get_manifest
from portmod.repo.util import get_hash
from portmod.repo.metadata import get_global_use, get_mod_metadata, license_exists
from portmod.repo.download import Source
from ..repo.download import parse_arrow
from portmod.log import err
from portmod.colour import colour
from colorama import Fore
from ..pybuild_interface import Pybuild
from ..pybuild_interface import Pybuild, Source
class InstallDir:
......@@ -184,20 +183,6 @@ class Pybuild1(Pybuild):
def is_valid(x):
return x in self.IUSE_EFFECTIVE
def group(sourcelist):
result = []
arrow = False
for value in sourcelist:
if arrow:
result[-1].name = value
arrow = False
elif value == "->":
arrow = True
else:
url = urlparse(value)
result.append(Source(value, os.path.basename(url.path)))
return result
sourcestr = self.SRC_URI
sources = use_reduce(
sourcestr,
......@@ -209,7 +194,7 @@ class Pybuild1(Pybuild):
matchnone=matchnone,
matchall=matchall,
)
grouped = group(sources)
grouped = parse_arrow(sources)
manifest = self.get_manifest()
......
# Copyright 2019 Portmod Authors
# Distributed under the terms of the GNU General Public License v3
from typing import List, Optional
from typing import Iterable, List, Optional
import urllib
import urllib.request
......@@ -31,6 +31,25 @@ def clobber_spaces():
)
def parse_arrow(sourcelist: Iterable[str]) -> List[Source]:
"""
Turns a list of urls using arrow notation into a list of
Source objects
"""
result = []
arrow = False
for value in sourcelist:
if arrow:
result[-1].name = value
arrow = False
elif value == "->":
arrow = True
else:
url = urllib.parse.urlparse(value)
result.append(Source(value, os.path.basename(url.path)))
return result
def get_filename(basename: str) -> str:
"""
Returns the location of the local cached version of the source file
......
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