diff options
Diffstat (limited to 'wizards/com/sun/star/wizards/common/FileAccess.py')
-rw-r--r-- | wizards/com/sun/star/wizards/common/FileAccess.py | 117 |
1 files changed, 5 insertions, 112 deletions
diff --git a/wizards/com/sun/star/wizards/common/FileAccess.py b/wizards/com/sun/star/wizards/common/FileAccess.py index af0efd6413ed..dc49ab05e914 100644 --- a/wizards/com/sun/star/wizards/common/FileAccess.py +++ b/wizards/com/sun/star/wizards/common/FileAccess.py @@ -39,7 +39,7 @@ class FileAccess(object): "com.sun.star.ucb.FileContentProvider") self.xInterface = xmsf.createInstance( "com.sun.star.ucb.SimpleFileAccess") - + @classmethod def deleteLastSlashfromUrl(self, _sPath): if _sPath.endswith("/"): @@ -69,62 +69,6 @@ class FileAccess(object): traceback.print_exc() return "" - ''' - Further information on arguments value see in OO Developer Guide, - chapter 6.2.7 - @param xMSF - @param sPath - @param sType use "share" or "user". Set to "" - f not needed eg for the WorkPath; - In the return Officepath a possible slash at the end is cut off - @param sSearchDir - @return - @throws NoValidPathException - ''' - - @classmethod - def getOfficePath2(self, xMSF, sPath, sType, sSearchDir): - #This method currently only works with sPath="Template" - bexists = False - try: - xPathInterface = xMSF.createInstance( - "com.sun.star.util.PathSettings") - ResultPath = "" - ReadPaths = () - xUcbInterface = xMSF.createInstance( - "com.sun.star.ucb.SimpleFileAccess") - Template_writable = xPathInterface.getPropertyValue( - sPath + "_writable") - Template_internal = xPathInterface.getPropertyValue( - sPath + "_internal") - Template_user = xPathInterface.getPropertyValue( - sPath + "_user") - if not hasattr(Template_internal, '__dict__'): - ReadPaths = ReadPaths + Template_internal - if not hasattr(Template_user, '__dict__'): - ReadPaths = ReadPaths + Template_user - ReadPaths = ReadPaths + (Template_writable,) - if sType.lower() == "user": - ResultPath = Template_writable - bexists = True - else: - #find right path using the search sub path - for i in ReadPaths: - tmpPath = i + sSearchDir - if xUcbInterface.exists(tmpPath): - ResultPath = i - bexists = True - break - - ResultPath = self.deleteLastSlashfromUrl(ResultPath) - except Exception: - traceback.print_exc() - ResultPath = "" - - if not bexists: - raise NoValidPathException (xMSF, "") - return ResultPath - @classmethod def combinePaths(self, xMSF, _sFirstPath, _sSecondPath): bexists = False @@ -146,7 +90,7 @@ class FileAccess(object): @classmethod def getFolderTitles(self, xMSF, FilterName, FolderName, resDict=None): #Returns and ordered dict containing the template's name and path - + locLayoutFiles = [] try: xDocInterface = xMSF.createInstance( @@ -158,7 +102,7 @@ class FileAccess(object): FilterName = None else: FilterName += "-" - + locLayoutDict = {} for i in nameList: fileName = self.getFilename(i) @@ -173,7 +117,7 @@ class FileAccess(object): else: title = xDocInterface.Title locLayoutDict[title] = i - + #sort the dictionary and create a list containing the #keys list and the values list keysList = sorted(locLayoutDict.keys()) @@ -181,7 +125,7 @@ class FileAccess(object): for i in keysList: valuesList.append(locLayoutDict[i]) locLayoutFiles.append(keysList) - locLayoutFiles.append(valuesList) + locLayoutFiles.append(valuesList) except Exception: traceback.print_exc() @@ -234,20 +178,6 @@ class FileAccess(object): traceback.print_exc() return default - def isDirectory(self, filename): - try: - return self.xInterface.isFolder(filename) - except Exception: - traceback.print_exc() - return False - - def getLastModified(self, url): - try: - return self.xInterface.getDateTimeModified(url) - except Exception: - traceback.print_exc() - return None - def delete(self, filename): try: self.xInterface.kill(filename) @@ -267,24 +197,6 @@ class FileAccess(object): traceback.print_exc() return [""] - # - # @param s - # @return - def mkdir(self, s): - try: - self.xInterface.createFolder(s) - return True - except Exception: - traceback.print_exc() - return False - - def createNewDir(self, parentDir, name): - s = self.getNewFile(parentDir, name, "") - if (self.mkdir(s)): - return s - else: - return None - def getSize(self, url): try: return self.xInterface.getSize(url) @@ -292,17 +204,6 @@ class FileAccess(object): traceback.print_exc() return -1 - def getNewFile(self, parentDir, name, extension): - i = 0 - url = "" - while (True): - filename = self.filename(name, extension, i) - url = self.getURL(parentDir, filename) - if (not self.exists(url, True)): - break - i += 1 - return url - def getURL(self, parentURL, childPath): if len(childPath) > 0 and childPath[0] == "/": path = parentURL + childPath @@ -310,14 +211,6 @@ class FileAccess(object): path = parentURL + "/" + childPath return path - ''' - return the filename out of a system-dependent path - ''' - - @classmethod - def getPathFilename(self, path): - return self.getFilename(path, FileSeparator) - @classmethod def getFilename(self, path, pathSeparator = "/"): return path.split(pathSeparator)[-1] |