mirror of
https://github.com/thegeneralist01/twitter-openapi
synced 2026-01-11 15:40:26 +01:00
wip
Signed-off-by: ふぁ <yuki@yuki0311.com>
This commit is contained in:
parent
49bfd77799
commit
0536aba4f4
3 changed files with 26 additions and 13 deletions
|
|
@ -40,8 +40,7 @@ components:
|
||||||
itemContent:
|
itemContent:
|
||||||
$ref: "#/components/schemas/ItemContentUnion"
|
$ref: "#/components/schemas/ItemContentUnion"
|
||||||
clientEventInfo:
|
clientEventInfo:
|
||||||
type: object
|
$ref: "#/components/schemas/ClientEventInfo"
|
||||||
additionalProperties: true # todo
|
|
||||||
feedbackInfo:
|
feedbackInfo:
|
||||||
type: object
|
type: object
|
||||||
additionalProperties: true # todo
|
additionalProperties: true # todo
|
||||||
|
|
@ -113,8 +112,7 @@ components:
|
||||||
- "itemContent"
|
- "itemContent"
|
||||||
properties:
|
properties:
|
||||||
clientEventInfo:
|
clientEventInfo:
|
||||||
type: object
|
$ref: "#/components/schemas/ClientEventInfo"
|
||||||
additionalProperties: true # todo
|
|
||||||
itemContent:
|
itemContent:
|
||||||
$ref: "#/components/schemas/ItemContentUnion"
|
$ref: "#/components/schemas/ItemContentUnion"
|
||||||
|
|
||||||
|
|
@ -229,4 +227,6 @@ components:
|
||||||
type: string # enum half_cover
|
type: string # enum half_cover
|
||||||
element:
|
element:
|
||||||
type: string
|
type: string
|
||||||
pattern: "^(january|february|march|april|may|june|july|august|september|october|november|december)-[0-9]{4}-([a-z]-)+[a-z]+$" # august-2023-privacy-prompt-candidate
|
# august-2023-privacy-prompt-candidate
|
||||||
|
pattern: "(([a-z]+|[0-9]+|[0-9a-f]+)(-|$))+"
|
||||||
|
# pattern: "^(january|february|march|april|may|june|july|august|september|october|november|december)-[0-9]{4}-([a-z]-)+[a-z]+$"
|
||||||
|
|
|
||||||
|
|
@ -267,7 +267,7 @@ components:
|
||||||
items:
|
items:
|
||||||
$ref: "#/components/schemas/Callback"
|
$ref: "#/components/schemas/Callback"
|
||||||
clientEventInfo:
|
clientEventInfo:
|
||||||
$ref: "#/components/schemas/ClientEventInfo"
|
$ref: "#/components/schemas/CtaClientEventInfo"
|
||||||
buttonStyle:
|
buttonStyle:
|
||||||
type: string
|
type: string
|
||||||
enum: ["Primary"]
|
enum: ["Primary"]
|
||||||
|
|
@ -286,9 +286,10 @@ components:
|
||||||
properties:
|
properties:
|
||||||
endpoint:
|
endpoint:
|
||||||
type: string
|
type: string
|
||||||
|
format: uri
|
||||||
# pattern: '^/1\.1/[a-z]+/[a-z]+\.json\?[a-z_]+=[a-z0-9-]+(&[a-z_]+=[a-z0-9-]+)+?$' #/1.1/onboarding/fatigue.json?{params}
|
# pattern: '^/1\.1/[a-z]+/[a-z]+\.json\?[a-z_]+=[a-z0-9-]+(&[a-z_]+=[a-z0-9-]+)+?$' #/1.1/onboarding/fatigue.json?{params}
|
||||||
|
|
||||||
ClientEventInfo:
|
CtaClientEventInfo:
|
||||||
required:
|
required:
|
||||||
- action
|
- action
|
||||||
properties:
|
properties:
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import time
|
||||||
import glob
|
import glob
|
||||||
import aenum
|
import aenum
|
||||||
import concurrent.futures
|
import concurrent.futures
|
||||||
|
import traceback
|
||||||
|
|
||||||
|
|
||||||
logging.basicConfig(level=logging.DEBUG, format="%(asctime)s %(levelname)s %(message)s")
|
logging.basicConfig(level=logging.DEBUG, format="%(asctime)s %(levelname)s %(message)s")
|
||||||
|
|
@ -106,21 +107,23 @@ def save_cache(data):
|
||||||
json.dump(data, f, indent=4)
|
json.dump(data, f, indent=4)
|
||||||
|
|
||||||
|
|
||||||
def task_callback(file):
|
def task_callback(file, thread=True):
|
||||||
try:
|
try:
|
||||||
with open(file, "r") as f:
|
with open(file, "r") as f:
|
||||||
cache = json.load(f)
|
cache = json.load(f)
|
||||||
data = pt.__dict__[cache["type"]].from_json(cache["raw"])
|
data = pt.__dict__[cache["type"]].from_json(cache["raw"])
|
||||||
rate = match_rate(data.to_dict(), json.loads(cache["raw"]))
|
rate = match_rate(data.to_dict(), json.loads(cache["raw"]))
|
||||||
return f"Match rate: {rate}"
|
return {rate}, {file}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return f"Error: {e} {file}"
|
if thread:
|
||||||
|
return 0, {file}
|
||||||
|
else:
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
def error_dump(e):
|
def error_dump(e):
|
||||||
if ERROR_UNCATCHED:
|
if ERROR_UNCATCHED:
|
||||||
raise
|
raise
|
||||||
import traceback
|
|
||||||
|
|
||||||
logger.error("==========[STACK TRACE]==========")
|
logger.error("==========[STACK TRACE]==========")
|
||||||
for trace in traceback.format_exc().split("\n"):
|
for trace in traceback.format_exc().split("\n"):
|
||||||
|
|
@ -146,12 +149,21 @@ if __name__ == "__main__":
|
||||||
with open("src/config/placeholder.json", "r") as f:
|
with open("src/config/placeholder.json", "r") as f:
|
||||||
placeholder = json.load(f)
|
placeholder = json.load(f)
|
||||||
|
|
||||||
|
fail = []
|
||||||
with concurrent.futures.ProcessPoolExecutor() as executor:
|
with concurrent.futures.ProcessPoolExecutor() as executor:
|
||||||
tasks = [executor.submit(task_callback, x) for x in glob.glob("cache/*.json")]
|
tasks = [executor.submit(task_callback, x) for x in glob.glob("cache/*.json")]
|
||||||
for task in concurrent.futures.as_completed(tasks):
|
for task in concurrent.futures.as_completed(tasks):
|
||||||
logger.info(task.result())
|
rate, file = [list(x).pop() for x in task.result()]
|
||||||
|
print(rate, file)
|
||||||
|
if rate < 1:
|
||||||
|
fail.append(file)
|
||||||
|
logger.info(f"Match rate: {rate}")
|
||||||
|
|
||||||
logger.info(f"Success: {len(glob.glob('cache/*.json'))}")
|
logger.info(f"Fail: {len(fail)} / {len(glob.glob('cache/*.json'))}")
|
||||||
|
|
||||||
|
for file in fail:
|
||||||
|
task_callback(file, thread=False)
|
||||||
|
logger.info(f"Match rate: {rate}")
|
||||||
|
|
||||||
api_conf = pt.Configuration(
|
api_conf = pt.Configuration(
|
||||||
api_key={
|
api_key={
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue