
import logging

from cotede.qc import ProfileQC
from . import fCNV
from .exceptions import CNVError


class fProfileQC(ProfileQC):
    """ Apply ProfileQC from CoTeDe straight from a file.
    """
    def __init__(self, inputfile, cfg=None, saveauxiliary=True, verbose=True,
            logger=None):
        """
        """
        self.logger = logging.getLogger(logger or 'seabird.qc.fProfileQC')
        self.name = 'fProfileQC'

        try:
            # Not the best way, but will work for now. I should pass
            #   the reference for the logger being used.
            profile = fCNV(inputfile, logger=None)
        except CNVError as e:
            #self.attributes['filename'] = basename(inputfile)
            logging.error(e.msg)
            raise

        super(fProfileQC, self).__init__(profile, cfg=cfg,
                saveauxiliary=saveauxiliary, verbose=verbose,
                logger=logger)


import logging
from os.path import basename

from cotede.qc import ProfileQC
from . import fCNV
from .exceptions import CNVError


class fProfileQC(ProfileQC):
    """ Apply ProfileQC from CoTeDe straight from a file.
    """
    def __init__(self, inputfile, cfg=None, saveauxiliary=True, verbose=True,
            logger=None):
        """
        """
        self.logger = logging.getLogger(logger or 'seabird.qc.fProfileQC')
        self.name = 'fProfileQC'

        try:
            # Not the best way, but will work for now. I should pass
            #   the reference for the logger being used.
            profile = fCNV(inputfile, logger=None)
        except CNVError as e:
            self.attributes['filename'] = basename(inputfile)
            logging.error(e.msg)
            raise

        super(fProfileQC, self).__init__(profile, cfg=cfg,
                saveauxiliary=saveauxiliary, verbose=verbose,
                logger=logger)

Add filename in attrs if fails to load it.
Add filename in attrs if fails to load it.

Filename in attrs helps to debug.

  
  import logging
+ from os.path import basename
  
  from cotede.qc import ProfileQC
  from . import fCNV
  from .exceptions import CNVError
  
  
  class fProfileQC(ProfileQC):
      """ Apply ProfileQC from CoTeDe straight from a file.
      """
      def __init__(self, inputfile, cfg=None, saveauxiliary=True, verbose=True,
              logger=None):
          """
          """
          self.logger = logging.getLogger(logger or 'seabird.qc.fProfileQC')
          self.name = 'fProfileQC'
  
          try:
              # Not the best way, but will work for now. I should pass
              #   the reference for the logger being used.
              profile = fCNV(inputfile, logger=None)
          except CNVError as e:
-             #self.attributes['filename'] = basename(inputfile)
+             self.attributes['filename'] = basename(inputfile)
              logging.error(e.msg)
              raise
  
          super(fProfileQC, self).__init__(profile, cfg=cfg,
                  saveauxiliary=saveauxiliary, verbose=verbose,
                  logger=logger)
  
Add filename in attrs if fails to load it.
## Code Before:

import logging

from cotede.qc import ProfileQC
from . import fCNV
from .exceptions import CNVError


class fProfileQC(ProfileQC):
    """ Apply ProfileQC from CoTeDe straight from a file.
    """
    def __init__(self, inputfile, cfg=None, saveauxiliary=True, verbose=True,
            logger=None):
        """
        """
        self.logger = logging.getLogger(logger or 'seabird.qc.fProfileQC')
        self.name = 'fProfileQC'

        try:
            # Not the best way, but will work for now. I should pass
            #   the reference for the logger being used.
            profile = fCNV(inputfile, logger=None)
        except CNVError as e:
            #self.attributes['filename'] = basename(inputfile)
            logging.error(e.msg)
            raise

        super(fProfileQC, self).__init__(profile, cfg=cfg,
                saveauxiliary=saveauxiliary, verbose=verbose,
                logger=logger)

## Instruction:
Add filename in attrs if fails to load it.
## Code After:

import logging
from os.path import basename

from cotede.qc import ProfileQC
from . import fCNV
from .exceptions import CNVError


class fProfileQC(ProfileQC):
    """ Apply ProfileQC from CoTeDe straight from a file.
    """
    def __init__(self, inputfile, cfg=None, saveauxiliary=True, verbose=True,
            logger=None):
        """
        """
        self.logger = logging.getLogger(logger or 'seabird.qc.fProfileQC')
        self.name = 'fProfileQC'

        try:
            # Not the best way, but will work for now. I should pass
            #   the reference for the logger being used.
            profile = fCNV(inputfile, logger=None)
        except CNVError as e:
            self.attributes['filename'] = basename(inputfile)
            logging.error(e.msg)
            raise

        super(fProfileQC, self).__init__(profile, cfg=cfg,
                saveauxiliary=saveauxiliary, verbose=verbose,
                logger=logger)
