mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
celaction: ditching agrparse
This commit is contained in:
parent
b0bf9a4a5c
commit
ad6fef12fa
1 changed files with 34 additions and 15 deletions
|
|
@ -1,5 +1,4 @@
|
||||||
import pyblish.api
|
import pyblish.api
|
||||||
import argparse
|
|
||||||
import sys
|
import sys
|
||||||
from pprint import pformat
|
from pprint import pformat
|
||||||
|
|
||||||
|
|
@ -11,20 +10,40 @@ class CollectCelactionCliKwargs(pyblish.api.Collector):
|
||||||
order = pyblish.api.Collector.order - 0.1
|
order = pyblish.api.Collector.order - 0.1
|
||||||
|
|
||||||
def process(self, context):
|
def process(self, context):
|
||||||
parser = argparse.ArgumentParser(prog="celaction")
|
args = list(sys.argv[1:])
|
||||||
parser.add_argument("--currentFile",
|
self.log.info(str(args))
|
||||||
help="Pass file to Context as `currentFile`")
|
missing_kwargs = []
|
||||||
parser.add_argument("--chunk",
|
passing_kwargs = {}
|
||||||
help=("Render chanks on farm"))
|
for key in (
|
||||||
parser.add_argument("--frameStart",
|
"chunk",
|
||||||
help=("Start of frame range"))
|
"frameStart",
|
||||||
parser.add_argument("--frameEnd",
|
"frameEnd",
|
||||||
help=("End of frame range"))
|
"resolutionWidth",
|
||||||
parser.add_argument("--resolutionWidth",
|
"resolutionHeight",
|
||||||
help=("Width of resolution"))
|
"currentFile",
|
||||||
parser.add_argument("--resolutionHeight",
|
):
|
||||||
help=("Height of resolution"))
|
arg_key = f"--{key}"
|
||||||
passing_kwargs = parser.parse_args(sys.argv[1:]).__dict__
|
if arg_key not in args:
|
||||||
|
missing_kwargs.append(key)
|
||||||
|
continue
|
||||||
|
arg_idx = args.index(arg_key)
|
||||||
|
args.pop(arg_idx)
|
||||||
|
if key != "currentFile":
|
||||||
|
value = args.pop(arg_idx)
|
||||||
|
else:
|
||||||
|
path_parts = []
|
||||||
|
while arg_idx < len(args):
|
||||||
|
path_parts.append(args.pop(arg_idx))
|
||||||
|
value = " ".join(path_parts).strip('"')
|
||||||
|
|
||||||
|
passing_kwargs[key] = value
|
||||||
|
|
||||||
|
if missing_kwargs:
|
||||||
|
raise RuntimeError("Missing arguments {}".format(
|
||||||
|
", ".join(
|
||||||
|
[f'"{key}"' for key in missing_kwargs]
|
||||||
|
)
|
||||||
|
))
|
||||||
|
|
||||||
self.log.info("Storing kwargs ...")
|
self.log.info("Storing kwargs ...")
|
||||||
self.log.debug("_ passing_kwargs: {}".format(pformat(passing_kwargs)))
|
self.log.debug("_ passing_kwargs: {}".format(pformat(passing_kwargs)))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue