Skip to content

Commit 4188cd3

Browse files
committed
fix: failing flake8
1 parent c5005db commit 4188cd3

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

scripts/create_repo.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#!/usr/bin/env python
22

33
'''
4-
This script is used to create a local repository linked with a remote repository.
4+
This script is used to create a local repository linked with a remote repository.
55
'''
66

7-
# imports the required modules
8-
import argparse # required for parsing the command line arguments passed to the script
9-
import os # required for creating the directory and changing the directory and running the git commands # noqa: E501
10-
import http.client # required for making the http request
11-
import json # required for parsing the response received from the http request
12-
from github_secrets import GITHUB_API_TOKEN, USERNAME # required for authenticating the http request and setting the user agent
7+
# Imports the required modules
8+
import argparse # required for parsing the command line arguments passed to the script
9+
import os # required for creating the directory and changing the directory and running the git commands # noqa: E501
10+
import http.client # required for making the http request
11+
import json # required for parsing the response received from the http request
12+
from github_secrets import GITHUB_API_TOKEN, USERNAME # required for authenticating the http request and setting the user agent # noqa: E501
1313

1414

1515
# Checks if the environment variables are set or not. If not, raises an error as ValueError. # noqa: E501
@@ -18,7 +18,7 @@
1818
if not GITHUB_API_TOKEN:
1919
raise ValueError("Please set the environment variable GITHUB_API_TOKEN in the github_secrets.py file") # noqa: E501
2020

21-
# Base URL for the GitHub API which
21+
# Base URL for the GitHub API which is used to create a new repository # noqa: E501
2222
URL = "https://api.github.com/user/repos"
2323

2424
# Creates a parser object of the argparse class
@@ -27,31 +27,31 @@
2727
parser = argparse.ArgumentParser(description='creates a local repository linked with a remote repository') # noqa: E501
2828

2929
# Adds the arguments to the parser object
30-
parser.add_argument('path', # This argument can be accessed using the `path` variable # noqa: E501
30+
parser.add_argument('path', # This argument can be accessed using the `path` variable # noqa: E501
3131
metavar='PATH',
3232
type=str,
3333
help='Enter the path for the new repository')
34-
parser.add_argument('name', # This argument can be accessed using the `name` variable # noqa: E501
35-
metavar='NAME',
34+
parser.add_argument('name', # This argument can be accessed using the `name` variable # noqa: E501
35+
metavar='NAME',
3636
type=str,
3737
help='Enter a name for the new repository')
38-
args = parser.parse_args() # parses the arguments passed to the script. The arguments are stored in the `args` variable # noqa: E501
38+
args = parser.parse_args() # parses the arguments passed to the script. The arguments are stored in the `args` variable # noqa: E501
3939

40-
name = args.name # stores the name of the repository from `args` in the name variable
41-
path = args.path # stores the path of the repository from `args` in the path variable
40+
name = args.name # stores the name of the repository from `args` in the name variable
41+
path = args.path # stores the path of the repository from `args` in the path variable
4242

4343

4444
# The following codes creates a new directory with the name of the repository and initializes it with git using the `os` module # noqa: E501
45-
os.chdir(path) # changes the directory to the path specified in the `path` variable # noqa: E501
46-
os.mkdir(name) # creates a new directory with the name specified in the `name` variable # noqa: E501
47-
os.chdir(name) # changes the directory to the newly created directory # noqa: E501
48-
os.system('git init -b main') # This executes 'git init -b main' as a system command as if it were written in git bash. It initializes the directory with git and sets the default branch to `main` # noqa: E501
49-
os.system('touch README.md') # creates a README.md file # noqa: E501
50-
os.system('git add . && git commit -m "initial commit"') # adds the newly created README.md file to the staging area and commits it with the message# noqa: E501
45+
os.chdir(path) # changes the directory to the path specified in the `path` variable # noqa: E501
46+
os.mkdir(name) # creates a new directory with the name specified in the `name` variable # noqa: E501
47+
os.chdir(name) # changes the directory to the newly created directory # noqa: E501
48+
os.system('git init -b main') # This executes 'git init -b main' as a system command as if it were written in git bash. It initializes the directory with git and sets the default branch to `main` # noqa: E501
49+
os.system('touch README.md') # creates a README.md file # noqa: E501
50+
os.system('git add . && git commit -m "initial commit"') # adds the newly created README.md file to the staging area and commits it with the message# noqa: E501
5151

5252

5353
# The following code makes a POST request to the GitHub API to create a new repository # noqa: E501
54-
conn = http.client.HTTPSConnection("api.github.com") # creates a connection object
54+
conn = http.client.HTTPSConnection("api.github.com") # creates a connection object
5555
# The payload is the data that is sent
5656
payload = json.dumps({
5757
"name": name,
@@ -71,15 +71,15 @@
7171
# The response is read and decoded using utf-8 encoding and stored in the `data` variable
7272
# The `data` variable is parsed using the json module and stored in the `response` variable # noqa: E501
7373
# The `response` variable contains the response received from the GitHub API, which is a JSON object # noqa: E501
74-
conn.request("POST", "/user/repos", payload, headers)
74+
conn.request("POST", "/user/repos", payload, headers)
7575
res = conn.getresponse()
7676
data = res.read().decode("utf-8")
7777
response = json.loads(data)
7878

7979
print(response)
80-
remote_url = response['svn_url'] # stores the remoteurl using the key `svn_url` in the `response` variable # noqa: E501
80+
remote_url = response['svn_url'] # stores the remoteurl using the key `svn_url` in the `response` variable # noqa: E501
8181

8282
# Runs the git commands as system commands # noqa: E501
83-
os.system(f'git remote add origin {remote_url}') # adds the remote url to the local repository
84-
os.system('git push origin main') # Pushes the local repository to the remote repository
85-
print(f"\nREMOTE URL FOR \"{name}\" is: {remote_url}") # Prints the remote url
83+
os.system(f'git remote add origin {remote_url}') # adds the remote url to the local repository
84+
os.system('git push origin main') # Pushes the local repository to the remote repository
85+
print(f"\nREMOTE URL FOR \"{name}\" is: {remote_url}") # Prints the remote url

0 commit comments

Comments
 (0)