Skip to content

Commit 2294343

Browse files
author
Jussi Kukkonen
committed
imports: Fix Updater importing
updater module cannot be included in 'client' default modules if updater module also loads 'client' (as python2 fails to import it). We do want to load client default modules in updater to be able to use namespacing, e.g. client.download.safe_download(). So don't include updater in default modules: this means the examples should use e.g. from tuf.client import updater or from tuf.client.updater import Updater Signed-off-by: Jussi Kukkonen <[email protected]>
1 parent 7f5996e commit 2294343

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

tuf/client/updater.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,8 @@
5151
5252
<Example Client>
5353
54-
# The client first imports the 'updater.py' module, the only module the
55-
# client is required to import. The client will utilize a single class
56-
# from this module.
57-
from tuf import client
54+
# The client first imports the Updater class:
55+
from tuf.client.updater import Updater
5856
5957
# The only other module the client interacts with is 'tuf.settings'. The
6058
# client accesses this module solely to set the repository directory.
@@ -83,7 +81,7 @@
8381
# is called with two arguments. The first argument assigns a name to this
8482
# particular updater and the second argument the repository mirrors defined
8583
# above.
86-
updater = client.updater.Updater('updater', repository_mirrors)
84+
updater = Updater('updater', repository_mirrors)
8785
8886
# The client next calls the refresh() method to ensure it has the latest
8987
# copies of the metadata files.
@@ -495,7 +493,7 @@ def get_updater(self, repository_name):
495493

496494
else:
497495
# Create repository mirrors object needed by the
498-
# client.updater.Updater(). Each 'repository_name' can have more
496+
# Updater(). Each 'repository_name' can have more
499497
# than one mirror.
500498
mirrors = {}
501499

@@ -510,7 +508,7 @@ def get_updater(self, repository_name):
510508
# NOTE: State (e.g., keys) should NOT be shared across different
511509
# updater instances.
512510
logger.debug('Adding updater for ' + repr(repository_name))
513-
updater = client.updater.Updater(repository_name, mirrors)
511+
updater = Updater(repository_name, mirrors)
514512

515513
except Exception:
516514
return None

0 commit comments

Comments
 (0)