Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit65adc27

Browse files
committed
micropython/mip: Allow accessing index from local filesystem.
Just set the index to `file://relative/path` or `file:///absolute/path`.Signed-off-by: Dominik Heidler <dheidler@suse.de>
1 parent7337e08 commit65adc27

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

‎micropython/mip/mip/__init__.py‎

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,14 @@ def _rewrite_url(url, branch=None):
9191

9292

9393
def_download_file(url,dest):
94+
ifurl.startswith("file://"):
95+
print("Copying:",dest)
96+
src=url[7:]
97+
_ensure_path_exists(dest)
98+
withopen(src,"b")assf:
99+
withopen(dest,"wb")asf:
100+
_chunk(sf,f.write)
101+
returnTrue
94102
response=requests.get(url)
95103
try:
96104
ifresponse.status_code!=200:
@@ -108,15 +116,20 @@ def _download_file(url, dest):
108116

109117

110118
def_install_json(package_json_url,index,target,version,mpy):
111-
response=requests.get(_rewrite_url(package_json_url,version))
112-
try:
113-
ifresponse.status_code!=200:
114-
print("Package not found:",package_json_url)
115-
returnFalse
119+
ifpackage_json_url.startswith("file://"):
120+
importjson
116121

117-
package_json=response.json()
118-
finally:
119-
response.close()
122+
package_json=json.load(open(package_json_url[7:]))
123+
else:
124+
response=requests.get(_rewrite_url(package_json_url,version))
125+
try:
126+
ifresponse.status_code!=200:
127+
print("Package not found:",package_json_url)
128+
returnFalse
129+
130+
package_json=response.json()
131+
finally:
132+
response.close()
120133
fortarget_path,short_hashinpackage_json.get("hashes", ()):
121134
fs_target_path=target+"/"+target_path
122135
if_check_exists(fs_target_path,short_hash):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp