pyjallib 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyjallib/__init__.py +17 -0
- pyjallib/max/__init__.py +46 -0
- pyjallib/max/align.py +112 -0
- pyjallib/max/anim.py +594 -0
- pyjallib/max/bip.py +508 -0
- pyjallib/max/bone.py +910 -0
- pyjallib/max/constraint.py +973 -0
- pyjallib/max/header.py +57 -0
- pyjallib/max/helper.py +433 -0
- pyjallib/max/layer.py +262 -0
- pyjallib/max/link.py +78 -0
- pyjallib/max/macro/jal_macro_align.py +155 -0
- pyjallib/max/macro/jal_macro_bone.py +358 -0
- pyjallib/max/macro/jal_macro_constraint.py +140 -0
- pyjallib/max/macro/jal_macro_helper.py +321 -0
- pyjallib/max/macro/jal_macro_link.py +55 -0
- pyjallib/max/macro/jal_macro_select.py +91 -0
- pyjallib/max/mirror.py +388 -0
- pyjallib/max/name.py +521 -0
- pyjallib/max/select.py +278 -0
- pyjallib/max/skin.py +996 -0
- pyjallib/max/twistBone.py +418 -0
- pyjallib/namePart.py +633 -0
- pyjallib/nameToPath.py +113 -0
- pyjallib/naming.py +1066 -0
- pyjallib/namingConfig.py +844 -0
- pyjallib/perforce.py +735 -0
- pyjallib/reloadModules.py +33 -0
- pyjallib-0.1.0.dist-info/METADATA +28 -0
- pyjallib-0.1.0.dist-info/RECORD +32 -0
- pyjallib-0.1.0.dist-info/WHEEL +5 -0
- pyjallib-0.1.0.dist-info/top_level.txt +1 -0
pyjallib/nameToPath.py
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
|
4
|
+
"""
|
5
|
+
nameToPath 모듈 - 이름과 경로 변환 관련 기능
|
6
|
+
이름 규칙에 따라 경로를 생성하거나 경로에서 이름을 추출하는 기능 제공
|
7
|
+
"""
|
8
|
+
|
9
|
+
import os
|
10
|
+
import json
|
11
|
+
from typing import Optional, Dict, Any, List
|
12
|
+
|
13
|
+
from pyjallib.naming import Naming
|
14
|
+
from pyjallib.namePart import NamePartType
|
15
|
+
|
16
|
+
class NameToPath(Naming):
|
17
|
+
"""
|
18
|
+
NameToPath 클래스는 Naming 클래스를 상속받아 이름을 기반으로 경로를 생성하는 기능을 제공합니다.
|
19
|
+
"""
|
20
|
+
def __init__(self, configPath: str, rootPath: str = None, sourceNaming: Naming = None):
|
21
|
+
"""
|
22
|
+
생성자 메서드입니다.
|
23
|
+
:param configPath: 설정 파일의 경로
|
24
|
+
:param rootPath: 루트 경로 (기본값: None)
|
25
|
+
:param sourceNaming: 소스 이름을 처리하기 위한 Naming 객체 (기본값: None)
|
26
|
+
"""
|
27
|
+
# 부모 클래스(Naming) 생성자 호출
|
28
|
+
super().__init__(configPath)
|
29
|
+
self.rootPath = None
|
30
|
+
if rootPath:
|
31
|
+
self.set_root_path(rootPath)
|
32
|
+
# 소스 네이밍 객체 설정
|
33
|
+
self.sourceNaming = sourceNaming
|
34
|
+
|
35
|
+
def set_root_path(self, inRootPath: str):
|
36
|
+
"""
|
37
|
+
루트 경로를 설정합니다.
|
38
|
+
입력된 경로를 정규화하고 유효성을 검증합니다.
|
39
|
+
|
40
|
+
:param inRootPath: 루트 경로 (문자열)
|
41
|
+
:return: 정규화된 경로
|
42
|
+
:raises ValueError: 경로가 존재하지 않는 경우
|
43
|
+
"""
|
44
|
+
if inRootPath:
|
45
|
+
# 경로 정규화 (상대 경로를 절대 경로로 변환, '/' 대신 '\' 사용 등)
|
46
|
+
normalized_path = os.path.normpath(os.path.abspath(inRootPath))
|
47
|
+
|
48
|
+
# 경로 존재 여부 확인 (선택적)
|
49
|
+
if not os.path.exists(normalized_path):
|
50
|
+
raise ValueError(f"경로가 존재하지 않습니다: {normalized_path}")
|
51
|
+
|
52
|
+
self.rootPath = normalized_path
|
53
|
+
return self.rootPath
|
54
|
+
else:
|
55
|
+
self.rootPath = None
|
56
|
+
return None
|
57
|
+
|
58
|
+
def combine(self, inPartsDict={}, inFilChar=os.sep) -> str:
|
59
|
+
"""
|
60
|
+
딕셔너리의 값들을 설정된 순서에 따라 문자열로 결합합니다. (인덱스 제외)
|
61
|
+
|
62
|
+
:param inPartsDict: 결합할 키-값 쌍을 포함하는 딕셔너리
|
63
|
+
:param inFilChar: 값들을 구분할 구분자 (기본값: "_")
|
64
|
+
:return: 결합된 문자열
|
65
|
+
"""
|
66
|
+
# 결과 배열 초기화 (빈 문자열로)
|
67
|
+
combinedNameArray = [""] * len(self._nameParts)
|
68
|
+
|
69
|
+
# 각 namePart에 대해
|
70
|
+
for i, part in enumerate(self._nameParts):
|
71
|
+
partName = part.get_name()
|
72
|
+
# 딕셔너리에서 해당 부분의 값 가져오기 (없으면 빈 문자열 사용)
|
73
|
+
if partName in inPartsDict:
|
74
|
+
combinedNameArray[i] = inPartsDict[partName]
|
75
|
+
|
76
|
+
# 배열을 문자열로 결합
|
77
|
+
newName = self._combine(combinedNameArray, inFilChar)
|
78
|
+
return newName
|
79
|
+
|
80
|
+
|
81
|
+
def gen_path(self, inStr):
|
82
|
+
"""
|
83
|
+
입력된 문자열을 기반으로 경로를 생성합니다.
|
84
|
+
|
85
|
+
:param inStr: 경로를 생성할 문자열 (이름)
|
86
|
+
:return: 생성된 경로 (문자열)
|
87
|
+
:raises ValueError: 루트 경로가 설정되지 않았거나 이름을 변환할 수 없는 경우
|
88
|
+
"""
|
89
|
+
if not self.rootPath:
|
90
|
+
raise ValueError("루트 경로가 설정되지 않았습니다.")
|
91
|
+
|
92
|
+
# 이름을 딕셔너리로 변환
|
93
|
+
nameDict = self.sourceNaming.convert_to_dictionary(inStr)
|
94
|
+
if not nameDict:
|
95
|
+
raise ValueError(f"이름을 변환할 수 없습니다: {inStr}")
|
96
|
+
print(f"Name Dictionary: {nameDict}")
|
97
|
+
|
98
|
+
pathDict = {}
|
99
|
+
|
100
|
+
# 선택된 NamePart 값들을 설명으로 변환하여 폴더 이름으로 사용
|
101
|
+
for key, value in nameDict.items():
|
102
|
+
namePart = self.sourceNaming.get_name_part(key)
|
103
|
+
if self.get_name_part(namePart.get_name()):
|
104
|
+
if namePart.get_type() == NamePartType.REALNAME:
|
105
|
+
# 실제 이름인 경우, 해당 이름을 사용
|
106
|
+
pathDict[key] = value
|
107
|
+
else:
|
108
|
+
pathDict[key] = namePart.get_description_by_value(value)
|
109
|
+
|
110
|
+
combinedPath = self.combine(pathDict)
|
111
|
+
finalPath = os.path.join(self.rootPath, combinedPath)
|
112
|
+
|
113
|
+
return os.path.normpath(finalPath)
|