www-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

www/server/source/linc linc.py


From: Pavel Kharitonov
Subject: www/server/source/linc linc.py
Date: Tue, 23 Dec 2014 14:02:45 +0000

CVSROOT:        /web/www
Module name:    www
Changes by:     Pavel Kharitonov <ineiev>       14/12/23 14:02:44

Modified files:
        server/source/linc: linc.py 

Log message:
        Add an option to skip symlinks.

CVSWeb URLs:
http://web.cvs.savannah.gnu.org/viewcvs/www/server/source/linc/linc.py?cvsroot=www&r1=1.24&r2=1.25

Patches:
Index: linc.py
===================================================================
RCS file: /web/www/www/server/source/linc/linc.py,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- linc.py     7 Dec 2014 09:51:57 -0000       1.24
+++ linc.py     23 Dec 2014 14:02:44 -0000      1.25
@@ -18,7 +18,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-LINC_VERSION = 'LINC 0.20'
+LINC_VERSION = 'LINC 0.21'
 USAGE = \
 '''Usage: %prog [options] [BASE_DIRECTORY]
 Check links in HTML files from BASE_DIRECTORY.'''
@@ -77,6 +77,9 @@
 # Don't download the files, assume no error.
 LOCAL = False
 
+# Don't process symlinks.
+NO_SYMLINKS = False
+
 CACHE = None
 
 # Matching directories will not be entered to check their
@@ -328,6 +331,7 @@
 
 def scan_file(root, file_to_check, symlink = None):
        path = os.path.join(root, file_to_check)
+       report (3, 'scanning file ' + path)
        fd = open(path, 'r')
        text = fd.read()
        fd.close()
@@ -364,6 +368,7 @@
                                          'type': link_type}
 
 def scan_directory(root, directory):
+       report (3, 'scanning directory ' + directory)
        for element_name in os.listdir(os.path.join(root, directory)):
                relative_path = os.path.join(directory, element_name)
                full_path = os.path.join(root, relative_path)
@@ -547,6 +552,8 @@
 parser.add_option('-l', '--local', dest = 'local', action = 'store_true',
                  default = False,
                  help = "don't download files, assume no error")
+parser.add_option('-n', '--no-symlinks', dest = 'no_symlinks', action = 
'store_true',
+                 default = False, help = "don't process .symlinks")
 parser.add_option('-o', '--output', dest = 'dir_name', metavar = 'DIRECTORY',
                  help = 'write reports to DIRECTORY [' \
                         + REPORT_FILE_PREFIX + ']')
@@ -627,6 +634,8 @@
        EXCLUDED_DIRECTORIES_REGEXP = options.exclude_dir
 if options.local != None:
        LOCAL = options.local
+if options.no_symlinks != None:
+       NO_SYMLINKS = options.no_symlinks
 CACHE = options.cache
 
 base_directory = BASE_DIRECTORY
@@ -658,6 +667,7 @@
 report(0, "Excluded files:       `" + EXCLUDED_FILENAMES_REGEXP + "'")
 report(0, "Excluded directories: `" + EXCLUDED_DIRECTORIES_REGEXP + "'")
 report(0, "Run locally:           " + str(LOCAL))
+report(0, "Skip .symlinks:        " + str(NO_SYMLINKS))
 report(0, "Verbosity:             " + str(VERBOSE))
 report(0, "Wickedness:            " + str(WICKED))
 
@@ -669,8 +679,11 @@
 links_to_check = []
 urls_to_check = {}
 scan_directory(base_directory, '')
-report(-1, 'Processing symlinks...')
-process_symlinks(base_directory)
+if NO_SYMLINKS:
+       report(-1, 'Skipping all .symlinks')
+else:
+       report(-1, 'Processing symlinks...')
+       process_symlinks(base_directory)
 checked_urls = load_cache(CACHE)
 unique_links = str(len(urls_to_check))
 cached_links = 0



reply via email to

[Prev in Thread] Current Thread [Next in Thread]