Skip to content

Commit

Permalink
Redo uncompress_name
Browse files Browse the repository at this point in the history
  • Loading branch information
Obijuan committed Mar 12, 2024
1 parent e233a87 commit fee97a6
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 9 deletions.
26 changes: 24 additions & 2 deletions apio/managers/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ def get_download_url(self, package: dict, platform: str) -> str:
* Release
- tag_name
- compressed_name
- uncompressed_name
- package_name
- extension
- url_version
Expand All @@ -186,6 +187,18 @@ def get_download_url(self, package: dict, platform: str) -> str:
# -- Replace the '%P' parameter with the platform
self.compressed_name = compressed_name_version.replace("%P", platform)

# -- Get the uncompressed name. It is also a template with the
# -- same parameters: %V and %P
uncompressed_name = package["release"]["uncompressed_name"]

# -- Replace the '%V' parameter
uncompress_name_version = uncompressed_name.replace("%V", self.version)

# -- Replace the '%P' parameter
self.uncompressed_name = uncompress_name_version.replace(
"%P", platform
)

# -- Build the package tarball filename
# --- Ex. 'apio-examples-0.0.35.zip'
tarball = f"{self.compressed_name}.{self.extension}"
Expand Down Expand Up @@ -287,8 +300,17 @@ def _install_package(self, dlpath: Path):
# -- Remove it!
shutil.rmtree(package_dir)

# -- Uncompress it!!
self._unpack(dlpath, package_dir)
# -- If there is a folder name for uncompressing the tarball
# -- Ex. 'apio-examples-0.0.35'
if self.uncompressed_name:

# -- Uncompress it!!
# -- Ex. folder: /home/obijuan/.apio/packages
self._unpack(dlpath, self.packages_dir)

# -- Use the calculated destination file
else:
self._unpack(dlpath, package_dir)

# -- Remove the downloaded compress file
# -- Ex. remove '/home/obijuan/.apio/packages/
Expand Down
13 changes: 7 additions & 6 deletions apio/managers/unpacker.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,13 @@ def start(self) -> bool:
items = self._unpacker.get_items()

# -- Progress bar...
with click.progressbar(items,
length=len(items),
label=click.style("Unpacking..", fg="yellow"),
fill_char=click.style("█", fg="blue"),
empty_char=click.style("░", fg="blue"),
) as pbar:
with click.progressbar(
items,
length=len(items),
label=click.style("Unpacking..", fg="yellow"),
fill_char=click.style("█", fg="blue"),
empty_char=click.style("░", fg="blue"),
) as pbar:

# -- Go though all the files in the archive...
for item in pbar:
Expand Down
5 changes: 4 additions & 1 deletion apio/resources/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"release": {
"tag_name": "%V",
"compressed_name": "apio-examples-%V",
"uncompressed_name": "apio-examples-%V",
"package_name": "examples",
"extension": "zip",
"url_version": "https://github.com/FPGAwars/apio-examples/raw/master/VERSION"
Expand All @@ -22,6 +23,7 @@
"release": {
"tag_name": "v%V",
"compressed_name": "tools-oss-cad-suite-%P-%V",
"uncompressed_name": "",
"package_name": "tools-oss-cad-suite",
"extension": "tar.gz",
"url_version": "https://github.com/FPGAwars/tools-oss-cad-suite/raw/main/VERSION_DEV"
Expand All @@ -37,6 +39,7 @@
"release": {
"tag_name": "v%V",
"compressed_name": "tool-gtkwave-%P-%V",
"uncompressed_name": "",
"package_name": "tool-gtkwave",
"extension": "tar.gz",
"url_version": "https://github.com/FPGAwars/tool-gtkwave/raw/master/VERSION",
Expand All @@ -57,6 +60,7 @@
"release": {
"tag_name": "v%V",
"compressed_name": "tools-drivers-%P-%V",
"uncompressed_name": "",
"package_name": "tools-drivers",
"extension": "tar.gz",
"url_version": "https://github.com/FPGAwars/tools-drivers/raw/master/VERSION",
Expand All @@ -69,4 +73,3 @@
"description": "Drivers tools for Windows"
}
}

0 comments on commit fee97a6

Please sign in to comment.