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










                                                                                                                                                                                                             












                                                                                                                                          



















                                                                                                               

                                                                                                              






                                                                           











































                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              



                                                                                                                                 














                                                                                                                                                                                                               

                                                                                                                                                                                 
































                                                                                                                                                                                                                 


                                                                                                                                                                        

                                                                                                                                                  


















                                                                                                                                                                                                                





                                                                                                                                                                                                                                                                     







                                                                                               

                                                                                                        
             
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module ranger.applications</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</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>.applications</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/work/ranger/ranger/applications.py">/home/hut/work/ranger/ranger/applications.py</a></font></td></tr></table>
    <p><tt>#&nbsp;Copyright&nbsp;(c)&nbsp;2009,&nbsp;2010&nbsp;hut&nbsp;&lt;hut@lavabit.com&gt;<br>
#<br>
#&nbsp;Permission&nbsp;to&nbsp;use,&nbsp;copy,&nbsp;modify,&nbsp;and/or&nbsp;distribute&nbsp;this&nbsp;software&nbsp;for&nbsp;any<br>
#&nbsp;purpose&nbsp;with&nbsp;or&nbsp;without&nbsp;fee&nbsp;is&nbsp;hereby&nbsp;granted,&nbsp;provided&nbsp;that&nbsp;the&nbsp;above<br>
#&nbsp;copyright&nbsp;notice&nbsp;and&nbsp;this&nbsp;permission&nbsp;notice&nbsp;appear&nbsp;in&nbsp;all&nbsp;copies.<br>
#<br>
#&nbsp;THE&nbsp;SOFTWARE&nbsp;IS&nbsp;PROVIDED&nbsp;"AS&nbsp;IS"&nbsp;AND&nbsp;THE&nbsp;AUTHOR&nbsp;DISCLAIMS&nbsp;ALL&nbsp;WARRANTIES<br>
#&nbsp;WITH&nbsp;REGARD&nbsp;TO&nbsp;THIS&nbsp;SOFTWARE&nbsp;INCLUDING&nbsp;ALL&nbsp;IMPLIED&nbsp;WARRANTIES&nbsp;OF<br>
#&nbsp;MERCHANTABILITY&nbsp;AND&nbsp;FITNESS.&nbsp;IN&nbsp;NO&nbsp;EVENT&nbsp;SHALL&nbsp;THE&nbsp;AUTHOR&nbsp;BE&nbsp;LIABLE&nbsp;FOR<br>
#&nbsp;ANY&nbsp;SPECIAL,&nbsp;DIRECT,&nbsp;INDIRECT,&nbsp;OR&nbsp;CONSEQUENTIAL&nbsp;DAMAGES&nbsp;OR&nbsp;ANY&nbsp;DAMAGES<br>
#&nbsp;WHATSOEVER&nbsp;RESULTING&nbsp;FROM&nbsp;LOSS&nbsp;OF&nbsp;USE,&nbsp;DATA&nbsp;OR&nbsp;PROFITS,&nbsp;WHETHER&nbsp;IN&nbsp;AN<br>
#&nbsp;ACTION&nbsp;OF&nbsp;CONTRACT,&nbsp;NEGLIGENCE&nbsp;OR&nbsp;OTHER&nbsp;TORTIOUS&nbsp;ACTION,&nbsp;ARISING&nbsp;OUT&nbsp;OF<br>
#&nbsp;OR&nbsp;IN&nbsp;CONNECTION&nbsp;WITH&nbsp;THE&nbsp;USE&nbsp;OR&nbsp;PERFORMANCE&nbsp;OF&nbsp;THIS&nbsp;SOFTWARE.</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
    
<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="os.html">os</a><br>
</td><td width="25%" valign=top><a href="sys.html">sys</a><br>
</td><td width="25%" valign=top></td><td width="25%" valign=top></td></tr></table></td></tr></table><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="builtins.html#object">builtins.object</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="ranger.applications.html#AppContext">AppContext</a>
</font></dt><dt><font face="helvetica, arial"><a href="ranger.applications.html#Applications">Applications</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="AppContext">class <strong>AppContext</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
    
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt>An&nbsp;<a href="#AppContext">AppContext</a>&nbsp;<a href="builtins.html#object">object</a>&nbsp;abstracts&nbsp;the&nbsp;spawning&nbsp;of&nbsp;processes.<br>
&nbsp;<br>
At&nbsp;initialization&nbsp;of&nbsp;the&nbsp;<a href="builtins.html#object">object</a>&nbsp;you&nbsp;can&nbsp;define&nbsp;many&nbsp;high-level&nbsp;options.<br>
When&nbsp;you&nbsp;call&nbsp;the&nbsp;<a href="#AppContext-run">run</a>()&nbsp;function,&nbsp;those&nbsp;options&nbsp;are&nbsp;evaluated&nbsp;and<br>
translated&nbsp;into&nbsp;Popen()&nbsp;calls.<br>
&nbsp;<br>
An&nbsp;instances&nbsp;of&nbsp;this&nbsp;class&nbsp;is&nbsp;passed&nbsp;as&nbsp;the&nbsp;only&nbsp;argument&nbsp;to<br>
app_xyz&nbsp;calls&nbsp;of&nbsp;the&nbsp;<a href="#Applications">Applications</a>&nbsp;<a href="builtins.html#object">object</a>.<br>
&nbsp;<br>
Attributes:<br>
action&nbsp;--&nbsp;a&nbsp;string&nbsp;with&nbsp;a&nbsp;command&nbsp;or&nbsp;a&nbsp;list&nbsp;of&nbsp;arguments&nbsp;for<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;the&nbsp;Popen&nbsp;call.<br>
app&nbsp;--&nbsp;the&nbsp;name&nbsp;of&nbsp;the&nbsp;app&nbsp;function.&nbsp;("vim"&nbsp;for&nbsp;app_vim.)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;app&nbsp;is&nbsp;used&nbsp;to&nbsp;get&nbsp;an&nbsp;action&nbsp;if&nbsp;the&nbsp;user&nbsp;didn't&nbsp;specify&nbsp;one.<br>
mode&nbsp;--&nbsp;a&nbsp;number,&nbsp;mainly&nbsp;used&nbsp;in&nbsp;determining&nbsp;the&nbsp;action&nbsp;in&nbsp;app_xyz()<br>
flags&nbsp;--&nbsp;a&nbsp;string&nbsp;with&nbsp;flags&nbsp;which&nbsp;change&nbsp;the&nbsp;way&nbsp;programs&nbsp;are&nbsp;run<br>
files&nbsp;--&nbsp;a&nbsp;list&nbsp;containing&nbsp;files,&nbsp;mainly&nbsp;used&nbsp;in&nbsp;app_xyz<br>
file&nbsp;--&nbsp;an&nbsp;arbitrary&nbsp;file&nbsp;from&nbsp;that&nbsp;list&nbsp;(or&nbsp;None)<br>
fm&nbsp;--&nbsp;the&nbsp;filemanager&nbsp;instance<br>
wait&nbsp;--&nbsp;boolean,&nbsp;wait&nbsp;for&nbsp;the&nbsp;end&nbsp;or&nbsp;execute&nbsp;programs&nbsp;in&nbsp;parallel?<br>
stdout&nbsp;--&nbsp;directly&nbsp;passed&nbsp;to&nbsp;Popen<br>
stderr&nbsp;--&nbsp;directly&nbsp;passed&nbsp;to&nbsp;Popen<br>
stdin&nbsp;--&nbsp;directly&nbsp;passed&nbsp;to&nbsp;Popen<br>
shell&nbsp;--&nbsp;directly&nbsp;passed&nbsp;to&nbsp;Popen.&nbsp;Should&nbsp;the&nbsp;string&nbsp;be&nbsp;shell-interpreted?<br>
&nbsp;<br>
List&nbsp;of&nbsp;allowed&nbsp;flags:<br>
s:&nbsp;silent&nbsp;mode.&nbsp;output&nbsp;will&nbsp;be&nbsp;discarded.<br>
d:&nbsp;detach&nbsp;the&nbsp;process.<br>
p:&nbsp;redirect&nbsp;output&nbsp;to&nbsp;the&nbsp;pager<br>
&nbsp;<br>
An&nbsp;uppercase&nbsp;key&nbsp;ensures&nbsp;that&nbsp;a&nbsp;certain&nbsp;flag&nbsp;will&nbsp;not&nbsp;be&nbsp;used.<br>&nbsp;</tt></td></tr>
<tr><td>&nbsp;</td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="AppContext-__init__"><strong>__init__</strong></a>(self, app<font color="#909090">='default'</font>, files<font color="#909090">=None</font>, mode<font color="#909090">=0</font>, flags<font color="#909090">=''</font>, fm<font color="#909090">=None</font>, stdout<font color="#909090">=None</font>, stderr<font color="#909090">=None</font>, stdin<font color="#909090">=None</font>, shell<font color="#909090">=None</font>, wait<font color="#909090">=True</font>, action<font color="#909090">=None</font>)</dt><dd><tt>The&nbsp;necessary&nbsp;parameters&nbsp;are&nbsp;fm&nbsp;and&nbsp;action&nbsp;or&nbsp;app.</tt></dd></dl>

<dl><dt><a name="AppContext-__iter__"><strong>__iter__</strong></a>(self)</dt><dd><tt>Iterates&nbsp;over&nbsp;all&nbsp;file&nbsp;paths</tt></dd></dl>

<dl><dt><a name="AppContext-get_action"><strong>get_action</strong></a>(self, apps<font color="#909090">=None</font>)</dt><dd><tt>Get&nbsp;the&nbsp;action&nbsp;from&nbsp;app_xyz</tt></dd></dl>

<dl><dt><a name="AppContext-run"><strong>run</strong></a>(self)</dt><dd><tt>Run&nbsp;the&nbsp;application&nbsp;in&nbsp;the&nbsp;way&nbsp;specified&nbsp;by&nbsp;the&nbsp;options.<br>
&nbsp;<br>
Returns&nbsp;False&nbsp;if&nbsp;nothing&nbsp;can&nbsp;be&nbsp;done,&nbsp;None&nbsp;if&nbsp;there&nbsp;was&nbsp;an&nbsp;error,<br>
otherwise&nbsp;the&nbsp;process&nbsp;<a href="builtins.html#object">object</a>&nbsp;returned&nbsp;by&nbsp;Popen().<br>
&nbsp;<br>
This&nbsp;function&nbsp;tries&nbsp;to&nbsp;find&nbsp;an&nbsp;action&nbsp;if&nbsp;none&nbsp;is&nbsp;defined.</tt></dd></dl>

