mirror of
				https://github.com/RGBCube/GitHubWrapper
				synced 2025-10-31 14:02:46 +00:00 
			
		
		
		
	Fix kwargs + initialize make_repo
This commit is contained in:
		
							parent
							
								
									2a2656c5dd
								
							
						
					
					
						commit
						7fa5a05dc0
					
				
					 2 changed files with 18 additions and 25 deletions
				
			
		|  | @ -128,23 +128,23 @@ async def get_user(session: aiohttp.ClientSession, username: str) -> User: | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| # repo-related functions / utils | # repo-related functions / utils | ||||||
| async def get_repo_from_name(session: aiohttp.ClientSession, owner: str, repo_name: str) -> Repository: | async def get_repo_from_name(session: aiohttp.ClientSession, owner: str, repo: str) -> Repository: | ||||||
|     """Returns a Repo object from the given owner and repo name.""" |     """Returns a Repo object from the given owner and repo name.""" | ||||||
|     result = await session.get(REPO_URL.format(owner, repo_name)) |     result = await session.get(REPO_URL.format(owner, repo)) | ||||||
|     if result.status == 200: |     if result.status == 200: | ||||||
|         return Repository(await result.json(), session) |         return Repository(await result.json(), session) | ||||||
|     raise RepositoryNotFound |     raise RepositoryNotFound | ||||||
| 
 | 
 | ||||||
| async def get_repo_issue(session: aiohttp.ClientSession, owner: str, repo_name: str, issue_number: int) -> Issue: | async def get_repo_issue(session: aiohttp.ClientSession, owner: str, repo: str, issue: int) -> Issue: | ||||||
|     """Returns a single issue from the given owner and repo name.""" |     """Returns a single issue from the given owner and repo name.""" | ||||||
|     result = await session.get(REPO_ISSUE_URL.format(owner, repo_name, issue_number)) |     result = await session.get(REPO_ISSUE_URL.format(owner, repo, issue)) | ||||||
|     if result.status == 200: |     if result.status == 200: | ||||||
|         return Issue(await result.json(), session) |         return Issue(await result.json(), session) | ||||||
|     raise IssueNotFound |     raise IssueNotFound | ||||||
| 
 | 
 | ||||||
| async def make_repo(session: aiohttp.ClientSession, name: str) -> Repository: | async def create_repo(session: aiohttp.ClientSession, name: str, description: str, private: bool, gitignore_template: str, **kwargs) -> Repository: | ||||||
|     """Creates a new repo with the given name.""" |     """Creates a new repo with the given name.""" | ||||||
|     _data = {"name" : name} |     _data = {"name" : name, "description" : description, "private" : private, "gitignore_template" : gitignore_template} | ||||||
|     result = await session.post(MAKE_REPO_URL, data= json.dumps(_data)) |     result = await session.post(MAKE_REPO_URL, data= json.dumps(_data)) | ||||||
|     if result.status == 201: |     if result.status == 201: | ||||||
|         return Repository(await result.json(), session) |         return Repository(await result.json(), session) | ||||||
|  | @ -156,9 +156,9 @@ async def make_repo(session: aiohttp.ClientSession, name: str) -> Repository: | ||||||
| 
 | 
 | ||||||
| # org-related functions / utils | # org-related functions / utils | ||||||
| 
 | 
 | ||||||
| async def get_org(session: aiohttp.ClientSession, org_name: str) -> Organization: | async def get_org(session: aiohttp.ClientSession, org: str) -> Organization: | ||||||
|     """Returns an org's public data in JSON format.""" |     """Returns an org's public data in JSON format.""" | ||||||
|     result = await session.get(ORG_URL.format(org_name)) |     result = await session.get(ORG_URL.format(org)) | ||||||
|     if result.status == 200: |     if result.status == 200: | ||||||
|         return Organization(await result.json(), session) |         return Organization(await result.json(), session) | ||||||
|     raise OrganizationNotFound |     raise OrganizationNotFound | ||||||
|  | @ -98,6 +98,7 @@ class GHClient: | ||||||
|             return wrapped |             return wrapped | ||||||
|         return wrapper |         return wrapper | ||||||
| 
 | 
 | ||||||
|  |     @_cache(type='User') | ||||||
|     async def get_self(self) -> User: |     async def get_self(self) -> User: | ||||||
|         """Returns the authenticated User object.""" |         """Returns the authenticated User object.""" | ||||||
|         if self._auth: |         if self._auth: | ||||||
|  | @ -106,33 +107,25 @@ class GHClient: | ||||||
|             raise exceptions.NoAuthProvided |             raise exceptions.NoAuthProvided | ||||||
| 
 | 
 | ||||||
|     @_cache(type='User') |     @_cache(type='User') | ||||||
|     async def get_user(self, **kwargs) -> User: |     async def get_user(self, username) -> User: | ||||||
|         """Fetch a Github user from their username.""" |         """Fetch a Github user from their username.""" | ||||||
|         username = kwargs.get('user') |  | ||||||
|         return await http.get_user(self.session, username) |         return await http.get_user(self.session, username) | ||||||
| 
 | 
 | ||||||
|     @_cache(type='Repo') |     @_cache(type='Repo') | ||||||
|     async def get_repo(self, **kwargs) -> Repository: |     async def get_repo(self, owner: str, repo: str) -> Repository: | ||||||
|         """Fetch a Github repository from it's name.""" |         """Fetch a Github repository from it's name.""" | ||||||
|         owner = kwargs.get('owner') |         return await http.get_repo_from_name(self.session, owner, repo) | ||||||
|         repo_name = kwargs.get('repo') |  | ||||||
|         return await http.get_repo_from_name(self.session, owner, repo_name) |  | ||||||
| 
 | 
 | ||||||
|     async def get_repo_issue(self, **kwargs) -> Issue: |     async def get_issue(self, owner: str, repo: str, issue: int) -> Issue: | ||||||
|         """Fetch a Github repository from it's name.""" |         """Fetch a Github repository from it's name.""" | ||||||
|         owner = kwargs.get('owner') |         return await http.get_repo_issue(self.session, owner, repo, issue) | ||||||
|         repo_name = kwargs.get('repo') |  | ||||||
|         issue_number = kwargs.get('issue') |  | ||||||
|         return await http.get_repo_issue(self.session, owner, repo_name, issue_number) |  | ||||||
| 
 | 
 | ||||||
|     async def make_repo(self, **kwargs) -> Repository: |     async def create_repo(self, name: str, description: str, private: bool, gitignore_template: str) -> Repository: | ||||||
|         """Create a new Github repository.""" |         """Create a new Github repository.""" | ||||||
|         name = kwargs.get('name') |         return await http.make_repo(self.session, name, description, private, gitignore_template) | ||||||
|         return await http.make_repo(self.session, name) |  | ||||||
| 
 | 
 | ||||||
|     async def get_org(self, **kwargs) -> Organization: |     async def get_org(self, org) -> Organization: | ||||||
|         """Fetch a Github organization from it's name""" |         """Fetch a Github organization from it's name""" | ||||||
|         org_name = kwargs.get('org') |         return await http.get_org(self.session, org) | ||||||
|         return await http.get_org(self.session, org_name) |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 VarMonke
						VarMonke