How to use is_built_in method in lisa

Best Python code snippet using lisa_python

data.py

Source:data.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2"""3Tencent is pleased to support the open source community by making 蓝鲸智云 - 监控平台 (BlueKing - Monitor) available.4Copyright (C) 2017-2021 THL A29 Limited, a Tencent company. All rights reserved.5Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.6You may obtain a copy of the License at http://opensource.org/licenses/MIT7Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on8an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the9specific language governing permissions and limitations under the License.10"""11ALL_LABEL_MSG = [12 {13 "index": 1,14 "label_type": "result_table_label",15 "level": 1,16 "parent_label": None,17 "label_id": "applications",18 "label_name": "用户体验",19 },20 {21 "index": 2,22 "label_type": "result_table_label",23 "level": 2,24 "parent_label": "applications",25 "label_id": "application_check",26 "label_name": "业务应用",27 },28 {29 "index": 2,30 "label_type": "result_table_label",31 "level": 2,32 "parent_label": "services",33 "label_id": "component",34 "label_name": "组件",35 },36 {37 "index": 3,38 "label_type": "result_table_label",39 "level": 1,40 "parent_label": None,41 "label_id": "hosts",42 "label_name": "主机",43 },44 {45 "index": 1,46 "label_type": "result_table_label",47 "level": 2,48 "parent_label": "hosts",49 "label_id": "host_process",50 "label_name": "进程",51 },52 {53 "index": 2,54 "label_type": "result_table_label",55 "level": 2,56 "parent_label": "hosts",57 "label_id": "os",58 "label_name": "操作系统",59 },60 {61 "index": 4,62 "label_type": "result_table_label",63 "level": 1,64 "parent_label": None,65 "label_id": "others",66 "label_name": "其他",67 },68 {69 "index": 1,70 "label_type": "result_table_label",71 "level": 2,72 "parent_label": "others",73 "label_id": "other_rt",74 "label_name": "其他",75 },76 {77 "index": 2,78 "label_type": "result_table_label",79 "level": 1,80 "parent_label": None,81 "label_id": "services",82 "label_name": "服务",83 },84 {85 "index": 1,86 "label_type": "result_table_label",87 "level": 2,88 "parent_label": "services",89 "label_id": "service_module",90 "label_name": "服务模块",91 },92 {93 "index": 1,94 "label_type": "result_table_label",95 "level": 2,96 "parent_label": "applications",97 "label_id": "uptimecheck",98 "label_name": "服务拨测",99 },100]101HANDEL_LABEL_MSG = [102 {103 "index": 1,104 "name": "用户体验",105 "id": "applications",106 "children": [107 {"index": 2, "id": "application_check", "name": "业务应用"},108 {"index": 1, "id": "uptimecheck", "name": "服务拨测"},109 ],110 },111 {112 "index": 2,113 "name": "服务",114 "id": "services",115 "children": [116 {"index": 2, "id": "component", "name": "组件"},117 {"index": 1, "id": "service_module", "name": "服务模块"},118 ],119 },120 {121 "index": 3,122 "name": "主机",123 "id": "hosts",124 "children": [{"index": 1, "id": "host_process", "name": "进程"}, {"index": 2, "id": "os", "name": "操作系统"}],125 },126 {"index": 4, "name": "其他", "id": "others", "children": [{"index": 1, "id": "other_rt", "name": "其他"}]},127]128BASE_METRICS = [129 {130 "related_name": "test_host_exporter",131 "metric_field": "host_cpu_idle_percent",132 "related_id": "test_host_exporter",133 "metric_field_name": "CPU\\u7a7a\\u95f2\\u65f6\\u95f4\\u767e\\u5206\\u6bd4",134 "id": 292,135 "unit": "%",136 "dimensions": [137 {"id": "bk_biz_id", "name": "\\u4e1a\\u52a1ID"},138 {"id": "bk_cloud_id", "name": "\\u4e91\\u533a\\u57dfID"},139 {"id": "ip", "name": "\\u91c7\\u96c6\\u5668IP\\u5730\\u5740"},140 {"id": "bk_target_ip", "name": "\\u76ee\\u6807IP"},141 {"id": "bk_target_cloud_id", "name": "\\u76ee\\u6807\\u673a\\u5668\\u4e91\\u533a\\u57dfID"},142 ],143 "collect_config": "test_host_exporter_collect",144 "data_target": "host_target",145 "data_type_label": "time_series",146 "collect_config_ids": [31],147 "description": "",148 "unit_conversion": 1.0,149 "bk_biz_id": 0,150 "data_source_label": "bk_monitor",151 "result_table_id": "exporter_test_host_exporter.cpu",152 "default_condition": [],153 "result_table_name": "CPU\\u6027\\u80fd",154 "result_table_label": "os",155 "default_dimensions": ["bk_target_ip", "bk_target_cloud_id"],156 "plugin_type": "Exporter",157 }158]159UPTIMECHECK_METRICS = [160 {161 "related_name": "ping_baidu",162 "metric_field": "available",163 "related_id": "1",164 "method_list": ["AVG"],165 "metric_field_name": "单点可用率",166 "id": 386,167 "unit": "%",168 "dimensions": [{"id": "task_id", "name": "任务ID"}],169 "collect_config": "",170 "data_target": "none_target",171 "data_type_label": "time_series",172 "result_table_id": "uptimecheck.http",173 "collect_config_ids": "",174 "description": "",175 "unit_conversion": 0.01,176 "bk_biz_id": 2,177 "data_source_label": "bk_monitor",178 "default_condition": [{"key": "task_id", "value_name": "1(ping_baidu)", "method": "eq", "value": 1}],179 "result_table_name": "uptimecheck.http",180 "result_table_label": "uptimecheck",181 "default_dimensions": ["task_id"],182 "plugin_type": "",183 }184]185HOST_INFO = {186 "2": {187 1: {188 "agent_status": 0,189 "ip": "10.0.1.10",190 "plat_id": 0,191 "bk_cloud_id": 0,192 "module_ids": {193 6,194 9,195 12,196 13,197 14,198 15,199 17,200 18,201 19,202 21,203 22,204 23,205 25,206 26,207 28,208 29,209 42,210 43,211 45,212 46,213 47,214 48,215 49,216 50,217 52,218 55,219 56,220 57,221 },222 },223 2: {224 "agent_status": 2,225 "ip": "10.0.1.11",226 "plat_id": 0,227 "bk_cloud_id": 0,228 "module_ids": {5, 9, 10, 12, 13, 16, 17, 19, 21, 28},229 },230 3: {231 "agent_status": 0,232 "ip": "10.0.1.16",233 "plat_id": 0,234 "bk_cloud_id": 0,235 "module_ids": {32, 33, 34, 35, 36, 37, 38, 39, 40, 9, 10, 13, 14, 17, 19, 20, 21, 41, 31, 30, 5},236 },237 1025: {"agent_status": 0, "ip": "10.0.1.69", "plat_id": 0, "bk_cloud_id": 0, "module_ids": {6}},238 1022: {"agent_status": 0, "ip": "10.0.1.8", "plat_id": 0, "bk_cloud_id": 0, "module_ids": {11, 19, 21, 14}},239 1023: {"agent_status": 0, "ip": "10.0.1.4", "plat_id": 0, "bk_cloud_id": 0, "module_ids": {9, 10, 21}},240 }241}242SERVICE_INFO = {243 "2": {244 128: {"host_status": 2, "bk_module_id": 5, "name": "10.0.1.11_fta:solution"},245 1: {"host_status": 0, "bk_module_id": 18, "name": "mysql"},246 2: {"host_status": 0, "bk_module_id": 46, "name": "gse_ops"},247 3: {"host_status": 0, "bk_module_id": 33, "name": "adminserver"},248 4: {"host_status": 0, "bk_module_id": 41, "name": "toposerver"},249 5: {"host_status": 0, "bk_module_id": 50, "name": "gse_task"},250 6: {"host_status": 0, "bk_module_id": 57, "name": "gse_syncdata"},251 7: {"host_status": 0, "bk_module_id": 9, "name": "redis_cluster"},252 8: {"host_status": 2, "bk_module_id": 9, "name": "redis_cluster"},253 9: {"host_status": 0, "bk_module_id": 9, "name": "redis_cluster"},254 10: {"host_status": 0, "bk_module_id": 12, "name": "redis"},255 11: {"host_status": 0, "bk_module_id": 13, "name": "zookeeper"},256 12: {"host_status": 2, "bk_module_id": 13, "name": "zookeeper"},257 13: {"host_status": 0, "bk_module_id": 13, "name": "zookeeper"},258 14: {"host_status": 0, "bk_module_id": 52, "name": "gse_opts"},259 15: {"host_status": 0, "bk_module_id": 20, "name": "rabbitmq"},260 16: {"host_status": 0, "bk_module_id": 36, "name": "eventserver"},261 17: {"host_status": 0, "bk_module_id": 45, "name": "gse_btsvr"},262 18: {"host_status": 0, "bk_module_id": 55, "name": "gse_procmgr"},263 19: {"host_status": 0, "bk_module_id": 23, "name": "appo"},264 20: {"host_status": 0, "bk_module_id": 31, "name": "objectcontroller"},265 21: {"host_status": 0, "bk_module_id": 34, "name": "apiserver"},266 22: {"host_status": 0, "bk_module_id": 37, "name": "webserver"},267 23: {"host_status": 0, "bk_module_id": 39, "name": "hostcontroller"},268 24: {"host_status": 0, "bk_module_id": 47, "name": "gse_alarm"},269 25: {"host_status": 0, "bk_module_id": 40, "name": "procserver"},270 26: {"host_status": 0, "bk_module_id": 42, "name": "gse_api"},271 27: {"host_status": 0, "bk_module_id": 48, "name": "license"},272 28: {"host_status": 0, "bk_module_id": 15, "name": "nginx"},273 29: {"host_status": 0, "bk_module_id": 35, "name": "datacollection"},274 30: {"host_status": 0, "bk_module_id": 56, "name": "gse_dataop"},275 31: {"host_status": 0, "bk_module_id": 21, "name": "consul"},276 32: {"host_status": 2, "bk_module_id": 21, "name": "consul"},277 33: {"host_status": 0, "bk_module_id": 21, "name": "consul"},278 34: {"host_status": 0, "bk_module_id": 25, "name": "esb"},279 35: {"host_status": 0, "bk_module_id": 30, "name": "hostserver"},280 36: {"host_status": 0, "bk_module_id": 32, "name": "proccontroller"},281 37: {"host_status": 0, "bk_module_id": 43, "name": "gse_dba"},282 38: {"host_status": 0, "bk_module_id": 49, "name": "gse_data"},283 39: {"host_status": 0, "bk_module_id": 38, "name": "auditcontroller"},284 40: {"host_status": 0, "bk_module_id": 17, "name": "mongodb"},285 41: {"host_status": 2, "bk_module_id": 17, "name": "mongodb"},286 42: {"host_status": 0, "bk_module_id": 17, "name": "mongodb"},287 133: {"host_status": 0, "bk_module_id": 6, "name": "10.0.1.69_dataapi-celery"},288 130: {"host_status": 0, "bk_module_id": 10, "name": "10.0.1.16_tsdb-proxy_5261"},289 129: {"host_status": 0, "bk_module_id": 19, "name": "10.0.1.16_kafka-java_9092"},290 142: {"host_status": 0, "bk_module_id": 22, "name": "10.0.1.10_paas-console_8004"},291 131: {"host_status": 0, "bk_module_id": 14, "name": "10.0.1.16_es-java_9300,10004"},292 106: {"host_status": 0, "bk_module_id": 14, "name": "10.0.1.10_es-java_9300,10004"},293 107: {"host_status": 0, "bk_module_id": 29, "name": "10.0.1.10_asdf_"},294 108: {"host_status": 0, "bk_module_id": 29, "name": "10.0.1.10_asdf_"},295 111: {"host_status": 2, "bk_module_id": 28, "name": "10.0.1.11_paas-appengine_8000"},296 112: {"host_status": 0, "bk_module_id": 28, "name": "10.0.1.10_paas-appengine_8000"},297 113: {"host_status": 0, "bk_module_id": 26, "name": "10.0.1.10_paas-login_8003"},298 114: {"host_status": 0, "bk_module_id": 5, "name": "10.0.1.16_fta-common:webserver_13021"},299 116: {"host_status": 0, "bk_module_id": 6, "name": "10.0.1.10_dataapi-py_10011"},300 117: {"host_status": 0, "bk_module_id": 21, "name": "10.0.1.8_consul-agent_8301,8500,53"},301 118: {"host_status": 0, "bk_module_id": 14, "name": "10.0.1.8_es-java_9300,10004"},302 119: {"host_status": 0, "bk_module_id": 11, "name": "10.0.1.8_etcd_2379,2380"},303 120: {"host_status": 0, "bk_module_id": 19, "name": "10.0.1.8_kafka-java_9092"},304 121: {"host_status": 0, "bk_module_id": 21, "name": "10.0.1.4_consul-agent_8301,8500,53"},305 122: {"host_status": 0, "bk_module_id": 9, "name": "10.0.1.4_redis-sentinel_16379"},306 123: {"host_status": 0, "bk_module_id": 10, "name": "10.0.1.4_tsdb-proxy_5261"},307 124: {"host_status": 0, "bk_module_id": 19, "name": "10.0.1.10_kafka-java_9092"},308 125: {"host_status": 2, "bk_module_id": 19, "name": "10.0.1.11_kafka-java_9092"},309 126: {"host_status": 2, "bk_module_id": 16, "name": "10.0.1.11_beanstalkd_6380"},310 127: {"host_status": 2, "bk_module_id": 10, "name": "10.0.1.11_tsdb-proxy_5261"},311 }312}313MODULE_SERVICE_CATEGORY_INFO = {314 "2": {315 3: 10,316 4: 10,317 5: 10,318 6: 10,319 7: 10,320 8: 10,321 9: 10,322 10: 10,323 11: 10,324 12: 10,325 13: 10,326 14: 10,327 15: 10,328 16: 10,329 17: 10,330 18: 10,331 19: 10,332 20: 10,333 21: 10,334 22: 10,335 23: 10,336 24: 10,337 25: 10,338 26: 10,339 27: 10,340 28: 38,341 29: 10,342 30: 10,343 31: 10,344 32: 10,345 33: 10,346 34: 10,347 35: 10,348 36: 10,349 37: 10,350 38: 10,351 39: 10,352 40: 10,353 41: 10,354 42: 10,355 43: 10,356 44: 10,357 45: 10,358 46: 10,359 47: 10,360 48: 10,361 49: 10,362 50: 10,363 52: 10,364 54: 10,365 55: 10,366 56: 10,367 57: 10,368 58: 10,369 59: 10,370 60: 10,371 61: 10,372 }373}374TOPO_TREE_INFO = {375 "2": {376 "host_count": 0,377 "node_link": ["biz|2"],378 "default": 0,379 "bk_obj_name": "\u4e1a\u52a1",380 "bk_obj_id": "biz",381 "service_instance_count": 0,382 "child": [383 {384 "node_link": ["biz|2", "set|2"],385 "bk_obj_name": "\u96c6\u7fa4",386 "bk_obj_id": "set",387 "child": [388 {389 "node_link": ["biz|2", "set|2", "module|3"],390 "bk_obj_name": "\u6a21\u5757",391 "bk_obj_id": "module",392 "child": [],393 "bk_inst_id": 3,394 "bk_inst_name": "\u7a7a\u95f2\u673a",395 },396 {397 "node_link": ["biz|2", "set|2", "module|4"],398 "bk_obj_name": "\u6a21\u5757",399 "bk_obj_id": "module",400 "child": [],401 "bk_inst_id": 4,402 "bk_inst_name": "\u6545\u969c\u673a",403 },404 ],405 "bk_inst_id": 2,406 "bk_inst_name": "\u7a7a\u95f2\u673a\u6c60",407 },408 {409 "host_count": 0,410 "node_link": ["biz|2", "test|2"],411 "default": 0,412 "bk_obj_name": "test",413 "bk_obj_id": "test",414 "service_instance_count": 0,415 "child": [416 {417 "host_count": 0,418 "node_link": ["biz|2", "test|2", "set|6"],419 "default": 0,420 "bk_obj_name": "\u96c6\u7fa4",421 "bk_obj_id": "set",422 "service_instance_count": 0,423 "child": [424 {425 "host_count": 0,426 "node_link": ["biz|2", "test|2", "set|6", "module|28"],427 "default": 0,428 "bk_obj_name": "\u6a21\u5757",429 "bk_obj_id": "module",430 "service_instance_count": 0,431 "child": [],432 "service_template_id": 0,433 "bk_inst_id": 28,434 "bk_inst_name": "appengine",435 },436 {437 "host_count": 0,438 "node_link": ["biz|2", "test|2", "set|6", "module|23"],439 "default": 0,440 "bk_obj_name": "\u6a21\u5757",441 "bk_obj_id": "module",442 "service_instance_count": 0,443 "child": [],444 "service_template_id": 0,445 "bk_inst_id": 23,446 "bk_inst_name": "appo",447 },448 {449 "host_count": 0,450 "node_link": ["biz|2", "test|2", "set|6", "module|24"],451 "default": 0,452 "bk_obj_name": "\u6a21\u5757",453 "bk_obj_id": "module",454 "service_instance_count": 0,455 "child": [],456 "service_template_id": 0,457 "bk_inst_id": 24,458 "bk_inst_name": "appt",459 },460 {461 "host_count": 0,462 "node_link": ["biz|2", "test|2", "set|6", "module|22"],463 "default": 0,464 "bk_obj_name": "\u6a21\u5757",465 "bk_obj_id": "module",466 "service_instance_count": 0,467 "child": [],468 "service_template_id": 0,469 "bk_inst_id": 22,470 "bk_inst_name": "console",471 },472 {473 "host_count": 0,474 "node_link": ["biz|2", "test|2", "set|6", "module|25"],475 "default": 0,476 "bk_obj_name": "\u6a21\u5757",477 "bk_obj_id": "module",478 "service_instance_count": 0,479 "child": [],480 "service_template_id": 0,481 "bk_inst_id": 25,482 "bk_inst_name": "esb",483 },484 {485 "host_count": 0,486 "node_link": ["biz|2", "test|2", "set|6", "module|26"],487 "default": 0,488 "bk_obj_name": "\u6a21\u5757",489 "bk_obj_id": "module",490 "service_instance_count": 0,491 "child": [],492 "service_template_id": 0,493 "bk_inst_id": 26,494 "bk_inst_name": "login",495 },496 {497 "host_count": 0,498 "node_link": ["biz|2", "test|2", "set|6", "module|27"],499 "default": 0,500 "bk_obj_name": "\u6a21\u5757",501 "bk_obj_id": "module",502 "service_instance_count": 0,503 "child": [],504 "service_template_id": 0,505 "bk_inst_id": 27,506 "bk_inst_name": "paas",507 },508 ],509 "service_template_id": 0,510 "bk_inst_id": 6,511 "bk_inst_name": "PaaS\u5e73\u53f0",512 },513 {514 "host_count": 0,515 "node_link": ["biz|2", "test|2", "set|7"],516 "default": 0,517 "bk_obj_name": "\u96c6\u7fa4",518 "bk_obj_id": "set",519 "service_instance_count": 0,520 "child": [521 {522 "host_count": 0,523 "node_link": ["biz|2", "test|2", "set|7", "module|29"],524 "default": 0,525 "bk_obj_name": "\u6a21\u5757",526 "bk_obj_id": "module",527 "service_instance_count": 0,528 "child": [],529 "service_template_id": 0,530 "bk_inst_id": 29,531 "bk_inst_name": "job",532 }533 ],534 "service_template_id": 0,535 "bk_inst_id": 7,536 "bk_inst_name": "\u4f5c\u4e1a\u5e73\u53f0",537 },538 {539 "host_count": 0,540 "node_link": ["biz|2", "test|2", "set|5"],541 "default": 0,542 "bk_obj_name": "\u96c6\u7fa4",543 "bk_obj_id": "set",544 "service_instance_count": 0,545 "child": [546 {547 "host_count": 0,548 "node_link": ["biz|2", "test|2", "set|5", "module|16"],549 "default": 0,550 "bk_obj_name": "\u6a21\u5757",551 "bk_obj_id": "module",552 "service_instance_count": 0,553 "child": [],554 "service_template_id": 0,555 "bk_inst_id": 16,556 "bk_inst_name": "beanstalk",557 },558 {559 "host_count": 0,560 "node_link": ["biz|2", "test|2", "set|5", "module|60"],561 "default": 0,562 "bk_obj_name": "\u6a21\u5757",563 "bk_obj_id": "module",564 "service_instance_count": 0,565 "child": [],566 "service_template_id": 0,567 "bk_inst_id": 60,568 "bk_inst_name": "ceph-mon",569 },570 {571 "host_count": 0,572 "node_link": ["biz|2", "test|2", "set|5", "module|61"],573 "default": 0,574 "bk_obj_name": "\u6a21\u5757",575 "bk_obj_id": "module",576 "service_instance_count": 0,577 "child": [],578 "service_template_id": 0,579 "bk_inst_id": 61,580 "bk_inst_name": "ceph-radosgw",581 },582 {583 "host_count": 0,584 "node_link": ["biz|2", "test|2", "set|5", "module|21"],585 "default": 0,586 "bk_obj_name": "\u6a21\u5757",587 "bk_obj_id": "module",588 "service_instance_count": 0,589 "child": [],590 "service_template_id": 0,591 "bk_inst_id": 21,592 "bk_inst_name": "consul",593 },594 {595 "host_count": 0,596 "node_link": ["biz|2", "test|2", "set|5", "module|14"],597 "default": 0,598 "bk_obj_name": "\u6a21\u5757",599 "bk_obj_id": "module",600 "service_instance_count": 0,601 "child": [],602 "service_template_id": 0,603 "bk_inst_id": 14,604 "bk_inst_name": "elasticsearch",605 },606 {607 "host_count": 0,608 "node_link": ["biz|2", "test|2", "set|5", "module|11"],609 "default": 0,610 "bk_obj_name": "\u6a21\u5757",611 "bk_obj_id": "module",612 "service_instance_count": 0,613 "child": [],614 "service_template_id": 0,615 "bk_inst_id": 11,616 "bk_inst_name": "etcd",617 },618 {619 "host_count": 0,620 "node_link": ["biz|2", "test|2", "set|5", "module|10"],621 "default": 0,622 "bk_obj_name": "\u6a21\u5757",623 "bk_obj_id": "module",624 "service_instance_count": 0,625 "child": [],626 "service_template_id": 0,627 "bk_inst_id": 10,628 "bk_inst_name": "influxdb",629 },630 {631 "host_count": 0,632 "node_link": ["biz|2", "test|2", "set|5", "module|19"],633 "default": 0,634 "bk_obj_name": "\u6a21\u5757",635 "bk_obj_id": "module",636 "service_instance_count": 0,637 "child": [],638 "service_template_id": 0,639 "bk_inst_id": 19,640 "bk_inst_name": "kafka",641 },642 {643 "host_count": 0,644 "node_link": ["biz|2", "test|2", "set|5", "module|17"],645 "default": 0,646 "bk_obj_name": "\u6a21\u5757",647 "bk_obj_id": "module",648 "service_instance_count": 0,649 "child": [],650 "service_template_id": 0,651 "bk_inst_id": 17,652 "bk_inst_name": "mongodb",653 },654 {655 "host_count": 0,656 "node_link": ["biz|2", "test|2", "set|5", "module|18"],657 "default": 0,658 "bk_obj_name": "\u6a21\u5757",659 "bk_obj_id": "module",660 "service_instance_count": 0,661 "child": [],662 "service_template_id": 0,663 "bk_inst_id": 18,664 "bk_inst_name": "mysql",665 },666 {667 "host_count": 0,668 "node_link": ["biz|2", "test|2", "set|5", "module|59"],669 "default": 0,670 "bk_obj_name": "\u6a21\u5757",671 "bk_obj_id": "module",672 "service_instance_count": 0,673 "child": [],674 "service_template_id": 0,675 "bk_inst_id": 59,676 "bk_inst_name": "nfs",677 },678 {679 "host_count": 0,680 "node_link": ["biz|2", "test|2", "set|5", "module|15"],681 "default": 0,682 "bk_obj_name": "\u6a21\u5757",683 "bk_obj_id": "module",684 "service_instance_count": 0,685 "child": [],686 "service_template_id": 0,687 "bk_inst_id": 15,688 "bk_inst_name": "nginx",689 },690 {691 "host_count": 0,692 "node_link": ["biz|2", "test|2", "set|5", "module|20"],693 "default": 0,694 "bk_obj_name": "\u6a21\u5757",695 "bk_obj_id": "module",696 "service_instance_count": 0,697 "child": [],698 "service_template_id": 0,699 "bk_inst_id": 20,700 "bk_inst_name": "rabbitmq",701 },702 {703 "host_count": 0,704 "node_link": ["biz|2", "test|2", "set|5", "module|12"],705 "default": 0,706 "bk_obj_name": "\u6a21\u5757",707 "bk_obj_id": "module",708 "service_instance_count": 0,709 "child": [],710 "service_template_id": 0,711 "bk_inst_id": 12,712 "bk_inst_name": "redis",713 },714 {715 "host_count": 0,716 "node_link": ["biz|2", "test|2", "set|5", "module|9"],717 "default": 0,718 "bk_obj_name": "\u6a21\u5757",719 "bk_obj_id": "module",720 "service_instance_count": 0,721 "child": [],722 "service_template_id": 0,723 "bk_inst_id": 9,724 "bk_inst_name": "redis_cluster",725 },726 {727 "host_count": 0,728 "node_link": ["biz|2", "test|2", "set|5", "module|13"],729 "default": 0,730 "bk_obj_name": "\u6a21\u5757",731 "bk_obj_id": "module",732 "service_instance_count": 0,733 "child": [],734 "service_template_id": 0,735 "bk_inst_id": 13,736 "bk_inst_name": "zookeeper",737 },738 ],739 "service_template_id": 0,740 "bk_inst_id": 5,741 "bk_inst_name": "\u516c\u5171\u7ec4\u4ef6",742 },743 {744 "host_count": 0,745 "node_link": ["biz|2", "test|2", "set|3"],746 "default": 0,747 "bk_obj_name": "\u96c6\u7fa4",748 "bk_obj_id": "set",749 "service_instance_count": 0,750 "child": [751 {752 "host_count": 0,753 "node_link": ["biz|2", "test|2", "set|3", "module|5"],754 "default": 0,755 "bk_obj_name": "\u6a21\u5757",756 "bk_obj_id": "module",757 "service_instance_count": 0,758 "child": [],759 "service_template_id": 0,760 "bk_inst_id": 5,761 "bk_inst_name": "fta",762 }763 ],764 "service_template_id": 0,765 "bk_inst_id": 3,766 "bk_inst_name": "\u6545\u969c\u81ea\u6108",767 },768 {769 "host_count": 0,770 "node_link": ["biz|2", "test|2", "set|4"],771 "default": 0,772 "bk_obj_name": "\u96c6\u7fa4",773 "bk_obj_id": "set",774 "service_instance_count": 0,775 "child": [776 {777 "host_count": 0,778 "node_link": ["biz|2", "test|2", "set|4", "module|6"],779 "default": 0,780 "bk_obj_name": "\u6a21\u5757",781 "bk_obj_id": "module",782 "service_instance_count": 0,783 "child": [],784 "service_template_id": 0,785 "bk_inst_id": 6,786 "bk_inst_name": "dataapi",787 },788 {789 "host_count": 0,790 "node_link": ["biz|2", "test|2", "set|4", "module|7"],791 "default": 0,792 "bk_obj_name": "\u6a21\u5757",793 "bk_obj_id": "module",794 "service_instance_count": 0,795 "child": [],796 "service_template_id": 0,797 "bk_inst_id": 7,798 "bk_inst_name": "databus",799 },800 {801 "host_count": 0,802 "node_link": ["biz|2", "test|2", "set|4", "module|58"],803 "default": 0,804 "bk_obj_name": "\u6a21\u5757",805 "bk_obj_id": "module",806 "service_instance_count": 0,807 "child": [],808 "service_template_id": 0,809 "bk_inst_id": 58,810 "bk_inst_name": "datamanager",811 },812 {813 "host_count": 0,814 "node_link": ["biz|2", "test|2", "set|4", "module|8"],815 "default": 0,816 "bk_obj_name": "\u6a21\u5757",817 "bk_obj_id": "module",818 "service_instance_count": 0,819 "child": [],820 "service_template_id": 0,821 "bk_inst_id": 8,822 "bk_inst_name": "monitor",823 },824 ],825 "service_template_id": 0,826 "bk_inst_id": 4,827 "bk_inst_name": "\u6570\u636e\u670d\u52a1\u6a21\u5757",828 },829 {830 "host_count": 0,831 "node_link": ["biz|2", "test|2", "set|9"],832 "default": 0,833 "bk_obj_name": "\u96c6\u7fa4",834 "bk_obj_id": "set",835 "service_instance_count": 0,836 "child": [837 {838 "host_count": 0,839 "node_link": ["biz|2", "test|2", "set|9", "module|47"],840 "default": 0,841 "bk_obj_name": "\u6a21\u5757",842 "bk_obj_id": "module",843 "service_instance_count": 0,844 "child": [],845 "service_template_id": 0,846 "bk_inst_id": 47,847 "bk_inst_name": "gse_alarm",848 },849 {850 "host_count": 0,851 "node_link": ["biz|2", "test|2", "set|9", "module|42"],852 "default": 0,853 "bk_obj_name": "\u6a21\u5757",854 "bk_obj_id": "module",855 "service_instance_count": 0,856 "child": [],857 "service_template_id": 0,858 "bk_inst_id": 42,859 "bk_inst_name": "gse_api",860 },861 {862 "host_count": 0,863 "node_link": ["biz|2", "test|2", "set|9", "module|45"],864 "default": 0,865 "bk_obj_name": "\u6a21\u5757",866 "bk_obj_id": "module",867 "service_instance_count": 0,868 "child": [],869 "service_template_id": 0,870 "bk_inst_id": 45,871 "bk_inst_name": "gse_btsvr",872 },873 {874 "host_count": 0,875 "node_link": ["biz|2", "test|2", "set|9", "module|49"],876 "default": 0,877 "bk_obj_name": "\u6a21\u5757",878 "bk_obj_id": "module",879 "service_instance_count": 0,880 "child": [],881 "service_template_id": 0,882 "bk_inst_id": 49,883 "bk_inst_name": "gse_data",884 },885 {886 "host_count": 0,887 "node_link": ["biz|2", "test|2", "set|9", "module|56"],888 "default": 0,889 "bk_obj_name": "\u6a21\u5757",890 "bk_obj_id": "module",891 "service_instance_count": 0,892 "child": [],893 "service_template_id": 0,894 "bk_inst_id": 56,895 "bk_inst_name": "gse_dataop",896 },897 {898 "host_count": 0,899 "node_link": ["biz|2", "test|2", "set|9", "module|43"],900 "default": 0,901 "bk_obj_name": "\u6a21\u5757",902 "bk_obj_id": "module",903 "service_instance_count": 0,904 "child": [],905 "service_template_id": 0,906 "bk_inst_id": 43,907 "bk_inst_name": "gse_dba",908 },909 {910 "host_count": 0,911 "node_link": ["biz|2", "test|2", "set|9", "module|46"],912 "default": 0,913 "bk_obj_name": "\u6a21\u5757",914 "bk_obj_id": "module",915 "service_instance_count": 0,916 "child": [],917 "service_template_id": 0,918 "bk_inst_id": 46,919 "bk_inst_name": "gse_ops",920 },921 {922 "host_count": 0,923 "node_link": ["biz|2", "test|2", "set|9", "module|52"],924 "default": 0,925 "bk_obj_name": "\u6a21\u5757",926 "bk_obj_id": "module",927 "service_instance_count": 0,928 "child": [],929 "service_template_id": 0,930 "bk_inst_id": 52,931 "bk_inst_name": "gse_opts",932 },933 {934 "host_count": 0,935 "node_link": ["biz|2", "test|2", "set|9", "module|44"],936 "default": 0,937 "bk_obj_name": "\u6a21\u5757",938 "bk_obj_id": "module",939 "service_instance_count": 0,940 "child": [],941 "service_template_id": 0,942 "bk_inst_id": 44,943 "bk_inst_name": "gse_proc",944 },945 {946 "host_count": 0,947 "node_link": ["biz|2", "test|2", "set|9", "module|55"],948 "default": 0,949 "bk_obj_name": "\u6a21\u5757",950 "bk_obj_id": "module",951 "service_instance_count": 0,952 "child": [],953 "service_template_id": 0,954 "bk_inst_id": 55,955 "bk_inst_name": "gse_procmgr",956 },957 {958 "host_count": 0,959 "node_link": ["biz|2", "test|2", "set|9", "module|57"],960 "default": 0,961 "bk_obj_name": "\u6a21\u5757",962 "bk_obj_id": "module",963 "service_instance_count": 0,964 "child": [],965 "service_template_id": 0,966 "bk_inst_id": 57,967 "bk_inst_name": "gse_syncdata",968 },969 {970 "host_count": 0,971 "node_link": ["biz|2", "test|2", "set|9", "module|50"],972 "default": 0,973 "bk_obj_name": "\u6a21\u5757",974 "bk_obj_id": "module",975 "service_instance_count": 0,976 "child": [],977 "service_template_id": 0,978 "bk_inst_id": 50,979 "bk_inst_name": "gse_task",980 },981 {982 "host_count": 0,983 "node_link": ["biz|2", "test|2", "set|9", "module|48"],984 "default": 0,985 "bk_obj_name": "\u6a21\u5757",986 "bk_obj_id": "module",987 "service_instance_count": 0,988 "child": [],989 "service_template_id": 0,990 "bk_inst_id": 48,991 "bk_inst_name": "license",992 },993 ],994 "service_template_id": 0,995 "bk_inst_id": 9,996 "bk_inst_name": "\u7ba1\u63a7\u5e73\u53f0",997 },998 {999 "host_count": 0,1000 "node_link": ["biz|2", "test|2", "set|8"],1001 "default": 0,1002 "bk_obj_name": "\u96c6\u7fa4",1003 "bk_obj_id": "set",1004 "service_instance_count": 0,1005 "child": [1006 {1007 "host_count": 0,1008 "node_link": ["biz|2", "test|2", "set|8", "module|33"],1009 "default": 0,1010 "bk_obj_name": "\u6a21\u5757",1011 "bk_obj_id": "module",1012 "service_instance_count": 0,1013 "child": [],1014 "service_template_id": 0,1015 "bk_inst_id": 33,1016 "bk_inst_name": "adminserver",1017 },1018 {1019 "host_count": 0,1020 "node_link": ["biz|2", "test|2", "set|8", "module|34"],1021 "default": 0,1022 "bk_obj_name": "\u6a21\u5757",1023 "bk_obj_id": "module",1024 "service_instance_count": 0,1025 "child": [],1026 "service_template_id": 0,1027 "bk_inst_id": 34,1028 "bk_inst_name": "apiserver",1029 },1030 {1031 "host_count": 0,1032 "node_link": ["biz|2", "test|2", "set|8", "module|38"],1033 "default": 0,1034 "bk_obj_name": "\u6a21\u5757",1035 "bk_obj_id": "module",1036 "service_instance_count": 0,1037 "child": [],1038 "service_template_id": 0,1039 "bk_inst_id": 38,1040 "bk_inst_name": "auditcontroller",1041 },1042 {1043 "host_count": 0,1044 "node_link": ["biz|2", "test|2", "set|8", "module|54"],1045 "default": 0,1046 "bk_obj_name": "\u6a21\u5757",1047 "bk_obj_id": "module",1048 "service_instance_count": 0,1049 "child": [],1050 "service_template_id": 0,1051 "bk_inst_id": 54,1052 "bk_inst_name": "cmdb-nginx",1053 },1054 {1055 "host_count": 0,1056 "node_link": ["biz|2", "test|2", "set|8", "module|35"],1057 "default": 0,1058 "bk_obj_name": "\u6a21\u5757",1059 "bk_obj_id": "module",1060 "service_instance_count": 0,1061 "child": [],1062 "service_template_id": 0,1063 "bk_inst_id": 35,1064 "bk_inst_name": "datacollection",1065 },1066 {1067 "host_count": 0,1068 "node_link": ["biz|2", "test|2", "set|8", "module|36"],1069 "default": 0,1070 "bk_obj_name": "\u6a21\u5757",1071 "bk_obj_id": "module",1072 "service_instance_count": 0,1073 "child": [],1074 "service_template_id": 0,1075 "bk_inst_id": 36,1076 "bk_inst_name": "eventserver",1077 },1078 {1079 "host_count": 0,1080 "node_link": ["biz|2", "test|2", "set|8", "module|39"],1081 "default": 0,1082 "bk_obj_name": "\u6a21\u5757",1083 "bk_obj_id": "module",1084 "service_instance_count": 0,1085 "child": [],1086 "service_template_id": 0,1087 "bk_inst_id": 39,1088 "bk_inst_name": "hostcontroller",1089 },1090 {1091 "host_count": 0,1092 "node_link": ["biz|2", "test|2", "set|8", "module|30"],1093 "default": 0,1094 "bk_obj_name": "\u6a21\u5757",1095 "bk_obj_id": "module",1096 "service_instance_count": 0,1097 "child": [],1098 "service_template_id": 0,1099 "bk_inst_id": 30,1100 "bk_inst_name": "hostserver",1101 },1102 {1103 "host_count": 0,1104 "node_link": ["biz|2", "test|2", "set|8", "module|31"],1105 "default": 0,1106 "bk_obj_name": "\u6a21\u5757",1107 "bk_obj_id": "module",1108 "service_instance_count": 0,1109 "child": [],1110 "service_template_id": 0,1111 "bk_inst_id": 31,1112 "bk_inst_name": "objectcontroller",1113 },1114 {1115 "host_count": 0,1116 "node_link": ["biz|2", "test|2", "set|8", "module|32"],1117 "default": 0,1118 "bk_obj_name": "\u6a21\u5757",1119 "bk_obj_id": "module",1120 "service_instance_count": 0,1121 "child": [],1122 "service_template_id": 0,1123 "bk_inst_id": 32,1124 "bk_inst_name": "proccontroller",1125 },1126 {1127 "host_count": 0,1128 "node_link": ["biz|2", "test|2", "set|8", "module|40"],1129 "default": 0,1130 "bk_obj_name": "\u6a21\u5757",1131 "bk_obj_id": "module",1132 "service_instance_count": 0,1133 "child": [],1134 "service_template_id": 0,1135 "bk_inst_id": 40,1136 "bk_inst_name": "procserver",1137 },1138 {1139 "host_count": 0,1140 "node_link": ["biz|2", "test|2", "set|8", "module|41"],1141 "default": 0,1142 "bk_obj_name": "\u6a21\u5757",1143 "bk_obj_id": "module",1144 "service_instance_count": 0,1145 "child": [],1146 "service_template_id": 0,1147 "bk_inst_id": 41,1148 "bk_inst_name": "toposerver",1149 },1150 {1151 "host_count": 0,1152 "node_link": ["biz|2", "test|2", "set|8", "module|37"],1153 "default": 0,1154 "bk_obj_name": "\u6a21\u5757",1155 "bk_obj_id": "module",1156 "service_instance_count": 0,1157 "child": [],1158 "service_template_id": 0,1159 "bk_inst_id": 37,1160 "bk_inst_name": "webserver",1161 },1162 ],1163 "service_template_id": 0,1164 "bk_inst_id": 8,1165 "bk_inst_name": "\u914d\u7f6e\u5e73\u53f0",1166 },1167 ],1168 "service_template_id": 0,1169 "bk_inst_id": 2,1170 "bk_inst_name": "test1",1171 },1172 ],1173 "service_template_id": 0,1174 "bk_inst_id": 2,1175 "bk_inst_name": "\u84dd\u9cb8",1176 }1177}1178SERVICE_CATEGORY_INFO = {1179 "2": {1180 1: {1181 "bk_root_id": 1,1182 "name": "\u6570\u636e\u5e93",1183 "is_built_in": False,1184 "bk_supplier_account": "0",1185 "id": 1,1186 "metadata": {"label": {"bk_biz_id": "2"}},1187 },1188 2: {1189 "bk_root_id": 1,1190 "name": "Mysql",1191 "is_built_in": False,1192 "bk_supplier_account": "0",1193 "bk_parent_id": 1,1194 "id": 2,1195 "metadata": {"label": {"bk_biz_id": "2"}},1196 },1197 3: {1198 "bk_root_id": 1,1199 "name": "Oracle",1200 "is_built_in": False,1201 "bk_supplier_account": "0",1202 "bk_parent_id": 1,1203 "id": 3,1204 "metadata": {"label": {"bk_biz_id": "2"}},1205 },1206 5: {1207 "bk_root_id": 1,1208 "name": "XXX",1209 "is_built_in": False,1210 "bk_supplier_account": "0",1211 "bk_parent_id": 1,1212 "id": 5,1213 "metadata": {"label": {"bk_biz_id": "2"}},1214 },1215 9: {1216 "bk_root_id": 9,1217 "name": "Default",1218 "is_built_in": True,1219 "bk_supplier_account": "0",1220 "id": 9,1221 "metadata": {"label": None},1222 },1223 10: {1224 "bk_root_id": 9,1225 "name": "Default",1226 "is_built_in": True,1227 "bk_supplier_account": "0",1228 "bk_parent_id": 9,1229 "id": 10,1230 "metadata": {"label": None},1231 },1232 11: {1233 "is_built_in": True,1234 "metadata": {"label": None},1235 "id": 11,1236 "name": "\u6570\u636e\u5e93",1237 "bk_supplier_account": "0",1238 },1239 12: {1240 "name": "Mysql",1241 "is_built_in": True,1242 "bk_supplier_account": "0",1243 "bk_parent_id": 11,1244 "id": 12,1245 "metadata": {"label": None},1246 },1247 13: {1248 "name": "Redis",1249 "is_built_in": True,1250 "bk_supplier_account": "0",1251 "bk_parent_id": 11,1252 "id": 13,1253 "metadata": {"label": None},1254 },1255 14: {1256 "name": "Oracle",1257 "is_built_in": True,1258 "bk_supplier_account": "0",1259 "bk_parent_id": 11,1260 "id": 14,1261 "metadata": {"label": None},1262 },1263 15: {1264 "name": "SQLServer",1265 "is_built_in": True,1266 "bk_supplier_account": "0",1267 "bk_parent_id": 11,1268 "id": 15,1269 "metadata": {"label": None},1270 },1271 16: {1272 "name": "MongoDB",1273 "is_built_in": True,1274 "bk_supplier_account": "0",1275 "bk_parent_id": 11,1276 "id": 16,1277 "metadata": {"label": None},1278 },1279 17: {1280 "name": "Etcd",1281 "is_built_in": True,1282 "bk_supplier_account": "0",1283 "bk_parent_id": 11,1284 "id": 17,1285 "metadata": {"label": None},1286 },1287 18: {1288 "name": "Zookeeper",1289 "is_built_in": True,1290 "bk_supplier_account": "0",1291 "bk_parent_id": 11,1292 "id": 18,1293 "metadata": {"label": None},1294 },1295 19: {1296 "is_built_in": True,1297 "metadata": {"label": None},1298 "id": 19,1299 "name": "\u6d88\u606f\u961f\u5217",1300 "bk_supplier_account": "0",1301 },1302 20: {1303 "name": "Kafka",1304 "is_built_in": True,1305 "bk_supplier_account": "0",1306 "bk_parent_id": 19,1307 "id": 20,1308 "metadata": {"label": None},1309 },1310 21: {1311 "name": "RabbitMQ",1312 "is_built_in": True,1313 "bk_supplier_account": "0",1314 "bk_parent_id": 19,1315 "id": 21,1316 "metadata": {"label": None},1317 },1318 22: {1319 "is_built_in": True,1320 "metadata": {"label": None},1321 "id": 22,1322 "name": "HTTP \u670d\u52a1",1323 "bk_supplier_account": "0",1324 },1325 23: {1326 "name": "Nginx",1327 "is_built_in": True,1328 "bk_supplier_account": "0",1329 "bk_parent_id": 22,1330 "id": 23,1331 "metadata": {"label": None},1332 },1333 24: {1334 "name": "Apache",1335 "is_built_in": True,1336 "bk_supplier_account": "0",1337 "bk_parent_id": 22,1338 "id": 24,1339 "metadata": {"label": None},1340 },1341 25: {1342 "name": "Tomcat",1343 "is_built_in": True,1344 "bk_supplier_account": "0",1345 "bk_parent_id": 22,1346 "id": 25,1347 "metadata": {"label": None},1348 },1349 26: {1350 "is_built_in": True,1351 "metadata": {"label": None},1352 "id": 26,1353 "name": "\u5b58\u50a8",1354 "bk_supplier_account": "0",1355 },1356 27: {1357 "name": "Ceph",1358 "is_built_in": True,1359 "bk_supplier_account": "0",1360 "bk_parent_id": 26,1361 "id": 27,1362 "metadata": {"label": None},1363 },1364 28: {1365 "name": "NFS",1366 "is_built_in": True,1367 "bk_supplier_account": "0",1368 "bk_parent_id": 26,1369 "id": 28,1370 "metadata": {"label": None},1371 },1372 30: {1373 "bk_root_id": 30,1374 "name": "bond",1375 "is_built_in": False,1376 "bk_supplier_account": "0",1377 "id": 30,1378 "metadata": {"label": {"bk_biz_id": "2"}},1379 },1380 31: {1381 "bk_root_id": 30,1382 "name": "bond1",1383 "is_built_in": False,1384 "bk_supplier_account": "0",1385 "bk_parent_id": 30,1386 "id": 31,1387 "metadata": {"label": {"bk_biz_id": "2"}},1388 },1389 32: {1390 "bk_root_id": 30,1391 "name": "bond2",1392 "is_built_in": False,1393 "bk_supplier_account": "0",1394 "bk_parent_id": 30,1395 "id": 32,1396 "metadata": {"label": {"bk_biz_id": "2"}},1397 },1398 33: {1399 "bk_root_id": 30,1400 "name": "bond3",1401 "is_built_in": False,1402 "bk_supplier_account": "0",1403 "bk_parent_id": 30,1404 "id": 33,1405 "metadata": {"label": {"bk_biz_id": "2"}},1406 },1407 34: {1408 "bk_root_id": 30,1409 "name": "tst",1410 "is_built_in": False,1411 "bk_supplier_account": "0",1412 "bk_parent_id": 30,1413 "id": 34,1414 "metadata": {"label": {"bk_biz_id": "2"}},1415 },1416 36: {1417 "bk_root_id": 36,1418 "name": "sssssss",1419 "is_built_in": False,1420 "bk_supplier_account": "0",1421 "id": 36,1422 "metadata": {"label": {"bk_biz_id": "2"}},1423 },1424 37: {1425 "bk_root_id": 37,1426 "name": "PaaS",1427 "is_built_in": False,1428 "bk_supplier_account": "0",1429 "id": 37,1430 "metadata": {"label": {"bk_biz_id": "2"}},1431 },1432 38: {1433 "bk_root_id": 37,1434 "name": "esb",1435 "is_built_in": False,1436 "bk_supplier_account": "0",1437 "bk_parent_id": 37,1438 "id": 38,1439 "metadata": {"label": {"bk_biz_id": "2"}},1440 },1441 42: {1442 "bk_root_id": 42,1443 "name": "hito-server-type",1444 "is_built_in": False,1445 "bk_supplier_account": "0",1446 "id": 42,1447 "metadata": {"label": {"bk_biz_id": "2"}},1448 },1449 43: {1450 "bk_root_id": 42,1451 "name": "server-type-1",1452 "is_built_in": False,1453 "bk_supplier_account": "0",1454 "bk_parent_id": 42,1455 "id": 43,1456 "metadata": {"label": {"bk_biz_id": "2"}},1457 },1458 }...

Full Screen

Full Screen

nodeast.py

Source:nodeast.py Github

copy

Full Screen

1import config2import os3from utils import CmpMember4class AbstractAst(object):5 def __init__(self,parent,type):6 self._parent = parent7 self._type = type8 self._childs = []9 if self._parent != None:10 self.Parent.AppendChild(self)11 12 @property13 def Type(self):14 return self._type15 16 @property17 def Parent(self):18 return self._parent19 20 def AppendChild(self,node):21 self._childs.append(node)22 23 @property24 def Childs(self):25 return self._childs26 27 def HasChild(self,name):28 for child in self.Childs:29 if child.Name == name:30 return True31 return False32 33 def RemoveChild(self,name):34 for child in self.Childs:35 if child.Name == name:36 self.Childs.remove(child)37 break38 39class BuiltinNode(AbstractAst):40 41 def __init__(self,name,type,parent,doc=None,is_built_in=True):42 super(BuiltinNode,self).__init__(parent,type)43 self._is_built_in = is_built_in44 self._name = name45 self._doc = doc46 47 @property48 def Name(self):49 return self._name50 51 @property52 def IsBuiltIn(self):53 return self._is_built_in54 def IsValidMember(self,child):55 if child.Type == config.NODE_UNKNOWN_TYPE:56 return False57 return True58 59 def GetMemberList(self,sort=True):60 ###member_list = [child.Name for child in self.Childs if child.Type != config.NODE_UNKNOWN_TYPE]61 member_list = []62 for child in self.Childs:63 if self.IsValidMember(child):64 if child.Type == config.NODE_FROMIMPORT_TYPE:65 member_list.extend(child.GetMemberList(sort))66 elif child.Type == config.NODE_IMPORT_TYPE:67 if child.AsName is not None:68 member_list.append(child.AsName)69 else:70 if child.Name.find('.') == -1:71 member_list.append(child.Name)72 else:73 if child.Name.find('.') == -1:74 member_list.append(child.Name)75 if sort:76 member_list.sort(CmpMember)77 return member_list78 @property79 def Doc(self):80 return self._doc81 82class Module(BuiltinNode):83 84 def __init__(self,name,path,doc,is_built_in = False):85 super(Module,self).__init__(name,config.NODE_MODULE_TYPE,None,doc,is_built_in)86 self._path = path87 88 @property89 def Path(self):90 return self._path91 92 @Path.setter93 def Path(self,path):94 self._name = os.path.basename(path).split(".")[0]95 self._path = path96 97 def __str__(self):98 #print 'module name is',self.Name,'path is',self.Path99 #for child in self.Childs:100 # print 'module child:', child101 return self.Name102 103class Node(BuiltinNode):104 105 def __init__(self,name,line,col,type,parent,doc=None,is_built_in = False):106 super(Node,self).__init__(name,type,parent,doc,is_built_in)107 self._line = line108 self._col = col109 110 @property111 def Line(self):112 return self._line113 114 @property115 def Col(self):116 return self._col117 118class ArgNode(Node):119 def __init__(self,name,line,col,is_default=False,is_var=False,is_kw=False,parent=None):120 super(ArgNode,self).__init__(name,line,col,config.NODE_ARG_TYPE,parent)121 #default argment ,like x=12122 self._is_default = is_default123 #var argment,like *args124 self._is_var = is_var125 #keyword argment,like **kw126 self._is_kw = is_kw127 #default value of default argment128 self._default_value = None129 130 @property131 def IsDefault(self):132 return self._is_default133 134 @property135 def IsVar(self):136 return self._is_var137 138 @property139 def IsKeyWord(self):140 return self._is_kw 141 142 def __str__(self):143 #print 'type is arg, name is',self.Name,'line is',self.Line,'col is',self.Col144 return self.Name145 146 def SetDefaultValue(self,default_value):147 self._default_value = default_value148class FuncDef(Node):149 def __init__(self,name,line,col,parent,doc,args = [],is_decorated = False,is_method = False,is_class_method = False,is_built_in = False):150 super(FuncDef,self).__init__(name,line,col,config.NODE_FUNCDEF_TYPE,parent,doc,is_built_in)151 self._is_decorated = is_decorated152 self._is_method = is_method153 self._is_class_method = is_class_method154 self._args = args155 self._is_constructor = True if self._is_method and self.Name == "__init__" else False156 157 @property158 def IsDecorated(self):159 return self._is_decorated160 161 @property162 def IsMethod(self):163 return self._is_method164 165 @property166 def IsClassMethod(self):167 return self._is_class_method168 169 @property170 def Args(self):171 return self._args172 173 def __str__(self):174 #print 'type is func, name is',self.Name,'args is',self.Args,'line is',self.Line,'col is',self.Col175 #for child in self.Childs:176 # print 'func child:', child177 return self.Name178 @property179 def IsConstructor(self):180 return self._is_constructor181class ClassDef(Node):182 183 def __init__(self,name,line,col,parent,doc,is_decorated = False,is_built_in = False,bases = []):184 super(ClassDef,self).__init__(name,line,col,config.NODE_CLASSDEF_TYPE,parent,doc,is_built_in)185 self._is_decorated = is_decorated186 self._child_defs = []187 self._bases = bases188 189 def __str__(self):190 #print 'type is class, name is',self.Name,'line is',self.Line,'col is',self.Col191 #for child in self.Childs:192 # print 'class child:', child193 return self.Name194 195 @property 196 def Bases(self):197 return self._bases198 def GetClassMembers(self,sort=True):199 member_list = []200 for child in self.Childs:201 if (child.Type == config.NODE_FUNCDEF_TYPE and child.IsClassMethod) or \202 child.Type == config.NODE_ASSIGN_TYPE:203 member_list.append(child.Name)204 if sort:205 member_list.sort(CmpMember)206 return member_list207 208 209class AssignDef(Node):210 def __init__(self,name,line,col,value,value_type,parent,doc=None,node_type = config.NODE_ASSIGN_TYPE,is_built_in = False):211 super(AssignDef,self).__init__(name,line,col,node_type,parent,doc,is_built_in)212 self._value_type = value_type213 self._value = value214 @property215 def ValueType(self):216 return self._value_type217 218 @property219 def Value(self):220 return self._value221 222 def __str__(self):223 #print 'type is assign, name is',self.Name,'line is',self.Line,'col is',self.Col224 return self.Name225 226class PropertyDef(AssignDef):227 228 def __init__(self,name,line,col,value,value_type,parent,doc=None,is_class_property = False,is_built_in = False):229 if is_class_property:230 super(PropertyDef,self).__init__(name,line,col,value,value_type,parent,doc,\231 config.NODE_CLASS_PROPERTY,is_built_in)232 else:233 super(PropertyDef,self).__init__(name,line,col,value,value_type,parent,doc,\234 config.NODE_OBJECT_PROPERTY,is_built_in)235 ###self property is the child of method and method's class236 if self.Parent.Type == config.NODE_FUNCDEF_TYPE and self.Parent.IsMethod:237 self.Parent.Parent.AppendChild(self)238 def __str__(self):239 #print 'type is property, name is',self.Name,'line is',self.Line,'col is',self.Col240 return self.Name241 242class ImportNode(Node):243 def __init__(self,name,line,col,parent,as_name=None):244 super(ImportNode,self).__init__(name,line,col,config.NODE_IMPORT_TYPE,parent)245 self._as_name = as_name246 @property247 def AsName(self):248 return self._as_name249class BuiltinImportNode(ImportNode):250 BUILTIN_MODULE_NAME = '__builtin__'251 def __init__(self,parent):252 super(BuiltinImportNode,self).__init__(self.BUILTIN_MODULE_NAME,0,0,parent)253 self._type = config.NODE_BUILTIN_IMPORT_TYPE254 255class FromImportNode(Node):256 def __init__(self,name,line,col,parent):257 super(FromImportNode,self).__init__(name,line,col,config.NODE_FROMIMPORT_TYPE,parent)258 def GetMemberList(self,sort=True):259 member_list = []260 for child in self.Childs:261 if child.AsName is None:262 member_list.append(child.Name)263 else:264 member_list.append(child.AsName)265 if sort:266 member_list.sort(CmpMember)267 return member_list268 269class UnknownNode(Node):270 def __init__(self,line,col,parent):271 super(UnknownNode,self).__init__("___UnknownNode",line,col,config.NODE_UNKNOWN_TYPE,parent)272 273class MainFunctionNode(Node):274 275 MAIN_FUNCTION_NAME = "__main__"276 277 def __init__(self,line,col,parent):278 super(MainFunctionNode,self).__init__(self.MAIN_FUNCTION_NAME,line,col,config.NODE_MAIN_FUNCTION_TYPE,parent)...

Full Screen

Full Screen

node.py

Source:node.py Github

copy

Full Screen

1import ast2from imp import is_builtin3import importlib4class FileNode():5 def __init__(self,name,is_built_in=False) -> None:6 self.name = name7 self.imported_filenames = []8 self.classes = []9 self.functions = []10 self.dependency_file_nodes = []11 self.is_built_in = is_built_in12 13 if not is_built_in:14 # get script15 with open(name) as f:16 self.script = f.read()17 self.ast_tree = ast.parse(self.script)18 def get_list_imports(self):19 if not self.is_built_in:20 # get imports, functions, and classes21 for elem in self.ast_tree.body:22 if type(elem) == ast.Import:23 # get module path24 import_name = elem.names[0].name25 module_specs = importlib.util.find_spec(import_name)26 module_path = module_specs.origin27 28 if module_path == None:29 continue30 # create node for imported file31 if module_path == 'built-in':32 child_file_node = FileNode(module_path,is_built_in=True)33 else:34 child_file_node = FileNode(module_path)35 self.dependency_file_nodes.append(child_file_node)36 if type(elem) == ast.ClassDef:37 class_name = elem.name38 self.classes.append(class_name)39 if type(elem) == ast.FunctionDef:40 function_name = elem.name41 self.functions.append(function_name)42 43 44class ClassNode():45 def __init__(self,name) -> None:46 self.name = name47 self.imported_classes = []48 self.line_no = 049 self.functions = []50 self.inner_classes = []51class FunctionNode():52 def __init__(self,name) -> None:53 self.name = name54 self.called_functions = []...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run lisa automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful