[Pypt-offline-general] SF.net SVN: pypt-offline: [132] trunk/pypt_core.py
Status: Beta
Brought to you by:
riteshsarraf
|
From: <rit...@us...> - 2007-03-22 09:57:08
|
Revision: 132
http://svn.sourceforge.net/pypt-offline/?rev=132&view=rev
Author: riteshsarraf
Date: 2007-03-22 02:57:06 -0700 (Thu, 22 Mar 2007)
Log Message:
-----------
* Removing the --debug option
* Adding color support on Windows using WConio
* Removed duplicate function definition of files() (is used for os.walk by find_first_match() )
Modified Paths:
--------------
trunk/pypt_core.py
Modified: trunk/pypt_core.py
===================================================================
--- trunk/pypt_core.py 2007-03-22 08:49:43 UTC (rev 131)
+++ trunk/pypt_core.py 2007-03-22 09:57:06 UTC (rev 132)
@@ -108,6 +108,21 @@
You should pass these options, taking it from optparse/getopt,
during instantiation'''
+ ''' WConio can provide simple coloring mechanism for Microsoft Windows console
+ Color Codes:
+ Black = 0
+ Green = 2
+ Red = 4
+ White = 15
+ Light Red = 12
+ Light Cyan = 11
+ '''
+
+ try:
+ import WConio
+ except ImportError:
+ WindowColor = False
+
def __init__(self, warnings, verbose, debug):
if warnings is True:
@@ -123,32 +138,32 @@
else: self.DEBUG = False
def msg(self, msg):
+ if self.WindowColor:
+ WConio.textcolor(15)
sys.stdout.write(msg)
sys.stdout.flush()
def err(self, msg):
+ if self.WindowColor:
+ WConio.textcolor(4)
sys.stderr.write(msg)
sys.stderr.flush()
# For the rest, we need to check the options also
def warn(self, msg):
if self.WARN is True:
- #if options.warnings is True:
+ if self.WindowColor:
+ WConio.textcolor(12)
sys.stderr.write(msg)
sys.stderr.flush()
def verbose(self, msg):
if self.VERBOSE is True:
- #if options.verbose is True:
+ if self.WindowColor:
+ WConio.textcolor(11)
sys.stdout.write(msg)
sys.stdout.flush()
- def debug(self, msg):
- if self.DEBUG is True:
- #if options.debug is True:
- sys.stdout.write(msg)
- sys.stdout.flush()
-
class Archiver:
def __init__(self, lock=None):
if lock is None or lock != 1:
@@ -257,7 +272,7 @@
return False
-def files(self, root):
+def files(root):
for path, folders, files in os.walk(root):
for file in files:
yield path, file
@@ -336,11 +351,6 @@
log.err("%s\n" % (e.reason))
if hasattr(e, 'code') and hasattr(e, 'reason'):
errfunc(e.code, e.reason, file)
-
-def files(root):
- for path, folders, files in os.walk(root):
- for file in files:
- yield path, file
def copy_first_match(cache_dir, filename, dest_dir, checksum): # aka new_walk_tree_copy()
'''Walks into "reposiotry" looking for "filename".
@@ -822,7 +832,6 @@
action="store", type="string", metavar=".")
parser.add_option("--verbose", dest="verbose", help="Enable verbose messages", action="store_true")
parser.add_option("--warnings", dest="warnings", help="Enable warnings", action="store_true")
- parser.add_option("--debug", dest="debug", help="Enable Debug mode", action="store_true")
parser.add_option("-u","--uris", dest="uris_file",
help="Full path of the uris file which contains the main database of files to be downloaded",action="store", type="string")
parser.add_option("","--disable-md5check", dest="disable_md5check",
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|