# ghmate
A comprehensive Python package for interacting with the GitHub API. This package simplifies GitHub API calls by providing a set of high-level commands encapsulated in easy-to-use classes.
### Prerequisites
### Prerequisites
- Python 3.8 or higher (specify other supported versions if applicable)
- `pip` for installing packages
- A GitHub account and [Personal Access Token](https://github.com/settings/tokens) (required for making authenticated API requests)
## Installation
To install `ghmate`, ensure you have Python 3.8 or higher and pip installed. Run the following command:
```bash
pip install ghmate
```
## Setup
Before using `ghmate`, set up your environment with your GitHub personal access token:
```bash
export GITHUB_TOKEN='your_personal_access_token'
```
(Optional) Use a .env file with python-dotenv to load environment variables.
Create a `.env` file in your project directory and add your GitHub Personal Access Token, repository owner, and repository name.
```plaintext
GITHUB_TOKEN=your_personal_access_token_here
OWNER=repository_owner_here
REPO=repository_name_here
```
Load environment variables using `python-dotenv`.
```python
import os
from dotenv import load_dotenv
# Load environment variables
load_dotenv()
# Get environment variables
token = os.getenv('GITHUB_TOKEN')
owner = os.getenv('OWNER')
repo = os.getenv('REPO')
```
## Usage
Initialize the GitHubClient with your repository owner, name, and token.
Replace owner_name, repository_name, and your_token with your actual GitHub information.
To start using `ghmate`, initialize the `GitHubClient`:
```python
from ghmate.github_client import GitHubClient
github_client = GitHubClient(
owner="owner_name",
repo="repository_name",
token="your_token"
)
```
Use CoreCommands for basic operations and ActionsCommands for GitHub Actions-related tasks.
Here are some examples:
### Core Commands
`CoreCommands` provides essential GitHub operations:
```python
from ghmate.core_commands import CoreCommands
core_commands = CoreCommands(
token="your_token",
owner="owner_name",
repo="repository_name"
)
# Authenticate and get user information
user_info = core_commands.auth()
# Browse topics
topics = core_commands.browse()
# Create an issue
issue = core_commands.issue(action='create', title='Issue Title', body='Issue description')
```
### Actions Commands
`ActionsCommands` focuses on GitHub Actions-related tasks:
```python
from ghmate.actions_commands import ActionsCommands
actions_commands = ActionsCommands(owner="owner_name", repo="repository_name", token="your_token")
# List artifacts
artifacts = actions_commands.list_artifacts()
# Cache management
cache_list = actions_commands.cache(action='list')
cache_restore = actions_commands.cache(action='restore', key='cache_key')
```
Handle exceptions that may occur during API calls.
## Tests
### Unit Test
Run tests to ensure the package is working as expected.
```bash
python -m unittest discover -s tests/unit
# OR
python3 -m unittest discover -s tests/unit
```
Mock external API calls when writing unit tests.
Integration tests will make actual API calls, so ensure you have the correct setup.
When writing unit tests, use the `unittest.mock` module to mock external API calls.
For example:
```python
from unittest import TestCase
from unittest.mock import patch
from ghmate.actions_commands import ActionsCommands
class TestActionsCommandsUnit(TestCase):
@patch.object(ActionsCommands, '_make_request')
def test_list_artifacts(self, mock_request):
# Your test code here
pass
```
### Integration Tests
For integration tests, ensure your .env file contains the necessary environment variables and run:
```bash
python -m unittest discover -s tests/integration
```
## Examples
Examples
The `examples` directory contains a sample project setup and usage examples.
```plaintext
example/
├── .env # Storing environment variables
├── using_dotenv.py # Example script utilizing the ghmate package
└── requirements.txt # Required packages
```
## Contributing
Contributions are welcome! Please read our [contributing guidelines](CONTRIBUTING.md) to get started.
## License
`ghmate` is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
Raw data
{
"_id": null,
"home_page": "https://github.com/serityops/ghmate",
"name": "ghmate",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "github,api,package",
"author": "",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/36/f9/86999ea2a051f1a026f7aad2b1c7a5a038e5345a2a30cb7410d210907857/ghmate-1.0.0.tar.gz",
"platform": null,
"description": "# ghmate\n\nA comprehensive Python package for interacting with the GitHub API. This package simplifies GitHub API calls by providing a set of high-level commands encapsulated in easy-to-use classes.\n\n### Prerequisites\n\n### Prerequisites\n\n- Python 3.8 or higher (specify other supported versions if applicable)\n- `pip` for installing packages\n- A GitHub account and [Personal Access Token](https://github.com/settings/tokens) (required for making authenticated API requests)\n\n## Installation\n\nTo install `ghmate`, ensure you have Python 3.8 or higher and pip installed. Run the following command:\n```bash\npip install ghmate\n```\n\n## Setup\n\nBefore using `ghmate`, set up your environment with your GitHub personal access token:\n```bash\nexport GITHUB_TOKEN='your_personal_access_token'\n```\n\n(Optional) Use a .env file with python-dotenv to load environment variables.\nCreate a `.env` file in your project directory and add your GitHub Personal Access Token, repository owner, and repository name.\n\n```plaintext\nGITHUB_TOKEN=your_personal_access_token_here\nOWNER=repository_owner_here\nREPO=repository_name_here\n```\n\nLoad environment variables using `python-dotenv`.\n\n```python\nimport os\nfrom dotenv import load_dotenv\n\n# Load environment variables\nload_dotenv()\n\n# Get environment variables\ntoken = os.getenv('GITHUB_TOKEN')\nowner = os.getenv('OWNER')\nrepo = os.getenv('REPO')\n```\n\n## Usage\nInitialize the GitHubClient with your repository owner, name, and token. \nReplace owner_name, repository_name, and your_token with your actual GitHub information.\n\n\nTo start using `ghmate`, initialize the `GitHubClient`:\n\n```python\nfrom ghmate.github_client import GitHubClient\n\ngithub_client = GitHubClient(\n owner=\"owner_name\",\n repo=\"repository_name\",\n token=\"your_token\"\n)\n```\nUse CoreCommands for basic operations and ActionsCommands for GitHub Actions-related tasks. \nHere are some examples:\n\n### Core Commands\n`CoreCommands` provides essential GitHub operations:\n\n```python\nfrom ghmate.core_commands import CoreCommands\n\ncore_commands = CoreCommands(\n token=\"your_token\",\n owner=\"owner_name\",\n repo=\"repository_name\"\n)\n\n# Authenticate and get user information\nuser_info = core_commands.auth()\n\n# Browse topics\ntopics = core_commands.browse()\n\n# Create an issue\nissue = core_commands.issue(action='create', title='Issue Title', body='Issue description')\n\n```\n\n### Actions Commands\n`ActionsCommands` focuses on GitHub Actions-related tasks:\n\n```python\nfrom ghmate.actions_commands import ActionsCommands\n\nactions_commands = ActionsCommands(owner=\"owner_name\", repo=\"repository_name\", token=\"your_token\")\n\n# List artifacts\nartifacts = actions_commands.list_artifacts()\n\n# Cache management\ncache_list = actions_commands.cache(action='list')\ncache_restore = actions_commands.cache(action='restore', key='cache_key')\n\n```\n\nHandle exceptions that may occur during API calls.\n\n## Tests\n\n### Unit Test\n\nRun tests to ensure the package is working as expected.\n\n```bash\npython -m unittest discover -s tests/unit\n# OR\npython3 -m unittest discover -s tests/unit\n\n```\nMock external API calls when writing unit tests. \nIntegration tests will make actual API calls, so ensure you have the correct setup.\nWhen writing unit tests, use the `unittest.mock` module to mock external API calls. \n\nFor example:\n\n```python\nfrom unittest import TestCase\nfrom unittest.mock import patch\nfrom ghmate.actions_commands import ActionsCommands\n\nclass TestActionsCommandsUnit(TestCase):\n @patch.object(ActionsCommands, '_make_request')\n def test_list_artifacts(self, mock_request):\n # Your test code here\n pass\n\n```\n\n### Integration Tests\nFor integration tests, ensure your .env file contains the necessary environment variables and run:\n\n```bash\npython -m unittest discover -s tests/integration\n```\n\n## Examples\nExamples\nThe `examples` directory contains a sample project setup and usage examples.\n\n```plaintext\nexample/\n\u251c\u2500\u2500 .env # Storing environment variables\n\u251c\u2500\u2500 using_dotenv.py # Example script utilizing the ghmate package\n\u2514\u2500\u2500 requirements.txt # Required packages\n```\n## Contributing\n\nContributions are welcome! Please read our [contributing guidelines](CONTRIBUTING.md) to get started.\n\n## License\n\n`ghmate` is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A Python package for interacting with the GitHub API.",
"version": "1.0.0",
"project_urls": {
"Homepage": "https://github.com/serityops/ghmate"
},
"split_keywords": [
"github",
"api",
"package"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "84a6bb793f9b1a750025a1433b80792943442b68ac7c7b4932baa6004a568cce",
"md5": "8bac95055b0653ed4094a99ae1c9352b",
"sha256": "173d0afd19efda9a9d8118978be9a5b54c3945a18d8a361a0c9c1c04727f245e"
},
"downloads": -1,
"filename": "ghmate-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8bac95055b0653ed4094a99ae1c9352b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 10448,
"upload_time": "2023-11-05T22:10:55",
"upload_time_iso_8601": "2023-11-05T22:10:55.476891Z",
"url": "https://files.pythonhosted.org/packages/84/a6/bb793f9b1a750025a1433b80792943442b68ac7c7b4932baa6004a568cce/ghmate-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "36f986999ea2a051f1a026f7aad2b1c7a5a038e5345a2a30cb7410d210907857",
"md5": "d5b9fde14b3ea993185aecfcb78790bf",
"sha256": "c063aba0e3e0a46236aaaca087f1bc8c4b1ed60597148687094e169838fa9d3b"
},
"downloads": -1,
"filename": "ghmate-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "d5b9fde14b3ea993185aecfcb78790bf",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 9325,
"upload_time": "2023-11-05T22:10:56",
"upload_time_iso_8601": "2023-11-05T22:10:56.891763Z",
"url": "https://files.pythonhosted.org/packages/36/f9/86999ea2a051f1a026f7aad2b1c7a5a038e5345a2a30cb7410d210907857/ghmate-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-11-05 22:10:56",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "serityops",
"github_project": "ghmate",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "ghmate"
}