Skip to content

Commit 5f21cf2

Browse files
authored
Merge pull request #2 from monkut/fix/update-readme
Fix/update readme
2 parents e37d2b5 + 668d7cf commit 5f21cf2

File tree

4 files changed

+54
-39
lines changed

4 files changed

+54
-39
lines changed

README.md

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,34 @@
22

33
This project is intended to provide tools to make it easier to discover the current state of multiple GITHUB Organizational projects.
44

5-
## Usage
65

7-
The main interface is through the `ghorgs.managers.GithubOrganizationManager` class.
8-
This class allows you to obtain all the projects assigned to a given organization, with the option to filter projects based on the project name.
6+
## GithubOrganizationManager class
97

10-
> NOTE: Github token may be set in the GITHUB_ACCESS_TOKEN environment variable.
8+
The main user interface is through the `ghorgs.managers.GithubOrganizationManager` class.
119

12-
Example:
13-
```
14-
from ghorgs.managers import GithubOrganizationManager
15-
ORGANIZATION = 'my orgnaization'
16-
PROJECT_NAMES_FILTER = ['My Org Project Name']
17-
manager = GithubOrganizationManager(github_oauth_token,
18-
ORGANIZATION)
19-
for project in manager.projects():
20-
for issue in project.issues():
21-
print(issue.simple)
22-
```
10+
### GithubOrganizationManager Methods
11+
12+
- `create_organizational_project(name: str, description: str, columns: list =None) -> Tuple[str, List[object]]`
13+
- Creates a new *organizational project*
14+
15+
- `projects() -> Generator[GithubOrganizationProject, None, None]`
16+
- returns a generator yielding `GithubOrganizationProject()` objects
17+
18+
- `repositories(names: List[str]=None) -> Generator[GithubRepository, None, None]`
19+
- returns a generator yielding `GithubRepository` objects
20+
21+
22+
## GithubOrganizationProject class
23+
24+
### GithubOrganizationProject methods
2325

2426
The `GithubOrganizationManager.projects()` method *yields* `GithubOrganizationProject` objects.
2527
`GithubOrganizationProject` objects wrap the github API returned JSON by providing the following convience methods:
2628

27-
*issues*
28-
29-
- Method that provides all issues attached to an *organzation project*, with the option to filter by *column_name*
30-
Returns a list of github issues containing the following information:
31-
- Resulting in a GithubIssue object that wraps the JSON object returned by the github API.
29+
- `issues()`
30+
- Method that provides all issues attached to an *organzation project*, with the option to filter by *column_name*
31+
Returns a list of github issues containing the following information:
32+
- Resulting in a GithubIssue object that wraps the JSON object returned by the github API.
3233

3334
```
3435
# Returned issue information:
@@ -54,9 +55,9 @@ ISSUE_DESCRIPTION, (str)
5455
]
5556
```
5657

57-
*columns*
58+
- `columns()`
59+
- Returns all available column data assigned to the project.
5860

59-
- Returns all available column data assigned to the project.
6061
```
6162
[
6263
{
@@ -68,6 +69,23 @@ ISSUE_DESCRIPTION, (str)
6869
'updated_at': '2017-03-27T04:11:18Z',
6970
'url': 'https://api.github.com/projects/columns/11111'
7071
},
71-
...
72+
...
7273
]
7374
```
75+
76+
77+
## Usage
78+
79+
> NOTE: Github token may be set in the GITHUB_ACCESS_TOKEN environment variable.
80+
81+
Example:
82+
```
83+
from ghorgs.managers import GithubOrganizationManager
84+
ORGANIZATION = 'my orgnaization'
85+
manager = GithubOrganizationManager(github_oauth_token,
86+
ORGANIZATION)
87+
for project in manager.projects():
88+
for issue in project.issues():
89+
print(issue.simple)
90+
```
91+

ghorgs/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.2.0'
1+
__version__ = '0.2.1'

ghorgs/exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ class GithubGraphQLError(Exception):
33

44

55
class UnexpectedResponseError(Exception):
6-
pass
6+
pass

ghorgs/managers.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import json
77
import uuid
88
import logging
9-
from typing import Tuple, List
9+
from typing import Tuple, List, Generator
1010
from functools import lru_cache
1111

1212
import requests
@@ -33,7 +33,7 @@ def __init__(self, github_organization_name: str, token: str):
3333
self.organization = github_organization_name
3434
self.token = token
3535

36-
def _get_owner_id(self, name):
36+
def _get_owner_id(self, name: str) -> str:
3737
"""Performs a lookup for the related internal github ID needed as a key for other queries"""
3838
query = """
3939
{
@@ -131,7 +131,7 @@ def create_organizational_project(self, name: str, description: str, columns: li
131131

132132
return project_url, responses
133133

134-
def add_columns(self, project_id, columns):
134+
def add_columns(self, project_id: str, columns: List[dict]) -> List:
135135
"""
136136
Add column(s) to the given project.
137137
@@ -173,7 +173,7 @@ class GithubOrganizationManager(GithubPagedRequestHandler):
173173
Functions/Tools for managing Github Organization Projects
174174
"""
175175

176-
def __init__(self, oauth_token=GITHUB_ACCESS_TOKEN, org=None):
176+
def __init__(self, oauth_token: str=GITHUB_ACCESS_TOKEN, org: str=None):
177177
"""
178178
:param oauth_token: GITHUB OAUTH TOKEN
179179
:param org: GITHUB ORGANIZATION NAME
@@ -220,7 +220,7 @@ def create_organizational_project(self, *args, **kwargs) -> Tuple[str, List[obje
220220
return graphql_manager.create_organizational_project(*args, **kwargs)
221221

222222
@lru_cache(maxsize=10)
223-
def projects(self):
223+
def projects(self) -> Generator[GithubOrganizationProject, None, None]:
224224
"""
225225
:return: list of organization project objects
226226
"""
@@ -232,15 +232,15 @@ def projects(self):
232232
yield from (GithubOrganizationProject(self._session, p) for p in projects_data)
233233

234234
@lru_cache(maxsize=10)
235-
def repositories(self, names=None):
236-
def classify(repository_dict):
235+
def repositories(self, names: List[str]=None) -> Generator[GithubRepository, None, None]:
236+
def classify(repository_response: dict) -> GithubRepository:
237237
"""
238-
Load Github repository API dictionary representation to an internally defined GitRepository Object
239-
:param repository_dict: (dict) github Repository dictionary Representation
238+
Load Github repository API dictionary representation into an internally defined GitRepository Object
239+
:param repository_response: (dict) github Repository dictionary Representation
240240
:return: (obj) GithubRepository
241241
"""
242-
repoository_json = json.dumps(repository_dict)
243-
repository = json.loads(repoository_json, object_hook=GithubRepository.from_dict)
242+
repository_json = json.dumps(repository_response)
243+
repository = json.loads(repository_json, object_hook=GithubRepository.from_dict)
244244
repository._session = self._session # attach session so queries can be made
245245
repository._org = self.org
246246
return repository
@@ -298,6 +298,3 @@ def classify(repository_dict):
298298
print('---')
299299
for urls in project.repository_urls():
300300
print(urls)
301-
302-
303-

0 commit comments

Comments
 (0)