Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/alkorgun/blacksmith-2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAl Korgun <alkorgun@gmail.com>2012-12-02 18:29:45 +0400
committerAl Korgun <alkorgun@gmail.com>2012-12-02 18:29:45 +0400
commit39f77268e1731a8c94004098acc327b9b02d6ff1 (patch)
treea634145283a2b1bc90eeb9572312a52b132490cc /expansions
parenta709c32f6bc941225cbe3e2307cfb6a97915f575 (diff)
refactoring
Diffstat (limited to 'expansions')
-rw-r--r--expansions/alive_keeper/code.py12
-rw-r--r--expansions/allweb/code.py15
-rw-r--r--expansions/basic_control/code.py2
-rw-r--r--expansions/config/code.py2
-rw-r--r--expansions/exp_control/code.py4
-rw-r--r--expansions/extra_control/code.py6
-rw-r--r--expansions/note/code.py30
-rw-r--r--expansions/note/insc.py4
-rw-r--r--expansions/roster_control/code.py36
9 files changed, 55 insertions, 56 deletions
diff --git a/expansions/alive_keeper/code.py b/expansions/alive_keeper/code.py
index be42720..ff53bfb 100644
--- a/expansions/alive_keeper/code.py
+++ b/expansions/alive_keeper/code.py
@@ -1,8 +1,8 @@
# coding: utf-8
# BlackSmith mark.2
-# exp_name = "alive_keeper" # /code.py v.x5
-# Id: 16~5c
+# exp_name = "alive_keeper" # /code.py v.x6
+# Id: 16~6c
# Code © (2011-2012) by WitcherGeralt [alkorgun@gmail.com]
class expansion_temp(expansion):
@@ -31,8 +31,10 @@ class expansion_temp(expansion):
Thr.kill()
try:
composeThr(connectAndDispatch, ThrName, (disp_str,)).start()
- except:
+ except iThr.error:
delivery(AnsBase[28] % (disp_str))
+ except:
+ collectExc(iThr.Thread.start)
elif expansions.has_key(self.name):
disp.aKeeper.plus()
iq = xmpp.Iq(to = "%s/%s" % (disp_str, GenResource), typ = Types[10])
@@ -68,8 +70,10 @@ class expansion_temp(expansion):
if TimerName not in ThrIds:
try:
composeTimer(180, ejoinTimer, TimerName, (conf.name,)).start()
- except:
+ except iThr.error:
pass
+ except:
+ collectExc(iThr.Thread.start)
elif expansions.has_key(self.name):
conf.aKeeper.plus()
iq = xmpp.Iq(to = "%s/%s" % (conf.name, conf.nick), typ = Types[10])
diff --git a/expansions/allweb/code.py b/expansions/allweb/code.py
index e0ee80f..6360917 100644
--- a/expansions/allweb/code.py
+++ b/expansions/allweb/code.py
@@ -1,8 +1,8 @@
# coding: utf-8
# BlackSmith mark.2
-# exp_name = "allweb" # /code.py v.x21
-# Id: 25~21c
+# exp_name = "allweb" # /code.py v.x22
+# Id: 25~22c
# Code © (2011-2012) by WitcherGeralt [alkorgun@gmail.com]
class expansion_temp(expansion):
@@ -581,10 +581,9 @@ class expansion_temp(expansion):
if not enough_access(source[1], source[2], 8):
folder = "Downloads"
if filename:
- ls = os.path.split(filename)
- if len(ls) > 1:
- filename = ls[-1]
+ filename = os.path.basename(filename.rstrip("\\/"))
if folder:
+ folder = os.path.normpath(folder)
if AsciiSys:
folder = folder.encode("utf-8")
if not os.path.isdir(folder):
@@ -851,14 +850,14 @@ class expansion_temp(expansion):
def command_gismeteo(self, stype, source, body, disp):
if body:
- ls = body.split()
+ ls = body.split(None, 1)
Numb = ls.pop(0)
if ls and isNumber(Numb):
- City = body[(body.find(Numb) + len(Numb)):].strip()
Numb = int(Numb)
+ City = ls.pop(0)
else:
- City = body
Numb = None
+ City = body
if -1 < Numb < 13 or not Numb:
Opener = Web("http://m.gismeteo.ru/citysearch/by_name/?", [("gis_search", City.encode("utf-8"))])
try:
diff --git a/expansions/basic_control/code.py b/expansions/basic_control/code.py
index 1bea6df..97d3e75 100644
--- a/expansions/basic_control/code.py
+++ b/expansions/basic_control/code.py
@@ -144,7 +144,7 @@ class expansion_temp(expansion):
if online(Name):
try:
Clients[Name].disconnect()
- except:
+ except IOError:
pass
if connect_client(Name, InstansesDesc[Name])[0]:
try:
diff --git a/expansions/config/code.py b/expansions/config/code.py
index 55f6445..0f91b96 100644
--- a/expansions/config/code.py
+++ b/expansions/config/code.py
@@ -118,7 +118,7 @@ class expansion_temp(expansion):
if online(Name):
try:
Clients[Name].disconnect()
- except:
+ except IOError:
pass
if Flood.has_key(Name):
del Flood[Name]
diff --git a/expansions/exp_control/code.py b/expansions/exp_control/code.py
index d1870c4..80740be 100644
--- a/expansions/exp_control/code.py
+++ b/expansions/exp_control/code.py
@@ -135,7 +135,7 @@ class expansion_temp(expansion):
cmd = Cmds.get(command)
if ls:
body = (ls.pop(0)).lower()
- if body in ("on", "вкл".decode("utf-8")):
+ if body in ("on", "1", "вкл".decode("utf-8")):
if not cmd.isAvalable:
if cmd.handler:
cmd.isAvalable = True
@@ -144,7 +144,7 @@ class expansion_temp(expansion):
answer = AnsBase[19] % (command)
else:
answer = self.AnsBase[16] % (command)
- elif body in ("off", "выкл".decode("utf-8")):
+ elif body in ("off", "0", "выкл".decode("utf-8")):
if cmd.isAvalable:
if cmd.handler:
cmd.isAvalable = False
diff --git a/expansions/extra_control/code.py b/expansions/extra_control/code.py
index fa281e1..ac38cdd 100644
--- a/expansions/extra_control/code.py
+++ b/expansions/extra_control/code.py
@@ -54,9 +54,9 @@ class expansion_temp(expansion):
if Number >= 0 and Number <= len(confs):
conf = confs[Number]
else:
- conf = False
+ conf = None
else:
- conf = False
+ conf = None
if conf:
itype = (body.pop(0)).lower()
if itype in ("chat", "чат".decode("utf-8")):
@@ -64,7 +64,7 @@ class expansion_temp(expansion):
elif itype in ("private", "приват".decode("utf-8")):
type2 = Types[0]
else:
- type2 = False
+ type2 = None
if type2:
cmd = (body.pop(0)).lower()
if body:
diff --git a/expansions/note/code.py b/expansions/note/code.py
index af5a4a1..8f91e44 100644
--- a/expansions/note/code.py
+++ b/expansions/note/code.py
@@ -87,26 +87,22 @@ class expansion_temp(expansion):
with database(self.NoteFile) as db:
db("select * from note where jid=?", (source_,))
db_desc = db.fetchone()
- if db_desc:
- Notes, Numb = str(), itypes.Number()
- for line in db_desc:
- if not Numb._int():
- Numb.plus()
- continue
- if line:
- Notes += "\nLine[%s] %s" % (Numb._str(), line)
- Numb.plus()
- if Notes:
- Notes = (self.AnsBase[6] % (Notes))
- if stype == Types[1]:
- Answer(AnsBase[11], stype, source, disp)
- Message(source[0], Notes, disp)
- else:
+ if db_desc:
+ notes = []
+ for numb, line in enumerate(db_desc):
+ if numb and line:
+ notes.append("Line[%s] %s" % (numb, line))
+ if notes:
+ Message(source[0], self.AnsBase[6] + str.join(chr(10), notes), disp)
+ if stype == Types[1]:
+ answer = AnsBase[11]
+ else:
+ with database(self.NoteFile) as db:
db("delete from note where jid=?", (source_,))
db.commit()
- answer = self.AnsBase[0]
- else:
answer = self.AnsBase[0]
+ else:
+ answer = self.AnsBase[0]
else:
answer = self.AnsBase[2]
if locals().has_key(Types[6]):
diff --git a/expansions/note/insc.py b/expansions/note/insc.py
index 532086f..2675fbf 100644
--- a/expansions/note/insc.py
+++ b/expansions/note/insc.py
@@ -8,7 +8,7 @@ if DefLANG in ("RU", "UA"):
"Все 16 строк уже заполнены.", # 3
"В блокноте 16 строк.", # 4
"Эта строка - пуста.", # 5
- "Твои записи:%s", # 6
+ "Твои записи:\n", # 6
"Запись добавлена под номером - %s.", # 7
"Эта строка итак пуста." # 8
)])
@@ -20,7 +20,7 @@ else:
"All of 16 lines are filled.", # 3
"There are 16 lines in note.", # 4
"This line is empty.", # 5
- "Your notes:%s", # 6
+ "Your notes:\n", # 6
"Recorded in line - %s.", # 7
"This line is already empty." # 8
) \ No newline at end of file
diff --git a/expansions/roster_control/code.py b/expansions/roster_control/code.py
index 626e79f..870f72f 100644
--- a/expansions/roster_control/code.py
+++ b/expansions/roster_control/code.py
@@ -16,41 +16,41 @@ class expansion_temp(expansion):
cls = sorted(Clients.keys())
if body:
ls = body.split()
- clnt = (ls.pop(0)).lower()
- if clnt in cls:
- cl_name = clnt
- elif isNumber(clnt):
+ body = (ls.pop(0)).lower()
+ if body in cls:
+ Name = body
+ elif isNumber(body):
Number = (int(clnt) - 1)
if Number >= 0 and Number <= len(cls):
- cl_name = cls[Number]
+ Name = cls[Number]
else:
- cl_name = False
+ Name = None
else:
- cl_name = False
- if cl_name:
+ Name = None
+ if Name:
if ls:
body = ls.pop(0)
if ls:
jid = (ls.pop(0)).lower()
if jid.count("."):
if body == "+":
- Clients[cl_name].Roster.Authorize(jid)
- Clients[cl_name].Roster.Subscribe(jid)
+ Clients[Name].Roster.Authorize(jid)
+ Clients[Name].Roster.Subscribe(jid)
if ls:
Tabe = ("admin", "админ".decode("utf-8"))
Nick = ls.pop(0)
if ls and Tabe.count(ls[0].lower()):
- Clients[cl_name].Roster.setItem(jid, Nick, ["Admins"])
+ Clients[Name].Roster.setItem(jid, Nick, ["Admins"])
else:
- Clients[cl_name].Roster.setItem(jid, Nick, ["Users"])
+ Clients[Name].Roster.setItem(jid, Nick, ["Users"])
else:
- Clients[cl_name].Roster.setItem(jid, (jid.split("@"))[0], ["Users"])
+ Clients[Name].Roster.setItem(jid, (jid.split("@"))[0], ["Users"])
answer = AnsBase[4]
elif body == "-":
- if jid in Clients[cl_name].Roster.keys():
- Clients[cl_name].Roster.Unauthorize(jid)
- Clients[cl_name].Roster.Unsubscribe(jid)
- Clients[cl_name].Roster.delItem(jid)
+ if jid in Clients[Name].Roster.keys():
+ Clients[Name].Roster.Unauthorize(jid)
+ Clients[Name].Roster.Unsubscribe(jid)
+ Clients[Name].Roster.delItem(jid)
answer = AnsBase[4]
else:
answer = self.AnsBase[0]
@@ -61,7 +61,7 @@ class expansion_temp(expansion):
else:
answer = AnsBase[2]
else:
- Rdsp = getattr(Clients[cl_name], "Roster")
+ Rdsp = getattr(Clients[Name], "Roster")
if Rdsp:
jids = Rdsp.keys()
for jid in jids: