From 871508ef5dd628471328382055bde4093f09d0a6 Mon Sep 17 00:00:00 2001 From: Bastian Kleineidam Date: Wed, 10 Oct 2012 06:53:16 +0200 Subject: [PATCH] Add docs and updated copyright. --- linkcheck/cache/addrinfo.py | 1 + linkcheck/cache/connection.py | 4 +++- linkcheck/cache/content.py | 2 +- linkcheck/cache/robots_txt.py | 3 +++ linkcheck/cmdline.py | 2 ++ linkcheck/colorama.py | 8 ++++++++ linkcheck/lock.py | 2 +- tests/checker/ftpserver.py | 2 +- tests/test_clamav.py | 2 +- 9 files changed, 21 insertions(+), 5 deletions(-) diff --git a/linkcheck/cache/addrinfo.py b/linkcheck/cache/addrinfo.py index ca6d28f7..5fba18b3 100644 --- a/linkcheck/cache/addrinfo.py +++ b/linkcheck/cache/addrinfo.py @@ -27,6 +27,7 @@ from ..decorators import synchronized _lock = get_lock("addrinfo") class AddrInfo(object): + """Cache for socket.getaddrinfo() results.""" def __init__(self): """Initialize address info cache and cache statistics.""" diff --git a/linkcheck/cache/connection.py b/linkcheck/cache/connection.py index 8d805b77..f7b15239 100644 --- a/linkcheck/cache/connection.py +++ b/linkcheck/cache/connection.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2005-2011 Bastian Kleineidam +# Copyright (C) 2005-2012 Bastian Kleineidam # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -37,10 +37,12 @@ DefaultLimits = dict( ) def get_connection_id(connection): + """Return unique id for connection object.""" return id(connection) def is_expired(curtime, conn_data): + """Test if connection is expired.""" return (curtime+5.0) >= conn_data[2] diff --git a/linkcheck/cache/content.py b/linkcheck/cache/content.py index 55fc3110..dabb9a8b 100644 --- a/linkcheck/cache/content.py +++ b/linkcheck/cache/content.py @@ -24,6 +24,7 @@ from ..decorators import synchronized _lock = get_lock("checksums") class ChecksumInfo(object): + """Cache for content checksums.""" def __init__(self): """Initialize checksums and cache statistics.""" @@ -68,4 +69,3 @@ def get_checksum_urls(url, content): @rtype: list of unicode""" checksum = hashlib.sha1(content).hexdigest() return _checksuminfo.get_checksum_urls(url, checksum) - diff --git a/linkcheck/cache/robots_txt.py b/linkcheck/cache/robots_txt.py index 1a81f2f8..113d4e9e 100644 --- a/linkcheck/cache/robots_txt.py +++ b/linkcheck/cache/robots_txt.py @@ -48,6 +48,8 @@ class RobotsTxt (object): return self._allows_url(roboturl, url, proxy, user, password, callback) def _allows_url (self, roboturl, url, proxy, user, password, callback): + """Ask robots.txt allowance. Assumes only single thread per robots.txt + URL calls this function.""" with cache_lock: if roboturl in self.cache: self.hits += 1 @@ -69,4 +71,5 @@ class RobotsTxt (object): @synchronized(robot_lock) def get_lock(self, roboturl): + """Return lock for robots.txt url.""" return self.roboturl_locks.setdefault(roboturl, get_lock(roboturl)) diff --git a/linkcheck/cmdline.py b/linkcheck/cmdline.py index b15f69ea..5770e140 100644 --- a/linkcheck/cmdline.py +++ b/linkcheck/cmdline.py @@ -96,6 +96,7 @@ class LCOptionParser (optparse.OptionParser, object): @notimplemented def get_usage (self): + """Print usage text.""" pass def print_help_msg (self, s, out): @@ -109,6 +110,7 @@ class LCOptionParser (optparse.OptionParser, object): @notimplemented def print_help (self, file=None): + """Print help text to given file.""" pass diff --git a/linkcheck/colorama.py b/linkcheck/colorama.py index 1fabfd8a..bacee047 100644 --- a/linkcheck/colorama.py +++ b/linkcheck/colorama.py @@ -70,6 +70,7 @@ class CONSOLE_SCREEN_BUFFER_INFO(Structure): ("dwMaximumWindowSize", COORD), ] def __str__(self): + """Get string representation of console screen buffer info.""" return '(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)' % ( self.dwSize.Y, self.dwSize.X , self.dwCursorPosition.Y, self.dwCursorPosition.X @@ -79,6 +80,7 @@ class CONSOLE_SCREEN_BUFFER_INFO(Structure): ) def GetConsoleScreenBufferInfo(stream_id=STDOUT): + """Get console screen buffer info object.""" handle = handles[stream_id] csbi = CONSOLE_SCREEN_BUFFER_INFO() success = windll.kernel32.GetConsoleScreenBufferInfo( @@ -87,6 +89,7 @@ def GetConsoleScreenBufferInfo(stream_id=STDOUT): def SetConsoleTextAttribute(stream_id, attrs): + """Set a console text attribute.""" handle = handles[stream_id] return windll.kernel32.SetConsoleTextAttribute(handle, attrs) @@ -111,6 +114,7 @@ _default_style = None def init(): + """Initialize foreground and background attributes.""" global _default_foreground, _default_background, _default_style attrs = GetConsoleScreenBufferInfo(STDOUT).wAttributes _default_foreground = attrs & 7 @@ -119,10 +123,12 @@ def init(): def get_attrs(foreground, background, style): + """Get foreground and background attributes.""" return foreground + (background << 4) + style def set_console(stream=STDOUT, foreground=None, background=None, style=None): + """Set console foreground and background attributes.""" if foreground is None: foreground = _default_foreground if background is None: @@ -134,8 +140,10 @@ def set_console(stream=STDOUT, foreground=None, background=None, style=None): def reset_console(stream=STDOUT): + """Reset the console.""" set_console(stream=stream) def get_console_size(): + """Get the console size.""" return GetConsoleScreenBufferInfo(STDOUT).dwSize diff --git a/linkcheck/lock.py b/linkcheck/lock.py index 3ddedb27..988faefe 100644 --- a/linkcheck/lock.py +++ b/linkcheck/lock.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2005-2011 Bastian Kleineidam +# Copyright (C) 2005-2012 Bastian Kleineidam # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/checker/ftpserver.py b/tests/checker/ftpserver.py index dfff43c6..c2e83f3a 100644 --- a/tests/checker/ftpserver.py +++ b/tests/checker/ftpserver.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2010 Bastian Kleineidam +# Copyright (C) 2010-2012 Bastian Kleineidam # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/test_clamav.py b/tests/test_clamav.py index 73feb6eb..05cd8f5b 100644 --- a/tests/test_clamav.py +++ b/tests/test_clamav.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2006-2010 Bastian Kleineidam +# Copyright (C) 2006-2012 Bastian Kleineidam # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by