[Skencil-commits] r728 - skencil/branches/skencil-0.6/src/Sketch/Lib

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Sep 22 23:52:57 CEST 2010


Author: igor_n
Date: 2010-09-22 23:52:57 +0200 (Wed, 22 Sep 2010)
New Revision: 728

Modified:
   skencil/branches/skencil-0.6/src/Sketch/Lib/dscparser.py
   skencil/branches/skencil-0.6/src/Sketch/Lib/psmisc.py
   skencil/branches/skencil-0.6/src/Sketch/Lib/skcompleter.py
   skencil/branches/skencil-0.6/src/Sketch/Lib/util.py
Log:
mixed indents are removed

Modified: skencil/branches/skencil-0.6/src/Sketch/Lib/dscparser.py
===================================================================
--- skencil/branches/skencil-0.6/src/Sketch/Lib/dscparser.py	2010-09-22 21:52:28 UTC (rev 727)
+++ skencil/branches/skencil-0.6/src/Sketch/Lib/dscparser.py	2010-09-22 21:52:57 UTC (rev 728)
@@ -33,7 +33,7 @@
     from warn import warn, INTERNAL
 except ImportError:
     def warn(*args):
-	pass
+        pass
     INTERNAL = None
 
 # match a line containing a DSC-comment.
@@ -84,35 +84,35 @@
 class EpsInfo:
 
     def __init__(self):
-	self.DocumentSuppliedResources = {}
-	self.DocumentNeededResources   = {}
-	self.BoundingBox = None
-	self.atend = 0
+        self.DocumentSuppliedResources = {}
+        self.DocumentNeededResources   = {}
+        self.BoundingBox = None
+        self.atend = 0
 
     def NeedResources(self, type, resources):
-	for res in resources:
-	    self.DocumentNeededResources[(type, res)] = 1
+        for res in resources:
+            self.DocumentNeededResources[(type, res)] = 1
 
     def SupplyResources(self, type, resources):
-	for res in resources:
-	    self.DocumentSuppliedResources[(type, res)] = 1
+        for res in resources:
+            self.DocumentSuppliedResources[(type, res)] = 1
 
     def print_info(self):
-	# print the contents of self in a readable manner. (for debugging)
-	print 'BoundingBox:\t%s' % `self.BoundingBox`
-	print 'DocumentNeededResources: [',
-	for res in self.DocumentNeededResources.keys():
-	    print res,
-	print ']'
-	print 'DocumentSuppliedResources: [',
-	for res in self.DocumentSuppliedResources.keys():
-	    print res,
-	print ']'
+        # print the contents of self in a readable manner. (for debugging)
+        print 'BoundingBox:\t%s' % `self.BoundingBox`
+        print 'DocumentNeededResources: [',
+        for res in self.DocumentNeededResources.keys():
+            print res,
+        print ']'
+        print 'DocumentSuppliedResources: [',
+        for res in self.DocumentSuppliedResources.keys():
+            print res,
+        print ']'
 
-	for key, value in self.__dict__.items():
-	    if key not in ('BoundingBox', 'DocumentNeededResources',
-			   'DocumentSuppliedResources', 'atend'):
-		print '%s\t%s' % (key, value)
+        for key, value in self.__dict__.items():
+            if key not in ('BoundingBox', 'DocumentNeededResources',
+                           'DocumentSuppliedResources', 'atend'):
+                print '%s\t%s' % (key, value)
 
 def IsEpsFileStart(data):
     # return true if data might be the beginning of an Encapsulated
@@ -131,69 +131,69 @@
     line = file.readline()
     last_key = ''
     while line:
-	match = rx_dsccomment.match(line)
-	if match:
-	    key = match.group(1)
-	    value = strip(line[match.end(0):])
-	    if key == 'EndComments' or key == 'EOF':
-		break
+        match = rx_dsccomment.match(line)
+        if match:
+            key = match.group(1)
+            value = strip(line[match.end(0):])
+            if key == 'EndComments' or key == 'EOF':
+                break
 
