[+] POPO generator
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env python3
|
||||
import json
|
||||
from pathlib import Path
|
||||
from sys import argv
|
||||
|
||||
|
||||
NUM = 1
|
||||
|
||||
|
||||
def transform_obj(obj: dict) -> str:
|
||||
global NUM
|
||||
|
||||
output = {}
|
||||
|
||||
for k, v in obj.items():
|
||||
if isinstance(v, dict):
|
||||
output[k] = transform_obj(v)
|
||||
|
||||
elif isinstance(v, list):
|
||||
if len(v) == 0:
|
||||
output[k] = 'list'
|
||||
elif isinstance(v[0], dict):
|
||||
output[k] = f'list[{transform_obj(v[0])}]'
|
||||
else:
|
||||
output[k] = f'list[{type(v[0])}]'
|
||||
|
||||
else:
|
||||
output[k] = type(v).__name__
|
||||
|
||||
name = f'Type{NUM}'
|
||||
NUM += 1
|
||||
|
||||
print(f'class {name}:' + ''.join(f'\n {k}: {v}' for k, v in output.items()))
|
||||
print()
|
||||
|
||||
return name
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
file = Path(argv[1])
|
||||
|
||||
obj = json.loads(file.read_text())
|
||||
transform_obj(obj)
|
||||
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from dataclasses import dataclass, field
|
||||
from types import SimpleNamespace
|
||||
from enum import Enum
|
||||
from typing import Optional, List, Any, Union
|
||||
@@ -38,6 +39,67 @@ class LoginData:
|
||||
currencyCode: str
|
||||
|
||||
|
||||
class TaobaoStore:
|
||||
name: str
|
||||
url: str
|
||||
|
||||
|
||||
class TaobaoItem:
|
||||
name: str
|
||||
url: str
|
||||
promises: list[str]
|
||||
price: str
|
||||
qty: str
|
||||
origPrice: str | None = None
|
||||
sel: list[tuple[str, str]] | None = None
|
||||
|
||||
|
||||
class TaobaoOrder:
|
||||
id: str
|
||||
date: str
|
||||
store: TaobaoStore
|
||||
items: list[TaobaoItem]
|
||||
priceTotal: str
|
||||
priceDelivery: str
|
||||
status: str
|
||||
delivery: dict
|
||||
|
||||
|
||||
@dataclass
|
||||
class CreateOrder:
|
||||
diybuyUserRemark: str
|
||||
shopId: str
|
||||
shopName: str
|
||||
goodsList: list[CreateGood]
|
||||
goodsPrefix: str = 'TB'
|
||||
guaranteeFlag: int = 0
|
||||
|
||||
|
||||
@dataclass
|
||||
class CreateGood:
|
||||
desc: str
|
||||
goodsId: str
|
||||
inventory: int
|
||||
name: str
|
||||
num: int
|
||||
shopName: str
|
||||
shopUrl: str
|
||||
skus: str
|
||||
totalPrice: float
|
||||
url: str
|
||||
riskinfor: list = field(default_factory=list)
|
||||
prifex: str = "TB"
|
||||
protips: str = ''
|
||||
remark: str = '自助购物'
|
||||
thumb: str = 'https://a-z-animals.com/media/2021/11/sunny-cat-picture-id508030340-1024x535.jpg'
|
||||
warehouseId: int = 1
|
||||
takeOutInvoice: int = 1
|
||||
openPackaging: int = 1
|
||||
needCheck: int = 1
|
||||
checkedContraband: int = 1
|
||||
samplingInspection: int = 0
|
||||
|
||||
|
||||
class Currency(Enum):
|
||||
"""
|
||||
For https://front.superbuy.com/package/parcel/app-list
|
||||
|
||||
Reference in New Issue
Block a user