diff options
author | John L. Villalovos <john@sodarock.com> | 2022-06-03 21:21:38 -0700 |
---|---|---|
committer | John L. Villalovos <john@sodarock.com> | 2022-06-03 21:24:58 -0700 |
commit | c86e471dead930468172f4b7439ea6fa207f12e8 (patch) | |
tree | b62a4f0651ccf75ecd490a2512090f4838bf6e2b /gitlab/cli.py | |
parent | 6189437d2c8d18f6c7d72aa7743abd6d36fb4efa (diff) | |
download | gitlab-c86e471dead930468172f4b7439ea6fa207f12e8.tar.gz |
chore: rename `what` to `gitlab_resource`
Naming a variable `what` makes it difficult to understand what it is
used for.
Rename it to `gitlab_resource` as that is what is being stored.
The Gitlab documentation talks about them being resources:
https://docs.gitlab.com/ee/api/api_resources.html
This will improve code readability.
Diffstat (limited to 'gitlab/cli.py')
-rw-r--r-- | gitlab/cli.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/gitlab/cli.py b/gitlab/cli.py index 4159632..c9e182d 100644 --- a/gitlab/cli.py +++ b/gitlab/cli.py @@ -91,14 +91,16 @@ def die(msg: str, e: Optional[Exception] = None) -> None: sys.exit(1) -def what_to_cls(what: str, namespace: ModuleType) -> Type[RESTObject]: +def gitlab_resource_to_cls( + gitlab_resource: str, namespace: ModuleType +) -> Type[RESTObject]: classes = CaseInsensitiveDict(namespace.__dict__) - lowercase_class = what.replace("-", "") + lowercase_class = gitlab_resource.replace("-", "") return classes[lowercase_class] -def cls_to_what(cls: RESTObject) -> str: +def cls_to_gitlab_resource(cls: RESTObject) -> str: dasherized_uppercase = camel_upperlower_regex.sub(r"\1-\2", cls.__name__) dasherized_lowercase = camel_lowerupper_regex.sub(r"\1-\2", dasherized_uppercase) return dasherized_lowercase.lower() @@ -322,7 +324,7 @@ def main() -> None: fields = [x.strip() for x in args.fields.split(",")] debug = args.debug action = args.whaction - what = args.what + gitlab_resource = args.gitlab_resource args_dict = vars(args) # Remove CLI behavior-related args @@ -331,7 +333,7 @@ def main() -> None: "config_file", "verbose", "debug", - "what", + "gitlab_resource", "whaction", "version", "output", @@ -359,4 +361,4 @@ def main() -> None: if debug: gl.enable_debug() - gitlab.v4.cli.run(gl, what, action, args_dict, verbose, output, fields) + gitlab.v4.cli.run(gl, gitlab_resource, action, args_dict, verbose, output, fields) |