-	    if key == '+':
-		key = last_key
-	    else:
-		last_key = ''
+            if key == '+':
+                key = last_key
+            else:
+                last_key = ''
 
-	    if key == 'BoundingBox':
-		if value != ATEND:
-		    # the bounding box should be given in UINTs
-		    # but may also (incorrectly) be float.
-		    info.BoundingBox = tuple(map(atof, split(value)))
-		else:
-		    info.atend = 1
-	    elif key == 'DocumentNeededResources':
-		if value != ATEND:
-		    if value:
-			[type, value] = split(value, None, 1)
-			if type == 'font':
-			    info.NeedResources(type, split(value))
-			else:
-			    # XXX: might occasionally be interesting for the
-			    # user
-			    warn(INTERNAL, 'needed resource %s %s ignored',
-				 type, value)
-		else:
-		    info.atend = 1
-	    elif key == 'DocumentNeededFonts':
-		if value != ATEND:
-		    info.NeedResources('font', split(value))
-		else:
-		    info.atend = 1
-	    elif key == 'DocumentSuppliedResources':
-		if value != ATEND:
-		    if value:
-			[type, value] = split(value, None, 1)
-			if type == 'font':
-			    info.NeedResources(type, split(value))
-			else:
-			    # XXX: might occasionally be interesting for the
-			    # user
-			    warn(INTERNAL, 'supplied resource %s %s ignored',
-				 type, value)
-		else:
-		    info.atend = 1
-	    else:
-		setattr(info, key, value)
-	    #
-	    last_key = key
-	else:
-	    # the header comments end at a line not beginning with %X,
-	    # where X is a printable character not in SPACE, TAB, NL
-	    # XXX: It is probably wrong to do this in the %%Trailer
-	    if line[0] != '%':
-		break
-	    if len(line) == 1 or line[1] not in endcommentchars:
-		break
-	line = file.readline()
+            if key == 'BoundingBox':
+                if value != ATEND:
+                    # the bounding box should be given in UINTs
+                    # but may also (incorrectly) be float.
+                    info.BoundingBox = tuple(map(atof, split(value)))
+                else:
+                    info.atend = 1
+            elif key == 'DocumentNeededResources':
+                if value != ATEND:
+                    if value:
+                        [type, value] = split(value, None, 1)
+                        if type == 'font':
+                            info.NeedResources(type, split(value))
+                        else:
+                            # XXX: might occasionally be interesting for the
+                            # user
+                            warn(INTERNAL, 'needed resource %s %s ignored',
+                                 type, value)
+                else:
+                    info.atend = 1
+            elif key == 'DocumentNeededFonts':
+                if value != ATEND:
+                    info.NeedResources('font', split(value))
+                else:
+                    info.atend = 1
+            elif key == 'DocumentSuppliedResources':
+                if value != ATEND:
+                    if value:
+                        [type, value] = split(value, None, 1)
+                        if type == 'font':
+                            info.NeedResources(type, split(value))
+                        else:
+                            # XXX: might occasionally be interesting for the
+                            # user
+                            warn(INTERNAL, 'supplied resource %s %s ignored',
+                                 type, value)
+                else:
+                    info.atend = 1
+            else:
+                setattr(info, key, value)
+            #
+            last_key = key
+        else:
+            # the header comments end at a line not beginning with %X,
+            # where X is a printable character not in SPACE, TAB, NL
+            # XXX: It is probably wrong to do this in the %%Trailer
+            if line[0] != '%':
+                break
+            if len(line) == 1 or line[1] not in endcommentchars:
+                break
+        line = file.readline()
 
 def skip_to_comment(file, comment):
     # Read lines from FILE until a line with a DSC comment COMMENT is
@@ -206,39 +206,39 @@
     # comment. Raise a DSCError if the comment is not found
     line = file.readline()
     while line:
