From 7a9f2a811bd995755631753a574317b09442eaeb Mon Sep 17 00:00:00 2001 From: Andrew Grimberg Date: Wed, 11 Jul 2018 14:44:36 -0700 Subject: [PATCH] Update Nexus string substition formating Bring the string substitution formatting on Nexus code to the latest standards for Python 3 Change-Id: I2c38cbbecc8b918aee968d46a12e251976cc8259 Signed-off-by: Andrew Grimberg --- lftools/nexus/__init__.py | 14 +++++++------- lftools/nexus/cmd.py | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lftools/nexus/__init__.py b/lftools/nexus/__init__.py index 5501e8ba..c0f8e3f3 100644 --- a/lftools/nexus/__init__.py +++ b/lftools/nexus/__init__.py @@ -56,7 +56,7 @@ class Nexus: for priv in targets['data']: if priv['name'] == name: return priv['id'] - raise LookupError("No target found named '%s'" % (name)) + raise LookupError("No target found named '{}'".format(name)) def create_target(self, name, patterns): """Create a target with the given patterns.""" @@ -83,14 +83,14 @@ class Nexus: """Get the ID for the privilege with the given name.""" url = '/'.join([self.baseurl, 'service/local/privileges']) - search_name = '%s - (%s)' % (name, priv) + search_name = "{} - ({})".format(name, priv) privileges = requests.get(url, auth=self.auth, headers=self.headers).json() for priv in privileges['data']: if priv['name'] == search_name: return priv['id'] - raise LookupError("No privilege found named '%s'" % name) + raise LookupError("No privilege found named '{}'".format(name)) def create_priv(self, name, target_id, priv): """Create a given privilege. @@ -136,7 +136,7 @@ class Nexus: if role['name'] == name: return role['id'] - raise LookupError("No role with name '%s'" % (name)) + raise LookupError("No role with name '{}'".format(name)) def create_role(self, name, privs): """Create a role with the given privileges.""" @@ -173,7 +173,7 @@ class Nexus: if user['userId'] == user_id: return - raise LookupError("No user with id '%s'" % (user_id)) + raise LookupError("No user with id '{}'".format(user_id)) def create_user(self, name, domain, role_id, password, extra_roles=[]): """Create a Deployment user with a specific role_id and potentially extra roles. @@ -185,7 +185,7 @@ class Nexus: user = { 'data': { 'userId': name, - 'email': '%s-deploy@%s' % (name, domain), + 'email': "{}-deploy@{}".format(name, domain), 'firstName': name, 'lastName': 'Deployment', 'roles': [ @@ -217,7 +217,7 @@ class Nexus: if repo['name'] == name: return repo['id'] - raise LookupError("No repository group named '%s'" % (name)) + raise LookupError("No repository group named '{}'".format(name)) def get_repo_group_details(self, repoId): """Get the current configuration of a given repo group with a specific ID.""" diff --git a/lftools/nexus/cmd.py b/lftools/nexus/cmd.py index cecc8be0..12bf56f2 100644 --- a/lftools/nexus/cmd.py +++ b/lftools/nexus/cmd.py @@ -136,7 +136,7 @@ def create_repos(config_file, settings_file): if 'repositories' in config: for sub_repo in config['repositories']: - sub_repo_id = '%s-%s' % (repoId, sub_repo) + sub_repo_id = "{}-{}".format(repoId, sub_repo) build_repo( sub_repo, sub_repo_id, -- 2.16.6