"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "snapcraft/internal/meta/package_repository.py" between
snapcraft-4.5.1.tar.gz and snapcraft-4.5.2.tar.gz

About: Snapcraft is a build and packaging tool that makes it easy to incorporate components from different sources and build technologies or solutions.

package_repository.py  (snapcraft-4.5.1):package_repository.py  (snapcraft-4.5.2)
skipping to change at line 23 skipping to change at line 23
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import abc import abc
import logging import logging
import re import re
from copy import deepcopy from copy import deepcopy
from typing import Any, Dict, List, Optional from typing import Any, Dict, List, Optional
from snapcraft.internal import repo
from . import errors from . import errors
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
class PackageRepository(abc.ABC): class PackageRepository(abc.ABC):
@abc.abstractmethod @abc.abstractmethod
def install(self) -> bool:
...
@abc.abstractmethod
def marshal(self) -> Dict[str, Any]: def marshal(self) -> Dict[str, Any]:
... ...
@classmethod @classmethod
def unmarshal(cls, data: Dict[str, str]) -> "PackageRepository": def unmarshal(cls, data: Dict[str, str]) -> "PackageRepository":
if not isinstance(data, dict): if not isinstance(data, dict):
raise errors.PackageRepositoryValidationError( raise errors.PackageRepositoryValidationError(
url=str(data), url=str(data),
brief=f"Invalid package repository object {data!r}.", brief=f"Invalid package repository object {data!r}.",
details="Package repository must be a valid dictionary object.", details="Package repository must be a valid dictionary object.",
skipping to change at line 79 skipping to change at line 73
return repositories return repositories
class PackageRepositoryAptPpa(PackageRepository): class PackageRepositoryAptPpa(PackageRepository):
def __init__(self, *, ppa: str) -> None: def __init__(self, *, ppa: str) -> None:
self.type = "apt" self.type = "apt"
self.ppa = ppa self.ppa = ppa
self.validate() self.validate()
def install(self) -> bool:
return repo.Ubuntu.install_ppa(ppa=self.ppa)
def marshal(self) -> Dict[str, Any]: def marshal(self) -> Dict[str, Any]:
data = dict(type="apt") data = dict(type="apt")
data["ppa"] = self.ppa data["ppa"] = self.ppa
return data return data
def validate(self) -> None: def validate(self) -> None:
if not self.ppa: if not self.ppa:
raise errors.PackageRepositoryValidationError( raise errors.PackageRepositoryValidationError(
url=self.ppa, url=self.ppa,
brief=f"Invalid PPA {self.ppa!r}.", brief=f"Invalid PPA {self.ppa!r}.",
skipping to change at line 170 skipping to change at line 161
self.name: str = re.sub(r"\W+", "_", url) self.name: str = re.sub(r"\W+", "_", url)
else: else:
self.name = name self.name = name
self.path = path self.path = path
self.suites = suites self.suites = suites
self.url = url self.url = url
self.validate() self.validate()
def install(self) -> bool:
"""Install repository configuration.
1) First check to see if package repo is implied path,
or "bare repository" config. This is indicated when no
path, components, or suites are indicated.
2) If path is specified, convert path to a suite entry,
ending with "/".
Relatedly, this assumes all of the error-checking has been
done already by validate(), but do some sanity checks here
anyways.
:returns: True if source configuration was changed.
"""
if not self.path and not self.components and not self.suites:
suites = ["/"]
elif self.path:
# Suites denoting exact path must end with '/'.
path = self.path
if not path.endswith("/"):
path += "/"
suites = [path]
elif self.suites:
suites = self.suites
if not self.components:
raise RuntimeError("no components with suites")
else:
raise RuntimeError("no suites or path")
return repo.Ubuntu.install_sources(
architectures=self.architectures,
components=self.components,
formats=self.formats,
name=self.name,
suites=suites,
url=self.url,
)
def marshal(self) -> Dict[str, Any]: def marshal(self) -> Dict[str, Any]:
data: Dict[str, Any] = {"type": "apt"} data: Dict[str, Any] = {"type": "apt"}
if self.architectures: if self.architectures:
data["architectures"] = self.architectures data["architectures"] = self.architectures
if self.components: if self.components:
data["components"] = self.components data["components"] = self.components
if self.formats: if self.formats:
 End of changes. 4 change blocks. 
48 lines changed or deleted 0 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)