public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/g-sorcery:master commit in: gs_db_tool/
@ 2013-08-29 21:30 Jauhien Piatlicki
  0 siblings, 0 replies; 3+ messages in thread
From: Jauhien Piatlicki @ 2013-08-29 21:30 UTC (permalink / raw
  To: gentoo-commits

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()


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: gs_db_tool/
@ 2013-09-04 18:03 Jauhien Piatlicki
  0 siblings, 0 replies; 3+ messages in thread
From: Jauhien Piatlicki @ 2013-09-04 18:03 UTC (permalink / raw
  To: gentoo-commits

commit:     28e010cc203fb9415d9d88677681ff03f8be5072
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Wed Sep  4 14:35:41 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Wed Sep  4 14:35:41 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=28e010cc

gs_db_tool/gs_db_tool: for_all added

---
 gs_db_tool/gs_db_tool.py | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/gs_db_tool/gs_db_tool.py b/gs_db_tool/gs_db_tool.py
index 94d8a14..5594a12 100644
--- a/gs_db_tool/gs_db_tool.py
+++ b/gs_db_tool/gs_db_tool.py
@@ -40,6 +40,10 @@ def main():
     p_ebuild_data_show_all = p_ebuild_data_subparsers.add_parser('show_all')
     p_ebuild_data_show_all.set_defaults(func=show_all)
 
+    p_ebuild_data_for_all = p_ebuild_data_subparsers.add_parser('for_all')
+    p_ebuild_data_for_all.add_argument('function')
+    p_ebuild_data_for_all.set_defaults(func=for_all)
+
     p_sync = subparsers.add_parser('sync')
     p_sync.set_defaults(func=sync)
     p_sync.add_argument('uri')
@@ -57,6 +61,19 @@ def transform_db(function):
     return transformator
 
 
+def read_db(function):
+    def reader(pkg_db, args):
+        pkg_db.read()
+        function(pkg_db, args)
+    return reader
+
+
+@read_db
+def for_all(pkg_db, args):
+    for package, ebuild_data in pkg_db:
+        exec(args.function)
+
+
 @transform_db
 def add_var(pkg_db, args):
     if args.function:
@@ -79,8 +96,8 @@ def add_var(pkg_db, args):
             pkg_db.add_package(package, ebuild_data)
 
 
+@read_db
 def show_all(pkg_db, args):
-    pkg_db.read()
     for package, ebuild_data in pkg_db:
         print(package)
         print('-' * len(str(package)))


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [gentoo-commits] proj/g-sorcery:master commit in: gs_db_tool/
@ 2013-09-05 16:33 Jauhien Piatlicki
  0 siblings, 0 replies; 3+ messages in thread
From: Jauhien Piatlicki @ 2013-09-05 16:33 UTC (permalink / raw
  To: gentoo-commits

commit:     e99bc52284ede1cc43189b5ac8ac905cf8f5e64f
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Thu Sep  5 16:32:18 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Thu Sep  5 16:32:18 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=e99bc522

gs_db_tool/gs_db_tool: pass package to lambda

---
 gs_db_tool/gs_db_tool.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gs_db_tool/gs_db_tool.py b/gs_db_tool/gs_db_tool.py
index 5594a12..1b58cee 100644
--- a/gs_db_tool/gs_db_tool.py
+++ b/gs_db_tool/gs_db_tool.py
@@ -83,10 +83,10 @@ def add_var(pkg_db, args):
             pkg_db.add_package(package, ebuild_data)
 
     elif args.lambda_function:
-        lmbd = "lambda ebuild_data: " + args.lambda_function
+        lmbd = "lambda package, ebuild_data: " + args.lambda_function
         f = eval(lmbd)
         for package, ebuild_data in pkg_db:
-            value = f(ebuild_data)
+            value = f(package, ebuild_data)
             ebuild_data[args.name] = value
             pkg_db.add_package(package, ebuild_data)
 


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-09-05 16:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-29 21:30 [gentoo-commits] proj/g-sorcery:master commit in: gs_db_tool/ Jauhien Piatlicki
  -- strict thread matches above, loose matches on Subject: below --
2013-09-04 18:03 Jauhien Piatlicki
2013-09-05 16:33 Jauhien Piatlicki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox