Skip to content
Open
Changes from all commits
Commits
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
48 changes: 48 additions & 0 deletions fix_5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import json
import hashlib
import time
from datetime import datetime

class LongHunAdapter:
def __init__(self, uid="9622", device="HM-9622-001"):
self.uid = uid
self.device = device

def wrap(self, data, task_type="default", persona="P04"):
wrapped_data = {
"uid": self.uid,
"device": self.device,
"task_type": task_type,
"persona": persona,
"data": data,
"timestamp": int(time.time())
}
return wrapped_data

def validate(self, wrapped):
required_fields = ["uid", "device", "task_type", "persona", "data", "timestamp"]
for field in required_fields:
if field not in wrapped:
return False
return True

def schemas(self):
return {
"uid": "string",
"device": "string",
"task_type": "string",
"persona": "string",
"data": "object",
"timestamp": "integer"
}

def main():
adapter = LongHunAdapter()
data = {"key": "value"}
wrapped_data = adapter.wrap(data)
print(json.dumps(wrapped_data, indent=4))
print(adapter.validate(wrapped_data))
print(adapter.schemas())

if __name__ == "__main__":
main()