Author: jkupec
Date: Fri Sep 12 13:25:36 2008
New Revision: 11029
URL: http://svn.opensuse.org/viewcvs/zypp?rev=11029&view=rev
Log:
- --xmlout form product-info added
Modified:
trunk/zypper/src/info.cc
trunk/zypper/src/info.h
trunk/zypper/src/utils/misc.cc
trunk/zypper/src/utils/misc.h
Modified: trunk/zypper/src/info.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/info.cc?rev=11029&r1=11028&r2=11029&view=diff
==============================================================================
--- trunk/zypper/src/info.cc (original)
+++ trunk/zypper/src/info.cc Fri Sep 12 13:25:36 2008
@@ -58,7 +58,7 @@
/**
*
*/
-void printInfo(const Zypper & zypper, const ResKind & kind)
+void printInfo(Zypper & zypper, const ResKind & kind)
{
ResPool pool = God->pool();
@@ -85,10 +85,14 @@
ui::Selectable::constPtr s = *q.selectableBegin();
// print info
// TranslatorExplanation E.g. "Information for package zypper:"
- cout << endl << format(_("Information for %s %s:"))
- % kind_to_string_localized(kind, 1) % *nameit;
-
- cout << endl << endl;
+
+ if (zypper.out().type() != Out::TYPE_XML)
+ {
+ cout << endl << format(_("Information for %s %s:"))
+ % kind_to_string_localized(kind, 1) % *nameit;
+
+ cout << endl << endl;
+ }
if (kind == ResKind::package)
printPkgInfo(zypper, *s);
@@ -100,7 +104,8 @@
printProductInfo(zypper, *s);
else
// TranslatorExplanation %s = resolvable type (package, patch, pattern, etc - untranslated).
- cout << format(_("Info for type '%s' not implemented.")) % kind << endl;
+ zypper.out().info(
+ boost::str(format(_("Info for type '%s' not implemented.")) % kind));
}
}
@@ -140,7 +145,7 @@
</pre>
*
*/
-void printPkgInfo(const Zypper & zypper, const ui::Selectable & s)
+void printPkgInfo(Zypper & zypper, const ui::Selectable & s)
{
PoolItem theone = s.theObj();
PoolItem installed = s.installedObj();
@@ -196,7 +201,7 @@
</pre>
*
*/
-void printPatchInfo(const Zypper & zypper, const ui::Selectable & s )
+void printPatchInfo(Zypper & zypper, const ui::Selectable & s )
{
const PoolItem & pool_item = s.theObj();
printNVA(pool_item.resolvable());
@@ -262,7 +267,7 @@
</pre>
*
*/
-void printPatternInfo(const Zypper & zypper, const ui::Selectable & s)
+void printPatternInfo(Zypper & zypper, const ui::Selectable & s)
{
const PoolItem & pool_item = s.theObj();
@@ -324,21 +329,32 @@
</pre>
*
*/
-void printProductInfo(const Zypper & zypper, const ui::Selectable & s)
+void printProductInfo(Zypper & zypper, const ui::Selectable & s)
{
const PoolItem & pool_item = s.theObj(); // should be the only one
- cout << (zypper.globalOpts().is_rug_compatible ? _("Catalog: ") : _("Repository: "))
- << pool_item.resolvable()->repository().info().name() << endl;
-
- printNVA(pool_item.resolvable());
-
- Product::constPtr product = asKind<Product>(pool_item.resolvable());
- cout << _("Category") << ": " << product->type() << endl;
- cout << _("Flavor") << ": " << product->flavor() << endl;
- cout << _("Installed") << ": " << (pool_item.status().isInstalled() ? "Yes" : "No") << endl;
- cout << _("Short Name") << ": " << product->shortName() << endl;
- printSummaryDesc(pool_item.resolvable());
+ if (zypper.out().type() == Out::TYPE_XML)
+ {
+ Product::constPtr pp
+ = dynamic_pointer_cast<const Product>(pool_item.resolvable());
+ cout
+ << asXML(*pp, pool_item.status().isInstalled())
+ << endl;
+ }
+ else
+ {
+ cout << (zypper.globalOpts().is_rug_compatible ? _("Catalog: ") : _("Repository: "))
+ << pool_item.resolvable()->repository().info().name() << endl;
+
+ printNVA(pool_item.resolvable());
+
+ Product::constPtr product = asKind<Product>(pool_item.resolvable());
+ cout << _("Category") << ": " << product->type() << endl;
+ cout << _("Flavor") << ": " << product->flavor() << endl;
+ cout << _("Installed") << ": " << (pool_item.status().isInstalled() ? "Yes" : "No") << endl;
+ cout << _("Short Name") << ": " << product->shortName() << endl;
+ printSummaryDesc(pool_item.resolvable());
+ }
}
// Local Variables:
Modified: trunk/zypper/src/info.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/info.h?rev=11029&r1=11028&r2=11029&view=diff
==============================================================================
--- trunk/zypper/src/info.h (original)
+++ trunk/zypper/src/info.h Fri Sep 12 13:25:36 2008
@@ -14,14 +14,14 @@
#include "Zypper.h"
-void printInfo(const Zypper & zypper, const zypp::ResKind & kind);
+void printInfo(Zypper & zypper, const zypp::ResKind & kind);
-void printPkgInfo(const Zypper & zypper, const zypp::ui::Selectable & s);
+void printPkgInfo(Zypper & zypper, const zypp::ui::Selectable & s);
-void printPatchInfo(const Zypper & zypper, const zypp::ui::Selectable & s);
+void printPatchInfo(Zypper & zypper, const zypp::ui::Selectable & s);
-void printPatternInfo(const Zypper & zypper, const zypp::ui::Selectable & s);
+void printPatternInfo(Zypper & zypper, const zypp::ui::Selectable & s);
-void printProductInfo(const Zypper & zypper, const zypp::ui::Selectable & s);
+void printProductInfo(Zypper & zypper, const zypp::ui::Selectable & s);
#endif /*ZYPPERINFO_H_*/
Modified: trunk/zypper/src/utils/misc.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/utils/misc.cc?rev=11029&r1=11028&r2=11029&view=diff
==============================================================================
--- trunk/zypper/src/utils/misc.cc (original)
+++ trunk/zypper/src/utils/misc.cc Fri Sep 12 13:25:36 2008
@@ -17,6 +17,8 @@
#include "zypp/parser/xml/XmlEscape.h"
#include "zypp/PoolItem.h"
+#include "zypp/Product.h"
+#include "zypp/Pattern.h"
#include "main.h"
#include "Zypper.h"
@@ -320,3 +322,32 @@
}
return Capability();
}
+
+string asXML(const Product & p, bool is_installed)
+{
+ ostringstream str;
+ str
+ << "