Exemplo n.º 1
0
    def _log_action(self, action, status, symbol, entry, min_level=3):
        if self.verbose < min_level:
            return

        if len(symbol) > 1 and symbol[0] in (">", "<"):
            symbol = " " + symbol  # make sure direction characters are aligned at 2nd column
        if self.options.get("no_color"):
            color = ""
            final = ""
        else:
            #             CM = self.COLOR_MAP
            #             color = CM.get((action, status),
            #                            CM.get(("*", status),
            #                                   CM.get((action, "*"),
            #                                          "")))
            if action in ("copy", "restore"):
                if "<" in symbol:
                    color = ansi_code("Fore.GREEN") + ansi_code(
                        "Style.BRIGHT") if status == "new" else ansi_code(
                            "Fore.GREEN")
                else:
                    color = ansi_code("Fore.CYAN") + ansi_code(
                        "Style.BRIGHT") if status == "new" else ansi_code(
                            "Fore.CYAN")
            elif action == "delete":
                color = ansi_code("Fore.RED")
            elif status == "conflict":
                color = ansi_code("Fore.LIGHTRED_EX")
            elif action == "skip" or status == "equal":
                color = ansi_code("Fore.LIGHTBLACK_EX")

            final = ansi_code("Style.RESET_ALL")

        final += " " * 10
        prefix = ""
        if self.dry_run:
            prefix = DRY_RUN_PREFIX
        if action and status:
            tag = ("%s %s" % (action, status)).upper()
        else:
            tag = ("%s%s" % (action, status)).upper()
        name = entry.get_rel_path()
        if entry.is_dir():
            name = "[%s]" % name

#         print("{0}{1:<16} {2:^3} {3}".format(prefix, tag, symbol, name))
        print("{0}{1}{2:<16} {3:^3} {4}{5}".format(prefix, color, tag, symbol,
                                                   name, final))
Exemplo n.º 2
0
    def _interactive_resolve(self, local, remote):
        """Return 'local', 'remote', or 'skip' to use local, remote resource or skip."""
        if self.resolve_all:
            return self.resolve_all
        resolve = self.options.get("resolve", "skip")
        assert resolve in ("remote", "ask", "skip")
        if resolve in ("remote", "skip"):
            self.resolve_all = resolve
            return resolve

        RED = ansi_code("Fore.LIGHTRED_EX")
        M = ansi_code("Style.BRIGHT") + ansi_code("Style.UNDERLINE")
        R = ansi_code("Style.RESET_ALL")

        print((RED + "CONFLICT in %s:" + R) % local.name)
        print("    local:  %s" % local.as_string())
        print("    remote: %s" % (remote.as_string() if remote else "n.a."))

        while True:
            prompt = "Use " + M + "R" + R + "emote, " + M + "S" + R + "kip, " + M + "H" + R + "elp)? "
            r = console_input(prompt).strip()
            if r in ("h", "H", "?"):
                print("The following keys are supported:")
                print("  'r': Download remote file")
                print("  's': Skip this file (leave both versions unchanged)")
                print(
                    "Hold Shift (upper case letters) to apply choice for all remaining conflicts."
                )
                print("Hit Ctrl+C to abort.")
                continue
            elif r in ("L", "R", "S"):
                r = self._resolve_shortcuts[r.lower()]
                self.resolve_all = r
                break
            elif r in ("l", "r", "s"):
                r = self._resolve_shortcuts[r]
                break

        return r
Exemplo n.º 3
0
    def _interactive_resolve(self, local, remote):
        """Return 'local', 'remote', or 'skip' to use local, remote resource or skip."""
        if self.resolve_all:
            return self.resolve_all
        resolve = self.options.get("resolve", "skip")
        assert resolve in ("remote", "ask", "skip")
        if resolve in ("remote", "skip"):
            self.resolve_all = resolve
            return resolve

        RED = ansi_code("Fore.LIGHTRED_EX")
        M = ansi_code("Style.BRIGHT") + ansi_code("Style.UNDERLINE")
        R = ansi_code("Style.RESET_ALL")

        print((RED + "CONFLICT in %s:" + R) % local.name)
        print("    local:  %s" % local.as_string())
        print("    remote: %s" % (remote.as_string() if remote else "n.a."))

        while True:
            prompt = "Use " + M + "R" + R + "emote, " + M + "S" + R + "kip, " + M + "H" + R + "elp)? "
            r = console_input(prompt).strip()
            if r in ("h", "H", "?"):
                print("The following keys are supported:")
                print("  'r': Download remote file")
                print("  's': Skip this file (leave both versions unchanged)")
                print("Hold Shift (upper case letters) to apply choice for all remaining conflicts.")
                print("Hit Ctrl+C to abort.")
                continue
            elif r in ("L", "R", "S"):
                r = self._resolve_shortcuts[r.lower()]
                self.resolve_all = r
                break
            elif r in ("l", "r", "s"):
                r = self._resolve_shortcuts[r]
                break

        return r
Exemplo n.º 4
0
    def _log_action(self, action, status, symbol, entry, min_level=3):
        if self.verbose < min_level:
            return
        
        if len(symbol) > 1 and symbol[0] in (">", "<"):
            symbol = " " + symbol # make sure direction characters are aligned at 2nd column
        if self.options.get("no_color"):
            color = ""
            final = ""
        else:
#             CM = self.COLOR_MAP
#             color = CM.get((action, status), 
#                            CM.get(("*", status), 
#                                   CM.get((action, "*"), 
#                                          "")))
            if action in ("copy", "restore"):
                if "<" in symbol:
                    color = ansi_code("Fore.GREEN") + ansi_code("Style.BRIGHT") if status == "new" else ansi_code("Fore.GREEN")
                else:
                    color = ansi_code("Fore.CYAN") + ansi_code("Style.BRIGHT") if status == "new" else ansi_code("Fore.CYAN")
            elif action == "delete":
                color = ansi_code("Fore.RED")
            elif status == "conflict":
                color = ansi_code("Fore.LIGHTRED_EX")
            elif action == "skip" or status == "equal":
                color = ansi_code("Fore.LIGHTBLACK_EX")

            final = ansi_code("Style.RESET_ALL")
        
        final += " " * 10
        prefix = "" 
        if self.dry_run:
            prefix = DRY_RUN_PREFIX
        if action and status:
            tag = ("%s %s" % (action, status)).upper()
        else:
            tag = ("%s%s" % (action, status)).upper()
        name = entry.get_rel_path()
        if entry.is_dir():
            name = "[%s]" % name

#         print("{0}{1:<16} {2:^3} {3}".format(prefix, tag, symbol, name))
        print("{0}{1}{2:<16} {3:^3} {4}{5}".format(prefix, color, tag, symbol, name, final))