From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1QMDVh-0004Va-Qu for garchives@archives.gentoo.org; Tue, 17 May 2011 06:12:02 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id F3E451C24E; Tue, 17 May 2011 06:11:53 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id BD30B1C24E for ; Tue, 17 May 2011 06:11:53 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 139261B4027 for ; Tue, 17 May 2011 06:11:53 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 37D2E80504 for ; Tue, 17 May 2011 06:11:52 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: Subject: [gentoo-commits] proj/portage:master commit in: pym/_emerge/ X-VCS-Repository: proj/portage X-VCS-Files: pym/_emerge/depgraph.py X-VCS-Directories: pym/_emerge/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: b29beea0ef190c8dad0e2742e89d34d1212ab9e0 Date: Tue, 17 May 2011 06:11:52 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: cac8c4a62a85b49a1bffdd212317c62f commit: b29beea0ef190c8dad0e2742e89d34d1212ab9e0 Author: Zac Medico gentoo org> AuthorDate: Tue May 17 06:10:38 2011 +0000 Commit: Zac Medico gentoo org> CommitDate: Tue May 17 06:10:38 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3Db29beea0 --autounmask-write: handle config file recursion --- pym/_emerge/depgraph.py | 36 ++++++++++++++++++++++++------------ 1 files changed, 24 insertions(+), 12 deletions(-) diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py index 1de147a..9e97415 100644 --- a/pym/_emerge/depgraph.py +++ b/pym/_emerge/depgraph.py @@ -8,6 +8,7 @@ import difflib import gc import logging import re +import stat import sys import textwrap from collections import deque @@ -5663,25 +5664,36 @@ class depgraph(object): """ Searches /etc/portage for an appropriate file to append changes to. If the file_name is a file it is returned, if it is a directory, the - last file in it is returned. + last file in it is returned. Order of traversal is the identical to + portage.util.grablines(recursive=3DTrue). =20 file_name - String containing a file name like "package.use" return value - String. Absolute path of file to write to. None if no suitable file exists. """ file_path =3D os.path.join(abs_user_config, file_name) - if os.path.exists(file_path): - if os.path.isfile(file_path): - return file_path - elif os.path.isdir(file_path): - try: - files =3D sorted(f for f in os.listdir(file_path) \ - if os.path.isfile(os.path.join(file_path, f))) - if len(files) !=3D 0: - return os.path.join(file_path, files[-1]) - except OSError: - pass + last_file_path =3D None + stack =3D [file_path] + while stack: + p =3D stack.pop() + try: + st =3D os.stat(p) + except OSError: + pass + else: + if stat.S_ISREG(st.st_mode): + last_file_path =3D p + elif stat.S_ISDIR(st.st_mode): + try: + contents =3D os.listdir(p) + except OSError: + pass + else: + contents.sort(reverse=3DTrue) + for child in contents: + stack.append(os.path.join(p, child)) =20 + return last_file_path =20 write_to_file =3D autounmask_write and not pretend #Make sure we have a file to write to before doing any write.