Name | sourcegraph JSON |
Version |
0.0.7
JSON |
| download |
home_page | None |
Summary | Convert GitHub Repo Into Graph |
upload_time | 2024-08-05 03:56:06 |
maintainer | None |
docs_url | None |
author | None |
requires_python | <=3.12,>=3.9.7 |
license | MIT License Copyright (c) [2024] [Ransaka Ravihara] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
networkx
python
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Sourcegraph Python Library
This Python library provides an interface to analyze and visualize code dependencies in GitHub repositories.
> **⚠️ Warning: Currently only supports Python repositories**
>
> Please note that this library is currently designed to work only with Python repositories. Analysis of repositories in other programming languages is not supported at this time.
## Installation
You can install the Sourcegraph Python library using pip:
```
pip install sourcegraph
```
## Usage
Here's how you can use the Sourcegraph library to analyze a GitHub repository:
```python
from sourcegraph import Sourcegraph
# Initialize the Sourcegraph object with a repository URL
repo = Sourcegraph(repository_url='https://github.com/Ransaka/sinlib.git')
# Generate a dependency graph
repo.run()
# Plot the dependency graph
repo.plot() # Supports different networkx compatible layouts when plotting
# Get properties of a specific node (function or class)
node_properties = repo.get_node_property('process_text')
print(node_properties)
# Get the total number of nodes in the repository
print(repo.n_nodes)
# Get all functions and classes in the repository
functions_and_classes = repo.get_functions_and_classes
print(functions_and_classes)
# Get dependencies of a specific class or function
tokenizer_dependencies = repo.get_dependencies("Tokenizer")
print(tokenizer_dependencies)
```
## Features
- **Dependency Analysis**: Analyze and visualize the dependencies between functions and classes in a GitHub repository.
- **Code Inspection**: Retrieve detailed information about specific functions or classes, including their definitions and docstrings.
- **Visualization**: Plot dependency graphs using networkx-compatible layouts.
## Main Methods
- `run()`: Generates the dependency graph for the specified repository.
- `plot()`: Visualizes the dependency graph.
- `get_node_property(node_name)`: Retrieves properties of a specific node (function or class).
- `get_functions_and_classes`: Returns a list of all functions and classes in the repository.
- `get_dependencies(node_name)`: Returns the dependencies of a specific function or class.
## Example Output
Getting node properties:
```python
repo.get_node_property('process_text')
# Output:
# {'type': 'function',
# 'name': 'process_text',
# 'definition': "def process_text(t):\n ...",
# 'file_name': 'preprocessing.py',
# 'docstring': ''}
```
Getting all functions and classes:
```python
repo.get_functions_and_classes
# Output:
# ['Romanizer', 'Tokenizer', 'Transliterator', 'load_tokenizer', ...]
```
Getting dependencies:
```python
repo.get_dependencies("Tokenizer")
# Output:
# {'load_default_vocab_map', 'process_text'}
```
## Limitations
- Currently, this library only supports analysis of Python repositories. Repositories in other programming languages cannot be processed at this time.
- The library assumes that the repository structure follows common Python project conventions.
## Contributing
Contributions to improve the Sourcegraph Python library are welcome. Please feel free to submit a Pull Request.
## License
This project is licensed under the MIT License - see the [LICENSE](https://github.com/Ransaka/sourcegraph/blob/main/LICENSE) file for details.
## Contact
For any queries or suggestions, please open an issue on the GitHub repository.
Raw data
{
"_id": null,
"home_page": null,
"name": "sourcegraph",
"maintainer": null,
"docs_url": null,
"requires_python": "<=3.12,>=3.9.7",
"maintainer_email": null,
"keywords": "NetworkX, Python",
"author": null,
"author_email": "Ransaka <ransaka.ravihara@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/d6/8d/41f90f8ab52e956a31376ba40460c0fb345f9ff0fd821fbaaf2bb7351e6c/sourcegraph-0.0.7.tar.gz",
"platform": null,
"description": "# Sourcegraph Python Library\n\nThis Python library provides an interface to analyze and visualize code dependencies in GitHub repositories.\n\n> **\u26a0\ufe0f Warning: Currently only supports Python repositories**\n> \n> Please note that this library is currently designed to work only with Python repositories. Analysis of repositories in other programming languages is not supported at this time.\n\n## Installation\n\nYou can install the Sourcegraph Python library using pip:\n\n```\npip install sourcegraph\n```\n\n## Usage\n\nHere's how you can use the Sourcegraph library to analyze a GitHub repository:\n\n```python\nfrom sourcegraph import Sourcegraph\n\n# Initialize the Sourcegraph object with a repository URL\nrepo = Sourcegraph(repository_url='https://github.com/Ransaka/sinlib.git')\n\n# Generate a dependency graph\nrepo.run()\n\n# Plot the dependency graph\nrepo.plot() # Supports different networkx compatible layouts when plotting\n\n# Get properties of a specific node (function or class)\nnode_properties = repo.get_node_property('process_text')\nprint(node_properties)\n\n# Get the total number of nodes in the repository\nprint(repo.n_nodes)\n\n# Get all functions and classes in the repository\nfunctions_and_classes = repo.get_functions_and_classes\nprint(functions_and_classes)\n\n# Get dependencies of a specific class or function\ntokenizer_dependencies = repo.get_dependencies(\"Tokenizer\")\nprint(tokenizer_dependencies)\n```\n\n## Features\n\n- **Dependency Analysis**: Analyze and visualize the dependencies between functions and classes in a GitHub repository.\n- **Code Inspection**: Retrieve detailed information about specific functions or classes, including their definitions and docstrings.\n- **Visualization**: Plot dependency graphs using networkx-compatible layouts.\n\n## Main Methods\n\n- `run()`: Generates the dependency graph for the specified repository.\n- `plot()`: Visualizes the dependency graph.\n- `get_node_property(node_name)`: Retrieves properties of a specific node (function or class).\n- `get_functions_and_classes`: Returns a list of all functions and classes in the repository.\n- `get_dependencies(node_name)`: Returns the dependencies of a specific function or class.\n\n## Example Output\n\nGetting node properties:\n```python\nrepo.get_node_property('process_text')\n# Output:\n# {'type': 'function',\n# 'name': 'process_text',\n# 'definition': \"def process_text(t):\\n ...\",\n# 'file_name': 'preprocessing.py',\n# 'docstring': ''}\n```\n\nGetting all functions and classes:\n```python\nrepo.get_functions_and_classes\n# Output:\n# ['Romanizer', 'Tokenizer', 'Transliterator', 'load_tokenizer', ...]\n```\n\nGetting dependencies:\n```python\nrepo.get_dependencies(\"Tokenizer\")\n# Output:\n# {'load_default_vocab_map', 'process_text'}\n```\n\n## Limitations\n\n- Currently, this library only supports analysis of Python repositories. Repositories in other programming languages cannot be processed at this time.\n- The library assumes that the repository structure follows common Python project conventions.\n\n## Contributing\n\nContributions to improve the Sourcegraph Python library are welcome. Please feel free to submit a Pull Request.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](https://github.com/Ransaka/sourcegraph/blob/main/LICENSE) file for details.\n\n## Contact\n\nFor any queries or suggestions, please open an issue on the GitHub repository.\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) [2024] [Ransaka Ravihara] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
"summary": "Convert GitHub Repo Into Graph",
"version": "0.0.7",
"project_urls": {
"Code": "https://github.com/Ransaka/sourcegraph",
"Docs": "https://github.com/Ransaka/sourcegraph"
},
"split_keywords": [
"networkx",
" python"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "1e75e02b7b367335bead609d9e44f78d12ae72079e26f846444c1fd11631d0b5",
"md5": "e9f5787332e48378ca1f65852dcbc14e",
"sha256": "48b90548fb6337a8a5accafa2bb3a78b87a1c19bb50b0a58c0353eae7707baf4"
},
"downloads": -1,
"filename": "sourcegraph-0.0.7-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e9f5787332e48378ca1f65852dcbc14e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<=3.12,>=3.9.7",
"size": 7031,
"upload_time": "2024-08-05T03:56:05",
"upload_time_iso_8601": "2024-08-05T03:56:05.385256Z",
"url": "https://files.pythonhosted.org/packages/1e/75/e02b7b367335bead609d9e44f78d12ae72079e26f846444c1fd11631d0b5/sourcegraph-0.0.7-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d68d41f90f8ab52e956a31376ba40460c0fb345f9ff0fd821fbaaf2bb7351e6c",
"md5": "dde933fc1a65b07ed51ff7fdd8f45001",
"sha256": "e62d7e1392a046df1965feefee0aa6125a7b4f431db57c245693dc2e60f45c5d"
},
"downloads": -1,
"filename": "sourcegraph-0.0.7.tar.gz",
"has_sig": false,
"md5_digest": "dde933fc1a65b07ed51ff7fdd8f45001",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<=3.12,>=3.9.7",
"size": 6959,
"upload_time": "2024-08-05T03:56:06",
"upload_time_iso_8601": "2024-08-05T03:56:06.660685Z",
"url": "https://files.pythonhosted.org/packages/d6/8d/41f90f8ab52e956a31376ba40460c0fb345f9ff0fd821fbaaf2bb7351e6c/sourcegraph-0.0.7.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-05 03:56:06",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Ransaka",
"github_project": "sourcegraph",
"github_not_found": true,
"lcname": "sourcegraph"
}