import amqp
from contextlib import closing


def get_message(queue):
    """ Get the first message from a queue.

    The first message from a queue is retrieved. If there is no such message, the function exits quietly. 

    :param queue: The name of the queue from which to get the message.

    Usage::

    >>> from utils import get_message
    >>> message = get_message('queue')

    """
    with closing(amqp.Connection()) as connection:
        channel = connection.channel()
        return channel.basic_get(queue=queue)

import amqp
from contextlib import closing


def __get_channel(connection):
    return connection.channel()

def __get_message_from_queue(channel, queue):
    return channel.basic_get(queue=queue)

def get_message(queue):
    """ Get the first message from a queue.

    The first message from a queue is retrieved. If there is no such message, the function exits quietly. 

    :param queue: The name of the queue from which to get the message.

    Usage::

    >>> from utils import get_message
    >>> message = get_message('queue')

    """
    with closing(amqp.Connection()) as connection:
        channel = __get_channel(connection)
        return  __get_message_from_queue(channel, queue)

Revert "Remove redundant functions (one too many levels of abstraction)@"
Revert "Remove redundant functions (one too many levels of abstraction)@"

This reverts commit 9c5bf06d1427db9839b1531aa08e66574c7b4582.

  import amqp
  from contextlib import closing
  
+ 
+ def __get_channel(connection):
+     return connection.channel()
+ 
+ def __get_message_from_queue(channel, queue):
+     return channel.basic_get(queue=queue)
  
  def get_message(queue):
      """ Get the first message from a queue.
  
      The first message from a queue is retrieved. If there is no such message, the function exits quietly. 
  
      :param queue: The name of the queue from which to get the message.
  
      Usage::
  
      >>> from utils import get_message
      >>> message = get_message('queue')
  
      """
      with closing(amqp.Connection()) as connection:
-         channel = connection.channel()
-         return channel.basic_get(queue=queue)
+         channel = __get_channel(connection)
+         return  __get_message_from_queue(channel, queue)
  
Revert "Remove redundant functions (one too many levels of abstraction)@"
## Code Before:
import amqp
from contextlib import closing


def get_message(queue):
    """ Get the first message from a queue.

    The first message from a queue is retrieved. If there is no such message, the function exits quietly. 

    :param queue: The name of the queue from which to get the message.

    Usage::

    >>> from utils import get_message
    >>> message = get_message('queue')

    """
    with closing(amqp.Connection()) as connection:
        channel = connection.channel()
        return channel.basic_get(queue=queue)

## Instruction:
Revert "Remove redundant functions (one too many levels of abstraction)@"
## Code After:
import amqp
from contextlib import closing


def __get_channel(connection):
    return connection.channel()

def __get_message_from_queue(channel, queue):
    return channel.basic_get(queue=queue)

def get_message(queue):
    """ Get the first message from a queue.

    The first message from a queue is retrieved. If there is no such message, the function exits quietly. 

    :param queue: The name of the queue from which to get the message.

    Usage::

    >>> from utils import get_message
    >>> message = get_message('queue')

    """
    with closing(amqp.Connection()) as connection:
        channel = __get_channel(connection)
        return  __get_message_from_queue(channel, queue)
