summaryrefslogtreecommitdiff
path: root/indra/lib
diff options
context:
space:
mode:
Diffstat (limited to 'indra/lib')
-rwxr-xr-xindra/lib/python/indra/ipc/compatibility.py26
-rwxr-xr-xindra/lib/python/indra/ipc/llmessage.py102
-rwxr-xr-xindra/lib/python/indra/ipc/tokenstream.py26
-rwxr-xr-xindra/lib/python/indra/util/test_win32_manifest.py26
4 files changed, 90 insertions, 90 deletions
diff --git a/indra/lib/python/indra/ipc/compatibility.py b/indra/lib/python/indra/ipc/compatibility.py
index b9045c22f3..d6ab4f15d5 100755
--- a/indra/lib/python/indra/ipc/compatibility.py
+++ b/indra/lib/python/indra/ipc/compatibility.py
@@ -32,7 +32,7 @@ $/LicenseInfo$
I M O N S
-- -- -- -- --
I: I I I I I
-M: I M M M M
+M: I M M M M
O: I M O M O
N: I M M N N
S: I M O N S
@@ -44,31 +44,31 @@ class _Compatibility(object):
self.reasons = [ ]
if reason:
self.reasons.append(reason)
-
+
def combine(self, other):
if self._level() <= other._level():
return self._buildclone(other)
else:
return other._buildclone(self)
-
+
def prefix(self, leadin):
- self.reasons = [ leadin + r for r in self.reasons ]
-
+ self.reasons = [ leadin + r for r in self.reasons ]
+
def same(self): return self._level() >= 1
def deployable(self): return self._level() > 0
def resolved(self): return self._level() > -1
def compatible(self): return self._level() > -2
-
+
def explain(self):
return self.__class__.__name__ + "\n" + "\n".join(self.reasons) + "\n"
-
+
def _buildclone(self, other=None):
c = self._buildinstance()
c.reasons = self.reasons
if other:
c.reasons = c.reasons + other.reasons
return c
-
+
def _buildinstance(self):
return self.__class__(None)
@@ -85,10 +85,10 @@ class Mixed(_Compatibility):
_Compatibility.__init__(self, None)
for i in inputs:
self.reasons += i.reasons
-
+
def _buildinstance(self):
return self.__class__()
-
+
def _level(self):
return -1
@@ -103,7 +103,7 @@ class _Aged(_Compatibility):
class Older(_Aged):
def _level(self):
return -0.25
-
+
class Newer(_Aged):
def _level(self):
return 0.25
@@ -111,10 +111,10 @@ class Newer(_Aged):
class Same(_Compatibility):
def __init__(self):
_Compatibility.__init__(self, None)
-
+
def _buildinstance(self):
return self.__class__()
-
+
def _level(self):
return 1
diff --git a/indra/lib/python/indra/ipc/llmessage.py b/indra/lib/python/indra/ipc/llmessage.py
index 663e2d9c63..235729944c 100755
--- a/indra/lib/python/indra/ipc/llmessage.py
+++ b/indra/lib/python/indra/ipc/llmessage.py
@@ -36,21 +36,21 @@ from .tokenstream import TokenStream
class Template:
def __init__(self):
self.messages = { }
-
+
def addMessage(self, m):
self.messages[m.name] = m
-
+
def compatibleWithBase(self, base):
messagenames = (
frozenset(list(self.messages.keys()))
| frozenset(list(base.messages.keys()))
)
-
+
compatibility = Same()
for name in messagenames:
selfmessage = self.messages.get(name, None)
basemessage = base.messages.get(name, None)
-
+
if not selfmessage:
c = Older("missing message %s, did you mean to deprecate?" % name)
elif not basemessage:
@@ -58,9 +58,9 @@ class Template:
else:
c = selfmessage.compatibleWithBase(basemessage)
c.prefix("in message %s: " % name)
-
+
compatibility = compatibility.combine(c)
-
+
return compatibility
@@ -72,11 +72,11 @@ class Message:
FIXED = "Fixed"
priorities = [ HIGH, MEDIUM, LOW, FIXED ]
prioritieswithnumber = [ FIXED ]
-
+
TRUSTED = "Trusted"
NOTTRUSTED = "NotTrusted"
trusts = [ TRUSTED, NOTTRUSTED ]
-
+
UNENCODED = "Unencoded"
ZEROCODED = "Zerocoded"
encodings = [ UNENCODED, ZEROCODED ]
@@ -87,7 +87,7 @@ class Message:
UDPBLACKLISTED = "UDPBlackListed"
deprecations = [ NOTDEPRECATED, UDPDEPRECATED, UDPBLACKLISTED, DEPRECATED ]
# in order of increasing deprecation
-
+
def __init__(self, name, number, priority, trust, coding):
self.name = name
self.number = number
@@ -100,31 +100,31 @@ class Message:
def deprecated(self):
return self.deprecateLevel != 0
- def deprecate(self, deprecation):
+ def deprecate(self, deprecation):
self.deprecateLevel = self.deprecations.index(deprecation)
def addBlock(self, block):
self.blocks.append(block)
-
+
def compatibleWithBase(self, base):
if self.name != base.name:
# this should never happen in real life because of the
# way Template matches up messages by name
return Incompatible("has different name: %s vs. %s in base"
- % (self.name, base.name))
+ % (self.name, base.name))
if self.priority != base.priority:
return Incompatible("has different priority: %s vs. %s in base"
- % (self.priority, base.priority))
+ % (self.priority, base.priority))
if self.trust != base.trust:
return Incompatible("has different trust: %s vs. %s in base"
- % (self.trust, base.trust))
+ % (self.trust, base.trust))
if self.coding != base.coding:
return Incompatible("has different coding: %s vs. %s in base"
- % (self.coding, base.coding))
+ % (self.coding, base.coding))
if self.number != base.number:
return Incompatible("has different number: %s vs. %s in base"
% (self.number, base.number))
-
+
compatibility = Same()
if self.deprecateLevel != base.deprecateLevel:
@@ -137,27 +137,27 @@ class Message:
self.deprecations[self.deprecateLevel],
self.deprecations[base.deprecateLevel]))
compatibility = compatibility.combine(c)
-
+
selflen = len(self.blocks)
baselen = len(base.blocks)
samelen = min(selflen, baselen)
-
+
for i in range(0, samelen):
selfblock = self.blocks[i]
baseblock = base.blocks[i]
-
+
c = selfblock.compatibleWithBase(baseblock)
if not c.same():
c = Incompatible("block %d isn't identical" % i)
compatibility = compatibility.combine(c)
-
+
if selflen > baselen:
c = Newer("has %d extra blocks" % (selflen - baselen))
elif selflen < baselen:
c = Older("missing %d extra blocks" % (baselen - selflen))
else:
c = Same()
-
+
compatibility = compatibility.combine(c)
return compatibility
@@ -169,7 +169,7 @@ class Block(object):
VARIABLE = "Variable"
repeats = [ SINGLE, MULTIPLE, VARIABLE ]
repeatswithcount = [ MULTIPLE ]
-
+
def __init__(self, name, repeat, count=None):
self.name = name
self.repeat = repeat
@@ -178,7 +178,7 @@ class Block(object):
def addVariable(self, variable):
self.variables.append(variable)
-
+
def compatibleWithBase(self, base):
if self.name != base.name:
return Incompatible("has different name: %s vs. %s in base"
@@ -189,17 +189,17 @@ class Block(object):
if self.repeat in Block.repeatswithcount:
if self.count != base.count:
return Incompatible("has different count: %s vs. %s in base"
- % (self.count, base.count))
+ % (self.count, base.count))
compatibility = Same()
-
+
selflen = len(self.variables)
baselen = len(base.variables)
-
+
for i in range(0, min(selflen, baselen)):
selfvar = self.variables[i]
basevar = base.variables[i]
-
+
c = selfvar.compatibleWithBase(basevar)
if not c.same():
c = Incompatible("variable %d isn't identical" % i)
@@ -232,12 +232,12 @@ class Variable:
LLVECTOR3, LLVECTOR3D, LLVECTOR4, LLQUATERNION,
LLUUID, BOOL, IPADDR, IPPORT, FIXED, VARIABLE ]
typeswithsize = [ FIXED, VARIABLE ]
-
+
def __init__(self, name, type, size):
self.name = name
self.type = type
self.size = size
-
+
def compatibleWithBase(self, base):
if self.name != base.name:
return Incompatible("has different name: %s vs. %s in base"
@@ -248,7 +248,7 @@ class Variable:
if self.type in Variable.typeswithsize:
if self.size != base.size:
return Incompatible("has different size: %s vs. %s in base"
- % (self.size, base.size))
+ % (self.size, base.size))
return Same()
@@ -274,60 +274,60 @@ class TemplateParser:
self._version = v
t.version = v
continue
-
+
m = self.parseMessage()
if m:
t.addMessage(m)
continue
-
+
if self._version >= 2.0:
tokens.require(tokens.wantEOF())
break
else:
if tokens.wantEOF():
break
-
+
tokens.consume()
# just assume (gulp) that this is a comment
# line 468: "sim -> dataserver"
- return t
+ return t
def parseMessage(self):
tokens = self._tokens
if not tokens.want("{"):
return None
-
+
name = tokens.require(tokens.wantSymbol())
priority = tokens.require(tokens.wantOneOf(Message.priorities))
-
+
if self._version >= 2.0 or priority in Message.prioritieswithnumber:
number = int("+" + tokens.require(tokens.wantInteger()), 0)
else:
self._numbers[priority] += 1
number = self._numbers[priority]
-
+
trust = tokens.require(tokens.wantOneOf(Message.trusts))
coding = tokens.require(tokens.wantOneOf(Message.encodings))
-
+
m = Message(name, number, priority, trust, coding)
-
+
if self._version >= 2.0:
d = tokens.wantOneOf(Message.deprecations)
if d:
m.deprecate(d)
-
+
while True:
b = self.parseBlock()
if not b:
break
m.addBlock(b)
-
+
tokens.require(tokens.want("}"))
-
+
return m
-
-
+
+
def parseBlock(self):
tokens = self._tokens
if not tokens.want("{"):
@@ -338,19 +338,19 @@ class TemplateParser:
count = int(tokens.require(tokens.wantInteger()))
else:
count = None
-
+
b = Block(name, repeat, count)
-
+
while True:
v = self.parseVariable()
if not v:
break
b.addVariable(v)
-
+
tokens.require(tokens.want("}"))
return b
-
-
+
+
def parseVariable(self):
tokens = self._tokens
if not tokens.want("{"):
@@ -360,11 +360,11 @@ class TemplateParser:
if type in Variable.typeswithsize:
size = tokens.require(tokens.wantInteger())
else:
- tokens.wantInteger() # in LandStatRequest: "{ ParcelLocalID S32 1 }"
+ tokens.wantInteger() # in LandStatRequest: "{ ParcelLocalID S32 1 }"
size = None
tokens.require(tokens.want("}"))
return Variable(name, type, size)
-
+
def parseTemplateString(s):
return TemplateParser(TokenStream().fromString(s)).parseTemplate()
diff --git a/indra/lib/python/indra/ipc/tokenstream.py b/indra/lib/python/indra/ipc/tokenstream.py
index ab97e94846..a8e0a17e9c 100755
--- a/indra/lib/python/indra/ipc/tokenstream.py
+++ b/indra/lib/python/indra/ipc/tokenstream.py
@@ -35,7 +35,7 @@ EOF = _EOF()
class _LineMarker(int):
pass
-
+
_commentRE = re.compile(r'//.*')
_symbolRE = re.compile(r'[a-zA-Z_][a-zA-Z_0-9]*')
_integerRE = re.compile(r'(0x[0-9A-Fa-f]+|0\d*|[1-9]\d*)')
@@ -48,7 +48,7 @@ class ParseError(Exception):
self.context = stream._context()
self.reason = reason
- def _contextString(self):
+ def _contextString(self):
c = [ ]
for t in self.context:
if isinstance(t, _LineMarker):
@@ -75,10 +75,10 @@ class TokenStream(object):
def __init__(self):
self.line = 0
self.tokens = [ ]
-
+
def fromString(self, string):
return self.fromLines(string.split('\n'))
-
+
def fromFile(self, file):
return self.fromLines(file)
@@ -90,23 +90,23 @@ class TokenStream(object):
self.tokens.extend(_commentRE.sub(" ", line).split())
self._consumeLines()
return self
-
+
def consume(self):
if not self.tokens:
return EOF
t = self.tokens.pop(0)
self._consumeLines()
return t
-
+
def _consumeLines(self):
while self.tokens and isinstance(self.tokens[0], _LineMarker):
self.line = self.tokens.pop(0)
-
+
def peek(self):
if not self.tokens:
return EOF
return self.tokens[0]
-
+
def want(self, t):
if t == self.peek():
return self.consume()
@@ -120,7 +120,7 @@ class TokenStream(object):
def wantEOF(self):
return self.want(EOF)
-
+
def wantRE(self, re, message=None):
t = self.peek()
if t != EOF:
@@ -130,16 +130,16 @@ class TokenStream(object):
if not message:
message = "expected match for r'%s'" % re.pattern
return ParseError(self, message)
-
+
def wantSymbol(self):
return self.wantRE(_symbolRE, "expected symbol")
-
+
def wantInteger(self):
return self.wantRE(_integerRE, "expected integer")
-
+
def wantFloat(self):
return self.wantRE(_floatRE, "expected float")
-
+
def _context(self):
n = min(5, len(self.tokens))
return self.tokens[0:n]
diff --git a/indra/lib/python/indra/util/test_win32_manifest.py b/indra/lib/python/indra/util/test_win32_manifest.py
index 98faef9bf9..b3ac2f8121 100755
--- a/indra/lib/python/indra/util/test_win32_manifest.py
+++ b/indra/lib/python/indra/util/test_win32_manifest.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
"""\
@file test_win32_manifest.py
-@brief Test an assembly binding version and uniqueness in a windows dll or exe.
+@brief Test an assembly binding version and uniqueness in a windows dll or exe.
$LicenseInfo:firstyear=2009&license=viewerlgpl$
Second Life Viewer Source Code
@@ -50,12 +50,12 @@ def get_HKLM_registry_value(key_str, value_str):
value = winreg.QueryValueEx(key, value_str)[0]
#print 'Found: %s' % value
return value
-
+
def find_vc_dir():
supported_versions = (r'8.0', r'9.0')
supported_products = (r'VisualStudio', r'VCExpress')
value_str = (r'ProductDir')
-
+
for product in supported_products:
for version in supported_versions:
key_str = (r'SOFTWARE\Microsoft\%s\%s\Setup\VC' %
@@ -69,14 +69,14 @@ def find_vc_dir():
return get_HKLM_registry_value(x64_key_str, value_str)
except:
print("Didn't find MS %s version %s " % (product,version), file=sys.stderr)
-
+
raise
def find_mt_path():
vc_dir = find_vc_dir()
mt_path = '\"%sbin\\mt.exe\"' % vc_dir
return mt_path
-
+
def test_assembly_binding(src_filename, assembly_name, assembly_ver):
print("checking %s dependency %s..." % (src_filename, assembly_name))
@@ -106,11 +106,11 @@ def test_assembly_binding(src_filename, assembly_name, assembly_ver):
if len(versions) == 0:
print("No matching assemblies found in %s" % src_filename)
raise NoMatchingAssemblyException()
-
+
elif len(versions) > 1:
print("Multiple bindings to %s found:" % assembly_name)
print(versions)
- print()
+ print()
raise MultipleBindingsException(versions)
elif versions[0] != assembly_ver:
@@ -118,17 +118,17 @@ def test_assembly_binding(src_filename, assembly_name, assembly_ver):
print("Wanted %s, found %s" % (assembly_ver, versions[0]))
print()
raise UnexpectedVersionException(assembly_ver, versions[0])
-
+
os.remove(tmp_file_name)
-
+
print("SUCCESS: %s OK!" % src_filename)
print()
-
+
if __name__ == '__main__':
print()
print("Running test_win32_manifest.py...")
-
+
usage = 'test_win32_manfest <srcFileName> <assemblyName> <assemblyVersion>'
try:
@@ -140,7 +140,7 @@ if __name__ == '__main__':
print(usage)
print()
raise
-
+
test_assembly_binding(src_filename, assembly_name, assembly_ver)
-
+