SF.net SVN: fclient:[875] trunk/fclient/fclient/impl/config.py
Status: Pre-Alpha
Brought to you by:
jurner
|
From: <jU...@us...> - 2008-08-09 07:34:14
|
Revision: 875
http://fclient.svn.sourceforge.net/fclient/?rev=875&view=rev
Author: jUrner
Date: 2008-08-09 07:34:24 +0000 (Sat, 09 Aug 2008)
Log Message:
-----------
bit more work to guess a fileName from a key
Modified Paths:
--------------
trunk/fclient/fclient/impl/config.py
Modified: trunk/fclient/fclient/impl/config.py
===================================================================
--- trunk/fclient/fclient/impl/config.py 2008-08-09 07:33:38 UTC (rev 874)
+++ trunk/fclient/fclient/impl/config.py 2008-08-09 07:34:24 UTC (rev 875)
@@ -4,6 +4,7 @@
if __name__ == '__main__': # see --> http://bugs.python.org/issue1510172 . works only current dir and below
import os; __path__ = [os.path.dirname(__file__)]
+import posixpath
import os
import weakref
from PyQt4 import QtCore
@@ -189,15 +190,19 @@
@paran default: what to return when no filename could be guessed?
@return: (QString) filename or or default if no filename was found
"""
- key = fcpKey.toString().rstrip('/')
filename = ''
if fcpKey.KeyType == fcp2.ConstKeyType.KSK:
if fcpKey.docName is not None:
- filename = os.path.basename(fcpKey.docName)
+ filename = posixpath.basename(fcpKey.docName)
+ elif fcpKey.KeyType == fcp2.ConstKeyType.CHK: #TODO: docName and tail allowed for CHKs? check fcp2.Key.CHK
+ if fcpKey.tail is not None:
+ filename = posixpath.basename(fcpKey.tail)
+ else:
+ if fcpKey.docName is not None:
+ filename = posixpath.basename(fcpKey.docName)
else:
- filename = os.path.basename(key)
- if filename == key:
- filename = ''
+ if fcpKey.tail is not None:
+ filename = posixpath.basename(fcpKey.tail)
if filename:
return QtCore.QString(filename)
return default
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|