gump-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aj...@apache.org
Subject svn commit: r201655 - /gump/trunk/python/gump/actor/document/xdocs/documenter.py
Date Fri, 24 Jun 2005 17:43:11 GMT
Author: ajack
Date: Fri Jun 24 10:43:09 2005
New Revision: 201655

URL: http://svn.apache.org/viewcvs?rev=201655&view=rev
Log:
Don't fail simply listing files/directories.

Modified:
    gump/trunk/python/gump/actor/document/xdocs/documenter.py

Modified: gump/trunk/python/gump/actor/document/xdocs/documenter.py
URL: http://svn.apache.org/viewcvs/gump/trunk/python/gump/actor/document/xdocs/documenter.py?rev=201655&r1=201654&r2=201655&view=diff
==============================================================================
--- gump/trunk/python/gump/actor/document/xdocs/documenter.py (original)
+++ gump/trunk/python/gump/actor/document/xdocs/documenter.py Fri Jun 24 10:43:09 2005
@@ -2565,77 +2565,80 @@
                     fileList.createEntry("Owner (Referencer): "))
             
         if fileReference.exists():
-            if fileReference.isDirectory():                
+            try:
+                if fileReference.isDirectory():                
                 
-                listingSection=fdocument.createSection('Directory Contents')
-                listingTable=listingSection.createTable(['Filename','Type','Size'])
+                    listingSection=fdocument.createSection('Directory Contents')
+                    listingTable=listingSection.createTable(['Filename','Type','Size'])
                 
-                directory=fileReference.getPath()
+                    directory=fileReference.getPath()
                 
-                # Change to os.walk once we can move to Python 2.3
-                files=os.listdir(directory)
-                files.sort()
-                for listedFile in files:
+                    # Change to os.walk once we can move to Python 2.3
+                    files=os.listdir(directory)
+                    files.sort()
+                    for listedFile in files:
                     
-                    filePath=os.path.abspath(os.path.join(directory,listedFile))
-                    listingRow=listingTable.createRow()
+                        filePath=os.path.abspath(os.path.join(directory,listedFile))
+                        listingRow=listingTable.createRow()
                     
-                    #
-                    listingRow.createData(listedFile)    
+                        #
+                        listingRow.createData(listedFile)    
                     
-                    if os.path.isdir(filePath):
-                        listingRow.createData('Directory')
-                        listingRow.createData('N/A')
-                    else:
-                        listingRow.createData('File')    
-                        listingRow.createData(str(os.path.getsize(filePath)))           
                                    
-            else:    
+                        if os.path.isdir(filePath):
+                            listingRow.createData('Directory')
+                            listingRow.createData('N/A')
+                        else:
+                            listingRow.createData('File')    
+                            listingRow.createData(str(os.path.getsize(filePath)))       
                                        
+                else:    
                     
-                #
-                # Show the content...
-                #
-                outputSection=fdocument.createSection('File Contents')
-                output=fileReference.getPath()
-                if output:
-                    try:            
-                        if os.path.getsize(output) > 100000:
-                            #
-                            # This is *big* just copy/point to it
-                            #
-                            from shutil import copyfile
-                            # Extract name, to make relative to group
-                            outputBaseName=os.path.basename(output)
-                            (outputName,outputExtn)=os.path.splitext(outputBaseName)
-                            displayedOutput=self.resolver.getFile(fileReference, outputName,
outputExtn, 1)
+                    #
+                    # Show the content...
+                    #
+                    outputSection=fdocument.createSection('File Contents')
+                    output=fileReference.getPath()
+                    if output:
+                        try:            
+                            if os.path.getsize(output) > 100000:
+                                #
+                                # This is *big* just copy/point to it
+                                #
+                                from shutil import copyfile
+                                # Extract name, to make relative to group
+                                outputBaseName=os.path.basename(output)
+                                (outputName,outputExtn)=os.path.splitext(outputBaseName)
+                                displayedOutput=self.resolver.getFile(fileReference, outputName,
outputExtn, 1)
                         
-                            # Do the transfer..
-                            copyfile(output,displayedOutput)                        
-                            outputSection.createParagraph().createLink(outputBaseName,'Complete
File')
-                        else:
-                            outputSource=outputSection.createSource()    
-                            o=None
-                            try:
-                                # Keep a length count to not exceed 32K
-                                size=0
-                                o=open(output, 'r')
-                                line=o.readline()
-                                while line:
-                                    length = len(line)
-                                    size += length
-                                    # Crude to 'ensure' that escaped
-                                    # it doesn't exceed 32K.
-                                    if size > 20000:
-                                        outputSection.createParagraph('Continuation...')
-                                        outputSource=outputSection.createSource()
-                                        size = length
-                                    outputSource.createText(line)
+                                # Do the transfer..
+                                copyfile(output,displayedOutput)                        
+                                outputSection.createParagraph().createLink(outputBaseName,'Complete
File')
+                            else:
+                                outputSource=outputSection.createSource()    
+                                o=None
+                                try:
+                                    # Keep a length count to not exceed 32K
+                                    size=0
+                                    o=open(output, 'r')
                                     line=o.readline()
-                            finally:
-                                if o: o.close()
-                    except Exception, details:
-                        outputSection.createParagraph('Failed to copy contents from :' +
output + ' : ' + str(details))
-                else:
-                    outputSection.createParagraph('No contents in this file.')
+                                    while line:
+                                        length = len(line)
+                                        size += length
+                                        # Crude to 'ensure' that escaped
+                                        # it doesn't exceed 32K.
+                                        if size > 20000:
+                                            outputSection.createParagraph('Continuation...')
+                                            outputSource=outputSection.createSource()
+                                            size = length
+                                        outputSource.createText(line)
+                                        line=o.readline()
+                                finally:
+                                    if o: o.close()
+                        except Exception, details:
+                            outputSection.createParagraph('Failed to copy contents from :'
+ output + ' : ' + str(details))
+                    else:
+                        outputSection.createParagraph('No contents in this file.')      
         
+            except Exception, details:
+                fdocument.createWarning('Failed documeting file or directory. %s' % details)
         else:
             fdocument.createWarning('No such file or directory.')
            



Mime
View raw message