-	match = rx_dsccomment.match(line)
-	if match:
-	    key = match.group(1)
-	    if key == comment:
-		return
-	    elif key == 'BeginDocument':
-		# skip embedded document
-		skip_to_comment(file, 'EndDocument')
-	    elif key == 'BeginData':
-		value = split(strip(line[match.end(0):]))
-		lines = 0
-		if len(value) >= 1:
-		    count = int(value[0])
-		    if len(value) == 3:
-			lines = value[2] == 'Lines'
-		else:
-		    # should never happen in a conforming document...
-		    count = 0
-		if count > 0:
-		    if lines:
-			for i in range(count):
-			    file.readline()
-		    else:
-			blocksize = 4000
-			while count:
-			    if count > blocksize:
-				count = count - len(file.read(blocksize))
-			    else:
-				count = count - len(file.read(count))
-	line = file.readline()
+        match = rx_dsccomment.match(line)
+        if match:
+            key = match.group(1)
+            if key == comment:
+                return
+            elif key == 'BeginDocument':
+                # skip embedded document
+                skip_to_comment(file, 'EndDocument')
+            elif key == 'BeginData':
+                value = split(strip(line[match.end(0):]))
+                lines = 0
+                if len(value) >= 1:
+                    count = int(value[0])
+                    if len(value) == 3:
+                        lines = value[2] == 'Lines'
+                else:
+                    # should never happen in a conforming document...
+                    count = 0
+                if count > 0:
+                    if lines:
+                        for i in range(count):
+                            file.readline()
+                    else:
+                        blocksize = 4000
+                        while count:
+                            if count > blocksize:
+                                count = count - len(file.read(blocksize))
+                            else:
+                                count = count - len(file.read(count))
+        line = file.readline()
 
     else:
-	raise DSCError('DSC-Comment %s not found' % comment)
+        raise DSCError('DSC-Comment %s not found' % comment)
 
 
 
@@ -251,12 +251,12 @@
     info = EpsInfo()
 
     if IsEpsFileStart(line):
-	parse_header(file, info)
-	if info.atend:
-	    skip_to_comment(file, 'Trailer')
-	    parse_header(file, info)
+        parse_header(file, info)
+        if info.atend:
+            skip_to_comment(file, 'Trailer')
+            parse_header(file, info)
     else:
-	raise DSCError('%s is not an EPS file' % filename)
+        raise DSCError('%s is not an EPS file' % filename)
 
     file.close()
 
@@ -275,8 +275,8 @@
 
     parse_header(file, info)
     if info.atend:
-	skip_to_comment(file, 'Trailer')
-	parse_header(file, info)
+        skip_to_comment(file, 'Trailer')
+        parse_header(file, info)
 
     file.close()
 

Modified: skencil/branches/skencil-0.6/src/Sketch/Lib/psmisc.py
===================================================================
--- skencil/branches/skencil-0.6/src/Sketch/Lib/psmisc.py	2010-09-22 21:52:28 UTC (rev 727)
+++ skencil/branches/skencil-0.6/src/Sketch/Lib/psmisc.py	2010-09-22 21:52:57 UTC (rev 728)
@@ -26,12 +26,12 @@
     table = [''] * 256
     quote = (ord('('), ord(')'), ord('\\'))
     for i in range(128):
-	if i in quote:
-	    table[i] = '\\' + chr(i)
-	else:
-	    table[i] = chr(i)
+        if i in quote:
+            table[i] = '\\' + chr(i)
+        else:
+            table[i] = chr(i)
     for i in range(128, 256):
-	table[i] = '\\' + oct(i)[1:]
+        table[i] = '\\' + oct(i)[1:]
     return table
 
 quote_table = make_ps_quote_table()
@@ -45,5 +45,5 @@
     # PS-string (with enclosing parens) otherwise.
     quoted = quote_ps_string(text)
     if quoted == text:
-	return text
+        return text
     return "(%s)" % quoted

Modified: skencil/branches/skencil-0.6/src/Sketch/Lib/skcompleter.py
===================================================================
--- skencil/branches/skencil-0.6/src/Sketch/Lib/skcompleter.py	2010-09-22 21:52:28 UTC (rev 727)
+++ skencil/branches/skencil-0.6/src/Sketch/Lib/skcompleter.py	2010-09-22 21:52:57 UTC (rev 728)
@@ -8,47 +8,47 @@
 class Completer:
 
     def __init__(self, global_dict = None, local_dict = None):
