Skip to content

Commit 9db0be6

Browse files
sourcode
1 parent 6a7f2b5 commit 9db0be6

File tree

9 files changed

+154
-3
lines changed

9 files changed

+154
-3
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ dist/
1515
downloads/
1616
eggs/
1717
.eggs/
18-
lib/
19-
lib64/
2018
parts/
2119
sdist/
2220
var/

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# test
2-
test.moduletool.com is a test framework for multilanguage source code
2+
python.dialoget.com is a test framework for multilanguage source code, based on decorators
33

44
## init
55
```bash

data/env.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import sys
2+
sys.path.append('../')
3+
4+
GITHUB_API_URL = "https://api.github.com"

data/map.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import sys
2+
sys.path.append('../')
3+
from data.user import *
4+
from data.prompt import *
5+
6+
FromEnv = {
7+
"API token": GITHUB_API_TOKEN,
8+
"GitHub Organization": GITHUB_ORGANIZATION_DEFAULT,
9+
"Repository": GITHUB_REPOSITORY_DEFAULT,
10+
}
11+
FromArgs = {
12+
"API token": api_token,
13+
"GitHub Organization": org_name,
14+
"Repository": repo_name,
15+
}

data/prompt.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
api_token=1
2+
domain = 1
3+
Repository = 1
4+
org_name = 1
5+
description = 1
6+
repo_name = 1

data/user.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
GITHUB_API_TOKEN = 1
2+
GITHUB_REPOSITORY_DEFAULT = 1
3+
GITHUB_ORGANIZATION_DEFAULT = 1
4+
GITHUB_DESCRIPTION_DEFAULT = 1
5+
GITHUB_DOMAIN_DEFAULT = 1

src/create_repo_on_org_github.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import sys
2+
sys.path.append('../')
3+
from data.env import GITHUB_API_URL
4+
from lib.dialoget import dialoget
5+
6+
#f'Connect to {GITHUB_API_URL} by {api_token}'
7+
#@dialoget('Connect {GITHUB_API_URL} on {api_token}, Set a {description}, Set a {domain}')
8+
#@dialoget('Update {GITHUB_API_URL} on {api_token}, Set a {description}, Set a {domain}')
9+
@dialoget('Update a {repo_name} on {org_name}, Set a {api_token}, Set a {GITHUB_API_URL}','../../')
10+
def create_repo_on_org_github(repo_name, org_name, api_token, GITHUB_API_URL):
11+
# Endpoint to create a repo within an organization
12+
url = f'{GITHUB_API_URL}/repos/{org_name}/{repo_name}/pages'
13+
14+
try:
15+
url = f'{GITHUB_API_URL}/repos/{org_name}/{repo_name}/pages'
16+
#print(url)
17+
except:
18+
print("Something went wrong")
19+
exit(1)
20+
#print(api_token, org_name, repo_name, description, domain)
21+
return 200
22+
23+
# result = update_repo_on_github(api_token, org_name, repo_name, description, domain)
24+
# (result.status == 200)
25+
26+
27+
28+
#def create_repo_on_org_github(api_token, repo_name, org_name, description, domain, GITHUB_API_URL='https://api.github.com'):

src/update_repo_on_github.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import sys
2+
sys.path.append('../')
3+
from data.env import GITHUB_API_URL
4+
from lib.dialoget import dialoget
5+
6+
@dialoget('Update a {repo_name} on {org_name}, Set a {description}, Set a {domain}','../../')
7+
def update_repo_on_github(api_token, org_name, repo_name, description, domain):
8+
# Endpoint to create a repo within an organization
9+
10+
url = f'{GITHUB_API_URL}/repos/{org_name}/{repo_name}/pages'
11+
12+
try:
13+
url = f'{GITHUB_API_URL}/repos/{org_name}/{repo_name}/pages'
14+
#print(url)
15+
except:
16+
print("Something went wrong")
17+
exit(1)
18+
#print(api_token, org_name, repo_name, description, domain)
19+
return 200
20+
21+
22+
# result = update_repo_on_github(api_token, org_name, repo_name, description, domain)
23+
# (result.status == 200)
24+
25+
26+
# f'Connect to {Github,github_url,GITHUB_API_URL} by {"API token",api_token,GITHUB_API_TOKEN}'

src/update_repo_on_github2.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import sys
2+
sys.path.append('../')
3+
from lib.dialoget import dialoget
4+
5+
@dialoget('Update a {repo_name} on {org_name}, Set a {description}, Set a {domain}', '../../')
6+
# Connect to the github API @GITHUB_API_URL with @api_token'
7+
# Update a @repo_name on @org_name
8+
# with a @description
9+
# on the @domain
10+
def update_repo_on_github2(api_token, org_name, repo_name, description, domain, GITHUB_API_URL='https://api.github.com'):
11+
"""
12+
Update the description of a specific GitHub repository.
13+
14+
This function uses the GitHub API to update the repository's description field.
15+
It requires an API token with appropriate permissions to modify repository settings.
16+
17+
Parameters:
18+
- api_token (str): The personal access token for GitHub API authentication.
19+
- org_name (str): The name of the organization under which the repository exists.
20+
Use the username for repositories owned by an individual user.
21+
- repo_name (str): The name of the repository to be updated.
22+
- description (str): The new description text for the repository.
23+
- domain (str): The custom domain to use for API requests. This is useful if you
24+
are using GitHub Enterprise with a different domain than github.com.
25+
- GITHUB_API_URL (str, optional): The base URL for the GitHub API. Defaults to
26+
'https://api.github.com', which is the public API URL.
27+
28+
Returns:
29+
None - This function does not return a value but raises an exception if the update fails.
30+
31+
Raises:
32+
- HTTPError: An error from the requests module 'requests.exceptions.HTTPError' if the
33+
HTTP request returned an unsuccessful status code.
34+
- Exception: A general exception if the update was unsuccessful, with an error message
35+
indicating the failure reason.
36+
37+
Usage:
38+
```python
39+
update_repo_on_github2('<your_api_token>', 'my-org', 'my-repo', 'New description', 'https://github.my-domain.com')
40+
```
41+
"""
42+
43+
# Code to perform the API request to update the repository description would go here.
44+
# The 'requests' library would typically be used to make the HTTP request.
45+
# Example:
46+
# headers = {'Authorization': f'token {api_token}'}
47+
# data = {'description': description}
48+
# response = requests.patch(f'{GITHUB_API_URL}/repos/{org_name}/{repo_name}',
49+
# json=data, headers=headers)
50+
# response.raise_for_status() # Raise an HTTPError if the request returned an
51+
# # unsuccessful status code.
52+
53+
# Endpoint to create a repo within an organization
54+
url = f'{GITHUB_API_URL}/repos/{org_name}/{repo_name}/pages'
55+
56+
try:
57+
url = f'{GITHUB_API_URL}/repos/{org_name}/{repo_name}/pages'
58+
# print(url)
59+
except:
60+
print("Something went wrong")
61+
exit(1)
62+
# print(api_token, org_name, repo_name, description, domain)
63+
return 200
64+
65+
# result = update_repo_on_github(api_token, org_name, repo_name, description, domain)
66+
# (result.status == 200)
67+
68+
69+
# f'Connect to {Github,github_url,GITHUB_API_URL} by {"API token",api_token,GITHUB_API_TOKEN}'

0 commit comments

Comments
 (0)