mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-15 23:42:37 +03:00
jenkins-build: make pylint handle the hashlib hash classes properly
hashlib uses some magic to load whatever is built into the local openssl. pylint gets confused by this, so we need a pylint plugin to trick pylint into thinking everything is good.
This commit is contained in:
parent
c353a69231
commit
e9dc2ddd51
2 changed files with 43 additions and 6 deletions
39
.pylint-plugins/astng_hashlib.py
Normal file
39
.pylint-plugins/astng_hashlib.py
Normal file
|
@ -0,0 +1,39 @@
|
|||
#
|
||||
# started from http://www.logilab.org/blogentry/78354
|
||||
#
|
||||
|
||||
from logilab.astng import MANAGER
|
||||
from logilab.astng.builder import ASTNGBuilder
|
||||
|
||||
def hashlib_transform(module):
|
||||
if module.name == 'hashlib':
|
||||
fake = ASTNGBuilder(MANAGER).string_build('''
|
||||
|
||||
class fakehash(object):
|
||||
digest_size = -1
|
||||
def __init__(self, value): pass
|
||||
def digest(self):
|
||||
return u''
|
||||
def hexdigest(self):
|
||||
return u''
|
||||
def update(self, value): pass
|
||||
|
||||
class md5(fakehash):
|
||||
pass
|
||||
|
||||
class sha1(fakehash):
|
||||
pass
|
||||
|
||||
class sha256(fakehash):
|
||||
pass
|
||||
|
||||
''')
|
||||
for hashfunc in ('sha256', 'sha1', 'md5'):
|
||||
module.locals[hashfunc] = fake.locals[hashfunc]
|
||||
|
||||
def register(linter):
|
||||
"""called when loaded by pylint --load-plugins, register our tranformation
|
||||
function here
|
||||
"""
|
||||
MANAGER.register_transformer(hashlib_transform)
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue