Package pallavi :: Package plugins :: Module OpenCommandLine
[hide private]
[frames] | no frames]

Source Code for Module pallavi.plugins.OpenCommandLine

 1  # Copyright (c) 2007 Dusty Phillips 
 2   
 3  # Permission is hereby granted, free of charge, to any person obtaining a 
 4  # copy of this software and associated documentation files (the "Software"), 
 5  # to deal in the Software without restriction, including without limitation 
 6  # the rights to use, copy, modify, merge, publish, distribute, sublicense, 
 7  # and/or sell copies of the Software, and to permit persons to whom the 
 8  # Software is furnished to do so, subject to the following conditions: 
 9   
10  # The above copyright notice and this permission notice shall be included in 
11  # all copies or substantial portions of the Software. 
12   
13  # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
14  # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
15  # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
16  # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
17  # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
18  # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
19  # DEALINGS IN THE SOFTWARE. 
20   
21  '''Plugin provides the ability to open files listed on the command line. 
22  If the argument -- is provided in the command line arguments, all following 
23  arguments will be opened as files. If it is not provided, then all arguments 
24  will be open. This allows other plugins to parse command line arguments provided 
25  before the --, for example, to specify the configuration file. 
26   
27  This plugin invokes the following actions: 
28  OpenFile 
29          Expects another plugin to open the filename it provides as data''' 
30  import wx 
31  import os.path 
32   
33   
34 -def setup():
35 '''Checks for any command line arguments and opens files for them on startup.''' 36 try: 37 index = config.sysargs.index('--') 38 except ValueError: 39 index = -1 40 for x in config.sysargs[index+1:]: 41 if os.path.isfile(x) or not os.path.exists(x): 42 actions.Invoke("OpenFile", [os.path.abspath(x)])
43