sophhub 0.2.0 → 0.2.2
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.
- package/package.json +1 -1
- package/skills/compact-context/skill.json +20 -0
- package/skills/compact-context/src/SKILL.md +133 -0
- package/skills/compact-context/src/scripts/check.sh +381 -0
- package/skills/compact-context/src/scripts/set-keep-recent.mjs +1337 -0
- package/skills/compact-context/src/scripts/setup.sh +96 -0
- package/skills/feishu-notes-assistant-universal/skill.json +20 -0
- package/skills/feishu-notes-assistant-universal/src/README.md +55 -0
- package/skills/feishu-notes-assistant-universal/src/SKILL.md +159 -0
- package/skills/feishu-notes-assistant-universal/src/bin/linux-amd64/lark-cli-openclaw +0 -0
- package/skills/feishu-notes-assistant-universal/src/bin/linux-arm64/lark-cli-openclaw +0 -0
- package/skills/feishu-notes-assistant-universal/src/scripts/_resolve_lark_cli.py +58 -0
- package/skills/feishu-notes-assistant-universal/src/scripts/openclaw_meeting_minutes.py +462 -0
- package/skills/feishu-notes-assistant-universal/src/scripts/openclaw_notes_crud.py +547 -0
- package/skills/feishu-notes-assistant-universal/src/scripts/openclaw_notes_crud_test.py +181 -0
- package/skills/feishu-notes-assistant-universal/src/scripts/run_meeting_minutes.py +80 -0
- package/skills/feishu-notes-assistant-universal/src/scripts/run_meeting_minutes.sh +5 -0
- package/skills/feishu-notes-assistant-universal/src/scripts/run_note_crud.py +32 -0
- package/skills/feishu-notes-assistant-universal/src/scripts/run_note_crud.sh +5 -0
- package/skills/image-classify/skill.json +5 -5
- package/skills/image-classify/src/SKILL.md +60 -67
- package/skills/image-classify/src/scripts/face_search.py +400 -15
- package/skills/image-classify/src/scripts/send_dm_message.py +332 -0
- package/skills/md2pdf-converter/skill.json +20 -0
- package/skills/md2pdf-converter/src/SKILL.md +244 -0
- package/skills/md2pdf-converter/src/_meta.json +6 -0
- package/skills/md2pdf-converter/src/scripts/generate_emoji_mapping.py +74 -0
- package/skills/md2pdf-converter/src/scripts/md2pdf-local.sh +291 -0
- package/skills/sophnet-bot-client/skill.json +20 -0
- package/skills/sophnet-bot-client/src/SKILL.md +255 -0
- package/skills/sophnet-bot-client/src/pyproject.toml +13 -0
- package/skills/sophnet-bot-client/src/scripts/__init__.py +0 -0
- package/skills/sophnet-bot-client/src/scripts/bot_client_proxy.py +165 -0
- package/skills/sophnet-bot-client/src/scripts/bot_client_safe.sh +29 -0
- package/skills/sophnet-bot-client/src/scripts/bot_client_setup.py +502 -0
- package/skills/sophnet-bot-client/src/tests/__init__.py +0 -0
- package/skills/sophnet-bot-client/src/tests/test_bot_client_proxy.py +255 -0
- package/skills/sophnet-bot-client/src/tests/test_bot_client_setup.py +679 -0
- package/skills/sophnet-bot-client/src/uv.lock +8 -0
- package/skills/sophnet-docx/skill.json +20 -0
- package/skills/sophnet-docx/src/SKILL.md +463 -0
- package/skills/sophnet-docx/src/package-lock.json +208 -0
- package/skills/sophnet-docx/src/package.json +16 -0
- package/skills/sophnet-docx/src/pyproject.toml +11 -0
- package/skills/sophnet-docx/src/scripts/__init__.py +1 -0
- package/skills/sophnet-docx/src/scripts/accept_changes.py +135 -0
- package/skills/sophnet-docx/src/scripts/comment.py +318 -0
- package/skills/sophnet-docx/src/scripts/ensure_uv_env.sh +68 -0
- package/skills/sophnet-docx/src/scripts/office/helpers/__init__.py +0 -0
- package/skills/sophnet-docx/src/scripts/office/helpers/merge_runs.py +199 -0
- package/skills/sophnet-docx/src/scripts/office/helpers/simplify_redlines.py +197 -0
- package/skills/sophnet-docx/src/scripts/office/pack.py +159 -0
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
- package/skills/sophnet-docx/src/scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
- package/skills/sophnet-docx/src/scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
- package/skills/sophnet-docx/src/scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
- package/skills/sophnet-docx/src/scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
- package/skills/sophnet-docx/src/scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
- package/skills/sophnet-docx/src/scripts/office/schemas/mce/mc.xsd +75 -0
- package/skills/sophnet-docx/src/scripts/office/schemas/microsoft/wml-2010.xsd +560 -0
- package/skills/sophnet-docx/src/scripts/office/schemas/microsoft/wml-2012.xsd +67 -0
- package/skills/sophnet-docx/src/scripts/office/schemas/microsoft/wml-2018.xsd +14 -0
- package/skills/sophnet-docx/src/scripts/office/schemas/microsoft/wml-cex-2018.xsd +20 -0
- package/skills/sophnet-docx/src/scripts/office/schemas/microsoft/wml-cid-2016.xsd +13 -0
- package/skills/sophnet-docx/src/scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
- package/skills/sophnet-docx/src/scripts/office/schemas/microsoft/wml-symex-2015.xsd +8 -0
- package/skills/sophnet-docx/src/scripts/office/soffice.py +183 -0
- package/skills/sophnet-docx/src/scripts/office/unpack.py +132 -0
- package/skills/sophnet-docx/src/scripts/office/validate.py +111 -0
- package/skills/sophnet-docx/src/scripts/office/validators/__init__.py +15 -0
- package/skills/sophnet-docx/src/scripts/office/validators/base.py +847 -0
- package/skills/sophnet-docx/src/scripts/office/validators/docx.py +446 -0
- package/skills/sophnet-docx/src/scripts/office/validators/pptx.py +275 -0
- package/skills/sophnet-docx/src/scripts/office/validators/redlining.py +247 -0
- package/skills/sophnet-docx/src/scripts/templates/comments.xml +3 -0
- package/skills/sophnet-docx/src/scripts/templates/commentsExtended.xml +3 -0
- package/skills/sophnet-docx/src/scripts/templates/commentsExtensible.xml +3 -0
- package/skills/sophnet-docx/src/scripts/templates/commentsIds.xml +3 -0
- package/skills/sophnet-docx/src/scripts/templates/people.xml +3 -0
- package/skills/sophnet-docx/src/scripts/upload_file.sh +96 -0
- package/skills/sophnet-docx/src/uv.lock +320 -0
- package/skills/sophnet-pdf/skill.json +20 -0
- package/skills/sophnet-pdf/src/SKILL.md +413 -0
- package/skills/sophnet-pdf/src/forms.md +297 -0
- package/skills/sophnet-pdf/src/pyproject.toml +14 -0
- package/skills/sophnet-pdf/src/reference.md +612 -0
- package/skills/sophnet-pdf/src/scripts/check_bounding_boxes.py +65 -0
- package/skills/sophnet-pdf/src/scripts/check_fillable_fields.py +11 -0
- package/skills/sophnet-pdf/src/scripts/convert_pdf_to_images.py +33 -0
- package/skills/sophnet-pdf/src/scripts/create_validation_image.py +37 -0
- package/skills/sophnet-pdf/src/scripts/enhance_tutorial.py +558 -0
- package/skills/sophnet-pdf/src/scripts/ensure_uv_env.sh +68 -0
- package/skills/sophnet-pdf/src/scripts/extract_form_field_info.py +122 -0
- package/skills/sophnet-pdf/src/scripts/extract_form_structure.py +115 -0
- package/skills/sophnet-pdf/src/scripts/extract_pdf_content.py +35 -0
- package/skills/sophnet-pdf/src/scripts/fill_fillable_fields.py +98 -0
- package/skills/sophnet-pdf/src/scripts/fill_pdf_form_with_annotations.py +107 -0
- package/skills/sophnet-pdf/src/scripts/upload_file.sh +88 -0
- package/skills/sophnet-pdf/src/uv.lock +537 -0
- package/skills/sophnet-xlsx/skill.json +20 -0
- package/skills/sophnet-xlsx/src/SKILL.md +399 -0
- package/skills/sophnet-xlsx/src/pyproject.toml +11 -0
- package/skills/sophnet-xlsx/src/scripts/ensure_uv_env.sh +68 -0
- package/skills/sophnet-xlsx/src/scripts/office/helpers/__init__.py +0 -0
- package/skills/sophnet-xlsx/src/scripts/office/helpers/merge_runs.py +199 -0
- package/skills/sophnet-xlsx/src/scripts/office/helpers/simplify_redlines.py +197 -0
- package/skills/sophnet-xlsx/src/scripts/office/pack.py +159 -0
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
- package/skills/sophnet-xlsx/src/scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
- package/skills/sophnet-xlsx/src/scripts/office/schemas/mce/mc.xsd +75 -0
- package/skills/sophnet-xlsx/src/scripts/office/schemas/microsoft/wml-2010.xsd +560 -0
- package/skills/sophnet-xlsx/src/scripts/office/schemas/microsoft/wml-2012.xsd +67 -0
- package/skills/sophnet-xlsx/src/scripts/office/schemas/microsoft/wml-2018.xsd +14 -0
- package/skills/sophnet-xlsx/src/scripts/office/schemas/microsoft/wml-cex-2018.xsd +20 -0
- package/skills/sophnet-xlsx/src/scripts/office/schemas/microsoft/wml-cid-2016.xsd +13 -0
- package/skills/sophnet-xlsx/src/scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
- package/skills/sophnet-xlsx/src/scripts/office/schemas/microsoft/wml-symex-2015.xsd +8 -0
- package/skills/sophnet-xlsx/src/scripts/office/soffice.py +183 -0
- package/skills/sophnet-xlsx/src/scripts/office/unpack.py +132 -0
- package/skills/sophnet-xlsx/src/scripts/office/validate.py +111 -0
- package/skills/sophnet-xlsx/src/scripts/office/validators/__init__.py +15 -0
- package/skills/sophnet-xlsx/src/scripts/office/validators/base.py +847 -0
- package/skills/sophnet-xlsx/src/scripts/office/validators/docx.py +446 -0
- package/skills/sophnet-xlsx/src/scripts/office/validators/pptx.py +275 -0
- package/skills/sophnet-xlsx/src/scripts/office/validators/redlining.py +247 -0
- package/skills/sophnet-xlsx/src/scripts/recalc.py +184 -0
- package/skills/sophnet-xlsx/src/scripts/upload_file.sh +96 -0
- package/skills/sophnet-xlsx/src/uv.lock +319 -0
- package/skills/wechat-article-publisher/skill.json +20 -0
- package/skills/wechat-article-publisher/src/SKILL.md +60 -0
- package/skills/wechat-article-publisher/src/config.json +7 -0
- package/skills/wechat-article-publisher/src/pyproject.toml +12 -0
- package/skills/wechat-article-publisher/src/scripts/publish_wechat.py +825 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import sys
|
|
3
|
+
|
|
4
|
+
from pypdf import PdfReader
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def get_full_annotation_field_id(annotation):
|
|
10
|
+
components = []
|
|
11
|
+
while annotation:
|
|
12
|
+
field_name = annotation.get('/T')
|
|
13
|
+
if field_name:
|
|
14
|
+
components.append(field_name)
|
|
15
|
+
annotation = annotation.get('/Parent')
|
|
16
|
+
return ".".join(reversed(components)) if components else None
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def make_field_dict(field, field_id):
|
|
20
|
+
field_dict = {"field_id": field_id}
|
|
21
|
+
ft = field.get('/FT')
|
|
22
|
+
if ft == "/Tx":
|
|
23
|
+
field_dict["type"] = "text"
|
|
24
|
+
elif ft == "/Btn":
|
|
25
|
+
field_dict["type"] = "checkbox"
|
|
26
|
+
states = field.get("/_States_", [])
|
|
27
|
+
if len(states) == 2:
|
|
28
|
+
if "/Off" in states:
|
|
29
|
+
field_dict["checked_value"] = states[0] if states[0] != "/Off" else states[1]
|
|
30
|
+
field_dict["unchecked_value"] = "/Off"
|
|
31
|
+
else:
|
|
32
|
+
print(f"Unexpected state values for checkbox `${field_id}`. Its checked and unchecked values may not be correct; if you're trying to check it, visually verify the results.")
|
|
33
|
+
field_dict["checked_value"] = states[0]
|
|
34
|
+
field_dict["unchecked_value"] = states[1]
|
|
35
|
+
elif ft == "/Ch":
|
|
36
|
+
field_dict["type"] = "choice"
|
|
37
|
+
states = field.get("/_States_", [])
|
|
38
|
+
field_dict["choice_options"] = [{
|
|
39
|
+
"value": state[0],
|
|
40
|
+
"text": state[1],
|
|
41
|
+
} for state in states]
|
|
42
|
+
else:
|
|
43
|
+
field_dict["type"] = f"unknown ({ft})"
|
|
44
|
+
return field_dict
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def get_field_info(reader: PdfReader):
|
|
48
|
+
fields = reader.get_fields()
|
|
49
|
+
|
|
50
|
+
field_info_by_id = {}
|
|
51
|
+
possible_radio_names = set()
|
|
52
|
+
|
|
53
|
+
for field_id, field in fields.items():
|
|
54
|
+
if field.get("/Kids"):
|
|
55
|
+
if field.get("/FT") == "/Btn":
|
|
56
|
+
possible_radio_names.add(field_id)
|
|
57
|
+
continue
|
|
58
|
+
field_info_by_id[field_id] = make_field_dict(field, field_id)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
radio_fields_by_id = {}
|
|
62
|
+
|
|
63
|
+
for page_index, page in enumerate(reader.pages):
|
|
64
|
+
annotations = page.get('/Annots', [])
|
|
65
|
+
for ann in annotations:
|
|
66
|
+
field_id = get_full_annotation_field_id(ann)
|
|
67
|
+
if field_id in field_info_by_id:
|
|
68
|
+
field_info_by_id[field_id]["page"] = page_index + 1
|
|
69
|
+
field_info_by_id[field_id]["rect"] = ann.get('/Rect')
|
|
70
|
+
elif field_id in possible_radio_names:
|
|
71
|
+
try:
|
|
72
|
+
on_values = [v for v in ann["/AP"]["/N"] if v != "/Off"]
|
|
73
|
+
except KeyError:
|
|
74
|
+
continue
|
|
75
|
+
if len(on_values) == 1:
|
|
76
|
+
rect = ann.get("/Rect")
|
|
77
|
+
if field_id not in radio_fields_by_id:
|
|
78
|
+
radio_fields_by_id[field_id] = {
|
|
79
|
+
"field_id": field_id,
|
|
80
|
+
"type": "radio_group",
|
|
81
|
+
"page": page_index + 1,
|
|
82
|
+
"radio_options": [],
|
|
83
|
+
}
|
|
84
|
+
radio_fields_by_id[field_id]["radio_options"].append({
|
|
85
|
+
"value": on_values[0],
|
|
86
|
+
"rect": rect,
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
fields_with_location = []
|
|
90
|
+
for field_info in field_info_by_id.values():
|
|
91
|
+
if "page" in field_info:
|
|
92
|
+
fields_with_location.append(field_info)
|
|
93
|
+
else:
|
|
94
|
+
print(f"Unable to determine location for field id: {field_info.get('field_id')}, ignoring")
|
|
95
|
+
|
|
96
|
+
def sort_key(f):
|
|
97
|
+
if "radio_options" in f:
|
|
98
|
+
rect = f["radio_options"][0]["rect"] or [0, 0, 0, 0]
|
|
99
|
+
else:
|
|
100
|
+
rect = f.get("rect") or [0, 0, 0, 0]
|
|
101
|
+
adjusted_position = [-rect[1], rect[0]]
|
|
102
|
+
return [f.get("page"), adjusted_position]
|
|
103
|
+
|
|
104
|
+
sorted_fields = fields_with_location + list(radio_fields_by_id.values())
|
|
105
|
+
sorted_fields.sort(key=sort_key)
|
|
106
|
+
|
|
107
|
+
return sorted_fields
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def write_field_info(pdf_path: str, json_output_path: str):
|
|
111
|
+
reader = PdfReader(pdf_path)
|
|
112
|
+
field_info = get_field_info(reader)
|
|
113
|
+
with open(json_output_path, "w") as f:
|
|
114
|
+
json.dump(field_info, f, indent=2)
|
|
115
|
+
print(f"Wrote {len(field_info)} fields to {json_output_path}")
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
if __name__ == "__main__":
|
|
119
|
+
if len(sys.argv) != 3:
|
|
120
|
+
print("Usage: extract_form_field_info.py [input pdf] [output json]")
|
|
121
|
+
sys.exit(1)
|
|
122
|
+
write_field_info(sys.argv[1], sys.argv[2])
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Extract form structure from a non-fillable PDF.
|
|
3
|
+
|
|
4
|
+
This script analyzes the PDF to find:
|
|
5
|
+
- Text labels with their exact coordinates
|
|
6
|
+
- Horizontal lines (row boundaries)
|
|
7
|
+
- Checkboxes (small rectangles)
|
|
8
|
+
|
|
9
|
+
Output: A JSON file with the form structure that can be used to generate
|
|
10
|
+
accurate field coordinates for filling.
|
|
11
|
+
|
|
12
|
+
Usage: python extract_form_structure.py <input.pdf> <output.json>
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
import json
|
|
16
|
+
import sys
|
|
17
|
+
import pdfplumber
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def extract_form_structure(pdf_path):
|
|
21
|
+
structure = {
|
|
22
|
+
"pages": [],
|
|
23
|
+
"labels": [],
|
|
24
|
+
"lines": [],
|
|
25
|
+
"checkboxes": [],
|
|
26
|
+
"row_boundaries": []
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
with pdfplumber.open(pdf_path) as pdf:
|
|
30
|
+
for page_num, page in enumerate(pdf.pages, 1):
|
|
31
|
+
structure["pages"].append({
|
|
32
|
+
"page_number": page_num,
|
|
33
|
+
"width": float(page.width),
|
|
34
|
+
"height": float(page.height)
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
words = page.extract_words()
|
|
38
|
+
for word in words:
|
|
39
|
+
structure["labels"].append({
|
|
40
|
+
"page": page_num,
|
|
41
|
+
"text": word["text"],
|
|
42
|
+
"x0": round(float(word["x0"]), 1),
|
|
43
|
+
"top": round(float(word["top"]), 1),
|
|
44
|
+
"x1": round(float(word["x1"]), 1),
|
|
45
|
+
"bottom": round(float(word["bottom"]), 1)
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
for line in page.lines:
|
|
49
|
+
if abs(float(line["x1"]) - float(line["x0"])) > page.width * 0.5:
|
|
50
|
+
structure["lines"].append({
|
|
51
|
+
"page": page_num,
|
|
52
|
+
"y": round(float(line["top"]), 1),
|
|
53
|
+
"x0": round(float(line["x0"]), 1),
|
|
54
|
+
"x1": round(float(line["x1"]), 1)
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
for rect in page.rects:
|
|
58
|
+
width = float(rect["x1"]) - float(rect["x0"])
|
|
59
|
+
height = float(rect["bottom"]) - float(rect["top"])
|
|
60
|
+
if 5 <= width <= 15 and 5 <= height <= 15 and abs(width - height) < 2:
|
|
61
|
+
structure["checkboxes"].append({
|
|
62
|
+
"page": page_num,
|
|
63
|
+
"x0": round(float(rect["x0"]), 1),
|
|
64
|
+
"top": round(float(rect["top"]), 1),
|
|
65
|
+
"x1": round(float(rect["x1"]), 1),
|
|
66
|
+
"bottom": round(float(rect["bottom"]), 1),
|
|
67
|
+
"center_x": round((float(rect["x0"]) + float(rect["x1"])) / 2, 1),
|
|
68
|
+
"center_y": round((float(rect["top"]) + float(rect["bottom"])) / 2, 1)
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
lines_by_page = {}
|
|
72
|
+
for line in structure["lines"]:
|
|
73
|
+
page = line["page"]
|
|
74
|
+
if page not in lines_by_page:
|
|
75
|
+
lines_by_page[page] = []
|
|
76
|
+
lines_by_page[page].append(line["y"])
|
|
77
|
+
|
|
78
|
+
for page, y_coords in lines_by_page.items():
|
|
79
|
+
y_coords = sorted(set(y_coords))
|
|
80
|
+
for i in range(len(y_coords) - 1):
|
|
81
|
+
structure["row_boundaries"].append({
|
|
82
|
+
"page": page,
|
|
83
|
+
"row_top": y_coords[i],
|
|
84
|
+
"row_bottom": y_coords[i + 1],
|
|
85
|
+
"row_height": round(y_coords[i + 1] - y_coords[i], 1)
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
return structure
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def main():
|
|
92
|
+
if len(sys.argv) != 3:
|
|
93
|
+
print("Usage: extract_form_structure.py <input.pdf> <output.json>")
|
|
94
|
+
sys.exit(1)
|
|
95
|
+
|
|
96
|
+
pdf_path = sys.argv[1]
|
|
97
|
+
output_path = sys.argv[2]
|
|
98
|
+
|
|
99
|
+
print(f"Extracting structure from {pdf_path}...")
|
|
100
|
+
structure = extract_form_structure(pdf_path)
|
|
101
|
+
|
|
102
|
+
with open(output_path, "w") as f:
|
|
103
|
+
json.dump(structure, f, indent=2)
|
|
104
|
+
|
|
105
|
+
print(f"Found:")
|
|
106
|
+
print(f" - {len(structure['pages'])} pages")
|
|
107
|
+
print(f" - {len(structure['labels'])} text labels")
|
|
108
|
+
print(f" - {len(structure['lines'])} horizontal lines")
|
|
109
|
+
print(f" - {len(structure['checkboxes'])} checkboxes")
|
|
110
|
+
print(f" - {len(structure['row_boundaries'])} row boundaries")
|
|
111
|
+
print(f"Saved to {output_path}")
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
if __name__ == "__main__":
|
|
115
|
+
main()
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Extract text from PDF to understand its content."""
|
|
3
|
+
|
|
4
|
+
import pdfplumber
|
|
5
|
+
import sys
|
|
6
|
+
|
|
7
|
+
pdf_path = "/Data/shutong.shan/clawd/media/inbound/documents/Image-Edit_教程.pdf"
|
|
8
|
+
|
|
9
|
+
try:
|
|
10
|
+
with pdfplumber.open(pdf_path) as pdf:
|
|
11
|
+
print(f"Total pages: {len(pdf.pages)}\n")
|
|
12
|
+
print("=" * 80)
|
|
13
|
+
print("PDF Content:")
|
|
14
|
+
print("=" * 80 + "\n")
|
|
15
|
+
|
|
16
|
+
for i, page in enumerate(pdf.pages, 1):
|
|
17
|
+
print(f"\n--- Page {i} ---\n")
|
|
18
|
+
text = page.extract_text()
|
|
19
|
+
if text:
|
|
20
|
+
print(text)
|
|
21
|
+
else:
|
|
22
|
+
print("[No text found on this page]")
|
|
23
|
+
|
|
24
|
+
# Check for tables
|
|
25
|
+
tables = page.extract_tables()
|
|
26
|
+
if tables:
|
|
27
|
+
print(f"\n[Found {len(tables)} table(s) on this page]")
|
|
28
|
+
for j, table in enumerate(tables, 1):
|
|
29
|
+
print(f"\nTable {j}:")
|
|
30
|
+
for row in table:
|
|
31
|
+
print(row)
|
|
32
|
+
|
|
33
|
+
except Exception as e:
|
|
34
|
+
print(f"Error: {e}", file=sys.stderr)
|
|
35
|
+
sys.exit(1)
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import sys
|
|
3
|
+
|
|
4
|
+
from pypdf import PdfReader, PdfWriter
|
|
5
|
+
|
|
6
|
+
from extract_form_field_info import get_field_info
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def fill_pdf_fields(input_pdf_path: str, fields_json_path: str, output_pdf_path: str):
|
|
12
|
+
with open(fields_json_path) as f:
|
|
13
|
+
fields = json.load(f)
|
|
14
|
+
fields_by_page = {}
|
|
15
|
+
for field in fields:
|
|
16
|
+
if "value" in field:
|
|
17
|
+
field_id = field["field_id"]
|
|
18
|
+
page = field["page"]
|
|
19
|
+
if page not in fields_by_page:
|
|
20
|
+
fields_by_page[page] = {}
|
|
21
|
+
fields_by_page[page][field_id] = field["value"]
|
|
22
|
+
|
|
23
|
+
reader = PdfReader(input_pdf_path)
|
|
24
|
+
|
|
25
|
+
has_error = False
|
|
26
|
+
field_info = get_field_info(reader)
|
|
27
|
+
fields_by_ids = {f["field_id"]: f for f in field_info}
|
|
28
|
+
for field in fields:
|
|
29
|
+
existing_field = fields_by_ids.get(field["field_id"])
|
|
30
|
+
if not existing_field:
|
|
31
|
+
has_error = True
|
|
32
|
+
print(f"ERROR: `{field['field_id']}` is not a valid field ID")
|
|
33
|
+
elif field["page"] != existing_field["page"]:
|
|
34
|
+
has_error = True
|
|
35
|
+
print(f"ERROR: Incorrect page number for `{field['field_id']}` (got {field['page']}, expected {existing_field['page']})")
|
|
36
|
+
else:
|
|
37
|
+
if "value" in field:
|
|
38
|
+
err = validation_error_for_field_value(existing_field, field["value"])
|
|
39
|
+
if err:
|
|
40
|
+
print(err)
|
|
41
|
+
has_error = True
|
|
42
|
+
if has_error:
|
|
43
|
+
sys.exit(1)
|
|
44
|
+
|
|
45
|
+
writer = PdfWriter(clone_from=reader)
|
|
46
|
+
for page, field_values in fields_by_page.items():
|
|
47
|
+
writer.update_page_form_field_values(writer.pages[page - 1], field_values, auto_regenerate=False)
|
|
48
|
+
|
|
49
|
+
writer.set_need_appearances_writer(True)
|
|
50
|
+
|
|
51
|
+
with open(output_pdf_path, "wb") as f:
|
|
52
|
+
writer.write(f)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def validation_error_for_field_value(field_info, field_value):
|
|
56
|
+
field_type = field_info["type"]
|
|
57
|
+
field_id = field_info["field_id"]
|
|
58
|
+
if field_type == "checkbox":
|
|
59
|
+
checked_val = field_info["checked_value"]
|
|
60
|
+
unchecked_val = field_info["unchecked_value"]
|
|
61
|
+
if field_value != checked_val and field_value != unchecked_val:
|
|
62
|
+
return f'ERROR: Invalid value "{field_value}" for checkbox field "{field_id}". The checked value is "{checked_val}" and the unchecked value is "{unchecked_val}"'
|
|
63
|
+
elif field_type == "radio_group":
|
|
64
|
+
option_values = [opt["value"] for opt in field_info["radio_options"]]
|
|
65
|
+
if field_value not in option_values:
|
|
66
|
+
return f'ERROR: Invalid value "{field_value}" for radio group field "{field_id}". Valid values are: {option_values}'
|
|
67
|
+
elif field_type == "choice":
|
|
68
|
+
choice_values = [opt["value"] for opt in field_info["choice_options"]]
|
|
69
|
+
if field_value not in choice_values:
|
|
70
|
+
return f'ERROR: Invalid value "{field_value}" for choice field "{field_id}". Valid values are: {choice_values}'
|
|
71
|
+
return None
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def monkeypatch_pydpf_method():
|
|
75
|
+
from pypdf.generic import DictionaryObject
|
|
76
|
+
from pypdf.constants import FieldDictionaryAttributes
|
|
77
|
+
|
|
78
|
+
original_get_inherited = DictionaryObject.get_inherited
|
|
79
|
+
|
|
80
|
+
def patched_get_inherited(self, key: str, default = None):
|
|
81
|
+
result = original_get_inherited(self, key, default)
|
|
82
|
+
if key == FieldDictionaryAttributes.Opt:
|
|
83
|
+
if isinstance(result, list) and all(isinstance(v, list) and len(v) == 2 for v in result):
|
|
84
|
+
result = [r[0] for r in result]
|
|
85
|
+
return result
|
|
86
|
+
|
|
87
|
+
DictionaryObject.get_inherited = patched_get_inherited
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
if __name__ == "__main__":
|
|
91
|
+
if len(sys.argv) != 4:
|
|
92
|
+
print("Usage: fill_fillable_fields.py [input pdf] [field_values.json] [output pdf]")
|
|
93
|
+
sys.exit(1)
|
|
94
|
+
monkeypatch_pydpf_method()
|
|
95
|
+
input_pdf = sys.argv[1]
|
|
96
|
+
fields_json = sys.argv[2]
|
|
97
|
+
output_pdf = sys.argv[3]
|
|
98
|
+
fill_pdf_fields(input_pdf, fields_json, output_pdf)
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import sys
|
|
3
|
+
|
|
4
|
+
from pypdf import PdfReader, PdfWriter
|
|
5
|
+
from pypdf.annotations import FreeText
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def transform_from_image_coords(bbox, image_width, image_height, pdf_width, pdf_height):
|
|
11
|
+
x_scale = pdf_width / image_width
|
|
12
|
+
y_scale = pdf_height / image_height
|
|
13
|
+
|
|
14
|
+
left = bbox[0] * x_scale
|
|
15
|
+
right = bbox[2] * x_scale
|
|
16
|
+
|
|
17
|
+
top = pdf_height - (bbox[1] * y_scale)
|
|
18
|
+
bottom = pdf_height - (bbox[3] * y_scale)
|
|
19
|
+
|
|
20
|
+
return left, bottom, right, top
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def transform_from_pdf_coords(bbox, pdf_height):
|
|
24
|
+
left = bbox[0]
|
|
25
|
+
right = bbox[2]
|
|
26
|
+
|
|
27
|
+
pypdf_top = pdf_height - bbox[1]
|
|
28
|
+
pypdf_bottom = pdf_height - bbox[3]
|
|
29
|
+
|
|
30
|
+
return left, pypdf_bottom, right, pypdf_top
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def fill_pdf_form(input_pdf_path, fields_json_path, output_pdf_path):
|
|
34
|
+
|
|
35
|
+
with open(fields_json_path, "r") as f:
|
|
36
|
+
fields_data = json.load(f)
|
|
37
|
+
|
|
38
|
+
reader = PdfReader(input_pdf_path)
|
|
39
|
+
writer = PdfWriter()
|
|
40
|
+
|
|
41
|
+
writer.append(reader)
|
|
42
|
+
|
|
43
|
+
pdf_dimensions = {}
|
|
44
|
+
for i, page in enumerate(reader.pages):
|
|
45
|
+
mediabox = page.mediabox
|
|
46
|
+
pdf_dimensions[i + 1] = [mediabox.width, mediabox.height]
|
|
47
|
+
|
|
48
|
+
annotations = []
|
|
49
|
+
for field in fields_data["form_fields"]:
|
|
50
|
+
page_num = field["page_number"]
|
|
51
|
+
|
|
52
|
+
page_info = next(p for p in fields_data["pages"] if p["page_number"] == page_num)
|
|
53
|
+
pdf_width, pdf_height = pdf_dimensions[page_num]
|
|
54
|
+
|
|
55
|
+
if "pdf_width" in page_info:
|
|
56
|
+
transformed_entry_box = transform_from_pdf_coords(
|
|
57
|
+
field["entry_bounding_box"],
|
|
58
|
+
float(pdf_height)
|
|
59
|
+
)
|
|
60
|
+
else:
|
|
61
|
+
image_width = page_info["image_width"]
|
|
62
|
+
image_height = page_info["image_height"]
|
|
63
|
+
transformed_entry_box = transform_from_image_coords(
|
|
64
|
+
field["entry_bounding_box"],
|
|
65
|
+
image_width, image_height,
|
|
66
|
+
float(pdf_width), float(pdf_height)
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
if "entry_text" not in field or "text" not in field["entry_text"]:
|
|
70
|
+
continue
|
|
71
|
+
entry_text = field["entry_text"]
|
|
72
|
+
text = entry_text["text"]
|
|
73
|
+
if not text:
|
|
74
|
+
continue
|
|
75
|
+
|
|
76
|
+
font_name = entry_text.get("font", "Arial")
|
|
77
|
+
font_size = str(entry_text.get("font_size", 14)) + "pt"
|
|
78
|
+
font_color = entry_text.get("font_color", "000000")
|
|
79
|
+
|
|
80
|
+
annotation = FreeText(
|
|
81
|
+
text=text,
|
|
82
|
+
rect=transformed_entry_box,
|
|
83
|
+
font=font_name,
|
|
84
|
+
font_size=font_size,
|
|
85
|
+
font_color=font_color,
|
|
86
|
+
border_color=None,
|
|
87
|
+
background_color=None,
|
|
88
|
+
)
|
|
89
|
+
annotations.append(annotation)
|
|
90
|
+
writer.add_annotation(page_number=page_num - 1, annotation=annotation)
|
|
91
|
+
|
|
92
|
+
with open(output_pdf_path, "wb") as output:
|
|
93
|
+
writer.write(output)
|
|
94
|
+
|
|
95
|
+
print(f"Successfully filled PDF form and saved to {output_pdf_path}")
|
|
96
|
+
print(f"Added {len(annotations)} text annotations")
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
if __name__ == "__main__":
|
|
100
|
+
if len(sys.argv) != 4:
|
|
101
|
+
print("Usage: fill_pdf_form_with_annotations.py [input pdf] [fields.json] [output pdf]")
|
|
102
|
+
sys.exit(1)
|
|
103
|
+
input_pdf = sys.argv[1]
|
|
104
|
+
fields_json = sys.argv[2]
|
|
105
|
+
output_pdf = sys.argv[3]
|
|
106
|
+
|
|
107
|
+
fill_pdf_form(input_pdf, fields_json, output_pdf)
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
usage() {
|
|
5
|
+
cat <<'USAGE'
|
|
6
|
+
Usage:
|
|
7
|
+
bash upload_file.sh --file "/path/to/file.pdf" [options]
|
|
8
|
+
|
|
9
|
+
Options:
|
|
10
|
+
--file "/path/to/file.pdf" Required. Local file path to upload.
|
|
11
|
+
--timeout 60 Optional. Upload timeout in seconds. Default: 60.
|
|
12
|
+
USAGE
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
FILE_PATH=""
|
|
16
|
+
TIMEOUT="60"
|
|
17
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
18
|
+
SKILL_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
19
|
+
|
|
20
|
+
while [[ $# -gt 0 ]]; do
|
|
21
|
+
case "$1" in
|
|
22
|
+
--file)
|
|
23
|
+
FILE_PATH="$2"
|
|
24
|
+
shift 2
|
|
25
|
+
;;
|
|
26
|
+
--timeout)
|
|
27
|
+
TIMEOUT="$2"
|
|
28
|
+
shift 2
|
|
29
|
+
;;
|
|
30
|
+
-h|--help)
|
|
31
|
+
usage
|
|
32
|
+
exit 0
|
|
33
|
+
;;
|
|
34
|
+
*)
|
|
35
|
+
# Handle unquoted file paths split by shell (e.g. spaces in Chinese filenames)
|
|
36
|
+
if [[ -n "$FILE_PATH" && "$1" != -* ]]; then
|
|
37
|
+
FILE_PATH="$FILE_PATH $1"
|
|
38
|
+
else
|
|
39
|
+
echo "Unknown argument: $1" >&2
|
|
40
|
+
usage
|
|
41
|
+
exit 1
|
|
42
|
+
fi
|
|
43
|
+
shift
|
|
44
|
+
;;
|
|
45
|
+
esac
|
|
46
|
+
done
|
|
47
|
+
|
|
48
|
+
if [[ -z "$FILE_PATH" ]]; then
|
|
49
|
+
echo "Error: --file is required." >&2
|
|
50
|
+
exit 1
|
|
51
|
+
fi
|
|
52
|
+
|
|
53
|
+
bash "$SCRIPT_DIR/ensure_uv_env.sh" --quiet
|
|
54
|
+
|
|
55
|
+
if command -v realpath >/dev/null 2>&1; then
|
|
56
|
+
ABS_FILE_PATH="$(realpath "$FILE_PATH")"
|
|
57
|
+
elif command -v readlink >/dev/null 2>&1; then
|
|
58
|
+
ABS_FILE_PATH="$(readlink -f "$FILE_PATH")"
|
|
59
|
+
else
|
|
60
|
+
ABS_FILE_PATH="$(uv run --project "$SKILL_DIR" python -c 'from pathlib import Path; import sys; print(Path(sys.argv[1]).expanduser().resolve())' "$FILE_PATH")"
|
|
61
|
+
fi
|
|
62
|
+
|
|
63
|
+
if [[ ! -f "$ABS_FILE_PATH" ]]; then
|
|
64
|
+
echo "Error: file not found: $ABS_FILE_PATH" >&2
|
|
65
|
+
exit 1
|
|
66
|
+
fi
|
|
67
|
+
|
|
68
|
+
if [[ "$ABS_FILE_PATH" != *.pdf ]]; then
|
|
69
|
+
echo "Error: expected a .pdf file: $ABS_FILE_PATH" >&2
|
|
70
|
+
exit 1
|
|
71
|
+
fi
|
|
72
|
+
|
|
73
|
+
signed_url="$(uv run --project "$SKILL_DIR" python -c "
|
|
74
|
+
import sophnet_tools, sys
|
|
75
|
+
u = sophnet_tools.upload_oss(sys.argv[1], timeout=int(sys.argv[2]))
|
|
76
|
+
print(u if u else '')
|
|
77
|
+
" "$ABS_FILE_PATH" "$TIMEOUT" 2>/dev/null || true)"
|
|
78
|
+
|
|
79
|
+
if [[ -z "$signed_url" ]]; then
|
|
80
|
+
echo "FILE_PATH=$ABS_FILE_PATH"
|
|
81
|
+
echo "UPLOAD_STATUS=skipped"
|
|
82
|
+
echo "ERROR=upload_failed"
|
|
83
|
+
exit 0
|
|
84
|
+
fi
|
|
85
|
+
|
|
86
|
+
echo "FILE_PATH=$ABS_FILE_PATH"
|
|
87
|
+
echo "UPLOAD_STATUS=uploaded"
|
|
88
|
+
echo "DOWNLOAD_URL=$signed_url"
|