Exemple #1
0
def _catch_exception(value, exc='', color=_f.red, fl=_fl):
    exc = _ind.get(_ind.default_exc, fl=fl) if not exc else exc
    if value in exc:
        _note.message_console("⛔ %s: Exception ¯\_(ツ)_/¯" % sp_path(value, 2),
                              c_pat='',
                              color=color)
        return True
    else:
        return False
Exemple #2
0
def _set_header(cmd, val=None):
    def __colorize_val(x):
        return _f.paint(x, _f.grey2)

    if cmd in ["type", "color", "fluency", "header", None]:
        val = [0] if val is None or isinstance(val[0], str) else val
        not_gen = cmd is not None
        arr = '⇛ '* not_gen
        dict_header = {
            "header":   ('🠶', " Header: %s%s"   % (arr, __colorize_val(_init(not_gen ^ _header, fl=_fl).switch.upper()))),
            "type":     ('📌', " Type: %s%s"     % (arr, __colorize_val(_init(not_gen ^ _type_dir, fl=_fl).switch.upper()))),
            "color":    ('👀', " Color: %s%s"    % (arr, __colorize_val(_init(not_gen ^ _color, fl=_fl).switch.upper()))),
            "fluency":  ('🚀', " Fluency: %s%s " % (arr, __colorize_val(_fl + val[0] * not_gen))),

        }
        if cmd is None:
            [_note.message_console(dict_header[x][1], c_pat=dict_header[x][0], color=_f.grey, c_pat_color=_f.grey2, end=_f.end + '  ') for x in ["type", "color", "header", "fluency"]]
            print()
        else:
            _note.message_console(dict_header[cmd][1], c_pat=dict_header[cmd][0], color=_f.grey, c_pat_color=_f.grey)
Exemple #3
0
 def __notify(step):
     if step == 0:
         _note.status(tag=MODE, color=navi_color, pattern='.') if it == 0 else print()
         if is_dir_clear:
             _note.result(directory, None, "cur_dir", '', _to_gp, general_c=navi_color, init=[True, ''], fl=fl),
             _set_header(None) if _header else None
             _note.message_console("Select %s location: " % _f.paint(mod, navi_color + _f.underline, navi_color), '', c_pat='', color=navi_color, end='')
         else:
             _note.result(_obj.get("folder"), True, "cur_dir", 'Choice', _to_gp, general_c=navi_color, init=['', ''], end=' ', fl=fl),
         _note.waiting(end=' ')
     elif step == 1:
         [print("{} {}".format(_f.paint(_dpw(i, str, 2)[0] + '.', navi_color), x)) for i, x in enumerate(cur_labels)]
     else:
         if flag:
             _note.result(cur_dir[k].content, None, MODE, decore=_to_gp, fl=fl)
         elif flag is None:
             None if correct else _note.result(fin, False, MODE, init=False, fl=fl)
         else:
             _note.parameters({"Iterations": it, "Final Path": directory}, color=navi_color + _f.bold + _f.underline, end='    ')
             None if not shutdown else _note.process(MODE, False, color=_f.bg(navi_color), fl=_fl)
             None if not shutdown else _note.status('.', '.', color=navi_color)
Exemple #4
0
 def goodbye(offset=False):
     print() if offset else None
     _note.message_console("Fuh...After all, we worked well, didn't we? ;)",
                           c_pat=AI_ico)
     _note.message_console("See you soon", c_pat=AI_ico)
     _note.message_console("Your {}".format(_p(AI, emit_color)),
                           c_pat=AI_ico)
Exemple #5
0
 def greeting(offset=False):
     print() if offset else None
     _note.message_console("Hello, {}!".format(USER),
                           c_pat=AI_ico,
                           time_delay=0.2)
     _note.message_console("I'm {} :)".format(AI),
                           c_pat=AI_ico,
                           time_delay=0.2)
     # TODO: Intersection colors
     # note.message_console("I'm {}{} :) {}".format(font.bold, AI, font.end, ''), c_pat=AI_ico, time_delay=0.2)
     _note.message_console("I'll be your assistant".format(
         _p(AI, emit_color)),
                           c_pat=AI_ico)
Exemple #6
0
 def info(diff):
     _note.message_console(_p("{} finishing".format("Process"), csl_color),
                           c_pat='')
     _note.message_console("In: {}{}h:{}m:{}s{}".format(
         emit_color, diff[0], diff[1], diff[2], _end),
                           c_pat='')
