Exemple #1
0
	def checkNameUses(x):
#		print('In check: ',x)
		if type(x) == list:
			if type(x[0]) != list:
				if ord(x[0][0]) >= ord('A') and ord(x[0][0]) <= ord('X'):
					isThisC = hash.get(tOfAll,x[0])
#					print(x,isThisC[0])
					if type(isThisC[0]) != list:
#						pass
						return checkNameUses(x[0]) and checkNameUses(x[1])
					else:
#						_,_,b = unifi(x, isThisC[0])
#						if b == False:
#							sys.exit('ERROR: wrong parameters for type\n' +
#									 'in line: ' + str(line) + '\n' +
#									 'for type: ' + x[0] + '\n' +
#									 'declared in line: ' + str(isThisC[1]) + '\n' +
#									 'with pattern: ' + str(isThisC[0]) + '\n' +
#									 '            | ' + toString(isThisC[0]) + '\n' +
#									 'in full type: ' + str(t) + '\n' +
#									 '            | ' + toString(t) + '\n' +
#									 'in local pattern: ' + str(x) + '\n' +
#									 '                | ' + toString(x) + '\n' )
#							return False
#							print('Error:',toString(x),x,isThisC[1])
						return checkNameUses(x[1])
				else:
					return checkNameUses(x[1])
			else:
				return checkNameUses(x[0]) and checkNameUses(x[1])
		else:
#			print(x)
			if ord(x[0]) >= ord('A') and ord(x[0]) <= ord('X'):
				isThisC = hash.get(tOfAll,x)
				if isThisC != None:
#					print(isThisC)
					if type(isThisC[0]) != list:
						return True
					else:
						sys.exit('ERROR: missing parameters for type\n' +
								 'in line: ' + str(line) + '\n' +
								 'for type: ' + x + '\n' +
								 'declared in line: ' + str(isThisC[1]) + '\n' +
								 'with pattern: ' + str(isThisC[0]) + '\n' +
								 '            | ' + toString(isThisC[0]) + '\n' +
								 'in full type: ' + str(t) + '\n' +
								 '            | ' + toString(t) + '\n' )
#						print('Error:',x,isThisC[1],isThisC[0])
						return False
				else:
					sys.exit('ERROR: undefined type:' + str(x) +'\n' +
							  'in line: ' + str(line) + '\n')
					return False
			else:
				return True
Exemple #2
0
def _make_hash(algorithm):
    if _is_md5(algorithm):
        return hash.get('MD5')()
    if _is_sha1(algorithm):
        return hash.get('SHA1')()
    if _is_sha256(algorithm):
        return hash.get('SHA256')()
    if _is_sha384(algorithm):
        return hash.get('SHA384')()
    if _is_sha512(algorithm):
        return hash.get('SHA512')()
    raise ValidationFailure, 'unknown hash for algorithm %u' % algorithm
Exemple #3
0
def _make_hash(algorithm):
    if _is_md5(algorithm):
        return hash.get('MD5')()
    if _is_sha1(algorithm):
        return hash.get('SHA1')()
    if _is_sha256(algorithm):
        return hash.get('SHA256')()
    if _is_sha384(algorithm):
        return hash.get('SHA384')()
    if _is_sha512(algorithm):
        return hash.get('SHA512')()
    raise ValidationFailure, 'unknown hash for algorithm %u' % algorithm
Exemple #4
0
	def unifi(a,b,at,bt):
		if type(a) != list and type(b)!=list:
			if ord(a[0]) < ord('a') and ord(b[0]) < ord('a'):
				if a == b:
					return (at,bt,True)
				else:
					return (at,bt,False)
			else:
				if ord(a[0]) >= ord('a'):
					nnn = hash.get(at,a)
					if nnn == None:
						return (hash.create(256,hash.toList(at)+[(a,b)]),bt,True)
					else:
						if type(nnn) != list:
							if ord(nnn[0]) >= ord('a'):
								return (at,bt,True)
						return unifi(nnn,b,at,bt)
				else:
					nnn = hash.get(bt,b)
					if nnn == None:
						return (at,hash.create(256,hash.toList(bt)+[(b,a)]),True)
					else:
						if type(nnn) != list:
							if ord(nnn[0]) >= ord('a'):
								return (at,bt,True)
						return unifi(a,nnn,at,bt)
		elif type(a) != list:
			if ord(a[0]) >= ord('a'):
				nnn = hash.get(at,a)
				if nnn == None:
					return (hash.create(256,hash.toList(at)+[(a,b)]),bt,True)
				else:
					if type(nnn) != list:
						if ord(nnn[0]) >= ord('a'):
							return (at,bt,True)
					return unifi(nnn,b,at,bt)
			return (at,bt,False)
		elif type(b) != list:
			if ord(b[0]) >= ord('a'):
				nnn = hash.get(bt,b)
				if nnn == None:
					return (at,hash.create(256,hash.toList(bt)+[(b,a)]),True)
				else:
					if type(nnn) != list:
						if ord(nnn[0]) >= ord('a'):
							return (at,bt,True)
					return unifi(a,nnn,at,bt)
			return (at,bt,False)
		else:
			at1,bt1,b1 = unifi(a[0],b[0],at,bt)
			at2,bt2,b2 = unifi(a[1],b[1],at1,bt1)
			return (at2,bt2,b1 and b2)
		return (at,bt,False)
