nodes: 0, module; 1, function_definition; 2, function_name:_get_vars; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, if_statement; 8, if_statement; 9, expression_statement; 10, comment:# translate a list of vars into a dict; 11, if_statement; 12, if_statement; 13, if_statement; 14, expression_statement; 15, expression_statement; 16, return_statement; 17, string; 18, comparison_operator:self.vars is None; 19, block; 20, comparison_operator:type(self.vars) not in [dict, list]; 21, block; 22, assignment; 23, comparison_operator:type(self.vars) == list; 24, block; 25, else_clause; 26, comparison_operator:type(self.playbook.extra_vars) == dict; 27, block; 28, comparison_operator:type(self.vars_prompt) == list; 29, block; 30, elif_clause; 31, else_clause; 32, assignment; 33, call; 34, identifier:results; 35, string_content:load the vars section from a play, accounting for all sorts of variable features
          including loading from yaml files, prompting, and conditional includes of the first
          file found in a list.; 36, attribute; 37, None; 38, expression_statement; 39, call; 40, list; 41, raise_statement; 42, identifier:vars; 43, dictionary; 44, call; 45, identifier:list; 46, for_statement; 47, block; 48, call; 49, identifier:dict; 50, expression_statement; 51, call; 52, identifier:list; 53, for_statement; 54, comparison_operator:type(self.vars_prompt) == dict; 55, block; 56, block; 57, identifier:results; 58, call; 59, attribute; 60, argument_list; 61, identifier:self; 62, identifier:vars; 63, assignment; 64, identifier:type; 65, argument_list; 66, identifier:dict; 67, identifier:list; 68, call; 69, identifier:type; 70, argument_list; 71, identifier:item; 72, attribute; 73, block; 74, expression_statement; 75, identifier:type; 76, argument_list; 77, call; 78, identifier:type; 79, argument_list; 80, identifier:var; 81, attribute; 82, block; 83, call; 84, identifier:dict; 85, for_statement; 86, raise_statement; 87, attribute; 88, argument_list; 89, identifier:results; 90, identifier:update; 91, identifier:vars; 92, attribute; 93, dictionary; 94, attribute; 95, attribute; 96, argument_list; 97, attribute; 98, identifier:self; 99, identifier:vars; 100, if_statement; 101, expression_statement; 102, expression_statement; 103, call; 104, attribute; 105, attribute; 106, argument_list; 107, attribute; 108, identifier:self; 109, identifier:vars_prompt; 110, if_statement; 111, expression_statement; 112, expression_statement; 113, expression_statement; 114, expression_statement; 115, expression_statement; 116, expression_statement; 117, expression_statement; 118, expression_statement; 119, if_statement; 120, identifier:type; 121, argument_list; 122, tuple_pattern; 123, call; 124, block; 125, call; 126, attribute; 127, identifier:copy; 128, identifier:self; 129, identifier:vars; 130, identifier:self; 131, identifier:vars; 132, identifier:errors; 133, identifier:AnsibleError; 134, string:"'vars' section must contain only key/value pairs"; 135, identifier:self; 136, identifier:vars; 137, comparison_operator:getattr(item, 'items', None) is None; 138, block; 139, assignment; 140, assignment; 141, attribute; 142, argument_list; 143, attribute; 144, identifier:extra_vars; 145, identifier:vars; 146, identifier:update; 147, attribute; 148, identifier:self; 149, identifier:vars_prompt; 150, not_operator; 151, block; 152, assignment; 153, assignment; 154, assignment; 155, assignment; 156, assignment; 157, assignment; 158, assignment; 159, assignment; 160, comparison_operator:vname not in self.playbook.extra_vars; 161, block; 162, attribute; 163, identifier:vname; 164, identifier:prompt; 165, attribute; 166, argument_list; 167, expression_statement; 168, if_statement; 169, attribute; 170, argument_list; 171, attribute; 172, identifier:extra_vars; 173, call; 174, None; 175, raise_statement; 176, pattern_list; 177, subscript; 178, subscript; 179, identifier:v; 180, identifier:vars; 181, identifier:update; 182, attribute; 183, identifier:self; 184, identifier:playbook; 185, attribute; 186, identifier:extra_vars; 187, comparison_operator:'name' in var; 188, raise_statement; 189, identifier:vname; 190, subscript; 191, identifier:prompt; 192, call; 193, identifier:default; 194, call; 195, identifier:private; 196, call; 197, identifier:confirm; 198, call; 199, identifier:encrypt; 200, call; 201, identifier:salt_size; 202, call; 203, identifier:salt; 204, call; 205, identifier:vname; 206, attribute; 207, expression_statement; 208, identifier:self; 209, identifier:vars_prompt; 210, attribute; 211, identifier:iteritems; 212, assignment; 213, comparison_operator:vname not in self.playbook.extra_vars; 214, block; 215, identifier:errors; 216, identifier:AnsibleError; 217, string:"'vars_prompt' section is malformed, see docs"; 218, identifier:self; 219, identifier:playbook; 220, identifier:getattr; 221, argument_list; 222, call; 223, identifier:k; 224, identifier:v; 225, call; 226, integer:0; 227, identifier:vars; 228, identifier:k; 229, identifier:self; 230, identifier:vars; 231, identifier:self; 232, identifier:playbook; 233, string; 234, identifier:var; 235, call; 236, identifier:var; 237, string; 238, attribute; 239, argument_list; 240, attribute; 241, argument_list; 242, attribute; 243, argument_list; 244, attribute; 245, argument_list; 246, attribute; 247, argument_list; 248, attribute; 249, argument_list; 250, attribute; 251, argument_list; 252, attribute; 253, identifier:extra_vars; 254, assignment; 255, identifier:self; 256, identifier:vars_prompt; 257, identifier:prompt_msg; 258, binary_operator:"%s: " % prompt; 259, identifier:vname; 260, attribute; 261, expression_statement; 262, identifier:item; 263, string; 264, None; 265, attribute; 266, argument_list; 267, attribute; 268, argument_list; 269, string_content:name; 270, attribute; 271, argument_list; 272, string_content:name; 273, identifier:var; 274, identifier:get; 275, string:"prompt"; 276, identifier:vname; 277, identifier:var; 278, identifier:get; 279, string:"default"; 280, None; 281, identifier:var; 282, identifier:get; 283, string:"private"; 284, True; 285, identifier:var; 286, identifier:get; 287, string:"confirm"; 288, False; 289, identifier:var; 290, identifier:get; 291, string:"encrypt"; 292, None; 293, identifier:var; 294, identifier:get; 295, string:"salt_size"; 296, None; 297, identifier:var; 298, identifier:get; 299, string:"salt"; 300, None; 301, identifier:self; 302, identifier:playbook; 303, subscript; 304, call; 305, string:"%s: "; 306, identifier:prompt; 307, attribute; 308, identifier:extra_vars; 309, assignment; 310, string_content:items; 311, identifier:errors; 312, identifier:AnsibleError; 313, string:"expecting a key-value pair in 'vars' section"; 314, identifier:item; 315, identifier:items; 316, identifier:errors; 317, identifier:AnsibleError; 318, string:"'vars_prompt' item is missing 'name:'"; 319, identifier:vars; 320, identifier:vname; 321, attribute; 322, argument_list; 323, identifier:self; 324, identifier:playbook; 325, subscript; 326, call; 327, attribute; 328, identifier:on_vars_prompt; 329, identifier:vname; 330, identifier:private; 331, identifier:prompt; 332, identifier:encrypt; 333, identifier:confirm; 334, identifier:salt_size; 335, identifier:salt; 336, identifier:default; 337, identifier:vars; 338, identifier:vname; 339, attribute; 340, argument_list; 341, attribute; 342, identifier:callbacks; 343, attribute; 344, identifier:on_vars_prompt; 345, keyword_argument; 346, keyword_argument; 347, keyword_argument; 348, keyword_argument; 349, identifier:self; 350, identifier:playbook; 351, attribute; 352, identifier:callbacks; 353, identifier:varname; 354, identifier:vname; 355, identifier:private; 356, False; 357, identifier:prompt; 358, identifier:prompt_msg; 359, identifier:default; 360, None; 361, identifier:self; 362, identifier:playbook
