
import logging
import configparser

from nirikshak.common import plugins
from nirikshak.workers import base

LOG = logging.getLogger(__name__)


@plugins.register('ini')
class INIConfigValidatorWorker(base.Worker):

    @base.match_expected_output
    @base.validate(required=('file', 'section', 'key'))
    def work(self, **kwargs):
        k = kwargs['input']['args']
        config = configparser.ConfigParser()
        config.read(k['file'])
        value = None
        try:
            value = config.get(k['section'], k['key'])
            LOG.info("%s configuration option found in %s section",
                     k['section'], k['key'])
        except Exception:
            LOG.error("Not able to find %s configuration parameter in %s "
                      "section", k['key'], k['section'], exc_info=True)

        return value


import logging
try:
    import configparser
except ImportError:
    import ConfigParser as configparser

from nirikshak.common import plugins
from nirikshak.workers import base

LOG = logging.getLogger(__name__)


@plugins.register('ini')
class INIConfigValidatorWorker(base.Worker):

    @base.match_expected_output
    @base.validate(required=('file', 'section', 'key'))
    def work(self, **kwargs):
        k = kwargs['input']['args']
        config = configparser.ConfigParser()
        config.read(k['file'])
        value = None
        try:
            value = config.get(k['section'], k['key'])
            LOG.info("%s configuration option found in %s section",
                     k['section'], k['key'])
        except Exception:
            LOG.error("Not able to find %s configuration parameter in %s "
                      "section", k['key'], k['section'], exc_info=True)

        return value

Support for python3.5 has been added for configparser
Support for python3.5 has been added for configparser

  
  import logging
+ try:
- import configparser
+     import configparser
+ except ImportError:
+     import ConfigParser as configparser
  
  from nirikshak.common import plugins
  from nirikshak.workers import base
  
  LOG = logging.getLogger(__name__)
  
  
  @plugins.register('ini')
  class INIConfigValidatorWorker(base.Worker):
  
      @base.match_expected_output
      @base.validate(required=('file', 'section', 'key'))
      def work(self, **kwargs):
          k = kwargs['input']['args']
          config = configparser.ConfigParser()
          config.read(k['file'])
          value = None
          try:
              value = config.get(k['section'], k['key'])
              LOG.info("%s configuration option found in %s section",
                       k['section'], k['key'])
          except Exception:
              LOG.error("Not able to find %s configuration parameter in %s "
                        "section", k['key'], k['section'], exc_info=True)
  
          return value
  
Support for python3.5 has been added for configparser
## Code Before:

import logging
import configparser

from nirikshak.common import plugins
from nirikshak.workers import base

LOG = logging.getLogger(__name__)


@plugins.register('ini')
class INIConfigValidatorWorker(base.Worker):

    @base.match_expected_output
    @base.validate(required=('file', 'section', 'key'))
    def work(self, **kwargs):
        k = kwargs['input']['args']
        config = configparser.ConfigParser()
        config.read(k['file'])
        value = None
        try:
            value = config.get(k['section'], k['key'])
            LOG.info("%s configuration option found in %s section",
                     k['section'], k['key'])
        except Exception:
            LOG.error("Not able to find %s configuration parameter in %s "
                      "section", k['key'], k['section'], exc_info=True)

        return value

## Instruction:
Support for python3.5 has been added for configparser
## Code After:

import logging
try:
    import configparser
except ImportError:
    import ConfigParser as configparser

from nirikshak.common import plugins
from nirikshak.workers import base

LOG = logging.getLogger(__name__)


@plugins.register('ini')
class INIConfigValidatorWorker(base.Worker):

    @base.match_expected_output
    @base.validate(required=('file', 'section', 'key'))
    def work(self, **kwargs):
        k = kwargs['input']['args']
        config = configparser.ConfigParser()
        config.read(k['file'])
        value = None
        try:
            value = config.get(k['section'], k['key'])
            LOG.info("%s configuration option found in %s section",
                     k['section'], k['key'])
        except Exception:
            LOG.error("Not able to find %s configuration parameter in %s "
                      "section", k['key'], k['section'], exc_info=True)

        return value
