mirror of
ssh://git.janware.com/janware/proj/jw-pkg
synced 2026-04-24 17:23:36 +02:00
CmdBuild: Don't use App.res_cache()
App.res_cache should be private. It's needed here to cache the results of a function which is private to CmdBuild anyway, so solve that with lru_cache, to allow App to do it's private thing with caching. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
eafed6434b
commit
917f56a814
1 changed files with 3 additions and 4 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import os, re, sys, subprocess, datetime, time
|
import os, re, sys, subprocess, datetime, time
|
||||||
from argparse import Namespace, ArgumentParser
|
from argparse import Namespace, ArgumentParser
|
||||||
|
from functools import lru_cache
|
||||||
|
|
||||||
from ...lib.log import *
|
from ...lib.log import *
|
||||||
from ..Cmd import Cmd
|
from ..Cmd import Cmd
|
||||||
|
|
@ -25,6 +26,7 @@ class CmdBuild(Cmd): # export
|
||||||
|
|
||||||
def _run(self, args: Namespace) -> None:
|
def _run(self, args: Namespace) -> None:
|
||||||
|
|
||||||
|
@lru_cache(maxsize=None)
|
||||||
def read_deps(cur, prereq_type):
|
def read_deps(cur, prereq_type):
|
||||||
# dep cache doesn't make a difference at all
|
# dep cache doesn't make a difference at all
|
||||||
if prereq_type in dep_cache:
|
if prereq_type in dep_cache:
|
||||||
|
|
@ -42,9 +44,6 @@ class CmdBuild(Cmd): # export
|
||||||
dep_cache[prereq_type][cur] = ret
|
dep_cache[prereq_type][cur] = ret
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def read_deps_cached(cur, prereq_type):
|
|
||||||
return self.app.res_cache.run(read_deps, [ cur, prereq_type ])
|
|
||||||
|
|
||||||
def add_dep_tree(cur, prereq_types, tree, all_deps):
|
def add_dep_tree(cur, prereq_types, tree, all_deps):
|
||||||
log(DEBUG, "adding prerequisites " + ' '.join(prereq_types) + " of module " + cur)
|
log(DEBUG, "adding prerequisites " + ' '.join(prereq_types) + " of module " + cur)
|
||||||
if cur in all_deps:
|
if cur in all_deps:
|
||||||
|
|
@ -54,7 +53,7 @@ class CmdBuild(Cmd): # export
|
||||||
all_deps.add(cur)
|
all_deps.add(cur)
|
||||||
for t in prereq_types:
|
for t in prereq_types:
|
||||||
log(DEBUG, "checking prereqisites of type " + t)
|
log(DEBUG, "checking prereqisites of type " + t)
|
||||||
deps.update(read_deps_cached(cur, t))
|
deps.update(read_deps(cur, t))
|
||||||
for d in deps:
|
for d in deps:
|
||||||
add_dep_tree(d, prereq_types, tree, all_deps)
|
add_dep_tree(d, prereq_types, tree, all_deps)
|
||||||
tree[cur] = deps
|
tree[cur] = deps
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue