Skip to content

Commit 89137d0

Browse files
committed
Uses .format instead of f-strings for greater compatibility
Fixes #2
1 parent 1168df0 commit 89137d0

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ This is a nifty little tool written in Python to work with GitHub Gists from com
6565
* Create interactively from an editor like **nano**, **vim** or **gedit**
6666
- ```gifc create create.md -d "How to create a gist from cli" -i nano```
6767
* Directly enter contents from cli
68-
- ```gifc create create.md -d "How to create a gist from cli" -m '''If you want to create a gist from an existing file then you do the following- `./gifc -c create.md -e "How to create a gist from cli" -i file.md`'''```
68+
- ```gifc create create.md -d "How to create a gist from cli" -m '''If you want to create a gist from an existing file then you do the following- `gifc create create.md -d "How to create a gist from cli" -f file.md`'''```
6969
* Take the contents from a file
7070
- `gifc create create.md -d "How to create a gist from cli" -f file.md`
7171
@@ -91,7 +91,7 @@ You can get the _gist id_ from the `get` method from earlier
9191
`gifc delete ffd2f4a482684f56bf33c8726cc6ae63`
9292
You can get the _gist id_ from the `get` method from earlier
9393
94-
#### LICENSE
94+
#### COPYRIGHT and LICENSE
9595
All the source files are licensed under GNU GLPv3 license. Refer [LICENSE.md](https://github.com/armsp/gifc/blob/master/LICENSE) for more details.
9696
9797
Gifc is a tool written in Python to work with GitHub Gists from command line.

gifc

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ if args.main == 'get':
7272
number_of_gists = args.number
7373
print('Getting gists...')
7474
user_id = get_config_details('GIT_USER_ID')
75-
r = requests.get(f'https://api.github.com/users/{user_id}/gists')
75+
r = requests.get('https://api.github.com/users/{}/gists'.format(user_id))
7676
gist_list = []
7777
for gist in r.json()[:number_of_gists]:
7878
gist_id = gist['id']
@@ -93,7 +93,7 @@ if args.main == 'create':
9393
payload = {'description': args.describe, 'public': args.public, 'files':{args.gist_item : {'content': message}}}
9494
#print(payload)
9595
r = requests.post(f"https://api.github.com/gists", headers=header, json=payload)
96-
print(r.status_code)
96+
#print(r.status_code)
9797
if r.status_code == 201:
9898
print(r.json()['id'])
9999
print('Gist successfully created')
@@ -105,7 +105,7 @@ if args.main == 'create':
105105
f2s = f.read()
106106
payload = {'description': args.describe, 'public': args.public, 'files':{args.gist_item : {'content': f2s}}}
107107
r = requests.post(f"https://api.github.com/gists", headers=header, json=payload)
108-
print(r.status_code)
108+
#print(r.status_code)
109109
if r.status_code == 201:
110110
print(r.json()['id'])
111111
print('Gist successfully created')
@@ -132,7 +132,7 @@ if args.main == 'create':
132132
print(e)
133133
exit()
134134
if r.status_code == 201:
135-
print(r.status_code)
135+
#print(r.status_code)
136136
print(r.json()['id'])
137137
print('Gist successfully created')
138138
else:
@@ -148,7 +148,7 @@ if args.main == 'update':
148148
payload = dict()
149149
#file content changes
150150
if args.file_name:
151-
r = requests.get(f'https://api.github.com/gists/{gid}')
151+
r = requests.get('https://api.github.com/gists/{}'.format(gid))
152152
if r.status_code != 200:
153153
print('Error getting gist contents for interactive mode')
154154
exit()
@@ -164,7 +164,7 @@ if args.main == 'update':
164164
os.remove(n)
165165
else:
166166
if args.interactive:
167-
get_gist = requests.get(f'https://api.github.com/gists/{gid}')
167+
get_gist = requests.get('https://api.github.com/gists/{}'.format(gid))
168168
gist_files = get_gist.json()['files']
169169
if len(gist_files) > 1:
170170
print(Color.red+'There are multiple files in this gist'+Color.end)
@@ -185,8 +185,8 @@ if args.main == 'update':
185185
if args.change_description:
186186
payload['description'] = args.change_description
187187

188-
r = requests.patch(f'https://api.github.com/gists/{gid}', headers=header, json=payload)
189-
print(r.status_code)
188+
r = requests.patch('https://api.github.com/gists/{}'.format(gid), headers=header, json=payload)
189+
#print(r.status_code)
190190
if r.status_code == 200:
191191
print("Gist successfully updated")
192192
else:
@@ -196,11 +196,11 @@ if args.main == 'update':
196196
#Delete files or gists
197197
if args.main == 'delete':
198198
gid = args.gist_id
199-
print(f'Deleting {gid}')
199+
print('Deleting {}'.format(gid))
200200
token = get_config_details('GIT_TOKEN')
201-
header = {'Authorization': f'Bearer {token}'}
201+
header = {'Authorization': 'Bearer {}'.format(token)}
202202

203-
r = requests.delete(f'https://api.github.com/gists/{gid}', headers=header)
203+
r = requests.delete('https://api.github.com/gists/{}'.format(gid), headers=header)
204204
#print(r.status_code)
205205
if r.status_code != 204:
206206
print('Request not completed. Maybe the gist_id is incorrect. Please try the GUI.')
@@ -210,14 +210,14 @@ if args.main == 'delete':
210210
if args.main == 'remove':
211211
gid = args.gist_id
212212
files = args.remove
213-
pprint.pprint(f'Deleting file(s) {files}')
213+
pprint.pprint('Deleting file(s) {}'.format(files))
214214
token = get_config_details('GIT_TOKEN')
215-
header = {'Authorization': f'Bearer {token}'}
215+
header = {'Authorization': 'Bearer {}'.format(token)}
216216
#print(files, len(files))
217217
file_del_payload = dict(zip(files,[None]*len(files)))
218218
payload = {"files": file_del_payload}
219219
#print(payload)
220-
r = requests.patch(f'https://api.github.com/gists/{gid}', headers=header, json=payload)
220+
r = requests.patch('https://api.github.com/gists/{}'.format(gid), headers=header, json=payload)
221221
#data vs json when you have to pass "null" as json.
222222
if r.status_code == 422:
223223
print('You are trying to delete a file that does not exist. Please try again with correct file.')

0 commit comments

Comments
 (0)