def __init__(self, cfg_config): super(CfgComponent, self).__init__() self.log = Logging.get_object_logger(self) self.config = cfg_config if self.config.yaml: cfg_dir = self.find_config_directory( self.config.yaml, self.config.custom_cfg_dirs + [self.config.cfg_dir]) self.log.debug("Using config directory: %s" % cfg_dir) with open(os.path.join(cfg_dir, self.config.yaml)) as f: cfg = yaml.load(f, Loader=yaml.FullLoader) if self.config.j2_config_template is None: self.cfg = cfg else: jinja2_env = jinja2.Environment( loader=jinja2.FileSystemLoader(cfg_dir)) template = jinja2_env.get_template( self.config.j2_config_template) self.cfg = yaml.load(template.render(**cfg)) self.cfg[CfgComponent.CONFIG_FILE_PATH] = os.path.join( cfg_dir, self.config.yaml) else: self.cfg = yaml.load("") print(dir(self.cfg))
def __init__(self, webdriver, root_uri=None): assert isinstance( webdriver, WebDriver ), 'webdriver={} needs to be selenium Webdriver object'.format( webdriver) super(CSFPageObject, self).__init__(webdriver=webdriver, root_uri=root_uri) self.log = Logging.get_object_logger(self)
def __init__(self, context): """ context - provided by radish: - each feature has its own context - for each scenario and its steps context is common however different than feature context - feature context may be retrieved in scenario using scenario.parent.context code - feature context may be retrieved in step using step.parent.parent.context code """ super(StepConfig, self).__init__() self.context = context self.cfg = context.cfg setattr(self.context, 'stc_%s' % self.__class__.__name__, self) self.log = Logging.get_object_logger(self) self.test_data = TestDataBase(self.cfg)
def dot_to_dict_notation(cls, dot_notation): """ replace dot_notation to nested_python_dict_notation so that It can be later used in nested dictionary value evaluation Input: '''a.b[2].c.d['1'].e''' Output: '''['a']['b'][2]['c']['d']['1']['e']''' NOTE the list indices and 'numbers_as_keys' are kept :param dot_notation: :return: """ # https://regex101.com/r/5BhJeE/2 # https://regex101.com/r/5BhJeE/1/codegen?language=python regex = r"(?:[\.'\[])*([_a-z][_a-z0-9- ]*)(?:[\.\]'])*" subst = "['\\1']" output = re.sub(regex, subst, dot_notation, 0, re.IGNORECASE | re.DOTALL) log = Logging.get_object_logger(cls) log.debug("transform: {dot_notation} ==> {output}".format(**locals())) return output
def __init__(self) -> None: super().__init__() self.log = Logging.get_object_logger(self)
def __init__(self): super(RequestsBaseSteps, self).__init__() self.log = Logging.get_object_logger(self) self.tools = RequestsBaseTools()
def __init__(self, template): super(TemplateForNestedDict, self).__init__(template) self.log = Logging.get_object_logger(self)
def __init__(self, cfg) -> None: super().__init__() self.data = {'cfg': cfg, 'generate': {}} self.log = Logging.get_object_logger(self)
def __init__(self): super(Config, self).__init__() self.log = Logging.get_object_logger(self)