Bladeren bron

Clean up output.py.

tags/v0.2
Ben Kurtovic 10 jaren geleden
bovenliggende
commit
beac864d29
2 gewijzigde bestanden met toevoegingen van 6 en 22 verwijderingen
  1. +5
    -21
      gitup/output.py
  2. +1
    -1
      gitup/update.py

+ 5
- 21
gitup/output.py Bestand weergeven

@@ -8,27 +8,11 @@ import re
__all__ = ["out", "bold", "red", "green", "yellow", "blue"]

# Text formatting functions:
bold = lambda t: _style_text(t, "bold")
red = lambda t: _style_text(t, "red")
green = lambda t: _style_text(t, "green")
yellow = lambda t: _style_text(t, "yellow")
blue = lambda t: _style_text(t, "blue")

def _style_text(text, effect):
"""Give a text string a certain effect, such as boldness, or a color."""
ansi = { # ANSI escape codes to make terminal output fancy
"reset": "\x1b[0m",
"bold": "\x1b[1m",
"red": "\x1b[1m\x1b[31m",
"green": "\x1b[1m\x1b[32m",
"yellow": "\x1b[1m\x1b[33m",
"blue": "\x1b[1m\x1b[34m",
}

try: # Pad text with effect, unless effect does not exist
return ansi[effect] + text + ansi["reset"]
except KeyError:
return text
bold = lambda t: "\x1b[1m" + t + "\x1b[0m"
red = lambda t: "\x1b[1m\x1b[31m" + t + "\x1b[0m"
green = lambda t: "\x1b[1m\x1b[32m" + t + "\x1b[0m"
yellow = lambda t: "\x1b[1m\x1b[33m" + t + "\x1b[0m"
blue = lambda t: "\x1b[1m\x1b[34m" + t + "\x1b[0m"

def out(indent, msg):
"""Print a message at a given indentation level."""


+ 1
- 1
gitup/update.py Bestand weergeven

@@ -107,7 +107,7 @@ def _update_directory(dir_path, dir_name, is_bookmark=False):
for item in dir_contents:
repo_path = os.path.join(dir_path, item)
repo_name = os.path.join(dir_name, item)
if _directory_is_git_repo(repo_path): # Filter out non-repositories
if _directory_is_git_repo(repo_path): # Filter out non-repos
repositories.append((repo_path, repo_name))

num_of_repos = len(repositories)


Laden…
Annuleren
Opslaan