Exemple #1
0
    def reset_interpreter_settings(self, upgrade_type):
        import json
        import interpreter_json_template
        interpreter_json_template = json.loads(
            interpreter_json_template.template)['interpreterSettings']
        config_data = self.get_interpreter_settings()
        interpreter_settings = config_data['interpreterSettings']

        if upgrade_type is not None:
            current_interpreters_keys = interpreter_settings.keys()
            for key in current_interpreters_keys:
                interpreter_data = interpreter_settings[key]
                if interpreter_data["name"] == "sh" and interpreter_data[
                        "group"] == "sh":
                    del interpreter_settings[key]

        for setting_key in interpreter_json_template.keys():
            if setting_key not in interpreter_settings:
                interpreter_settings[setting_key] = interpreter_json_template[
                    setting_key]
            else:
                templateGroups = interpreter_json_template[setting_key][
                    'interpreterGroup']
                groups = interpreter_settings[setting_key]['interpreterGroup']

                templateProperties = interpreter_json_template[setting_key][
                    'properties']
                properties = interpreter_settings[setting_key]['properties']

                templateOptions = interpreter_json_template[setting_key][
                    'option']
                options = interpreter_settings[setting_key]['option']

                # search for difference in groups from current interpreter and template interpreter
                # if any group exists in template but doesn't exist in current interpreter, it will be added
                group_names = []
                for group in groups:
                    group_names.append(group['name'])

                for template_group in templateGroups:
                    if not template_group['name'] in group_names:
                        groups.append(template_group)

                # search for difference in properties from current interpreter and template interpreter
                # if any property exists in template but doesn't exist in current interpreter, it will be added
                for template_property in templateProperties:
                    if not template_property in properties:
                        properties[template_property] = templateProperties[
                            template_property]

                # search for difference in options from current interpreter and template interpreter
                # if any option exists in template but doesn't exist in current interpreter, it will be added
                for template_option in templateOptions:
                    if not template_option in options:
                        options[template_option] = templateOptions[
                            template_option]

        self.set_interpreter_settings(config_data)
Exemple #2
0
  def reset_interpreter_settings(self):
    import json
    import interpreter_json_template
    interpreter_json_template = json.loads(interpreter_json_template.template)['interpreterSettings']
    config_data = self.get_interpreter_settings()
    interpreter_settings = config_data['interpreterSettings']

    for setting_key in interpreter_json_template.keys():
      if setting_key not in interpreter_settings:
        interpreter_settings[setting_key] = interpreter_json_template[
          setting_key]

    self.set_interpreter_settings(config_data)