Skip to content

Commit

Permalink
🐛(ozi-new interactive): args output fixed and project_urls added
Browse files Browse the repository at this point in the history
Signed-off-by: rjdbcm <[email protected]>
  • Loading branch information
rjdbcm committed Jun 29, 2024
1 parent b0a9425 commit fcfcdba
Showing 1 changed file with 67 additions and 5 deletions.
72 changes: 67 additions & 5 deletions ozi/new/interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@ def license_( # noqa: C901
_default = None
for n, i in enumerate(output):
if i.startswith('--license'):
_default = output.pop(n).replace('--license=', '').strip('"')
_default = output.pop(n + 1)
output.remove('--license')
while True:
license_ = radiolist_dialog(
values=sorted(
Expand Down Expand Up @@ -265,7 +266,8 @@ def license_expression( # noqa: C901
_default = possible_spdx[0]
for n, i in enumerate(output):
if i.startswith('--license-expression'):
_default = output.pop(n).replace('--license-expression=', '').strip('"')
_default = output.pop(n + 1)
output.remove('--license-expression')

if len(possible_spdx) < 1:
_license_expression = input_dialog(
Expand Down Expand Up @@ -430,7 +432,7 @@ def requires_dist(
),
)
for req in del_requirement:
output.pop(output.index(req) - 1)
output.pop(output.index(req))
output.remove(req)
prefix.pop(f'Requires-Dist: {req}')
else:
Expand All @@ -457,7 +459,8 @@ def readme_type(
_default = ''
for n, i in enumerate(output):
if i.startswith('--readme-type'):
_default = output.pop(n).replace('--readme-type=', '').strip('"')
_default = output.pop(n + 1)
output.remove('--readme-type')
readme_type = radiolist_dialog(
values=(
('rst', 'ReStructuredText'),
Expand Down Expand Up @@ -495,7 +498,8 @@ def typing(
_default = None
for n, i in enumerate(output):
if i.startswith('--typing'):
_default = output.pop(n).replace('--typing=', '').strip('"')
_default = output.pop(n + 1)
output.remove('--typing')
result = radiolist_dialog(
values=(
('Typed', 'Typed'),
Expand Down Expand Up @@ -523,6 +527,62 @@ def typing(
)
return result, output, prefix

@staticmethod
def project_urls( # noqa: C901
project_name: str,
output: list[str],
prefix: dict[str, str],
) -> tuple[str, list[str], dict[str, str]]:
_default = None
url = None
for n, i in enumerate(output):
if i.startswith('--project-url'):
_default = output.pop(n + 1)
output.remove('--project-url')
while True:
result = checkboxlist_dialog(
values=(
('Changelog', 'Changelog'),
('Documentation', 'Documentation'),
('Bug Report', 'Bug Report'),
('Funding', 'Funding'),
('Source', 'Source'),
),
title='ozi-new interactive prompt',
text=f'Please select project URLs you want to add to {project_name}:',
style=_style,
ok_text='✔ Ok',
cancel_text='← Back',
).run()
if result is not None:
for i in result:
url = input_dialog(
title='ozi-new interactive prompt',
text=f'Please enter the {i} URL for {project_name}:',
ok_text='✔ Ok',
cancel_text='← Back',
default='https://',
style=_style,
).run()
if url is None:
break
output += ['--project-url', f'{i}, {url}']
prefix.update(
(
{
f'Project-URL: {i}': f'Project-URL: {i}, {url}', # noqa: B950, RUF100, E501
}
if i
else {}
),
)
continue
else:
output += ['--project-url', _default] if _default else []
break

return f'{result}, {url}', output, prefix


_P = Project()

Expand Down Expand Up @@ -783,6 +843,7 @@ def header_input( # noqa: C901
for n, i in enumerate(output):
if i.startswith(f'--{label.lower()}'):
_default = output.pop(n + 1)
output.remove(f'--{label.lower()}')
header = input_dialog(
title='ozi-new interactive prompt',
text='\n'.join(args),
Expand Down Expand Up @@ -870,6 +931,7 @@ def menu_loop(
('license_expression', 'Extra: License-Expression'),
('maintainer', 'Maintainer'),
('maintainer_email', 'Maintainer-email'),
('project_urls', 'Project-URL'),
('requires_dist', 'Requires-Dist (requirements)'),
('audience', 'Intended Audience'),
('environment', 'Environment'),
Expand Down

0 comments on commit fcfcdba

Please sign in to comment.