├── efpodsanalyzer ├── __init__.py ├── EFPAConfig.json ├── template │ └── data.json ├── EFPADiagram │ ├── graph_force.html │ ├── index.html │ ├── graph_circular.html │ ├── js │ │ ├── xml2json.min.js │ │ └── dataTool.js │ └── css │ │ └── style.css └── efpodsanalyzer.py ├── _config.yml ├── setup.cfg ├── MANIFEST.in ├── assets ├── example.png ├── overview.png ├── headimage.png └── example_circular.png ├── docs ├── setting.json ├── graph_force.html ├── index.html ├── graph_circular.html ├── js │ ├── xml2json.min.js │ └── dataTool.js ├── css │ └── style.css └── data.json ├── tea.yaml ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE.md ├── CONTRIBUTING.md └── CODE_OF_CONDUCT.md ├── .gitignore ├── setup.py ├── CHANGELOG.md ├── README_CN.md ├── README.md └── LICENSE /efpodsanalyzer/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [metadata] 2 | description-file = README.md 3 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include *.js 2 | include *.html 3 | include *.json 4 | include *.css -------------------------------------------------------------------------------- /assets/example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EyreFree/EFPodsAnalyzer/HEAD/assets/example.png -------------------------------------------------------------------------------- /assets/overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EyreFree/EFPodsAnalyzer/HEAD/assets/overview.png -------------------------------------------------------------------------------- /assets/headimage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EyreFree/EFPodsAnalyzer/HEAD/assets/headimage.png -------------------------------------------------------------------------------- /assets/example_circular.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EyreFree/EFPodsAnalyzer/HEAD/assets/example_circular.png -------------------------------------------------------------------------------- /docs/setting.json: -------------------------------------------------------------------------------- 1 | setting = '{"setting": {"title": "Coding-iOS","categories": ["M-prefixed Libraries", "Library ending with Kit", "Other"]}}'; -------------------------------------------------------------------------------- /tea.yaml: -------------------------------------------------------------------------------- 1 | # https://tea.xyz/what-is-this-file 2 | --- 3 | version: 1.0.0 4 | codeOwners: 5 | - '0xFF7db19c4158A23a609Cf22e8978edafF04bEC84' 6 | quorum: 1 7 | -------------------------------------------------------------------------------- /efpodsanalyzer/EFPAConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "config": { 3 | "categories": ["M-prefixed Libraries", "Library ending with Kit", "Other"], 4 | "categoryRegexes": ["^M.*", ".*(Kit)$", ".*"] 5 | } 6 | } -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [EyreFree] 4 | # patreon: # Replace with a single Patreon username 5 | # open_collective: # Replace with a single Open Collective username 6 | # ko_fi: # Replace with a single Ko-fi username 7 | # tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | custom: https://www.efqrcode.com/donations.jpg 9 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Check List 2 | 3 | Thanks for considering to open an issue. Before you submit your issue, please confirm these boxes are checked. 4 | 5 | - [ ] I have read the [README.md](https://github.com/EyreFree/EFPodsAnalyzer/blob/master/README.md), but there is no information I need. 6 | - [ ] I have searched in [existing issues](https://github.com/EyreFree/EFPodsAnalyzer/issues?utf8=%E2%9C%93&q=is%3Aissue), but did find a same one. 7 | 8 | ### Issue Description 9 | 10 | #### Description 11 | 12 | [Tell us about the issue] 13 | 14 | #### Reproduce 15 | 16 | [The steps to reproduce this issue. What are the parameters, where did you put your code, etc.] 17 | 18 | #### Other Comment 19 | 20 | [Add anything else here] 21 | -------------------------------------------------------------------------------- /efpodsanalyzer/template/data.json: -------------------------------------------------------------------------------- 1 | { 2 | "gexf": { 3 | "meta": { 4 | "creator": "Gephi 0.8.1", 5 | "description": "", 6 | "_lastmodifieddate": "2014-01-30" 7 | }, 8 | "graph": { 9 | "attributes": { 10 | "attribute": { 11 | "_id": "modularity_class", 12 | "_title": "Modularity Class", 13 | "_type": "integer" 14 | }, 15 | "_class": "node", 16 | "_mode": "static" 17 | }, 18 | "nodes": { 19 | "node": [ 20 | $nodes$ 21 | ] 22 | }, 23 | "edges": { 24 | "edge": [ 25 | $edges$ 26 | ] 27 | }, 28 | "_defaultedgetype": "undirected", 29 | "_mode": "static" 30 | }, 31 | "_xmlns": "http://www.gexf.net/1.2draft", 32 | "_xmlns:viz": "http://www.gexf.net/1.2draft/viz", 33 | "_xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance", 34 | "_version": "1.2", 35 | "_xsi:schemaLocation": "http://www.gexf.net/1.2draft http://www.gexf.net/1.2draft/gexf.xsd" 36 | } 37 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OS X 2 | .DS_Store 3 | 4 | # Xcode 5 | build/ 6 | *.pbxuser 7 | !default.pbxuser 8 | *.mode1v3 9 | !default.mode1v3 10 | *.mode2v3 11 | !default.mode2v3 12 | *.perspectivev3 13 | !default.perspectivev3 14 | xcuserdata/ 15 | *.xccheckout 16 | profile 17 | *.moved-aside 18 | DerivedData 19 | *.hmap 20 | *.ipa 21 | 22 | # Bundler 23 | .bundle 24 | 25 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 26 | # Carthage/Checkouts 27 | 28 | Carthage/Build 29 | 30 | # We recommend against adding the Pods directory to your .gitignore. However 31 | # you should judge for yourself, the pros and cons are mentioned at: 32 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 33 | # 34 | # Note: if you ignore the Pods directory, make sure to uncomment 35 | # `pod install` in .travis.yml 36 | # 37 | Pods/ 38 | 39 | Download/ 40 | Downloadef/ 41 | PROJECT_DIR 42 | 43 | build 44 | dist 45 | dist/ 46 | efpodsanalyzer.egg-info 47 | efpodsanalyzer.egg-info/ 48 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | #-*- coding:utf-8 -*- 3 | 4 | ############################################# 5 | # File Name: setup.py 6 | # Author: EyreFree 7 | # Mail: eyrefree@eyrefree.org 8 | # Created Time: 2019-02-05 15:01:34 PM 9 | ############################################# 10 | 11 | 12 | from setuptools import setup, find_packages 13 | 14 | setup( 15 | name = "efpodsanalyzer", 16 | version = "0.2.6", 17 | keywords = ("pip", "eyrefree", "cocoapods", "analyzer", "efpodsanalyzer"), 18 | description = "CocoaPods dependency analysis tool", 19 | long_description = "CocoaPods dependency analysis tool", 20 | license = "GPLv3 Licence", 21 | 22 | url = "https://github.com/EyreFree/EFPodsAnalyzer", 23 | author = "EyreFree", 24 | author_email = "eyrefree@eyrefree.org", 25 | 26 | packages = find_packages(), 27 | #include_package_data = True, 28 | package_data={ 29 | 'efpodsanalyzer': [ 30 | 'EFPADiagram/*.html', 31 | 'EFPADiagram/js/*', 32 | 'EFPADiagram/css/*', 33 | 'template/*', 34 | 'EFPAConfig.json' 35 | ] 36 | }, 37 | platforms = "any", 38 | install_requires = [], 39 | entry_points={ 40 | 'console_scripts':[ 41 | 'efpodsanalyzer = efpodsanalyzer.efpodsanalyzer:main' 42 | ] 43 | } 44 | ) 45 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | ----- 4 | 5 | ## [0.2.6](https://github.com/EyreFree/EFPodsAnalyzer/releases/tag/0.2.6) (2021-09-12) 6 | 7 | * Fix issue [#5](https://github.com/EyreFree/EFPodsAnalyzer/issues/5). 8 | 9 | --- 10 | 11 | ## [0.2.5](https://github.com/EyreFree/EFPodsAnalyzer/releases/tag/0.2.5) (2021-05-20) 12 | 13 | #### Fix 14 | 15 | * Fix dead loop problem caused by sub dependency without first level reference relationship. 16 | 17 | --- 18 | 19 | ## [0.2.4](https://github.com/EyreFree/EFPodsAnalyzer/releases/tag/0.2.4) (2020-09-11) 20 | 21 | #### Fix 22 | 23 | * Fix `include_package_data`. 24 | 25 | --- 26 | 27 | ## [0.2.3](https://github.com/EyreFree/EFPodsAnalyzer/releases/tag/0.2.3) (2020-09-11) 28 | 29 | #### Fix 30 | 31 | * Fix `ValueError: must have exactly one of create/read/write/append mode`. 32 | 33 | --- 34 | 35 | ## [0.2.2](https://github.com/EyreFree/EFPodsAnalyzer/releases/tag/0.2.2) (2020-09-11) 36 | 37 | #### Add 38 | 39 | * Add default `EFPAConfig.json` if not exist. 40 | 41 | --- 42 | 43 | ## [0.2.1](https://github.com/EyreFree/EFPodsAnalyzer/releases/tag/0.2.1) (2019-02-10) 44 | 45 | #### Fix 46 | 47 | * Fix `style.css`. 48 | 49 | --- 50 | 51 | ## [0.2.0](https://github.com/EyreFree/EFPodsAnalyzer/releases/tag/0.2.0) (2019-02-10) 52 | 53 | #### Add 54 | 55 | * Add reference count; 56 | * Add new style `circular`. 57 | 58 | --- 59 | 60 | ## [0.1.4](https://github.com/EyreFree/EFPodsAnalyzer/releases/tag/0.1.4) (2019-02-07) 61 | 62 | #### Add 63 | 64 | * Wrap with PyPI. 65 | 66 | --- 67 | 68 | ## [0.0.2](https://github.com/EyreFree/EFPodsAnalyzer/releases/tag/0.0.2) (2018-09-12) 69 | 70 | #### Fix 71 | 72 | * Fix dead cycle. 73 | 74 | --- 75 | 76 | ## [0.0.1](https://github.com/EyreFree/EFPodsAnalyzer/releases/tag/0.0.1) (2018-02-09) 77 | 78 | First public release. 79 | -------------------------------------------------------------------------------- /docs/graph_force.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | EFPodsAnalyzer 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /efpodsanalyzer/EFPADiagram/graph_force.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | EFPodsAnalyzer 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | EFPodsAnalyzer | CocoaPods dependency analysis tool. 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 |

28 |

EFPodsAnalyzer is a Python script that is used to help us sort out the CoaoaPods library dependency relationship. The analysis results are as follows:

29 |

Graph

30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 |
IndexDescriptionLink
1Circular layoutgraph_circular.html
2Force layoutgraph_force.html
51 | 55 |
56 | 57 | 58 | -------------------------------------------------------------------------------- /efpodsanalyzer/EFPADiagram/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | EFPodsAnalyzer | CocoaPods dependency analysis tool. 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 |

28 |

EFPodsAnalyzer is a Python script that is used to help us sort out the CoaoaPods library dependency relationship. The analysis results are as follows:

29 |

Graph

