pilot.linkstec 0.0.25__py3-none-any.whl → 0.0.27__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.
- pilot/conver/commentRemover.py +100 -0
- pilot/conver/converfileEncodding.py +4 -32
- pilot/generater/vertexai.py +2 -0
- pilot/job/job_interface.py +1 -0
- {pilot_linkstec-0.0.25.dist-info → pilot_linkstec-0.0.27.dist-info}/METADATA +1 -1
- {pilot_linkstec-0.0.25.dist-info → pilot_linkstec-0.0.27.dist-info}/RECORD +9 -8
- {pilot_linkstec-0.0.25.dist-info → pilot_linkstec-0.0.27.dist-info}/WHEEL +0 -0
- {pilot_linkstec-0.0.25.dist-info → pilot_linkstec-0.0.27.dist-info}/licenses/LICENSE +0 -0
- {pilot_linkstec-0.0.25.dist-info → pilot_linkstec-0.0.27.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
class CommentRemover:
|
|
6
|
+
"""
|
|
7
|
+
ColdFusion (.cfm, .cfc) と JavaScript (.js) のコメント削除クラス
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
def __init__(self, file_path: str):
|
|
11
|
+
self.file_path = Path(file_path)
|
|
12
|
+
self.text = ''
|
|
13
|
+
self.cleaned_text = ''
|
|
14
|
+
|
|
15
|
+
def load(self, encoding='utf-8'):
|
|
16
|
+
try:
|
|
17
|
+
with self.file_path.open('r', encoding=encoding) as f:
|
|
18
|
+
self.text = f.read()
|
|
19
|
+
except Exception as e:
|
|
20
|
+
print(f"Failed to load file {self.file_path}: {e}", file=sys.stderr)
|
|
21
|
+
raise
|
|
22
|
+
|
|
23
|
+
def save(self, output_path: str, encoding='utf-8'):
|
|
24
|
+
try:
|
|
25
|
+
with open(output_path, 'w', encoding=encoding) as f:
|
|
26
|
+
f.write(self.cleaned_text)
|
|
27
|
+
except Exception as e:
|
|
28
|
+
print(f"Failed to save file {output_path}: {e}", file=sys.stderr)
|
|
29
|
+
raise
|
|
30
|
+
|
|
31
|
+
def remove_comments(self):
|
|
32
|
+
ext = self.file_path.suffix.lower()
|
|
33
|
+
if ext in ['.cfm', '.cfc']:
|
|
34
|
+
self.cleaned_text = self.remove_coldfusion_comments(self.text)
|
|
35
|
+
elif ext == '.js':
|
|
36
|
+
self.cleaned_text = self.remove_js_comments(self.text)
|
|
37
|
+
elif ext in ['.cbl', '.cob', '.cobol']:
|
|
38
|
+
self.cleaned_text = self.remove_cobol_comments(self.text)
|
|
39
|
+
else:
|
|
40
|
+
print(f"Unsupported file extension: {ext}, no comment removal applied.", file=sys.stderr)
|
|
41
|
+
self.cleaned_text = self.text
|
|
42
|
+
|
|
43
|
+
def remove_coldfusion_comments(self, text: str) -> str:
|
|
44
|
+
pattern_cftag = r'<!---(?:.|\n)*?--->'
|
|
45
|
+
pattern_block = r'/\*(?:.|\n)*?\*/'
|
|
46
|
+
pattern_line = r'//.*?$'
|
|
47
|
+
|
|
48
|
+
text = re.sub(pattern_cftag, '', text, flags=re.MULTILINE)
|
|
49
|
+
text = re.sub(pattern_block, '', text, flags=re.MULTILINE)
|
|
50
|
+
text = re.sub(pattern_line, '', text, flags=re.MULTILINE)
|
|
51
|
+
return text
|
|
52
|
+
|
|
53
|
+
def remove_js_comments(self, text: str) -> str:
|
|
54
|
+
pattern_block = r'/\*(?:.|\n)*?\*/'
|
|
55
|
+
pattern_line = r'//.*?$'
|
|
56
|
+
|
|
57
|
+
text = re.sub(pattern_block, '', text, flags=re.MULTILINE)
|
|
58
|
+
text = re.sub(pattern_line, '', text, flags=re.MULTILINE)
|
|
59
|
+
return text
|
|
60
|
+
|
|
61
|
+
def remove_cobol_comments(self, text: str) -> str:
|
|
62
|
+
"""
|
|
63
|
+
COBOLのコメント行、および方言の行内コメント *>以降を削除
|
|
64
|
+
|
|
65
|
+
・固定形式コメント行
|
|
66
|
+
行頭が '*'(先頭1文字目が*)の行はコメント → 削除
|
|
67
|
+
または7文字目が '*'の行もコメント → 削除
|
|
68
|
+
|
|
69
|
+
・行内コメント (方言)
|
|
70
|
+
'*> '以降はコメント → 削除
|
|
71
|
+
"""
|
|
72
|
+
|
|
73
|
+
lines = text.splitlines()
|
|
74
|
+
cleaned_lines = []
|
|
75
|
+
|
|
76
|
+
for line in lines:
|
|
77
|
+
# 固定長形式にあわせて7文字目 (index 6)を判定
|
|
78
|
+
# 行長が7未満でも対応 (存在しなければFalse)
|
|
79
|
+
is_comment_line = False
|
|
80
|
+
|
|
81
|
+
if line.startswith('*'):
|
|
82
|
+
is_comment_line = True
|
|
83
|
+
elif len(line) >= 7 and line[6] == '*':
|
|
84
|
+
is_comment_line = True
|
|
85
|
+
|
|
86
|
+
if is_comment_line:
|
|
87
|
+
# コメント行なのでスキップ
|
|
88
|
+
continue
|
|
89
|
+
|
|
90
|
+
# 行内コメント *> の扱い
|
|
91
|
+
# 行の途中に '*> ' (*>に続く空白も含む) があればその位置で切り捨てる
|
|
92
|
+
comment_pos = line.find('*>')
|
|
93
|
+
if comment_pos != -1:
|
|
94
|
+
# 行内コメント開始位置でカット(空白も含め全部削除)
|
|
95
|
+
# 例えば 'MOVE X TO Y *> このコメント' => 'MOVE X TO Y '
|
|
96
|
+
line = line[:comment_pos].rstrip()
|
|
97
|
+
|
|
98
|
+
cleaned_lines.append(line)
|
|
99
|
+
|
|
100
|
+
return '\n'.join(cleaned_lines)
|
|
@@ -10,14 +10,15 @@ def nkf_convert(file_path, nkf_args):
|
|
|
10
10
|
:param nkf_args: nkf に渡す引数のリスト(例: ['-w'])
|
|
11
11
|
"""
|
|
12
12
|
# nkfコマンドの引数にファイルパスを追加
|
|
13
|
-
|
|
13
|
+
cmd = ['nkf'] + nkf_args + [file_path]
|
|
14
14
|
|
|
15
|
-
cmd =
|
|
15
|
+
#cmd = 'nkf32' + ' ' + arg1 + ' '+ arg2 +' '+ file_path
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
try:
|
|
19
19
|
# nkfを実行し標準出力を取得
|
|
20
|
-
result = subprocess.run(
|
|
20
|
+
result = subprocess.run(
|
|
21
|
+
cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True)
|
|
21
22
|
print(f"nkfの実行完了しました: {file_path}")
|
|
22
23
|
except subprocess.CalledProcessError as e:
|
|
23
24
|
print(f"nkfの実行でエラーが発生しました: {e.stderr.decode()}", file=sys.stderr)
|
|
@@ -46,32 +47,3 @@ def nkf_convert(file_path, nkf_args):
|
|
|
46
47
|
# output = nkf_convert(file_path, nkf_args)
|
|
47
48
|
|
|
48
49
|
|
|
49
|
-
if __name__ == "__main__":
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
target_dir = r'D:\work\fullsource'
|
|
53
|
-
nkf_args = ['-w', '--overwrite']
|
|
54
|
-
#extensions = (
|
|
55
|
-
# '.cfc', '.cfm', '.cob', '.cobol', '.cpy', '.csh', '.css', '.ctl',
|
|
56
|
-
# '.htm', '.html', '.js', '.sh', '.sql', '.tpl', '.txt'
|
|
57
|
-
#)
|
|
58
|
-
extensions = ('.cnd','.cng','int')
|
|
59
|
-
for root, dirs, files in os.walk(target_dir):
|
|
60
|
-
for file in files:
|
|
61
|
-
if file.lower().endswith(extensions):
|
|
62
|
-
filepath = os.path.join(root, file)
|
|
63
|
-
output = nkf_convert([filepath], nkf_args)
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
#if output is not None:
|
|
67
|
-
# 結果を標準出力にバイナリのまま書き出す場合
|
|
68
|
-
# sys.stdout.buffer.write(output)
|
|
69
|
-
|
|
70
|
-
# あるいはUTF-8等に応じてデコードして表示する場合
|
|
71
|
-
# 一旦utf-8デコードを試みる例(必要に応じて変更してください)
|
|
72
|
-
# try:
|
|
73
|
-
# decoded_output = output.decode('utf-8')
|
|
74
|
-
# print(decoded_output)
|
|
75
|
-
# except UnicodeDecodeError:
|
|
76
|
-
# print("utf-8へのデコードに失敗しました。バイナリデータとして出力します。", file=sys.stderr)
|
|
77
|
-
# sys.stdout.buffer.write(output)
|
pilot/generater/vertexai.py
CHANGED
pilot/job/job_interface.py
CHANGED
|
@@ -6,12 +6,13 @@ pilot/control/control_interface.py,sha256=zGv380oQgAKPAIHDHeFdPYzhj2Ngo2T66NWlNl
|
|
|
6
6
|
pilot/control/impl/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
7
|
pilot/control/impl/base_controller.py,sha256=h-A2X4BD_4GGQ0BjCXv_tcO8XdM8_YjXHDIZzvdzyjQ,1634
|
|
8
8
|
pilot/conver/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
-
pilot/conver/
|
|
9
|
+
pilot/conver/commentRemover.py,sha256=S8uwp9Glp0bdv4EFqf62WIcOTLiJZdracG2FAMKY1EY,3777
|
|
10
|
+
pilot/conver/converfileEncodding.py,sha256=EK2zrVbRjSPEljR3myq_ZEDJkM7i79ol9lbVM_Khbok,1596
|
|
10
11
|
pilot/conver/nkf_converter.py,sha256=JqgThmXcdnTGMsLIHUEwe8sc0VGMqDaKCIQTg-UE3WE,1148
|
|
11
12
|
pilot/generater/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
|
-
pilot/generater/vertexai.py,sha256=
|
|
13
|
+
pilot/generater/vertexai.py,sha256=SOFfl0qCuLhfjeIoSU7Tk-I7ZB6ZrOyGme2rXDYCGzk,2599
|
|
13
14
|
pilot/job/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
|
-
pilot/job/job_interface.py,sha256=
|
|
15
|
+
pilot/job/job_interface.py,sha256=EKtuj0IcdolP494aAgTtctgamyQIoFXVwRORwOQck7A,124
|
|
15
16
|
pilot/job/impl/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
17
|
pilot/job/impl/base_job.py,sha256=iojwBJApivsCmHG9HRCJrWUwtbBc_GrCI31xac0JYtE,14053
|
|
17
18
|
pilot/logging/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -27,8 +28,8 @@ pilot/unit/impl/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
27
28
|
pilot/unit/impl/base_unit.py,sha256=LsFPpL28aSNv5rsZhfKv6CWhAw1XR4n-A6FOn2RBrZo,1272
|
|
28
29
|
pilot/util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
29
30
|
pilot/util/files.py,sha256=v9uzfzo3Aq4xgnUIASEZeBJoA2nD9Qz_EA3P-FwzGFQ,1896
|
|
30
|
-
pilot_linkstec-0.0.
|
|
31
|
-
pilot_linkstec-0.0.
|
|
32
|
-
pilot_linkstec-0.0.
|
|
33
|
-
pilot_linkstec-0.0.
|
|
34
|
-
pilot_linkstec-0.0.
|
|
31
|
+
pilot_linkstec-0.0.27.dist-info/licenses/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
|
|
32
|
+
pilot_linkstec-0.0.27.dist-info/METADATA,sha256=-OvWLiazdPFZcMsONpP-S5LQpVh1JEN7Itx7M_JT4LM,679
|
|
33
|
+
pilot_linkstec-0.0.27.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
34
|
+
pilot_linkstec-0.0.27.dist-info/top_level.txt,sha256=BijnVJdXnIPxxx3s60M848seL4Z12gNUPod6KPJxK9c,6
|
|
35
|
+
pilot_linkstec-0.0.27.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|