summary refs log blame commit diff stats
path: root/doc/pydoc/ranger.ext.command_parser.html
blob: 9e6fc95094aa4aa26c1fcdf370629dc2b39f20f6 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
 

                                                                   






                                                                                                                                                                                                                                                     
                                                                                                                                                                                                               
                                                                                                                              
     



                                                                                                                                           
     






                                                                                                                                                                              







                                                                                                  
                                                                                          









                                                                                                    
                                                                                                                                                                                   






















                                                                                                                                                                                                                                         
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module ranger.ext.command_parser</title>
</head><body bgcolor="#f0f0f8">

<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong><a href="ranger.html"><font color="#ffffff">ranger</font></a>.<a href="ranger.ext.html"><font color="#ffffff">ext</font></a>.command_parser</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/hut/ranger/ranger/ext/command_parser.py">/home/hut/ranger/ranger/ext/command_parser.py</a></font></td></tr></table>
    <p><tt>#&nbsp;Copyright&nbsp;(C)&nbsp;2009,&nbsp;2010&nbsp;&nbsp;Roman&nbsp;Zimbelmann&nbsp;&lt;romanz@lavabit.com&gt;<br>
#<br>
#&nbsp;This&nbsp;program&nbsp;is&nbsp;free&nbsp;software:&nbsp;you&nbsp;can&nbsp;redistribute&nbsp;it&nbsp;and/or&nbsp;modify<br>
#&nbsp;it&nbsp;under&nbsp;the&nbsp;terms&nbsp;of&nbsp;the&nbsp;GNU&nbsp;General&nbsp;Public&nbsp;License&nbsp;as&nbsp;published&nbsp;by<br>
#&nbsp;the&nbsp;Free&nbsp;Software&nbsp;Foundation,&nbsp;either&nbsp;version&nbsp;3&nbsp;of&nbsp;the&nbsp;License,&nbsp;or<br>
#&nbsp;(at&nbsp;your&nbsp;option)&nbsp;any&nbsp;later&nbsp;version.<br>
#<br>
#&nbsp;This&nbsp;program&nbsp;is&nbsp;distributed&nbsp;in&nbsp;the&nbsp;hope&nbsp;that&nbsp;it&nbsp;will&nbsp;be&nbsp;useful,<br>
#&nbsp;but&nbsp;WITHOUT&nbsp;ANY&nbsp;WARRANTY;&nbsp;without&nbsp;even&nbsp;the&nbsp;implied&nbsp;warranty&nbsp;of<br>
#&nbsp;MERCHANTABILITY&nbsp;or&nbsp;FITNESS&nbsp;FOR&nbsp;A&nbsp;PARTICULAR&nbsp;PURPOSE.&nbsp;&nbsp;See&nbsp;the<br>
#&nbsp;GNU&nbsp;General&nbsp;Public&nbsp;License&nbsp;for&nbsp;more&nbsp;details.<br>
#<br>
#&nbsp;You&nbsp;should&nbsp;have&nbsp;received&nbsp;a&nbsp;copy&nbsp;of&nbsp;the&nbsp;GNU&nbsp;General&nbsp;Public&nbsp;License<br>
#&nbsp;along&nbsp;with&nbsp;this&nbsp;program.&nbsp;&nbsp;If&nbsp;not,&nbsp;see&nbsp;&lt;<a href="http://www.gnu.org/licenses/">http://www.gnu.org/licenses/</a>&gt;.</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
    
<tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="__builtin__.html#object">__builtin__.object</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="ranger.ext.command_parser.html#LazyParser">LazyParser</a>
</font></dt></dl>
</dd>
</dl>
 <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="LazyParser">class <strong>LazyParser</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr>
    
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt>Parse&nbsp;commands&nbsp;and&nbsp;extract&nbsp;information<br>&nbsp;</tt></td></tr>
<tr><td>&nbsp;</td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="LazyParser-__add__"><strong>__add__</strong></a>(self, newpart)</dt></dl>

<dl><dt><a name="LazyParser-__init__"><strong>__init__</strong></a>(self, line)</dt></dl>

<dl><dt><a name="LazyParser-chunk"><strong>chunk</strong></a>(self, n, otherwise<font color="#909090">=''</font>)</dt><dd><tt>Chunks&nbsp;are&nbsp;pieces&nbsp;of&nbsp;the&nbsp;command&nbsp;seperated&nbsp;by&nbsp;spaces</tt></dd></dl>

<dl><dt><a name="LazyParser-rest"><strong>rest</strong></a>(self, n, otherwise<font color="#909090">=''</font>)</dt><dd><tt>Rests&nbsp;are&nbsp;the&nbsp;strings&nbsp;which&nbsp;come&nbsp;after&nbsp;each&nbsp;word.</tt></dd></dl>

<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
</td></tr></table></td></tr></table>
</body></html>
e>


                                                                                              
                                                   
                        

      
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>

#include "config.h"

#include "command/cmd_funcs.h"
#include "xmpp/xmpp.h"

#include "ui/stub_ui.h"

#define CMD_PGP "/pgp"

#ifdef HAVE_LIBGPGME
void
cmd_pgp_shows_usage_when_no_args(void** state)
{
    gchar* args[] = { NULL };

    expect_string(cons_bad_cmd_usage, cmd, CMD_PGP);

    gboolean result = cmd_pgp(NULL, CMD_PGP, args);
    assert_true(result);
}

void
cmd_pgp_start_shows_message_when_connection(jabber_conn_status_t conn_status)
{
    gchar* args[] = { "start", NULL };
    ProfWin window;
    window.type = WIN_CHAT;

    will_return(connection_get_status, conn_status);

    expect_cons_show("You must be connected to start PGP encrpytion.");

    gboolean result = cmd_pgp(&window, CMD_PGP, args);
    assert_true(result);
}

void
cmd_pgp_start_shows_message_when_disconnected(void** state)
{
    cmd_pgp_start_shows_message_when_connection(JABBER_DISCONNECTED);
}

void
cmd_pgp_start_shows_message_when_disconnecting(void** state)
{
    cmd_pgp_start_shows_message_when_connection(JABBER_DISCONNECTING);
}

void
cmd_pgp_start_shows_message_when_connecting(void** state)
{
    cmd_pgp_start_shows_message_when_connection(JABBER_CONNECTING);
}

void
cmd_pgp_start_shows_message_when_no_arg_in_wintype(win_type_t wintype)
{
    gchar* args[] = { "start", NULL };
    ProfWin window;
    window.type = wintype;

    will_return(connection_get_status, JABBER_CONNECTED);

    expect_cons_show("You must be in a regular chat window to start PGP encrpytion.");

    gboolean result = cmd_pgp(&window, CMD_PGP, args);
    assert_true(result);
}

void
cmd_pgp_start_shows_message_when_no_arg_in_console(void** state)
{
    cmd_pgp_start_shows_message_when_no_arg_in_wintype(WIN_CONSOLE);
}

void
cmd_pgp_start_shows_message_when_no_arg_in_muc(void** state)
{
    cmd_pgp_start_shows_message_when_no_arg_in_wintype(WIN_MUC);
}

void
cmd_pgp_start_shows_message_when_no_arg_in_conf(void** state)
{
    cmd_pgp_start_shows_message_when_no_arg_in_wintype(WIN_CONFIG);
}

void
cmd_pgp_start_shows_message_when_no_arg_in_private(void** state)
{
    cmd_pgp_start_shows_message_when_no_arg_in_wintype(WIN_PRIVATE);
}

void
cmd_pgp_start_shows_message_when_no_arg_in_xmlconsole(void** state)
{
    cmd_pgp_start_shows_message_when_no_arg_in_wintype(WIN_XML);
}

#else
void
cmd_pgp_shows_message_when_pgp_unsupported(void** state)
{
    gchar* args[] = { "gen", NULL };

    expect_cons_show("This version of Profanity has not been built with PGP support enabled");

    gboolean result = cmd_pgp(NULL, CMD_PGP, args);
    assert_true(result);
}
#endif