From: "Jauhien Piatlicki" <piatlicki@gmail.com>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/g-sorcery:master commit in: gs_db_tool/
Date: Thu, 29 Aug 2013 21:30:19 +0000 (UTC) [thread overview]
Message-ID: <1377811778.951244c9ad5bd94f1b95931413c369ccc6670136.jauhien@gentoo> (raw)
commit: 951244c9ad5bd94f1b95931413c369ccc6670136
Author: Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Thu Aug 29 21:29:38 2013 +0000
Commit: Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Thu Aug 29 21:29:38 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=951244c9
gs_db_tool/gs_db_tool: add_var with arbitrary code and a fixed value
---
gs_db_tool/gs_db_tool.py | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/gs_db_tool/gs_db_tool.py b/gs_db_tool/gs_db_tool.py
index 14e4930..94d8a14 100644
--- a/gs_db_tool/gs_db_tool.py
+++ b/gs_db_tool/gs_db_tool.py
@@ -28,7 +28,9 @@ def main():
p_ebuild_data_rename = p_ebuild_data_subparsers.add_parser('add_var')
p_ebuild_data_rename.set_defaults(func=add_var)
p_ebuild_data_rename.add_argument('name')
+ p_ebuild_data_rename.add_argument('-f', '--function')
p_ebuild_data_rename.add_argument('-l', '--lambda_function')
+ p_ebuild_data_rename.add_argument('-v', '--value')
p_ebuild_data_rename = p_ebuild_data_subparsers.add_parser('rename_var')
p_ebuild_data_rename.set_defaults(func=rename_var)
@@ -57,7 +59,13 @@ def transform_db(function):
@transform_db
def add_var(pkg_db, args):
- if args.lambda_function:
+ if args.function:
+ for package, ebuild_data in pkg_db:
+ exec(args.function)
+ ebuild_data[args.name] = value
+ pkg_db.add_package(package, ebuild_data)
+
+ elif args.lambda_function:
lmbd = "lambda ebuild_data: " + args.lambda_function
f = eval(lmbd)
for package, ebuild_data in pkg_db:
@@ -65,6 +73,11 @@ def add_var(pkg_db, args):
ebuild_data[args.name] = value
pkg_db.add_package(package, ebuild_data)
+ elif args.value:
+ for package, ebuild_data in pkg_db:
+ ebuild_data[args.name] = args.value
+ pkg_db.add_package(package, ebuild_data)
+
def show_all(pkg_db, args):
pkg_db.read()
next reply other threads:[~2013-08-29 21:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-29 21:30 Jauhien Piatlicki [this message]
-- strict thread matches above, loose matches on Subject: below --
2013-09-04 18:03 [gentoo-commits] proj/g-sorcery:master commit in: gs_db_tool/ Jauhien Piatlicki
2013-09-05 16:33 Jauhien Piatlicki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1377811778.951244c9ad5bd94f1b95931413c369ccc6670136.jauhien@gentoo \
--to=piatlicki@gmail.com \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox