Skip to content

Commit

Permalink
Merge pull request SUSE#177 from SUSE/osc-data-dir
Browse files Browse the repository at this point in the history
Removed support for `.osc` data directory
  • Loading branch information
frozenIceage authored Aug 6, 2024
2 parents 47746d1 + 74f4d8d commit 1616298
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 103 deletions.
15 changes: 4 additions & 11 deletions osctiny/extensions/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from lxml.etree import tounicode, SubElement, Element
from lxml.objectify import fromstring

from ..utils.base import ExtensionBase, DataDir
from ..utils.base import ExtensionBase
from ..utils.errors import OscError


Expand Down Expand Up @@ -396,9 +396,6 @@ def checkout(self, project, package, destdir, rev=None, meta=False, expand=False
"""
Checkout all files and directories of package
.. note:: Only by using :py:meth:`checkout` the directory structure is
compatible with the ``osc`` command line tool!
:param project: name of project
:param package: name of package
:param destdir: target local directory
Expand All @@ -412,16 +409,16 @@ def checkout(self, project, package, destdir, rev=None, meta=False, expand=False
.. versionchanged:: 0.3.3
Added the parameter ``expand``
.. versionchanged:: {{ NEXT_RELEASE }}
The feature to create an ``osc`` compatible ``.osc/`` directory structure was removed.
"""
if not os.path.exists(destdir):
if not os.path.isdir(destdir):
os.makedirs(destdir)
else:
raise TypeError("Destination {} is a file!".format(destdir))

oscdir = DataDir(osc=self.osc, path=destdir, project=project,
package=package)

dirlist = self.get_files(project, package, rev=rev, meta=meta, expand=expand)
for entry in dirlist.findall("entry"):
self.download_file(
Expand All @@ -434,10 +431,6 @@ def checkout(self, project, package, destdir, rev=None, meta=False, expand=False
rev=rev,
expand=expand
)
os.link(
os.path.join(destdir, entry.get("name")),
os.path.join(oscdir.path, entry.get("name"))
)

def delete(self, project, package, force=False, comment=None):
"""
Expand Down
36 changes: 0 additions & 36 deletions osctiny/tests/test_datadir.py

This file was deleted.

56 changes: 0 additions & 56 deletions osctiny/utils/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
^^^^^^^^^^^^^^^^^^^
"""
# pylint: disable=too-few-public-methods,
import os
import typing
from pathlib import Path

from lxml.etree import tounicode


class ExtensionBase:
Expand All @@ -16,54 +11,3 @@ class ExtensionBase:
"""
def __init__(self, osc_obj: "Osc"):
self.osc = osc_obj


# pylint: disable=too-many-instance-attributes
class DataDir:
"""
Compatibility layer for the ``.osc`` data directory used by the ``osc`` CLI
"""
data_dir = ".osc"
osclib_version_string = "1.0"

# pylint: disable=too-many-arguments
def __init__(self, osc: "Osc", path: Path, project: str, package: typing.Optional[str] = None,
overwrite: bool = False):
self.osc = osc
self.path = os.path.join(path, self.data_dir)
self.project = project
self.package = package
self._apiurl = os.path.join(self.path, "_apiurl")
self._project = os.path.join(self.path, "_project")
self._package = os.path.join(self.path, "_package")
self._files = os.path.join(self.path, "_files")
self._osclib_version = os.path.join(self.path, "_osclib_version")
if not os.path.isdir(self.path):
os.makedirs(self.path)
overwrite = True

if overwrite:
self.write_dir_contents()

def write_dir_contents(self) -> None:
"""
Create files with default content in ``.osc`` sub-directory
"""
with open(self._apiurl, "w") as filehandle:
filehandle.write(self.osc.url + os.linesep)

with open(self._osclib_version, "w") as filehandle:
filehandle.write(self.osclib_version_string + os.linesep)

with open(self._project, "w") as filehandle:
filehandle.write(self.project + os.linesep)

if self.package:
with open(self._package, "w") as filehandle:
filehandle.write(self.package + os.linesep)

with open(self._files, "w") as filehandle:
filehandle.write(
tounicode(self.osc.packages.get_files(self.project,
self.package))
)

0 comments on commit 1616298

Please sign in to comment.