pyOpenVBA 2.0.0__tar.gz → 2.0.1__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.
Files changed (22) hide show
  1. {pyopenvba-2.0.0 → pyopenvba-2.0.1}/PKG-INFO +9 -18
  2. {pyopenvba-2.0.0 → pyopenvba-2.0.1}/README.md +8 -17
  3. {pyopenvba-2.0.0 → pyopenvba-2.0.1}/pyproject.toml +1 -1
  4. {pyopenvba-2.0.0 → pyopenvba-2.0.1}/src/pyopenvba/__init__.py +1 -1
  5. {pyopenvba-2.0.0 → pyopenvba-2.0.1}/src/pyopenvba/vba.py +32 -3
  6. {pyopenvba-2.0.0 → pyopenvba-2.0.1}/.gitignore +0 -0
  7. {pyopenvba-2.0.0 → pyopenvba-2.0.1}/LICENSE.md +0 -0
  8. {pyopenvba-2.0.0 → pyopenvba-2.0.1}/docs/architecture.md +0 -0
  9. {pyopenvba-2.0.0 → pyopenvba-2.0.1}/docs/ms-ovba-implementation-guide_v2.md +0 -0
  10. {pyopenvba-2.0.0 → pyopenvba-2.0.1}/docs/roadmap.md +0 -0
  11. {pyopenvba-2.0.0 → pyopenvba-2.0.1}/src/pyopenvba/__main__.py +0 -0
  12. {pyopenvba-2.0.0 → pyopenvba-2.0.1}/src/pyopenvba/_templates/__init__.py +0 -0
  13. {pyopenvba-2.0.0 → pyopenvba-2.0.1}/src/pyopenvba/_templates/blank_files/blank_document.docm +0 -0
  14. {pyopenvba-2.0.0 → pyopenvba-2.0.1}/src/pyopenvba/_templates/blank_files/blank_presentation.pptm +0 -0
  15. {pyopenvba-2.0.0 → pyopenvba-2.0.1}/src/pyopenvba/_templates/blank_files/blank_workbook.xlsb +0 -0
  16. {pyopenvba-2.0.0 → pyopenvba-2.0.1}/src/pyopenvba/_templates/blank_files/blank_workbook.xlsm +0 -0
  17. {pyopenvba-2.0.0 → pyopenvba-2.0.1}/src/pyopenvba/cfb.py +0 -0
  18. {pyopenvba-2.0.0 → pyopenvba-2.0.1}/src/pyopenvba/excel.py +0 -0
  19. {pyopenvba-2.0.0 → pyopenvba-2.0.1}/src/pyopenvba/exceptions.py +0 -0
  20. {pyopenvba-2.0.0 → pyopenvba-2.0.1}/src/pyopenvba/powerpoint.py +0 -0
  21. {pyopenvba-2.0.0 → pyopenvba-2.0.1}/src/pyopenvba/word.py +0 -0
  22. {pyopenvba-2.0.0 → pyopenvba-2.0.1}/tests/fuzz_corpus/README.md +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyOpenVBA
3
- Version: 2.0.0
3
+ Version: 2.0.1
4
4
  Summary: Read and write VBA macros inside Excel, Word, and PowerPoint files in pure Python, no dependencies.
5
5
  Project-URL: Homepage, https://github.com/WilliamSmithEdward/pyOpenVBA
6
6
  Project-URL: Repository, https://github.com/WilliamSmithEdward/pyOpenVBA
