mirror of
https://github.com/TinyTapeout/tt-support-tools.git
synced 2026-11-03 04:36:09 +01:00
lint
This commit is contained in:
+7
-23
@@ -55,8 +55,8 @@ def fetch_file(url, filename):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def fetch_wokwi_file(wokwi_id:int, file_requested:str,
|
def fetch_wokwi_file(wokwi_id: int, file_requested: str,
|
||||||
destination_name:str = None):
|
destination_name: str = None):
|
||||||
'''
|
'''
|
||||||
fetch_wokwi_file -- perform a request on the wokwi api to
|
fetch_wokwi_file -- perform a request on the wokwi api to
|
||||||
retrieve a file from a given project.
|
retrieve a file from a given project.
|
||||||
@@ -73,16 +73,14 @@ def fetch_wokwi_file(wokwi_id:int, file_requested:str,
|
|||||||
return fetch_file(url, destination_name)
|
return fetch_file(url, destination_name)
|
||||||
|
|
||||||
|
|
||||||
def install_wokwi_testing(wokwi_id:int, destination_dir:str='src',
|
def install_wokwi_testing(wokwi_id: int, destination_dir: str = 'src',
|
||||||
resource_dir:str=None):
|
resource_dir: str = None):
|
||||||
|
|
||||||
wokwi_id_str = str(wokwi_id)
|
wokwi_id_str = str(wokwi_id)
|
||||||
#wokwi_user_module = f'user_module_{wokwi_'
|
|
||||||
|
|
||||||
if resource_dir is None or not len(resource_dir):
|
if resource_dir is None or not len(resource_dir):
|
||||||
resource_dir = os.path.join(os.path.dirname(__file__), 'testing')
|
resource_dir = os.path.join(os.path.dirname(__file__), 'testing')
|
||||||
|
|
||||||
|
|
||||||
# directories in testing/lib to copy over
|
# directories in testing/lib to copy over
|
||||||
pyLibsDir = os.path.join(resource_dir, 'lib')
|
pyLibsDir = os.path.join(resource_dir, 'lib')
|
||||||
|
|
||||||
@@ -96,9 +94,6 @@ def install_wokwi_testing(wokwi_id:int, destination_dir:str='src',
|
|||||||
os.path.join(destination_dir, os.path.basename(libfullpath)),
|
os.path.join(destination_dir, os.path.basename(libfullpath)),
|
||||||
dirs_exist_ok=True)
|
dirs_exist_ok=True)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for srcTemplate in glob.glob(os.path.join(srcTplDir, '*')):
|
for srcTemplate in glob.glob(os.path.join(srcTplDir, '*')):
|
||||||
with open(srcTemplate, 'r') as f:
|
with open(srcTemplate, 'r') as f:
|
||||||
contents = f.read()
|
contents = f.read()
|
||||||
@@ -110,11 +105,6 @@ def install_wokwi_testing(wokwi_id:int, destination_dir:str='src',
|
|||||||
outf.close()
|
outf.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_project_source(yaml):
|
def get_project_source(yaml):
|
||||||
# wokwi_id must be an int or 0
|
# wokwi_id must be an int or 0
|
||||||
try:
|
try:
|
||||||
@@ -126,26 +116,20 @@ def get_project_source(yaml):
|
|||||||
# it's a wokwi project
|
# it's a wokwi project
|
||||||
if wokwi_id != 0:
|
if wokwi_id != 0:
|
||||||
src_file = f'user_module_{wokwi_id}.v'
|
src_file = f'user_module_{wokwi_id}.v'
|
||||||
if not fetch_wokwi_file(wokwi_id, 'verilog',
|
if not fetch_wokwi_file(wokwi_id, 'verilog', os.path.join("src", src_file)):
|
||||||
os.path.join("src", src_file) ):
|
|
||||||
logging.error(f'Could not fetch verilog file for wokwi project {wokwi_id}')
|
logging.error(f'Could not fetch verilog file for wokwi project {wokwi_id}')
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
|
|
||||||
# also fetch the wokwi diagram
|
# also fetch the wokwi diagram
|
||||||
if not fetch_wokwi_file(wokwi_id, 'diagram.json',
|
if not fetch_wokwi_file(wokwi_id, 'diagram.json', os.path.join("src", 'wokwi_diagram.json')):
|
||||||
os.path.join("src", 'wokwi_diagram.json')):
|
|
||||||
logging.error(f'Could not fetch diagram.json file for wokwi project {wokwi_id}')
|
logging.error(f'Could not fetch diagram.json file for wokwi project {wokwi_id}')
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
|
|
||||||
# attempt to download the *optional* truthtable for the project
|
# attempt to download the *optional* truthtable for the project
|
||||||
if fetch_wokwi_file(wokwi_id, 'truthtable.md',
|
if fetch_wokwi_file(wokwi_id, 'truthtable.md', os.path.join('src', 'truthtable.md')):
|
||||||
os.path.join('src', 'truthtable.md')):
|
|
||||||
logging.info(f'Wokwi project {wokwi_id} has a truthtable included, will test!')
|
logging.info(f'Wokwi project {wokwi_id} has a truthtable included, will test!')
|
||||||
install_wokwi_testing(wokwi_id)
|
install_wokwi_testing(wokwi_id)
|
||||||
|
|
||||||
|
|
||||||
return [src_file, 'cells.v']
|
return [src_file, 'cells.v']
|
||||||
|
|
||||||
# else it's HDL, so check source files
|
# else it's HDL, so check source files
|
||||||
|
|||||||
+1
-1
@@ -63,7 +63,7 @@ if __name__ == '__main__':
|
|||||||
if args.print_warnings:
|
if args.print_warnings:
|
||||||
reports.print_warnings(args)
|
reports.print_warnings(args)
|
||||||
|
|
||||||
elif args.print_wokwi_id:
|
if args.print_wokwi_id:
|
||||||
project.print_wokwi_id(project_yaml)
|
project.print_wokwi_id(project_yaml)
|
||||||
|
|
||||||
if args.create_user_config:
|
if args.create_user_config:
|
||||||
|
|||||||
Reference in New Issue
Block a user