diff --git a/ughub.py b/ughub.py index 1a78c36..4d7d8a9 100644 --- a/ughub.py +++ b/ughub.py @@ -448,10 +448,13 @@ def ListPackages(args): namesonly = ughubUtil.HasCommandlineOption(args, ("--namesonly",)) if namesonly: + result = "" for key in sorted(packageDict.keys()): pkgs = packageDict[key] for pkg in pkgs: - print(pkg["name"], end=" ") + result += pkg["name"] + " " + + ughubUtil.Write(result) else: print("{0:24.4} {1:10} {2:11} {3:}" .format("NAME", "PREFIX", "SOURCE", "URL")) @@ -968,7 +971,9 @@ def GetAutoCompletions(args): result += "\n" for p in packages: result += p["name"] + "\n" - print(result[:-1], end="") + + ughubUtil.Write(result[:-1]) + return if len(args) >= 1 and args[0] == "log": @@ -981,16 +986,17 @@ def GetAutoCompletions(args): for p in packages: if PackageIsInstalled(p): result += p["name"] + "\n" - print(result[:-1], end="") + + ughubUtil.Write(result[:-1]) return if len(args) >= 1 and args[0] == "help": - ughubHelp.PrintCommandNames() - print("\n" + ughubHelp.GetOptionStringsForCommand(args[0]), end="") + ughubHelp.PrintCommandNames() + ughubUtil.Write("\n" + ughubHelp.GetOptionStringsForCommand(args[0])) return if len(args) >= 1 and ughubHelp.IsCommandInHelp(args[0]): - print(ughubHelp.GetOptionStringsForCommand(args[0]), end="") + ughubUtil.Write(ughubHelp.GetOptionStringsForCommand(args[0])) return if len(args) == 1: diff --git a/ughubHelp.py b/ughubHelp.py index 86dfedd..fd398d5 100644 --- a/ughubHelp.py +++ b/ughubHelp.py @@ -28,6 +28,7 @@ import ughubUtil import ughubHelpContents +import sys class MalformedHelpContentsError(Exception) : pass @@ -88,8 +89,9 @@ def PrintCommandNames(): result = "" for cmd in GetCommandsInHelp(): for c in cmd.split(","): - result += c.strip() + "\n" - print(result[:-1], end ="") + result += c.strip() + "\n" + + ughubUtil.Write(result[:-1]) # Prints help for the command specified in 'cmd'. def PrintCommandHelp(cmdName, args=[]): @@ -105,7 +107,7 @@ def PrintCommandHelp(cmdName, args=[]): if shortdesc: if "shortdescription" in cmdDict: - print(cmdDict["shortdescription"], end="") + ughubUtil.Write(cmdDict["shortdescription"]) return print("Usage: ughub {0}".format(cmdDict["usage"])) diff --git a/ughubUtil.py b/ughubUtil.py index 39279db..fb5e2b8 100644 --- a/ughubUtil.py +++ b/ughubUtil.py @@ -94,3 +94,7 @@ def RemoveOptions(args): if len(a) > 0 and a[0] != "-": filteredArgs.append(a) return filteredArgs + +def Write(string): + sys.stdout.write(string) + sys.stdout.flush() \ No newline at end of file