KDE 4.3 PyKDE API Reference
  • KDE's Python API
  • Overview
  • PyKDE Home
  • Sitemap
  • Contact Us
 

KMacroExpander Namespace Reference

from PyKDE4.kdecore.KMacroExpander import *

Detailed Description


Functions

QString expandMacros (QString str, QHash map, QChar c='%')
QString expandMacros (QString str, QHash map, QChar c=QLatin1Char('%'))
QString expandMacros (QString str, QHash map, QChar c=QLatin1Char('%'))
QString expandMacros (QString str, QHash map, QChar c=QLatin1Char('%'))
QString expandMacrosShellQuote (QString str, QHash map, QChar c=QLatin1Char('%'))
QString expandMacrosShellQuote (QString str, QHash map, QChar c=QLatin1Char('%'))
QString expandMacrosShellQuote (QString str, QHash map, QChar c=QLatin1Char('%'))
QString expandMacrosShellQuote (QString str, QHash map, QChar c=QLatin1Char('%'))

Function Documentation

QString expandMacros ( QString  str,
QHash  map,
QChar  c='%'
)

Perform safe macro expansion (substitution) on a string. The escape char must be quoted with itself to obtain its literal representation in the resulting string.

Parameters:
str  The string to expand
map  map with substitutions
c  escape char indicating start of macro, or QChar.null if none

Returns:
the string with all valid macros expanded

 // Code example
 QHash<QChar,QString> map;
 map.insert('u', "/tmp/myfile.txt");
 map.insert('n', "My File");
 QString s = "%% Title: %u:%n";
 s = KMacroExpander.expandMacros(s, map);
 // s is now "% Title: /tmp/myfile.txt:My File";

QString expandMacros ( QString  str,
QHash  map,
QChar  c=QLatin1Char('%')
)

Perform safe macro expansion (substitution) on a string. The escape char must be quoted with itself to obtain its literal representation in the resulting string. Macro names can consist of chars in the range [A-Za-z0-9_]; use braces to delimit macros from following words starting with these chars, or to use other chars for macro names.

Parameters:
str  The string to expand
map  map with substitutions
c  escape char indicating start of macro, or QChar.null if none

Returns:
the string with all valid macros expanded

 // Code example
 QHash<QString,QString> map;
 map.insert("url", "/tmp/myfile.txt");
 map.insert("name", "My File");
 QString s = "Title: %{url}-%name";
 s = KMacroExpander.expandMacros(s, map);
 // s is now "Title: /tmp/myfile.txt-My File";

QString expandMacros ( QString  str,
QHash  map,
QChar  c=QLatin1Char('%')
)

Same as above, except that the macros expand to string lists that are simply join(" ")ed together.

QString expandMacros ( QString  str,
QHash  map,
QChar  c=QLatin1Char('%')
)
QString expandMacrosShellQuote ( QString  str,
QHash  map,
QChar  c=QLatin1Char('%')
)

Perform safe macro expansion (substitution) on a string for use in shell commands. The escape char must be quoted with itself to obtain its literal representation in the resulting string.

Parameters:
str  The string to expand
map  map with substitutions
c  escape char indicating start of macro, or QChar.null if none

Returns:
the string with all valid macros expanded, or a null string if a shell syntax error was detected in the command

 // Code example
 QHash<QChar,QString> map;
 map.insert('u', "/tmp/myfile.txt");
 map.insert('n', "My File");
 QString s = "kedit --caption %n %u";
 s = KMacroExpander.expandMacrosShellQuote(s, map);
 // s is now "kedit --caption 'My File' '/tmp/myfile.txt'";
 system(QFile.encodeName(s));

QString expandMacrosShellQuote ( QString  str,
QHash  map,
QChar  c=QLatin1Char('%')
)

Perform safe macro expansion (substitution) on a string for use in shell commands. See KMacroExpanderBase.expandMacrosShellQuote() for the exact semantics. The escape char must be quoted with itself to obtain its literal representation in the resulting string. Macro names can consist of chars in the range [A-Za-z0-9_]; use braces to delimit macros from following words starting with these chars, or to use other chars for macro names.

Parameters:
str  The string to expand
map  map with substitutions
c  escape char indicating start of macro, or QChar.null if none

Returns:
the string with all valid macros expanded, or a null string if a shell syntax error was detected in the command

 // Code example
 QHash<QString,QString> map;
 map.insert("url", "/tmp/myfile.txt");
 map.insert("name", "My File");
 QString s = "kedit --caption %name %{url}";
 s = KMacroExpander.expandMacrosShellQuote(s, map);
 // s is now "kedit --caption 'My File' '/tmp/myfile.txt'";
 system(QFile.encodeName(s));

QString expandMacrosShellQuote ( QString  str,
QHash  map,
QChar  c=QLatin1Char('%')
)

Same as above, except that the macros expand to string lists. If the macro appears inside a quoted string, the list is simply join(" ")ed together; otherwise every element expands to a separate quoted string.

QString expandMacrosShellQuote ( QString  str,
QHash  map,
QChar  c=QLatin1Char('%')
)
  • Full Index

Modules

  • akonadi
  • dnssd
  • kdecore
  • kdeui
  • khtml
  • kio
  • knewstuff
  • kparts
  • kutils
  • nepomuk
  • phonon
  • plasma
  • polkitqt
  • solid
  • soprano
This documentation is maintained by Simon Edwards.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal