from scripts.old_single_meta_class_generator import CUBA_DATA_CONTAINER_EXCLUDE


class CUBAEnumGenerator(object):
    """Generator class for cuba.py enumeration.
    """

    def generate(self, cuba_dict, simphony_metadata_dict, output):
        """Generates the cuba file from the yaml-extracted dictionary
        of cuba and simphony_metadata files. Writes the generated code
        in the file object output
        """
        lines = [
            '# code auto-generated by the\n',
            '# simphony-metadata/scripts/generate.py script.\n',
            '# cuba.yml VERSION: {}\n'.format(cuba_dict['VERSION']),
            'from enum import Enum, unique\n',
            '\n',
            '\n',
            '@unique\n',
            'class CUBA(Enum):\n'
            ]
        template = '    {} = "{}"\n'

        all_keys = set(
            cuba_dict['CUBA_KEYS']) | set(simphony_metadata_dict['CUDS_KEYS'])

        for keyword in sorted(list(all_keys)):
            if keyword in CUBA_DATA_CONTAINER_EXCLUDE:
                continue
            lines.append(template.format(keyword, keyword))

        output.writelines(lines)

from scripts import utils


class CUBAEnumGenerator(object):
    """Generator class for cuba.py enumeration.
    """

    def generate(self, cuba_dict, simphony_metadata_dict, output):
        """Generates the cuba file from the yaml-extracted dictionary
        of cuba and simphony_metadata files. Writes the generated code
        in the file object output
        """
        lines = [
            '# code auto-generated by the\n',
            '# simphony-metadata/scripts/generate.py script.\n',
            '# cuba.yml VERSION: {}\n'.format(cuba_dict['VERSION']),
            'from enum import Enum, unique\n',
            '\n',
            '\n',
            '@unique\n',
            'class CUBA(Enum):\n'
            ]
        template = '    {} = "{}"\n'

        all_keys = set(
            cuba_dict['CUBA_KEYS']) | set(simphony_metadata_dict['CUDS_KEYS'])

        for keyword in sorted(list(all_keys)):
            lines.append(template.format(keyword,
                                         utils.with_cuba_prefix(keyword)))

        output.writelines(lines)

Put prefix to enum values. Removed old hack.
Put prefix to enum values. Removed old hack.

- from scripts.old_single_meta_class_generator import CUBA_DATA_CONTAINER_EXCLUDE
+ from scripts import utils
  
  
  class CUBAEnumGenerator(object):
      """Generator class for cuba.py enumeration.
      """
  
      def generate(self, cuba_dict, simphony_metadata_dict, output):
          """Generates the cuba file from the yaml-extracted dictionary
          of cuba and simphony_metadata files. Writes the generated code
          in the file object output
          """
          lines = [
              '# code auto-generated by the\n',
              '# simphony-metadata/scripts/generate.py script.\n',
              '# cuba.yml VERSION: {}\n'.format(cuba_dict['VERSION']),
              'from enum import Enum, unique\n',
              '\n',
              '\n',
              '@unique\n',
              'class CUBA(Enum):\n'
              ]
          template = '    {} = "{}"\n'
  
          all_keys = set(
              cuba_dict['CUBA_KEYS']) | set(simphony_metadata_dict['CUDS_KEYS'])
  
          for keyword in sorted(list(all_keys)):
-             if keyword in CUBA_DATA_CONTAINER_EXCLUDE:
-                 continue
-             lines.append(template.format(keyword, keyword))
+             lines.append(template.format(keyword,
+                                          utils.with_cuba_prefix(keyword)))
  
          output.writelines(lines)
  
Put prefix to enum values. Removed old hack.
## Code Before:
from scripts.old_single_meta_class_generator import CUBA_DATA_CONTAINER_EXCLUDE


class CUBAEnumGenerator(object):
    """Generator class for cuba.py enumeration.
    """

    def generate(self, cuba_dict, simphony_metadata_dict, output):
        """Generates the cuba file from the yaml-extracted dictionary
        of cuba and simphony_metadata files. Writes the generated code
        in the file object output
        """
        lines = [
            '# code auto-generated by the\n',
            '# simphony-metadata/scripts/generate.py script.\n',
            '# cuba.yml VERSION: {}\n'.format(cuba_dict['VERSION']),
            'from enum import Enum, unique\n',
            '\n',
            '\n',
            '@unique\n',
            'class CUBA(Enum):\n'
            ]
        template = '    {} = "{}"\n'

        all_keys = set(
            cuba_dict['CUBA_KEYS']) | set(simphony_metadata_dict['CUDS_KEYS'])

        for keyword in sorted(list(all_keys)):
            if keyword in CUBA_DATA_CONTAINER_EXCLUDE:
                continue
            lines.append(template.format(keyword, keyword))

        output.writelines(lines)

## Instruction:
Put prefix to enum values. Removed old hack.
## Code After:
from scripts import utils


class CUBAEnumGenerator(object):
    """Generator class for cuba.py enumeration.
    """

    def generate(self, cuba_dict, simphony_metadata_dict, output):
        """Generates the cuba file from the yaml-extracted dictionary
        of cuba and simphony_metadata files. Writes the generated code
        in the file object output
        """
        lines = [
            '# code auto-generated by the\n',
            '# simphony-metadata/scripts/generate.py script.\n',
            '# cuba.yml VERSION: {}\n'.format(cuba_dict['VERSION']),
            'from enum import Enum, unique\n',
            '\n',
            '\n',
            '@unique\n',
            'class CUBA(Enum):\n'
            ]
        template = '    {} = "{}"\n'

        all_keys = set(
            cuba_dict['CUBA_KEYS']) | set(simphony_metadata_dict['CUDS_KEYS'])

        for keyword in sorted(list(all_keys)):
            lines.append(template.format(keyword,
                                         utils.with_cuba_prefix(keyword)))

        output.writelines(lines)
