Redifine ParseKwargs to not import scraibe to early on
This commit is contained in:
@@ -6,8 +6,21 @@ The main Reason for this script is to allow the use of multiprocessing in the ap
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
from scraibe.misc import ParseKwargs
|
from argparse import ArgumentParser, Action
|
||||||
from argparse import ArgumentParser
|
|
||||||
|
class ParseKwargs(Action):
|
||||||
|
"""
|
||||||
|
Custom argparse action to parse keyword arguments. has to bne redifined here because of multiprocessing.
|
||||||
|
"""
|
||||||
|
def __call__(self, parser, namespace, values, option_string=None):
|
||||||
|
setattr(namespace, self.dest, dict())
|
||||||
|
for value in values:
|
||||||
|
key, value = value.split('=')
|
||||||
|
try:
|
||||||
|
value = eval(value)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
getattr(namespace, self.dest)[key] = value
|
||||||
|
|
||||||
parser = ArgumentParser()
|
parser = ArgumentParser()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user