old_contents: # -*- coding: utf-8 -*-
  #===============================================================================
  # Filename      : services.py
  # Author        : Vincent BESANCON <besancon.vincent@gmail.com>
  #-------------------------------------------------------------------------------
  # This program is free software: you can redistribute it and/or modify
  # it under the terms of the GNU General Public License as published by
  # the Free Software Foundation, either version 3 of the License, or
  # (at your option) any later version.
  #
  # This program is distributed in the hope that it will be useful,
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  # GNU General Public License for more details.
  #
  # You should have received a copy of the GNU General Public License
  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
  #===============================================================================
  
  from monitoring.nagios.objects.definition import ObjectDefinition, ObjectGroup
  
  class Service(ObjectDefinition):
      """
      Represent a Host definition.
      """
      def __str__(self):
          if self.is_template():
              return self.name
          else:
              return self.service_description
  
  class Services(ObjectGroup):
      """
      Represent all hosts objects defined in the configuration.
      """
      pass
  
new_contents: # -*- coding: utf-8 -*-
  #===============================================================================
  # Filename      : services.py
  # Author        : Vincent BESANCON <besancon.vincent@gmail.com>
  #-------------------------------------------------------------------------------
  # This program is free software: you can redistribute it and/or modify
  # it under the terms of the GNU General Public License as published by
  # the Free Software Foundation, either version 3 of the License, or
  # (at your option) any later version.
  #
  # This program is distributed in the hope that it will be useful,
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  # GNU General Public License for more details.
  #
  # You should have received a copy of the GNU General Public License
  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
  #===============================================================================
  
  from monitoring.nagios.objects.definition import ObjectDefinition, ObjectGroup
  
  class Service(ObjectDefinition):
      """
      Represent a service definition.
      """
      def __str__(self):
          if hasattr(self.service_description):
              return self.service_description
          elif hasattr(self.name):
              return self.name
          else:
              raise AttributeError("Service has no name !")
  
  class Services(ObjectGroup):
      """
      Represent all services objects defined in the configuration.
      """
      pass
  
subject: use hasattr in __str__ for Service class.