-	if global_dict is None:
-	    global_dict = __main__.__dict__
-	self.global_dict = global_dict
-	if local_dict is None:
-	    local_dict = global_dict
-	self.local_dict = local_dict
+        if global_dict is None:
+            global_dict = __main__.__dict__
+        self.global_dict = global_dict
+        if local_dict is None:
+            local_dict = global_dict
+        self.local_dict = local_dict
 
     def complete(self, text, state):
-	if state == 0:
-	    if "." in text:
-		self.matches = self.attr_matches(text)
-	    else:
-		self.matches = self.global_matches(text)
-	return self.matches[state]
+        if state == 0:
+            if "." in text:
+                self.matches = self.attr_matches(text)
+            else:
+                self.matches = self.global_matches(text)
+        return self.matches[state]
 
     def global_matches(self, text):
-	import keyword
-	matches = []
-	n = len(text)
-	for list in [keyword.kwlist,
-		     self.local_dict.keys(),
-		     self.global_dict.keys(),
-		     __builtin__.__dict__.keys()]:
-	    for word in list:
-		if word[:n] == text:
-		    matches.append(word)
-	return matches
+        import keyword
+        matches = []
+        n = len(text)
+        for list in [keyword.kwlist,
+                     self.local_dict.keys(),
+                     self.global_dict.keys(),
+                     __builtin__.__dict__.keys()]:
+            for word in list:
+                if word[:n] == text:
+                    matches.append(word)
+        return matches
 
     def attr_matches(self, text):
-	import re
-	m = re.match(r"(\w+(\.\w+)*)\.(\w*)", text)
-	if not m:
-	    return
-	expr, attr = m.group(1, 3)
-	words = dir(eval(expr, self.global_dict, self.local_dict))
-	matches = []
-	n = len(attr)
-	for word in words:
-	    if word[:n] == attr:
-		matches.append("%s.%s" % (expr, word))
-	return matches
+        import re
+        m = re.match(r"(\w+(\.\w+)*)\.(\w*)", text)
+        if not m:
+            return
+        expr, attr = m.group(1, 3)
+        words = dir(eval(expr, self.global_dict, self.local_dict))
+        matches = []
+        n = len(attr)
+        for word in words:
+            if word[:n] == attr:
+                matches.append("%s.%s" % (expr, word))
+        return matches
 
 def install(global_dict = None, local_dict = None):
     readline.set_completer(Completer(global_dict, local_dict).complete)

Modified: skencil/branches/skencil-0.6/src/Sketch/Lib/util.py
===================================================================
--- skencil/branches/skencil-0.6/src/Sketch/Lib/util.py	2010-09-22 21:52:28 UTC (rev 727)
+++ skencil/branches/skencil-0.6/src/Sketch/Lib/util.py	2010-09-22 21:52:57 UTC (rev 728)
@@ -26,7 +26,7 @@
 # otherwise. In Python 1.5 one might use os.environ.get(S) instead...
 def getenv(s):
     if os.environ.has_key(s):
-	return os.environ[s]
+        return os.environ[s]
     return None
 
 
@@ -36,38 +36,38 @@
     import pwd
     user = getenv("USER") or getenv("LOGNAME")
     if not user:
-	return pwd.getpwuid(os.getuid())
+        return pwd.getpwuid(os.getuid())
     else:
-	return pwd.getpwnam(user)
+        return pwd.getpwnam(user)
 
 # Return the user's home directory. If it can't be determined from the
 # environment or from the password database, return the current
 # directory.
 def gethome():
     try:
-	home = getenv("HOME")
-	if not home:
-	    home = get_pwd()[5]
-	return home
+        home = getenv("HOME")
+        if not home:
+            home = get_pwd()[5]
+        return home
     except (KeyError, ImportError):
-	return os.curdir
+        return os.curdir
 
 # Return the real user name (the gecos field of passwd)
 def get_real_username():
     try:
-	return get_pwd()[4]
+        return get_pwd()[4]
     except:
