Exemple #1
0
    def test03_read(self):
        # print("\n>>> Testing read")
        Configuration._set_configuration_filename("rspub_test.cfg")
        new_path = os.path.dirname(os.path.realpath(__file__))
        config1 = Configuration()
        config2 = Configuration()

        config1.set_plugin_dir(new_path)
        self.assertEquals(config1.plugin_dir(), new_path)
        config1.set_plugin_dir(None)
        self.assertEquals(config1.plugin_dir(), None)

        self.assertEquals(config2.plugin_dir(), None)

        Configuration.reset()
Exemple #2
0
    def __init__(self, config_name=None, resource_dir=config, metadata_dir=config, description_dir=config,
                 url_prefix=config, strategy=config, selector_file=config,
                 simple_select_file=config, select_mode=config, plugin_dir=config,
                 history_dir=config, max_items_in_list=config, zero_fill_filename=config, is_saving_pretty_xml=config,
                 is_saving_sitemaps=config, has_wellknown_at_root=config,
                 exp_scp_server=config, exp_scp_port=config, exp_scp_user=config,
                 exp_scp_document_root=config, zip_filename=config,
                 imp_scp_server=config, imp_scp_port=config, imp_scp_user=config,
                 imp_scp_remote_path=config, imp_scp_local_path=config,
                 **kwargs):
        """
        :samp:`Construct an instance of {RsParameters}`

        All ``parameters`` will get their value from

        1. the _named argument in `\*\*kwargs`. (this is for cloning instances of RsParameters). If not available:
        2. the named argument. If not available:
        3. the parameter as saved in the current configuration. If not available:
        4. the default configuration value.

        :param str config_name: the name of the configuration to read. If given, sets the current configuration.
        :param str resource_dir: ``parameter`` :func:`resource_dir`
        :param str metadata_dir: ``parameter`` :func:`metadata_dir`
        :param str description_dir: ``parameter`` :func:`description_dir`
        :param str url_prefix: ``parameter`` :func:`url_prefix`
        :param Union[Strategy, int, str] strategy: ``parameter`` :func:`strategy`
        :param str selector_file: ``parameter`` :func:`selector_file`
        :param str simple_select_file: ``parameter`` :func:`simple_select_file`
        :param SelectMode select_mode: ``parameter`` :func:`select_mode`
        :param str plugin_dir: ``parameter`` :func:`plugin_dir`
        :param str history_dir: ``parameter`` :func:`history_dir`
        :param int max_items_in_list: ``parameter`` :func:`max_items_in_list`
        :param int zero_fill_filename: ``parameter`` :func:`zero_fill_filename`
        :param bool is_saving_pretty_xml: ``parameter`` :func:`is_saving_pretty_xml`
        :param bool is_saving_sitemaps: ``parameter`` :func:`is_saving_sitemaps`
        :param bool has_wellknown_at_root: ``parameter`` :func:`has_wellknown_at_root`
        :param str exp_scp_server: ``parameter`` :func:`exp_scp_server`
        :param int exp_scp_port: ``parameter`` :func:`exp_scp_port`
        :param str exp_scp_user: ``parameter`` :func:`exp_scp_user`
        :param str exp_scp_document_root: ``parameter`` :func:`exp_scp_document_root`
        :param str zip_filename: ``parameter`` :func:`zip_filename`
        :param str imp_scp_server: ``parameter`` :func:`imp_scp_server`
        :param int imp_scp_port: ``parameter`` :func:`imp_scp_port`
        :param str imp_scp_user: ``parameter`` :func:`imp_scp_user`
        :param str imp_scp_remote_path: ``parameter`` :func:`imp_scp_remote_path`
        :param str imp_scp_local_path: ``parameter`` :func:`imp_scp_local_path`
        :param kwargs: named arguments, same as parameters, but preceded by _
        :raises: :exc:`ValueError` if a parameter is not valid or if the configuration with the given `config_name` is not found
        """
        kwargs.update({
            "resource_dir": resource_dir,
            "metadata_dir": metadata_dir,
            "description_dir": description_dir,
            "url_prefix": url_prefix,
            "strategy": strategy,
            "selector_file": selector_file,
            "simple_select_file": simple_select_file,
            "select_mode": select_mode,
            "plugin_dir": plugin_dir,
            "history_dir": history_dir,
            "max_items_in_list": max_items_in_list,
            "zero_fill_filename": zero_fill_filename,
            "is_saving_pretty_xml": is_saving_pretty_xml,
            "is_saving_sitemaps": is_saving_sitemaps,
            "has_wellknown_at_root": has_wellknown_at_root,
            "exp_scp_server": exp_scp_server,
            "exp_scp_port": exp_scp_port,
            "exp_scp_user": exp_scp_user,
            "exp_scp_document_root": exp_scp_document_root,
            "zip_filename": zip_filename,
            "imp_scp_server": imp_scp_server,
            "imp_scp_port": imp_scp_port,
            "imp_scp_user": imp_scp_user,
            "imp_scp_remote_path": imp_scp_remote_path,
            "imp_scp_local_path": imp_scp_local_path,
        })
        if config_name:
            cfg = Configurations.load_configuration(config_name)
        else:
            cfg = Configuration()

        self._resource_dir = None
        _resource_dir_ = self.__arg__("_resource_dir", cfg.resource_dir(), **kwargs)
        self.resource_dir = _resource_dir_

        self._metadata_dir = None
        _metadata_dir_ = self.__arg__("_metadata_dir", cfg.metadata_dir(), **kwargs)
        self.metadata_dir = _metadata_dir_

        self._description_dir = None
        _description_dir_ = self.__arg__("_description_dir", cfg.description_dir(), **kwargs)
        self.description_dir = _description_dir_

        self._url_prefix = None
        _url_prefix_ = self.__arg__("_url_prefix", cfg.url_prefix(), **kwargs)
        self.url_prefix = _url_prefix_

        self._strategy = None
        _strategy_ = self.__arg__("_strategy", cfg.strategy(), **kwargs)
        self.strategy = _strategy_

        self._selector_file = None
        _selector_file_ = self.__arg__("_selector_file", cfg.selector_file(), **kwargs)
        self.selector_file = _selector_file_

        self._simple_select_file = None
        _simple_select_file_ = self.__arg__("_simple_select_file", cfg.simple_select_file(), **kwargs)
        self.simple_select_file = _simple_select_file_

        self._select_mode = None
        _select_mode_ = self.__arg__("_select_mode", cfg.select_mode(), **kwargs)
        self.select_mode = _select_mode_

        self._plugin_dir = None
        _plugin_dir_ = self.__arg__("_plugin_dir", cfg.plugin_dir(), **kwargs)
        self.plugin_dir = _plugin_dir_

        self._history_dir = None
        _history_dir_ = self.__arg__("_history_dir", cfg.history_dir(), **kwargs)
        self.history_dir = _history_dir_

        self._max_items_in_list = None
        _max_items_in_list_ = self.__arg__("_max_items_in_list", cfg.max_items_in_list(), **kwargs)
        self.max_items_in_list = _max_items_in_list_

        self._zero_fill_filename = None
        _zero_fill_filename_ = self.__arg__("_zero_fill_filename", cfg.zero_fill_filename(), **kwargs)
        self.zero_fill_filename = _zero_fill_filename_

        self._is_saving_pretty_xml = self.__arg__("_is_saving_pretty_xml", cfg.is_saving_pretty_xml(), **kwargs)
        self._is_saving_sitemaps = self.__arg__("_is_saving_sitemaps", cfg.is_saving_sitemaps(), **kwargs)
        self._has_wellknown_at_root = self.__arg__("_has_wellknown_at_root", cfg.has_wellknown_at_root(), **kwargs)

        self._exp_scp_server = None
        _exp_scp_server_ = self.__arg__("_exp_scp_server", cfg.exp_scp_server(), **kwargs)
        self.exp_scp_server = _exp_scp_server_

        self._exp_scp_port = None
        _exp_scp_port_ = self.__arg__("_exp_scp_port", cfg.exp_scp_port(), **kwargs)
        self.exp_scp_port = _exp_scp_port_

        self._exp_scp_user = None
        _exp_scp_user_ = self.__arg__("_exp_scp_user", cfg.exp_scp_user(), **kwargs)
        self.exp_scp_user = _exp_scp_user_

        self._exp_scp_document_root = None
        _exp_scp_document_root_ = self.__arg__("_exp_scp_document_root", cfg.exp_scp_document_root(), **kwargs)
        self.exp_scp_document_root = _exp_scp_document_root_

        self._zip_filename = None
        _zip_filename_ = self.__arg__("_zip_filename", cfg.zip_filename(), **kwargs)
        self.zip_filename = _zip_filename_

        self._imp_scp_server = None
        _imp_scp_server_ = self.__arg__("_imp_scp_server", cfg.imp_scp_server(), **kwargs)
        self.imp_scp_server = _imp_scp_server_

        self._imp_scp_port = None
        _imp_scp_port_ = self.__arg__("_imp_scp_port", cfg.imp_scp_port(), **kwargs)
        self.imp_scp_port = _imp_scp_port_

        self._imp_scp_user = None
        _imp_scp_user_ = self.__arg__("_imp_scp_user", cfg.imp_scp_user(), **kwargs)
        self.imp_scp_user = _imp_scp_user_

        self._imp_scp_remote_path = None
        _imp_scp_remote_path_ = self.__arg__("_imp_scp_remote_path", cfg.imp_scp_remote_path(), **kwargs)
        self.imp_scp_remote_path = _imp_scp_remote_path_

        self._imp_scp_local_path = None
        _imp_scp_local_path_ = self.__arg__("_imp_scp_local_path", cfg.imp_scp_local_path(), **kwargs)
        self.imp_scp_local_path = _imp_scp_local_path_

        self.last_execution = self.__arg__("last_execution", cfg.last_excution(), **kwargs)
        self.last_strategy = self.__arg__("last_strategy", cfg.last_strategy(), **kwargs)
        self.last_sitemaps = self.__arg__("last_sitemaps", cfg.last_sitemaps(), **kwargs)