Skip to content

Commit e31b35d

Browse files
committed
Minor code update
1 parent a520633 commit e31b35d

1 file changed

Lines changed: 31 additions & 28 deletions

File tree

src/briefcase/platforms/web/static.py

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ def _trim_file(self, path, sentinel):
100100
for line in content:
101101
f.write(line)
102102

103-
def write_inserts(self, app: AppConfig, filename: Path, inserts: dict[str,dict[str, str]]):
103+
def write_inserts(
104+
self, app: AppConfig, filename: Path, inserts: dict[str, dict[str, str]]
105+
):
104106
"""Write inserts into an existing file.
105107
106108
This function looks for start and end markers in the named file and
@@ -224,38 +226,37 @@ def _process_wheel(
224226
with ZipFile(wheelfile) as wheel:
225227
for filename in wheel.namelist():
226228
# Skip directories and shallow paths
229+
if filename.endswith("/"):
230+
continue
227231
path = Path(filename)
228232
parts = path.parts
229-
if (len(parts) >= 3 and not (filename.endswith("/"))):
230-
# Handle inserts under deploy/inserts
231-
if parts[:2] == ("deploy", "inserts"):
232-
source = str(Path(*parts[2:]))
233-
234-
try:
235-
target, insert = source.split(":", 1)
236-
except ValueError:
237-
self.console.warning(
238-
f" {source}: missing ':<insert>'; skipping insert."
239-
)
240-
continue
241-
242-
self.console.info(
243-
f" {source}: Adding {insert} insert for {target}"
233+
if len(parts) < 3:
234+
continue
235+
# Handle inserts under deploy/inserts
236+
if parts[:2] == ("deploy", "inserts"):
237+
source = str(Path(*parts[2:]))
238+
239+
try:
240+
target, insert = source.split(":", 1)
241+
except ValueError:
242+
self.console.warning(
243+
f" {source}: missing ':<insert>'; skipping insert."
244244
)
245+
continue
245246

246-
try:
247-
text = wheel.read(filename).decode("utf-8")
248-
except UnicodeDecodeError as e:
249-
raise BriefcaseCommandError(
250-
f"{source}: insert must be UTF-8 encoded"
251-
) from e
247+
self.console.info(
248+
f" {source}: Adding {insert} insert for {target}"
249+
)
250+
251+
try:
252+
text = wheel.read(filename).decode("utf-8")
253+
except UnicodeDecodeError as e:
254+
raise BriefcaseCommandError(
255+
f"{source}: insert must be UTF-8 encoded"
256+
) from e
252257

253258
# Store raw contribution text per package
254-
pkg_map = (
255-
inserts
256-
.setdefault(target, {})
257-
.setdefault(insert, {})
258-
)
259+
pkg_map = inserts.setdefault(target, {}).setdefault(insert, {})
259260
# Append if the same package contributes multiple files for the same slot
260261
if package_key in pkg_map and pkg_map[package_key]:
261262
pkg_map[package_key] += "\n" + text
@@ -325,7 +326,9 @@ def extract_backend_config(self, wheels):
325326
"Only 'pyscript' backend is currently supported for web static builds."
326327
)
327328

328-
pyscript_path = config_filename.replace("config.toml", "pyscript.toml")
329+
pyscript_path = config_filename.replace(
330+
"config.toml", "pyscript.toml"
331+
)
329332
try:
330333
with wheel.open(pyscript_path) as pyscript_file:
331334
pyscript_config = tomllib.load(pyscript_file)

0 commit comments

Comments
 (0)