Created
October 9, 2021 16:31
-
-
Save iceman1001/0ef4a16c486ae2dcfe8ebc135ea1ecba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# python3 -m pip install pandas, lxml, html5lib | |
import sys | |
import pandas as pd | |
import requests | |
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]; | |
a = a.replace(' ','') | |
b = df['desc'][i]; | |
b = b.replace(' ','') | |
print(a) | |
#print(f' {{ " {a} ", " {b} " }},') | |
def main(): | |
r = requests.get(ATR_URL) | |
r.status_code | |
list_atr = pd.read_html(r.text, header=0) | |
df = list_atr[0] | |
df.columns = ['atr', 'desc'] | |
df = df.astype('string') | |
print( | |
"""#ifndef ATRS_H__ | |
#define ATRS_H__ | |
typedef struct atr_s { | |
const char *bytes; | |
const char *desc; | |
} atr_t; | |
// atr_t array are expected to be NULL terminated | |
static atr_t AtrTable[] = {""") | |
print_atr(df) | |
print(""" {NULL, NULL} | |
}; | |
#endif""") | |
if __name__ == "__main__": | |
main() |
doegox
commented
Oct 9, 2021
aaaaa, awesome!
I pushed a first draft of the atr lookup.
There is two special cases, one with dots. and one with [1-5] (where 1-2 is numbers valid for that pos)
I handle the first special case. Not the second yet.
maybe refactor it to use regex instead....
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment