프로젝트

일반

사용자정보

개정판 b4555d97

IDb4555d97ed742f3b4629f813efd2f55a46e30620
상위 cea694ef
하위 cf505947

함의성이(가) 약 5년 전에 추가함

issue #563: support metric unit

Change-Id: Ibd9922d3909baea49e5004af597b757476a36b31

차이점 보기:

DTI_PID/DTI_PID/AppDocData.py
776 776
                                finally:
777 777
                                    file.close()
778 778
                        conn.commit()
779
                        self.saveConfigs([Config('Project', 'Unit', project.prj_unit)])
779 780
                except Exception as ex:
780 781
                    print('error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
781 782
                                                              sys.exc_info()[-1].tb_lineno))
DTI_PID/DTI_PID/Shapes/EngineeringReducerItem.py
34 34
        from AppDocData import AppDocData
35 35

  
36 36
        matches = [assoc for assoc in self.associations() if type(assoc) is QEngineeringSizeTextItem]
37
        configs = AppDocData.instance().getConfigs('Size', 'Delimiter')
37
        appDocData = AppDocData.instance()
38
        configs = appDocData.getConfigs('Size', 'Delimiter')
38 39
        delimiter = configs[0].value.upper() if 1 == len(configs) else None
40

  
41
        configs = appDocData.getConfigs('Project', 'Unit')
42
        sizeUnit = configs[0].value if 1 == len(configs) else None
43

  
39 44
        if matches:
40 45
            first, second = '', ''
41 46
            text = matches[0].text().replace("'", '"').upper()
47
            # for imperial
42 48
            if text.find('"') is not -1:
43 49
                first = text[:text.find('"') + 1]
44 50

  
......
50 56
                    second = text
51 57

  
52 58
                    return [first, second]
59
            # for metric
60
            else:
61
                split_text = text.strip().split(delimiter.upper())
62
                if len(split_text) is not 2:
63
                    return [None, None]
64
                first = split_text[0]
65
                second = split_text[1]
66
                return [first, second]
53 67

  
54 68
        return [None, None]
55 69

  
DTI_PID/DTI_PID/TextItemFactory.py
300 300
    def isSizeText(self, text, delimiter=None):
301 301
        from NominalPipeSize import NominalPipeSizeTable
302 302

  
303
        sizeUnit = None
304
        configs = AppDocData.instance().getConfigs('Project', 'Unit')
305
        sizeUnit = configs[0].value if 1 == len(configs) else None
306

  
303 307
        pipe_sizes = NominalPipeSizeTable.instance().pipe_sizes
304 308

  
305 309
        text = text.replace("'", '"').upper()
306 310

  
307 311
        first, second = None, None
312
        # for imperial
308 313
        if text.find('"') is not -1:
309 314
            first = text[:text.find('"') + 1]
310 315
            second = text[text.find('"') + 1:].replace(delimiter.upper(), '', 1).strip() if delimiter is not None else text[text.find('"') + 1:].strip()
316
        # for metric
317
        else:
318
            split_text = text.strip().split(delimiter.upper())
319
            if len(split_text) > 2:
320
                return False
321
            first = split_text[0]
322
            second = split_text[1] if len(split_text) is 2 else None
311 323

  
312 324
        tokens = [first, second] if second is not None and len(second) is not 0 else [first]
313 325
        for token in tokens:
314
            matches = [sizeData for sizeData in pipe_sizes if sizeData.find(token)]
326
            matches = [sizeData for sizeData in pipe_sizes if (sizeData.find(token, sizeUnit) if sizeUnit else sizeData.find(token))]
315 327
            if not matches: return False
316 328
        
317 329
        return True

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)