aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/portage/_sets/__init__.py')
-rw-r--r--lib/portage/_sets/__init__.py50
1 files changed, 29 insertions, 21 deletions
diff --git a/lib/portage/_sets/__init__.py b/lib/portage/_sets/__init__.py
index 15f942b10..295a1e353 100644
--- a/lib/portage/_sets/__init__.py
+++ b/lib/portage/_sets/__init__.py
@@ -9,9 +9,6 @@ __all__ = [
"load_default_config",
]
-import io
-import logging
-import sys
import portage
from portage import os
from portage import load_mod
@@ -181,7 +178,7 @@ class SetConfig:
import random
while setname in parser.sections():
- setname = "%08d" % random.randint(0, 10 ** 10)
+ setname = "%08d" % random.randint(0, 10**10)
parser.add_section(setname)
for k, v in options.items():
@@ -342,7 +339,6 @@ class SetConfig:
def load_default_config(settings, trees):
-
if not _ENABLE_SET_CONFIG:
return SetConfig(None, settings, trees)
@@ -354,21 +350,33 @@ def load_default_config(settings, trees):
vcs_dirs = [_unicode_encode(x, encoding=_encodings["fs"]) for x in VCS_DIRS]
def _getfiles():
- for path, dirs, files in os.walk(os.path.join(global_config_path, "sets")):
- for d in dirs:
- if d in vcs_dirs or d.startswith(b".") or d.endswith(b"~"):
- dirs.remove(d)
- for f in files:
- if not f.startswith(b".") and not f.endswith(b"~"):
- yield os.path.join(path, f)
-
- dbapi = trees["porttree"].dbapi
- for repo in dbapi.getRepositories():
- path = dbapi.getRepositoryPath(repo)
- yield os.path.join(path, "sets.conf")
-
- yield os.path.join(
- settings["PORTAGE_CONFIGROOT"], USER_CONFIG_PATH, "sets.conf"
- )
+ sets_config_paths = [
+ os.path.join(global_config_path, "sets"),
+ *(
+ os.path.join(repo.location, "sets.conf")
+ for repo in trees["porttree"].dbapi.repositories
+ ),
+ os.path.join(settings["PORTAGE_CONFIGROOT"], USER_CONFIG_PATH, "sets.conf"),
+ ]
+
+ dot = "."
+ tilde = "~"
+ if not portage.utf8_mode:
+ dot = _unicode_encode(dot)
+ tilde = _unicode_encode(tilde)
+
+ for sets_config_path in sets_config_paths:
+ if os.path.isdir(sets_config_path):
+ for path, dirs, files in os.walk(sets_config_path):
+ dirs.sort()
+ files.sort()
+ for d in dirs:
+ if d in vcs_dirs or d.startswith(dot) or d.endswith(tilde):
+ dirs.remove(d)
+ for f in files:
+ if not f.startswith(dot) and not f.endswith(tilde):
+ yield os.path.join(path, f)
+ elif os.path.isfile(sets_config_path):
+ yield sets_config_path
return SetConfig(_getfiles(), settings, trees)