Exemple #7
0
def _get_correct_input(directory, fin, cur_dir, mod, _exc):
    """ Convert user_input to command, tags and values """
    # [False, True, None] == [Exit, GoNext, Refresh]    ||    "cmd": (flag, value),    ||    "cmd": func(*args),
    def __offset(x, check_list):
        print() if x in check_list else None

    def __set(value):
        return set(value) if isinstance(value, list) else {value}

    _set_time(0)
    """ Get cmd, tag, val """
    cmd, tag, val = _console(fin)
    __offset(cmd, ["rename", "del", "move", "copy", "open", "get", "make"])
    """ Init built-in vars """
    global correct
    temp0, temp1 = False, False
    cmd = "sort" if mod == "sort" and cmd in ['', "sort"] and not val else cmd
    correct = True if fin == "rf" or cmd and cmd != "ref" else False
    # input([cmd, tag, val])
    out = {
        "help":     (None, ''),
        "undo":     (None, ''),
        "fin":      (False, "exit"),
        "":         (False, ''),
        "make":     (None, ''),
        "rename":   (None, ''),
        "del":      (False, []),
        "move":     (False, []),
        "copy":     (False, []),
        "sort":     (False, "single"),
        "open":     (None, ''),
        "ref":      (None, ''),
        "type":     (None, "switch_tp"),
        "color":    (None, "switch_cl"),
        "header":   (None, "switch_hd"),
        "ind":      (None, ''),
        "fluency":  (None, ''),
        "get":      (None, ''),
        "cd":       (True, 0),
    }
    do = {
        "help":     (lambda x: input(">> ..")),
        "make":     (lambda x: _fm.create(op.join(directory, x), '', True)),
        "del":      (lambda x: _fm.delete(x, True)),
        "rename":   (lambda x: _fm.rename(x, input("Enter new name: "), True, 2)),
        "open":     (lambda x: _fm.open(x, True)),
        "get":      (lambda x: _subs(x, temp0, temp1, public=True, fl=_fl)),
        "ind":      (lambda x: _ind.append(op.join(_ind.dir_tmp, str(temp0)), x, public=True)),
        "fluency":  (lambda x: _set_fluency(x)),
    }
    """ Init cmd, tag, val """
    if cmd in out.keys():
        if cmd in ["move", "copy"]:     # TODO: if all are exc
            pathways, pathways_c, moved = [cur_dir[x] for x in val], [cur_dir[x].content for x in val], []
            msg = [_f.paint("Selected:", _f.yellow) + _f.paint('(' + cmd + ')', _f.grey)] + [_obj.get("element") + ' ' + p for p in _ind.files(pathways_c, pathways_c, _exc, _f.red)[0]]
            [print(x) for x in msg]
            inter = __set(pathways[0].family)
            for i in range(1, len(pathways)):
                inter &= __set(pathways[i].family)
            for sup_dst in list(inter):
                if sup_dst in _dirs:
                    _dst = _dirs[sup_dst]
                    dst_name_colored = _f.paint(_init(_dst[1], fl=_fl).sign + ' ' + _dst[1], _dst[0], '')
                    if _start("Is {0}{2}{1} the {0}destination{1}".format(_f.bold, _f.end, dst_name_colored), reverse=True, color=''):
                        r_dst = _dst[1]
                        break
            else:
                r_dst, msg = run([x[1] for x in _dirs.values()], 1, _f.yellow, cmd, False)
            print()
            for item in pathways:
                moved.append(op.join(r_dst, item.name))
                _fm.move(item.content, r_dst, public=True, exc=_exc, mod=cmd)
            out.update({cmd: (False, moved)})
        else:   # TODO: optimize for not common function; help by key_work cmd: fl -> ++/ -- ?
            """ INIT <val> """
            if cmd in ["fluency"]:
                val = [val]
            elif not val:
                val = [directory]
            else:
                val = [(cur_dir[x].content if isinstance(x, int) else x) for x in
                       (val if isinstance(val, list) else [val])]
            """ INIT <cmd> """
            """ "type", "color", "fluency", "header" """
            _set_header(cmd, val)
            """ "ind" """
            temp0 = _ind.used_tmp if cmd == "ind" and tag == "usd" else (_ind.exc_tmp if cmd == "ind" and tag == "exc" else temp0)
            """ "get" """
            temp0, temp1 = (True, False) if cmd == "get" and tag == "dir" else ((False, True) if cmd == "get" and tag == "file" else (temp0, temp1))
            """ "del" """
            out.update({cmd: (False, [x for x in val if x != directory])}) if cmd == "del" else None
            """ "sort -rec" """
            out.update({cmd: (False, "recursive")}) if cmd == "sort" and tag == "rec" else None
            """ "del - odd" """
            if cmd == "del" and tag == "odd":
                val = [x.content for x in cur_dir if x.property == "~/empty"]
                if not val:
                    _note.message_console("Nothing to delete ¯\_(ツ)_/¯ (or try to down fluency)", c_pat='', color=_f.grey)
                    cmd, tag, val = "ref", '', ''
            """ Do by <cmd> """
            [do.get(cmd)(x) for x in val] if cmd in do.keys() else None
    elif 0 <= val < len(cur_dir):
        if _fm._catch_exception(cur_dir[val].content, _exc, _f.grey):
            cmd = "ref"
        elif cur_dir[val].type == "file":
            cmd = "open"
            do.get("open")([directory] if not val else cur_dir[val].content)
        else:
            cmd = "cd"
            out.update({cmd: (True, val)})
    else:
        cmd = "ref"
    __offset(cmd, ["del", "move", "copy"]), _set_time(1)
    return out.get(cmd)