1
Fork 0
mirror of https://github.com/thegeneralist01/twitter-openapi synced 2026-01-11 15:40:26 +01:00
Signed-off-by: ふぁ <yuki@yuki0311.com>
This commit is contained in:
ふぁ 2023-09-15 12:19:21 +09:00
parent 49bfd77799
commit 0536aba4f4
No known key found for this signature in database
GPG key ID: 83A8A5E74872A8AA
3 changed files with 26 additions and 13 deletions

View file

@ -40,8 +40,7 @@ components:
itemContent:
$ref: "#/components/schemas/ItemContentUnion"
clientEventInfo:
type: object
additionalProperties: true # todo
$ref: "#/components/schemas/ClientEventInfo"
feedbackInfo:
type: object
additionalProperties: true # todo
@ -113,8 +112,7 @@ components:
- "itemContent"
properties:
clientEventInfo:
type: object
additionalProperties: true # todo
$ref: "#/components/schemas/ClientEventInfo"
itemContent:
$ref: "#/components/schemas/ItemContentUnion"
@ -229,4 +227,6 @@ components:
type: string # enum half_cover
element:
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]+$"

View file

@ -267,7 +267,7 @@ components:
items:
$ref: "#/components/schemas/Callback"
clientEventInfo:
$ref: "#/components/schemas/ClientEventInfo"
$ref: "#/components/schemas/CtaClientEventInfo"
buttonStyle:
type: string
enum: ["Primary"]
@ -286,9 +286,10 @@ components:
properties:
endpoint:
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}
ClientEventInfo:
CtaClientEventInfo:
required:
- action
properties:

View file

@ -8,6 +8,7 @@ import time
import glob
import aenum
import concurrent.futures
import traceback
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)
def task_callback(file):
def task_callback(file, thread=True):
try:
with open(file, "r") as f:
cache = json.load(f)
data = pt.__dict__[cache["type"]].from_json(cache["raw"])
rate = match_rate(data.to_dict(), json.loads(cache["raw"]))
return f"Match rate: {rate}"
return {rate}, {file}
except Exception as e:
return f"Error: {e} {file}"
if thread:
return 0, {file}
else:
raise
def error_dump(e):
if ERROR_UNCATCHED:
raise
import traceback
logger.error("==========[STACK TRACE]==========")
for trace in traceback.format_exc().split("\n"):
@ -146,12 +149,21 @@ if __name__ == "__main__":
with open("src/config/placeholder.json", "r") as f:
placeholder = json.load(f)
fail = []
with concurrent.futures.ProcessPoolExecutor() as executor:
tasks = [executor.submit(task_callback, x) for x in glob.glob("cache/*.json")]
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_key={