forked from LBRYCommunity/lbry-sdk
Merge pull request #247 from lbryio/bad-whitespace
add bad-whitespace check to pylint
This commit is contained in:
commit
37fee71898
16 changed files with 87 additions and 71 deletions
|
@ -54,7 +54,7 @@ class InvalidStreamDescriptorError(Exception):
|
|||
|
||||
class InvalidStreamInfoError(Exception):
|
||||
def __init__(self, name, stream_info):
|
||||
msg = '{} has claim with invalid stream info: {}'.format(name, stream_info)
|
||||
msg = '{} has claim with invalid stream info: {}'.format(name, stream_info)
|
||||
Exception.__init__(self, msg)
|
||||
self.name = name
|
||||
self.stream_info = stream_info
|
||||
|
|
|
@ -334,18 +334,14 @@ class Wallet(object):
|
|||
def _log_success(claim_id):
|
||||
log.info("lbry://%s complies with %s, claimid: %s", name, metadata.version, claim_id)
|
||||
return defer.succeed(None)
|
||||
|
||||
if 'error' in result:
|
||||
log.warning("Got an error looking up a name: %s", result['error'])
|
||||
return Failure(UnknownNameError(name))
|
||||
|
||||
_check_result_fields(result)
|
||||
|
||||
try:
|
||||
metadata = Metadata(json.loads(result['value']))
|
||||
except (TypeError, ValueError, ValidationError):
|
||||
return Failure(InvalidStreamInfoError(name,result['value']))
|
||||
|
||||
return Failure(InvalidStreamInfoError(name, result['value']))
|
||||
txid = result['txid']
|
||||
sd_hash = metadata['sources']['lbry_sd_hash']
|
||||
d = self._save_name_metadata(name, txid, sd_hash)
|
||||
|
|
|
@ -91,7 +91,7 @@ class CryptStreamBlobMaker(object):
|
|||
|
||||
def _write_buffer(self):
|
||||
num_bytes_to_encrypt = (len(self.buff) // AES.block_size) * AES.block_size
|
||||
data_to_encrypt, self.buff = self.buff[:num_bytes_to_encrypt], self.buff[num_bytes_to_encrypt:]
|
||||
data_to_encrypt, self.buff = split(self.buff, num_bytes_to_encrypt)
|
||||
encrypted_data = self.cipher.encrypt(data_to_encrypt)
|
||||
self.blob.write(encrypted_data)
|
||||
|
||||
|
@ -107,3 +107,6 @@ class CryptStreamBlobMaker(object):
|
|||
|
||||
def _return_info(self, blob_hash):
|
||||
return CryptBlobInfo(blob_hash, self.blob_num, self.length, binascii.hexlify(self.iv))
|
||||
|
||||
def split(buff, cutoff):
|
||||
return buff[:cutoff], buff[cutoff:]
|
||||
|
|
|
@ -590,7 +590,7 @@ class Node(object):
|
|||
contacts = self._routingTable.findCloseNodes(key, constants.k, rpcSenderID)
|
||||
contactTriples = []
|
||||
for contact in contacts:
|
||||
contactTriples.append( (contact.id, contact.address, contact.port) )
|
||||
contactTriples.append((contact.id, contact.address, contact.port))
|
||||
return contactTriples
|
||||
|
||||
@rpcmethod
|
||||
|
|
|
@ -266,7 +266,8 @@ class KademliaProtocol(protocol.DatagramProtocol):
|
|||
try:
|
||||
##try:
|
||||
## # Try to pass the sender's node id to the function...
|
||||
result = func(*args, **{'_rpcNodeID': senderContact.id, '_rpcNodeContact': senderContact})
|
||||
kwargs = {'_rpcNodeID': senderContact.id, '_rpcNodeContact': senderContact}
|
||||
result = func(*args, **kwargs)
|
||||
##except TypeError:
|
||||
## # ...or simply call it if that fails
|
||||
## result = func(*args)
|
||||
|
@ -276,7 +277,7 @@ class KademliaProtocol(protocol.DatagramProtocol):
|
|||
df.callback(result)
|
||||
else:
|
||||
# No such exposed method
|
||||
df.errback( failure.Failure( AttributeError('Invalid method: %s' % method) ) )
|
||||
df.errback(failure.Failure(AttributeError('Invalid method: %s' % method)))
|
||||
|
||||
def _msgTimeout(self, messageID):
|
||||
""" Called when an RPC request message times out """
|
||||
|
|
|
@ -419,4 +419,5 @@ class OptimizedTreeRoutingTable(TreeRoutingTable):
|
|||
# Replace this stale contact with one from our replacemnent cache, if we have any
|
||||
if self._replacementCache.has_key(bucketIndex):
|
||||
if len(self._replacementCache[bucketIndex]) > 0:
|
||||
self._buckets[bucketIndex].addContact( self._replacementCache[bucketIndex].pop() )
|
||||
self._buckets[bucketIndex].addContact(
|
||||
self._replacementCache[bucketIndex].pop())
|
||||
|
|
|
@ -145,7 +145,7 @@ if __name__ == '__main__':
|
|||
# If you wish to have a pure Kademlia network, use the entangled.kademlia.node.Node class instead
|
||||
print 'Creating Node...'
|
||||
#node = EntangledNode( udpPort=int(sys.argv[1]), dataStore=dataStore )
|
||||
node = Node( udpPort=int(sys.argv[1]), lbryid=lbryid)
|
||||
node = Node(udpPort=int(sys.argv[1]), lbryid=lbryid)
|
||||
|
||||
# Schedule the node to join the Kademlia/Entangled DHT
|
||||
node.joinNetwork(knownNodes)
|
||||
|
|
|
@ -72,7 +72,7 @@ class Console():
|
|||
self.lbrycrd_dir = lbrycrd_dir
|
||||
if not self.lbrycrd_dir:
|
||||
if sys.platform == "darwin":
|
||||
self.lbrycrd_dir = os.path.join(os.path.expanduser("~"), "Library/Application Support/lbrycrd")
|
||||
self.lbrycrd_dir = os.path.join(os.path.expanduser("~"), "Library/Application Support/lbrycrd")
|
||||
else:
|
||||
self.lbrycrd_dir = os.path.join(os.path.expanduser("~"), ".lbrycrd")
|
||||
if not self.lbrycrd_conf:
|
||||
|
|
|
@ -42,7 +42,7 @@ class DaemonRequest(server.Request):
|
|||
if self.do_log:
|
||||
print '%f Request Received' % time.time()
|
||||
|
||||
self.content.seek(0,0)
|
||||
self.content.seek(0, 0)
|
||||
self.args = {}
|
||||
self.stack = []
|
||||
|
||||
|
@ -74,7 +74,7 @@ class DaemonRequest(server.Request):
|
|||
args.update(parse_qs(self.content.read(), 1))
|
||||
elif key == mfd:
|
||||
try:
|
||||
self.content.seek(0,0)
|
||||
self.content.seek(0, 0)
|
||||
args.update(self.parse_multipart(self.content, pdict))
|
||||
#args.update(cgi.parse_multipart(self.content, pdict))
|
||||
|
||||
|
@ -100,14 +100,13 @@ class DaemonRequest(server.Request):
|
|||
if self.do_log:
|
||||
print '%f Parsing Multipart data: ' % time.time()
|
||||
rewind = fp.tell() #save cursor
|
||||
fp.seek(0,0) #reset cursor
|
||||
fp.seek(0, 0) #reset cursor
|
||||
|
||||
boundary = ""
|
||||
if 'boundary' in pdict:
|
||||
boundary = pdict['boundary']
|
||||
if not cgi.valid_boundary(boundary):
|
||||
raise ValueError, ('Invalid boundary in multipart form: %r'
|
||||
% (boundary,))
|
||||
raise ValueError('Invalid boundary in multipart form: %r' % (boundary,))
|
||||
|
||||
nextpart = "--" + boundary
|
||||
lastpart = "--" + boundary + "--"
|
||||
|
@ -175,7 +174,7 @@ class DaemonRequest(server.Request):
|
|||
else:
|
||||
# Unnamed parts are not returned at all.
|
||||
continue
|
||||
data.seek(0,0)
|
||||
data.seek(0, 0)
|
||||
if name in partdict:
|
||||
partdict[name].append(data)
|
||||
else:
|
||||
|
|
|
@ -33,7 +33,7 @@ class Metadata(StructuredDict):
|
|||
]
|
||||
|
||||
def __init__(self, metadata, migrate=True, target_version=None):
|
||||
if not isinstance(metadata,dict):
|
||||
if not isinstance(metadata, dict):
|
||||
raise TypeError("metadata is not a dictionary")
|
||||
starting_version = metadata.get('ver', '0.0.1')
|
||||
|
||||
|
|
|
@ -64,9 +64,9 @@ VER_001 = {
|
|||
},
|
||||
'fee': {
|
||||
'properties': {
|
||||
'LBC': { '$ref': '#/definitions/fee_info' },
|
||||
'BTC': { '$ref': '#/definitions/fee_info' },
|
||||
'USD': { '$ref': '#/definitions/fee_info' }
|
||||
'LBC': {'$ref': '#/definitions/fee_info'},
|
||||
'BTC': {'$ref': '#/definitions/fee_info'},
|
||||
'USD': {'$ref': '#/definitions/fee_info'}
|
||||
}
|
||||
},
|
||||
'contact': {
|
||||
|
@ -76,7 +76,8 @@ VER_001 = {
|
|||
'type': 'string'
|
||||
},
|
||||
},
|
||||
'required': ['title', 'description', 'author', 'language', 'license', 'content-type', 'sources'],
|
||||
'required': [
|
||||
'title', 'description', 'author', 'language', 'license', 'content-type', 'sources'],
|
||||
'additionalProperties': False
|
||||
}
|
||||
|
||||
|
@ -147,9 +148,9 @@ VER_002 = {
|
|||
},
|
||||
'fee': {
|
||||
'properties': {
|
||||
'LBC': { '$ref': '#/definitions/fee_info' },
|
||||
'BTC': { '$ref': '#/definitions/fee_info' },
|
||||
'USD': { '$ref': '#/definitions/fee_info' }
|
||||
'LBC': {'$ref': '#/definitions/fee_info'},
|
||||
'BTC': {'$ref': '#/definitions/fee_info'},
|
||||
'USD': {'$ref': '#/definitions/fee_info'}
|
||||
}
|
||||
},
|
||||
'contact': {
|
||||
|
@ -167,7 +168,10 @@ VER_002 = {
|
|||
},
|
||||
|
||||
},
|
||||
'required': ['ver', 'title', 'description', 'author', 'language', 'license', 'content-type', 'sources', 'nsfw'],
|
||||
'required': [
|
||||
'ver', 'title', 'description', 'author', 'language', 'license',
|
||||
'content-type', 'sources', 'nsfw'
|
||||
],
|
||||
'additionalProperties': False
|
||||
}
|
||||
|
||||
|
@ -238,9 +242,9 @@ VER_003 = {
|
|||
},
|
||||
'fee': {
|
||||
'properties': {
|
||||
'LBC': { '$ref': '#/definitions/fee_info' },
|
||||
'BTC': { '$ref': '#/definitions/fee_info' },
|
||||
'USD': { '$ref': '#/definitions/fee_info' }
|
||||
'LBC': {'$ref': '#/definitions/fee_info'},
|
||||
'BTC': {'$ref': '#/definitions/fee_info'},
|
||||
'USD': {'$ref': '#/definitions/fee_info'}
|
||||
}
|
||||
},
|
||||
'contact': {
|
||||
|
@ -260,7 +264,10 @@ VER_003 = {
|
|||
'type': 'string'
|
||||
}
|
||||
},
|
||||
'required': ['ver', 'title', 'description', 'author', 'language', 'license', 'content_type', 'sources', 'nsfw'],
|
||||
'required': [
|
||||
'ver', 'title', 'description', 'author', 'language', 'license',
|
||||
'content_type', 'sources', 'nsfw'
|
||||
],
|
||||
'additionalProperties': False,
|
||||
'dependencies': {
|
||||
'pubkey': ['sig'],
|
||||
|
|
|
@ -88,7 +88,7 @@ class ReflectorServer(Protocol):
|
|||
else:
|
||||
self.incoming_blob = blob
|
||||
self.blob_finished_d, self.blob_write, self.cancel_write = blob.open_for_writing(self.peer)
|
||||
self.blob_finished_d.addCallback(lambda _ :self.blob_manager.blob_completed(blob))
|
||||
self.blob_finished_d.addCallback(lambda _: self.blob_manager.blob_completed(blob))
|
||||
return {'send_blob': True}
|
||||
|
||||
def close_blob(self):
|
||||
|
|
|
@ -3,7 +3,8 @@ import ctypes, sys
|
|||
from ctypes import windll, wintypes
|
||||
from uuid import UUID
|
||||
|
||||
class GUID(ctypes.Structure): # [1]
|
||||
# http://msdn.microsoft.com/en-us/library/windows/desktop/aa373931.aspx
|
||||
class GUID(ctypes.Structure):
|
||||
_fields_ = [
|
||||
("Data1", wintypes.DWORD),
|
||||
("Data2", wintypes.WORD),
|
||||
|
@ -17,7 +18,10 @@ class GUID(ctypes.Structure): # [1]
|
|||
for i in range(2, 8):
|
||||
self.Data4[i] = rest>>(8 - i - 1)*8 & 0xff
|
||||
|
||||
class FOLDERID: # [2]
|
||||
|
||||
# http://msdn.microsoft.com/en-us/library/windows/desktop/dd378457.aspx
|
||||
class FOLDERID:
|
||||
# pylint: disable=bad-whitespace
|
||||
AccountPictures = UUID('{008ca0b1-55b4-4c56-b8a8-4de4b299d3be}')
|
||||
AdminTools = UUID('{724EF170-A42D-4FEF-9F26-B60E846FBA4F}')
|
||||
ApplicationShortcuts = UUID('{A3918781-E5F2-4890-B3D9-A7E54332328C}')
|
||||
|
@ -113,20 +117,30 @@ class FOLDERID: # [2]
|
|||
VideosLibrary = UUID('{491E922F-5643-4AF4-A7EB-4E7A138D8174}')
|
||||
Windows = UUID('{F38BF404-1D43-42F2-9305-67DE0B28FC23}')
|
||||
|
||||
class UserHandle: # [3]
|
||||
current = wintypes.HANDLE(0)
|
||||
common = wintypes.HANDLE(-1)
|
||||
|
||||
_CoTaskMemFree = windll.ole32.CoTaskMemFree # [4]
|
||||
_CoTaskMemFree.restype= None
|
||||
# http://msdn.microsoft.com/en-us/library/windows/desktop/bb762188.aspx
|
||||
class UserHandle:
|
||||
current = wintypes.HANDLE(0)
|
||||
common = wintypes.HANDLE(-1)
|
||||
|
||||
|
||||
# http://msdn.microsoft.com/en-us/library/windows/desktop/ms680722.aspx
|
||||
_CoTaskMemFree = windll.ole32.CoTaskMemFree
|
||||
_CoTaskMemFree.restype = None
|
||||
_CoTaskMemFree.argtypes = [ctypes.c_void_p]
|
||||
|
||||
_SHGetKnownFolderPath = windll.shell32.SHGetKnownFolderPath # [5] [3]
|
||||
|
||||
# http://msdn.microsoft.com/en-us/library/windows/desktop/bb762188.aspx
|
||||
# http://www.themacaque.com/?p=954
|
||||
_SHGetKnownFolderPath = windll.shell32.SHGetKnownFolderPath
|
||||
_SHGetKnownFolderPath.argtypes = [
|
||||
ctypes.POINTER(GUID), wintypes.DWORD, wintypes.HANDLE, ctypes.POINTER(ctypes.c_wchar_p)
|
||||
]
|
||||
|
||||
class PathNotFoundException(Exception): pass
|
||||
|
||||
class PathNotFoundException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
def get_path(folderid, user_handle=UserHandle.common):
|
||||
fid = GUID(folderid)
|
||||
|
@ -138,6 +152,7 @@ def get_path(folderid, user_handle=UserHandle.common):
|
|||
_CoTaskMemFree(pPath)
|
||||
return path
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) < 2 or sys.argv[1] in ['-?', '/?']:
|
||||
print('python knownpaths.py FOLDERID {current|common}')
|
||||
|
@ -157,9 +172,3 @@ if __name__ == '__main__':
|
|||
except PathNotFoundException:
|
||||
print('Folder not found "%s"' % ' '.join(sys.argv[1:]), file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
# [1] http://msdn.microsoft.com/en-us/library/windows/desktop/aa373931.aspx
|
||||
# [2] http://msdn.microsoft.com/en-us/library/windows/desktop/dd378457.aspx
|
||||
# [3] http://msdn.microsoft.com/en-us/library/windows/desktop/bb762188.aspx
|
||||
# [4] http://msdn.microsoft.com/en-us/library/windows/desktop/ms680722.aspx
|
||||
# [5] http://www.themacaque.com/?p=954
|
||||
|
|
|
@ -64,7 +64,7 @@ pip install pyOpenSSL
|
|||
|
||||
pip install pylint
|
||||
pylint -E --disable=inherit-non-class --disable=no-member --ignored-modules=distutils \
|
||||
--enable=unused-import lbrynet packaging/osx/lbry-osx-app/lbrygui/
|
||||
--enable=unused-import --enable=bad-whitespace lbrynet packaging/osx/lbry-osx-app/lbrygui/
|
||||
|
||||
python setup.py install
|
||||
|
||||
|
|
|
@ -46,4 +46,4 @@ coveralls
|
|||
# Ignoring distutils because: https://github.com/PyCQA/pylint/issues/73
|
||||
# TODO: as code quality improves, make pylint be more strict
|
||||
pylint -E --disable=inherit-non-class --disable=no-member --ignored-modules=distutils \
|
||||
--enable=unused-import lbrynet
|
||||
--enable=unused-import --enable=bad-whitespace lbrynet
|
||||
|
|
|
@ -2,5 +2,5 @@ C:\Python27\Scripts\pip.exe install mock
|
|||
C:\Python27\Scripts\pip.exe install pylint
|
||||
C:\Python27\python.exe C:\Python27\Scripts\trial.py C:\projects\lbry\tests\unit
|
||||
if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
|
||||
C:\Python27\Scripts\pylint.exe -E --disable=inherit-non-class --disable=no-member --ignored-modules=distutils --enable=unused-import lbrynet packaging/windows/lbry-win32-app/LBRYWin32App.py
|
||||
C:\Python27\Scripts\pylint.exe -E --disable=inherit-non-class --disable=no-member --ignored-modules=distutils --enable=unused-import --enable=bad-whitespace lbrynet packaging/windows/lbry-win32-app/LBRYWin32App.py
|
||||
if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
|
||||
|
|
Loading…
Reference in a new issue