Skip to content

Commit 7ad6049

Browse files
committed
250621.1
1 parent 542c530 commit 7ad6049

File tree

6 files changed

+26
-4
lines changed

6 files changed

+26
-4
lines changed
-36.3 KB
Binary file not shown.
36.5 KB
Binary file not shown.
Binary file not shown.

easycoder/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
from .ec_timestamp import *
1010
from .ec_value import *
1111

12-
__version__ = "250618.1"
12+
__version__ = "250621.1"

easycoder/ec_core.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,29 @@ def r_divide(self, command):
357357
self.putSymbolValue(target, value)
358358
return self.nextPC()
359359

360+
# download [binary] {url} to {path}
361+
def k_download(self, command):
362+
if self.nextIs('binary'):
363+
command['binary'] = True
364+
self.nextToken()
365+
else: command['binary'] = False
366+
command['url'] = self.getValue()
367+
self.skip('to')
368+
command['path'] = self.nextValue()
369+
self.add(command)
370+
return True
371+
372+
def r_download(self, command):
373+
binary = command['binary']
374+
url = self.getRuntimeValue(command['url'])
375+
path = self.getRuntimeValue(command['path'])
376+
mode = 'wb' if binary else 'w'
377+
response = requests.get(url, stream=True)
378+
with open(path, mode) as f:
379+
for chunk in response.iter_content(chunk_size=8192):
380+
if chunk: f.write(chunk)
381+
return self.nextPC()
382+
360383
# Dummy command for testing
361384
def k_dummy(self, command):
362385
self.add(command)

easycoder/ec_pyside.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -920,9 +920,8 @@ def r_show(self, command):
920920
message = data['message']
921921
if style == 'question':
922922
choice = QMessageBox.question(window, title, message)
923-
if choice == QMessageBox.Yes: result = 'Yes'
924-
else: result = 'No'
925-
if style == 'yesnocancel':
923+
result = 'Yes' if choice == QMessageBox.Yes else 'No'
924+
elif style == 'yesnocancel':
926925
choice = QMessageBox.question(
927926
window,
928927
title,

0 commit comments

Comments
 (0)