nodes: 0, module; 1, function_definition; 2, function_name:_initDevClasses; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, if_statement; 13, for_statement; 14, expression_statement; 15, expression_statement; 16, expression_statement; 17, for_statement; 18, comment:"""Sort block devices into lists depending on device class and 
          initialize device type map and partition map."""; 19, assignment; 20, assignment; 21, assignment; 22, assignment; 23, assignment; 24, comparison_operator:self._mapMajorDevclass is None; 25, block; 26, identifier:dev; 27, attribute; 28, block; 29, call; 30, call; 31, assignment; 32, identifier:partdev; 33, identifier:otherdevs; 34, block; 35, attribute; 36, dictionary; 37, attribute; 38, dictionary; 39, attribute; 40, dictionary; 41, identifier:basedevs; 42, list; 43, identifier:otherdevs; 44, list; 45, attribute; 46, None; 47, expression_statement; 48, identifier:self; 49, identifier:_diskStats; 50, expression_statement; 51, expression_statement; 52, if_statement; 53, attribute; 54, argument_list; 55, attribute; 56, argument_list; 57, identifier:idx; 58, integer:0; 59, while_statement; 60, for_statement; 61, identifier:self; 62, identifier:_devClassTree; 63, identifier:self; 64, identifier:_partitionTree; 65, identifier:self; 66, identifier:_mapDevType; 67, identifier:self; 68, identifier:_mapMajorDevclass; 69, call; 70, assignment; 71, assignment; 72, comparison_operator:devclass is not None; 73, block; 74, identifier:basedevs; 75, identifier:sort; 76, keyword_argument; 77, keyword_argument; 78, identifier:otherdevs; 79, identifier:sort; 80, keyword_argument; 81, keyword_argument; 82, comparison_operator:len(basedevs[idx]) > partdev; 83, block; 84, identifier:dev; 85, subscript; 86, block; 87, attribute; 88, argument_list; 89, identifier:stats; 90, subscript; 91, identifier:devclass; 92, call; 93, identifier:devclass; 94, None; 95, expression_statement; 96, if_statement; 97, identifier:key; 98, identifier:len; 99, identifier:reverse; 100, True; 101, identifier:key; 102, identifier:len; 103, identifier:reverse; 104, True; 105, call; 106, identifier:partdev; 107, expression_statement; 108, identifier:basedevs; 109, slice; 110, if_statement; 111, identifier:self; 112, identifier:_initBlockMajorMap; 113, attribute; 114, identifier:dev; 115, attribute; 116, argument_list; 117, assignment; 118, call; 119, block; 120, else_clause; 121, identifier:len; 122, argument_list; 123, augmented_assignment; 124, identifier:idx; 125, call; 126, block; 127, identifier:self; 128, identifier:_diskStats; 129, attribute; 130, identifier:get; 131, subscript; 132, identifier:devdir; 133, call; 134, attribute; 135, argument_list; 136, if_statement; 137, expression_statement; 138, expression_statement; 139, expression_statement; 140, block; 141, subscript; 142, identifier:idx; 143, integer:1; 144, attribute; 145, argument_list; 146, if_statement; 147, expression_statement; 148, expression_statement; 149, identifier:self; 150, identifier:_mapMajorDevclass; 151, identifier:stats; 152, string; 153, attribute; 154, argument_list; 155, attribute; 156, identifier:isdir; 157, identifier:devdir; 158, not_operator; 159, block; 160, call; 161, assignment; 162, call; 163, expression_statement; 164, identifier:basedevs; 165, identifier:idx; 166, identifier:re; 167, identifier:match; 168, binary_operator:"%s(\d+|p\d+)$" % dev; 169, identifier:partdev; 170, not_operator; 171, block; 172, call; 173, assignment; 174, string_content:major; 175, attribute; 176, identifier:join; 177, identifier:sysfsBlockdevDir; 178, identifier:dev; 179, identifier:os; 180, identifier:path; 181, call; 182, expression_statement; 183, attribute; 184, argument_list; 185, subscript; 186, identifier:devclass; 187, attribute; 188, argument_list; 189, call; 190, string:"%s(\d+|p\d+)$"; 191, identifier:dev; 192, call; 193, expression_statement; 194, attribute; 195, argument_list; 196, subscript; 197, string; 198, identifier:os; 199, identifier:path; 200, attribute; 201, argument_list; 202, assignment; 203, subscript; 204, identifier:append; 205, identifier:dev; 206, attribute; 207, identifier:dev; 208, identifier:basedevs; 209, identifier:append; 210, identifier:dev; 211, attribute; 212, argument_list; 213, attribute; 214, argument_list; 215, assignment; 216, subscript; 217, identifier:append; 218, identifier:partdev; 219, attribute; 220, identifier:partdev; 221, string_content:part; 222, attribute; 223, identifier:has_key; 224, identifier:devclass; 225, subscript; 226, list; 227, attribute; 228, identifier:devclass; 229, identifier:self; 230, identifier:_mapDevType; 231, identifier:otherdevs; 232, identifier:append; 233, identifier:dev; 234, attribute; 235, identifier:has_key; 236, identifier:dev; 237, subscript; 238, list; 239, attribute; 240, identifier:dev; 241, identifier:self; 242, identifier:_mapDevType; 243, identifier:self; 244, identifier:_devClassTree; 245, attribute; 246, identifier:devclass; 247, identifier:self; 248, identifier:_devClassTree; 249, identifier:self; 250, identifier:_partitionTree; 251, attribute; 252, identifier:dev; 253, identifier:self; 254, identifier:_partitionTree; 255, identifier:self; 256, identifier:_devClassTree; 257, identifier:self; 258, identifier:_partitionTree
code: def _initDevClasses(self):
          """Sort block devices into lists depending on device class and 
          initialize device type map and partition map."""
          self._devClassTree = {}
          self._partitionTree = {}
          self._mapDevType = {}
          basedevs = []
          otherdevs = []
          if self._mapMajorDevclass is None:
              self._initBlockMajorMap()
          for dev in self._diskStats:
              stats = self._diskStats[dev]
              devclass = self._mapMajorDevclass.get(stats['major'])
              if devclass is not None:
                  devdir = os.path.join(sysfsBlockdevDir, dev)
                  if os.path.isdir(devdir):
                      if not self._devClassTree.has_key(devclass):
                          self._devClassTree[devclass] = []
                      self._devClassTree[devclass].append(dev)
                      self._mapDevType[dev] = devclass
                      basedevs.append(dev)
                  else:
                      otherdevs.append(dev)
          basedevs.sort(key=len, reverse=True)
          otherdevs.sort(key=len, reverse=True)
          idx = 0
          for partdev in otherdevs:
              while len(basedevs[idx]) > partdev:
                  idx += 1 
              for dev in basedevs[idx:]:
                  if re.match("%s(\d+|p\d+)$" % dev, partdev):
                      if not self._partitionTree.has_key(dev):
                          self._partitionTree[dev] = []
                      self._partitionTree[dev].append(partdev)
                      self._mapDevType[partdev] = 'part'