Skip to content

Commit

Permalink
Flake (#96)
Browse files Browse the repository at this point in the history
* Enabled flake8 on vos and fixed the codestyle errors
  • Loading branch information
andamian committed Oct 24, 2017
1 parent b4ff77f commit 238ff91
Show file tree
Hide file tree
Showing 69 changed files with 2,320 additions and 1,227 deletions.
9 changes: 8 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@ install:
- pip install coveralls

script:
- for i in $(ls -d */); do cd $i; pytest --cov $i || exit 1; cd ..; done
- for i in $(ls -d */); do
cd $i;
pytest --cov $i || exit 1;
if [[ $TRAVIS_PYTHON_VERSION == '3.5' ]]; then
flake8 -v $i || break -1;
fi;
cd ..;
done

after_success:
# If coveralls.io is set up for this package, uncomment the line
Expand Down
3 changes: 2 additions & 1 deletion vofs/dev_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
-e .
pytest>=3.0.5
pytest-cov>=2.5.1
flake8>=3.4.1
mock==2.0.0
future==0.16.0
unittest2==1.1.0
unittest2==1.1.0
2 changes: 1 addition & 1 deletion vofs/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def readme():

# generate the version file
with open(os.path.join(PACKAGENAME, 'version.py'), 'w') as f:
f.write('version = \'{}\''.format(VERSION))
f.write('version = \'{}\'\n'.format(VERSION))

# Treat everything in scripts except README.rst as a script to be installed
scripts = [fname for fname in glob.glob(os.path.join('scripts', '*'))
Expand Down
27 changes: 15 additions & 12 deletions vofs/vofs/CacheMetaData.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

logger = logging.getLogger('cache')

class CacheMetaData(object):

class CacheMetaData(object):
def __init__(self, metaDataFile, blocks, md5sum, size):
"""
Creates an instance of CacheMetaData for the given file. If the same
Expand All @@ -31,7 +31,7 @@ def __init__(self, metaDataFile, blocks, md5sum, size):
f = open(self.metaDataFile, 'rb')
persisted = pickle.load(f)
if self.md5sum is None or persisted.md5sum == self.md5sum:
#persisted bitmap still valid. Used that instead
# persisted bitmap still valid. Used that instead
self.bitmap = persisted.bitmap
self.size = persisted.size
self.md5sum = persisted.md5sum
Expand All @@ -42,16 +42,19 @@ def __init__(self, metaDataFile, blocks, md5sum, size):

def __str__(self):
"""To create a print representation that is informative."""
return "CacheMetaData: metaDataFile=%r bitmap=%r md5sum=%r size=%r" % (str(self.metaDataFile),
self.bitmap,
self.md5sum,
self.size)
return "CacheMetaData: metaDataFile=%r bitmap=%r md5sum=%r size=%r" % \
(str(self.metaDataFile),
self.bitmap,
self.md5sum,
self.size)

def __repr__(self):
return "CacheMetaData(metaDataFile=%r, blocks=%r, md5sum=%r, size=%r)" % (str(self.metaDataFile),
self.blocks,
self.md5sum,
self.size)
return ("CacheMetaData(metaDataFile=%r, blocks=%r, "
"md5sum=%r, size=%r)") % (str(self.metaDataFile),
self.blocks,
self.md5sum,
self.size)

def setReadBlocks(self, start, end):
""" To mark several blocks as read (start and end inclusive). """
startBlock = start
Expand All @@ -62,7 +65,7 @@ def setReadBlocks(self, start, end):
endBlock = self.bitmap.length() + end
if startBlock > endBlock:
raise ValueError('''Incorrect interval, max is %d > %d''' %
(startBlock, endBlock))
(startBlock, endBlock))
for i in range(startBlock, endBlock + 1):
self.setReadBlock(i)

Expand Down Expand Up @@ -103,7 +106,7 @@ def getRange(self, start, end):
startBlock = i
break
if i == endBlock:
#all the blocks are cached already
# all the blocks are cached already
return (None, None)

for i in reversed(range(startBlock, endBlock + 1)):
Expand Down

0 comments on commit 238ff91

Please sign in to comment.