Esempio n. 1
0
 def add_class_object(self, class_object):
     class_name = get_class_name(class_object)
     attr_name = self._get_new_name(class_name)
     if not self._already_existing_class_name(attr_name):
         resolved_instance = self._get_resolved_instance_of_class(
             class_object)
         self._resolve_names_and_add(resolved_instance, class_name)
Esempio n. 2
0
    def _get_class_adding_method(self, class_object):
        prefix = self._get_class_prefix(class_object)
        class_dict = dict(ib = self._add_ib_class, csv = self._add_csv_class, arctic = self._add_arctic_class,
                          mongo = self._add_mongo_class)

        method_to_add_with = class_dict.get(prefix, None)
        if method_to_add_with is None:
            error_msg = "Don't know how to handle object named %s" % get_class_name(class_object)
            self._raise_and_log_error(error_msg)

        return method_to_add_with
Esempio n. 3
0
    def _add_ib_class(self, class_object):
        log = self._get_specific_logger(class_object)
        try:
            resolved_instance = class_object(self.ib_conn, log = log)
        except Exception as e:
                class_name = get_class_name(class_object)
                msg = (
                        "Error %s couldn't evaluate %s(self.ib_conn, log = self.log.setup(component = %s)) This might be because (a) IB gateway not running, or (b) import is missing\
                         or (c) arguments don't follow pattern" % (str(e), class_name, class_name))
                self._raise_and_log_error(msg)

        return resolved_instance
Esempio n. 4
0
    def _add_arctic_class(self, class_object):
        log = self._get_specific_logger(class_object)
        try:
            resolved_instance = class_object(mongo_db=self.mongo_db, log = log)
        except Exception as e:
                class_name = get_class_name(class_object)
                msg = (
                        "Error %s couldn't evaluate %s(mongo_db=self.mongo_db, log = self.log.setup(component = %s)) \
                        This might be because import is missing\
                         or arguments don't follow pattern" % (str(e), class_name, class_name))
                self._raise_and_log_error(msg)

        return resolved_instance
Esempio n. 5
0
    def _get_csv_paths_for_class(self, class_object) -> str:
        class_name = get_class_name(class_object)
        csv_data_paths = self.csv_data_paths
        if csv_data_paths is arg_not_supplied:
            self.log.warn("No datapaths provided for .csv, will use defaults  (may break in production, should be fine in sim)")
            return arg_not_supplied

        datapath = csv_data_paths.get(class_name, "")
        if datapath == "":
            self.log.warn(
                "No key for %s in csv_data_paths, will use defaults (may break in production, should be fine in sim)" %
                class_name)
            return arg_not_supplied

        return datapath
Esempio n. 6
0
 def add_class_object(self, class_object):
     resolved_instance = self._get_resolved_instance_of_class(class_object)
     class_name = get_class_name(class_object)
     self._resolve_names_and_add(resolved_instance, class_name)
Esempio n. 7
0
    def _get_specific_logger(self, class_object):
        class_name = get_class_name(class_object)
        log = self.log.setup(component=class_name)

        return log
Esempio n. 8
0
    def _get_class_prefix(self, class_object) -> str:
        class_name = get_class_name(class_object)
        split_up_name = camel_case_split(class_name)
        prefix = split_up_name[0]

        return prefix