_example_ update
This commit is contained in:
parent
877c434ccb
commit
d6551e1ff2
@ -1,20 +1,30 @@
|
||||
EXAMPLES = $(wildcard *.py)
|
||||
FIRSTLOGS = ${EXAMPLES:.py=_1.log}
|
||||
LASTLOGS = ${EXAMPLES:.py=_2.log}
|
||||
# pylibs examples Makefile: Version 1.0 (2025-08-15)
|
||||
|
||||
.ONESHELL:
|
||||
SHELL = /usr/bin/bash
|
||||
MAKEFLAGS += --no-print-directory
|
||||
.SILENT:
|
||||
|
||||
INTERPRETER = python3
|
||||
|
||||
.PHONY: all
|
||||
.SECONDAY: $(FIRSTLOGS)
|
||||
EXAMPLES := $(wildcard *.py)
|
||||
EXAMPLES := $(filter-out config.py, $(EXAMPLES))
|
||||
LOGFILES := ${EXAMPLES:.py=.log}
|
||||
|
||||
all: $(LASTLOGS)
|
||||
all: $(LOGFILES)
|
||||
|
||||
%_1.log: %.py
|
||||
rm -f *.json *.pickle
|
||||
python3 $< > $@
|
||||
-include __make.d__/*.mk
|
||||
|
||||
%_2.log: %.py %_1.log
|
||||
python3 $< > $@
|
||||
rm -f *.json *.pickle
|
||||
%.py_local:
|
||||
|
||||
%.log: %.py
|
||||
$(MAKE) $<_local
|
||||
echo -e "\e[1m * Running example $<\e[0m"
|
||||
$(INTERPRETER) $< > $@
|
||||
|
||||
localclean:
|
||||
clean: localclean
|
||||
echo -e "\e[1m * Example logs...\e[0m"
|
||||
rm -f $(LOGFILES)
|
||||
|
||||
clean:
|
||||
@echo "\e[1m * Example logs...\e[0m"
|
||||
@rm -f $(FIRSTLOGS) $(LASTLOGS) *.json *.pickle
|
||||
|
9
_examples_/__make.d__/clean.mk
Normal file
9
_examples_/__make.d__/clean.mk
Normal file
@ -0,0 +1,9 @@
|
||||
.ONESHELL:
|
||||
SHELL = /usr/bin/bash
|
||||
MAKEFLAGS += --no-print-directory
|
||||
.SILENT:
|
||||
|
||||
localclean:
|
||||
echo -e "\e[1m * Example cache files...\e[0m"
|
||||
rm -f cache.json cache.pickle
|
||||
|
@ -1 +0,0 @@
|
||||
..
|
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: UTF-8 -*-
|
||||
import sys # nopep8
|
||||
sys.path.append('../..') # nopep8
|
||||
|
||||
import caching
|
||||
import logging
|
||||
@ -55,6 +55,7 @@ class test_slow_data(object):
|
||||
self.print_n_sleep("__five__")
|
||||
return 'five'
|
||||
|
||||
|
||||
class test_slow_data_cached(test_slow_data):
|
||||
def __init__(self, *args, **kwargs) -> None:
|
||||
super().__init__(*args, **kwargs)
|
||||
@ -79,4 +80,3 @@ if __name__ == "__main__":
|
||||
for key in data.keys():
|
||||
print(data.get(key))
|
||||
print('--------------------------------\nThe execution time was %.1fs' % (time.time()-tm))
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: UTF-8 -*-
|
||||
import sys # nopep8
|
||||
sys.path.append('../..') # nopep8
|
||||
|
||||
import caching
|
||||
import logging
|
||||
@ -55,6 +55,7 @@ class test_slow_data(object):
|
||||
self.print_n_sleep("__five__")
|
||||
return 'five'
|
||||
|
||||
|
||||
class test_slow_data_cached(test_slow_data):
|
||||
def __init__(self, *args, **kwargs) -> None:
|
||||
super().__init__(*args, **kwargs)
|
||||
|
Loading…
x
Reference in New Issue
Block a user