From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (unknown [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 238351381F3 for ; Tue, 9 Jul 2013 22:54:48 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 4D04EE0ABC; Tue, 9 Jul 2013 22:50:25 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id BCBE9E0A43 for ; Tue, 9 Jul 2013 22:50:13 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 1516033E96D for ; Mon, 8 Jul 2013 22:48:01 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 9EA08E5466 for ; Mon, 8 Jul 2013 22:47:58 +0000 (UTC) From: "André Erdmann" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "André Erdmann" Message-ID: <1373322784.932c509c1e622b28c7f0d4a3640bb9b424c59309.dywi@gentoo> Subject: [gentoo-commits] proj/R_overlay:gsoc13/next commit in: roverlay/util/ X-VCS-Repository: proj/R_overlay X-VCS-Files: roverlay/util/common.py X-VCS-Directories: roverlay/util/ X-VCS-Committer: dywi X-VCS-Committer-Name: André Erdmann X-VCS-Revision: 932c509c1e622b28c7f0d4a3640bb9b424c59309 X-VCS-Branch: gsoc13/next Date: Mon, 8 Jul 2013 22:47:58 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 4050b294-0b34-459e-9dcb-059ca9fcb2c5 X-Archives-Hash: 7558e6ee196130d366ff18e2e7d0cd6a commit: 932c509c1e622b28c7f0d4a3640bb9b424c59309 Author: André Erdmann mailerd de> AuthorDate: Mon Jul 8 22:33:04 2013 +0000 Commit: André Erdmann mailerd de> CommitDate: Mon Jul 8 22:33:04 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=932c509c roverlay/util/common: is_vcs_dir(), getsize() --- roverlay/util/common.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/roverlay/util/common.py b/roverlay/util/common.py index 6deee14..9ecdcc9 100644 --- a/roverlay/util/common.py +++ b/roverlay/util/common.py @@ -7,7 +7,8 @@ """provides utility functions commonly used""" __all__= [ - 'dodir', 'for_all_files', 'get_dict_hash', 'keepenv', 'priosort', 'sysnop' + 'dodir', 'for_all_files', 'get_dict_hash', 'keepenv', 'priosort', 'sysnop', + 'getsize', 'is_vcs_dir', ] import os @@ -16,6 +17,10 @@ import logging LOGGER = logging.getLogger ( 'util' ) +# COULDFIX: add .svn et al. +# +VCS_DIRNAMES = frozenset ({ '.git', }) + def for_all_files ( files_or_dirs, func, args=(), kwargs={}, file_filter=None, ignore_missing=False @@ -186,3 +191,22 @@ def dodir ( directory, mkdir_p=False, **makedirs_kw ): return os.path.isdir ( directory ) # --- end of dodir (...) --- + +def getsize ( filepath ): + """Returns the size of the given file. + + arguments: + * filepath -- + """ + return os.stat ( filepath ).st_size +# --- end of getsize (...) --- + +def is_vcs_dir ( dirpath ): + """Returns True if dirpath could be a directory maintained by a version + control system, e.g. git. + + arguments: + * dirpath -- + """ + return os.path.basename ( dirpath.rstrip ( os.sep ) ) in VCS_DIRNAMES +# --- end of is_vcs_dir (...) ---