commit:     9e7fda6c40a3588d56aae74c6b769d5c651fe890
Author:     Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org>
AuthorDate: Wed Dec 10 20:06:54 2014 +0000
Commit:     Arfrever Frehtes Taifersar Arahesis <arfrever <AT> apache <DOT> org>
CommitDate: Wed Dec 10 20:06:54 2014 +0000
URL:        
http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=9e7fda6c

Update loading of configuration of sets.

- Ignore VCS directories.
- Ignore directories and files whose names start with "." or end with "~".
- Fix "BytesWarning: Comparison between bytes and string", which was occurring
  when any directory in /etc/portage/sets exists.

---
 pym/portage/_sets/__init__.py | 9 +++++++--
 pym/portage/_sets/files.py    | 9 +++++----
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/pym/portage/_sets/__init__.py b/pym/portage/_sets/__init__.py
index a652227..5e4a9dc 100644
--- a/pym/portage/_sets/__init__.py
+++ b/pym/portage/_sets/__init__.py
@@ -1,4 +1,4 @@
-# Copyright 2007-2012 Gentoo Foundation
+# Copyright 2007-2014 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from __future__ import print_function
@@ -24,6 +24,7 @@ from portage import _unicode_decode
 from portage import _unicode_encode
 from portage import _encodings
 from portage.const import USER_CONFIG_PATH, GLOBAL_CONFIG_PATH
+from portage.const import VCS_DIRS
 from portage.const import _ENABLE_SET_CONFIG
 from portage.exception import PackageSetNotFound
 from portage.localization import _
@@ -307,10 +308,14 @@ def load_default_config(settings, trees):
        if portage.const.EPREFIX:
                global_config_path = os.path.join(portage.const.EPREFIX,
                        GLOBAL_CONFIG_PATH.lstrip(os.sep))
+       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'.'):
+                               if not f.startswith(b".") and not 
f.endswith(b"~"):
                                        yield os.path.join(path, f)
 
                dbapi = trees["porttree"].dbapi

diff --git a/pym/portage/_sets/files.py b/pym/portage/_sets/files.py
index 379ca30..9d25280 100644
--- a/pym/portage/_sets/files.py
+++ b/pym/portage/_sets/files.py
@@ -1,4 +1,4 @@
-# Copyright 2007-2013 Gentoo Foundation
+# Copyright 2007-2014 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 import errno
@@ -10,7 +10,7 @@ from portage import _encodings
 from portage import _unicode_decode
 from portage import _unicode_encode
 from portage.util import grabfile, write_atomic, ensure_dirs, normalize_path
-from portage.const import USER_CONFIG_PATH, WORLD_FILE, WORLD_SETS_FILE
+from portage.const import USER_CONFIG_PATH, VCS_DIRS, WORLD_FILE, 
WORLD_SETS_FILE
 from portage.localization import _
 from portage.locks import lockfile, unlockfile
 from portage import portage_gid
@@ -142,6 +142,7 @@ class StaticFileSet(EditablePackageSet):
                                _("Directory path contains invalid character(s) 
for encoding '%s': '%s'") \
                                % (_encodings['fs'], directory))
 
+               vcs_dirs = [_unicode_encode(x, encoding=_encodings['fs']) for x 
in VCS_DIRS]
                if os.path.isdir(directory):
                        directory = normalize_path(directory)
 
@@ -152,7 +153,7 @@ class StaticFileSet(EditablePackageSet):
                                except UnicodeDecodeError:
                                        continue
                                for d in dirs[:]:
-                                       if d[:1] == '.':
+                                       if d in vcs_dirs or d.startswith(b".") 
or d.endswith(b"~"):
                                                dirs.remove(d)
                                for filename in files:
                                        try:
@@ -160,7 +161,7 @@ class StaticFileSet(EditablePackageSet):
                                                        
encoding=_encodings['fs'], errors='strict')
                                        except UnicodeDecodeError:
                                                continue
-                                       if filename[:1] == '.':
+                                       if filename.startswith(".") or 
filename.endswith("~"):
                                                continue
                                        if filename.endswith(".metadata"):
                                                continue

Reply via email to