Skip to content

Commit e43c659

Browse files
author
jwiltse
committed
- Add to @Property for suffix and headers
- Satisfy linter by eliminating temporary
1 parent a3ae2a3 commit e43c659

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/portable_python/__init__.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -504,8 +504,7 @@ def cfg_url(self, version):
504504
if config_url := PPG.config.get_value("%s-url" % self.m_name):
505505
url_template = Template(config_url)
506506
url_subbed = url_template.substitute(version=version)
507-
url_expanded = os.path.expandvars(url_subbed)
508-
return url_expanded
507+
return os.path.expandvars(url_subbed)
509508

510509
def cfg_src_suffix(self):
511510
return PPG.config.get_value("%s-src-suffix" % self.m_name)
@@ -523,6 +522,16 @@ def url(self):
523522
"""Url of source tarball, if any"""
524523
return ""
525524

525+
@property
526+
def headers(self):
527+
"""Headers for connecting to source url, if any"""
528+
return self.cfg_http_headers()
529+
530+
@property
531+
def src_suffix(self):
532+
"""Suffix of src archive for when URL doesn't end in the file extension"""
533+
return self.cfg_src_suffix()
534+
526535
@property
527536
def version(self):
528537
"""Version to use"""
@@ -645,10 +654,10 @@ def compile(self):
645654
self._finalize()
646655
return
647656

648-
# Some src_url don't end in file extension, such as with redirects
657+
# Some URL's may not end in file extension, such as with redirects.
649658
# Github releases asset endpoint is this way .../releases/assets/48151
650-
if not self.url.endswith(".zip", ".tar.gz"):
651-
suffix = self.cfg_src_suffix() or ".tar.gz"
659+
if not self.url.endswith((".zip", ".tar.gz")):
660+
suffix = self.src_suffix or ".tar.gz"
652661
basename = f"{self.m_name}-{self.version}.{suffix}"
653662
else:
654663
# Split on '#' for urls that include a checksum, such as #sha256=... fragment

0 commit comments

Comments
 (0)