Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
silkaj
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
clients
python
silkaj
Commits
89f6b9de
Commit
89f6b9de
authored
3 years ago
by
Moul
Browse files
Options
Downloads
Patches
Plain Diff
[mod]
#194
: {cli,crypto}_tools: Use f-string
parent
4bc8a211
No related branches found
No related tags found
1 merge request
!195
#194, #376: Use f-string and sys.exit()
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
silkaj/cli_tools.py
+5
-6
5 additions, 6 deletions
silkaj/cli_tools.py
silkaj/crypto_tools.py
+3
-6
3 additions, 6 deletions
silkaj/crypto_tools.py
with
8 additions
and
12 deletions
silkaj/cli_tools.py
+
5
−
6
View file @
89f6b9de
...
@@ -22,17 +22,16 @@ class MutuallyExclusiveOption(Option):
...
@@ -22,17 +22,16 @@ class MutuallyExclusiveOption(Option):
help
=
kwargs
.
get
(
"
help
"
,
""
)
help
=
kwargs
.
get
(
"
help
"
,
""
)
if
self
.
mutually_exclusive
:
if
self
.
mutually_exclusive
:
ex_str
=
"
,
"
.
join
(
self
.
mutually_exclusive
)
ex_str
=
"
,
"
.
join
(
self
.
mutually_exclusive
)
kwargs
[
"
help
"
]
=
help
+
(
kwargs
[
"
NOTE: This argument is mutually exclusive with
"
"
help
"
"
arguments: [
"
+
ex_str
+
"
].
"
]
=
f
"
{
help
}
NOTE: This argument is mutually exclusive with arguments: [
{
ex_str
}
].
"
)
super
().
__init__
(
*
args
,
**
kwargs
)
super
().
__init__
(
*
args
,
**
kwargs
)
def
handle_parse_result
(
self
,
ctx
,
opts
,
args
):
def
handle_parse_result
(
self
,
ctx
,
opts
,
args
):
if
self
.
mutually_exclusive
.
intersection
(
opts
)
and
self
.
name
in
opts
:
if
self
.
mutually_exclusive
.
intersection
(
opts
)
and
self
.
name
in
opts
:
arguments
=
"
,
"
.
join
(
self
.
mutually_exclusive
)
raise
UsageError
(
raise
UsageError
(
"
Usage: `{}` is mutually exclusive with
"
f
"
Usage: `
{
self
.
name
}
` is mutually exclusive with arguments `
{
arguments
}
`.
"
"
arguments `{}`.
"
.
format
(
self
.
name
,
"
,
"
.
join
(
self
.
mutually_exclusive
))
)
)
return
super
().
handle_parse_result
(
ctx
,
opts
,
args
)
return
super
().
handle_parse_result
(
ctx
,
opts
,
args
)
This diff is collapsed.
Click to expand it.
silkaj/crypto_tools.py
+
3
−
6
View file @
89f6b9de
...
@@ -51,7 +51,7 @@ def check_pubkey_format(pubkey, display_error=True):
...
@@ -51,7 +51,7 @@ def check_pubkey_format(pubkey, display_error=True):
elif
re
.
search
(
re
.
compile
(
PUBKEY_CHECKSUM_PATTERN
),
pubkey
):
elif
re
.
search
(
re
.
compile
(
PUBKEY_CHECKSUM_PATTERN
),
pubkey
):
return
True
return
True
elif
display_error
:
elif
display_error
:
message_exit
(
"
Error: bad format for following public key:
"
+
pubkey
)
message_exit
(
f
"
Error: bad format for following public key:
{
pubkey
}
"
)
return
return
...
@@ -65,11 +65,8 @@ def validate_checksum(pubkey_checksum):
...
@@ -65,11 +65,8 @@ def validate_checksum(pubkey_checksum):
if
checksum
==
gen_checksum
(
pubkey
):
if
checksum
==
gen_checksum
(
pubkey
):
return
pubkey
return
pubkey
message_exit
(
message_exit
(
"
Error: public key
'"
f
"
Error: public key
'
{
pubkey
}
'
does not match checksum
'
{
checksum
}
'
.
\n\
+
pubkey
Please verify the public key.
"
+
"'
does not match checksum
'"
+
checksum
+
"'
.
\n
Please verify the public key.
"
)
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment