[Gelistirici] Göç Aracı

S.Çağlar Onur caglar at pardus.org.tr
6 Tem 2007 Cum 23:23:53 EEST


06 Tem 2007 Cum tarihinde, Murat ONGAN şunları yazmıştı: 
> Kodları incelemek, programı çalıştırmak isteyenler SVN'i ziyaret edebilir:
> http://svn.pardus.org.tr/uludag/trunk/staj-projeleri/migration-tool/src/
>
> Görüşlerinizi belirtirseniz, çalışmamı ona göre yönlendirebilirim.

Eline sağlık, hızlıca bakınca gözüme çarpan birkaç yorum;

- self.pix = QPixmap("/usr/share/icons/Tulliana-2.0/16x16/actions/folder.png")

gibi hard code değerler kullanma, iconPath KDE arkadaşa sorup öğrenilen 
birşey )

- return "a"+self.name

yerine return "a%s" % self.name daha şık, daha unicode sever :)

- QMessageBox.warning(self, u"Dikkat!", u"Seçtiğiniz dosyaların toplam 
boyutu %d MB, ancak sizin %d MB yeriniz var!"\

acilinden gettext desteği gerekiyor :)

-                 link.write("[Desktop 
Entry]\nEncoding=UTF-8\nIcon=%s\nType=Link\nURL=%s" % (icons[name] ,path))

gibi bir syntax yerine

hede = """
[Desktop Entry]
Encoding=UTF-8
Icon=%s
Type=Link
URL=%s"""

link.write(hede" % (icons[name] ,path))

kodu çok daha okunabilir hale getirecektir

- makedir at files.py

def makedir(path):
    "Makes a directory and returns its name."
    # If parent not exists, create it first
    dirname = os.path.dirname(path)
    if not os.path.isdir(dirname):
        dirname = makedir(dirname)
        path = os.path.join(dirname, os.path.basename(path))    # If parent 
name changed
    # If there is a file, find another name:
    if os.path.isfile(path):
        ext = 1
        while os.path.isfile(path + "_" + str(ext)):
            ext += 1
        path = (path + "_" + str(ext))
    # If directory already exists, return it
    if os.path.isdir(path):
        return path
    # If directory doesn't exists, create and return
    elif not os.path.exists(path):
        os.mkdir(path)
        return path
    else:
        raise IOError, "Directory '%s' cannot be created" % path

bu fonksiyon tamamen gereksiz os.makedirs neyine yetmedi :)

- aynı şekilde copy at files.py'de gözüme gereksiz geldi :)

- Tab/space karışmış bir dosya tab diğeri space kullanıyor

- Bunu daha öncede söylemiştim

def getPartitions():
·   "get all partitions in the form: '/mnt/hda9'"
·   partitions=[]
·   df = commands.getoutput("df")
·   df = string.split(df,"\n")
·   for i in df[1:]:
·   ·   i = string.split(i," ")
·   ·   partitions.append(i[-1])
·   return partitions

bu olacak şey değil, Bu bilgileri /sys altından veya HAL'a sorarak al lütfen.

- getThumbnail at Wallpaper.py

def getThumbnail(oldfile, width=100, height=100):
    newfile = tempfile.mktemp(".jpg")
    command = "convert '" + oldfile + "' -resize 100x100 '" + newfile + "'"
    os.system(command)
    return newfile

python imaging lib dururken external komut çalıştırmayalım lütfen (hatta 
os.system ile birşey çağırmayalım mümkünse :))

Arkası daha bir geniş zaman bulduğumda gelecek umarım :)

Saygılar
-- 
S.Çağlar Onur <caglar at pardus.org.tr>
http://cekirdek.pardus.org.tr/~caglar/

Linux is like living in a teepee. No Windows, no Gates and an Apache in house!
-------------- sonraki bölüm --------------
A non-text attachment was scrubbed...
Name: kullanılamıyor
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://liste.pardus.org.tr/gelistirici/attachments/20070706/55e6b725/attachment-0002.pgp>


Gelistirici mesaj listesiyle ilgili daha fazla bilgi