diff --git a/_examples_/Makefile b/_examples_/Makefile index 1621f5b..9aea2b0 100644 --- a/_examples_/Makefile +++ b/_examples_/Makefile @@ -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 diff --git a/_examples_/__make.d__/clean.mk b/_examples_/__make.d__/clean.mk new file mode 100644 index 0000000..8ab1f32 --- /dev/null +++ b/_examples_/__make.d__/clean.mk @@ -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 + diff --git a/_examples_/caching b/_examples_/caching deleted file mode 120000 index a96aa0e..0000000 --- a/_examples_/caching +++ /dev/null @@ -1 +0,0 @@ -.. \ No newline at end of file diff --git a/_examples_/property_cache_json.py b/_examples_/property_cache_json.py index 536532f..2ea20e4 100644 --- a/_examples_/property_cache_json.py +++ b/_examples_/property_cache_json.py @@ -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)) - diff --git a/_examples_/property_cache_pickle.py b/_examples_/property_cache_pickle.py index e07a7bb..3cc688f 100644 --- a/_examples_/property_cache_pickle.py +++ b/_examples_/property_cache_pickle.py @@ -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)