old_contents: #!/usr/bin/env python
  # -*- coding: utf-8 -*-
  
  # This file is part of PyBOSSA.
  #
  # PyBOSSA is free software: you can redistribute it and/or modify
  # it under the terms of the GNU Affero General Public License as published by
  # the Free Software Foundation, either version 3 of the License, or
  # (at your option) any later version.
  #
  # PyBOSSA 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 Affero General Public License for more details.
  #
  # You should have received a copy of the GNU Affero General Public License
  # along with PyBOSSA.  If not, see <http://www.gnu.org/licenses/>.
  """
  Helper functions for the pbs command line client.
  
  This module exports the following methods:
      * find_app_by_short_name: return the project by short_name.
      * check_api_errors: check for API errors returned by a PyBossa server.
      * format_error: format error message.
      * format_json_task: format a CSV row into JSON.
  """
  import json
  import logging
  from requests import exceptions
  
  __all__ = ['find_app_by_short_name', 'check_api_error',
             'format_error', 'format_json_task']
  
  
  def find_app_by_short_name(short_name, pbclient):
      """Return project by short_name."""
      try:
          response = pbclient.find_app(short_name=short_name)
          check_api_error(response)
          return response[0]
      except exceptions.ConnectionError:
          raise
      except:
          format_error("pbclient.find_app", response)
  
  
  def check_api_error(api_response):
      """Check if returned API response contains an error."""
      if type(api_response) == dict and (api_response.get('status') == 'failed'):
          raise exceptions.HTTPError
  
  
  def format_error(module, error):
      """Format the error for the given module."""
      logging.error(module)
      # Beautify JSON error
      if type(error) == list:
          print "Application not found"
      else:
          print json.dumps(error, sort_keys=True, indent=4, separators=(',', ': '))
      exit(1)
  
  
  def format_json_task(task_info):
      """Format task_info into JSON if applicable."""
      try:
          return json.loads(task_info)
      except:
          return task_info
  
new_contents: #!/usr/bin/env python
  # -*- coding: utf-8 -*-
  
  # This file is part of PyBOSSA.
  #
  # PyBOSSA is free software: you can redistribute it and/or modify
  # it under the terms of the GNU Affero General Public License as published by
  # the Free Software Foundation, either version 3 of the License, or
  # (at your option) any later version.
  #
  # PyBOSSA 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 Affero General Public License for more details.
  #
  # You should have received a copy of the GNU Affero General Public License
  # along with PyBOSSA.  If not, see <http://www.gnu.org/licenses/>.
  """
  Helper functions for the pbs command line client.
  
  This module exports the following methods:
      * find_app_by_short_name: return the project by short_name.
      * check_api_errors: check for API errors returned by a PyBossa server.
      * format_error: format error message.
      * format_json_task: format a CSV row into JSON.
  """
  import json
  import logging
  from requests import exceptions
  
  __all__ = ['find_app_by_short_name', 'check_api_error',
             'format_error', 'format_json_task']
  
  
  def find_app_by_short_name(short_name, pbclient):
      """Return project by short_name."""
      try:
          response = pbclient.find_app(short_name=short_name)
          check_api_error(response)
          return response[0]
      except exceptions.ConnectionError:
          raise
      except:
          format_error("pbclient.find_app", response)
  
  
  def check_api_error(api_response):
      """Check if returned API response contains an error."""
      if type(api_response) == dict and (api_response.get('status') == 'failed'):
          raise exceptions.HTTPError
  
  
  def format_error(module, error):
      """Format the error for the given module."""
      logging.error(module)
      # Beautify JSON error
      if type(error) == list:
          print "Project not found"
      else:
          print json.dumps(error, sort_keys=True, indent=4, separators=(',', ': '))
      exit(1)
  
  
  def format_json_task(task_info):
      """Format task_info into JSON if applicable."""
      try:
          return json.loads(task_info)
      except:
          return task_info
  
subject: Fix name.