Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
335 commits
Select commit Hold shift + click to select a range
2b90e2c
Update test_doc_module.py
Beakerboy Nov 13, 2024
5bd21b0
Update test_fullFile.py
Beakerboy Nov 13, 2024
b2d314d
Update test_doc_module.py
Beakerboy Nov 13, 2024
e12caab
Update test_fullFile.py
Beakerboy Nov 13, 2024
cfdfb44
Update test_fullFile.py
Beakerboy Nov 13, 2024
c6c2b9a
Update test_doc_module.py
Beakerboy Nov 13, 2024
c7229ef
Update test_dirObject.py
Beakerboy Nov 13, 2024
09e13b3
Update test_dirObject.py
Beakerboy Nov 13, 2024
410ecf8
Update test_doc_module.py
Beakerboy Nov 13, 2024
8e6efc6
Update test_doc_module.py
Beakerboy Nov 13, 2024
1ce84f4
Update test_doc_module.py
Beakerboy Nov 13, 2024
759b38f
Update test_dirObject.py
Beakerboy Nov 13, 2024
eec83cc
Update test_dirObject.py
Beakerboy Nov 13, 2024
e3aadf4
Update test_dirObject.py
Beakerboy Nov 13, 2024
6b2d1a8
Update test_fullFile.py
Beakerboy Nov 13, 2024
f099a77
Update test_doc_module.py
Beakerboy Nov 13, 2024
b4a6644
Update test_dirObject.py
Beakerboy Nov 13, 2024
3f08c7f
Update test_fullFile.py
Beakerboy Nov 13, 2024
76dec0c
Update test_dirObject.py
Beakerboy Nov 13, 2024
e395a64
Update test_doc_module.py
Beakerboy Nov 13, 2024
e022c75
Update README.md
Beakerboy Nov 13, 2024
d823a8a
Update project_ole_file.py
Beakerboy Nov 13, 2024
4b12d05
Update test_fullFile.py
Beakerboy Nov 13, 2024
fcc2857
Update test_fullFile.py
Beakerboy Nov 13, 2024
f4d8f43
Update test_fullFile.py
Beakerboy Nov 13, 2024
1714734
Update test_fullFile.py
Beakerboy Nov 13, 2024
6b2f2aa
Update test_fullFile.py
Beakerboy Nov 13, 2024
d7a4b39
Update test_fullFile.py
Beakerboy Nov 13, 2024
d02bb8e
Update test_fullFile.py
Beakerboy Nov 13, 2024
8aff196
Update test_fullFile.py
Beakerboy Nov 13, 2024
7035c33
Update test_fullFile.py
Beakerboy Nov 13, 2024
839b098
Update test_fullFile.py
Beakerboy Nov 13, 2024
9980f20
Update test_fullFile.py
Beakerboy Nov 13, 2024
12f6645
Update test_fullFile.py
Beakerboy Nov 13, 2024
33ae79e
Update vbaProject.py
Beakerboy Nov 13, 2024
100ca86
Update vbaProject.py
Beakerboy Nov 13, 2024
b068695
Update vbaProject.py
Beakerboy Nov 13, 2024
f1b49d7
Update vbaProject.py
Beakerboy Nov 13, 2024
df92994
Update project_ole_file.py
Beakerboy Nov 13, 2024
abd395c
Update project_ole_file.py
Beakerboy Nov 13, 2024
141a3a4
Update test_fullFile.py
Beakerboy Nov 13, 2024
529f4fc
Update test_fullFile.py
Beakerboy Nov 13, 2024
fdec471
Update project_ole_file.py
Beakerboy Nov 13, 2024
f2c0918
Update test_fullFile.py
Beakerboy Nov 13, 2024
19da506
Update test_fullFile.py
Beakerboy Nov 15, 2024
84df1a2
Update test_fullFile.py
Beakerboy Nov 15, 2024
9bdcfb9
Update test_fullFile.py
Beakerboy Nov 15, 2024
7392cbf
Update test_doc_module.py
Beakerboy Nov 15, 2024
2c99ead
Update test_dirObject.py
Beakerboy Nov 16, 2024
d495750
Update test_fullFile.py
Beakerboy Nov 16, 2024
81877bf
Update test_fullFile.py
Beakerboy Nov 16, 2024
c87e433
Update test_fullFile.py
Beakerboy Nov 16, 2024
484632e
Update test_fullFile.py
Beakerboy Nov 16, 2024
ee03e7d
changed dir name
Beakerboy Nov 24, 2024
9889839
Fix typo in README about CLI functionality
Beakerboy Dec 31, 2025
cae4d1c
Fix typo in README regarding CLI functionality
Beakerboy Dec 31, 2025
3596ac6
Update test_vba_project.py
Beakerboy Dec 31, 2025
010242f
Refactor import statements in module_base.py
Beakerboy Dec 31, 2025
a3d6b5a
Update import paths for module_base and reference_record
Beakerboy Dec 31, 2025
c4e3645
Refactor imports to use ms_ovba module
Beakerboy Dec 31, 2025
e9511e9
Fix import path for ModuleBase in doc_module.py
Beakerboy Dec 31, 2025
5f20515
Update import paths for reference_record.py
Beakerboy Dec 31, 2025
ad24b35
Fix import path for IdSizeField in doubleEncodedString.py
Beakerboy Dec 31, 2025
84f6f54
Update import path for ModuleBase
Beakerboy Dec 31, 2025
d00dbfd
Update dirStream.py
Beakerboy Dec 31, 2025
5aabbb3
Update project.py
Beakerboy Dec 31, 2025
6e616e9
Update projectWm.py
Beakerboy Dec 31, 2025
3e0fab7
Refactor import statements for vbaProject module
Beakerboy Dec 31, 2025
4a2fd6f
Update import path for VbaProject
Beakerboy Dec 31, 2025
60ee682
Refactor imports to use ms_ovba module
Beakerboy Dec 31, 2025
39a5592
Refactor import statements for ms_ovba module
Beakerboy Dec 31, 2025
5c1fc73
Update test_doc_module.py
Beakerboy Dec 31, 2025
e67f3b2
Update test_std_module.py
Beakerboy Dec 31, 2025
6494a1d
Update import path for IdSizeField
Beakerboy Dec 31, 2025
771147b
Update import path for LibidReference
Beakerboy Dec 31, 2025
53fe2f9
Change import path for VbaProject
Beakerboy Dec 31, 2025
eaef4c7
Update import paths for project modules
Beakerboy Dec 31, 2025
1e019c4
Update import statements for projectWm test
Beakerboy Dec 31, 2025
d4a70db
Update test_fullFile.py
Beakerboy Dec 31, 2025
e19f092
Update file path in test_doc_module.py
Beakerboy Dec 31, 2025
6eab382
Update README.md
Beakerboy Dec 31, 2025
cf7ef27
Update README.md
Beakerboy Dec 31, 2025
f47f7a8
Update python-package.yml
Beakerboy Dec 31, 2025
82fa59c
Fix pip install command for MS-Pcode-Assembler
Beakerboy Feb 26, 2026
20e0a9c
Create project_reference.py
Beakerboy Feb 26, 2026
5e929e3
Update project_reference.py
Beakerboy Feb 26, 2026
cc8dad1
Add reference_registered.py file
Beakerboy Feb 26, 2026
a656356
Update vbaProject.py
Beakerboy Feb 26, 2026
dcac878
Update project_reference.py
Beakerboy Feb 26, 2026
79e5328
Update project_reference.py
Beakerboy Feb 26, 2026
fb603c1
Add return type annotation to __len__ method
Beakerboy Feb 26, 2026
6de90a4
Create reference_project.py
Beakerboy Feb 26, 2026
1e0b27c
Fix syntax error in pack method for reference_project
Beakerboy Feb 27, 2026
e2f29e5
Fix constructor parameter default value for embedded
Beakerboy Feb 27, 2026
76107d0
Add docstring to LibidReference class
Beakerboy Feb 27, 2026
52a427f
Update python-package.yml
Beakerboy Feb 27, 2026
e9e8867
Fix formatting issues in project_reference.py
Beakerboy Feb 27, 2026
115b952
Fix formatting in LibidReference class definition
Beakerboy Feb 27, 2026
9d898bf
Update project_reference.py
Beakerboy Feb 27, 2026
86b27db
Update reference_project.py
Beakerboy Feb 27, 2026
b7e3f31
Update reference_project.py
Beakerboy Feb 27, 2026
b6de017
Update reference_registered.py
Beakerboy Feb 27, 2026
01418ab
Update reference_project.py
Beakerboy Feb 27, 2026
5469b92
Create reference.py
Beakerboy Feb 27, 2026
978a398
Update reference.py
Beakerboy Feb 27, 2026
b389f99
Update reference_project.py
Beakerboy Feb 27, 2026
d2d4058
Update reference_registered.py
Beakerboy Feb 27, 2026
3c7cc3c
Create reference_type
Beakerboy Feb 27, 2026
3d1fe1a
Update reference.py
Beakerboy Feb 27, 2026
91e2068
Update reference.py
Beakerboy Feb 27, 2026
5269919
Rename reference_type to reference_type.py
Beakerboy Feb 27, 2026
c3383fd
Update reference_type.py
Beakerboy Feb 27, 2026
8201893
Update reference_type.py
Beakerboy Feb 27, 2026
2ab355c
Update doubleEncodedString.py
Beakerboy Feb 27, 2026
43fe040
Update reference.py
Beakerboy Feb 27, 2026
948eaa3
Update reference class to use refname instead of name
Beakerboy Feb 27, 2026
a63d1f6
Update reference_registered.py
Beakerboy Feb 27, 2026
59d5111
Update reference.py
Beakerboy Feb 27, 2026
a2374e4
Update reference_registered.py
Beakerboy Feb 27, 2026
0d5209a
Update test_fullFile.py
Beakerboy Feb 27, 2026
0841d7c
Update test_fullFile.py
Beakerboy Feb 27, 2026
dc675b1
Update test_dirObject.py
Beakerboy Feb 27, 2026
8d2d5ed
Update test_fullFile.py
Beakerboy Feb 27, 2026
4d7fcc4
Update test_dirObject.py
Beakerboy Feb 27, 2026
4c9e8dc
Update test_dirObject.py
Beakerboy Feb 27, 2026
f6cfec9
Update reference_registered.py
Beakerboy Feb 27, 2026
4c04841
Update reference_registered.py
Beakerboy Feb 27, 2026
7da2347
Update reference_registered.py
Beakerboy Feb 27, 2026
431bb7f
Update reference_registered.py
Beakerboy Feb 27, 2026
8119630
Update reference_registered.py
Beakerboy Feb 27, 2026
5a24efb
Update reference_registered.py
Beakerboy Feb 27, 2026
af71926
Update reference_registered.py
Beakerboy Feb 27, 2026
2e0e773
Update reference_registered.py
Beakerboy Feb 27, 2026
e7d1a3f
Update README.md
Beakerboy Feb 27, 2026
444c787
Update README.md
Beakerboy Feb 27, 2026
05819fc
Create test_reference_project.py
Beakerboy Feb 27, 2026
06509df
Update reference_registered.py
Beakerboy Feb 27, 2026
7883a20
Update test_reference_project.py
Beakerboy Feb 27, 2026
1fc029b
Update project_reference.py
Beakerboy Feb 27, 2026
772fae5
Create test_project_reference.py
Beakerboy Feb 27, 2026
8382e75
Update test_reference_project.py
Beakerboy Feb 27, 2026
65b6d7a
Update project_reference.py
Beakerboy Feb 27, 2026
b170ab0
Update project_reference.py
Beakerboy Feb 27, 2026
982e64e
Update project_reference.py
Beakerboy Feb 27, 2026
f669b72
Update project_reference.py
Beakerboy Feb 27, 2026
9dfc4b6
Update project_reference.py
Beakerboy Feb 27, 2026
af43a4a
Update test_project_reference.py
Beakerboy Feb 27, 2026
03ebaa7
Update test_project_reference.py
Beakerboy Feb 27, 2026
f102eb8
Update test_project_reference.py
Beakerboy Feb 27, 2026
7d458d6
Update test_project_reference.py
Beakerboy Feb 27, 2026
5e0b76b
Update test_project_reference.py
Beakerboy Feb 27, 2026
0abf185
Update project_reference.py
Beakerboy Feb 27, 2026
4c78366
Update test_reference_project.py
Beakerboy Feb 27, 2026
4aa664c
Update reference_project.py
Beakerboy Feb 27, 2026
148d4c7
Update test_reference_project.py
Beakerboy Feb 27, 2026
1cb7197
Update test_reference_project.py
Beakerboy Feb 27, 2026
56d30fb
Update test_reference_project.py
Beakerboy Feb 27, 2026
fda3d2b
Update test_reference_project.py
Beakerboy Feb 27, 2026
c7fa8cf
Update test_reference_project.py
Beakerboy Feb 27, 2026
d107251
Update reference_project.py
Beakerboy Feb 27, 2026
7aacc9d
Create test_reference_registered.py
Beakerboy Feb 27, 2026
7a0827f
Update test_reference_registered.py
Beakerboy Feb 27, 2026
144607c
Update test_reference_registered.py
Beakerboy Feb 27, 2026
9c939da
Update test_reference_registered.py
Beakerboy Feb 27, 2026
31e6ff1
Update test_reference_registered.py
Beakerboy Feb 27, 2026
d6c649f
Update test_reference_registered.py
Beakerboy Feb 27, 2026
c05294f
Update test_reference_registered.py
Beakerboy Feb 27, 2026
9f49cad
Update test_reference_registered.py
Beakerboy Feb 27, 2026
dcc7995
Create test_reference.py
Beakerboy Feb 27, 2026
0343cae
Update test_reference.py
Beakerboy Feb 27, 2026
e9a1345
Update test_reference.py
Beakerboy Feb 27, 2026
852d87f
Update test_reference.py
Beakerboy Feb 27, 2026
6e91422
Rename test_fullFile.py to test_fullFile.pyt
Beakerboy Feb 27, 2026
855bb70
Update README.md
Beakerboy Feb 27, 2026
0688a00
Update and rename reference_type.py to reference_record.py (#118)
Beakerboy Feb 28, 2026
60b736e
Update reference.py
Beakerboy Feb 28, 2026
f6ccd48
Update reference.py
Beakerboy Feb 28, 2026
0b8204b
Update reference.py
Beakerboy Feb 28, 2026
b041cfb
Update reference.py
Beakerboy Feb 28, 2026
39f807b
Update reference.py
Beakerboy Feb 28, 2026
7a2f1b6
Update reference.py
Beakerboy Feb 28, 2026
8535f8f
Update reference.py
Beakerboy Feb 28, 2026
0302327
Update reference_record.py
Beakerboy Feb 28, 2026
2a41355
Update reference_record.py
Beakerboy Feb 28, 2026
b7b9750
Update reference_record.py
Beakerboy Feb 28, 2026
4a496fa
Update reference_registered.py
Beakerboy Feb 28, 2026
b8061fd
Update reference_registered.py
Beakerboy Feb 28, 2026
58a920f
Update reference_registered.py
Beakerboy Feb 28, 2026
81913de
Update reference_registered.py
Beakerboy Feb 28, 2026
6ca9bb1
Update reference_record.py
Beakerboy Feb 28, 2026
028bc11
Update reference.py
Beakerboy Feb 28, 2026
01b90aa
Update reference.py
Beakerboy Feb 28, 2026
145d2bc
Update reference_record.py
Beakerboy Feb 28, 2026
0c83181
Update reference.py
Beakerboy Feb 28, 2026
fa7aa4a
Update reference.py
Beakerboy Feb 28, 2026
00cc4f8
Update reference_record.py
Beakerboy Feb 28, 2026
32ce0a4
Update reference.py
Beakerboy Feb 28, 2026
cbb378d
Update reference.py
Beakerboy Feb 28, 2026
5d79339
Update reference_record.py
Beakerboy Feb 28, 2026
b0ee824
Update reference_record.py
Beakerboy Feb 28, 2026
c5fce21
Update test_reference_registered.py
Beakerboy Feb 28, 2026
e0f5b73
Update reference_registered.py
Beakerboy Feb 28, 2026
c01134f
Update reference_registered.py
Beakerboy Feb 28, 2026
eb02298
Update reference_registered.py
Beakerboy Feb 28, 2026
42df9b6
Update reference_registered.py
Beakerboy Feb 28, 2026
5540afc
Update reference_registered.py
Beakerboy Feb 28, 2026
03899bd
Update reference_registered.py
Beakerboy Feb 28, 2026
73b5998
Update reference_registered.py
Beakerboy Feb 28, 2026
1974937
Update reference_registered.py
Beakerboy Feb 28, 2026
c59eb09
Update libid_reference.py
Beakerboy Feb 28, 2026
7d8b473
Update libid_reference.py
Beakerboy Feb 28, 2026
cd37694
Update reference_registered.py
Beakerboy Feb 28, 2026
913626a
Update test_vba_project.py (#119)
Beakerboy Mar 1, 2026
89b94b8
Update test_reference_registered.py
Beakerboy Mar 1, 2026
1aa6360
Update test_reference_registered.py
Beakerboy Mar 1, 2026
4c57801
Update test_reference_registered.py
Beakerboy Mar 1, 2026
ce99b63
Update test_reference_registered.py
Beakerboy Mar 1, 2026
b723a60
Update test_reference_registered.py
Beakerboy Mar 1, 2026
f02ce84
Update test_reference_registered.py
Beakerboy Mar 1, 2026
97d03d1
Update test_reference_registered.py
Beakerboy Mar 1, 2026
307ac23
Update test_reference_registered.py
Beakerboy Mar 1, 2026
7fa6c6a
Update test_reference_registered.py
Beakerboy Mar 1, 2026
b2e83fe
Update test_reference_registered.py
Beakerboy Mar 1, 2026
d8a47a5
Update test_reference_registered.py
Beakerboy Mar 1, 2026
c2f6535
Update test_reference_registered.py
Beakerboy Mar 1, 2026
48386bd
Update test_reference_registered.py
Beakerboy Mar 1, 2026
ecc98b5
Update test_reference_registered.py
Beakerboy Mar 1, 2026
086f9de
Update test_reference_registered.py
Beakerboy Mar 1, 2026
8a32019
Update test_reference_registered.py
Beakerboy Mar 1, 2026
77545c8
Update test_reference_registered.py
Beakerboy Mar 1, 2026
3c94a97
Update test_reference_registered.py
Beakerboy Mar 1, 2026
922347b
Update test_reference_registered.py
Beakerboy Mar 1, 2026
78fdd7d
Update test_reference_registered.py
Beakerboy Mar 1, 2026
5bfcebc
Update test_reference_registered.py
Beakerboy Mar 1, 2026
0ea8761
Update test_reference_registered.py
Beakerboy Mar 1, 2026
8db3bca
Update test_reference_registered.py
Beakerboy Mar 1, 2026
1d71234
Update test_reference_registered.py
Beakerboy Mar 1, 2026
2d48aee
Update test_reference_registered.py
Beakerboy Mar 1, 2026
b5b0b7c
Update test_reference_project.py
Beakerboy Mar 1, 2026
e31b0b4
Update test_reference_project.py
Beakerboy Mar 1, 2026
f536df9
Update test_reference_project.py
Beakerboy Mar 1, 2026
e699b8d
Update test_reference_project.py
Beakerboy Mar 1, 2026
c099bd3
Update test_reference_project.py
Beakerboy Mar 1, 2026
ad633bd
Update test_reference_project.py
Beakerboy Mar 1, 2026
ff8017f
Update test_libidReference.py (#121)
Beakerboy Mar 1, 2026
37641d0
Update project_ole_file.py (#122)
Beakerboy Mar 1, 2026
931c97d
Rename test_doc_module.py to test_doc_module.py (#123)
Beakerboy Mar 2, 2026
3169be6
Rename tests/Unit/Models/test_vbaProject.py to tests/Unit/test_vbaPro…
Beakerboy Mar 13, 2026
8f9d35e
Create project_lk.py
Beakerboy Mar 13, 2026
43f6ba0
Project lk (#132)
Beakerboy Mar 15, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]

steps:
- uses: actions/checkout@v3
Expand All @@ -26,12 +26,9 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f requirements_dev.txt ]; then pip install -r requirements_dev.txt; fi
pip install git+https://github.com/Beakerboy/MS-CFB@dev
pip install git+https://github.com/Beakerboy/MS-Pcode-Assembler@dev
pip install -e .
pip install git+https://github.com/Beakerboy/MS-CFB
pip install git+https://github.com/Beakerboy/MS-Pcode-Assembler
pip install -e .[tests]
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
Expand All @@ -42,15 +39,16 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pytest --cov=vbaProjectCompiler
pytest --cov=src
coveralls --service=github
ls -al

flake8:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10"]
python-version: ["3.14"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand Down
41 changes: 12 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,56 +1,39 @@
[![Coverage Status](https://coveralls.io/repos/github/Beakerboy/vbaProject-Compiler/badge.svg?branch=main)](https://coveralls.io/github/Beakerboy/vbaProject-Compiler?branch=main)
[![Coverage Status](https://coveralls.io/repos/github/Beakerboy/MS-OVBA/badge.svg?branch=main)](https://coveralls.io/github/Beakerboy/MS-OVBA?branch=main)
# vbaProject-Compiler
Create a vbaProject.bin file from VBA source files.


## VBAProject Class
## Command Line Interface
Eventually it will be possible to use the CLI to create a vbaProject.bin file from source files and an optional configuration file.

The vbaProject class contains all the data and metadata that will be used to create the OLE container.
## VBAProject Class
The vbaProject class contains all the data and metadata that is used to create the OLE container. It can use this data to create several files, then compress and combine them into an OLE container

```python
from vbaProjectCompiler.vbaProject import VbaProject
from vbaProjectCompiler.ole_file import OleFile
from ms_ovba.vbaProject import VbaProject
from ms_cfb.ole_file import OleFile


project = VbaProject()
thisWorkbook = DocModule("ThisWorkbook")
thisWorkbook.addFile(path)
project.addModule(thisWorkbook)

ole_file = OleFile(project)
ole_file.writeFile(".")
ProjectOleFile.write_file(project)
```

The VbaProject class has many layers of customization available. Forexample a librry referenece can be added to the project.
The VbaProject class has many layers of customization available. For example a library reference can be added to the project.

```python
codePage = 0x04E4
codePageName = "cp" + str(codePage)
libidRef = LibidReference(
"windows",
libidRef = ReferenceRecord(codePageName, LibidReference(
"{00020430-0000-0000-C000-000000000046}",
"2.0",
"0",
"C:\\Windows\\System32\\stdole2.tlb",
"OLE Automation"
)
oleReference = ReferenceRecord(codePageName, "stdole", libidRef)
))
oleReference = Reference(codePageName, libidRef, "stdole")
project.addReference(oleReference)
```

## oleFile Class

Users should not have to interact with the oleFile class. It's job is to extract the data from the vbaProject and turn it into a valid file. This includes deciding which data stream appears where, and applying different views to the models to save the data in the correct formats.

The oleFIle has two parts, a header and a FAT Sector Chain. This FAT chain stores multiple streams of data:
* Fat Chain Stream
* Directory Stream
* Minifat Chain Stream
* Minifat Data Stream
* Fat Data Stream

These are all different views of data from the following Models

* fatChain
* minifatChain
* directoryStream
18 changes: 16 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "vba_project_compiler"
name = "vbaproject_compiler"
version = "0.0.1"
authors = [
{ name="Kevin Nowaczyk", email="beakerboy99@yahoo.com" },
Expand All @@ -16,7 +16,19 @@ classifiers = [
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
]

dependencies = [
'ms_ovba_compression',
'ms_ovba_crypto'
]
[project.optional-dependencies]
tests = [
'pytest',
'pytest-cov',
'pytest-mock',
'coveralls',
'pep8-naming',
'flake8-annotations'
]
[project.urls]
"Homepage" = "https://github.com/Beakerboy/vbaProject-Compiler"
"Bug Tracker" = "https://github.com/Beakerboy/vbaProject-Compiler/issues"
Expand All @@ -26,3 +38,5 @@ pythonpath = "src"
testpaths = [
"tests",
]
[tool.setuptools.package-data]
"*" = ["*.cls"]
2 changes: 0 additions & 2 deletions requirements.txt

This file was deleted.

4 changes: 0 additions & 4 deletions requirements_dev.txt

This file was deleted.

7 changes: 0 additions & 7 deletions setup.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,34 +1,29 @@
from ms_ovba_compression.ms_ovba import MsOvba
from vbaProjectCompiler.Models.Entities.module_base import ModuleBase
from ms_ovba.Models.Entities.module_base import ModuleBase
from typing import TypeVar


T = TypeVar('T', bound='DocModule')


class DocModule(ModuleBase):
"""
A Document Module is a module record that is associated with a worksheet or
workbook.
"""
def __init__(self, name):
self.docTlibVer = 0
def __init__(self: T, name: str) -> None:
self.doc_tlib_ver = 0
super(DocModule, self).__init__(name)
self.type = "Document"

# GUIDs
self._guid = []

def toProjectModuleString(self):
def to_project_module_string(self: T) -> str:
return ("Document=" + self.modName.value + "/&H"
+ self.docTlibVer.to_bytes(4, "big").hex())

def set_guid(self, guid):
if isinstance(guid, list):
self._guid = guid
else:
self._guid = [guid]

def add_guid(self, guid):
self._guid += guid
+ self.doc_tlib_ver.to_bytes(4, "big").hex())

def normalize_file(self):
def normalize_file(self: T) -> None:
f = open(self._file_path, "r")
new_f = open(self._file_path + ".new", "a+", newline='\r\n')
for i in range(5):
Expand All @@ -46,7 +41,7 @@ def normalize_file(self):
new_f.writelines([self._attr("Customizable", "True")])
new_f.close()

def write_file(self):
def write_file(self: T) -> None:
bin_f = open(self._file_path + ".bin", "wb")
bin_f.write(self._cache)
with open(self._file_path + ".new", mode="rb") as new_f:
Expand Down
24 changes: 24 additions & 0 deletions src/ms_ovba/Models/Entities/license_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import struct
import uuid
from typing import TypeVar


T = TypeVar('T', bound='LicenseInfo')


class LicenseInfo:
def __init__(self: T, guid: uuid.UUID, key: bytes) -> None:
self._guid = guid
self._key = key
self._required = len(key) > 0

def not_required(self: T) -> None:
self._required = False

def to_bytes(self: T) -> bytes:
return (
self._guid.bytes +
struct.pack("<I", len(self._key)) +
self._key +
struct.pack("<I", 1 if self._required else 0)
)
117 changes: 117 additions & 0 deletions src/ms_ovba/Models/Entities/module_base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
from ms_ovba_compression.ms_ovba import MsOvba
from ms_ovba.Models.Fields.doubleEncodedString import (
DoubleEncodedString
)
from ms_ovba.Models.Fields.packed_data import PackedData
from ms_ovba.Models.Fields.idSizeField import IdSizeField
from typing import TypeVar


T = TypeVar('T', bound='ModuleBase')


class ModuleBase():
def __init__(self: T, name: str) -> None:
"""
Initialize the module record
"""
self.modName = DoubleEncodedString([0x0019, 0x0047], name)
self.streamName = DoubleEncodedString([0x001A, 0x0032], name)
self.docString = DoubleEncodedString([0x001C, 0x0048], "")
self.helpContext = IdSizeField(0x001E, 4, 0)
self._cookie = IdSizeField(0x002C, 2, 0xFFFF)

# self.readonly = SimpleRecord(0x001E, 4, helpContext)
# self.private = SimpleRecord(0x001E, 4, helpContext)
self._cache = b''
self.workspace = [0, 0, 0, 0, 'C']
self.type = ''
self.created = 0
self.modified = 0
self._fileSize = 0
self._size = 0

# GUIDs
self._guids = []

@property
def guids(self: T) -> str:
return self._guids

@guids.setter
def guids(self: T, guid: str) -> None:
if isinstance(guid, list):
self._guids = guid
else:
self._guids = [guid]

def add_guid(self: T, guid: str) -> None:
"""
Append a guid to the list
"""
self._guid += [guid]

@property
def cache(self: T) -> bytes:
return self._cache

@cache.setter
def cache(self: T, cache: bytes) -> None:
self._cache = cache

@property
def cookie(self: T) -> int:
return self._cookie.value

@cookie.setter
def cookie(self: T, value: int) -> None:
self._cookie = IdSizeField(0x002C, 2, value)

@property
def name(self: T) -> str:
return self.modName.value

@property
def bin_path(self: T) -> str:
return self._file_path + ".bin"

def add_workspace(self: T, val1: int, val2: int,
val3: int, val4: int, val5: int) -> None:
self.workspace = [val1, val2, val3, val4, val5]

def pack(self: T, endien: str, cp_name: str) -> bytes:
"""
Pack the metadata for use in the dir stream.
"""
typeid_value = 0x0022 if self.type == 'Document' else 0x0021
type_id = PackedData("HI", typeid_value, 0)
self.offsetRec = IdSizeField(0x0031, 4, len(self._cache))
output = (self.modName.pack(endien, cp_name)
+ self.streamName.pack(endien, cp_name)
+ self.docString.pack(endien, cp_name)
+ self.offsetRec.pack(endien)
+ self.helpContext.pack(endien, cp_name)
+ self._cookie.pack(endien)
+ type_id.pack(endien))
footer = PackedData("HI", 0x002B, 0)
output += footer.pack(endien)
return output

def to_project_module_string(self: T) -> str:
return self.type + "=" + self.modName.value

def add_file(self: T, file_path: str) -> None:
self._file_path = file_path

def write_file(self: T) -> None:
bin_f = open(self._file_path + ".bin", "wb")
bin_f.write(self._cache)
with open(self._file_path + ".new", mode="rb") as new_f:
contents = new_f.read()
ms_ovba = MsOvba()
compressed = ms_ovba.compress(contents)
bin_f.write(compressed)
bin_f.close()

def _attr(self: T, name: str, value: str) -> str:
return 'Attribute VB_' + name + ' = ' + value + '\n'
Loading
Loading