diff options
author | Xisco Fauli <anistenis@gmail.com> | 2013-02-11 22:01:25 +0100 |
---|---|---|
committer | Xisco Fauli <anistenis@gmail.com> | 2013-02-11 22:03:14 +0100 |
commit | 57041602e2e0c5d1035359108ff1237a324c39d6 (patch) | |
tree | e21d0c4e34caa6c8e0decc81bd0132f2309e225e /wizards/com/sun/star/wizards/common | |
parent | ebb263856c40d019c6aa9f5c281b33d26578004e (diff) |
pywizards: simplify paths handling
Change-Id: I436ca81e180d595e018811823e8b77c8b675bef5
Diffstat (limited to 'wizards/com/sun/star/wizards/common')
-rw-r--r-- | wizards/com/sun/star/wizards/common/FileAccess.py | 120 |
1 files changed, 0 insertions, 120 deletions
diff --git a/wizards/com/sun/star/wizards/common/FileAccess.py b/wizards/com/sun/star/wizards/common/FileAccess.py index fd7a97cd9ca5..409c15c4c267 100644 --- a/wizards/com/sun/star/wizards/common/FileAccess.py +++ b/wizards/com/sun/star/wizards/common/FileAccess.py @@ -16,10 +16,6 @@ # the License at http://www.apache.org/licenses/LICENSE-2.0 . # import traceback -from .NoValidPathException import NoValidPathException - -from com.sun.star.ucb import CommandAbortedException -from com.sun.star.awt.VclWindowPeerAttribute import OK, YES_NO ''' This class delivers static convenience methods @@ -41,109 +37,6 @@ class FileAccess(object): "com.sun.star.ucb.FileContentProvider") @classmethod - def deleteLastSlashfromUrl(self, _sPath): - if _sPath.endswith("/"): - return _sPath[:-1] - else: - return _sPath - - ''' - Further information on arguments value see in OO Developer Guide, - chapter 6.2.7 - @param xMSF - @param sPath - @param xSimpleFileAccess - @return the respective path of the office application. - A probable following "/" at the end is trimmed. - ''' - - @classmethod - def getOfficePath(self, xMSF, sPath, xSimpleFileAccess): - try: - ResultPath = "" - xInterface = xMSF.createInstance("com.sun.star.util.PathSettings") - ResultPath = str(Helper.getUnoPropertyValue(xInterface, sPath)) - ResultPath = self.deleteLastSlashfromUrl(ResultPath) - return ResultPath - except Exception: - 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 - ReturnPath = "" - try: - xUcbInterface = xMSF.createInstance( - "com.sun.star.ucb.SimpleFileAccess") - ReturnPath = _sFirstPath + _sSecondPath - bexists = xUcbInterface.exists(ReturnPath) - except Exception: - traceback.print_exc() - return "" - - if not bexists: - raise NoValidPathException (xMSF, ""); - - return ReturnPath - - @classmethod def getFolderTitles(self, xMSF, FilterName, FolderName, resDict=None): #Returns and ordered dict containing the template's name and path @@ -221,35 +114,22 @@ class FileAccess(object): ''' return the filename out of a system-dependent path - @param path - @return ''' @classmethod def getPathFilename(self, path): return self.getFilename(path, File.separator) - ''' - @author rpiterman - @param path - @param pathSeparator - @return - ''' - @classmethod def getFilename(self, path, pathSeparator = "/"): return path.split(pathSeparator)[-1] ''' - @param url - @return the parent dir of the given url. if the path points to file, gives the directory in which the file is. ''' @classmethod def getParentDir(self, url): - while url[-1] == "/": - url = hello[:-1] return url[:url.rfind("/")] @classmethod |