# Copyright 2005 James Bunton <james@delx.cjb.net>
# Licensed for distribution under the GPL version 2, check COPYING for details
+from tlib import xmlw
+
import utils
import config
import xdb
import os.path
+X = os.path.sep
+
def init():
global noteList
global noteListF
class NotesToMyself:
def __init__(self):
- pre = os.path.abspath(config.spooldir) + "/" + config.jid + "/"
- self.filename = pre + "/notes_to_myself"
+ pre = os.path.abspath(config.spooldir) + X + config.jid + X
+ self.filename = pre + X + "notes_to_myself"
self.notes = []
if os.path.exists(self.filename):
def doSpoolPrepCheck():
- pre = os.path.abspath(config.spooldir) + "/" + config.jid + "/"
+ pre = os.path.abspath(config.spooldir) + X + config.jid + X
print "Checking spool files and stringprepping any if necessary...",
for file in os.listdir(pre):
try:
file = xdb.unmangle(file).decode("utf-8")
- filej = utils.jid(file).full()
+ filej = xmlw.jid.intern(file).full()
if(file != filej):
file = xdb.mangle(file)
filej = xdb.mangle(filej)
print "Upgrading your XDB structure to use hashed directories for speed...",
# Do avatars...
- pre = os.path.abspath(config.spooldir) + "/" + config.jid + "/avatars/"
+ pre = os.path.join(os.path.abspath(config.spooldir), config.jid) + X + "avatars" + X
if os.path.exists(pre):
for file in os.listdir(pre):
try:
if os.path.isfile(pre + file):
- pre2 = pre + file[0:3] + "/"
+ pre2 = pre + file[0:3] + X
if not os.path.exists(pre2):
os.makedirs(pre2)
shutil.move(pre + file, pre2 + file)
raise
# Do spool files...
- pre = os.path.abspath(config.spooldir) + "/" + config.jid + "/"
+ pre = os.path.join(os.path.abspath(config.spooldir), config.jid) + X
if os.path.exists(pre):
for file in os.listdir(pre):
try:
if os.path.isfile(pre + file) and file != "notes_to_myself":
hash = file[0:2]
- pre2 = pre + hash + "/"
+ pre2 = pre + hash + X
if not os.path.exists(pre2):
os.makedirs(pre2)