mirror of https://github.com/KLayout/klayout.git
Ignoring __pycache__ directories in macro editor
This feature can be configured by providing a colon-separated list of directory names to ignore in the $KLAYOUT_IGNORE_MACRO_DIRS env var.
This commit is contained in:
parent
3d0bb8516b
commit
3ddd2046c4
|
|
@ -38,6 +38,7 @@
|
|||
#include "tlProgress.h"
|
||||
#include "tlFileUtils.h"
|
||||
#include "tlResources.h"
|
||||
#include "tlEnv.h"
|
||||
|
||||
#include "rba.h"
|
||||
#include "pya.h"
|
||||
|
|
@ -363,6 +364,22 @@ namespace {
|
|||
}
|
||||
#endif
|
||||
|
||||
// Some directories are ignored in addition to dotfiles
|
||||
static bool dir_is_ignored (const std::string &dn)
|
||||
{
|
||||
static std::set <std::string> ignored;
|
||||
static bool initialized = false;
|
||||
|
||||
if (! initialized) {
|
||||
// a colon-separated list of directory names
|
||||
std::string ign = tl::get_env ("KLAYOUT_IGNORE_MACRO_DIRS", "__pycache__");
|
||||
auto ignv = tl::split (ign, ":");
|
||||
ignored.insert (ignv.begin (), ignv.end ());
|
||||
}
|
||||
|
||||
return ignored.find (dn) != ignored.end ();
|
||||
}
|
||||
|
||||
void MacroCollection::scan ()
|
||||
{
|
||||
std::string p = path ();
|
||||
|
|
@ -431,6 +448,10 @@ void MacroCollection::scan ()
|
|||
continue;
|
||||
}
|
||||
|
||||
if (dir_is_ignored (*f)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
MacroCollection *&mc = m_folders.insert (std::make_pair (*f, (MacroCollection *) 0)).first->second;
|
||||
|
|
|
|||
Loading…
Reference in New Issue