@@ -39,7 +39,7 @@ Description-Content-Type: text/markdown
39
39
  [![PyPI version](https://img.shields.io/pypi/v/pyOpenVBA.svg)](https://pypi.org/project/pyOpenVBA/)
40
40
  [![Python versions](https://img.shields.io/pypi/pyversions/pyOpenVBA.svg)](https://pypi.org/project/pyOpenVBA/)
41
41
  [![CI](https://github.com/WilliamSmithEdward/pyOpenVBA/actions/workflows/ci.yml/badge.svg)](https://github.com/WilliamSmithEdward/pyOpenVBA/actions/workflows/ci.yml)
42
- [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE.md)
42
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/WilliamSmithEdward/pyOpenVBA/blob/main/LICENSE.md)
43
43
  [![Downloads](https://img.shields.io/pypi/dm/pyOpenVBA.svg)](https://pypi.org/project/pyOpenVBA/)
44
44
 
45
45
  **Read and write VBA macros inside Excel, Word, and PowerPoint files, in pure Python.**
@@ -226,18 +226,9 @@ with ExcelFile("workbook.xlsm") as wb:
226
226
  kind=VBAModuleKind.standard,
227
227
  )
228
228
 
229
- # Add a class module (VB_Base attribute is required)
230
- _CLASS_VB_BASE = "0{FCFB3D2A-A0FA-1068-A738-08002B3371B5}"
229
+ # Add a class module (header is synthesized automatically)
231
230
  project.add_module(
232
231
  "MyClass",
233
- f'Attribute VB_Name = "MyClass"\r\n'
234
- f'Attribute VB_Base = "{_CLASS_VB_BASE}"\r\n'
235
- "Attribute VB_GlobalNameSpace = False\r\n"
236
- "Attribute VB_Creatable = False\r\n"
237
- "Attribute VB_PredeclaredId = False\r\n"
238
- "Attribute VB_Exposed = False\r\n"
239
- "Attribute VB_TemplateDerived = False\r\n"
240
- "Attribute VB_Customizable = False\r\n"
241
232
  "Option Explicit\r\n",
242
233
  kind=VBAModuleKind.other,
243
234
  )
@@ -385,7 +376,7 @@ following are preserved byte-for-byte but not interpreted:
385
376
  - Re-signing digitally signed projects.
386
377
  - ActiveX license editing.
387
378
 
388
- See [docs/roadmap.md](docs/roadmap.md) for the full feature matrix.
379
+ See [docs/roadmap.md](https://github.com/WilliamSmithEdward/pyOpenVBA/blob/main/docs/roadmap.md) for the full feature matrix.
389
380
 
390
381
  ---
391
382
 
@@ -395,7 +386,7 @@ See [docs/roadmap.md](docs/roadmap.md) for the full feature matrix.
395
386
  src/pyopenvba/
396
387
  __init__.py public API (ExcelFile, WordFile, PowerPointFile,
397
388
  pull/push, pull_word/push_word, pull_ppt/push_ppt,
398
- VBAModuleKind, exceptions)
389
+ VBAModuleKind, synthesize_class_header, exceptions)
399
390
  excel.py ExcelFile facade (ZIP / CFB dispatch, pull/push helpers)
400
391
  word.py WordFile facade
401
392
  powerpoint.py PowerPointFile facade
@@ -408,10 +399,10 @@ src/pyopenvba/
408
399
 
409
400
  For deeper documentation:
410
401
 
411
- - [docs/architecture.md](docs/architecture.md) - internal module layout.
412
- - [docs/ms-ovba-implementation-guide_v2.md](docs/ms-ovba-implementation-guide_v2.md) -
402
+ - [docs/architecture.md](https://github.com/WilliamSmithEdward/pyOpenVBA/blob/main/docs/architecture.md) - internal module layout.
403
+ - [docs/ms-ovba-implementation-guide_v2.md](https://github.com/WilliamSmithEdward/pyOpenVBA/blob/main/docs/ms-ovba-implementation-guide_v2.md) -
413
404
  language-agnostic guide for re-implementing MS-OVBA in another language.
414
- - [docs/roadmap.md](docs/roadmap.md) - per-feature implementation status.
405
+ - [docs/roadmap.md](https://github.com/WilliamSmithEdward/pyOpenVBA/blob/main/docs/roadmap.md) - per-feature implementation status.
415
406
 
416
407
  ---
417
408
 
@@ -438,4 +429,4 @@ pushed.
438
429
 
439
430
  ## License
440
431
 
441
- [MIT](LICENSE.md).
432
+ [MIT](https://github.com/WilliamSmithEdward/pyOpenVBA/blob/main/LICENSE.md).
@@ -3,7 +3,7 @@
3
3
  [![PyPI version](https://img.shields.io/pypi/v/pyOpenVBA.svg)](https://pypi.org/project/pyOpenVBA/)
4
4
  [![Python versions](https://img.shields.io/pypi/pyversions/pyOpenVBA.svg)](https://pypi.org/project/pyOpenVBA/)
5
5
  [![CI](https://github.com/WilliamSmithEdward/pyOpenVBA/actions/workflows/ci.yml/badge.svg)](https://github.com/WilliamSmithEdward/pyOpenVBA/actions/workflows/ci.yml)
6
- [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE.md)
6
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/WilliamSmithEdward/pyOpenVBA/blob/main/LICENSE.md)
7
7
  [![Downloads](https://img.shields.io/pypi/dm/pyOpenVBA.svg)](https://pypi.org/project/pyOpenVBA/)
8
8
 
9
9
  **Read and write VBA macros inside Excel, Word, and PowerPoint files, in pure Python.**
@@ -190,18 +190,9 @@ with ExcelFile("workbook.xlsm") as wb:
190
190
  kind=VBAModuleKind.standard,
191
191
  )
192
192
 
193
- # Add a class module (VB_Base attribute is required)
194
- _CLASS_VB_BASE = "0{FCFB3D2A-A0FA-1068-A738-08002B3371B5}"
193
+ # Add a class module (header is synthesized automatically)
195
194
  project.add_module(
196
195
  "MyClass",
197
- f'Attribute VB_Name = "MyClass"\r\n'
198
- f'Attribute VB_Base = "{_CLASS_VB_BASE}"\r\n'
199
- "Attribute VB_GlobalNameSpace = False\r\n"
200
- "Attribute VB_Creatable = False\r\n"
201
- "Attribute VB_PredeclaredId = False\r\n"
202
- "Attribute VB_Exposed = False\r\n"
203
- "Attribute VB_TemplateDerived = False\r\n"
204
- "Attribute VB_Customizable = False\r\n"
205
196
  "Option Explicit\r\n",
206
197
  kind=VBAModuleKind.other,
207
198
  )
@@ -349,7 +340,7 @@ following are preserved byte-for-byte but not interpreted:
349
340
  - Re-signing digitally signed projects.
350
341
  - ActiveX license editing.
351
342
 
352
- See [docs/roadmap.md](docs/roadmap.md) for the full feature matrix.
343
+ See [docs/roadmap.md](https://github.com/WilliamSmithEdward/pyOpenVBA/blob/main/docs/roadmap.md) for the full feature matrix.
353
344
 
354
345
  ---
355
346
 
@@ -359,7 +350,7 @@ See [docs/roadmap.md](docs/roadmap.md) for the full feature matrix.
359
350
  src/pyopenvba/
360
351
  __init__.py public API (ExcelFile, WordFile, PowerPointFile,
361
352
  pull/push, pull_word/push_word, pull_ppt/push_ppt,
362
- VBAModuleKind, exceptions)
353
+ VBAModuleKind, synthesize_class_header, exceptions)
363
354
  excel.py ExcelFile facade (ZIP / CFB dispatch, pull/push helpers)
364
355
  word.py WordFile facade
365
356
  powerpoint.py PowerPointFile facade
@@ -372,10 +363,10 @@ src/pyopenvba/
372
363
 
373
364
  For deeper documentation:
374
365
 
375
- - [docs/architecture.md](docs/architecture.md) - internal module layout.
376
- - [docs/ms-ovba-implementation-guide_v2.md](docs/ms-ovba-implementation-guide_v2.md) -
366
+ - [docs/architecture.md](https://github.com/WilliamSmithEdward/pyOpenVBA/blob/main/docs/architecture.md) - internal module layout.
367
+ - [docs/ms-ovba-implementation-guide_v2.md](https://github.com/WilliamSmithEdward/pyOpenVBA/blob/main/docs/ms-ovba-implementation-guide_v2.md) -
377
368
  language-agnostic guide for re-implementing MS-OVBA in another language.
378
- - [docs/roadmap.md](docs/roadmap.md) - per-feature implementation status.
369
+ - [docs/roadmap.md](https://github.com/WilliamSmithEdward/pyOpenVBA/blob/main/docs/roadmap.md) - per-feature implementation status.
379
370
 
380
371
  ---
381
372
 
@@ -402,4 +393,4 @@ pushed.
402
393
 
403
394
  ## License
404
395
 
405
- [MIT](LICENSE.md).
396
+ [MIT](https://github.com/WilliamSmithEdward/pyOpenVBA/blob/main/LICENSE.md).
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "pyOpenVBA"
7
- version = "2.0.0"
7
+ version = "2.0.1"
8
8
  description = "Read and write VBA macros inside Excel, Word, and PowerPoint files in pure Python, no dependencies."
9
9
  readme = "README.md"
10
10
  license = { text = "MIT" }
@@ -58,7 +58,7 @@ from pyopenvba.exceptions import (
58
58
  VBAProjectError,
59
59
  UnsupportedFormatError,
60
60
  )
61
- from pyopenvba.vba import VBAModuleKind
61
+ from pyopenvba.vba import VBAModuleKind, synthesize_class_header
62
62
 
63
63
 
64
64
  def pull(
@@ -755,12 +755,14 @@ class VBAProject:
755
755
  elif kind == VBAModuleKind.standard:
756
756
  header = synthesize_standard_header(name)
757
757
  full_source = header + source
758
+ elif kind == VBAModuleKind.other:
759
+ header = synthesize_class_header(name)
760
+ full_source = header + source
758
761
  else:
759
762
  raise ValueError(
760
763
  f"add_module(kind={kind.name}) requires the source to start "
761
- "with its own attribute header (e.g. 'VERSION 1.0 CLASS' "
762
- "for a class module). pyOpenVBA does not invent class or "
763
- "document module headers."
764
+ "with its own attribute header. pyOpenVBA does not invent "
765
+ "document or designer module headers."
764
766
  )
765
767
 
766
768
  module = VBAModule(
@@ -981,6 +983,33 @@ def synthesize_standard_header(name: str) -> str:
981
983
  return f'Attribute VB_Name = "{name}"\r\n'
982
984
 
983
985
 
986
+ # Universal CLSID for plain VBA class modules (not document/designer modules).
987
+ _CLASS_MODULE_CLSID = "0{FCFB3D2A-A0FA-1068-A738-08002B3371B5}"
988
+
989
+
990
+ def synthesize_class_header(name: str) -> str:
991
+ """Return the standard attribute header for a new plain class module.
992
+
993
+ Uses the universal VBA class CLSID as ``VB_Base`` and the conventional
994
+ default values for all other class attributes. This header is equivalent
995
+ to what VBE emits when you insert a new Class Module.
996
+
997
+ Only suitable for plain class modules. Document modules (ThisWorkbook,
998
+ Sheet1, ThisDocument, etc.) and designer modules (UserForms) carry host-
999
+ specific CLSIDs and must be provided with an explicit attribute header.
1000
+ """
1001
+ return (
1002
+ f'Attribute VB_Name = "{name}"\r\n'
1003
+ f'Attribute VB_Base = "{_CLASS_MODULE_CLSID}"\r\n'
1004
+ 'Attribute VB_GlobalNameSpace = False\r\n'
1005
+ 'Attribute VB_Creatable = False\r\n'
1006
+ 'Attribute VB_PredeclaredId = False\r\n'
1007
+ 'Attribute VB_Exposed = False\r\n'
1008
+ 'Attribute VB_TemplateDerived = False\r\n'
1009
+ 'Attribute VB_Customizable = False\r\n'
1010
+ )
1011
+
1012
+
984
1013
  def rebuild_module_stream(module: VBAModule, code_page: int) -> bytes:
985
1014
  """
986
1015
  Rebuild a module stream by preserving the original ``[0:text_offset]``
File without changes
File without changes
File without changes