[actions] implement 'flag … = skip' (#8960)
This commit is contained in:
@@ -10173,7 +10173,7 @@ Description
|
|||||||
|
|
||||||
| Expected syntax is ``<flag>[ = <value>]`` (e.g. ``post = stop``)
|
| Expected syntax is ``<flag>[ = <value>]`` (e.g. ``post = stop``)
|
||||||
| ``<flag>`` can be one of ``file``, ``post``, ``child``, ``download``
|
| ``<flag>`` can be one of ``file``, ``post``, ``child``, ``download``
|
||||||
| ``<value>`` can be one of ``stop``, ``abort``, ``terminate``, ``restart`` (default ``stop``)
|
| ``<value>`` can be one of ``stop``, ``abort``, ``terminate``, ``restart``, ``skip`` (default ``stop``)
|
||||||
``wait``:
|
``wait``:
|
||||||
| Sleep for a given Duration_ or
|
| Sleep for a given Duration_ or
|
||||||
| wait until Enter is pressed when no argument was given.
|
| wait until Enter is pressed when no argument was given.
|
||||||
|
|||||||
@@ -231,7 +231,13 @@ def action_flag(opts):
|
|||||||
r"(?i)(file|post|child|download)(?:\s*[= ]\s*(.+))?"
|
r"(?i)(file|post|child|download)(?:\s*[= ]\s*(.+))?"
|
||||||
).match(opts).groups()
|
).match(opts).groups()
|
||||||
flag = flag.upper()
|
flag = flag.upper()
|
||||||
value = "stop" if value is None else value.lower()
|
|
||||||
|
if value is None:
|
||||||
|
value = "stop"
|
||||||
|
elif value == "skip":
|
||||||
|
value = "stop" if flag == "DOWNLOAD" else False
|
||||||
|
else:
|
||||||
|
value = value.lower()
|
||||||
|
|
||||||
def _flag(args):
|
def _flag(args):
|
||||||
util.FLAGS.__dict__[flag] = value
|
util.FLAGS.__dict__[flag] = value
|
||||||
|
|||||||
@@ -385,10 +385,9 @@ class HttpDownloader(DownloaderBase):
|
|||||||
def receive(self, fp, content, bytes_total, bytes_start):
|
def receive(self, fp, content, bytes_total, bytes_start):
|
||||||
write = fp.write
|
write = fp.write
|
||||||
for data in content:
|
for data in content:
|
||||||
write(data)
|
|
||||||
|
|
||||||
if FLAGS.DOWNLOAD is not None:
|
if FLAGS.DOWNLOAD is not None:
|
||||||
FLAGS.process("DOWNLOAD")
|
return FLAGS.process("DOWNLOAD")
|
||||||
|
write(data)
|
||||||
|
|
||||||
def _receive_rate(self, fp, content, bytes_total, bytes_start):
|
def _receive_rate(self, fp, content, bytes_total, bytes_start):
|
||||||
rate = self.rate() if self.rate else None
|
rate = self.rate() if self.rate else None
|
||||||
@@ -399,14 +398,13 @@ class HttpDownloader(DownloaderBase):
|
|||||||
time_start = time.monotonic()
|
time_start = time.monotonic()
|
||||||
|
|
||||||
for data in content:
|
for data in content:
|
||||||
|
if FLAGS.DOWNLOAD is not None:
|
||||||
|
return FLAGS.process("DOWNLOAD")
|
||||||
time_elapsed = time.monotonic() - time_start
|
time_elapsed = time.monotonic() - time_start
|
||||||
bytes_downloaded += len(data)
|
bytes_downloaded += len(data)
|
||||||
|
|
||||||
write(data)
|
write(data)
|
||||||
|
|
||||||
if FLAGS.DOWNLOAD is not None:
|
|
||||||
FLAGS.process("DOWNLOAD")
|
|
||||||
|
|
||||||
if progress is not None:
|
if progress is not None:
|
||||||
if time_elapsed > progress:
|
if time_elapsed > progress:
|
||||||
self.out.progress(
|
self.out.progress(
|
||||||
|
|||||||
@@ -224,12 +224,18 @@ class Job():
|
|||||||
|
|
||||||
elif process is None:
|
elif process is None:
|
||||||
continue
|
continue
|
||||||
|
elif FLAGS.POST is False:
|
||||||
|
FLAGS.POST = process = None
|
||||||
|
continue
|
||||||
|
|
||||||
elif msg == Message.Url:
|
elif msg == Message.Url:
|
||||||
if self.metadata_url:
|
if self.metadata_url:
|
||||||
kwdict[self.metadata_url] = url
|
kwdict[self.metadata_url] = url
|
||||||
self.update_kwdict(kwdict)
|
self.update_kwdict(kwdict)
|
||||||
if self.pred_url(url, kwdict):
|
if self.pred_url(url, kwdict):
|
||||||
|
if FLAGS.FILE is False:
|
||||||
|
FLAGS.FILE = None
|
||||||
|
continue
|
||||||
self.handle_url(url, kwdict)
|
self.handle_url(url, kwdict)
|
||||||
if FLAGS.FILE is not None:
|
if FLAGS.FILE is not None:
|
||||||
FLAGS.process("FILE")
|
FLAGS.process("FILE")
|
||||||
@@ -239,6 +245,9 @@ class Job():
|
|||||||
if self.metadata_url:
|
if self.metadata_url:
|
||||||
kwdict[self.metadata_url] = url
|
kwdict[self.metadata_url] = url
|
||||||
if self.pred_queue(url, kwdict):
|
if self.pred_queue(url, kwdict):
|
||||||
|
if FLAGS.CHILD is False:
|
||||||
|
FLAGS.CHILD = None
|
||||||
|
continue
|
||||||
self.handle_queue(url, kwdict)
|
self.handle_queue(url, kwdict)
|
||||||
if FLAGS.CHILD is not None:
|
if FLAGS.CHILD is not None:
|
||||||
FLAGS.process("CHILD")
|
FLAGS.process("CHILD")
|
||||||
|
|||||||
@@ -677,6 +677,8 @@ class Flags():
|
|||||||
|
|
||||||
def process(self, flag):
|
def process(self, flag):
|
||||||
value = self.__dict__[flag]
|
value = self.__dict__[flag]
|
||||||
|
if value is False: # flag was set to "skip"
|
||||||
|
return "skip"
|
||||||
self.__dict__[flag] = None
|
self.__dict__[flag] = None
|
||||||
|
|
||||||
if value == "abort":
|
if value == "abort":
|
||||||
|
|||||||
Reference in New Issue
Block a user