code: def _get_vars(self):
          ''' load the vars section from a play, accounting for all sorts of variable features
          including loading from yaml files, prompting, and conditional includes of the first
          file found in a list. '''
  
          if self.vars is None:
              self.vars = {}
  
          if type(self.vars) not in [dict, list]:
              raise errors.AnsibleError("'vars' section must contain only key/value pairs")
  
          vars = {}
  
          # translate a list of vars into a dict
          if type(self.vars) == list:
              for item in self.vars:
                  if getattr(item, 'items', None) is None:
                      raise errors.AnsibleError("expecting a key-value pair in 'vars' section")
                  k, v = item.items()[0]
                  vars[k] = v
          else:
              vars.update(self.vars)
  
          if type(self.playbook.extra_vars) == dict:
              vars.update(self.playbook.extra_vars)
  
          if type(self.vars_prompt) == list:
              for var in self.vars_prompt:
                  if not 'name' in var:
                      raise errors.AnsibleError("'vars_prompt' item is missing 'name:'")
  
                  vname = var['name']
                  prompt = var.get("prompt", vname)
                  default = var.get("default", None)
                  private = var.get("private", True)
  
                  confirm = var.get("confirm", False)
                  encrypt = var.get("encrypt", None)
                  salt_size = var.get("salt_size", None)
                  salt = var.get("salt", None)
  
                  if vname not in self.playbook.extra_vars:
                      vars[vname] = self.playbook.callbacks.on_vars_prompt (
                                       vname, private, prompt, encrypt, confirm, salt_size, salt, default
                                    )
  
          elif type(self.vars_prompt) == dict:
              for (vname, prompt) in self.vars_prompt.iteritems():
                  prompt_msg = "%s: " % prompt
                  if vname not in self.playbook.extra_vars:
                      vars[vname] = self.playbook.callbacks.on_vars_prompt(
                                       varname=vname, private=False, prompt=prompt_msg, default=None
                                    )
  
          else:
              raise errors.AnsibleError("'vars_prompt' section is malformed, see docs")
  
          results = self.playbook.extra_vars.copy()
          results.update(vars)
          return results