Revision: 8807 Author: purodha Date: 2010-12-27 21:34:11 +0000 (Mon, 27 Dec 2010) Log Message: ----------- Cosmetic changes. Typos in documentation and more logical code ordering.
Modified Paths: -------------- trunk/pywikipedia/basic.py trunk/pywikipedia/config.py trunk/pywikipedia/interwiki.py
Modified: trunk/pywikipedia/basic.py =================================================================== --- trunk/pywikipedia/basic.py 2010-12-26 16:44:25 UTC (rev 8806) +++ trunk/pywikipedia/basic.py 2010-12-27 21:34:11 UTC (rev 8807) @@ -58,7 +58,7 @@ """ Constructor. Parameters: @param generator: The page generator that determines on which pages - to work on. + to work. @type generator: generator. @param dry: If True, doesn't do any real changes, but only shows what would have been changed.
Modified: trunk/pywikipedia/config.py =================================================================== --- trunk/pywikipedia/config.py 2010-12-26 16:44:25 UTC (rev 8806) +++ trunk/pywikipedia/config.py 2010-12-27 21:34:11 UTC (rev 8807) @@ -1,8 +1,9 @@ # -*- coding: utf-8 -*- # # (C) Rob W.W. Hooft, 2003 +# parts by holger@trillke.net 2002/03/18 # Purodha Blissenbach (Modifier), 2010 - +# (C) Pywikipedia bot team, 2007-2010 # # Distributed under the terms of the MIT license. # @@ -467,7 +468,44 @@ # End of configuration section # ============================
+def makepath(path): + """Return a normalized absolute version of the path argument.
+ - if the given path already exists in the filesystem + the filesystem is not modified. + + - otherwise makepath creates directories along the given path + using the dirname() of the path. You may append + a '/' to the path if you want it to be a directory path. + + from holger@trillke.net 2002/03/18 + + """ + from os import makedirs + from os.path import normpath, dirname, exists, abspath + + dpath = normpath(dirname(path)) + if not exists(dpath): makedirs(dpath) + return normpath(abspath(path)) + +def datafilepath(*filename): + """Return an absolute path to a data file in a standard location. + + Argument(s) are zero or more directory names, optionally followed by a + data file name. The return path is offset to config.base_dir. Any + directories in the path that do not already exist are created. + + """ + import os + return makepath(os.path.join(base_dir, *filename)) + +def shortpath(path): + """Return a file path relative to config.base_dir.""" + import os + if path.startswith(base_dir): + return path[len(base_dir) + len(os.path.sep) : ] + return path + # is config verbose? _verbose = False for _arg in __sys.argv[1:]: @@ -546,46 +584,6 @@
# Save base_dir for use by other modules base_dir = _base_dir - -def makepath(path): - """Return a normalized absolute version of the path argument. - - - if the given path already exists in the filesystem - the filesystem is not modified. - - - otherwise makepath creates directories along the given path - using the dirname() of the path. You may append - a '/' to the path if you want it to be a directory path. - - from holger@trillke.net 2002/03/18 - - """ - from os import makedirs - from os.path import normpath, dirname, exists, abspath - - dpath = normpath(dirname(path)) - if not exists(dpath): makedirs(dpath) - return normpath(abspath(path)) - -def datafilepath(*filename): - """Return an absolute path to a data file in a standard location. - - Argument(s) are zero or more directory names, optionally followed by a - data file name. The return path is offset to config.base_dir. Any - directories in the path that do not already exist are created. - - """ - import os - return makepath(os.path.join(base_dir, *filename)) - -def shortpath(path): - """Return a file path relative to config.base_dir.""" - import os - if path.startswith(base_dir): - return path[len(base_dir) + len(os.path.sep) : ] - return path - - if _verbose: print "- base_dir: ", base_dir
@@ -615,7 +613,7 @@ for _name in _k: if _name[0] != '_': if not type(globals()[_name]) in [types.FunctionType, types.ModuleType]: - try: + try: if _all or _glv[_name] != globals()[_name]: print _name, "=", repr(globals()[_name]) except KeyError:
Modified: trunk/pywikipedia/interwiki.py =================================================================== --- trunk/pywikipedia/interwiki.py 2010-12-26 16:44:25 UTC (rev 8806) +++ trunk/pywikipedia/interwiki.py 2010-12-27 21:34:11 UTC (rev 8807) @@ -276,7 +276,7 @@ For example, if the local page has links to de and fr, this option will make sure that only the local site and the de: (larger) sites are updated. This option is useful - to quickly set two way links without updating all of + to quickly set two way links without updating all of the wiki families sites. (note: without ending colon)
pywikipedia-svn@lists.wikimedia.org