2021-10-10 15:37:39 +08:00
|
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
|
|
# python3 -m pip install pandas, lxml, html5lib
|
|
|
|
|
import sys
|
|
|
|
|
import pandas as pd
|
|
|
|
|
import requests
|
2021-10-10 21:33:23 +08:00
|
|
|
|
import re
|
2021-10-10 15:37:39 +08:00
|
|
|
|
|
|
|
|
|
ATR_URL = 'https://www.eftlab.co.uk/knowledge-base/171-atr-list-full/'
|
|
|
|
|
|
|
|
|
|
def print_atr(df):
|
|
|
|
|
for i in df.index:
|
|
|
|
|
|
|
|
|
|
a = df['atr'][i];
|
|
|
|
|
b = df['desc'][i];
|
|
|
|
|
|
|
|
|
|
if type(a) is not str or type(b) is not str:
|
|
|
|
|
continue
|
2021-10-10 21:33:23 +08:00
|
|
|
|
|
2021-10-10 15:37:39 +08:00
|
|
|
|
a = a.replace(' ','')
|
2021-10-10 21:33:23 +08:00
|
|
|
|
a = a.replace('…', '..')
|
2021-10-10 15:37:39 +08:00
|
|
|
|
|
|
|
|
|
if (len(a) == 0 or len(b) == 0):
|
|
|
|
|
continue
|
|
|
|
|
|
2021-10-10 21:33:23 +08:00
|
|
|
|
|
|
|
|
|
b = b.replace('\\', '\\\\')
|
|
|
|
|
b = b.replace('’', '\'')
|
|
|
|
|
b = b.replace('‘', '\'')
|
|
|
|
|
b = b.replace('“', '\'')
|
|
|
|
|
b = b.replace('”', '\'')
|
|
|
|
|
b = b.replace('ó', 'o')
|
|
|
|
|
b = b.replace('ú', 'u')
|
|
|
|
|
b = b.replace('–', '-')
|
|
|
|
|
b = b.replace('—', '-')
|
|
|
|
|
b = b.replace('€', '')
|
|
|
|
|
b = b.replace('Č', 'C')
|
|
|
|
|
b = b.replace('á', 'a')
|
|
|
|
|
b = b.replace('ř', 'r')
|
|
|
|
|
b = b.replace('ę', 'e')
|
|
|
|
|
b = b.replace('ł', 'l')
|
|
|
|
|
b = b.replace('İ', 'I')
|
|
|
|
|
b = b.replace('…', '...')
|
|
|
|
|
|
|
|
|
|
#b = re.sub('[^A-Za-zs ]+', '', b)
|
2021-10-10 15:37:39 +08:00
|
|
|
|
|
|
|
|
|
print(f' {{ "{a}", "{b}" }},')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
2021-10-10 21:33:23 +08:00
|
|
|
|
|
|
|
|
|
# making sure we print UTF-8
|
|
|
|
|
sys.stdout = open(1, 'w', encoding='utf-8', closefd=False)
|
|
|
|
|
|
2021-10-10 15:37:39 +08:00
|
|
|
|
r = requests.get(ATR_URL)
|
|
|
|
|
r.status_code
|
|
|
|
|
list_atr = pd.read_html(r.text, header=0, keep_default_na=False)
|
|
|
|
|
df = list_atr[0]
|
|
|
|
|
df.columns = ['atr', 'desc']
|
|
|
|
|
df = df.astype('string')
|
|
|
|
|
|
|
|
|
|
print(
|
|
|
|
|
"""#ifndef ATRS_H__
|
2021-10-10 17:45:43 +08:00
|
|
|
|
|
2021-10-10 18:31:03 +08:00
|
|
|
|
#define ATRS_H__
|
2021-10-10 15:37:39 +08:00
|
|
|
|
|
2021-10-10 18:31:03 +08:00
|
|
|
|
#include <stddef.h>
|
2021-10-10 15:37:39 +08:00
|
|
|
|
|
2021-10-10 18:31:03 +08:00
|
|
|
|
typedef struct atr_s {
|
|
|
|
|
const char *bytes;
|
|
|
|
|
const char *desc;
|
|
|
|
|
} atr_t;
|
2021-10-10 15:37:39 +08:00
|
|
|
|
|
2021-10-10 18:31:03 +08:00
|
|
|
|
const char *getAtrInfo(const char *atr_str);
|
2021-10-10 15:37:39 +08:00
|
|
|
|
|
2021-10-10 18:31:03 +08:00
|
|
|
|
// atr_t array are expected to be NULL terminated
|
2021-10-10 22:15:29 +08:00
|
|
|
|
const static atr_t AtrTable[] = {
|
|
|
|
|
{ "3BDF18FFC080B1FE751F033078464646462026204963656D616E1D", "Cardhelper by 0xFFFF and Iceman" },""")
|
2021-10-10 15:37:39 +08:00
|
|
|
|
|
|
|
|
|
print_atr(df)
|
|
|
|
|
|
2021-10-10 22:15:29 +08:00
|
|
|
|
print(""" {NULL, "N/A"}
|
2021-10-10 18:31:03 +08:00
|
|
|
|
};
|
2021-10-10 15:37:39 +08:00
|
|
|
|
|
2021-10-10 18:31:03 +08:00
|
|
|
|
#endif""")
|
2021-10-10 15:37:39 +08:00
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
main()
|