summaryrefslogtreecommitdiffstats
path: root/filter/source/config/tools/merge
diff options
context:
space:
mode:
authorTor Lillqvist <tlillqvist@novell.com>2011-02-14 02:29:21 +0200
committerTor Lillqvist <tlillqvist@novell.com>2011-02-14 02:40:38 +0200
commit197c659abfef8183d0e27370ea6162408292046e (patch)
treea088d5382294acad10e188c6feadbec56a11b017 /filter/source/config/tools/merge
parentWaE: variable set but unused (diff)
downloadcore-197c659abfef8183d0e27370ea6162408292046e.tar.gz
core-197c659abfef8183d0e27370ea6162408292046e.zip
Correct inconsistent use of tabs and spaces
Diffstat (limited to 'filter/source/config/tools/merge')
-rwxr-xr-xfilter/source/config/tools/merge/pyAltFCFGMerge342
1 files changed, 171 insertions, 171 deletions
diff --git a/filter/source/config/tools/merge/pyAltFCFGMerge b/filter/source/config/tools/merge/pyAltFCFGMerge
index a44a4bb81d29..0d7666aed912 100755
--- a/filter/source/config/tools/merge/pyAltFCFGMerge
+++ b/filter/source/config/tools/merge/pyAltFCFGMerge
@@ -51,7 +51,7 @@ Copyright (C) 2002,2004 - Ollie Rutherfurd <oliver@rutherfurd.net>
Based on:
- http://java.sun.com/j2se/1.3/docs/api/java/util/Properties.html
+ http://java.sun.com/j2se/1.3/docs/api/java/util/Properties.html
Missing:
@@ -89,190 +89,190 @@ __all__ = ['Properties']
def dec2hex(n):
- h = hex(n)[2:].upper()
- return '\\u' + '0' * (4 - len(h)) + h
+ h = hex(n)[2:].upper()
+ return '\\u' + '0' * (4 - len(h)) + h
def escapestr(s):
- buff = []
- # QUESTION: escape leading or trailing spaces?
- for c in s:
- if c == '\\':
- buff.append('\\\\')
- elif c == '\t':
- buff.append('\\t')
- elif c == '\n':
- buff.append('\\n')
- elif c == '\r':
- buff.append('\\r')
- elif c == ' ':
- buff.append('\\ ')
- elif c == "'":
- buff.append("\\'")
- elif c == '"':
- buff.append('\\"')
- elif c == '#':
- buff.append('\\#')
- elif c == '!':
- buff.append('\\!')
- elif c == '=':
- buff.append('\\=')
- elif 32 <= ord(c) <= 126:
- buff.append(c)
- else:
- buff.append(dec2hex(c))
-
- return ''.join(buff)
+ buff = []
+ # QUESTION: escape leading or trailing spaces?
+ for c in s:
+ if c == '\\':
+ buff.append('\\\\')
+ elif c == '\t':
+ buff.append('\\t')
+ elif c == '\n':
+ buff.append('\\n')
+ elif c == '\r':
+ buff.append('\\r')
+ elif c == ' ':
+ buff.append('\\ ')
+ elif c == "'":
+ buff.append("\\'")
+ elif c == '"':
+ buff.append('\\"')
+ elif c == '#':
+ buff.append('\\#')
+ elif c == '!':
+ buff.append('\\!')
+ elif c == '=':
+ buff.append('\\=')
+ elif 32 <= ord(c) <= 126:
+ buff.append(c)
+ else:
+ buff.append(dec2hex(c))
+
+ return ''.join(buff)
# TODO: add support for \uXXXX?
def unescapestr(line):
- buff = []
- escape = 0
- for i in range(len(line)):
- c = line[i]
- if c == '\\':
- if escape:
- escape = 0
- buff.append('\\')
- continue
- else:
- # this is to deal with '\'
- # acting as a line continuation
- # character
- if i == len(line) - 1:
- buff.append('\\')
- break
- else:
- escape = 1
- continue
- elif c == 'n':
- if escape:
- escape = 0
- buff.append('\n')
- continue
- elif c == 'r':
- if escape:
- escape = 0
- buff.append('\r')
- continue
- elif c == 't':
- if escape:
- escape = 0
- buff.append('\t')
- continue
-
- buff.append(c)
-
- # make sure escape doesn't stay one
- # all expected escape sequences either break
- # or continue, so this should be safe
- if escape:
- escape = 0
-
- return ''.join(buff)
+ buff = []
+ escape = 0
+ for i in range(len(line)):
+ c = line[i]
+ if c == '\\':
+ if escape:
+ escape = 0
+ buff.append('\\')
+ continue
+ else:
+ # this is to deal with '\'
+ # acting as a line continuation
+ # character
+ if i == len(line) - 1:
+ buff.append('\\')
+ break
+ else:
+ escape = 1
+ continue
+ elif c == 'n':
+ if escape:
+ escape = 0
+ buff.append('\n')
+ continue
+ elif c == 'r':
+ if escape:
+ escape = 0
+ buff.append('\r')
+ continue
+ elif c == 't':
+ if escape:
+ escape = 0
+ buff.append('\t')
+ continue
+
+ buff.append(c)
+
+ # make sure escape doesn't stay one
+ # all expected escape sequences either break
+ # or continue, so this should be safe
+ if escape:
+ escape = 0
+
+ return ''.join(buff)
class Properties(dict):
- def __init__(self, defaults={}):
- dict.__init__(self)
- for n,v in defaults.items():
- self[n] = v
-
- def __getittem__(self,key):
- try:
- return dict.__getittem__(self,key)
- except KeyError:
- return None
-
- def read(self,filename):
- """
- Reads properties from a file (java Property class
- reads from an input stream -- see load()).
- """
- f = None
- try:
- f = open(filename)
- self.load(f)
- finally:
- if f:
- f.close()
-
- def load(self, buff):
- """
- Reads properties from a stream (StringIO, file, etc...)
- """
- props = readprops(buff)
- for n,v in props.iteritems():
- self[n] = v
+ def __init__(self, defaults={}):
+ dict.__init__(self)
+ for n,v in defaults.items():
+ self[n] = v
+
+ def __getittem__(self,key):
+ try:
+ return dict.__getittem__(self,key)
+ except KeyError:
+ return None
+
+ def read(self,filename):
+ """
+ Reads properties from a file (java Property class
+ reads from an input stream -- see load()).
+ """
+ f = None
+ try:
+ f = open(filename)
+ self.load(f)
+ finally:
+ if f:
+ f.close()
+
+ def load(self, buff):
+ """
+ Reads properties from a stream (StringIO, file, etc...)
+ """
+ props = readprops(buff)
+ for n,v in props.iteritems():
+ self[n] = v
def readprops(buff):
- name,value = None,''
- props = {}
- continued = 0
-
- while 1:
- line = buff.readline()
- if not line:
- break
- line = line.strip()
-
- # empty line
- if not line:
- continue
-
- # comment
- if line[0] in ('#','!'):
- continue
-
- # find name
- i,escaped = 0,0
- while i < len(line):
- c = line[i]
-
- if c == '\\':
- if escaped:
- escaped = 0
- else:
- escaped = 1
- i += 1
- continue
-
- elif c in (' ', '\t', ':', '=') and not escaped:
- name = unescapestr(line[:i])
- break
-
- # make sure escaped doesn't stay on
- if escaped:
- escaped = 0
-
- i += 1
-
- # no dlimiter was found, name is entire line, there is no value
- if name == None:
- name = unescapestr(line.lstrip())
-
- # skip delimiter
- while line[i:i+1] in ('\t', ' ', ':', '='):
- i += 1
-
- value = unescapestr(line[i:].strip())
- while value[-1:] == '\\':
- value = value[:-1] # remove \
- line = buff.readline()
- if not line:
- break
- value += unescapestr(line.strip())
-
- #print 'value:',value ##
- props[name] = value
-
- return props
+ name,value = None,''
+ props = {}
+ continued = 0
+
+ while 1:
+ line = buff.readline()
+ if not line:
+ break
+ line = line.strip()
+
+ # empty line
+ if not line:
+ continue
+
+ # comment
+ if line[0] in ('#','!'):
+ continue
+
+ # find name
+ i,escaped = 0,0
+ while i < len(line):
+ c = line[i]
+
+ if c == '\\':
+ if escaped:
+ escaped = 0
+ else:
+ escaped = 1
+ i += 1
+ continue
+
+ elif c in (' ', '\t', ':', '=') and not escaped:
+ name = unescapestr(line[:i])
+ break
+
+ # make sure escaped doesn't stay on
+ if escaped:
+ escaped = 0
+
+ i += 1
+
+ # no dlimiter was found, name is entire line, there is no value
+ if name == None:
+ name = unescapestr(line.lstrip())
+
+ # skip delimiter
+ while line[i:i+1] in ('\t', ' ', ':', '='):
+ i += 1
+
+ value = unescapestr(line[i:].strip())
+ while value[-1:] == '\\':
+ value = value[:-1] # remove \
+ line = buff.readline()
+ if not line:
+ break
+ value += unescapestr(line.strip())
+
+ #print 'value:',value ##
+ props[name] = value
+
+ return props
#---end java.util.Properties copy---#
# Its a simple command line tool, which can merge different XML fragments
@@ -341,7 +341,7 @@ def StringTokenizer(mstring, separators, isSepIncluded=0):
# @author Andreas Schluens
class ConfigHelper:
def __init__(self, sPropFile, lCommandLineArgs):
- self.m_bEmpty = 1
+ self.m_bEmpty = 1
# first load prop file, so its values can be overwritten
# by command line args later
# Do it only, if a valid file name was given.
@@ -399,7 +399,7 @@ class ConfigHelper:
def getValueWithDefault(self, sProp, default):
if not self.props.has_key(sProp):
- return default;
+ return default;
return self.props[sProp];
def getStringList(self, sProp, sDelimiter, bTrim, bDecode):
@@ -543,7 +543,7 @@ class Merger:
sBuffer = sBuffer + generateFooter()
# Attention!
- # If the package seem to be empty, it make no sense to generate a
+ # If the package seem to be empty, it make no sense to generate a
# corresponding xml file. We should suppress writing of this file on
# disk completly ...
if nItemCount < 1: