BMLN / job_scraper

0 stars 0 forks source link

TODO: better arg_parse #3

Open BMLN opened 1 month ago

BMLN commented 1 month ago

possible options to adjust main args:

BMLN commented 1 month ago

attach parser_addspider as class method? -> read https://stackoverflow.com/questions/13079299/dynamically-adding-methods-to-a-class

BMLN commented 1 month ago

(without arg_parse formatting:) use custom action since they get the full namespace, compare self.dependenyvalue with namespace[self.dependencykey], set/raise error accordingly.

in the fashion of:

class DependencyAction(Action):

    def __init__(self, dependenykey):
        self.dependencykey = dependencykey
        self.dependencyvalue = None

    def __call__(self, parser, namespace, values, option_string=None):
        if self.dependenyvalue != namespace[self.dependencykey]:
          self.dependencyvalue = namespace[self.dependencykey]
          <do_action>
        else:
          raise ArgumentTypeError