-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changed formatted strings to fstrings in add_collaborators.py #24
base: BoatswainFormatToFString
Are you sure you want to change the base?
Changes from all commits
3371a2c
16deb2b
4ddc822
1c372d9
41b5402
9c1f550
9f5ad33
f5fefe9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,7 +71,7 @@ def log(self, fmt, *args, tag=None): | |
if len(args) > 0: | ||
fmt = fmt.format(*args) | ||
if tag is not None: | ||
fmt = '=={}==\t{}'.format(tag, fmt) | ||
fmt = f'=={tag}==\t{fmt}' | ||
|
||
# TODO: logging to file | ||
print(fmt) | ||
|
@@ -183,9 +183,9 @@ def ParseOption( | |
) | ||
except configparser.NoOptionError: | ||
print('[WARN]: You appear to be missing a Canvas token in your ' | ||
+ 'Boatswain configuration ({}). Please add this information ' | ||
+ f'Boatswain configuration ({config_path}). Please add this information ' | ||
+ 'to your config file under section [canvas] with key "token".' | ||
+ '\n'.format(config_path)) | ||
+ '\n') | ||
Comment on lines
+186
to
+188
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't need the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same for the rest of the changes in this file |
||
parser.add_argument('canvas_token', | ||
type=str, | ||
help='Canvas LMS auth token', | ||
|
@@ -202,9 +202,9 @@ def ParseOption( | |
) | ||
except configparser.NoOptionError: | ||
print('[WARN]: You appear to be missing the Canvas URL in your ' | ||
+ 'Boatswain configuration ({}). Please add this information ' | ||
+ f'Boatswain configuration ({config_path}). Please add this information ' | ||
+ 'to your config file under section [canvas] with key "url".' | ||
+ '\n'.format(config_path)) | ||
+ '\n') | ||
parser.add_argument('canvas_url', | ||
type=str, | ||
help='Canvas LMS URL', | ||
|
@@ -222,9 +222,9 @@ def ParseOption( | |
) | ||
except configparser.NoOptionError: | ||
print('[WARN]: You appear to be missing a GitHub token in your ' | ||
+ 'Boatswain configuration ({}). Please add this information ' | ||
+ f'Boatswain configuration ({config_path}). Please add this information ' | ||
+ 'to your config file under section [github] with key "token".' | ||
+ '\n'.format(config_path)) | ||
+ '\n') | ||
parser.add_argument('github_token', | ||
type=str, | ||
help='GitHub auth token', | ||
|
@@ -299,7 +299,7 @@ def createConfigInteractive(): | |
config = newPopulatedConfigInteractive() | ||
config.write(open(path, 'w+')) | ||
|
||
itv.output('Boatswain config file created at {}'.format(path)) | ||
itv.output(f'Boatswain config file created at {path}') | ||
|
||
except EOFError: | ||
itv.output() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,13 +7,13 @@ def output(*args): | |
|
||
def promptInput(prompt, fmt='', default=''): | ||
if fmt != '': | ||
promptf = '{} [{}]'.format(prompt, fmt) | ||
promptf = f'{prompt} [{fmt}]' | ||
elif default != '': | ||
promptf = '{} [{}]'.format(prompt, default) | ||
promptf = f'{prompt} [{default}]' | ||
else: | ||
promptf = prompt | ||
|
||
promptf = '{}: '.format(promptf) | ||
promptf = '{promptf}: ' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing a starting |
||
|
||
while True: | ||
inp = input(promptf) | ||
|
@@ -31,7 +31,7 @@ def promptValidate(prompt, validator, fmt='', default=''): | |
v = validator(inp) | ||
if v == '': | ||
return inp | ||
output('Invalid input (case-insensitive): {}'.format(v)) | ||
output(f'Invalid input (case-insensitive): {v}') | ||
|
||
|
||
def selectorValidator(options, default=''): | ||
|
@@ -70,7 +70,7 @@ def newFileValidator(): | |
def validator(inp): | ||
try: | ||
if os.path.exists(inp): | ||
return '{} already exists'.format(inp) | ||
return f'{inp} already exists' | ||
else: | ||
open(inp, 'w').close() | ||
os.unlink(inp) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,16 +49,12 @@ def mk_group_repos(opt): | |
org = g.get_organization(opt.org) | ||
|
||
if not opt.promptYes(('Are you sure you would like to create group repos ' | ||
'for users in {} under org {} with name {}') | ||
.format(opt.groups.name, opt.org, | ||
fmt_hyphen(opt.prefix, '<group>')), | ||
f'for users in {opt.groups.name} under org {opt.org} with name {fmt_hyphen(opt.prefix, '<group>')}'), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would split this into multiple lines. Also, I'm not sure the quotes surrounding There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same for line 57 |
||
True): | ||
opt.warn('Aborting') | ||
return | ||
|
||
opt.info('Creating repos under {} for groups in {}, with name {}' | ||
.format(opt.groups.name, opt.org, | ||
fmt_hyphen(opt.prefix, '<group>'))) | ||
opt.info(f'Creating repos under {opt.groups.name} for groups in {opt.org}, with name {fmt_hyphen(opt.prefix, '<group>')}') | ||
|
||
for g in csv.reader(opt.groups): | ||
group, members = g[0], [m.strip() for m in g[1:] if m != ''] | ||
|
@@ -69,19 +65,18 @@ def mk_group_repos(opt): | |
action = 'creating' | ||
else: | ||
action = 'looking up' | ||
opt.info('{} {}/{} and adding members {}' | ||
.format(action, opt.org, repo_name, members)) | ||
opt.info(f'{action} {opt.org}/{repo_name} and adding members {members}') | ||
|
||
if opt.create: | ||
repo = do_mk_repo(org, repo_name, opt) | ||
else: | ||
repo = org.get_repo(repo_name) | ||
opt.info('Looked up repo {}/{}'.format(org.name, repo_name)) | ||
opt.info(f'Looked up repo {org.name}/{repo_name}') | ||
|
||
if opt.permission == 'none': | ||
opt.info('Not adding {} to {}'.format(members, repo_name)) | ||
opt.info(f'Not adding {members} to {repo_name}') | ||
else: | ||
opt.info('Adding {} to {}'.format(members, repo_name)) | ||
opt.info(f'Adding {members} to {repo_name}') | ||
for member in members: | ||
do_add_collaborator(repo, member, opt.permission, opt) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing a closing parentheses