Exemple #1
0
def _get_renamed_name(elm: ElmType) -> str:
    assert isinstance(elm, ElmType)

    _fname = new_filename_by_input(str(elm))

    if is_duplicated_path_in_dir(elm, _fname):
        logger.warning(
            msg.ERR_FAIL_DUPLICATED_DATA.format(
                data=f"new name for renaming in {PROC}"))
        return ""
    return _fname
Exemple #2
0
def _get_new_filename(elm: ElmType, fname: str) -> str:
    assert isinstance(elm, ElmType)

    _fname = assertion.is_str(fname) if fname else new_filename_by_input(
        str(elm))

    if is_duplicated_path_in_dir(elm, _fname):
        logger.warning(
            msg.ERR_FAIL_DUPLICATED_DATA_WITH_DATA.format(
                data=f"new filename in {PROC}"), _fname)
        return ""
    return _fname
Exemple #3
0
def _get_edit_filename(elm: ElmType, fname: str) -> str:
    assert isinstance(elm, ElmType)

    filenames = filepaths_by_elm(elm)

    _fname = assertion.is_str(fname) if fname else get_target_filename_from_list(f"edit {str(elm)}", filenames)

    if not is_duplicated_path_in_dir(elm, _fname):
        logger.warning(
                msg.ERR_FAIL_MISSING_DATA_WITH_DATA.format(data=f"edit filename in {PROC}"),
                _fname)
        return ""
    return _fname
Exemple #4
0
def _get_reject_filename(elm: ElmType, fname: str) -> str:
    assert isinstance(elm, ElmType)

    ordernames = [
        rid_prefix(orderitem_of(elm), name)
        for name in get_filenames_in_order_by_elm(elm)
    ]

    _fname = assertion.is_str(
        fname) if fname else get_target_filename_from_list(
            f"reject {str(elm)}", ordernames)

    if not is_duplicated_path_in_dir(elm, _fname):
        logger.warning(
            msg.ERR_FAIL_CANNOT_WRITE_DATA_WITH_DATA.format(
                data=f"reject filename in {PROC}"), _fname)
        return ""
    return _fname
Exemple #5
0
def _get_push_parent_filename(elm: ElmType) -> str:
    assert isinstance(elm, ElmType)

    parent_elm = get_elm_from_order(get_parent_item_of(orderitem_of(elm)))
    ordernames = [
        rid_prefix(orderitem_of(parent_elm), name)
        for name in get_filenames_in_order_by_elm(parent_elm)
    ]

    _fname = get_target_filename_from_list("parent name", ordernames)

    if not is_duplicated_path_in_dir(parent_elm, _fname):
        logger.warning(
            msg.ERR_FAIL_MISSING_DATA_WITH_DATA.format(
                data=f"parent filename in {PROC}"), _fname)
        return ""

    return _fname
Exemple #6
0
def _get_push_filename(elm: ElmType, fname: str) -> str:
    assert isinstance(elm, ElmType)

    filenames = [basename_of(name) for name in filepaths_by_elm(elm)]
    ordernames = [
        rid_prefix(orderitem_of(elm), name)
        for name in get_filenames_in_order_by_elm(elm)
    ]

    _fname = assertion.is_str(
        fname) if fname else get_target_filename_from_list(
            f"push {str(elm)}", list(set(filenames) - set(ordernames)))

    if not is_duplicated_path_in_dir(elm, _fname):
        logger.warning(
            msg.ERR_FAIL_MISSING_DATA_WITH_DATA.format(
                data=f"push filename in {PROC}"), _fname)
        return ""
    return _fname