parameters: (self, nodes: List[PermNode])
docstring: 这里计算的是一个组织的
docstring_summary: 这里计算的是一个组织的
docstring_tokens: 这里计算的是一个组织的
function: def compute_node_assets_amount(self, nodes: List[PermNode]):
          """
          这里计算的是一个组织的
          """
          # 直接授权了根节点，直接计算
          if len(nodes) == 1:
              node = nodes[0]
              if node.node_from == NodeFrom.granted and node.key.isdigit():
                  with tmp_to_org(node.org):
                      node.granted_assets_amount = len(node.get_all_asset_ids())
                      return
  
          direct_granted_nodes_key = []
          node_id_key_mapper = {}
          for node in nodes:
              if node.node_from == NodeFrom.granted:
                  direct_granted_nodes_key.append(node.key)
              node_id_key_mapper[node.id.hex] = node.key
  
          # 授权的节点和直接资产的映射
          nodekey_assetsid_mapper = defaultdict(set)
          # 直接授权的节点，资产从完整树过来
          self._fill_direct_granted_node_asset_ids_from_mem(
              direct_granted_nodes_key, nodekey_assetsid_mapper
          )
  
          # 处理直接授权资产
          # 直接授权资产，取节点与资产的关系
          node_asset_pairs = self.direct_granted_asset_id_node_id_str_pairs
          node_asset_pairs = list(node_asset_pairs)
  
          for node_id, asset_id in node_asset_pairs:
              if node_id not in node_id_key_mapper:
                  continue
              nkey = node_id_key_mapper[node_id]
              nodekey_assetsid_mapper[nkey].add(asset_id)
  
          util = NodeAssetsUtil(nodes, nodekey_assetsid_mapper)
          util.generate()
  
          for node in nodes:
              assets_amount = util.get_assets_amount(node.key)
              node.assets_amount = assets_amount
function_tokens: def compute_node_assets_amount ( self , nodes : List [ PermNode ] ) : # 直接授权了根节点，直接计算 if len ( nodes ) == 1 : node = nodes [ 0 ] if node . node_from == NodeFrom . granted and node . key . isdigit ( ) : with tmp_to_org ( node . org ) : node . granted_assets_amount = len ( node . get_all_asset_ids ( ) ) return direct_granted_nodes_key = [ ] node_id_key_mapper = { } for node in nodes : if node . node_from == NodeFrom . granted : direct_granted_nodes_key . append ( node . key ) node_id_key_mapper [ node . id . hex ] = node . key # 授权的节点和直接资产的映射 nodekey_assetsid_mapper = defaultdict ( set ) # 直接授权的节点，资产从完整树过来 self . _fill_direct_granted_node_asset_ids_from_mem ( direct_granted_nodes_key , nodekey_assetsid_mapper ) # 处理直接授权资产 # 直接授权资产，取节点与资产的关系 node_asset_pairs = self . direct_granted_asset_id_node_id_str_pairs node_asset_pairs = list ( node_asset_pairs ) for node_id , asset_id in node_asset_pairs : if node_id not in node_id_key_mapper : continue nkey = node_id_key_mapper [ node_id ] nodekey_assetsid_mapper [ nkey ] . add ( asset_id ) util = NodeAssetsUtil ( nodes , nodekey_assetsid_mapper ) util . generate ( ) for node in nodes : assets_amount = util . get_assets_amount ( node . key ) node . assets_amount = assets_amount