import fnmatch
import os
import time
from multiprocessing import Pool

DICT_OF_PATHS={'УС-0617': r'\\ZUMZ-DC2\UserData\Чертежи УСПК-Екб\УС-0617.00.000 БУ 400',
               'УС-0718': r'\\ZUMZ-DC2\UserData\Чертежи УСПК-Екб\УС-0718.00.000 Модернизация 3Д',
               'УС-1219': r'\\ZUMZ-DC2\UserData\Чертежи УСПК-Екб\УС-1219.00.000 БУ320',
               'УС-0719': r'\\ZUMZ-DC2\UserData\Чертежи УСПК-Екб\УС-0719.00.000 БУ 3Д',

def no_execution(value:str)->str:
    if value[len(value)-3:len(value)-2:1] in '-' :
        return value[0:len(value)-3:1]
    elif value[len(value)-2:len(value)-1:1] in '-' :
        return value[0:len(value)-2:1]
        return value  

def find_file(pattern,# designation + '*.cdw'
                 path): # DICT_OF_PATHS.get(designation[0:7], SEARCH_LOCALION)
    result = []
    for root, dirs, files in os.walk(path):
        for name in files:
            if fnmatch.fnmatch(name, pattern):
                result.append(os.path.join(root, name))
    return result

def check_found_file_path(designation:str, result_find):
    for path_file in result_find:
        if path_file.find(designation + " ") > 0:
            return path_file
def call_path_file(designation:str):
    result_find = find_file(designation + '*.cdw',
                            DICT_OF_PATHS.get(designation[0:7], SEARCH_LOCALION))
    if result_find:
        if len(result_find) >= 1:
            return check_found_file_path(designation, result_find)
        mod_designation = no_execution(designation)
        result_find_mod = find_file(mod_designation + '*.cdw',
                                    DICT_OF_PATHS.get(designation[0:7], SEARCH_LOCALION))
        if result_find_mod:
            return check_found_file_path(mod_designation, result_find_mod)
def start_file_KOMPAS(path_file):
    if path_file:

def multiprocessing_find_path_file(list_search):
    with Pool(processes=32) as pool: #32 optimal
        return, list_search)

if __name__ == '__main__':
    import reading_writing_txt as RW
    startTime = time.time()
    for path_file in multiprocessing_find_path_file(RW.read_db_txt()):
    endTime = time.time()
    totalTime = endTime - startTime 
    print("Время, затраченное на выполнение данного кода = ", totalTime)

Share a link to this review

7.58% issue ratio

R46 Not using pathlib

Python's built-in pathlib library is nice! It's less verbose than os.path and is easier to read, for example: root = Path('root'); subdir = root / 'subfolder1' / 'subfolder2'; subdir.mkdir(exist_ok=True). Use it!

R1 Missing type hints

Type hints help humans and linters (like mypy) to understand what to expect "in" and "out" for a function. Not only it serves as a documentation for others (and you after some time, when the code is wiped from your "brain cache"), but also allows using automated tools to find type errors.

O15 Using print()

print() is a nice way to output to stdout. But one day you'll need to not only write to stdout, but also, say, to a file. Another day you'll need to output only severe errors' messages, and nothing else. This all could be solved if using logging module. Usually it's as easy as from logging import getLogger; log = getLogger(__name__).

L12 Redundant code / overengineering

This code is not really needed or may be simplified

Suggested change:
if result_find and len(result_find) >= 1:
R61 Not using f-strings

F-strings are powerful and very easy to read. Compare: 'text ' + str(number) + ' text' vs f'text {number} text'

Create new review request