Exemple #5
0
def make_ds(name, key, algorithm, origin=None):
    if algorithm.upper() == 'SHA1':
        dsalg = 1
        hash = hash.get('SHA1')()
    elif algorithm.upper() == 'SHA256':
        dsalg = 2
        hash = hash.get('SHA256')()
    else:
        raise UnsupportedAlgorithm, 'unsupported algorithm "%s"' % algorithm

    if isinstance(name, (str, unicode)):
        name = name.from_text(name, origin)
    hash.update(name.canonicalize().to_wire())
    hash.update(_to_rdata(key, origin))
    digest = hash.digest()

    dsrdata = struct.pack("!HBB", key_id(key), key.algorithm, dsalg) + digest
    return rdata.from_wire(rdataclass.IN, rdatatype.DS, dsrdata, 0,
                           len(dsrdata))
Exemple #6
0
def make_ds(name, key, algorithm, origin=None):
    if algorithm.upper() == 'SHA1':
        dsalg = 1
        hash = hash.get('SHA1')()
    elif algorithm.upper() == 'SHA256':
        dsalg = 2
        hash = hash.get('SHA256')()
    else:
        raise UnsupportedAlgorithm, 'unsupported algorithm "%s"' % algorithm

    if isinstance(name, (str, unicode)):
        name = name.from_text(name, origin)
    hash.update(name.canonicalize().to_wire())
    hash.update(_to_rdata(key, origin))
    digest = hash.digest()

    dsrdata = struct.pack("!HBB", key_id(key), key.algorithm, dsalg) + digest
    return rdata.from_wire(rdataclass.IN, rdatatype.DS, dsrdata, 0,
                               len(dsrdata))
def checkOnUseSugar(x, t):
    listOfAll = f.reduce(lambda a, x: a + hash.toList(x), t, [])
    tOfAll = hash.create(1024, listOfAll)
    res = hash.get(tOfAll, x[0])
    if res == None:
        return True
    sys.exit('ERROR: name conflict:  syntax sugar and type constructor\n' +
             'name: ' + x[0] + '\n' + 'syntax sugar declared in line: ' +
             str(x[1]) + '\n' + 'type constructor declared in line: ' +
             str(res[1]) + '\n')
    return False
Exemple #8
0
    def clearScobe(a):
        if a == []:
            return []

        if a[0][0] == parser.pP_word:
            thisName = a[0][1][0][1]
            t = hash.get(ts, thisName)
            if t != None:
                return clearScobe(a[1:])

        return [a[0]] + clearScobe(a[1:])
        pass
Exemple #9
0
    def get_issue(self, proposal_id):
        origin = hash.get('avsl_proposals', proposal_id)
        if not origin:
            self.error_response(404, "proposal by id #%d not found" % int(proposal_id))
            return

        obj = hash.decode_dict(origin)
        info = click.url_info(obj["hostname"], obj)

        if not info:
            self.error_response(404, "domain %s cannot generate click url" % obj["hostname"])
            return

        self.write(boot.click_xml_response(info))
Exemple #10
0
    def get_issue(self, proposal_id):
        origin = hash.get('avsl_proposals', proposal_id)
        if not origin:
            self.error_response(
                404, "proposal by id #%d not found" % int(proposal_id))
            return

        obj = hash.decode_dict(origin)
        info = click.url_info(obj["hostname"], obj)

        if not info:
            self.error_response(
                404, "domain %s cannot generate click url" % obj["hostname"])
            return

        self.write(boot.click_xml_response(info))
Exemple #11
0
    def asInfix(x):
        if x[0] != parser.pP_word:
            return None
        thisName = x[1][0][1]

        if thisName in (
                '+ - / * << >> >= <= != = % and xor not or | ~').split(' '):
            return (getPriot(thisName), isRightAssoc(thisName))

        thisS = hash.get(t, thisName)
        if thisS == None:
            sys.exit('ERROR: undefined symbol:\n' + 'symbol: ' + thisName +
                     '\n')

        if thisS[2] & const.S_INFIXL > 0:
            return (getPriot(thisName), False)

        if thisS[2] & const.S_INFIXR > 0:
            return (getPriot(thisName), True)

        return None
Exemple #12
0
def _maybe_add_hash(tsig_alg, hash_alg):
    try:
        _hashes[tsig_alg] = hash.get(hash_alg)
    except KeyError:
        pass
Exemple #13
0
def In(tInfix, s):
    return hash.get(tInfix, s) != None
Exemple #14
0
tree = tree[0]


# print(tree)
# print(sss)
def getAllInfix(s):
    def tmp(a, x):
        if x[0] == parser.pP_Dec:
            if x[1][1][1] != []:
                mode = x[1][1][1][0][1]
                modeTo = mode == 'infixr'
                return a + [(x[1][0][1], modeTo)]
        return a

    return f.reduce(tmp, s, [])


tInfix = getAllInfix(tree[1])
tInfix = hash.create(127, tInfix)


def In(tInfix, s):
    return hash.get(tInfix, s) != None


get = lambda t: lambda s: hash.get(t, s)
isR = get(tInfix)

print(isR('>>>'))
dt.draw(tree)
s
Exemple #15
0
def _maybe_add_hash(tsig_alg, hash_alg):
    try:
        _hashes[tsig_alg] = hash.get(hash_alg)
    except KeyError:
        pass