-	return None
+        return None
 
 # Return the hostname
 def gethostname():
     name = getenv('HOSTNAME')
     if not name:
-	try:
-	    import socket
-	    name = socket.gethostname()
-	except:
-	    pass
+        try:
+            import socket
+            name = socket.gethostname()
+        except:
+            pass
     return name
 
 
@@ -101,7 +101,7 @@
 # directory.
 def commonbasedir(path1, path2):
     if path1[-1] != os.sep:
-	path1 = path1 + os.sep
+        path1 = path1 + os.sep
     return os.path.split(os.path.commonprefix([path1, path2]))[0]
 
 
@@ -112,15 +112,15 @@
 # account...
 def relpath(path1, path2):
     if not os.path.isabs(path2):
-	return path2
+        return path2
     basedir = commonbasedir(path1, path2)
     if basedir == os.sep:
-	return path2
+        return path2
     path2 = path2[len(basedir) + 1 : ]
     curbase = path1
     while curbase != basedir:
-	curbase = os.path.split(curbase)[0]
-	path2 = os.pardir + os.sep + path2
+        curbase = os.path.split(curbase)[0]
+        path2 = os.pardir + os.sep + path2
     return path2
 
 
@@ -128,25 +128,25 @@
 # is found, return its full name, None otherwise.
 def find_in_path(paths, file):
     for path in paths:
-	fullname = os.path.join(path, file)
-	if os.path.isfile(fullname):
-	    return fullname
+        fullname = os.path.join(path, file)
+        if os.path.isfile(fullname):
+            return fullname
 
 # find one of the files listed in FILES in one of the directories in
 # PATHS. Return the name of the first one found, None if no file is
 # found.
 def find_files_in_path(paths, files):
     for path in paths:
-	for file in files:
-	    fullname = os.path.join(path, file)
-	    if os.path.isfile(fullname):
-		return fullname
+        for file in files:
+            fullname = os.path.join(path, file)
+            if os.path.isfile(fullname):
+                return fullname
 
 
 # Create the directory dir and its parent dirs when necessary
 def create_directory(dir):
     if os.path.isdir(dir):
-	return
+        return
 
     parent, base = os.path.split(dir)
     create_directory(parent)
@@ -157,18 +157,18 @@
 
 class BackupError(Exception):
     def __init__(self, errno, strerror, filename = ''):
-	self.errno = errno
-	self.strerror = strerror
-	self.filename = filename
+        self.errno = errno
+        self.strerror = strerror
+        self.filename = filename
 
 
 def make_backup(filename):
     if os.path.isfile(filename):
-	backupname = filename + '~'
-	try:
-	    os.rename(filename, backupname)
-	except os.error, value:
-	    raise BackupError(value[0], value[1], backupname)
+        backupname = filename + '~'
+        try:
+            os.rename(filename, backupname)
+        except os.error, value:
+            raise BackupError(value[0], value[1], backupname)
 
 #
 #
@@ -191,8 +191,8 @@
 #An empty class...
 class Empty:
     def __init__(self, **kw):
-	for key, value in kw.items():
-	    setattr(self, key, value)
+        for key, value in kw.items():
+            setattr(self, key, value)
 
 #
 #	List Manipulation
@@ -202,10 +202,10 @@
 def flatten(list):
     result = []
     for item in list:
-	if type(item) == ListType:
-	    result = result + flatten(item)
-	else:
-	    result.append(item)
+        if type(item) == ListType:
+            result = result + flatten(item)
+        else:
+            result.append(item)
     return result
 
 
@@ -239,7 +239,7 @@
     import string
     width, height = bitmap.GetGeometry()[3:5]
     lines = ['#define sketch_width %d' % width,
-	     '#define sketch_height %d' % height,
-	     'static unsigned char sketch_bits[] = {']
+             '#define sketch_height %d' % height,
+             'static unsigned char sketch_bits[] = {']
     lines = lines + bitmap.GetXbmStrings() + ['}', '']
     return string.join(lines, '\n')



More information about the Skencil-commits mailing list