优化项目结构, 增加表格和文档插件
This commit is contained in:
1 parent
057d267e9f
commit
7805931355
3 files changed
+20
-38
No files matched your search
+1
-1
@@ -40,7 +40,7 @@ def invoke_wps_func(func, args):
|
||||
xhr.send(JSON.stringify({{id: '{req_uui}', response: res}}));void(0"
|
||||
|
||||
data = {
|
||||
"name": "xbotet",
|
||||
"name": "xbot-et",
|
||||
"function": "var res = InvokeFromXbot",
|
||||
"info": info,
|
||||
"showToFront": True,
|
||||
|
||||
Binary file not shown.
+19
-37
@@ -34,7 +34,7 @@ def create_authwebsite_xml(directory, node_name="xbotwps"):
|
||||
|
||||
try:
|
||||
# Parse the XML file
|
||||
dom = minidom.parse()
|
||||
dom = minidom.parse(file_path)
|
||||
|
||||
# Get the websites element
|
||||
websites_elements = dom.getElementsByTagName("websites")
|
||||
@@ -69,26 +69,14 @@ def create_authwebsite_xml(directory, node_name="xbotwps"):
|
||||
print(f"Updated authwebsite.xml at {file_path}")
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error working with authwebsite.xml: {e}")
|
||||
# Create a completely new file with the correct structure and node
|
||||
content = (
|
||||
'<?xml version="1.0" encoding="UTF-8"?>\n'
|
||||
"<websites>\n"
|
||||
f' <website origin="null" status="enable" name="{node_name}"/>\n'
|
||||
"</websites>\n"
|
||||
)
|
||||
with open(file_path, "w", encoding="utf-8") as f:
|
||||
f.write(content)
|
||||
print(f"Created new authwebsite.xml at {file_path}")
|
||||
raise Exception(f"Error working with authwebsite.xml: {e}")
|
||||
|
||||
|
||||
def create_publish_xml(
|
||||
directory, node_name="xbotwps", addon_path=None, verson="1.0.0", addon_type="wps"
|
||||
directory, node_name="xbotwps", verson="1.0.0", addon_type="wps"
|
||||
):
|
||||
"""Create the publish.xml file if it doesn't exist or update it if it exists."""
|
||||
file_path = os.path.join(directory, "publish.xml")
|
||||
if addon_path is None:
|
||||
raise ValueError("addon_path must be provided")
|
||||
|
||||
# Create the basic XML structure if the file doesn't exist
|
||||
if not os.path.exists(file_path):
|
||||
@@ -124,7 +112,7 @@ def create_publish_xml(
|
||||
# Create and append the new jsplugin node
|
||||
new_jsplugin = dom.createElement("jsplugin")
|
||||
new_jsplugin.setAttribute("enable", "enable_dev")
|
||||
new_jsplugin.setAttribute("url", addon_path)
|
||||
new_jsplugin.setAttribute("url", "null")
|
||||
new_jsplugin.setAttribute("install", "null")
|
||||
new_jsplugin.setAttribute("version", verson)
|
||||
new_jsplugin.setAttribute("type", addon_type)
|
||||
@@ -139,23 +127,13 @@ def create_publish_xml(
|
||||
print(f"Updated publish.xml at {file_path}")
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error working with publish.xml: {e}")
|
||||
# Create a completely new file with the correct structure and node
|
||||
content = (
|
||||
'<?xml version="1.0" encoding="UTF-8"?>\n'
|
||||
"<jsplugins>\n"
|
||||
f' <jsplugin enable="enable_dev" url="{addon_path}" install="null" version="1.0.0" type="wps" customDomain="" name="{node_name}"/>\n'
|
||||
"</jsplugins>\n"
|
||||
)
|
||||
with open(file_path, "w", encoding="utf-8") as f:
|
||||
f.write(content)
|
||||
print(f"Created new publish.xml at {file_path}")
|
||||
raise Exception(f"Error working with publish.xml: {e}")
|
||||
|
||||
|
||||
def extract_addon(addon_path, install_dir):
|
||||
def extract_addon(addon_path, install_dir, addon_name, addon_version):
|
||||
"""Extract the addon archive to the installation directory."""
|
||||
addon_name = "xbotwps"
|
||||
extract_dir = os.path.join(install_dir, addon_name)
|
||||
addon_name_with_version = f"{addon_name}_{addon_version}"
|
||||
extract_dir = os.path.join(install_dir, addon_name_with_version)
|
||||
|
||||
# Clean the existing directory if it exists
|
||||
if os.path.exists(extract_dir):
|
||||
@@ -171,7 +149,7 @@ def extract_addon(addon_path, install_dir):
|
||||
try:
|
||||
print(f"Extracting ZIP archive to {extract_dir}")
|
||||
with zipfile.ZipFile(addon_path, "r") as zip_ref:
|
||||
zip_ref.extractall(install_dir)
|
||||
zip_ref.extractall(extract_dir)
|
||||
print("Extraction completed successfully")
|
||||
|
||||
return True
|
||||
@@ -185,9 +163,11 @@ def main():
|
||||
# 2. 从插件目录下读取package.json文件,获取插件名称, 版本号, 插件类型
|
||||
# 3. 创建authwebsite.xml文件,添加插件名称节点
|
||||
# 4. 创建publish.xml文件,添加插件名称节点
|
||||
|
||||
addon_path = r"C:\\Users\\32075\\OneDrive\\文档\\Code\\RPA_Script\\wps-js-extension\\XbotWps\\wps-addon-build\\xbotwps.zip"
|
||||
node_name = "xbotwps"
|
||||
|
||||
addon_name = "XbotWps"
|
||||
addon_type = "et"
|
||||
addon_version = "1.0.0"
|
||||
addon_path = r"C:\Users\32075\OneDrive\文档\Code\RPA_Script\wps-js-extension\XbotWps\scripts\XbotWps_1.0.0.zip"
|
||||
install_dir = get_install_directory()
|
||||
print(f"Installation directory: {install_dir}")
|
||||
|
||||
@@ -197,11 +177,13 @@ def main():
|
||||
print(f"Created installation directory: {install_dir}")
|
||||
|
||||
# Create the required XML files
|
||||
create_authwebsite_xml(install_dir, node_name)
|
||||
create_publish_xml(install_dir, node_name, addon_path)
|
||||
create_authwebsite_xml(install_dir, addon_name)
|
||||
create_publish_xml(
|
||||
install_dir, addon_name, verson=addon_version, addon_type=addon_type
|
||||
)
|
||||
|
||||
# Extract the addon to the installation directory
|
||||
if extract_addon(addon_path, install_dir):
|
||||
if extract_addon(addon_path, install_dir, addon_name, addon_version):
|
||||
print("Addon extracted successfully.")
|
||||
else:
|
||||
print("Failed to extract addon.")
|
||||
|
||||
Reference in new issue
Block a user