From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 18655138202 for ; Wed, 4 Sep 2013 10:16:43 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 18578E0D58; Wed, 4 Sep 2013 10:16:40 +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 75BB2E0D57 for ; Wed, 4 Sep 2013 10:16:39 +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 2884E33DAC7 for ; Wed, 4 Sep 2013 10:16:38 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id D117FE468F for ; Wed, 4 Sep 2013 10:16:36 +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: <1378289579.e438767ef4e262de19a600680c9732d555ed8a8c.dywi@gentoo> Subject: [gentoo-commits] proj/R_overlay:master commit in: roverlay/config/ X-VCS-Repository: proj/R_overlay X-VCS-Files: roverlay/config/entrymap.py roverlay/config/loader.py X-VCS-Directories: roverlay/config/ X-VCS-Committer: dywi X-VCS-Committer-Name: André Erdmann X-VCS-Revision: e438767ef4e262de19a600680c9732d555ed8a8c X-VCS-Branch: master Date: Wed, 4 Sep 2013 10:16:36 +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: d24c55df-d515-49e3-8b44-f30928978345 X-Archives-Hash: 8982a6760f8fecd9ffaa58720ec77a2b commit: e438767ef4e262de19a600680c9732d555ed8a8c Author: André Erdmann mailerd de> AuthorDate: Wed Sep 4 10:12:59 2013 +0000 Commit: André Erdmann mailerd de> CommitDate: Wed Sep 4 10:12:59 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=e438767e config: comments, EVENT_HOOK_RC EVENT_HOOK_RC is a shell file that should be loaded by the mux.sh script before running the hooks. Not defining hook-related variables in the main config file allows to use $variables etc. --- roverlay/config/entrymap.py | 12 +++++++++++- roverlay/config/loader.py | 3 +-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/roverlay/config/entrymap.py b/roverlay/config/entrymap.py index 88974ba..c7b1493 100644 --- a/roverlay/config/entrymap.py +++ b/roverlay/config/entrymap.py @@ -22,7 +22,7 @@ known dict keys are 'path', 'description'/'desc' and 'value_type': * path (string or list of strings) -- path of this entry in the config tree * description (string) -- describes the entry -* value_type (string), you can specify: +* value_type can be any of: -> list -- value is a whitespace-separated list -> int -- integer -> str -- [explicit string conversion] @@ -33,6 +33,9 @@ known dict keys are 'path', 'description'/'desc' and 'value_type': -> fs_dir -- fs_abs and value must be a dir if it exists -> fs_file -- fs_abs and value must be a file if it exists -> regex -- value is a regex and will be compiled (re.compile(..)) +-> a type (str,int,...) +-> a callable that accepts one arg and returns the converted value or None, + where None means "not valid" Multiple types are generally not supported ('this is an int or a str'), but subtypes are ('list of yesno'), which can be specified by either @@ -505,6 +508,12 @@ CONFIG_ENTRY_MAP = dict ( description = 'script that is run on certain events, e.g. overlay_success', ), + event_hook_rc = dict ( + path = [ 'EVENT_HOOK', 'config_file', ], + value_type = 'fs_abs', + description = 'hook (shell) config file', + ), + event_hook_restrict = dict ( path = [ 'EVENT_HOOK', 'restrict', ], value_type = 'list:str', @@ -514,6 +523,7 @@ CONFIG_ENTRY_MAP = dict ( # * alias hook = 'event_hook', + hook_rc = 'event_hook_rc', hook_restrict = 'event_hook_restrict', diff --git a/roverlay/config/loader.py b/roverlay/config/loader.py index e05e72f..19d377b 100644 --- a/roverlay/config/loader.py +++ b/roverlay/config/loader.py @@ -402,7 +402,6 @@ class ConfigLoader ( object ): else: return None - def fs_file ( val ): """"val is a file - returns expanded path if it is an existent file or it does not exist. @@ -455,7 +454,7 @@ class ConfigLoader ( object ): vtypes = value_type elif isinstance ( value_type, str ): vtypes = value_type.split ( ':' ) - elif type ( value_type ) is type: + elif hasattr ( value_type, '__call__' ) or type ( value_type ) is type: try: return value_type ( value ) except ValueError: