hwp2hwpx 1.0.0__tar.gz
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.
- hwp2hwpx-1.0.0/LICENSE +177 -0
- hwp2hwpx-1.0.0/NOTICE +15 -0
- hwp2hwpx-1.0.0/PKG-INFO +106 -0
- hwp2hwpx-1.0.0/README.md +80 -0
- hwp2hwpx-1.0.0/pyproject.toml +39 -0
- hwp2hwpx-1.0.0/setup.cfg +4 -0
- hwp2hwpx-1.0.0/src/hwp2hwpx/__init__.py +25 -0
- hwp2hwpx-1.0.0/src/hwp2hwpx/cli.py +98 -0
- hwp2hwpx-1.0.0/src/hwp2hwpx/converter.py +204 -0
- hwp2hwpx-1.0.0/src/hwp2hwpx/jars/hwp2hwpx.jar +0 -0
- hwp2hwpx-1.0.0/src/hwp2hwpx.egg-info/PKG-INFO +106 -0
- hwp2hwpx-1.0.0/src/hwp2hwpx.egg-info/SOURCES.txt +13 -0
- hwp2hwpx-1.0.0/src/hwp2hwpx.egg-info/dependency_links.txt +1 -0
- hwp2hwpx-1.0.0/src/hwp2hwpx.egg-info/entry_points.txt +2 -0
- hwp2hwpx-1.0.0/src/hwp2hwpx.egg-info/top_level.txt +1 -0
hwp2hwpx-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding any notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
hwp2hwpx-1.0.0/NOTICE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
hwp2hwpx - HWP to HWPX Converter
|
|
2
|
+
Copyright 2025 neolord0
|
|
3
|
+
|
|
4
|
+
This product includes software developed by neolord0:
|
|
5
|
+
- hwp2hwpx (https://github.com/neolord0/hwp2hwpx)
|
|
6
|
+
- hwplib (https://github.com/neolord0/hwplib)
|
|
7
|
+
- hwpxlib (https://github.com/neolord0/hwpxlib)
|
|
8
|
+
|
|
9
|
+
All original Java libraries are licensed under the Apache License 2.0.
|
|
10
|
+
|
|
11
|
+
This Python wrapper packages the pre-built Java JAR for convenient
|
|
12
|
+
pip installation and adds a CLI interface.
|
|
13
|
+
|
|
14
|
+
This product references publicly available HWP/HWPX file format
|
|
15
|
+
specifications published by Hancom Inc. (https://www.hancom.com).
|
hwp2hwpx-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hwp2hwpx
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Convert HWP (Hangul Word Processor) files to HWPX format
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
Project-URL: Homepage, https://github.com/neolord0/hwp2hwpx
|
|
7
|
+
Project-URL: Issues, https://github.com/neolord0/hwp2hwpx/issues
|
|
8
|
+
Keywords: hwp,hwpx,hangul,korean,document,converter
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Topic :: Office/Business
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
21
|
+
Requires-Python: >=3.8
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
License-File: NOTICE
|
|
25
|
+
Dynamic: license-file
|
|
26
|
+
|
|
27
|
+
# hwp2hwpx
|
|
28
|
+
|
|
29
|
+
HWP(한글 워드프로세서) 파일을 HWPX(OWPML) 형식으로 변환하는 Python 패키지.
|
|
30
|
+
|
|
31
|
+
[neolord0/hwp2hwpx](https://github.com/neolord0/hwp2hwpx) Java 라이브러리를 번들하여
|
|
32
|
+
`pip install` 한 줄로 설치, 바로 사용할 수 있게 만든 래퍼입니다.
|
|
33
|
+
|
|
34
|
+
## 요구사항
|
|
35
|
+
|
|
36
|
+
- Python 3.8+
|
|
37
|
+
- Java Runtime Environment (JRE) 8+
|
|
38
|
+
|
|
39
|
+
## 설치
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install hwp2hwpx
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Java가 없으면:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# Windows
|
|
49
|
+
winget install EclipseAdoptium.Temurin.21.JDK
|
|
50
|
+
|
|
51
|
+
# macOS
|
|
52
|
+
brew install temurin
|
|
53
|
+
|
|
54
|
+
# Linux (Debian/Ubuntu)
|
|
55
|
+
apt install default-jre
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## 사용법
|
|
59
|
+
|
|
60
|
+
### CLI
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
# 단일 파일
|
|
64
|
+
hwp2hwpx document.hwp
|
|
65
|
+
|
|
66
|
+
# 여러 파일
|
|
67
|
+
hwp2hwpx *.hwp
|
|
68
|
+
|
|
69
|
+
# 출력 디렉토리 지정
|
|
70
|
+
hwp2hwpx document.hwp -o output/
|
|
71
|
+
|
|
72
|
+
# 폴더 내 전체 변환 (재귀)
|
|
73
|
+
hwp2hwpx ./documents/ -r
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Python API
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from hwp2hwpx import convert, convert_batch
|
|
80
|
+
|
|
81
|
+
# 단일 파일
|
|
82
|
+
output_path = convert("document.hwp")
|
|
83
|
+
output_path = convert("document.hwp", "output.hwpx")
|
|
84
|
+
|
|
85
|
+
# 배치
|
|
86
|
+
results = convert_batch(["a.hwp", "b.hwp"], output_dir="output/")
|
|
87
|
+
for input_path, output_path, error in results:
|
|
88
|
+
if error:
|
|
89
|
+
print(f"FAIL: {input_path}: {error}")
|
|
90
|
+
else:
|
|
91
|
+
print(f"OK: {output_path}")
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## 한글 경로 지원
|
|
95
|
+
|
|
96
|
+
Windows에서 한글(Korean) 파일 경로를 자동으로 처리합니다.
|
|
97
|
+
내부적으로 임시 ASCII 경로를 경유하여 JVM 인코딩 문제를 우회합니다.
|
|
98
|
+
|
|
99
|
+
## 라이선스
|
|
100
|
+
|
|
101
|
+
Apache License 2.0
|
|
102
|
+
|
|
103
|
+
원본 Java 라이브러리:
|
|
104
|
+
- [hwp2hwpx](https://github.com/neolord0/hwp2hwpx) by neolord0
|
|
105
|
+
- [hwplib](https://github.com/neolord0/hwplib) by neolord0
|
|
106
|
+
- [hwpxlib](https://github.com/neolord0/hwpxlib) by neolord0
|
hwp2hwpx-1.0.0/README.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# hwp2hwpx
|
|
2
|
+
|
|
3
|
+
HWP(한글 워드프로세서) 파일을 HWPX(OWPML) 형식으로 변환하는 Python 패키지.
|
|
4
|
+
|
|
5
|
+
[neolord0/hwp2hwpx](https://github.com/neolord0/hwp2hwpx) Java 라이브러리를 번들하여
|
|
6
|
+
`pip install` 한 줄로 설치, 바로 사용할 수 있게 만든 래퍼입니다.
|
|
7
|
+
|
|
8
|
+
## 요구사항
|
|
9
|
+
|
|
10
|
+
- Python 3.8+
|
|
11
|
+
- Java Runtime Environment (JRE) 8+
|
|
12
|
+
|
|
13
|
+
## 설치
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pip install hwp2hwpx
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Java가 없으면:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Windows
|
|
23
|
+
winget install EclipseAdoptium.Temurin.21.JDK
|
|
24
|
+
|
|
25
|
+
# macOS
|
|
26
|
+
brew install temurin
|
|
27
|
+
|
|
28
|
+
# Linux (Debian/Ubuntu)
|
|
29
|
+
apt install default-jre
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## 사용법
|
|
33
|
+
|
|
34
|
+
### CLI
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# 단일 파일
|
|
38
|
+
hwp2hwpx document.hwp
|
|
39
|
+
|
|
40
|
+
# 여러 파일
|
|
41
|
+
hwp2hwpx *.hwp
|
|
42
|
+
|
|
43
|
+
# 출력 디렉토리 지정
|
|
44
|
+
hwp2hwpx document.hwp -o output/
|
|
45
|
+
|
|
46
|
+
# 폴더 내 전체 변환 (재귀)
|
|
47
|
+
hwp2hwpx ./documents/ -r
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Python API
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
from hwp2hwpx import convert, convert_batch
|
|
54
|
+
|
|
55
|
+
# 단일 파일
|
|
56
|
+
output_path = convert("document.hwp")
|
|
57
|
+
output_path = convert("document.hwp", "output.hwpx")
|
|
58
|
+
|
|
59
|
+
# 배치
|
|
60
|
+
results = convert_batch(["a.hwp", "b.hwp"], output_dir="output/")
|
|
61
|
+
for input_path, output_path, error in results:
|
|
62
|
+
if error:
|
|
63
|
+
print(f"FAIL: {input_path}: {error}")
|
|
64
|
+
else:
|
|
65
|
+
print(f"OK: {output_path}")
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## 한글 경로 지원
|
|
69
|
+
|
|
70
|
+
Windows에서 한글(Korean) 파일 경로를 자동으로 처리합니다.
|
|
71
|
+
내부적으로 임시 ASCII 경로를 경유하여 JVM 인코딩 문제를 우회합니다.
|
|
72
|
+
|
|
73
|
+
## 라이선스
|
|
74
|
+
|
|
75
|
+
Apache License 2.0
|
|
76
|
+
|
|
77
|
+
원본 Java 라이브러리:
|
|
78
|
+
- [hwp2hwpx](https://github.com/neolord0/hwp2hwpx) by neolord0
|
|
79
|
+
- [hwplib](https://github.com/neolord0/hwplib) by neolord0
|
|
80
|
+
- [hwpxlib](https://github.com/neolord0/hwpxlib) by neolord0
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "hwp2hwpx"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Convert HWP (Hangul Word Processor) files to HWPX format"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "Apache-2.0"
|
|
11
|
+
requires-python = ">=3.8"
|
|
12
|
+
keywords = ["hwp", "hwpx", "hangul", "korean", "document", "converter"]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 4 - Beta",
|
|
15
|
+
"Intended Audience :: Developers",
|
|
16
|
+
"Operating System :: OS Independent",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Programming Language :: Python :: 3.8",
|
|
19
|
+
"Programming Language :: Python :: 3.9",
|
|
20
|
+
"Programming Language :: Python :: 3.10",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Programming Language :: Python :: 3.13",
|
|
24
|
+
"Topic :: Office/Business",
|
|
25
|
+
"Topic :: Software Development :: Libraries",
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
[project.scripts]
|
|
29
|
+
hwp2hwpx = "hwp2hwpx.cli:main"
|
|
30
|
+
|
|
31
|
+
[project.urls]
|
|
32
|
+
Homepage = "https://github.com/neolord0/hwp2hwpx"
|
|
33
|
+
Issues = "https://github.com/neolord0/hwp2hwpx/issues"
|
|
34
|
+
|
|
35
|
+
[tool.setuptools.packages.find]
|
|
36
|
+
where = ["src"]
|
|
37
|
+
|
|
38
|
+
[tool.setuptools.package-data]
|
|
39
|
+
hwp2hwpx = ["jars/*.jar"]
|
hwp2hwpx-1.0.0/setup.cfg
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""HWP to HWPX converter.
|
|
2
|
+
|
|
3
|
+
Python wrapper for neolord0/hwp2hwpx Java library (Apache-2.0).
|
|
4
|
+
Requires Java Runtime Environment (JRE) 8 or later.
|
|
5
|
+
|
|
6
|
+
Usage::
|
|
7
|
+
|
|
8
|
+
from hwp2hwpx import convert
|
|
9
|
+
|
|
10
|
+
output = convert("document.hwp")
|
|
11
|
+
output = convert("document.hwp", "output.hwpx")
|
|
12
|
+
|
|
13
|
+
CLI::
|
|
14
|
+
|
|
15
|
+
hwp2hwpx document.hwp
|
|
16
|
+
hwp2hwpx *.hwp -o output_dir/
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
from __future__ import annotations
|
|
20
|
+
|
|
21
|
+
__version__ = "1.0.0"
|
|
22
|
+
|
|
23
|
+
from .converter import convert, convert_batch, check_java
|
|
24
|
+
|
|
25
|
+
__all__ = ["convert", "convert_batch", "check_java", "__version__"]
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"""CLI entry point: ``hwp2hwpx document.hwp``."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import sys
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
from . import __version__
|
|
10
|
+
from .converter import convert
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _collect_files(raw_paths: list[str]) -> list[Path]:
|
|
14
|
+
"""Expand globs and directories into a flat list of .hwp files."""
|
|
15
|
+
files: list[Path] = []
|
|
16
|
+
for raw in raw_paths:
|
|
17
|
+
p = Path(raw)
|
|
18
|
+
if "*" in raw or "?" in raw:
|
|
19
|
+
# Windows shell doesn't expand globs
|
|
20
|
+
parent = p.parent if str(p.parent) != "." else Path.cwd()
|
|
21
|
+
files.extend(sorted(parent.glob(p.name)))
|
|
22
|
+
elif p.is_dir():
|
|
23
|
+
files.extend(sorted(p.glob("*.hwp")))
|
|
24
|
+
else:
|
|
25
|
+
files.append(p)
|
|
26
|
+
return files
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def main(argv: list[str] | None = None) -> None:
|
|
30
|
+
parser = argparse.ArgumentParser(
|
|
31
|
+
prog="hwp2hwpx",
|
|
32
|
+
description="Convert HWP files to HWPX format.",
|
|
33
|
+
)
|
|
34
|
+
parser.add_argument(
|
|
35
|
+
"input",
|
|
36
|
+
nargs="+",
|
|
37
|
+
help="HWP file(s), glob pattern, or directory",
|
|
38
|
+
)
|
|
39
|
+
parser.add_argument(
|
|
40
|
+
"-o",
|
|
41
|
+
"--output-dir",
|
|
42
|
+
metavar="DIR",
|
|
43
|
+
help="Output directory (default: same as input file)",
|
|
44
|
+
)
|
|
45
|
+
parser.add_argument(
|
|
46
|
+
"-r",
|
|
47
|
+
"--recursive",
|
|
48
|
+
action="store_true",
|
|
49
|
+
help="Recurse into subdirectories (when input is a directory)",
|
|
50
|
+
)
|
|
51
|
+
parser.add_argument(
|
|
52
|
+
"-V",
|
|
53
|
+
"--version",
|
|
54
|
+
action="version",
|
|
55
|
+
version=f"%(prog)s {__version__}",
|
|
56
|
+
)
|
|
57
|
+
args = parser.parse_args(argv)
|
|
58
|
+
|
|
59
|
+
# Collect files
|
|
60
|
+
files: list[Path] = []
|
|
61
|
+
for raw in args.input:
|
|
62
|
+
p = Path(raw)
|
|
63
|
+
if "*" in raw or "?" in raw:
|
|
64
|
+
parent = p.parent if str(p.parent) != "." else Path.cwd()
|
|
65
|
+
files.extend(sorted(parent.glob(p.name)))
|
|
66
|
+
elif p.is_dir():
|
|
67
|
+
pattern = "**/*.hwp" if args.recursive else "*.hwp"
|
|
68
|
+
files.extend(sorted(p.glob(pattern)))
|
|
69
|
+
else:
|
|
70
|
+
files.append(p)
|
|
71
|
+
|
|
72
|
+
if not files:
|
|
73
|
+
print("No HWP files found.", file=sys.stderr)
|
|
74
|
+
sys.exit(1)
|
|
75
|
+
|
|
76
|
+
print(f"hwp2hwpx {__version__}: {len(files)} file(s)")
|
|
77
|
+
|
|
78
|
+
ok = 0
|
|
79
|
+
fail = 0
|
|
80
|
+
for f in files:
|
|
81
|
+
try:
|
|
82
|
+
out_path = None
|
|
83
|
+
if args.output_dir:
|
|
84
|
+
out_path = Path(args.output_dir) / (f.stem + ".hwpx")
|
|
85
|
+
result = convert(f, out_path)
|
|
86
|
+
kb = result.stat().st_size / 1024
|
|
87
|
+
print(f" OK {kb:.1f}KB | {f.name}")
|
|
88
|
+
ok += 1
|
|
89
|
+
except Exception as exc:
|
|
90
|
+
print(f" FAIL | {f.name}: {exc}", file=sys.stderr)
|
|
91
|
+
fail += 1
|
|
92
|
+
|
|
93
|
+
print(f"\nDone: {ok} OK, {fail} failed")
|
|
94
|
+
sys.exit(1 if fail else 0)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
if __name__ == "__main__":
|
|
98
|
+
main()
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"""Core conversion logic — calls bundled JAR via subprocess."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
import platform
|
|
7
|
+
import shutil
|
|
8
|
+
import subprocess
|
|
9
|
+
import tempfile
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
from typing import List, Optional, Union
|
|
12
|
+
|
|
13
|
+
_java_exe: Optional[str] = None # cached after first lookup
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _jar_path() -> Path:
|
|
17
|
+
return Path(__file__).parent / "jars" / "hwp2hwpx.jar"
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _find_java() -> Optional[str]:
|
|
21
|
+
"""Find java executable — PATH, JAVA_HOME, then common install dirs."""
|
|
22
|
+
global _java_exe
|
|
23
|
+
if _java_exe is not None:
|
|
24
|
+
return _java_exe
|
|
25
|
+
|
|
26
|
+
def _works(cmd: str) -> bool:
|
|
27
|
+
try:
|
|
28
|
+
subprocess.run(
|
|
29
|
+
[cmd, "-version"], capture_output=True, timeout=15,
|
|
30
|
+
)
|
|
31
|
+
return True
|
|
32
|
+
except (FileNotFoundError, subprocess.TimeoutExpired, OSError):
|
|
33
|
+
return False
|
|
34
|
+
|
|
35
|
+
# 1) PATH (refresh on Windows — new installs may not be in current session)
|
|
36
|
+
if platform.system() == "Windows":
|
|
37
|
+
import ctypes
|
|
38
|
+
try:
|
|
39
|
+
machine = os.environ.get("Path", "")
|
|
40
|
+
fresh = ctypes.windll.kernel32 # type: ignore[attr-defined]
|
|
41
|
+
# Simpler: read registry-level PATH
|
|
42
|
+
import winreg
|
|
43
|
+
with winreg.OpenKey(
|
|
44
|
+
winreg.HKEY_LOCAL_MACHINE,
|
|
45
|
+
r"SYSTEM\CurrentControlSet\Control\Session Manager\Environment",
|
|
46
|
+
) as key:
|
|
47
|
+
machine, _ = winreg.QueryValueEx(key, "Path")
|
|
48
|
+
with winreg.OpenKey(winreg.HKEY_CURRENT_USER, r"Environment") as key:
|
|
49
|
+
user, _ = winreg.QueryValueEx(key, "Path")
|
|
50
|
+
os.environ["Path"] = machine + ";" + user
|
|
51
|
+
except Exception:
|
|
52
|
+
pass
|
|
53
|
+
|
|
54
|
+
if _works("java"):
|
|
55
|
+
_java_exe = "java"
|
|
56
|
+
return _java_exe
|
|
57
|
+
|
|
58
|
+
# 2) JAVA_HOME
|
|
59
|
+
java_home = os.environ.get("JAVA_HOME")
|
|
60
|
+
if java_home:
|
|
61
|
+
candidate = os.path.join(java_home, "bin", "java")
|
|
62
|
+
if _works(candidate):
|
|
63
|
+
_java_exe = candidate
|
|
64
|
+
return _java_exe
|
|
65
|
+
|
|
66
|
+
# 3) Common Windows install directories
|
|
67
|
+
if platform.system() == "Windows":
|
|
68
|
+
for base in [
|
|
69
|
+
r"C:\Program Files\Eclipse Adoptium",
|
|
70
|
+
r"C:\Program Files\Java",
|
|
71
|
+
r"C:\Program Files\Microsoft",
|
|
72
|
+
r"C:\Program Files\Zulu",
|
|
73
|
+
]:
|
|
74
|
+
if not os.path.isdir(base):
|
|
75
|
+
continue
|
|
76
|
+
for d in sorted(os.listdir(base), reverse=True):
|
|
77
|
+
candidate = os.path.join(base, d, "bin", "java.exe")
|
|
78
|
+
if os.path.isfile(candidate) and _works(candidate):
|
|
79
|
+
_java_exe = candidate
|
|
80
|
+
return _java_exe
|
|
81
|
+
|
|
82
|
+
return None
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def check_java() -> bool:
|
|
86
|
+
"""Check if Java runtime is available.
|
|
87
|
+
|
|
88
|
+
Returns:
|
|
89
|
+
True if a working ``java`` executable is found.
|
|
90
|
+
"""
|
|
91
|
+
return _find_java() is not None
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def _require_java() -> str:
|
|
95
|
+
"""Return java executable path, or raise with install instructions."""
|
|
96
|
+
java = _find_java()
|
|
97
|
+
if java is None:
|
|
98
|
+
raise RuntimeError(
|
|
99
|
+
"Java runtime not found. Install JRE 8+ to use hwp2hwpx.\n"
|
|
100
|
+
" Windows : winget install EclipseAdoptium.Temurin.21.JDK\n"
|
|
101
|
+
" macOS : brew install temurin\n"
|
|
102
|
+
" Linux : apt install default-jre"
|
|
103
|
+
)
|
|
104
|
+
return java
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def convert(
|
|
108
|
+
input_path: Union[str, Path],
|
|
109
|
+
output_path: Optional[Union[str, Path]] = None,
|
|
110
|
+
*,
|
|
111
|
+
timeout: int = 120,
|
|
112
|
+
) -> Path:
|
|
113
|
+
"""Convert a single HWP file to HWPX.
|
|
114
|
+
|
|
115
|
+
Uses temporary files with ASCII-only paths internally so that
|
|
116
|
+
Korean (or other non-ASCII) file paths never reach the JVM,
|
|
117
|
+
avoiding encoding issues on Windows.
|
|
118
|
+
|
|
119
|
+
Args:
|
|
120
|
+
input_path: Path to the ``.hwp`` file.
|
|
121
|
+
output_path: Where to write the ``.hwpx`` file.
|
|
122
|
+
Defaults to the same directory and base name.
|
|
123
|
+
timeout: Subprocess timeout in seconds.
|
|
124
|
+
|
|
125
|
+
Returns:
|
|
126
|
+
Resolved :class:`~pathlib.Path` of the created ``.hwpx`` file.
|
|
127
|
+
|
|
128
|
+
Raises:
|
|
129
|
+
FileNotFoundError: *input_path* does not exist.
|
|
130
|
+
RuntimeError: Java is missing or conversion failed.
|
|
131
|
+
"""
|
|
132
|
+
input_path = Path(input_path).resolve()
|
|
133
|
+
if not input_path.exists():
|
|
134
|
+
raise FileNotFoundError(f"Input file not found: {input_path}")
|
|
135
|
+
|
|
136
|
+
if output_path is None:
|
|
137
|
+
output_path = input_path.with_suffix(".hwpx")
|
|
138
|
+
output_path = Path(output_path).resolve()
|
|
139
|
+
|
|
140
|
+
java = _require_java()
|
|
141
|
+
jar = _jar_path()
|
|
142
|
+
|
|
143
|
+
# Temp dir with ASCII-only paths (Korean path workaround)
|
|
144
|
+
tmp_dir = Path(tempfile.mkdtemp(prefix="hwp2hwpx_"))
|
|
145
|
+
tmp_in = tmp_dir / "input.hwp"
|
|
146
|
+
tmp_out = tmp_dir / "output.hwpx"
|
|
147
|
+
|
|
148
|
+
try:
|
|
149
|
+
shutil.copy2(input_path, tmp_in)
|
|
150
|
+
|
|
151
|
+
result = subprocess.run(
|
|
152
|
+
[
|
|
153
|
+
java,
|
|
154
|
+
"-Dfile.encoding=UTF-8",
|
|
155
|
+
"-jar",
|
|
156
|
+
str(jar),
|
|
157
|
+
str(tmp_in),
|
|
158
|
+
str(tmp_out),
|
|
159
|
+
],
|
|
160
|
+
capture_output=True,
|
|
161
|
+
text=True,
|
|
162
|
+
timeout=timeout,
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
if not tmp_out.exists():
|
|
166
|
+
detail = (result.stderr or result.stdout or "no output").strip()
|
|
167
|
+
raise RuntimeError(f"Conversion failed: {detail}")
|
|
168
|
+
|
|
169
|
+
output_path.parent.mkdir(parents=True, exist_ok=True)
|
|
170
|
+
shutil.move(str(tmp_out), str(output_path))
|
|
171
|
+
return output_path
|
|
172
|
+
|
|
173
|
+
finally:
|
|
174
|
+
shutil.rmtree(tmp_dir, ignore_errors=True)
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def convert_batch(
|
|
178
|
+
paths: List[Union[str, Path]],
|
|
179
|
+
output_dir: Optional[Union[str, Path]] = None,
|
|
180
|
+
*,
|
|
181
|
+
timeout: int = 120,
|
|
182
|
+
) -> list[tuple[Path, Optional[Path], Optional[str]]]:
|
|
183
|
+
"""Convert multiple HWP files.
|
|
184
|
+
|
|
185
|
+
Args:
|
|
186
|
+
paths: HWP file paths.
|
|
187
|
+
output_dir: Common output directory. ``None`` = same as each input.
|
|
188
|
+
timeout: Per-file subprocess timeout.
|
|
189
|
+
|
|
190
|
+
Returns:
|
|
191
|
+
List of ``(input, output_or_None, error_or_None)`` tuples.
|
|
192
|
+
"""
|
|
193
|
+
_require_java() # fail-fast before processing any files
|
|
194
|
+
|
|
195
|
+
results: list[tuple[Path, Optional[Path], Optional[str]]] = []
|
|
196
|
+
for p in paths:
|
|
197
|
+
p = Path(p)
|
|
198
|
+
out = Path(output_dir) / (p.stem + ".hwpx") if output_dir else None
|
|
199
|
+
try:
|
|
200
|
+
created = convert(p, out, timeout=timeout)
|
|
201
|
+
results.append((p, created, None))
|
|
202
|
+
except Exception as exc:
|
|
203
|
+
results.append((p, None, str(exc)))
|
|
204
|
+
return results
|
|
Binary file
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hwp2hwpx
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Convert HWP (Hangul Word Processor) files to HWPX format
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
Project-URL: Homepage, https://github.com/neolord0/hwp2hwpx
|
|
7
|
+
Project-URL: Issues, https://github.com/neolord0/hwp2hwpx/issues
|
|
8
|
+
Keywords: hwp,hwpx,hangul,korean,document,converter
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Topic :: Office/Business
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
21
|
+
Requires-Python: >=3.8
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
License-File: NOTICE
|
|
25
|
+
Dynamic: license-file
|
|
26
|
+
|
|
27
|
+
# hwp2hwpx
|
|
28
|
+
|
|
29
|
+
HWP(한글 워드프로세서) 파일을 HWPX(OWPML) 형식으로 변환하는 Python 패키지.
|
|
30
|
+
|
|
31
|
+
[neolord0/hwp2hwpx](https://github.com/neolord0/hwp2hwpx) Java 라이브러리를 번들하여
|
|
32
|
+
`pip install` 한 줄로 설치, 바로 사용할 수 있게 만든 래퍼입니다.
|
|
33
|
+
|
|
34
|
+
## 요구사항
|
|
35
|
+
|
|
36
|
+
- Python 3.8+
|
|
37
|
+
- Java Runtime Environment (JRE) 8+
|
|
38
|
+
|
|
39
|
+
## 설치
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install hwp2hwpx
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Java가 없으면:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# Windows
|
|
49
|
+
winget install EclipseAdoptium.Temurin.21.JDK
|
|
50
|
+
|
|
51
|
+
# macOS
|
|
52
|
+
brew install temurin
|
|
53
|
+
|
|
54
|
+
# Linux (Debian/Ubuntu)
|
|
55
|
+
apt install default-jre
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## 사용법
|
|
59
|
+
|
|
60
|
+
### CLI
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
# 단일 파일
|
|
64
|
+
hwp2hwpx document.hwp
|
|
65
|
+
|
|
66
|
+
# 여러 파일
|
|
67
|
+
hwp2hwpx *.hwp
|
|
68
|
+
|
|
69
|
+
# 출력 디렉토리 지정
|
|
70
|
+
hwp2hwpx document.hwp -o output/
|
|
71
|
+
|
|
72
|
+
# 폴더 내 전체 변환 (재귀)
|
|
73
|
+
hwp2hwpx ./documents/ -r
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Python API
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from hwp2hwpx import convert, convert_batch
|
|
80
|
+
|
|
81
|
+
# 단일 파일
|
|
82
|
+
output_path = convert("document.hwp")
|
|
83
|
+
output_path = convert("document.hwp", "output.hwpx")
|
|
84
|
+
|
|
85
|
+
# 배치
|
|
86
|
+
results = convert_batch(["a.hwp", "b.hwp"], output_dir="output/")
|
|
87
|
+
for input_path, output_path, error in results:
|
|
88
|
+
if error:
|
|
89
|
+
print(f"FAIL: {input_path}: {error}")
|
|
90
|
+
else:
|
|
91
|
+
print(f"OK: {output_path}")
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## 한글 경로 지원
|
|
95
|
+
|
|
96
|
+
Windows에서 한글(Korean) 파일 경로를 자동으로 처리합니다.
|
|
97
|
+
내부적으로 임시 ASCII 경로를 경유하여 JVM 인코딩 문제를 우회합니다.
|
|
98
|
+
|
|
99
|
+
## 라이선스
|
|
100
|
+
|
|
101
|
+
Apache License 2.0
|
|
102
|
+
|
|
103
|
+
원본 Java 라이브러리:
|
|
104
|
+
- [hwp2hwpx](https://github.com/neolord0/hwp2hwpx) by neolord0
|
|
105
|
+
- [hwplib](https://github.com/neolord0/hwplib) by neolord0
|
|
106
|
+
- [hwpxlib](https://github.com/neolord0/hwpxlib) by neolord0
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
NOTICE
|
|
3
|
+
README.md
|
|
4
|
+
pyproject.toml
|
|
5
|
+
src/hwp2hwpx/__init__.py
|
|
6
|
+
src/hwp2hwpx/cli.py
|
|
7
|
+
src/hwp2hwpx/converter.py
|
|
8
|
+
src/hwp2hwpx.egg-info/PKG-INFO
|
|
9
|
+
src/hwp2hwpx.egg-info/SOURCES.txt
|
|
10
|
+
src/hwp2hwpx.egg-info/dependency_links.txt
|
|
11
|
+
src/hwp2hwpx.egg-info/entry_points.txt
|
|
12
|
+
src/hwp2hwpx.egg-info/top_level.txt
|
|
13
|
+
src/hwp2hwpx/jars/hwp2hwpx.jar
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
hwp2hwpx
|