def minify(packages): locallatexdir = PPath("/usr/local/texlive/2020/texmf-dist") stdimports = defaultdict(list) print(f"{DECO}* Trying to analyze imports of the offical sty files") for stdsty in locallatexdir.walk("file::**.sty"): stdname = stdsty.stem if stdname in packages \ and stdname not in PACKAGE_ALREADY_ANALYZED: print(f"{DECO*2}- Looking inside the offical << {stdsty.name} >>") PACKAGE_ALREADY_ANALYZED.append(stdname) with stdsty.open(mode="r", encoding="utf-8") as stdfile: for oneline in stdfile.readlines(): oneline = oneline.strip() if not oneline: continue info = analyze(info=oneline, nobug=True) if info is None: continue if info[KIND_ID] == PACKAGE_ID: stdimports[stdname] += info[NAMES_ID] if stdname not in stdimports: stdimports[stdname] = [] # Local sty. localpackages = set(packages) - set(stdimports.keys()) # Let's minimize. somecleaningdone = True while (somecleaningdone): somecleaningdone = False for pack in stdimports: for _, itsimports in stdimports.items(): if pack in itsimports: somecleaningdone = True break if somecleaningdone: del stdimports[pack] break shortlist = list(stdimports) + list(localpackages) return sorted(shortlist)
ARGS = parser.parse_args() if not ARGS.norec: PPATH_PATTERNS += [f"file::**build-*.{ext}" for ext in EXT_2_CMDS] # -------------------------------------- # # -- LAUNCHING ALL THE BUILDING TOOLS -- # # -------------------------------------- # option2suffix = { lname[2:]: f"[{suffix}]" for suffix, (_, lname) in SUFFIX_CFG.items() } allpaths = [p for pattern in PPATH_PATTERNS for p in THIS_DIR.walk(pattern)] allpaths.sort() for onepath in allpaths: filename = (onepath - THIS_DIR).stem nolaunch = False for option, suffix in option2suffix.items(): if getattr(ARGS, option) \ and filename.endswith(suffix): print(f"- No suffix {suffix} : << {filename} >> ignored.") nolaunch = True
with open( file = THIS_DIR / "config" / "header[fr].sty", encoding = "utf-8" ) as headerfile: HEADER = headerfile.read().strip() # ---------------------- # # -- LOOKING FOR DOCS -- # # ---------------------- # CONTENTS = [] EXAMPLE_FILES = [] LATEXFILES = [] for subdir in THIS_DIR.walk("dir::"): subdir_name = str(subdir.name) subdir_str = str(subdir) if subdir_name in ["config", "style"] \ or "x-" in subdir_str: continue LATEXFILES += [ l for l in subdir.walk("file::*\[fr\].tex") if not l.stem.endswith("-nodoc[fr]") ] subdir_exa = subdir / "examples" EXAMPLE_FILES += [
from mistool.os_use import PPath # ----------------------- # # -- TOOLS & CONSTANTS -- # # ----------------------- # THIS_DIR = PPath(__file__).parent PROJECT_NAME = "tnsalgo" PROJECT_DIR = THIS_DIR.parent / f"{PROJECT_NAME}" # ----------------------- # # -- CLEAN BEFORE PUSH -- # # ----------------------- # for toremove in PROJECT_DIR.walk("dir::**_minted"): if toremove.name.startswith("_minted"): toremove.remove() for toremove in THIS_DIR.walk("file::**.macros-x.txt"): toremove.remove() for toremove in PROJECT_DIR.walk("file::*.macros-x.txt"): toremove.remove() for toremove in THIS_DIR.walk("file::**.pdf"): toremove.remove() for toremove in THIS_DIR.walk("dir::*"): latexclean(toremove)
#! /usr/bin/env python3 from mistool.latex_use import clean as latexclean from mistool.os_use import PPath # ----------------------- # # -- TOOLS & CONSTANTS -- # # ----------------------- # FACTORY_DIR = PPath(__file__).parent LYXAM_DIR = FACTORY_DIR.parent / "lyalgo" # ----------------------- # # -- CLEAN BEFORE PUSH -- # # ----------------------- # for toremove in FACTORY_DIR.walk("file::**.macros-x.txt"): toremove.remove() for toremove in LYXAM_DIR.walk("file::*.macros-x.txt"): toremove.remove() for toremove in FACTORY_DIR.walk("file::**.pdf"): toremove.remove() for toremove in FACTORY_DIR.walk("dir::*"): latexclean(toremove)
DIRVIEW_CLASS = term_use.DirView # --------------------------------------- # # -- THE_DATAS_FOR_TESTING FOR TESTING -- # # --------------------------------------- # VIRTUAL_DIR = THIS_DIR while VIRTUAL_DIR.name != "test": VIRTUAL_DIR = VIRTUAL_DIR.parent VIRTUAL_DIR /= "virtual_dir" THE_DATAS_FOR_TESTING = OrderedDict() for ppath in THIS_DIR.walk(regpath="file::**.txt"): THE_DATAS_FOR_TESTING["{0} [{1}]".format( ppath.stem, ppath.parent.stem)] = READ(content=ppath, mode={ "keyval:: =": "gene", "verbatim": ["ascii", "latex", "toc", "tree"] }) @fixture(scope="module") def or_datas(request): for name, allinfos in THE_DATAS_FOR_TESTING.items(): allinfos.build()
runthis( cmd = "py.test -v --resultlog=x-pytest_log-x.txt", showoutput = True ) except Exception as e: tests_passed = False # ---------------------------------------- # # -- LAUNCHING ALL THE "HUMAN CHECKING" -- # # ---------------------------------------- # printtile("Launching the scripts producing infos to be checked by a human...") for onepath in THIS_DIR.walk("file::human_checking/**.py"): print(' + "{0}" executed.'.format(onepath.name)) runthis( cmd = 'python "{0}"'.format(onepath), showoutput = True ) # ---------------------- # # -- UPDATING THE LOG -- # # ---------------------- # printtile("Updating the log file...") if tests_passed:
# --------------------------------------- # # -- THE_DATAS_FOR_TESTING FOR TESTING -- # # --------------------------------------- # VIRTUAL_DIR = THIS_DIR while VIRTUAL_DIR.name != "test": VIRTUAL_DIR = VIRTUAL_DIR.parent VIRTUAL_DIR /= "virtual_dir" THE_DATAS_FOR_TESTING = OrderedDict() for ppath in THIS_DIR.walk(regpath = "file::**.txt"): THE_DATAS_FOR_TESTING[ "{0} [{1}]".format(ppath.stem, ppath.parent.stem) ] = READ( content = ppath, mode = { "keyval:: =": "gene", "verbatim" : ["ascii", "latex", "toc", "tree"] } ) @fixture(scope="module") def or_datas(request): for name, allinfos in THE_DATAS_FOR_TESTING.items(): allinfos.build()