def _create_poller(operation):
 try:
  operation_name = operation['name']
 except KeyError:
  raise MalformedOperation(u'Failed to parse operation, could not find key name in: {}'.format(operation))
 if ('zone' in operation):
  zone_url_parts = unicode(operation['zone']).split('/')
  try:
   project = zone_url_parts[(-3)]
   zone = zone_url_parts[(-1)]
  except IndexError:
   raise MalformedOperation("'zone' key of operation had unexpected form: {}.\nExpected '(.*/)?<project>/zones/<zone>'.\nFull operation: {}.".format(operation['zone'], operation))
  return ZoneOperationPoller(zone=unicode(zone), project=unicode(project), operation_name=unicode(operation_name))
 else:
  try:
   project = unicode(operation['selfLink']).split('/')[(-4)]
  except KeyError:
   raise MalformedOperation(u'Failed to parse global operation, could not find key selfLink in: {}'.format(operation))
  except IndexError:
   raise MalformedOperation("'selfLink' key of operation had unexpected form: {}.\nExpected '(.*/)?<project>/global/operations/<name>'.\nFull operation: {}.".format(operation['selfLink'], operation))
  return GlobalOperationPoller(project=unicode(project), operation_name=unicode(operation_name))

def _create_poller ( operation ) : try : operation_name = operation [ 'name' ] except KeyError : raise MalformedOperation ( u'Failed to parse operation, could not find key name in: {}' . format ( operation ) ) if ( 'zone' in operation ) : zone_url_parts = unicode ( operation [ 'zone' ] ) . split ( '/' ) try : project = zone_url_parts [ ( - 3 ) ] zone = zone_url_parts [ ( - 1 ) ] except IndexError : raise MalformedOperation ( "'zone' key of operation had unexpected form: {}.\nExpected '(.*/)?<project>/zones/<zone>'.\nFull operation: {}." . format ( operation [ 'zone' ] , operation ) ) return ZoneOperationPoller ( zone = unicode ( zone ) , project = unicode ( project ) , operation_name = unicode ( operation_name ) ) else : try : project = unicode ( operation [ 'selfLink' ] ) . split ( '/' ) [ ( - 4 ) ] except KeyError : raise MalformedOperation ( u'Failed to parse global operation, could not find key selfLink in: {}' . format ( operation ) ) except IndexError : raise MalformedOperation ( "'selfLink' key of operation had unexpected form: {}.\nExpected '(.*/)?<project>/global/operations/<name>'.\nFull operation: {}." . format ( operation [ 'selfLink' ] , operation ) ) return GlobalOperationPoller ( project = unicode ( project ) , operation_name = unicode ( operation_name ) )
creates an operation poller from the passed in operation .