Skip to content

Commit

Permalink
Improve codestyle
Browse files Browse the repository at this point in the history
[Flake error E741](https://www.flake8rules.com/rules/E741.html) fixed.
Replaced single digit variablenames with meaningful names
Replaced re enum with its long version

Fixes #14
  • Loading branch information
mtausig committed Oct 7, 2020
1 parent 7181e8e commit 323b9cf
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
34 changes: 17 additions & 17 deletions lib/cfv/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -735,10 +735,10 @@ class FooSum_Base(TextChksumType):
def do_test_chksumfile_print_testingline(self, file):
TextChksumType.do_test_chksumfile_print_testingline(self, file, parse_commentline(file.peekline(512), ';#'))

def do_test_chksumline(self, l):
if l[0] in ';#':
def do_test_chksumline(self, line):
if line[0] in ';#':
return
x = self._foosum_rem.match(l)
x = self._foosum_rem.match(line)
if not x:
return -1
if x.group(2) == ' ':
Expand Down Expand Up @@ -897,8 +897,8 @@ def auto_chksumfile_match(file, _autorem=re.compile(r'MD5 \(.+\) = [0-9a-fA-F]{3

_bsdmd5rem = re.compile(r'MD5 \((.+)\) = ([0-9a-fA-F]{32})[\r\n]*$')

def do_test_chksumline(self, l):
x = self._bsdmd5rem.match(l)
def do_test_chksumline(self, line):
x = self._bsdmd5rem.match(line)
if not x:
return -1
self.test_file(x.group(1), unhexlify(x.group(2)))
Expand Down Expand Up @@ -1397,10 +1397,10 @@ def do_test_chksumfile_print_testingline(self, file):
# override the default testing line to show first SFV comment line, if any
TextChksumType.do_test_chksumfile_print_testingline(self, file, parse_commentline(file.peekline(512), ';'))

def do_test_chksumline(self, l):
if l[0] == ';':
def do_test_chksumline(self, line):
if line[0] == ';':
return
x = self._sfvrem.match(l)
x = self._sfvrem.match(line)
if not x:
return -1
self.test_file(x.group(1), unhexlify(x.group(2)))
Expand Down Expand Up @@ -1502,8 +1502,8 @@ def auto_chksumfile_match(file, _autorem=re.compile(_csvfnautore + '[0-9]+,[0-9a

_csvrem = re.compile(_csvfnre + r'([0-9]+),([0-9a-fA-F]{8}),')

def do_test_chksumline(self, l):
x = self._csvrem.match(l)
def do_test_chksumline(self, line):
x = self._csvrem.match(line)
if not x:
return -1
self.test_file(csvunquote(x.group(1), x.group(2)), unhexlify(x.group(4)), int(x.group(3)))
Expand Down Expand Up @@ -1534,8 +1534,8 @@ def auto_chksumfile_match(file, _autorem=re.compile(r'%s[0-9]+,[0-9a-fA-F]{8},%s

_csv4rem = re.compile(r'%s([0-9]+),([0-9a-fA-F]{8}),%s' % (_csvfnre, _csvstrre))

def do_test_chksumline(self, l):
x = self._csv4rem.match(l)
def do_test_chksumline(self, line):
x = self._csv4rem.match(line)
if not x:
return -1
name = csvunquote(x.group(1), x.group(2))
Expand Down Expand Up @@ -1569,8 +1569,8 @@ def auto_chksumfile_match(file, _autorem=re.compile(_csvfnautore + '[0-9]+,[\n\r

_csv2rem = re.compile(_csvfnre + r'([0-9]+),')

def do_test_chksumline(self, l):
x = self._csv2rem.match(l)
def do_test_chksumline(self, line):
x = self._csv2rem.match(line)
if not x:
return -1
self.test_file(csvunquote(x.group(1), x.group(2)), None, int(x.group(3)))
Expand Down Expand Up @@ -1646,11 +1646,11 @@ def do_test_chksumfile_print_testingline(self, file):
_commentboundary = re.compile(r'^-+(\s+-+){1,4}\s*$')
_nstrip = re.compile(r'[.,]')

def do_test_chksumline(self, l):
if self._commentboundary.match(l):
def do_test_chksumline(self, line):
if self._commentboundary.match(line):
self.in_comments = not self.in_comments
return
x = self._crcrem.match(l)
x = self._crcrem.match(line)
if not x:
if self.in_comments:
return
Expand Down
2 changes: 1 addition & 1 deletion lib/cfv/osutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def path_split(filename):
return parts


def strippath(filename, num='a', _splitdrivere=re.compile(r'[a-z]:[/\\]', re.I)):
def strippath(filename, num='a', _splitdrivere=re.compile(r'[a-z]:[/\\]', re.IGNORECASE)):
"""Strip off path components from the left side of the filename.
>>> strippath(os.path.join('c:','foo','bar','baz'))
Expand Down
6 changes: 3 additions & 3 deletions lib/cfv/strutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
from StringIO import StringIO


def safesort(l):
def safesort(line):
sl = []
ul = []
for s in l:
for s in line:
if isinstance(s, str):
sl.append(s)
else:
ul.append(s)
sl.sort()
ul.sort()
l[:] = ul + sl
line[:] = ul + sl


def showfn(s):
Expand Down
2 changes: 1 addition & 1 deletion test/cfvtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def isatty(self):
def write(self, s):
pass

def writelines(self, l):
def writelines(self, lines):
pass

def flush(self):
Expand Down

0 comments on commit 323b9cf

Please sign in to comment.