https://github.com/marktsuchida/vcxproj-stream-editor
Simple Python library to modify Visual Studio .vcxproj files without spurious changes
https://github.com/marktsuchida/vcxproj-stream-editor
vcxproj visual-studio
Last synced: about 1 year ago
JSON representation
Simple Python library to modify Visual Studio .vcxproj files without spurious changes
- Host: GitHub
- URL: https://github.com/marktsuchida/vcxproj-stream-editor
- Owner: marktsuchida
- Created: 2013-07-28T21:44:24.000Z (almost 13 years ago)
- Default Branch: main
- Last Pushed: 2024-07-07T19:35:13.000Z (almost 2 years ago)
- Last Synced: 2025-04-15T09:43:46.842Z (about 1 year ago)
- Topics: vcxproj, visual-studio
- Language: Python
- Homepage: https://pypi.org/project/vcxproj-stream-editor/
- Size: 23.4 KB
- Stars: 11
- Watchers: 4
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# vcxproj-stream-editor
Simple Python library to parse Microsoft Visual Studio .vcxproj files and modify/rewrite without spurious changes
`pip install vcxproj-stream-editor`
## Usage:
Given the following simplified `myproject.vcxproj`:
``` xml
{96F21549-A7BF-4695-A1B1-B43625B91A14}
Level3
```
### Example 1 (input only):
``` python
import vcxproj
@vcxproj.coroutine
def print_project_guid():
while True:
action, params = yield
if action == "start_elem" and params["name"] == "ProjectGuid":
action, params = yield
assert action == "chars"
print("Project GUID is ", params["content"])
vcxproj.check_file("myproject.vcxproj", print_project_guid)
```
Output:
```
Project GUID is {96F21549-A7BF-4695-A1B1-B43625B91A14}
```
### Example 2 (input and output):
``` python
import vcxproj
@vcxproj.coroutine
def remove_warning_level(target)
while True:
action, params = yield
if action == "start_elem" and params["name"] == "WarningLevel":
action, params = yield
assert action == "chars"
action, params = yield
assert action == "end_elem"
assert params["name"] == "WarningLevel"
continue
target.send((action, params))
vcxproj.filter_file("myproject.vcxproj", remove_warning_level, "myproject.stripped.vcxproj")
```
`myproject.stripped.vcxproj` will have the following content:
``` xml
{96F21549-A7BF-4695-A1B1-B43625B91A14}
```
### Possible values for `(action, params)`:
| action | params |
|--------------|----------------------------------------------------------------------|
| `start_elem` | `{"name":, "attrs":{:, :}}` |
| `chars` | `{"content":}` |
| `end_elem` | `{"name":}` |