-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
54 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env python | ||
|
||
import os | ||
import platform | ||
import xml.etree.ElementTree as ET | ||
import xml.dom.minidom as minidom | ||
|
||
home_path = os.path.expanduser("~") | ||
esp_share_path = "share/inkscape/extensions/eps_input.inx" | ||
eps_input_paths = { | ||
"Darwin": [ | ||
os.path.join("/Applications/Inkscape.app/Contents/Resources", esp_share_path), | ||
os.path.join("/usr", esp_share_path) | ||
], | ||
"Windows": [ | ||
os.path.join("C:\\Program Files\\Inkscape", esp_share_path), | ||
os.path.join(home_path, "AppData\\Roaming\\inkscape\\eps_input.inx") | ||
], | ||
"Linux": [os.path.join("/usr", esp_share_path)] | ||
}.get(platform.system(), []) | ||
|
||
default_ns = "http://www.inkscape.org/namespace/inkscape/extension" | ||
|
||
ET.register_namespace("", default_ns) | ||
|
||
for inx in eps_input_paths: | ||
if not os.path.exists(inx): | ||
print("{} doesn't exists. Skip".format(inx)) | ||
continue | ||
|
||
tree = ET.parse(inx) | ||
root = tree.getroot() | ||
|
||
print("{} before processing:".format(inx)) | ||
print(minidom.parseString(ET.tostring(root)).toprettyxml(indent=" ")) | ||
|
||
orig_param = tree.find("./param[@name='autorotate']", | ||
namespaces={"": default_ns}) | ||
if orig_param is not None: | ||
root.remove(orig_param) | ||
print("Original autorotate param {} removed".format(orig_param)) | ||
|
||
new_param = ET.Element("param", | ||
attrib={"name": "autorotate", | ||
"type": "string", "gui-hidden": "true"}) | ||
new_param.text = "None" | ||
root.append(new_param) | ||
|
||
tree.write() | ||
|
||
print("{} after processing:".format(inx)) | ||
print(minidom.parseString(ET.tostring(root)).toprettyxml()) |