Skip to content

Commit

Permalink
Fixed small error when listing with --namesonly and introduced ughubU…
Browse files Browse the repository at this point in the history
…til.Write()
  • Loading branch information
timsschoen committed Sep 10, 2020
1 parent bacbb35 commit 85d3b5d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
20 changes: 9 additions & 11 deletions ughub.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,8 @@ def ListPackages(args):
pkgs = packageDict[key]
for pkg in pkgs:
result += pkg["name"] + " "
sys.stdout.write(result)
sys.stdout.flush()

ughubUtil.Write(result)
else:
print("{0:24.4} {1:10} {2:11} {3:}"
.format("NAME", "PREFIX", "SOURCE", "URL"))
Expand Down Expand Up @@ -972,8 +972,8 @@ def GetAutoCompletions(args):
for p in packages:
result += p["name"] + "\n"

sys.stdout.write(result[:-1])
sys.stdout.flush()
ughubUtil.Write(result[:-1])

return

if len(args) >= 1 and args[0] == "log":
Expand All @@ -986,19 +986,17 @@ def GetAutoCompletions(args):
for p in packages:
if PackageIsInstalled(p):
result += p["name"] + "\n"
sys.stdout.write(result[:-1])
sys.stdout.flush()

ughubUtil.Write(result[:-1])
return

if len(args) >= 1 and args[0] == "help":
ughubHelp.PrintCommandNames()
sys.stdout.write("\n" + ughubHelp.GetOptionStringsForCommand(args[0]))
sys.stdout.flush()
ughubHelp.PrintCommandNames()
ughubUtil.Write("\n" + ughubHelp.GetOptionStringsForCommand(args[0]))
return

if len(args) >= 1 and ughubHelp.IsCommandInHelp(args[0]):
sys.stdout.write(ughubHelp.GetOptionStringsForCommand(args[0]))
sys.stdout.flush()
ughubUtil.Write(ughubHelp.GetOptionStringsForCommand(args[0]))
return

if len(args) == 1:
Expand Down
6 changes: 2 additions & 4 deletions ughubHelp.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ def PrintCommandNames():
for c in cmd.split(","):
result += c.strip() + "\n"

sys.stdout.write(result[:-1])
sys.stdout.flush()
ughubUtil.Write(result[:-1])

# Prints help for the command specified in 'cmd'.
def PrintCommandHelp(cmdName, args=[]):
Expand All @@ -108,8 +107,7 @@ def PrintCommandHelp(cmdName, args=[]):

if shortdesc:
if "shortdescription" in cmdDict:
sys.stdout.write(cmdDict["shortdescription"])
sys.stdout.flush()
ughubUtil.Write(cmdDict["shortdescription"])
return

print("Usage: ughub {0}".format(cmdDict["usage"]))
Expand Down
4 changes: 4 additions & 0 deletions ughubUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 85d3b5d

Please sign in to comment.