<dl><dt><a name="AppContext-squash_flags"><strong>squash_flags</strong></a>(self)</dt><dd><tt>Remove&nbsp;duplicates&nbsp;and&nbsp;lowercase&nbsp;counterparts&nbsp;of&nbsp;uppercase&nbsp;flags</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> <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="Applications">class <strong>Applications</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
    
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt>This&nbsp;class&nbsp;contains&nbsp;definitions&nbsp;on&nbsp;how&nbsp;to&nbsp;run&nbsp;programs&nbsp;and&nbsp;should<br>
be&nbsp;extended&nbsp;in&nbsp;ranger.defaults.apps<br>
&nbsp;<br>
The&nbsp;user&nbsp;can&nbsp;decide&nbsp;what&nbsp;program&nbsp;to&nbsp;run,&nbsp;and&nbsp;if&nbsp;he&nbsp;uses&nbsp;eg.&nbsp;'vim',&nbsp;the<br>
function&nbsp;app_vim()&nbsp;will&nbsp;be&nbsp;called.&nbsp;&nbsp;However,&nbsp;usually&nbsp;the&nbsp;user<br>
simply&nbsp;wants&nbsp;to&nbsp;"start"&nbsp;the&nbsp;file&nbsp;without&nbsp;specific&nbsp;instructions.<br>
In&nbsp;such&nbsp;a&nbsp;case,&nbsp;app_default()&nbsp;is&nbsp;called,&nbsp;where&nbsp;you&nbsp;should&nbsp;examine<br>
the&nbsp;context&nbsp;and&nbsp;decide&nbsp;which&nbsp;program&nbsp;to&nbsp;use.<br>
&nbsp;<br>
All&nbsp;app&nbsp;functions&nbsp;have&nbsp;a&nbsp;name&nbsp;starting&nbsp;with&nbsp;app_&nbsp;and&nbsp;return&nbsp;a&nbsp;string<br>
containing&nbsp;the&nbsp;whole&nbsp;command&nbsp;or&nbsp;a&nbsp;tuple&nbsp;containing&nbsp;a&nbsp;list&nbsp;of&nbsp;the<br>
arguments.<br>
It&nbsp;has&nbsp;one&nbsp;argument,&nbsp;which&nbsp;is&nbsp;the&nbsp;<a href="#AppContext">AppContext</a>&nbsp;instance.<br>
&nbsp;<br>
You&nbsp;should&nbsp;define&nbsp;app_default,&nbsp;app_pager&nbsp;and&nbsp;app_editor&nbsp;since<br>
internal&nbsp;functions&nbsp;depend&nbsp;on&nbsp;those.&nbsp;&nbsp;Here&nbsp;are&nbsp;sample&nbsp;implementations:<br>
&nbsp;<br>
def&nbsp;app_default(self,&nbsp;context):<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;context.file.media:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;context.file.video:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;detach&nbsp;videos&nbsp;from&nbsp;the&nbsp;filemanager<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;context.flags&nbsp;+=&nbsp;'d'<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;app_mplayer(context)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;app_editor(context)<br>
&nbsp;<br>
def&nbsp;app_pager(self,&nbsp;context):<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;('less',&nbsp;)&nbsp;+&nbsp;tuple(context)<br>
&nbsp;<br>
def&nbsp;app_editor(self,&nbsp;context):<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;('vim',&nbsp;)&nbsp;+&nbsp;tuple(context)<br>&nbsp;</tt></td></tr>
<tr><td>&nbsp;</td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="Applications-all"><strong>all</strong></a>(self)</dt><dd><tt>Returns&nbsp;a&nbsp;list&nbsp;with&nbsp;all&nbsp;application&nbsp;functions</tt></dd></dl>

<dl><dt><a name="Applications-app_self"><strong>app_self</strong></a>(self, context)</dt><dd><tt>Run&nbsp;the&nbsp;file&nbsp;itself</tt></dd></dl>

<dl><dt><a name="Applications-get"><strong>get</strong></a>(self, app)</dt><dd><tt>Looks&nbsp;for&nbsp;an&nbsp;application,&nbsp;returns&nbsp;app_default&nbsp;if&nbsp;it&nbsp;doesn't&nbsp;exist</tt></dd></dl>

<dl><dt><a name="Applications-has"><strong>has</strong></a>(self, app)</dt><dd><tt>Returns&nbsp;whether&nbsp;an&nbsp;application&nbsp;is&nbsp;defined</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><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
    
<tr><td bgcolor="#eeaa77"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl><dt><a name="-run"><strong>run</strong></a>(action<font color="#909090">=None</font>, **kw)</dt><dd><tt>Shortcut&nbsp;for&nbsp;creating&nbsp;and&nbsp;immediately&nbsp;running&nbsp;an&nbsp;<a href="#AppContext">AppContext</a>.</tt></dd></dl>
 <dl><dt><a name="-tup"><strong>tup</strong></a>(*args)</dt><dd><tt>This&nbsp;helper&nbsp;function&nbsp;creates&nbsp;a&nbsp;tuple&nbsp;out&nbsp;of&nbsp;the&nbsp;arguments.<br>
&nbsp;<br>
('a',&nbsp;)&nbsp;+&nbsp;tuple(some_iterator)<br>
is&nbsp;equivalent&nbsp;to:<br>
<a href="#-tup">tup</a>('a',&nbsp;*some_iterator)</tt></dd></dl>
</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
    
<tr><td bgcolor="#55aa55"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><strong>ALLOWED_FLAGS</strong> = 'sdpSDP'<br>
<strong>PIPE</strong> = -1<br>
<strong>devnull</strong> = &lt;_io.TextIOWrapper name='/dev/null' encoding='UTF-8'&gt;</td></tr></table>
</body></html>