More DREI updates

This commit is contained in:
Miroslav Stampar
2019-05-08 12:28:50 +02:00
parent 1241a025a2
commit 09aba3b5ce
16 changed files with 65 additions and 36 deletions

View File

@@ -93,6 +93,7 @@ if sys.version_info >= (3, 0):
xrange = range
text_type = str
binary_type = bytes
basestring = str
else:
text_type = unicode
binary_type = str
@@ -673,7 +674,7 @@ class Tag(PageElement):
"""Calling a tag like a function is the same as calling its
findAll() method. Eg. tag('a') returns a list of all the A tags
found within this tag."""
return apply(self.findAll, args, kwargs)
return self.findAll(*args, **kwargs)
def __getattr__(self, tag):
#print "Getattr %s.%s" % (self.__class__, tag)
@@ -1332,7 +1333,7 @@ class BeautifulStoneSoup(Tag, sgmllib.SGMLParser):
if (nestingResetTriggers is not None
and p.name in nestingResetTriggers) \
or (nestingResetTriggers is None and isResetNesting
and self.RESET_NESTING_TAGS.has_key(p.name)):
and p.name in self.RESET_NESTING_TAGS):
#If we encounter one of the nesting reset triggers
#peculiar to this tag, or we encounter another tag

View File

@@ -455,7 +455,7 @@ def _PERM_OP(a,b,n,m):
def _set_key(password):
"""Generate DES key schedule from ASCII password."""
c,d = struct.unpack('<ii', password)
c,d = struct.unpack('<ii', password.encode("utf8") if not isinstance(password, bytes) else password)
c = (c & 0x7f7f7f7f) << 1
d = (d & 0x7f7f7f7f) << 1
@@ -606,7 +606,7 @@ crypt supported by the OpenBSD C library.
# Convert to characters.
for i in xrange(len(r)):
r[i] = _cov_2char[r[i]]
return salt[:2] + string.join(r, '')
return salt[:2] + ''.join(r)
def _test():
"""Run doctest on fcrypt module."""

View File

@@ -200,7 +200,7 @@ try:
magic_compile.argtypes = [magic_t, c_char_p]
except (ImportError, OSError):
from_file = from_buffer = lambda *args, **kwargs: "unknown"
from_file = from_buffer = lambda *args, **kwargs: MAGIC_UNKNOWN_FILETYPE
MAGIC_NONE = 0x000000 # No flags
MAGIC_DEBUG = 0x000001 # Turn on debugging
@@ -223,3 +223,4 @@ MAGIC_NO_CHECK_ASCII = 0x020000 # Don't check for ascii files
MAGIC_NO_CHECK_TROFF = 0x040000 # Don't check ascii/troff
MAGIC_NO_CHECK_FORTRAN = 0x080000 # Don't check ascii/fortran
MAGIC_NO_CHECK_TOKENS = 0x100000 # Don't check ascii/tokens
MAGIC_UNKNOWN_FILETYPE = "unknown"