30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 |
IndexDescriptionLink
1Circular layoutgraph_circular.html
2Force layoutgraph_force.html
51 | 55 |
56 | 57 | 58 | -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Guidelines 2 | 3 | This document contains information and guidelines about contributing to this project. 4 | Please read it before you start participating. 5 | 6 | **Topics** 7 | 8 | * [Asking Questions](#asking-questions) 9 | * [Reporting Issues](#reporting-issues) 10 | * [Developers Certificate of Origin](#developers-certificate-of-origin) 11 | 12 | ## Asking Questions 13 | 14 | We don't use GitHub as a support forum. 15 | For any usage questions that are not specific to the project itself, 16 | please ask on [Stack Overflow](https://stackoverflow.com) instead. 17 | By doing so, you'll be more likely to quickly solve your problem, 18 | and you'll allow anyone else with the same question to find the answer. 19 | This also allows maintainers to focus on improving the project for others. 20 | 21 | ## Reporting Issues 22 | 23 | A great way to contribute to the project 24 | is to send a detailed issue when you encounter an problem. 25 | We always appreciate a well-written, thorough bug report. 26 | 27 | Check that the project issues database 28 | doesn't already include that problem or suggestion before submitting an issue. 29 | If you find a match, add a quick "+1" or "I have this problem too." 30 | Doing this helps prioritize the most common problems and requests. 31 | 32 | When reporting issues, please include the following: 33 | 34 | * The version of Xcode you're using 35 | * The version of iOS or macOS you're targeting 36 | * The full output of any stack trace or compiler error 37 | * A code snippet that reproduces the described behavior, if applicable 38 | * Any other details that would be useful in understanding the problem 39 | 40 | This information will help us review and fix your issue faster. 41 | 42 | ## Developer's Certificate of Origin 43 | 44 | By making a contribution to this project, I certify that: 45 | 46 | - (a) The contribution was created in whole or in part by me and I 47 | have the right to submit it under the open source license 48 | indicated in the file; or 49 | 50 | - (b) The contribution is based upon previous work that, to the best 51 | of my knowledge, is covered under an appropriate open source 52 | license and I have the right under that license to submit that 53 | work with modifications, whether created in whole or in part 54 | by me, under the same open source license (unless I am 55 | permitted to submit under a different license), as indicated 56 | in the file; or 57 | 58 | - (c) The contribution was provided directly to me by some other 59 | person who certified (a), (b) or (c) and I have not modified 60 | it. 61 | 62 | - (d) I understand and agree that this project and the contribution 63 | are public and that a record of the contribution (including all 64 | personal information I submit with it, including my sign-off) is 65 | maintained indefinitely and may be redistributed consistent with 66 | this project or the open source license(s) involved. 67 | 68 | --- 69 | 70 | *Some of the ideas and wording for the statements above were based on work by the [Alamofire](https://github.com/Alamofire/Alamofire/blob/master/CONTRIBUTING.md) communities. We commend them for their efforts to facilitate collaboration in their projects.* 71 | -------------------------------------------------------------------------------- /docs/graph_circular.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | EFPodsAnalyzer 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /efpodsanalyzer/EFPADiagram/graph_circular.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | EFPodsAnalyzer 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /.github/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. 6 | 7 | ## Our Standards 8 | 9 | Examples of behavior that contributes to creating a positive environment include: 10 | 11 | * Using welcoming and inclusive language 12 | * Being respectful of differing viewpoints and experiences 13 | * Gracefully accepting constructive criticism 14 | * Focusing on what is best for the community 15 | * Showing empathy towards other community members 16 | 17 | Examples of unacceptable behavior by participants include: 18 | 19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | * Trolling, insulting/derogatory comments, and personal or political attacks 21 | * Public or private harassment 22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission 23 | * Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | ## Our Responsibilities 26 | 27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 28 | 29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | ## Scope 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 34 | 35 | ## Enforcement 36 | 37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at eyrefree@eyrefree.org. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. 38 | 39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 40 | 41 | ## Attribution 42 | 43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 44 | 45 | [homepage]: http://contributor-covenant.org 46 | [version]: http://contributor-covenant.org/version/1/4/ 47 | -------------------------------------------------------------------------------- /README_CN.md: -------------------------------------------------------------------------------- 1 | ![](assets/headimage.png) 2 | 3 |

4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 |

26 | 27 | EFPodsAnalyzer 是一个用来帮助我们梳理项目 CoaoaPods 库依赖关系的 Python 脚本,一个命令即可生成清晰的 Pods 依赖关系图,给我们的依赖整理 / 组件清理工作带来一定的帮助(广告:EF 的组件化 / 模块化总结 [蜂鸟商家版 iOS 组件化 / 模块化实践总结](https://juejin.im/post/5a620cf5f265da3e36415764) 望能够给大家提供一些参考)。 28 | 29 | > [English Introduction](/README.md) 30 | 31 | ## 预览 32 | 33 | Pods 库越多、依赖关系越复杂的库,越是用得到本工具,例如模块化后的项目;反之如果项目依赖很少,依赖关系非常简单的话,其实基本不需要本工具(当然你硬是要用我也不拦着)。我司某项目的依赖关系图大致如下,一坨: 34 | 35 | ![](assets/overview.png) 36 | 37 | ## 环境 38 | 39 | - Python 2.7 40 | 41 | ## 安装 42 | 43 | ### PyPI 44 | 45 | 如果你的设备上已经安装了 [pip](https://github.com/pypa/pip) 的话,可以使用如下命令直接安装本工具的最新版: 46 | 47 | ``` 48 | sudo pip install efpodsanalyzer --upgrade 49 | ``` 50 | 51 | ### 手动 52 | 53 | 下载本仓库,或执行如下命令将本仓库 Clone 到本地: 54 | 55 | ``` 56 | git clone git@github.com:EyreFree/EFPodsAnalyzer.git 57 | ``` 58 | 59 | ## 使用 60 | 61 | ### PyPI 62 | 63 | 1. 首先确保你的工程已进行 `pod install` 操作并成功生成了 Pods 目录; 64 | 2. 利用 pip 完成本工具 efpodsanalyzer 的安装; 65 | 3. 根据待分析项目的具体情况对依赖的库进行分类,并分别给出每个分类的正则对依赖的名称进行归类,然后将分类规则写到你的 Podfile 所在目录下的 `EFPAConfig.json` 文件中(EFPAConfig.json 结构参考下面的示例); 66 | 4. 执行如下命令进行依赖关系图的生成: 67 | 68 | ``` 69 | sudo efpodsanalyzer [待分析项目的 Podfile 文件路径] 70 | ``` 71 | 72 | 5. 查看终端的输出,若有看到如下日志表示生成完成,可用浏览器打开生成的关系图文件 `index.html`,即可进行浏览: 73 | 74 | ``` 75 | Dependency graph generated: .../EFPADiagram/index.html 76 | ``` 77 | 78 | 若抛错的话请根据对应的错误信息进行处理,有其他问题欢迎 PR 或 Issue。 79 | 80 | ### 手动 81 | 82 | 1. 首先确保你的工程已进行 `pod install` 操作并成功生成了 Pods 目录; 83 | 2. 本仓库内容已完整下载到本地; 84 | 3. 根据待分析项目的具体情况对依赖的库进行分类,并分别给出每个分类的正则对依赖的名称进行归类,然后将分类规则写到你的 Podfile 所在目录下的 `EFPAConfig.json` 文件中(EFPAConfig.json 结构参考下面的示例); 85 | 4. 执行如下命令进行依赖关系图的生成: 86 | 87 | ``` 88 | python [EFPodsAnalyzer.py 文件路径] [待分析项目的 Podfile 文件路径] 89 | ``` 90 | 91 | 5. 查看终端的输出,若有看到如下日志表示生成完成,可用浏览器打开生成的关系图文件 `index.html`,即可进行浏览: 92 | 93 | ``` 94 | Dependency graph generated: .../EFPADiagram/index.html 95 | ``` 96 | 97 | 若抛错的话请根据对应的错误信息进行处理,有其他问题欢迎 PR 或 Issue。 98 | 99 | ## 示例 100 | 101 | 这里我们以 [Coding 的开源 iOS 客户端](https://github.com/Coding/Coding-iOS) 为例,给大家演示一下完整的使用过程: 102 | 103 | 1. 利用 pip 完成本工具 efpodsanalyzer 的安装; 104 | 2. 然后下载 Coding iOS 端工程到本地,并进行 `pod install` 操作; 105 | 3. 因为这里 Coding 客户端的依赖基本没啥可归类的,都是第三方库;所以出于演示目的,这里我分为了「以 M 开头的库」、「以 Kit 结尾的库」和「其它」三类,对应的 `EFPAConfig.json` 如下(你也可以 [点击此处](/efpodsanalyzer/EFPAConfig.json) 在线查看配置文件示例): 106 | 107 | ``` 108 | { 109 | "config": { 110 | "categories": ["以 M 开头的库", "以 Kit 结尾的库", "其它"], 111 | "categoryRegexes": ["^M.*", ".*(Kit)$", ".*"] 112 | } 113 | } 114 | ``` 115 | 116 | 4. 关系图生成的命令如下: 117 | 118 | ``` 119 | sudo efpodsanalyzer /Users/eyrefree/Documents/iOS_GitHub/Coding-iOS/Podfile 120 | ``` 121 | 122 | 5. 最后生成的依赖关系图如下,你可以进行 [在线预览](https://eyrefree.github.io/EFPodsAnalyzer/docs/graph_force.html): 123 | 124 | ![](assets/example.png) 125 | 126 | - 点击上方的类目名可控制该类的显示和隐藏; 127 | - 鼠标悬浮于节点上可显示节点名; 128 | - 鼠标悬浮于两点之间的连线上可显示两节点之间的依赖关系。 129 | 130 | 另一种样式 `circular`,如下图所示,同样可以 [在线预览](https://eyrefree.github.io/EFPodsAnalyzer/docs/graph_circular.html): 131 | 132 | ![](assets/example_circular.png) 133 | 134 | ## 计划 135 | 136 | - 根据头文件引用进一步判断依赖是否需要移除; 137 | - 根据类依赖关系进一步判断依赖是否需要移除; 138 | - 支持更多关系图样式。 139 | 140 | ## 其它 141 | 142 | 1. 依赖图的展示使用了 [ECharts](https://github.com/ecomfe/echarts) 图表库和 [xml2json](https://github.com/abdmob/x2js) 解析库,在此对这些项目的开发人员表示感谢! 143 | 2. 本仓库代码可使用如下命令打包 / 发布,有二次开发需求的同学可自行摸索(请在本仓库根目录下执行): 144 | 145 | ``` 146 | rm -rf dist/*; 147 | python setup.py sdist bdist_wheel; 148 | twine upload dist/efpodsanalyzer*; 149 | ``` 150 | 151 | ## 作者 152 | 153 | EyreFree, eyrefree@eyrefree.org 154 | 155 | ## 协议 156 | 157 | ![](https://www.gnu.org/graphics/gplv3-127x51.png) 158 | 159 | EFPodsAnalyzer 基于 GPLv3 协议进行分发和使用,更多信息参见协议文件。 160 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![](assets/headimage.png) 2 | 3 |

4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 |

26 | 27 | EFPodsAnalyzer is a Python script that is used to help us sort out the CoaoaPods library dependency relationship. It can generate clear Pods dependency graph with only one command, which will help us in dependency sorting / component cleaning. 28 | 29 | > [中文介绍](/README_CN.md) 30 | 31 | ## Preview 32 | 33 | The more the Pods library is, the more complex the library is, the more it is used to get the tool, for example, the modularized item; conversely, if the project dependency is very few and the dependency relation is very simple, there is no need for this tool. The dependency graph of a project of our company is as follows, looks like a shit: 34 | 35 | ![](assets/overview.png) 36 | 37 | ## Requirements 38 | 39 | - Python 2.7 40 | 41 | ## Installation 42 | 43 | ### PyPI 44 | 45 | If you have [pip](https://github.com/pypa/pip) installed on your device, you can install the latest version of this tool directly with the following commands: 46 | 47 | ``` 48 | sudo pip install efpodsanalyzer --upgrade 49 | ``` 50 | 51 | ### Manual 52 | 53 | Download this project, or execute the following commands to Clone this project: 54 | 55 | ``` 56 | git clone git@github.com:EyreFree/EFPodsAnalyzer.git 57 | ``` 58 | 59 | ## Usage 60 | 61 | ### PyPI 62 | 63 | 1. First, ensure that your project has been operated on `pod install` and successfully generated the Pods directory; 64 | 2. Install `efpodsanalyzer` on your device with `pip`; 65 | 3. Classify the dependent libraries according to the specific circumstances of the projects to be analyzed, and give the regex of each category separately, then write the rules to the `EFPAConfig.json` file under the directory which contains the target `Podfile`; 66 | 4. Execute the following commands for the generation of the dependency graph: 67 | 68 | ``` 69 | sudo efpodsanalyzer [Target Podfile file path] 70 | ``` 71 | 72 | 5. You can check the output of the terminal. If you see the following log, you can open the generated file `index.html` in the path with your browser: 73 | 74 | ``` 75 | Dependency graph generated: .../EFPADiagram/index.html 76 | ``` 77 | 78 | If there is any error, please deal with the corresponding error information, or you can make a PR or an Issue. 79 | 80 | ### Manual 81 | 82 | 1. First, ensure that your project has been operated on `pod install` and successfully generated the Pods directory; 83 | 2. The content of this tool has been fully downloaded to the local area; 84 | 3. Classify the dependent libraries according to the specific circumstances of the projects to be analyzed, and give the regex of each category separately, then write the rules to the `EFPAConfig.json` file under the directory which contains the target `Podfile`; 85 | 4. Execute the following commands for the generation of the dependency graph: 86 | 87 | ``` 88 | python [EFPodsAnalyzer.py file path] [Target Podfile file path] 89 | ``` 90 | 91 | 5. You can check the output of the terminal. If you see the following log, you can open the generated file `index.html` in the path with your browser: 92 | 93 | ``` 94 | Dependency graph generated: .../EFPADiagram/index.html 95 | ``` 96 | 97 | If there is any error, please deal with the corresponding error information, or you can make a PR or an Issue. 98 | 99 | ## Example 100 | 101 | Here we take [Coding's open source iOS client](https://github.com/Coding/Coding-iOS) as an example to show you the complete use of this tool: 102 | 103 | 1. First, install `efpodsanalyzer` on your device with `pip`. 104 | 2. Then download the Coding iOS project to local, and perform `pod install` operation; 105 | 3. Because the dependency of the Coding client is basically not classified, which is all the third party library. Therefore, for demonstration purposes, I divide it into three categories: the library with the beginning of 'M', the library ending with 'Kit' and the others. The `EFPAConfig.json` is as follows(You can also [click here](/efpodsanalyzer/EFPAConfig.json) to see the sample file online): 106 | 107 | ``` 108 | { 109 | "config": { 110 | "categories": ["M-prefixed Libraries", "Library ending with Kit", "Other"], 111 | "categoryRegexes": ["^M.*", ".*(Kit)$", ".*"] 112 | } 113 | } 114 | ``` 115 | 116 | 4. The command to generate diagram is as follows: 117 | 118 | ``` 119 | sudo efpodsanalyzer /Users/eyrefree/Documents/iOS_GitHub/Coding-iOS/Podfile 120 | ``` 121 | 122 | 5. The final dependency graph is generated as follows, you can also [view it online](https://eyrefree.github.io/EFPodsAnalyzer/docs/graph_force.html): 123 | 124 | ![](assets/example.png) 125 | 126 | - Clicking on the top class name can control the display and hiding of the class; 127 | - The mouse can be suspended on the node to display the node name; 128 | - The mouse can be suspended on the line between two nodes to display the relationship of them. 129 | 130 | Another style `circular`, as follows, you can [view it online](https://eyrefree.github.io/EFPodsAnalyzer/docs/graph_circular.html) too: 131 | 132 | ![](assets/example_circular.png) 133 | 134 | ## Todo 135 | 136 | - Determine whether the dependency needs to be removed, according to the header file reference; 137 | - Determine whether the dependency needs to be removed, depending on the class dependency; 138 | - More style of diagrams. 139 | 140 | ## Other 141 | 142 | 1. The view of dependency graph is based on [ECharts](https://github.com/ecomfe/echarts) and [xml2json](https://github.com/abdmob/x2js), thanks for their work! 143 | 2. Code of this tool can be packaged / released using the following commands. People who needs to build a custom version can make some self exploration(Under the root directory of this project): 144 | 145 | ``` 146 | rm -rf dist/*; 147 | python setup.py sdist bdist_wheel; 148 | twine upload dist/efpodsanalyzer*; 149 | ``` 150 | 151 | ## Author 152 | 153 | EyreFree, eyrefree@eyrefree.org 154 | 155 | ## License 156 | 157 | ![](https://www.gnu.org/graphics/gplv3-127x51.png) 158 | 159 | EFPodsAnalyzer is available under the GPLv3 license. See the LICENSE file for more info. 160 | -------------------------------------------------------------------------------- /docs/js/xml2json.min.js: -------------------------------------------------------------------------------- 1 | (function(a,b){if(typeof define==="function"&&define.amd){define([],b);}else{if(typeof exports==="object"){module.exports=b();}else{a.X2JS=b();}}}(this,function(){return function(z){var t="1.2.0";z=z||{};i();u();function i(){if(z.escapeMode===undefined){z.escapeMode=true;}z.attributePrefix=z.attributePrefix||"_";z.arrayAccessForm=z.arrayAccessForm||"none";z.emptyNodeForm=z.emptyNodeForm||"text";if(z.enableToStringFunc===undefined){z.enableToStringFunc=true;}z.arrayAccessFormPaths=z.arrayAccessFormPaths||[];if(z.skipEmptyTextNodesForObj===undefined){z.skipEmptyTextNodesForObj=true;}if(z.stripWhitespaces===undefined){z.stripWhitespaces=true;}z.datetimeAccessFormPaths=z.datetimeAccessFormPaths||[];if(z.useDoubleQuotes===undefined){z.useDoubleQuotes=false;}z.xmlElementsFilter=z.xmlElementsFilter||[];z.jsonPropertiesFilter=z.jsonPropertiesFilter||[];if(z.keepCData===undefined){z.keepCData=false;}}var h={ELEMENT_NODE:1,TEXT_NODE:3,CDATA_SECTION_NODE:4,COMMENT_NODE:8,DOCUMENT_NODE:9};function u(){}function x(B){var C=B.localName;if(C==null){C=B.baseName;}if(C==null||C==""){C=B.nodeName;}return C;}function r(B){return B.prefix;}function s(B){if(typeof(B)=="string"){return B.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'");}else{return B;}}function k(B){return B.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/&/g,"&");}function w(C,F,D,E){var B=0;for(;B0){if(w(z.arrayAccessFormPaths,D,B,C)){D[B]=[D[B]];}}}function a(G){var E=G.split(/[-T:+Z]/g);var F=new Date(E[0],E[1]-1,E[2]);var D=E[5].split(".");F.setHours(E[3],E[4],D[0]);if(D.length>1){F.setMilliseconds(D[1]);}if(E[6]&&E[7]){var C=E[6]*60+Number(E[7]);var B=/\d\d-\d\d:\d\d$/.test(G)?"-":"+";C=0+(B=="-"?-1*C:C);F.setMinutes(F.getMinutes()-C-F.getTimezoneOffset());}else{if(G.indexOf("Z",G.length-1)!==-1){F=new Date(Date.UTC(F.getFullYear(),F.getMonth(),F.getDate(),F.getHours(),F.getMinutes(),F.getSeconds(),F.getMilliseconds()));}}return F;}function q(D,B,C){if(z.datetimeAccessFormPaths.length>0){var E=C.split(".#")[0];if(w(z.datetimeAccessFormPaths,D,B,E)){return a(D);}else{return D;}}else{return D;}}function b(E,C,B,D){if(C==h.ELEMENT_NODE&&z.xmlElementsFilter.length>0){return w(z.xmlElementsFilter,E,B,D);}else{return true;}}function A(D,J){if(D.nodeType==h.DOCUMENT_NODE){var K=new Object;var B=D.childNodes;for(var L=0;L1&&K.__text!=null&&z.skipEmptyTextNodesForObj){if((z.stripWhitespaces&&K.__text=="")||(K.__text.trim()=="")){delete K.__text;}}}}}delete K.__cnt;if(z.enableToStringFunc&&(K.__text!=null||K.__cdata!=null)){K.toString=function(){return(this.__text!=null?this.__text:"")+(this.__cdata!=null?this.__cdata:"");};}return K;}else{if(D.nodeType==h.TEXT_NODE||D.nodeType==h.CDATA_SECTION_NODE){return D.nodeValue;}}}}function o(I,F,H,C){var E="<"+((I!=null&&I.__prefix!=null)?(I.__prefix+":"):"")+F;if(H!=null){for(var G=0;G";}function v(C,B){return C.indexOf(B,C.length-B.length)!==-1;}function y(C,B){if((z.arrayAccessForm=="property"&&v(B.toString(),("_asArray")))||B.toString().indexOf(z.attributePrefix)==0||B.toString().indexOf("__")==0||(C[B] instanceof Function)){return true;}else{return false;}}function m(D){var C=0;if(D instanceof Object){for(var B in D){if(y(D,B)){continue;}C++;}}return C;}function l(D,B,C){return z.jsonPropertiesFilter.length==0||C==""||w(z.jsonPropertiesFilter,D,B,C);}function c(D){var C=[];if(D instanceof Object){for(var B in D){if(B.toString().indexOf("__")==-1&&B.toString().indexOf(z.attributePrefix)==0){C.push(B);}}}return C;}function g(C){var B="";if(C.__cdata!=null){B+="";}if(C.__text!=null){if(z.escapeMode){B+=s(C.__text);}else{B+=C.__text;}}return B;}function d(C){var B="";if(C instanceof Object){B+=g(C);}else{if(C!=null){if(z.escapeMode){B+=s(C);}else{B+=C;}}}return B;}function p(C,B){if(C===""){return B;}else{return C+"."+B;}}function f(D,G,F,E){var B="";if(D.length==0){B+=o(D,G,F,true);}else{for(var C=0;C0){for(var E in I){if(y(I,E)||(H!=""&&!l(I,E,p(H,E)))){continue;}var D=I[E];var G=c(D);if(D==null||D==undefined){B+=o(D,E,G,true);}else{if(D instanceof Object){if(D instanceof Array){B+=f(D,E,G,H);}else{if(D instanceof Date){B+=o(D,E,G,false);B+=D.toISOString();B+=j(D,E);}else{var C=m(D);if(C>0||D.__text!=null||D.__cdata!=null){B+=o(D,E,G,false);B+=e(D,p(H,E));B+=j(D,E);}else{B+=o(D,E,G,true);}}}}else{B+=o(D,E,G,false);B+=d(D);B+=j(D,E);}}}}B+=d(I);return B;}this.parseXmlString=function(D){var F=window.ActiveXObject||"ActiveXObject" in window;if(D===undefined){return null;}var E;if(window.DOMParser){var G=new window.DOMParser();var B=null;if(!F){try{B=G.parseFromString("INVALID","text/xml").getElementsByTagName("parsererror")[0].namespaceURI;}catch(C){B=null;}}try{E=G.parseFromString(D,"text/xml");if(B!=null&&E.getElementsByTagNameNS(B,"parsererror").length>0){E=null;}}catch(C){E=null;}}else{if(D.indexOf("")+2);}E=new ActiveXObject("Microsoft.XMLDOM");E.async="false";E.loadXML(D);}return E;};this.asArray=function(B){if(B===undefined||B==null){return[];}else{if(B instanceof Array){return B;}else{return[B];}}};this.toXmlDateTime=function(B){if(B instanceof Date){return B.toISOString();}else{if(typeof(B)==="number"){return new Date(B).toISOString();}else{return null;}}};this.asDateTime=function(B){if(typeof(B)=="string"){return a(B);}else{return B;}};this.xml2json=function(B){return A(B);};this.xml_str2json=function(B){var C=this.parseXmlString(B);if(C!=null){return this.xml2json(C);}else{return null;}};this.json2xml_str=function(B){return e(B,"");};this.json2xml=function(C){var B=this.json2xml_str(C);return this.parseXmlString(B);};this.getVersion=function(){return t;};};})); -------------------------------------------------------------------------------- /efpodsanalyzer/EFPADiagram/js/xml2json.min.js: -------------------------------------------------------------------------------- 1 | (function(a,b){if(typeof define==="function"&&define.amd){define([],b);}else{if(typeof exports==="object"){module.exports=b();}else{a.X2JS=b();}}}(this,function(){return function(z){var t="1.2.0";z=z||{};i();u();function i(){if(z.escapeMode===undefined){z.escapeMode=true;}z.attributePrefix=z.attributePrefix||"_";z.arrayAccessForm=z.arrayAccessForm||"none";z.emptyNodeForm=z.emptyNodeForm||"text";if(z.enableToStringFunc===undefined){z.enableToStringFunc=true;}z.arrayAccessFormPaths=z.arrayAccessFormPaths||[];if(z.skipEmptyTextNodesForObj===undefined){z.skipEmptyTextNodesForObj=true;}if(z.stripWhitespaces===undefined){z.stripWhitespaces=true;}z.datetimeAccessFormPaths=z.datetimeAccessFormPaths||[];if(z.useDoubleQuotes===undefined){z.useDoubleQuotes=false;}z.xmlElementsFilter=z.xmlElementsFilter||[];z.jsonPropertiesFilter=z.jsonPropertiesFilter||[];if(z.keepCData===undefined){z.keepCData=false;}}var h={ELEMENT_NODE:1,TEXT_NODE:3,CDATA_SECTION_NODE:4,COMMENT_NODE:8,DOCUMENT_NODE:9};function u(){}function x(B){var C=B.localName;if(C==null){C=B.baseName;}if(C==null||C==""){C=B.nodeName;}return C;}function r(B){return B.prefix;}function s(B){if(typeof(B)=="string"){return B.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'");}else{return B;}}function k(B){return B.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/&/g,"&");}function w(C,F,D,E){var B=0;for(;B0){if(w(z.arrayAccessFormPaths,D,B,C)){D[B]=[D[B]];}}}function a(G){var E=G.split(/[-T:+Z]/g);var F=new Date(E[0],E[1]-1,E[2]);var D=E[5].split(".");F.setHours(E[3],E[4],D[0]);if(D.length>1){F.setMilliseconds(D[1]);}if(E[6]&&E[7]){var C=E[6]*60+Number(E[7]);var B=/\d\d-\d\d:\d\d$/.test(G)?"-":"+";C=0+(B=="-"?-1*C:C);F.setMinutes(F.getMinutes()-C-F.getTimezoneOffset());}else{if(G.indexOf("Z",G.length-1)!==-1){F=new Date(Date.UTC(F.getFullYear(),F.getMonth(),F.getDate(),F.getHours(),F.getMinutes(),F.getSeconds(),F.getMilliseconds()));}}return F;}function q(D,B,C){if(z.datetimeAccessFormPaths.length>0){var E=C.split(".#")[0];if(w(z.datetimeAccessFormPaths,D,B,E)){return a(D);}else{return D;}}else{return D;}}function b(E,C,B,D){if(C==h.ELEMENT_NODE&&z.xmlElementsFilter.length>0){return w(z.xmlElementsFilter,E,B,D);}else{return true;}}function A(D,J){if(D.nodeType==h.DOCUMENT_NODE){var K=new Object;var B=D.childNodes;for(var L=0;L1&&K.__text!=null&&z.skipEmptyTextNodesForObj){if((z.stripWhitespaces&&K.__text=="")||(K.__text.trim()=="")){delete K.__text;}}}}}delete K.__cnt;if(z.enableToStringFunc&&(K.__text!=null||K.__cdata!=null)){K.toString=function(){return(this.__text!=null?this.__text:"")+(this.__cdata!=null?this.__cdata:"");};}return K;}else{if(D.nodeType==h.TEXT_NODE||D.nodeType==h.CDATA_SECTION_NODE){return D.nodeValue;}}}}function o(I,F,H,C){var E="<"+((I!=null&&I.__prefix!=null)?(I.__prefix+":"):"")+F;if(H!=null){for(var G=0;G";}function v(C,B){return C.indexOf(B,C.length-B.length)!==-1;}function y(C,B){if((z.arrayAccessForm=="property"&&v(B.toString(),("_asArray")))||B.toString().indexOf(z.attributePrefix)==0||B.toString().indexOf("__")==0||(C[B] instanceof Function)){return true;}else{return false;}}function m(D){var C=0;if(D instanceof Object){for(var B in D){if(y(D,B)){continue;}C++;}}return C;}function l(D,B,C){return z.jsonPropertiesFilter.length==0||C==""||w(z.jsonPropertiesFilter,D,B,C);}function c(D){var C=[];if(D instanceof Object){for(var B in D){if(B.toString().indexOf("__")==-1&&B.toString().indexOf(z.attributePrefix)==0){C.push(B);}}}return C;}function g(C){var B="";if(C.__cdata!=null){B+="";}if(C.__text!=null){if(z.escapeMode){B+=s(C.__text);}else{B+=C.__text;}}return B;}function d(C){var B="";if(C instanceof Object){B+=g(C);}else{if(C!=null){if(z.escapeMode){B+=s(C);}else{B+=C;}}}return B;}function p(C,B){if(C===""){return B;}else{return C+"."+B;}}function f(D,G,F,E){var B="";if(D.length==0){B+=o(D,G,F,true);}else{for(var C=0;C0){for(var E in I){if(y(I,E)||(H!=""&&!l(I,E,p(H,E)))){continue;}var D=I[E];var G=c(D);if(D==null||D==undefined){B+=o(D,E,G,true);}else{if(D instanceof Object){if(D instanceof Array){B+=f(D,E,G,H);}else{if(D instanceof Date){B+=o(D,E,G,false);B+=D.toISOString();B+=j(D,E);}else{var C=m(D);if(C>0||D.__text!=null||D.__cdata!=null){B+=o(D,E,G,false);B+=e(D,p(H,E));B+=j(D,E);}else{B+=o(D,E,G,true);}}}}else{B+=o(D,E,G,false);B+=d(D);B+=j(D,E);}}}}B+=d(I);return B;}this.parseXmlString=function(D){var F=window.ActiveXObject||"ActiveXObject" in window;if(D===undefined){return null;}var E;if(window.DOMParser){var G=new window.DOMParser();var B=null;if(!F){try{B=G.parseFromString("INVALID","text/xml").getElementsByTagName("parsererror")[0].namespaceURI;}catch(C){B=null;}}try{E=G.parseFromString(D,"text/xml");if(B!=null&&E.getElementsByTagNameNS(B,"parsererror").length>0){E=null;}}catch(C){E=null;}}else{if(D.indexOf("")+2);}E=new ActiveXObject("Microsoft.XMLDOM");E.async="false";E.loadXML(D);}return E;};this.asArray=function(B){if(B===undefined||B==null){return[];}else{if(B instanceof Array){return B;}else{return[B];}}};this.toXmlDateTime=function(B){if(B instanceof Date){return B.toISOString();}else{if(typeof(B)==="number"){return new Date(B).toISOString();}else{return null;}}};this.asDateTime=function(B){if(typeof(B)=="string"){return a(B);}else{return B;}};this.xml2json=function(B){return A(B);};this.xml_str2json=function(B){var C=this.parseXmlString(B);if(C!=null){return this.xml2json(C);}else{return null;}};this.json2xml_str=function(B){return e(B,"");};this.json2xml=function(C){var B=this.json2xml_str(C);return this.parseXmlString(B);};this.getVersion=function(){return t;};};})); -------------------------------------------------------------------------------- /docs/css/style.css: -------------------------------------------------------------------------------- 1 | /*! normalize.css v3.0.2 | MIT License | git.io/normalize */@import url("https://fonts.googleapis.com/css?family=Open+Sans:400,700");html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background-color:transparent}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:bold}dfn{font-style:italic}h1{font-size:2em;margin:0.67em 0}mark{background:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{box-sizing:content-box;height:0}pre{overflow:auto}code,kbd,pre,samp{font-family:monospace, monospace;font-size:1em}button,input,optgroup,select,textarea{color:inherit;font:inherit;margin:0}button{overflow:visible}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}input{line-height:normal}input[type="checkbox"],input[type="radio"]{box-sizing:border-box;padding:0}input[type="number"]::-webkit-inner-spin-button,input[type="number"]::-webkit-outer-spin-button{height:auto}input[type="search"]{-webkit-appearance:textfield;box-sizing:content-box}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}fieldset{border:1px solid #c0c0c0;margin:0 2px;padding:0.35em 0.625em 0.75em}legend{border:0;padding:0}textarea{overflow:auto}optgroup{font-weight:bold}table{border-collapse:collapse;border-spacing:0}td,th{padding:0}.highlight table td{padding:5px}.highlight table pre{margin:0}.highlight .cm{color:#999988;font-style:italic}.highlight .cp{color:#999999;font-weight:bold}.highlight .c1{color:#999988;font-style:italic}.highlight .cs{color:#999999;font-weight:bold;font-style:italic}.highlight .c,.highlight .cd{color:#999988;font-style:italic}.highlight .err{color:#a61717;background-color:#e3d2d2}.highlight .gd{color:#000000;background-color:#ffdddd}.highlight .ge{color:#000000;font-style:italic}.highlight .gr{color:#aa0000}.highlight .gh{color:#999999}.highlight .gi{color:#000000;background-color:#ddffdd}.highlight .go{color:#888888}.highlight .gp{color:#555555}.highlight .gs{font-weight:bold}.highlight .gu{color:#aaaaaa}.highlight .gt{color:#aa0000}.highlight .kc{color:#000000;font-weight:bold}.highlight .kd{color:#000000;font-weight:bold}.highlight .kn{color:#000000;font-weight:bold}.highlight .kp{color:#000000;font-weight:bold}.highlight .kr{color:#000000;font-weight:bold}.highlight .kt{color:#445588;font-weight:bold}.highlight .k,.highlight .kv{color:#000000;font-weight:bold}.highlight .mf{color:#009999}.highlight .mh{color:#009999}.highlight .il{color:#009999}.highlight .mi{color:#009999}.highlight .mo{color:#009999}.highlight .m,.highlight .mb,.highlight .mx{color:#009999}.highlight .sb{color:#d14}.highlight .sc{color:#d14}.highlight .sd{color:#d14}.highlight .s2{color:#d14}.highlight .se{color:#d14}.highlight .sh{color:#d14}.highlight .si{color:#d14}.highlight .sx{color:#d14}.highlight .sr{color:#009926}.highlight .s1{color:#d14}.highlight .ss{color:#990073}.highlight .s{color:#d14}.highlight .na{color:#008080}.highlight .bp{color:#999999}.highlight .nb{color:#0086B3}.highlight .nc{color:#445588;font-weight:bold}.highlight .no{color:#008080}.highlight .nd{color:#3c5d5d;font-weight:bold}.highlight .ni{color:#800080}.highlight .ne{color:#990000;font-weight:bold}.highlight .nf{color:#990000;font-weight:bold}.highlight .nl{color:#990000;font-weight:bold}.highlight .nn{color:#555555}.highlight .nt{color:#000080}.highlight .vc{color:#008080}.highlight .vg{color:#008080}.highlight .vi{color:#008080}.highlight .nv{color:#008080}.highlight .ow{color:#000000;font-weight:bold}.highlight .o{color:#000000;font-weight:bold}.highlight .w{color:#bbbbbb}.highlight{background-color:#f8f8f8}*{box-sizing:border-box}body{padding:0;margin:0;font-family:"Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;font-size:16px;line-height:1.5;color:#606c71}a{color:#1e6bb8;text-decoration:none}a:hover{text-decoration:underline}.btn{display:inline-block;margin-bottom:1rem;color:rgba(255,255,255,0.7);background-color:rgba(255,255,255,0.08);border-color:rgba(255,255,255,0.2);border-style:solid;border-width:1px;border-radius:0.3rem;transition:color 0.2s, background-color 0.2s, border-color 0.2s}.btn:hover{color:rgba(255,255,255,0.8);text-decoration:none;background-color:rgba(255,255,255,0.2);border-color:rgba(255,255,255,0.3)}.btn+.btn{margin-left:1rem}@media screen and (min-width: 64em){.btn{padding:0.75rem 1rem}}@media screen and (min-width: 42em) and (max-width: 64em){.btn{padding:0.6rem 0.9rem;font-size:0.9rem}}@media screen and (max-width: 42em){.btn{display:block;width:100%;padding:0.75rem;font-size:0.9rem}.btn+.btn{margin-top:1rem;margin-left:0}}.page-header{color:#fff;text-align:center;background-color:#159957;background-image:linear-gradient(120deg, #155799, #159957)}@media screen and (min-width: 64em){.page-header{padding:5rem 6rem}}@media screen and (min-width: 42em) and (max-width: 64em){.page-header{padding:3rem 4rem}}@media screen and (max-width: 42em){.page-header{padding:2rem 1rem}}.project-name{margin-top:0;margin-bottom:0.1rem}@media screen and (min-width: 64em){.project-name{font-size:3.25rem}}@media screen and (min-width: 42em) and (max-width: 64em){.project-name{font-size:2.25rem}}@media screen and (max-width: 42em){.project-name{font-size:1.75rem}}.project-tagline{margin-bottom:2rem;font-weight:normal;opacity:0.7}@media screen and (min-width: 64em){.project-tagline{font-size:1.25rem}}@media screen and (min-width: 42em) and (max-width: 64em){.project-tagline{font-size:1.15rem}}@media screen and (max-width: 42em){.project-tagline{font-size:1rem}}.main-content{word-wrap:break-word}.main-content :first-child{margin-top:0}@media screen and (min-width: 64em){.main-content{max-width:64rem;padding:2rem 6rem;margin:0 auto;font-size:1.1rem}}@media screen and (min-width: 42em) and (max-width: 64em){.main-content{padding:2rem 4rem;font-size:1.1rem}}@media screen and (max-width: 42em){.main-content{padding:2rem 1rem;font-size:1rem}}.main-content img{max-width:100%}.main-content h1,.main-content h2,.main-content h3,.main-content h4,.main-content h5,.main-content h6{margin-top:2rem;margin-bottom:1rem;font-weight:normal;color:#159957}.main-content p{margin-bottom:1em}.main-content code{padding:2px 4px;font-family:Consolas, "Liberation Mono", Menlo, Courier, monospace;font-size:0.9rem;color:#567482;background-color:#f3f6fa;border-radius:0.3rem}.main-content pre{padding:0.8rem;margin-top:0;margin-bottom:1rem;font:1rem Consolas, "Liberation Mono", Menlo, Courier, monospace;color:#567482;word-wrap:normal;background-color:#f3f6fa;border:solid 1px #dce6f0;border-radius:0.3rem}.main-content pre>code{padding:0;margin:0;font-size:0.9rem;color:#567482;word-break:normal;white-space:pre;background:transparent;border:0}.main-content .highlight{margin-bottom:1rem}.main-content .highlight pre{margin-bottom:0;word-break:normal}.main-content .highlight pre,.main-content pre{padding:0.8rem;overflow:auto;font-size:0.9rem;line-height:1.45;border-radius:0.3rem;-webkit-overflow-scrolling:touch}.main-content pre code,.main-content pre tt{display:inline;max-width:initial;padding:0;margin:0;overflow:initial;line-height:inherit;word-wrap:normal;background-color:transparent;border:0}.main-content pre code:before,.main-content pre code:after,.main-content pre tt:before,.main-content pre tt:after{content:normal}.main-content ul,.main-content ol{margin-top:0}.main-content blockquote{padding:0 1rem;margin-left:0;color:#819198;border-left:0.3rem solid #dce6f0}.main-content blockquote>:first-child{margin-top:0}.main-content blockquote>:last-child{margin-bottom:0}.main-content table{display:block;width:100%;overflow:auto;word-break:normal;word-break:keep-all;-webkit-overflow-scrolling:touch}.main-content table th{font-weight:bold}.main-content table th,.main-content table td{padding:0.5rem 1rem;border:1px solid #e9ebec}.main-content dl{padding:0}.main-content dl dt{padding:0;margin-top:1rem;font-size:1rem;font-weight:bold}.main-content dl dd{padding:0;margin-bottom:1rem}.main-content hr{height:2px;padding:0;margin:1rem 0;background-color:#eff0f1;border:0}.site-footer{padding-top:2rem;margin-top:2rem;border-top:solid 1px #eff0f1}@media screen and (min-width: 64em){.site-footer{font-size:1rem}}@media screen and (min-width: 42em) and (max-width: 64em){.site-footer{font-size:1rem}}@media screen and (max-width: 42em){.site-footer{font-size:0.9rem}}.site-footer-owner{display:block;font-weight:bold}.site-footer-credits{color:#819198} -------------------------------------------------------------------------------- /efpodsanalyzer/EFPADiagram/css/style.css: -------------------------------------------------------------------------------- 1 | /*! normalize.css v3.0.2 | MIT License | git.io/normalize */@import url("https://fonts.googleapis.com/css?family=Open+Sans:400,700");html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background-color:transparent}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:bold}dfn{font-style:italic}h1{font-size:2em;margin:0.67em 0}mark{background:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{box-sizing:content-box;height:0}pre{overflow:auto}code,kbd,pre,samp{font-family:monospace, monospace;font-size:1em}button,input,optgroup,select,textarea{color:inherit;font:inherit;margin:0}button{overflow:visible}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}input{line-height:normal}input[type="checkbox"],input[type="radio"]{box-sizing:border-box;padding:0}input[type="number"]::-webkit-inner-spin-button,input[type="number"]::-webkit-outer-spin-button{height:auto}input[type="search"]{-webkit-appearance:textfield;box-sizing:content-box}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}fieldset{border:1px solid #c0c0c0;margin:0 2px;padding:0.35em 0.625em 0.75em}legend{border:0;padding:0}textarea{overflow:auto}optgroup{font-weight:bold}table{border-collapse:collapse;border-spacing:0}td,th{padding:0}.highlight table td{padding:5px}.highlight table pre{margin:0}.highlight .cm{color:#999988;font-style:italic}.highlight .cp{color:#999999;font-weight:bold}.highlight .c1{color:#999988;font-style:italic}.highlight .cs{color:#999999;font-weight:bold;font-style:italic}.highlight .c,.highlight .cd{color:#999988;font-style:italic}.highlight .err{color:#a61717;background-color:#e3d2d2}.highlight .gd{color:#000000;background-color:#ffdddd}.highlight .ge{color:#000000;font-style:italic}.highlight .gr{color:#aa0000}.highlight .gh{color:#999999}.highlight .gi{color:#000000;background-color:#ddffdd}.highlight .go{color:#888888}.highlight .gp{color:#555555}.highlight .gs{font-weight:bold}.highlight .gu{color:#aaaaaa}.highlight .gt{color:#aa0000}.highlight .kc{color:#000000;font-weight:bold}.highlight .kd{color:#000000;font-weight:bold}.highlight .kn{color:#000000;font-weight:bold}.highlight .kp{color:#000000;font-weight:bold}.highlight .kr{color:#000000;font-weight:bold}.highlight .kt{color:#445588;font-weight:bold}.highlight .k,.highlight .kv{color:#000000;font-weight:bold}.highlight .mf{color:#009999}.highlight .mh{color:#009999}.highlight .il{color:#009999}.highlight .mi{color:#009999}.highlight .mo{color:#009999}.highlight .m,.highlight .mb,.highlight .mx{color:#009999}.highlight .sb{color:#d14}.highlight .sc{color:#d14}.highlight .sd{color:#d14}.highlight .s2{color:#d14}.highlight .se{color:#d14}.highlight .sh{color:#d14}.highlight .si{color:#d14}.highlight .sx{color:#d14}.highlight .sr{color:#009926}.highlight .s1{color:#d14}.highlight .ss{color:#990073}.highlight .s{color:#d14}.highlight .na{color:#008080}.highlight .bp{color:#999999}.highlight .nb{color:#0086B3}.highlight .nc{color:#445588;font-weight:bold}.highlight .no{color:#008080}.highlight .nd{color:#3c5d5d;font-weight:bold}.highlight .ni{color:#800080}.highlight .ne{color:#990000;font-weight:bold}.highlight .nf{color:#990000;font-weight:bold}.highlight .nl{color:#990000;font-weight:bold}.highlight .nn{color:#555555}.highlight .nt{color:#000080}.highlight .vc{color:#008080}.highlight .vg{color:#008080}.highlight .vi{color:#008080}.highlight .nv{color:#008080}.highlight .ow{color:#000000;font-weight:bold}.highlight .o{color:#000000;font-weight:bold}.highlight .w{color:#bbbbbb}.highlight{background-color:#f8f8f8}*{box-sizing:border-box}body{padding:0;margin:0;font-family:"Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;font-size:16px;line-height:1.5;color:#606c71}a{color:#1e6bb8;text-decoration:none}a:hover{text-decoration:underline}.btn{display:inline-block;margin-bottom:1rem;color:rgba(255,255,255,0.7);background-color:rgba(255,255,255,0.08);border-color:rgba(255,255,255,0.2);border-style:solid;border-width:1px;border-radius:0.3rem;transition:color 0.2s, background-color 0.2s, border-color 0.2s}.btn:hover{color:rgba(255,255,255,0.8);text-decoration:none;background-color:rgba(255,255,255,0.2);border-color:rgba(255,255,255,0.3)}.btn+.btn{margin-left:1rem}@media screen and (min-width: 64em){.btn{padding:0.75rem 1rem}}@media screen and (min-width: 42em) and (max-width: 64em){.btn{padding:0.6rem 0.9rem;font-size:0.9rem}}@media screen and (max-width: 42em){.btn{display:block;width:100%;padding:0.75rem;font-size:0.9rem}.btn+.btn{margin-top:1rem;margin-left:0}}.page-header{color:#fff;text-align:center;background-color:#159957;background-image:linear-gradient(120deg, #155799, #159957)}@media screen and (min-width: 64em){.page-header{padding:5rem 6rem}}@media screen and (min-width: 42em) and (max-width: 64em){.page-header{padding:3rem 4rem}}@media screen and (max-width: 42em){.page-header{padding:2rem 1rem}}.project-name{margin-top:0;margin-bottom:0.1rem}@media screen and (min-width: 64em){.project-name{font-size:3.25rem}}@media screen and (min-width: 42em) and (max-width: 64em){.project-name{font-size:2.25rem}}@media screen and (max-width: 42em){.project-name{font-size:1.75rem}}.project-tagline{margin-bottom:2rem;font-weight:normal;opacity:0.7}@media screen and (min-width: 64em){.project-tagline{font-size:1.25rem}}@media screen and (min-width: 42em) and (max-width: 64em){.project-tagline{font-size:1.15rem}}@media screen and (max-width: 42em){.project-tagline{font-size:1rem}}.main-content{word-wrap:break-word}.main-content :first-child{margin-top:0}@media screen and (min-width: 64em){.main-content{max-width:64rem;padding:2rem 6rem;margin:0 auto;font-size:1.1rem}}@media screen and (min-width: 42em) and (max-width: 64em){.main-content{padding:2rem 4rem;font-size:1.1rem}}@media screen and (max-width: 42em){.main-content{padding:2rem 1rem;font-size:1rem}}.main-content img{max-width:100%}.main-content h1,.main-content h2,.main-content h3,.main-content h4,.main-content h5,.main-content h6{margin-top:2rem;margin-bottom:1rem;font-weight:normal;color:#159957}.main-content p{margin-bottom:1em}.main-content code{padding:2px 4px;font-family:Consolas, "Liberation Mono", Menlo, Courier, monospace;font-size:0.9rem;color:#567482;background-color:#f3f6fa;border-radius:0.3rem}.main-content pre{padding:0.8rem;margin-top:0;margin-bottom:1rem;font:1rem Consolas, "Liberation Mono", Menlo, Courier, monospace;color:#567482;word-wrap:normal;background-color:#f3f6fa;border:solid 1px #dce6f0;border-radius:0.3rem}.main-content pre>code{padding:0;margin:0;font-size:0.9rem;color:#567482;word-break:normal;white-space:pre;background:transparent;border:0}.main-content .highlight{margin-bottom:1rem}.main-content .highlight pre{margin-bottom:0;word-break:normal}.main-content .highlight pre,.main-content pre{padding:0.8rem;overflow:auto;font-size:0.9rem;line-height:1.45;border-radius:0.3rem;-webkit-overflow-scrolling:touch}.main-content pre code,.main-content pre tt{display:inline;max-width:initial;padding:0;margin:0;overflow:initial;line-height:inherit;word-wrap:normal;background-color:transparent;border:0}.main-content pre code:before,.main-content pre code:after,.main-content pre tt:before,.main-content pre tt:after{content:normal}.main-content ul,.main-content ol{margin-top:0}.main-content blockquote{padding:0 1rem;margin-left:0;color:#819198;border-left:0.3rem solid #dce6f0}.main-content blockquote>:first-child{margin-top:0}.main-content blockquote>:last-child{margin-bottom:0}.main-content table{display:block;width:100%;overflow:auto;word-break:normal;word-break:keep-all;-webkit-overflow-scrolling:touch}.main-content table th{font-weight:bold}.main-content table th,.main-content table td{padding:0.5rem 1rem;border:1px solid #e9ebec}.main-content dl{padding:0}.main-content dl dt{padding:0;margin-top:1rem;font-size:1rem;font-weight:bold}.main-content dl dd{padding:0;margin-bottom:1rem}.main-content hr{height:2px;padding:0;margin:1rem 0;background-color:#eff0f1;border:0}.site-footer{padding-top:2rem;margin-top:2rem;border-top:solid 1px #eff0f1}@media screen and (min-width: 64em){.site-footer{font-size:1rem}}@media screen and (min-width: 42em) and (max-width: 64em){.site-footer{font-size:1rem}}@media screen and (max-width: 42em){.site-footer{font-size:0.9rem}}.site-footer-owner{display:block;font-weight:bold}.site-footer-credits{color:#819198} -------------------------------------------------------------------------------- /efpodsanalyzer/efpodsanalyzer.py: -------------------------------------------------------------------------------- 1 | # !/usr/bin/python 2 | # -*- coding: UTF-8 -*- 3 | 4 | from __future__ import print_function 5 | 6 | import json 7 | import os 8 | import re 9 | import sys 10 | # import webbrowser 11 | import shutil 12 | 13 | # 错误码 14 | ERROR_PARAMETERS_COUNT = 1 # 参数数量错误 15 | ERROR_PARAMETERS_TYPE = 2 # 参数错误 16 | ERROR_NEED_PODS = 3 # Pods 目录不存在或不完整 17 | ERROR_FILE_CORRUPTED = 4 # 文件损坏或格式不正确 18 | ERROR_FILE_NOT_EXIST = 5 # 文件不存在 19 | 20 | # 文件名长度 21 | SELF_FILENAME_LEN = len(sys.argv[0].split('/')[-1]) 22 | POD_FILENAME_LEN = len(sys.argv[1].split('/')[-1]) 23 | 24 | # 路径相关 25 | PROJECT_NAME = "efpodsanalyzer" 26 | MODULE_NAME = PROJECT_NAME.lower() 27 | ROOT_PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 28 | MODULE_DIR = os.path.join(ROOT_PROJECT_DIR, MODULE_NAME) 29 | 30 | # 原始数据单元 31 | class ManifestPodClass: 32 | 'Manifest中取出的未处理数据单元' 33 | podName = '' 34 | podDependencies = [] 35 | 36 | def __init__(self, name, dependencies): 37 | self.podName = name 38 | self.podDependencies = dependencies 39 | 40 | def dependenciesCount(self): 41 | return len(self.podDependencies) 42 | 43 | @staticmethod 44 | def printList(Objectlist): 45 | for object in Objectlist: 46 | print(object.podName, object.podDependencies) 47 | 48 | # 最终数据单元 49 | class PodClass: 50 | '处理后的数据单元' 51 | podName = '' 52 | podDependencyIndexes = [] 53 | podReferenceCount = 1 54 | 55 | def __init__(self, name, dependencyIndexes): 56 | self.podName = name 57 | self.podDependencyIndexes = dependencyIndexes 58 | 59 | def dependenciesCount(self): 60 | return len(self.podDependencyIndexes) 61 | 62 | def dependencies(self, podList): 63 | return [podList[i] for i in self.podDependencyIndexes] 64 | 65 | @staticmethod 66 | def printList(Objectlist): 67 | for object in Objectlist: 68 | print(object.podName, object.podDependencyIndexes) 69 | 70 | # 从 Manifest.lock 读取 PODS 原始数据单元列表 71 | def readManifestPodListFromFile(fileName): 72 | fo = open(fileName, "r+") 73 | manifestFileContent = fo.read() 74 | fo.close() 75 | spliteList = manifestFileContent.split('DEPENDENCIES:') 76 | if len(spliteList) <= 1: 77 | print('Error: The Manifest.lock file is corrupted!') 78 | exit(ERROR_FILE_CORRUPTED) 79 | podsString = ' ' + spliteList[0][5:].strip(' \n') 80 | podsStringList = podsString.split('\n') 81 | # 生成原始数据单元数组 82 | returnList = [] 83 | index = -1 84 | lastObject = ManifestPodClass('', []) 85 | for line in podsStringList: 86 | lineClean = line.replace('\'','').replace('\"','') 87 | podName = lineClean.lstrip(' -').split(' ')[0] 88 | if lineClean.startswith(' - '): 89 | if index >= 0: 90 | lastObject.podDependencies.append(podName) 91 | elif lineClean.startswith(' - '): 92 | if index >= 0: 93 | returnList.append(lastObject) 94 | index = index + 1 95 | lastObject = ManifestPodClass(podName, []) 96 | else: 97 | print('Error: The Manifest.lock file is corrupted!') 98 | exit(ERROR_FILE_CORRUPTED) 99 | returnList.append(lastObject) 100 | return returnList 101 | 102 | # 从 ManifestPodList 生成最终数据单元列表 103 | def generatePodListFromList(manifestPodList): 104 | def getBaseIndexes(dependencies, baseList): 105 | returnList = [] 106 | if 0 == len(dependencies): 107 | return returnList 108 | for dependency in dependencies: 109 | #print("dependency: " + dependency) 110 | tempMark = False 111 | for index, base in enumerate(baseList): 112 | #print("dependency: " + dependency + ", base.podName: " + base.podName) 113 | if base.podName == dependency: 114 | returnList.append(index) 115 | tempMark = True 116 | if False == tempMark: 117 | return returnList 118 | return returnList 119 | 120 | returnList = [] 121 | nextList = list(manifestPodList) 122 | while 0 < len(nextList): 123 | doingList = list(nextList) 124 | for manifestPod in doingList: 125 | baseIndexes = getBaseIndexes(manifestPod.podDependencies, returnList) 126 | if len(baseIndexes) == len(manifestPod.podDependencies): 127 | returnList.append(PodClass(manifestPod.podName, baseIndexes)) 128 | nextList.remove(manifestPod) 129 | # 权重 130 | for baseIndex in baseIndexes: 131 | returnList[baseIndex].podReferenceCount += 1 132 | # print(str(baseIndex) + "+= 1, podReferenceCount = " + str(returnList[baseIndex].podReferenceCount)) 133 | else: 134 | # 解决一种奇怪的特殊情况 135 | for podDependencie in manifestPod.podDependencies: 136 | checkSpecial = True 137 | for rtnItem in returnList: 138 | if rtnItem.podName == podDependencie: 139 | checkSpecial = False 140 | for nextItem in nextList: 141 | if nextItem.podName == podDependencie: 142 | checkSpecial = False 143 | if checkSpecial == True: 144 | returnList.append(PodClass(podDependencie, [])) 145 | return returnList 146 | 147 | # 生成依赖关系图 148 | def generateDependencyGraph(podlist, configString): 149 | # Directory 150 | directory = podFilePath() + "EFPADiagram" 151 | if not os.path.exists(directory): 152 | os.makedirs(directory) 153 | 154 | configObject = json.loads(configString) 155 | 156 | settingTitle = podFileDirectoryName() 157 | settingCategories = json.dumps(configObject['config']['categories']) 158 | settingCategoryRegexes = configObject['config']['categoryRegexes'] 159 | settingContent = "setting = '{\"setting\": {\"title\": \"" + \ 160 | settingTitle + "\",\"categories\": " + str(settingCategories) + "}}';" 161 | xx = open(podFilePath() + "EFPADiagram/setting.json", "w+") 162 | xx.write(settingContent) 163 | xx.close() 164 | 165 | # Data 166 | nodeString = "" 167 | for index, pod in enumerate(podlist): 168 | podValue = str(pod.podReferenceCount) 169 | podID = str(index) 170 | podLabel = pod.podName 171 | podAttvalue = str(1) 172 | for index, regex in enumerate(settingCategoryRegexes): 173 | if re.match(regex, pod.podName): 174 | # print(pod.podName + " -> " + regex) 175 | podAttvalue = str(index) 176 | break 177 | 178 | nodeString = nodeString + "{\"attvalues\": {\"attvalue\": {\"_for\": \"modularity_class\",\"_value\": \"" + podAttvalue + \ 179 | "\"}},\"size\": {\"_value\": \"" + podValue + "\",\"__prefix\": \"viz\"},\"position\": {\"_x\": \"-225.73984\",\"_" + \ 180 | "y\": \"82.41631\",\"_z\": \"0.0\",\"__prefix\": \"viz\"},\"color\": {\"_r\": \"236\",\"_g\": \"81\",\"_b\": \"72\"" + \ 181 | ",\"__prefix\": \"viz\"},\"_id\": \"" + podID + "\",\"_label\": \"" + podLabel + "\"}" 182 | nodeString = nodeString + "," 183 | 184 | if nodeString.endswith(","): 185 | nodeString = nodeString[:-1] 186 | 187 | edgeString = "" 188 | edgeIndex = 0 189 | for index, pod in enumerate(podlist): 190 | if pod.dependenciesCount() > 0: 191 | for podDependencyIndex in pod.podDependencyIndexes: 192 | podID = str(edgeIndex) 193 | podSource = str(index) 194 | podTarget = str(podDependencyIndex) 195 | edgeIndex += 1 196 | edgeString = edgeString + "{\"attvalues\": \"\",\"_id\": \"" + podID + "\",\"_source\": \"" + \ 197 | podSource + "\",\"_target\": \"" + podTarget + "\",\"_weight\": \"16.0\"}" 198 | edgeString = edgeString + "," 199 | 200 | if edgeString.endswith(","): 201 | edgeString = edgeString[:-1] 202 | 203 | oo = open(resourcePath("template/data.json"), "r+") 204 | dataTemplate = oo.read() 205 | oo.close() 206 | 207 | dataContent = "data = \'" + dataTemplate.replace("$nodes$", nodeString).replace("$edges$", edgeString).replace("\n", "") + "\';" 208 | xx = open(podFilePath() + "EFPADiagram/data.json", "w+") 209 | xx.write(dataContent) 210 | xx.close() 211 | 212 | # JS 213 | directoryJS = podFilePath() + "EFPADiagram/js" 214 | if not os.path.exists(directoryJS): 215 | os.makedirs(directoryJS) 216 | shutil.copy(resourcePath("EFPADiagram/js/dataTool.js"), directoryJS + "/dataTool.js") 217 | shutil.copy(resourcePath("EFPADiagram/js/echarts.min.js"), directoryJS + "/echarts.min.js") 218 | shutil.copy(resourcePath("EFPADiagram/js/jquery.min.js"), directoryJS + "/jquery.min.js") 219 | shutil.copy(resourcePath("EFPADiagram/js/xml2json.min.js"), directoryJS + "/xml2json.min.js") 220 | 221 | # CSS 222 | directoryCSS = podFilePath() + "EFPADiagram/css" 223 | if not os.path.exists(directoryCSS): 224 | os.makedirs(directoryCSS) 225 | shutil.copy(resourcePath("EFPADiagram/css/style.css"), directoryCSS + "/style.css") 226 | 227 | # HTML 228 | graphHtmlPath = podFilePath() + "EFPADiagram/" 229 | shutil.copy(resourcePath("EFPADiagram/graph_circular.html"), graphHtmlPath + "graph_circular.html") 230 | shutil.copy(resourcePath("EFPADiagram/graph_force.html"), graphHtmlPath + "graph_force.html") 231 | shutil.copy(resourcePath("EFPADiagram/index.html"), graphHtmlPath + "index.html") 232 | print("Dependency graph generated: " + graphHtmlPath) 233 | 234 | # webbrowser.open("file://" + graphHtmlPath) 235 | 236 | return 237 | 238 | # 生成资源文件目录访问路径 239 | def resourcePath(relativePath): 240 | return os.path.join(MODULE_DIR, relativePath) 241 | 242 | # 当前文件所在路径 243 | def selfFilePath(): 244 | return sys.argv[0][:-SELF_FILENAME_LEN] 245 | 246 | # 目标文件所在路径 247 | def podFilePath(): 248 | return sys.argv[1][:-POD_FILENAME_LEN] 249 | 250 | # 目标文件上级目录名 251 | def podFileDirectoryName(): 252 | return sys.argv[1][:-8].split('/')[-1] 253 | 254 | # 主要 255 | def main(): 256 | # 输入参数数量错误直接返回错误 257 | if 2 != len(sys.argv): 258 | print('Error:Count of parameters is not correct!') 259 | exit(ERROR_PARAMETERS_COUNT) 260 | 261 | # 输入文件不是 Podfile 直接返回错误 262 | if True != sys.argv[1].endswith('Podfile'): 263 | print('Error: Illegal parameters!') 264 | exit(ERROR_PARAMETERS_TYPE) 265 | 266 | # 判断 Pods 目录下的 Manifest.lock 是否存在,否则返回错误 267 | manifestFileName = sys.argv[1][:-4] + 's/Manifest.lock' 268 | if True != os.path.exists(manifestFileName): 269 | print('Error: Please run `pod install` first!') 270 | exit(ERROR_NEED_PODS) 271 | 272 | # 判断目标目录下的 EFPAConfig.json 是否存在,如果不存在的话,则使用默认的配置文件 273 | configFileName = podFilePath() + '/EFPAConfig.json' 274 | configString = ''' 275 | { 276 | "config": { 277 | "categories": ["Other"], 278 | "categoryRegexes": [".*"] 279 | } 280 | } 281 | ''' 282 | if True == os.path.exists(configFileName): 283 | cc = open(podFilePath() + "EFPAConfig.json", "r+") 284 | configString = cc.read() 285 | cc.close() 286 | 287 | # 读取 PODS 依赖关系并生成依赖关系数组 288 | manifestPodlist = readManifestPodListFromFile(manifestFileName) 289 | # ManifestPodClass.printList(manifestPodlist) 290 | podlist = generatePodListFromList(manifestPodlist) 291 | # PodClass.printList(podlist) 292 | 293 | # 生成依赖关系页面 294 | generateDependencyGraph(podlist, configString) 295 | 296 | # 执行 297 | if __name__ == "__main__": 298 | main() 299 | -------------------------------------------------------------------------------- /docs/data.json: -------------------------------------------------------------------------------- 1 | data = '{ "gexf": { "meta": { "creator": "Gephi 0.8.1", "description": "", "_lastmodifieddate": "2014-01-30" }, "graph": { "attributes": { "attribute": { "_id": "modularity_class", "_title": "Modularity Class", "_type": "integer" }, "_class": "node", "_mode": "static" }, "nodes": { "node": [ {"attvalues": {"attvalue": {"_for": "modularity_class","_value": "2"}},"size": {"_value": "1","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "0","_label": "APParallaxHeader"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "2"}},"size": {"_value": "4","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "1","_label": "BlocksKit/Core"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "2"}},"size": {"_value": "4","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "2","_label": "BlocksKit/DynamicDelegate"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "2"}},"size": {"_value": "2","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "3","_label": "BlocksKit/MessageUI"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "1"}},"size": {"_value": "2","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "4","_label": "BlocksKit/UIKit"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "2"}},"size": {"_value": "1","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "5","_label": "evernote-cloud-sdk-ios"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "2"}},"size": {"_value": "1","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "6","_label": "FLEX"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "2"}},"size": {"_value": "2","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "7","_label": "FontAwesome+iOS"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "2"}},"size": {"_value": "1","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "8","_label": "hpple"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "2"}},"size": {"_value": "1","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "9","_label": "JazzHands"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "0"}},"size": {"_value": "1","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "10","_label": "MarqueeLabel"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "0"}},"size": {"_value": "1","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "11","_label": "Masonry"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "0"}},"size": {"_value": "1","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "12","_label": "MBProgressHUD"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "0"}},"size": {"_value": "1","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "13","_label": "MMMarkdown"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "1"}},"size": {"_value": "1","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "14","_label": "NYXImagesKit"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "2"}},"size": {"_value": "7","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "15","_label": "pop"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "2"}},"size": {"_value": "3","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "16","_label": "POP+MCAnimate/Group"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "2"}},"size": {"_value": "4","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "17","_label": "POP+MCAnimate/Internal"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "2"}},"size": {"_value": "3","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "18","_label": "POP+MCAnimate/Shorthand"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "2"}},"size": {"_value": "3","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "19","_label": "POP+MCAnimate/Velocity"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "2"}},"size": {"_value": "1","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "20","_label": "PPiAwesomeButton"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "2"}},"size": {"_value": "2","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "21","_label": "RBBAnimation"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "2"}},"size": {"_value": "2","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "22","_label": "ReactiveCocoa/no-arc"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "2"}},"size": {"_value": "1","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "23","_label": "RegexKitLite-NoWarning"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "2"}},"size": {"_value": "1","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "24","_label": "SDAutoLayout"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "2"}},"size": {"_value": "2","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "25","_label": "SDCAutoLayout"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "2"}},"size": {"_value": "1","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "26","_label": "SSKeychain"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "2"}},"size": {"_value": "1","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "27","_label": "TMCache"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "2"}},"size": {"_value": "1","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "28","_label": "TPKeyboardAvoiding"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "2"}},"size": {"_value": "1","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "29","_label": "TTTAttributedLabel"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "2"}},"size": {"_value": "1","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "30","_label": "UIImage+BlurredFrame"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "2"}},"size": {"_value": "1","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "31","_label": "UMengAnalytics"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "2"}},"size": {"_value": "2","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "32","_label": "UMengUShare/Network"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "2"}},"size": {"_value": "2","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "33","_label": "BlocksKit/All"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "2"}},"size": {"_value": "2","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "34","_label": "POP+MCAnimate/Animations"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "2"}},"size": {"_value": "2","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "35","_label": "ReactiveCocoa/Core"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "2"}},"size": {"_value": "2","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "36","_label": "ReactiveCocoa/UI"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "2"}},"size": {"_value": "1","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "37","_label": "SDCAlertView"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "2"}},"size": {"_value": "7","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "38","_label": "UMengUShare/Core"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "2"}},"size": {"_value": "2","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "39","_label": "UMengUShare/Social/ReducedQQ"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "2"}},"size": {"_value": "2","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "40","_label": "UMengUShare/Social/ReducedSina"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "2"}},"size": {"_value": "2","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "41","_label": "UMengUShare/Social/ReducedWeChat"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "2"}},"size": {"_value": "1","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "42","_label": "UMengUShare/Social/Sina"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "2"}},"size": {"_value": "1","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "43","_label": "UMengUShare/Social/WeChat"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "1"}},"size": {"_value": "1","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "44","_label": "BlocksKit"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "2"}},"size": {"_value": "1","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "45","_label": "POP+MCAnimate"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "2"}},"size": {"_value": "1","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "46","_label": "ReactiveCocoa"},{"attvalues": {"attvalue": {"_for": "modularity_class","_value": "2"}},"size": {"_value": "1","__prefix": "viz"},"position": {"_x": "-225.73984","_y": "82.41631","_z": "0.0","__prefix": "viz"},"color": {"_r": "236","_g": "81","_b": "72","__prefix": "viz"},"_id": "47","_label": "UMengUShare/Social/QQ"} ] }, "edges": { "edge": [ {"attvalues": "","_id": "0","_source": "3","_target": "1","_weight": "16.0"},{"attvalues": "","_id": "1","_source": "3","_target": "2","_weight": "16.0"},{"attvalues": "","_id": "2","_source": "4","_target": "1","_weight": "16.0"},{"attvalues": "","_id": "3","_source": "4","_target": "2","_weight": "16.0"},{"attvalues": "","_id": "4","_source": "16","_target": "15","_weight": "16.0"},{"attvalues": "","_id": "5","_source": "17","_target": "15","_weight": "16.0"},{"attvalues": "","_id": "6","_source": "18","_target": "15","_weight": "16.0"},{"attvalues": "","_id": "7","_source": "19","_target": "15","_weight": "16.0"},{"attvalues": "","_id": "8","_source": "19","_target": "17","_weight": "16.0"},{"attvalues": "","_id": "9","_source": "20","_target": "7","_weight": "16.0"},{"attvalues": "","_id": "10","_source": "33","_target": "1","_weight": "16.0"},{"attvalues": "","_id": "11","_source": "33","_target": "2","_weight": "16.0"},{"attvalues": "","_id": "12","_source": "33","_target": "3","_weight": "16.0"},{"attvalues": "","_id": "13","_source": "33","_target": "4","_weight": "16.0"},{"attvalues": "","_id": "14","_source": "34","_target": "15","_weight": "16.0"},{"attvalues": "","_id": "15","_source": "34","_target": "16","_weight": "16.0"},{"attvalues": "","_id": "16","_source": "34","_target": "17","_weight": "16.0"},{"attvalues": "","_id": "17","_source": "34","_target": "18","_weight": "16.0"},{"attvalues": "","_id": "18","_source": "34","_target": "19","_weight": "16.0"},{"attvalues": "","_id": "19","_source": "35","_target": "22","_weight": "16.0"},{"attvalues": "","_id": "20","_source": "36","_target": "35","_weight": "16.0"},{"attvalues": "","_id": "21","_source": "37","_target": "21","_weight": "16.0"},{"attvalues": "","_id": "22","_source": "37","_target": "25","_weight": "16.0"},{"attvalues": "","_id": "23","_source": "38","_target": "32","_weight": "16.0"},{"attvalues": "","_id": "24","_source": "39","_target": "38","_weight": "16.0"},{"attvalues": "","_id": "25","_source": "40","_target": "38","_weight": "16.0"},{"attvalues": "","_id": "26","_source": "41","_target": "38","_weight": "16.0"},{"attvalues": "","_id": "27","_source": "42","_target": "38","_weight": "16.0"},{"attvalues": "","_id": "28","_source": "42","_target": "40","_weight": "16.0"},{"attvalues": "","_id": "29","_source": "43","_target": "38","_weight": "16.0"},{"attvalues": "","_id": "30","_source": "43","_target": "41","_weight": "16.0"},{"attvalues": "","_id": "31","_source": "44","_target": "33","_weight": "16.0"},{"attvalues": "","_id": "32","_source": "45","_target": "15","_weight": "16.0"},{"attvalues": "","_id": "33","_source": "45","_target": "34","_weight": "16.0"},{"attvalues": "","_id": "34","_source": "45","_target": "16","_weight": "16.0"},{"attvalues": "","_id": "35","_source": "45","_target": "17","_weight": "16.0"},{"attvalues": "","_id": "36","_source": "45","_target": "18","_weight": "16.0"},{"attvalues": "","_id": "37","_source": "45","_target": "19","_weight": "16.0"},{"attvalues": "","_id": "38","_source": "46","_target": "36","_weight": "16.0"},{"attvalues": "","_id": "39","_source": "47","_target": "38","_weight": "16.0"},{"attvalues": "","_id": "40","_source": "47","_target": "39","_weight": "16.0"} ] }, "_defaultedgetype": "undirected", "_mode": "static" }, "_xmlns": "http://www.gexf.net/1.2draft", "_xmlns:viz": "http://www.gexf.net/1.2draft/viz", "_xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance", "_version": "1.2", "_xsi:schemaLocation": "http://www.gexf.net/1.2draft http://www.gexf.net/1.2draft/gexf.xsd" }}'; -------------------------------------------------------------------------------- /docs/js/dataTool.js: -------------------------------------------------------------------------------- 1 | (function (global, factory) { 2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('echarts')) : 3 | typeof define === 'function' && define.amd ? define(['exports', 'echarts'], factory) : 4 | (factory((global.dataTool = {}),global.echarts)); 5 | }(this, (function (exports,echarts) { 'use strict'; 6 | 7 | /** 8 | * @module zrender/core/util 9 | */ 10 | 11 | // 鐢ㄤ簬澶勭悊merge鏃舵棤娉曢亶鍘咲ate绛夊璞$殑闂 12 | var arrayProto = Array.prototype; 13 | var nativeMap = arrayProto.map; 14 | 15 | 16 | /** 17 | * Those data types can be cloned: 18 | * Plain object, Array, TypedArray, number, string, null, undefined. 19 | * Those data types will be assgined using the orginal data: 20 | * BUILTIN_OBJECT 21 | * Instance of user defined class will be cloned to a plain object, without 22 | * properties in prototype. 23 | * Other data types is not supported (not sure what will happen). 24 | * 25 | * Caution: do not support clone Date, for performance consideration. 26 | * (There might be a large number of date in `series.data`). 27 | * So date should not be modified in and out of echarts. 28 | * 29 | * @param {*} source 30 | * @return {*} new 31 | */ 32 | 33 | 34 | /** 35 | * @memberOf module:zrender/core/util 36 | * @param {*} target 37 | * @param {*} source 38 | * @param {boolean} [overwrite=false] 39 | */ 40 | 41 | 42 | /** 43 | * @param {Array} targetAndSources The first item is target, and the rests are source. 44 | * @param {boolean} [overwrite=false] 45 | * @return {*} target 46 | */ 47 | 48 | 49 | /** 50 | * @param {*} target 51 | * @param {*} source 52 | * @memberOf module:zrender/core/util 53 | */ 54 | 55 | 56 | /** 57 | * @param {*} target 58 | * @param {*} source 59 | * @param {boolean} [overlay=false] 60 | * @memberOf module:zrender/core/util 61 | */ 62 | 63 | 64 | 65 | 66 | 67 | 68 | /** 69 | * 鏌ヨ鏁扮粍涓厓绱犵殑index 70 | * @memberOf module:zrender/core/util 71 | */ 72 | 73 | 74 | /** 75 | * 鏋勯€犵被缁ф壙鍏崇郴 76 | * 77 | * @memberOf module:zrender/core/util 78 | * @param {Function} clazz 婧愮被 79 | * @param {Function} baseClazz 鍩虹被 80 | */ 81 | 82 | 83 | /** 84 | * @memberOf module:zrender/core/util 85 | * @param {Object|Function} target 86 | * @param {Object|Function} sorce 87 | * @param {boolean} overlay 88 | */ 89 | 90 | 91 | /** 92 | * Consider typed array. 93 | * @param {Array|TypedArray} data 94 | */ 95 | 96 | 97 | /** 98 | * 鏁扮粍鎴栧璞¢亶鍘� 99 | * @memberOf module:zrender/core/util 100 | * @param {Object|Array} obj 101 | * @param {Function} cb 102 | * @param {*} [context] 103 | */ 104 | 105 | 106 | /** 107 | * 鏁扮粍鏄犲皠 108 | * @memberOf module:zrender/core/util 109 | * @param {Array} obj 110 | * @param {Function} cb 111 | * @param {*} [context] 112 | * @return {Array} 113 | */ 114 | function map(obj, cb, context) { 115 | if (!(obj && cb)) { 116 | return; 117 | } 118 | if (obj.map && obj.map === nativeMap) { 119 | return obj.map(cb, context); 120 | } 121 | else { 122 | var result = []; 123 | for (var i = 0, len = obj.length; i < len; i++) { 124 | result.push(cb.call(context, obj[i], i, obj)); 125 | } 126 | return result; 127 | } 128 | } 129 | 130 | /** 131 | * @memberOf module:zrender/core/util 132 | * @param {Array} obj 133 | * @param {Function} cb 134 | * @param {Object} [memo] 135 | * @param {*} [context] 136 | * @return {Array} 137 | */ 138 | 139 | 140 | /** 141 | * 鏁扮粍杩囨护 142 | * @memberOf module:zrender/core/util 143 | * @param {Array} obj 144 | * @param {Function} cb 145 | * @param {*} [context] 146 | * @return {Array} 147 | */ 148 | 149 | 150 | /** 151 | * 鏁扮粍椤规煡鎵� 152 | * @memberOf module:zrender/core/util 153 | * @param {Array} obj 154 | * @param {Function} cb 155 | * @param {*} [context] 156 | * @return {*} 157 | */ 158 | 159 | 160 | /** 161 | * @memberOf module:zrender/core/util 162 | * @param {Function} func 163 | * @param {*} context 164 | * @return {Function} 165 | */ 166 | 167 | 168 | /** 169 | * @memberOf module:zrender/core/util 170 | * @param {Function} func 171 | * @return {Function} 172 | */ 173 | 174 | 175 | /** 176 | * @memberOf module:zrender/core/util 177 | * @param {*} value 178 | * @return {boolean} 179 | */ 180 | 181 | 182 | /** 183 | * @memberOf module:zrender/core/util 184 | * @param {*} value 185 | * @return {boolean} 186 | */ 187 | 188 | 189 | /** 190 | * @memberOf module:zrender/core/util 191 | * @param {*} value 192 | * @return {boolean} 193 | */ 194 | 195 | 196 | /** 197 | * @memberOf module:zrender/core/util 198 | * @param {*} value 199 | * @return {boolean} 200 | */ 201 | 202 | 203 | /** 204 | * @memberOf module:zrender/core/util 205 | * @param {*} value 206 | * @return {boolean} 207 | */ 208 | 209 | 210 | /** 211 | * @memberOf module:zrender/core/util 212 | * @param {*} value 213 | * @return {boolean} 214 | */ 215 | 216 | 217 | /** 218 | * @memberOf module:zrender/core/util 219 | * @param {*} value 220 | * @return {boolean} 221 | */ 222 | 223 | 224 | /** 225 | * Whether is exactly NaN. Notice isNaN('a') returns true. 226 | * @param {*} value 227 | * @return {boolean} 228 | */ 229 | 230 | 231 | /** 232 | * If value1 is not null, then return value1, otherwise judget rest of values. 233 | * Low performance. 234 | * @memberOf module:zrender/core/util 235 | * @return {*} Final value 236 | */ 237 | 238 | 239 | 240 | 241 | 242 | 243 | /** 244 | * @memberOf module:zrender/core/util 245 | * @param {Array} arr 246 | * @param {number} startIndex 247 | * @param {number} endIndex 248 | * @return {Array} 249 | */ 250 | 251 | 252 | /** 253 | * Normalize css liked array configuration 254 | * e.g. 255 | * 3 => [3, 3, 3, 3] 256 | * [4, 2] => [4, 2, 4, 2] 257 | * [4, 3, 2] => [4, 3, 2, 3] 258 | * @param {number|Array.} val 259 | * @return {Array.} 260 | */ 261 | 262 | 263 | /** 264 | * @memberOf module:zrender/core/util 265 | * @param {boolean} condition 266 | * @param {string} message 267 | */ 268 | 269 | 270 | /** 271 | * @memberOf module:zrender/core/util 272 | * @param {string} str string to be trimed 273 | * @return {string} trimed string 274 | */ 275 | 276 | 277 | /** 278 | * Set an object as primitive to be ignored traversing children in clone or merge 279 | */ 280 | 281 | // GEXF File Parser 282 | // http://gexf.net/1.2draft/gexf-12draft-primer.pdf 283 | 284 | function parse(xml) { 285 | var doc; 286 | if (typeof xml === 'string') { 287 | var parser = new DOMParser(); 288 | doc = parser.parseFromString(xml, 'text/xml'); 289 | } 290 | else { 291 | doc = xml; 292 | } 293 | if (!doc || doc.getElementsByTagName('parsererror').length) { 294 | return null; 295 | } 296 | 297 | var gexfRoot = getChildByTagName(doc, 'gexf'); 298 | 299 | if (!gexfRoot) { 300 | return null; 301 | } 302 | 303 | var graphRoot = getChildByTagName(gexfRoot, 'graph'); 304 | 305 | var attributes = parseAttributes(getChildByTagName(graphRoot, 'attributes')); 306 | var attributesMap = {}; 307 | for (var i = 0; i < attributes.length; i++) { 308 | attributesMap[attributes[i].id] = attributes[i]; 309 | } 310 | 311 | return { 312 | nodes: parseNodes(getChildByTagName(graphRoot, 'nodes'), attributesMap), 313 | links: parseEdges(getChildByTagName(graphRoot, 'edges')) 314 | }; 315 | } 316 | 317 | function parseAttributes(parent) { 318 | return parent ? map(getChildrenByTagName(parent, 'attribute'), function (attribDom) { 319 | return { 320 | id: getAttr(attribDom, 'id'), 321 | title: getAttr(attribDom, 'title'), 322 | type: getAttr(attribDom, 'type') 323 | }; 324 | }) : []; 325 | } 326 | 327 | function parseNodes(parent, attributesMap) { 328 | return parent ? map(getChildrenByTagName(parent, 'node'), function (nodeDom) { 329 | 330 | var id = getAttr(nodeDom, 'id'); 331 | var label = getAttr(nodeDom, 'label'); 332 | 333 | var node = { 334 | id: id, 335 | name: label, 336 | itemStyle: { 337 | normal: {} 338 | } 339 | }; 340 | 341 | var vizSizeDom = getChildByTagName(nodeDom, 'viz:size'); 342 | var vizPosDom = getChildByTagName(nodeDom, 'viz:position'); 343 | var vizColorDom = getChildByTagName(nodeDom, 'viz:color'); 344 | // var vizShapeDom = getChildByTagName(nodeDom, 'viz:shape'); 345 | 346 | var attvaluesDom = getChildByTagName(nodeDom, 'attvalues'); 347 | 348 | if (vizSizeDom) { 349 | node.symbolSize = parseFloat(getAttr(vizSizeDom, 'value')); 350 | } 351 | if (vizPosDom) { 352 | node.x = parseFloat(getAttr(vizPosDom, 'x')); 353 | node.y = parseFloat(getAttr(vizPosDom, 'y')); 354 | // z 355 | } 356 | if (vizColorDom) { 357 | node.itemStyle.normal.color = 'rgb(' +[ 358 | getAttr(vizColorDom, 'r') | 0, 359 | getAttr(vizColorDom, 'g') | 0, 360 | getAttr(vizColorDom, 'b') | 0 361 | ].join(',') + ')'; 362 | } 363 | // if (vizShapeDom) { 364 | // node.shape = getAttr(vizShapeDom, 'shape'); 365 | // } 366 | if (attvaluesDom) { 367 | var attvalueDomList = getChildrenByTagName(attvaluesDom, 'attvalue'); 368 | 369 | node.attributes = {}; 370 | 371 | for (var j = 0; j < attvalueDomList.length; j++) { 372 | var attvalueDom = attvalueDomList[j]; 373 | var attId = getAttr(attvalueDom, 'for'); 374 | var attValue = getAttr(attvalueDom, 'value'); 375 | var attribute = attributesMap[attId]; 376 | 377 | if (attribute) { 378 | switch (attribute.type) { 379 | case 'integer': 380 | case 'long': 381 | attValue = parseInt(attValue, 10); 382 | break; 383 | case 'float': 384 | case 'double': 385 | attValue = parseFloat(attValue); 386 | break; 387 | case 'boolean': 388 | attValue = attValue.toLowerCase() == 'true'; 389 | break; 390 | default: 391 | } 392 | node.attributes[attId] = attValue; 393 | } 394 | } 395 | } 396 | 397 | return node; 398 | }) : []; 399 | } 400 | 401 | function parseEdges(parent) { 402 | return parent ? map(getChildrenByTagName(parent, 'edge'), function (edgeDom) { 403 | var id = getAttr(edgeDom, 'id'); 404 | var label = getAttr(edgeDom, 'label'); 405 | 406 | var sourceId = getAttr(edgeDom, 'source'); 407 | var targetId = getAttr(edgeDom, 'target'); 408 | 409 | var edge = { 410 | id: id, 411 | name: label, 412 | source: sourceId, 413 | target: targetId, 414 | lineStyle: { 415 | normal: {} 416 | } 417 | }; 418 | 419 | var lineStyle = edge.lineStyle.normal; 420 | 421 | var vizThicknessDom = getChildByTagName(edgeDom, 'viz:thickness'); 422 | var vizColorDom = getChildByTagName(edgeDom, 'viz:color'); 423 | // var vizShapeDom = getChildByTagName(edgeDom, 'viz:shape'); 424 | 425 | if (vizThicknessDom) { 426 | lineStyle.width = parseFloat(vizThicknessDom.getAttribute('value')); 427 | } 428 | if (vizColorDom) { 429 | lineStyle.color = 'rgb(' + [ 430 | getAttr(vizColorDom, 'r') | 0, 431 | getAttr(vizColorDom, 'g') | 0, 432 | getAttr(vizColorDom, 'b') | 0 433 | ].join(',') + ')'; 434 | } 435 | // if (vizShapeDom) { 436 | // edge.shape = vizShapeDom.getAttribute('shape'); 437 | // } 438 | 439 | return edge; 440 | }) : []; 441 | } 442 | 443 | function getAttr(el, attrName) { 444 | return el.getAttribute(attrName); 445 | } 446 | 447 | function getChildByTagName (parent, tagName) { 448 | var node = parent.firstChild; 449 | 450 | while (node) { 451 | if ( 452 | node.nodeType != 1 || 453 | node.nodeName.toLowerCase() != tagName.toLowerCase() 454 | ) { 455 | node = node.nextSibling; 456 | } else { 457 | return node; 458 | } 459 | } 460 | 461 | return null; 462 | } 463 | 464 | function getChildrenByTagName (parent, tagName) { 465 | var node = parent.firstChild; 466 | var children = []; 467 | while (node) { 468 | if (node.nodeName.toLowerCase() == tagName.toLowerCase()) { 469 | children.push(node); 470 | } 471 | node = node.nextSibling; 472 | } 473 | 474 | return children; 475 | } 476 | 477 | 478 | var gexf = (Object.freeze || Object)({ 479 | parse: parse 480 | }); 481 | 482 | /** 483 | * Copyright (c) 2010-2015, Michael Bostock 484 | * All rights reserved. 485 | * 486 | * Redistribution and use in source and binary forms, with or without 487 | * modification, are permitted provided that the following conditions are met: 488 | * 489 | * * Redistributions of source code must retain the above copyright notice, this 490 | * list of conditions and the following disclaimer. 491 | * 492 | * * Redistributions in binary form must reproduce the above copyright notice, 493 | * this list of conditions and the following disclaimer in the documentation 494 | * and/or other materials provided with the distribution. 495 | * 496 | * * The name Michael Bostock may not be used to endorse or promote products 497 | * derived from this software without specific prior written permission. 498 | * 499 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 500 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 501 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 502 | * DISCLAIMED. IN NO EVENT SHALL MICHAEL BOSTOCK BE LIABLE FOR ANY DIRECT, 503 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 504 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 505 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 506 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 507 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 508 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 509 | */ 510 | 511 | /** 512 | * @see 513 | * @see 514 | * @param {Array.} ascArr 515 | */ 516 | var quantile = function(ascArr, p) { 517 | var H = (ascArr.length - 1) * p + 1, 518 | h = Math.floor(H), 519 | v = +ascArr[h - 1], 520 | e = H - h; 521 | return e ? v + e * (ascArr[h] - v) : v; 522 | }; 523 | 524 | /** 525 | * Linear mapping a value from domain to range 526 | * @memberOf module:echarts/util/number 527 | * @param {(number|Array.)} val 528 | * @param {Array.} domain Domain extent domain[0] can be bigger than domain[1] 529 | * @param {Array.} range Range extent range[0] can be bigger than range[1] 530 | * @param {boolean} clamp 531 | * @return {(number|Array.} 532 | */ 533 | 534 | 535 | /** 536 | * Convert a percent string to absolute number. 537 | * Returns NaN if percent is not a valid string or number 538 | * @memberOf module:echarts/util/number 539 | * @param {string|number} percent 540 | * @param {number} all 541 | * @return {number} 542 | */ 543 | 544 | 545 | /** 546 | * (1) Fix rounding error of float numbers. 547 | * (2) Support return string to avoid scientific notation like '3.5e-7'. 548 | * 549 | * @param {number} x 550 | * @param {number} [precision] 551 | * @param {boolean} [returnStr] 552 | * @return {number|string} 553 | */ 554 | 555 | 556 | function asc(arr) { 557 | arr.sort(function (a, b) { 558 | return a - b; 559 | }); 560 | return arr; 561 | } 562 | 563 | /** 564 | * Get precision 565 | * @param {number} val 566 | */ 567 | 568 | 569 | /** 570 | * @param {string|number} val 571 | * @return {number} 572 | */ 573 | 574 | 575 | /** 576 | * Minimal dicernible data precisioin according to a single pixel. 577 | * 578 | * @param {Array.} dataExtent 579 | * @param {Array.} pixelExtent 580 | * @return {number} precision 581 | */ 582 | 583 | 584 | /** 585 | * Get a data of given precision, assuring the sum of percentages 586 | * in valueList is 1. 587 | * The largest remainer method is used. 588 | * https://en.wikipedia.org/wiki/Largest_remainder_method 589 | * 590 | * @param {Array.} valueList a list of all data 591 | * @param {number} idx index of the data to be processed in valueList 592 | * @param {number} precision integer number showing digits of precision 593 | * @return {number} percent ranging from 0 to 100 594 | */ 595 | 596 | 597 | // Number.MAX_SAFE_INTEGER, ie do not support. 598 | 599 | 600 | /** 601 | * To 0 - 2 * PI, considering negative radian. 602 | * @param {number} radian 603 | * @return {number} 604 | */ 605 | 606 | 607 | /** 608 | * @param {type} radian 609 | * @return {boolean} 610 | */ 611 | 612 | 613 | /** 614 | * @param {string|Date|number} value These values can be accepted: 615 | * + An instance of Date, represent a time in its own time zone. 616 | * + Or string in a subset of ISO 8601, only including: 617 | * + only year, month, date: '2012-03', '2012-03-01', '2012-03-01 05', '2012-03-01 05:06', 618 | * + separated with T or space: '2012-03-01T12:22:33.123', '2012-03-01 12:22:33.123', 619 | * + time zone: '2012-03-01T12:22:33Z', '2012-03-01T12:22:33+8000', '2012-03-01T12:22:33-05:00', 620 | * all of which will be treated as local time if time zone is not specified 621 | * (see ). 622 | * + Or other string format, including (all of which will be treated as loacal time): 623 | * '2012', '2012-3-1', '2012/3/1', '2012/03/01', 624 | * '2009/6/12 2:00', '2009/6/12 2:05:08', '2009/6/12 2:05:08.123' 625 | * + a timestamp, which represent a time in UTC. 626 | * @return {Date} date 627 | */ 628 | 629 | 630 | /** 631 | * Quantity of a number. e.g. 0.1, 1, 10, 100 632 | * 633 | * @param {number} val 634 | * @return {number} 635 | */ 636 | 637 | 638 | /** 639 | * find a 鈥渘ice鈥� number approximately equal to x. Round the number if round = true, 640 | * take ceiling if round = false. The primary observation is that the 鈥渘icest鈥� 641 | * numbers in decimal are 1, 2, and 5, and all power-of-ten multiples of these numbers. 642 | * 643 | * See "Nice Numbers for Graph Labels" of Graphic Gems. 644 | * 645 | * @param {number} val Non-negative value. 646 | * @param {boolean} round 647 | * @return {number} 648 | */ 649 | 650 | 651 | /** 652 | * Order intervals asc, and split them when overlap. 653 | * expect(numberUtil.reformIntervals([ 654 | * {interval: [18, 62], close: [1, 1]}, 655 | * {interval: [-Infinity, -70], close: [0, 0]}, 656 | * {interval: [-70, -26], close: [1, 1]}, 657 | * {interval: [-26, 18], close: [1, 1]}, 658 | * {interval: [62, 150], close: [1, 1]}, 659 | * {interval: [106, 150], close: [1, 1]}, 660 | * {interval: [150, Infinity], close: [0, 0]} 661 | * ])).toEqual([ 662 | * {interval: [-Infinity, -70], close: [0, 0]}, 663 | * {interval: [-70, -26], close: [1, 1]}, 664 | * {interval: [-26, 18], close: [0, 1]}, 665 | * {interval: [18, 62], close: [0, 1]}, 666 | * {interval: [62, 150], close: [0, 1]}, 667 | * {interval: [150, Infinity], close: [0, 0]} 668 | * ]); 669 | * @param {Array.} list, where `close` mean open or close 670 | * of the interval, and Infinity can be used. 671 | * @return {Array.} The origin list, which has been reformed. 672 | */ 673 | 674 | 675 | /** 676 | * parseFloat NaNs numeric-cast false positives (null|true|false|"") 677 | * ...but misinterprets leading-number strings, particularly hex literals ("0x...") 678 | * subtraction forces infinities to NaN 679 | * 680 | * @param {*} v 681 | * @return {boolean} 682 | */ 683 | 684 | /** 685 | * See: 686 | * 687 | * 688 | * 689 | * Helper method for preparing data. 690 | * 691 | * @param {Array.} rawData like 692 | * [ 693 | * [12,232,443], (raw data set for the first box) 694 | * [3843,5545,1232], (raw datat set for the second box) 695 | * ... 696 | * ] 697 | * @param {Object} [opt] 698 | * 699 | * @param {(number|string)} [opt.boundIQR=1.5] Data less than min bound is outlier. 700 | * default 1.5, means Q1 - 1.5 * (Q3 - Q1). 701 | * If 'none'/0 passed, min bound will not be used. 702 | * @param {(number|string)} [opt.layout='horizontal'] 703 | * Box plot layout, can be 'horizontal' or 'vertical' 704 | * @return {Object} { 705 | * boxData: Array.> 706 | * outliers: Array.> 707 | * axisData: Array. 708 | * } 709 | */ 710 | var prepareBoxplotData = function (rawData, opt) { 711 | opt = opt || []; 712 | var boxData = []; 713 | var outliers = []; 714 | var axisData = []; 715 | var boundIQR = opt.boundIQR; 716 | var useExtreme = boundIQR === 'none' || boundIQR === 0; 717 | 718 | for (var i = 0; i < rawData.length; i++) { 719 | axisData.push(i + ''); 720 | var ascList = asc(rawData[i].slice()); 721 | 722 | var Q1 = quantile(ascList, 0.25); 723 | var Q2 = quantile(ascList, 0.5); 724 | var Q3 = quantile(ascList, 0.75); 725 | var min = ascList[0]; 726 | var max = ascList[ascList.length - 1]; 727 | 728 | var bound = (boundIQR == null ? 1.5 : boundIQR) * (Q3 - Q1); 729 | 730 | var low = useExtreme 731 | ? min 732 | : Math.max(min, Q1 - bound); 733 | var high = useExtreme 734 | ? max 735 | : Math.min(max, Q3 + bound); 736 | 737 | boxData.push([low, Q1, Q2, Q3, high]); 738 | 739 | for (var j = 0; j < ascList.length; j++) { 740 | var dataItem = ascList[j]; 741 | if (dataItem < low || dataItem > high) { 742 | var outlier = [i, dataItem]; 743 | opt.layout === 'vertical' && outlier.reverse(); 744 | outliers.push(outlier); 745 | } 746 | } 747 | } 748 | return { 749 | boxData: boxData, 750 | outliers: outliers, 751 | axisData: axisData 752 | }; 753 | }; 754 | 755 | var version = '1.0.0'; 756 | 757 | // For backward compatibility, where the namespace `dataTool` will 758 | // be mounted on `echarts` is the extension `dataTool` is imported. 759 | // But the old version of echarts do not have `dataTool` namespace, 760 | // so check it before mounting. 761 | if (echarts.dataTool) { 762 | echarts.dataTool.version = version; 763 | echarts.dataTool.gexf = gexf; 764 | echarts.dataTool.prepareBoxplotData = prepareBoxplotData; 765 | } 766 | 767 | exports.version = version; 768 | exports.gexf = gexf; 769 | exports.prepareBoxplotData = prepareBoxplotData; 770 | 771 | }))); 772 | //# sourceMappingURL=dataTool.js.map -------------------------------------------------------------------------------- /efpodsanalyzer/EFPADiagram/js/dataTool.js: -------------------------------------------------------------------------------- 1 | (function (global, factory) { 2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('echarts')) : 3 | typeof define === 'function' && define.amd ? define(['exports', 'echarts'], factory) : 4 | (factory((global.dataTool = {}),global.echarts)); 5 | }(this, (function (exports,echarts) { 'use strict'; 6 | 7 | /** 8 | * @module zrender/core/util 9 | */ 10 | 11 | // 鐢ㄤ簬澶勭悊merge鏃舵棤娉曢亶鍘咲ate绛夊璞$殑闂 12 | var arrayProto = Array.prototype; 13 | var nativeMap = arrayProto.map; 14 | 15 | 16 | /** 17 | * Those data types can be cloned: 18 | * Plain object, Array, TypedArray, number, string, null, undefined. 19 | * Those data types will be assgined using the orginal data: 20 | * BUILTIN_OBJECT 21 | * Instance of user defined class will be cloned to a plain object, without 22 | * properties in prototype. 23 | * Other data types is not supported (not sure what will happen). 24 | * 25 | * Caution: do not support clone Date, for performance consideration. 26 | * (There might be a large number of date in `series.data`). 27 | * So date should not be modified in and out of echarts. 28 | * 29 | * @param {*} source 30 | * @return {*} new 31 | */ 32 | 33 | 34 | /** 35 | * @memberOf module:zrender/core/util 36 | * @param {*} target 37 | * @param {*} source 38 | * @param {boolean} [overwrite=false] 39 | */ 40 | 41 | 42 | /** 43 | * @param {Array} targetAndSources The first item is target, and the rests are source. 44 | * @param {boolean} [overwrite=false] 45 | * @return {*} target 46 | */ 47 | 48 | 49 | /** 50 | * @param {*} target 51 | * @param {*} source 52 | * @memberOf module:zrender/core/util 53 | */ 54 | 55 | 56 | /** 57 | * @param {*} target 58 | * @param {*} source 59 | * @param {boolean} [overlay=false] 60 | * @memberOf module:zrender/core/util 61 | */ 62 | 63 | 64 | 65 | 66 | 67 | 68 | /** 69 | * 鏌ヨ鏁扮粍涓厓绱犵殑index 70 | * @memberOf module:zrender/core/util 71 | */ 72 | 73 | 74 | /** 75 | * 鏋勯€犵被缁ф壙鍏崇郴 76 | * 77 | * @memberOf module:zrender/core/util 78 | * @param {Function} clazz 婧愮被 79 | * @param {Function} baseClazz 鍩虹被 80 | */ 81 | 82 | 83 | /** 84 | * @memberOf module:zrender/core/util 85 | * @param {Object|Function} target 86 | * @param {Object|Function} sorce 87 | * @param {boolean} overlay 88 | */ 89 | 90 | 91 | /** 92 | * Consider typed array. 93 | * @param {Array|TypedArray} data 94 | */ 95 | 96 | 97 | /** 98 | * 鏁扮粍鎴栧璞¢亶鍘� 99 | * @memberOf module:zrender/core/util 100 | * @param {Object|Array} obj 101 | * @param {Function} cb 102 | * @param {*} [context] 103 | */ 104 | 105 | 106 | /** 107 | * 鏁扮粍鏄犲皠 108 | * @memberOf module:zrender/core/util 109 | * @param {Array} obj 110 | * @param {Function} cb 111 | * @param {*} [context] 112 | * @return {Array} 113 | */ 114 | function map(obj, cb, context) { 115 | if (!(obj && cb)) { 116 | return; 117 | } 118 | if (obj.map && obj.map === nativeMap) { 119 | return obj.map(cb, context); 120 | } 121 | else { 122 | var result = []; 123 | for (var i = 0, len = obj.length; i < len; i++) { 124 | result.push(cb.call(context, obj[i], i, obj)); 125 | } 126 | return result; 127 | } 128 | } 129 | 130 | /** 131 | * @memberOf module:zrender/core/util 132 | * @param {Array} obj 133 | * @param {Function} cb 134 | * @param {Object} [memo] 135 | * @param {*} [context] 136 | * @return {Array} 137 | */ 138 | 139 | 140 | /** 141 | * 鏁扮粍杩囨护 142 | * @memberOf module:zrender/core/util 143 | * @param {Array} obj 144 | * @param {Function} cb 145 | * @param {*} [context] 146 | * @return {Array} 147 | */ 148 | 149 | 150 | /** 151 | * 鏁扮粍椤规煡鎵� 152 | * @memberOf module:zrender/core/util 153 | * @param {Array} obj 154 | * @param {Function} cb 155 | * @param {*} [context] 156 | * @return {*} 157 | */ 158 | 159 | 160 | /** 161 | * @memberOf module:zrender/core/util 162 | * @param {Function} func 163 | * @param {*} context 164 | * @return {Function} 165 | */ 166 | 167 | 168 | /** 169 | * @memberOf module:zrender/core/util 170 | * @param {Function} func 171 | * @return {Function} 172 | */ 173 | 174 | 175 | /** 176 | * @memberOf module:zrender/core/util 177 | * @param {*} value 178 | * @return {boolean} 179 | */ 180 | 181 | 182 | /** 183 | * @memberOf module:zrender/core/util 184 | * @param {*} value 185 | * @return {boolean} 186 | */ 187 | 188 | 189 | /** 190 | * @memberOf module:zrender/core/util 191 | * @param {*} value 192 | * @return {boolean} 193 | */ 194 | 195 | 196 | /** 197 | * @memberOf module:zrender/core/util 198 | * @param {*} value 199 | * @return {boolean} 200 | */ 201 | 202 | 203 | /** 204 | * @memberOf module:zrender/core/util 205 | * @param {*} value 206 | * @return {boolean} 207 | */ 208 | 209 | 210 | /** 211 | * @memberOf module:zrender/core/util 212 | * @param {*} value 213 | * @return {boolean} 214 | */ 215 | 216 | 217 | /** 218 | * @memberOf module:zrender/core/util 219 | * @param {*} value 220 | * @return {boolean} 221 | */ 222 | 223 | 224 | /** 225 | * Whether is exactly NaN. Notice isNaN('a') returns true. 226 | * @param {*} value 227 | * @return {boolean} 228 | */ 229 | 230 | 231 | /** 232 | * If value1 is not null, then return value1, otherwise judget rest of values. 233 | * Low performance. 234 | * @memberOf module:zrender/core/util 235 | * @return {*} Final value 236 | */ 237 | 238 | 239 | 240 | 241 | 242 | 243 | /** 244 | * @memberOf module:zrender/core/util 245 | * @param {Array} arr 246 | * @param {number} startIndex 247 | * @param {number} endIndex 248 | * @return {Array} 249 | */ 250 | 251 | 252 | /** 253 | * Normalize css liked array configuration 254 | * e.g. 255 | * 3 => [3, 3, 3, 3] 256 | * [4, 2] => [4, 2, 4, 2] 257 | * [4, 3, 2] => [4, 3, 2, 3] 258 | * @param {number|Array.} val 259 | * @return {Array.} 260 | */ 261 | 262 | 263 | /** 264 | * @memberOf module:zrender/core/util 265 | * @param {boolean} condition 266 | * @param {string} message 267 | */ 268 | 269 | 270 | /** 271 | * @memberOf module:zrender/core/util 272 | * @param {string} str string to be trimed 273 | * @return {string} trimed string 274 | */ 275 | 276 | 277 | /** 278 | * Set an object as primitive to be ignored traversing children in clone or merge 279 | */ 280 | 281 | // GEXF File Parser 282 | // http://gexf.net/1.2draft/gexf-12draft-primer.pdf 283 | 284 | function parse(xml) { 285 | var doc; 286 | if (typeof xml === 'string') { 287 | var parser = new DOMParser(); 288 | doc = parser.parseFromString(xml, 'text/xml'); 289 | } 290 | else { 291 | doc = xml; 292 | } 293 | if (!doc || doc.getElementsByTagName('parsererror').length) { 294 | return null; 295 | } 296 | 297 | var gexfRoot = getChildByTagName(doc, 'gexf'); 298 | 299 | if (!gexfRoot) { 300 | return null; 301 | } 302 | 303 | var graphRoot = getChildByTagName(gexfRoot, 'graph'); 304 | 305 | var attributes = parseAttributes(getChildByTagName(graphRoot, 'attributes')); 306 | var attributesMap = {}; 307 | for (var i = 0; i < attributes.length; i++) { 308 | attributesMap[attributes[i].id] = attributes[i]; 309 | } 310 | 311 | return { 312 | nodes: parseNodes(getChildByTagName(graphRoot, 'nodes'), attributesMap), 313 | links: parseEdges(getChildByTagName(graphRoot, 'edges')) 314 | }; 315 | } 316 | 317 | function parseAttributes(parent) { 318 | return parent ? map(getChildrenByTagName(parent, 'attribute'), function (attribDom) { 319 | return { 320 | id: getAttr(attribDom, 'id'), 321 | title: getAttr(attribDom, 'title'), 322 | type: getAttr(attribDom, 'type') 323 | }; 324 | }) : []; 325 | } 326 | 327 | function parseNodes(parent, attributesMap) { 328 | return parent ? map(getChildrenByTagName(parent, 'node'), function (nodeDom) { 329 | 330 | var id = getAttr(nodeDom, 'id'); 331 | var label = getAttr(nodeDom, 'label'); 332 | 333 | var node = { 334 | id: id, 335 | name: label, 336 | itemStyle: { 337 | normal: {} 338 | } 339 | }; 340 | 341 | var vizSizeDom = getChildByTagName(nodeDom, 'viz:size'); 342 | var vizPosDom = getChildByTagName(nodeDom, 'viz:position'); 343 | var vizColorDom = getChildByTagName(nodeDom, 'viz:color'); 344 | // var vizShapeDom = getChildByTagName(nodeDom, 'viz:shape'); 345 | 346 | var attvaluesDom = getChildByTagName(nodeDom, 'attvalues'); 347 | 348 | if (vizSizeDom) { 349 | node.symbolSize = parseFloat(getAttr(vizSizeDom, 'value')); 350 | } 351 | if (vizPosDom) { 352 | node.x = parseFloat(getAttr(vizPosDom, 'x')); 353 | node.y = parseFloat(getAttr(vizPosDom, 'y')); 354 | // z 355 | } 356 | if (vizColorDom) { 357 | node.itemStyle.normal.color = 'rgb(' +[ 358 | getAttr(vizColorDom, 'r') | 0, 359 | getAttr(vizColorDom, 'g') | 0, 360 | getAttr(vizColorDom, 'b') | 0 361 | ].join(',') + ')'; 362 | } 363 | // if (vizShapeDom) { 364 | // node.shape = getAttr(vizShapeDom, 'shape'); 365 | // } 366 | if (attvaluesDom) { 367 | var attvalueDomList = getChildrenByTagName(attvaluesDom, 'attvalue'); 368 | 369 | node.attributes = {}; 370 | 371 | for (var j = 0; j < attvalueDomList.length; j++) { 372 | var attvalueDom = attvalueDomList[j]; 373 | var attId = getAttr(attvalueDom, 'for'); 374 | var attValue = getAttr(attvalueDom, 'value'); 375 | var attribute = attributesMap[attId]; 376 | 377 | if (attribute) { 378 | switch (attribute.type) { 379 | case 'integer': 380 | case 'long': 381 | attValue = parseInt(attValue, 10); 382 | break; 383 | case 'float': 384 | case 'double': 385 | attValue = parseFloat(attValue); 386 | break; 387 | case 'boolean': 388 | attValue = attValue.toLowerCase() == 'true'; 389 | break; 390 | default: 391 | } 392 | node.attributes[attId] = attValue; 393 | } 394 | } 395 | } 396 | 397 | return node; 398 | }) : []; 399 | } 400 | 401 | function parseEdges(parent) { 402 | return parent ? map(getChildrenByTagName(parent, 'edge'), function (edgeDom) { 403 | var id = getAttr(edgeDom, 'id'); 404 | var label = getAttr(edgeDom, 'label'); 405 | 406 | var sourceId = getAttr(edgeDom, 'source'); 407 | var targetId = getAttr(edgeDom, 'target'); 408 | 409 | var edge = { 410 | id: id, 411 | name: label, 412 | source: sourceId, 413 | target: targetId, 414 | lineStyle: { 415 | normal: {} 416 | } 417 | }; 418 | 419 | var lineStyle = edge.lineStyle.normal; 420 | 421 | var vizThicknessDom = getChildByTagName(edgeDom, 'viz:thickness'); 422 | var vizColorDom = getChildByTagName(edgeDom, 'viz:color'); 423 | // var vizShapeDom = getChildByTagName(edgeDom, 'viz:shape'); 424 | 425 | if (vizThicknessDom) { 426 | lineStyle.width = parseFloat(vizThicknessDom.getAttribute('value')); 427 | } 428 | if (vizColorDom) { 429 | lineStyle.color = 'rgb(' + [ 430 | getAttr(vizColorDom, 'r') | 0, 431 | getAttr(vizColorDom, 'g') | 0, 432 | getAttr(vizColorDom, 'b') | 0 433 | ].join(',') + ')'; 434 | } 435 | // if (vizShapeDom) { 436 | // edge.shape = vizShapeDom.getAttribute('shape'); 437 | // } 438 | 439 | return edge; 440 | }) : []; 441 | } 442 | 443 | function getAttr(el, attrName) { 444 | return el.getAttribute(attrName); 445 | } 446 | 447 | function getChildByTagName (parent, tagName) { 448 | var node = parent.firstChild; 449 | 450 | while (node) { 451 | if ( 452 | node.nodeType != 1 || 453 | node.nodeName.toLowerCase() != tagName.toLowerCase() 454 | ) { 455 | node = node.nextSibling; 456 | } else { 457 | return node; 458 | } 459 | } 460 | 461 | return null; 462 | } 463 | 464 | function getChildrenByTagName (parent, tagName) { 465 | var node = parent.firstChild; 466 | var children = []; 467 | while (node) { 468 | if (node.nodeName.toLowerCase() == tagName.toLowerCase()) { 469 | children.push(node); 470 | } 471 | node = node.nextSibling; 472 | } 473 | 474 | return children; 475 | } 476 | 477 | 478 | var gexf = (Object.freeze || Object)({ 479 | parse: parse 480 | }); 481 | 482 | /** 483 | * Copyright (c) 2010-2015, Michael Bostock 484 | * All rights reserved. 485 | * 486 | * Redistribution and use in source and binary forms, with or without 487 | * modification, are permitted provided that the following conditions are met: 488 | * 489 | * * Redistributions of source code must retain the above copyright notice, this 490 | * list of conditions and the following disclaimer. 491 | * 492 | * * Redistributions in binary form must reproduce the above copyright notice, 493 | * this list of conditions and the following disclaimer in the documentation 494 | * and/or other materials provided with the distribution. 495 | * 496 | * * The name Michael Bostock may not be used to endorse or promote products 497 | * derived from this software without specific prior written permission. 498 | * 499 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 500 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 501 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 502 | * DISCLAIMED. IN NO EVENT SHALL MICHAEL BOSTOCK BE LIABLE FOR ANY DIRECT, 503 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 504 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 505 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 506 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 507 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 508 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 509 | */ 510 | 511 | /** 512 | * @see 513 | * @see 514 | * @param {Array.} ascArr 515 | */ 516 | var quantile = function(ascArr, p) { 517 | var H = (ascArr.length - 1) * p + 1, 518 | h = Math.floor(H), 519 | v = +ascArr[h - 1], 520 | e = H - h; 521 | return e ? v + e * (ascArr[h] - v) : v; 522 | }; 523 | 524 | /** 525 | * Linear mapping a value from domain to range 526 | * @memberOf module:echarts/util/number 527 | * @param {(number|Array.)} val 528 | * @param {Array.} domain Domain extent domain[0] can be bigger than domain[1] 529 | * @param {Array.} range Range extent range[0] can be bigger than range[1] 530 | * @param {boolean} clamp 531 | * @return {(number|Array.} 532 | */ 533 | 534 | 535 | /** 536 | * Convert a percent string to absolute number. 537 | * Returns NaN if percent is not a valid string or number 538 | * @memberOf module:echarts/util/number 539 | * @param {string|number} percent 540 | * @param {number} all 541 | * @return {number} 542 | */ 543 | 544 | 545 | /** 546 | * (1) Fix rounding error of float numbers. 547 | * (2) Support return string to avoid scientific notation like '3.5e-7'. 548 | * 549 | * @param {number} x 550 | * @param {number} [precision] 551 | * @param {boolean} [returnStr] 552 | * @return {number|string} 553 | */ 554 | 555 | 556 | function asc(arr) { 557 | arr.sort(function (a, b) { 558 | return a - b; 559 | }); 560 | return arr; 561 | } 562 | 563 | /** 564 | * Get precision 565 | * @param {number} val 566 | */ 567 | 568 | 569 | /** 570 | * @param {string|number} val 571 | * @return {number} 572 | */ 573 | 574 | 575 | /** 576 | * Minimal dicernible data precisioin according to a single pixel. 577 | * 578 | * @param {Array.} dataExtent 579 | * @param {Array.} pixelExtent 580 | * @return {number} precision 581 | */ 582 | 583 | 584 | /** 585 | * Get a data of given precision, assuring the sum of percentages 586 | * in valueList is 1. 587 | * The largest remainer method is used. 588 | * https://en.wikipedia.org/wiki/Largest_remainder_method 589 | * 590 | * @param {Array.} valueList a list of all data 591 | * @param {number} idx index of the data to be processed in valueList 592 | * @param {number} precision integer number showing digits of precision 593 | * @return {number} percent ranging from 0 to 100 594 | */ 595 | 596 | 597 | // Number.MAX_SAFE_INTEGER, ie do not support. 598 | 599 | 600 | /** 601 | * To 0 - 2 * PI, considering negative radian. 602 | * @param {number} radian 603 | * @return {number} 604 | */ 605 | 606 | 607 | /** 608 | * @param {type} radian 609 | * @return {boolean} 610 | */ 611 | 612 | 613 | /** 614 | * @param {string|Date|number} value These values can be accepted: 615 | * + An instance of Date, represent a time in its own time zone. 616 | * + Or string in a subset of ISO 8601, only including: 617 | * + only year, month, date: '2012-03', '2012-03-01', '2012-03-01 05', '2012-03-01 05:06', 618 | * + separated with T or space: '2012-03-01T12:22:33.123', '2012-03-01 12:22:33.123', 619 | * + time zone: '2012-03-01T12:22:33Z', '2012-03-01T12:22:33+8000', '2012-03-01T12:22:33-05:00', 620 | * all of which will be treated as local time if time zone is not specified 621 | * (see ). 622 | * + Or other string format, including (all of which will be treated as loacal time): 623 | * '2012', '2012-3-1', '2012/3/1', '2012/03/01', 624 | * '2009/6/12 2:00', '2009/6/12 2:05:08', '2009/6/12 2:05:08.123' 625 | * + a timestamp, which represent a time in UTC. 626 | * @return {Date} date 627 | */ 628 | 629 | 630 | /** 631 | * Quantity of a number. e.g. 0.1, 1, 10, 100 632 | * 633 | * @param {number} val 634 | * @return {number} 635 | */ 636 | 637 | 638 | /** 639 | * find a 鈥渘ice鈥� number approximately equal to x. Round the number if round = true, 640 | * take ceiling if round = false. The primary observation is that the 鈥渘icest鈥� 641 | * numbers in decimal are 1, 2, and 5, and all power-of-ten multiples of these numbers. 642 | * 643 | * See "Nice Numbers for Graph Labels" of Graphic Gems. 644 | * 645 | * @param {number} val Non-negative value. 646 | * @param {boolean} round 647 | * @return {number} 648 | */ 649 | 650 | 651 | /** 652 | * Order intervals asc, and split them when overlap. 653 | * expect(numberUtil.reformIntervals([ 654 | * {interval: [18, 62], close: [1, 1]}, 655 | * {interval: [-Infinity, -70], close: [0, 0]}, 656 | * {interval: [-70, -26], close: [1, 1]}, 657 | * {interval: [-26, 18], close: [1, 1]}, 658 | * {interval: [62, 150], close: [1, 1]}, 659 | * {interval: [106, 150], close: [1, 1]}, 660 | * {interval: [150, Infinity], close: [0, 0]} 661 | * ])).toEqual([ 662 | * {interval: [-Infinity, -70], close: [0, 0]}, 663 | * {interval: [-70, -26], close: [1, 1]}, 664 | * {interval: [-26, 18], close: [0, 1]}, 665 | * {interval: [18, 62], close: [0, 1]}, 666 | * {interval: [62, 150], close: [0, 1]}, 667 | * {interval: [150, Infinity], close: [0, 0]} 668 | * ]); 669 | * @param {Array.} list, where `close` mean open or close 670 | * of the interval, and Infinity can be used. 671 | * @return {Array.} The origin list, which has been reformed. 672 | */ 673 | 674 | 675 | /** 676 | * parseFloat NaNs numeric-cast false positives (null|true|false|"") 677 | * ...but misinterprets leading-number strings, particularly hex literals ("0x...") 678 | * subtraction forces infinities to NaN 679 | * 680 | * @param {*} v 681 | * @return {boolean} 682 | */ 683 | 684 | /** 685 | * See: 686 | * 687 | * 688 | * 689 | * Helper method for preparing data. 690 | * 691 | * @param {Array.} rawData like 692 | * [ 693 | * [12,232,443], (raw data set for the first box) 694 | * [3843,5545,1232], (raw datat set for the second box) 695 | * ... 696 | * ] 697 | * @param {Object} [opt] 698 | * 699 | * @param {(number|string)} [opt.boundIQR=1.5] Data less than min bound is outlier. 700 | * default 1.5, means Q1 - 1.5 * (Q3 - Q1). 701 | * If 'none'/0 passed, min bound will not be used. 702 | * @param {(number|string)} [opt.layout='horizontal'] 703 | * Box plot layout, can be 'horizontal' or 'vertical' 704 | * @return {Object} { 705 | * boxData: Array.> 706 | * outliers: Array.> 707 | * axisData: Array. 708 | * } 709 | */ 710 | var prepareBoxplotData = function (rawData, opt) { 711 | opt = opt || []; 712 | var boxData = []; 713 | var outliers = []; 714 | var axisData = []; 715 | var boundIQR = opt.boundIQR; 716 | var useExtreme = boundIQR === 'none' || boundIQR === 0; 717 | 718 | for (var i = 0; i < rawData.length; i++) { 719 | axisData.push(i + ''); 720 | var ascList = asc(rawData[i].slice()); 721 | 722 | var Q1 = quantile(ascList, 0.25); 723 | var Q2 = quantile(ascList, 0.5); 724 | var Q3 = quantile(ascList, 0.75); 725 | var min = ascList[0]; 726 | var max = ascList[ascList.length - 1]; 727 | 728 | var bound = (boundIQR == null ? 1.5 : boundIQR) * (Q3 - Q1); 729 | 730 | var low = useExtreme 731 | ? min 732 | : Math.max(min, Q1 - bound); 733 | var high = useExtreme 734 | ? max 735 | : Math.min(max, Q3 + bound); 736 | 737 | boxData.push([low, Q1, Q2, Q3, high]); 738 | 739 | for (var j = 0; j < ascList.length; j++) { 740 | var dataItem = ascList[j]; 741 | if (dataItem < low || dataItem > high) { 742 | var outlier = [i, dataItem]; 743 | opt.layout === 'vertical' && outlier.reverse(); 744 | outliers.push(outlier); 745 | } 746 | } 747 | } 748 | return { 749 | boxData: boxData, 750 | outliers: outliers, 751 | axisData: axisData 752 | }; 753 | }; 754 | 755 | var version = '1.0.0'; 756 | 757 | // For backward compatibility, where the namespace `dataTool` will 758 | // be mounted on `echarts` is the extension `dataTool` is imported. 759 | // But the old version of echarts do not have `dataTool` namespace, 760 | // so check it before mounting. 761 | if (echarts.dataTool) { 762 | echarts.dataTool.version = version; 763 | echarts.dataTool.gexf = gexf; 764 | echarts.dataTool.prepareBoxplotData = prepareBoxplotData; 765 | } 766 | 767 | exports.version = version; 768 | exports.gexf = gexf; 769 | exports.prepareBoxplotData = prepareBoxplotData; 770 | 771 | }))); 772 | //# sourceMappingURL=dataTool.js.map -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . --------------------------------------------------------------------------------