
    4	                     h    d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 ddl
mZ d	 Zd
 Zy)z#Utilities for handling region flag.    )absolute_import)division)unicode_literals)	constants)log)
properties)
console_ioc                      t        j                         syt        j                  } t        j                  | dd      }| |   }t
        j                  j                  dj                  |             |S )zjPrompt for region from list of available regions.

  Returns:
    The region specified by the user, str
  NzaPlease specify a region:
(For the global endpoint the region needs to be specified as 'global'.)
T)messagecancel_optionzPTo make this the default region, run `gcloud config set ai_platform/region {}`.
)	r	   	CanPromptr   SUPPORTED_REGIONS_WITH_GLOBALPromptChoicer   statusPrintformat)all_regionsidxregions      7lib/googlecloudsdk/command_lib/ml_engine/region_util.py_PromptForRegionr      so     
			77+ : 		#
 s&**55;VF^E 
-    c                 $   | j                  d      r| j                  S t        j                  j                  j                  j                         r2t        j                  j                  j                  j                         S t               }|xs dS )a[  Gets the region and prompt for region if not provided.

  Note: region can be either `global` or one of supported regions.

    Region is decided in the following order:
  - region argument;
  - ai_platform/region gcloud config;
  - prompt user input.

  Args:
    args: Namespace, The args namespace.

  Returns:
    A str representing region.
  r   zus-central1)IsSpecifiedr   r   VALUESai_platformIsExplicitlySetGetr   )argsr   s     r   	GetRegionr    1   sp      
h;;""))99;((//3355& 
	 = r   N)__doc__
__future__r   r   r   $googlecloudsdk.command_lib.ml_enginer   googlecloudsdk.corer   r   googlecloudsdk.core.consoler	   r   r     r   r   <module>r'      s)    * &  ' : # * 2,!r   