Skip to content

Commit

Permalink
Merge tag 'v0.6.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
wch committed Dec 22, 2023
2 parents a020af6 + 4cea3b6 commit 04a4889
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [0.6.1.1] - 2023-12-22

### Bug fixes

* Fixed #935: `shiny create` required the `requests` package, but it was not listed as a dependency. It now uses `urllib` instead, which is part of the Python standard library. (#940)


## [0.6.1] - 2023-12-18

### New features
Expand Down
21 changes: 15 additions & 6 deletions shiny/_template_utils.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
from __future__ import annotations

import os
import shutil
import sys
import tempfile
import zipfile
from pathlib import Path
from typing import Dict, List, Optional
from typing import Optional, cast
from urllib.error import URLError
from urllib.parse import urlparse
from urllib.request import urlopen

import questionary
import requests
from questionary import Choice

from ._custom_component_template_questions import (
Expand All @@ -33,7 +36,7 @@
back_choice: Choice = Choice(title=[("class:secondary", "← Back")], value="back")


def choice_from_dict(choice_dict: Dict[str, str]) -> List[Choice]:
def choice_from_dict(choice_dict: dict[str, str]) -> list[Choice]:
return [Choice(title=key, value=value) for key, value in choice_dict.items()]


Expand Down Expand Up @@ -75,10 +78,16 @@ def template_query(question_state: Optional[str] = None, mode: Optional[str] = N


def download_and_extract_zip(url: str, temp_dir: Path):
response = requests.get(url)
response.raise_for_status()
try:
response = urlopen(url)
data = cast(bytes, response.read())
except URLError as e:
# Note that HTTPError is a subclass of URLError
e.msg += f" for url: {url}" # pyright: ignore
raise e

zip_file_path = temp_dir / "repo.zip"
zip_file_path.write_bytes(response.content)
zip_file_path.write_bytes(data)
with zipfile.ZipFile(zip_file_path, "r") as zip_file:
zip_file.extractall(temp_dir)

Expand Down

0 comments on commit 04a4889

Please sign in to comment.