[damned-lies] Add a management command to update module information with doap file



commit 23d329c343f9a4b20f35d97eff9a300deeb0f882
Author: Claude Paroz <claude 2xlibre net>
Date:   Tue Oct 26 21:51:53 2010 +0200

    Add a management command to update module information with doap file

 stats/management/commands/update-from-doap.py |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/stats/management/commands/update-from-doap.py b/stats/management/commands/update-from-doap.py
new file mode 100644
index 0000000..f4f0bb6
--- /dev/null
+++ b/stats/management/commands/update-from-doap.py
@@ -0,0 +1,23 @@
+import sys
+from django.core.management.base import BaseCommand
+
+from stats.models import Module
+from stats.doap import update_doap_infos
+
+class Command(BaseCommand):
+    help = "Update module information from doap file"
+    args = "MODULE"
+
+    def handle(self, *args, **options):
+        if len(args) == 0:
+            sys.stderr.write("You must provide at least one module name for this command.\n")
+            sys.exit(1)
+
+        for mod_name in args:
+            try:
+                mod = Module.objects.get(name=mod_name)
+            except Module.DoesNotExist:
+                sys.stderr.write("No module named '%s'. Ignoring.\n" % mod_name)
+                continue
+            update_doap_infos(mod)
+            sys.stdout.write("Module '%s' updated from its doap file.\n" % mod_name)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]