Created a sorted list class
This commit is contained in:
parent
acdcca152e
commit
f1172d85d0
|
@ -1,9 +0,0 @@
|
|||
#! /usr/bin/python
|
||||
|
||||
# To change this template, choose Tools | Templates
|
||||
# and open the template in the editor.
|
||||
|
||||
__author__="bjschuma"
|
||||
__date__ ="$Feb 22, 2010 10:52:13 PM$"
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ def add(script):
|
|||
|
||||
def runScript(script):
|
||||
# Run commands if the script is not a python script
|
||||
if re.match("\w*\.py",script) == None:
|
||||
if re.match("(\/|\w)*\.py",script) == None:
|
||||
from bt import cmd
|
||||
f = file.fopen(script)
|
||||
for line in f:
|
||||
|
@ -34,6 +34,7 @@ def runScript(script):
|
|||
f.close()
|
||||
# Execute the script with the python interpreter as a backend
|
||||
else:
|
||||
write("Running python script: "+script,2)
|
||||
execfile(script)
|
||||
|
||||
|
||||
|
@ -65,7 +66,7 @@ def isScript(script):
|
|||
global scripts
|
||||
write("Checking if file is a script: "+script,2)
|
||||
for ext in extension:
|
||||
if not re.match("\w*\."+ext,script) == None:
|
||||
if not re.match("(\/|\w)*\."+ext,script) == None:
|
||||
scripts += [script]
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
|
||||
__author__="bjschuma"
|
||||
__date__ ="$Feb 22, 2010 10:52:13 PM$"
|
||||
|
||||
|
||||
# This is a sorted list (as long as items are inserted with add() )
|
||||
class slist(list):
|
||||
def __init__(self):
|
||||
list.__init__(self)
|
||||
|
||||
|
||||
def add(self,item):
|
||||
self += [item]
|
||||
self.sort()
|
||||
|
|
@ -16,16 +16,9 @@ class Plugin(plugin.Plugin):
|
|||
self.usage = "exec [command, file file.py]"
|
||||
|
||||
|
||||
def open(self):
|
||||
pass
|
||||
|
||||
|
||||
def close(self):
|
||||
pass
|
||||
|
||||
|
||||
def run(self, args=None):
|
||||
if args==None:
|
||||
write(self.usage)
|
||||
return
|
||||
|
||||
join = ' '
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
print "hello,world"
|
||||
import session
|
||||
from bt.message import write
|
||||
write(session.settings)
|
|
@ -0,0 +1,3 @@
|
|||
echo success!
|
||||
echo I love you, Holly!
|
||||
echo echo test!
|
|
@ -0,0 +1,2 @@
|
|||
echo this is a script
|
||||
echo 42
|
|
@ -0,0 +1 @@
|
|||
exec file tests/test.py
|
Loading…
Reference in New Issue