[feaLib] Make feaLib compliant with the PEP8 style guide
After this change, pep8 v1.6.2 reports no style guide violations.
This commit is contained in:
parent
4f27ce3585
commit
701c72116d
@ -80,15 +80,16 @@ class LexerTest(unittest.TestCase):
|
||||
self.assertRaises(FeatureLibError, lambda: lex("123 \u0001"))
|
||||
|
||||
def test_newline(self):
|
||||
lines = lambda s: [loc[1] for (_, _, loc) in Lexer(s, "test.fea")]
|
||||
def lines(s):
|
||||
return [loc[1] for (_, _, loc) in Lexer(s, "test.fea")]
|
||||
self.assertEqual(lines("FOO\n\nBAR\nBAZ"), [1, 3, 4]) # Unix
|
||||
self.assertEqual(lines("FOO\r\rBAR\rBAZ"), [1, 3, 4]) # Macintosh
|
||||
self.assertEqual(lines("FOO\r\n\r\n BAR\r\nBAZ"), [1, 3, 4]) # Windows
|
||||
self.assertEqual(lines("FOO\n\rBAR\r\nBAZ"), [1, 3, 4]) # mixed
|
||||
|
||||
def test_location(self):
|
||||
locs = lambda s: ["%s:%d:%d" % loc
|
||||
for (_, _, loc) in Lexer(s, "test.fea")]
|
||||
def locs(s):
|
||||
return ["%s:%d:%d" % loc for (_, _, loc) in Lexer(s, "test.fea")]
|
||||
self.assertEqual(locs("a b # Comment\n12 @x"), [
|
||||
"test.fea:1:1", "test.fea:1:3", "test.fea:2:1",
|
||||
"test.fea:2:4"
|
||||
|
@ -400,6 +400,11 @@ class Parser(object):
|
||||
except StopIteration:
|
||||
self.next_token_type_, self.next_token_ = (None, None)
|
||||
|
||||
@staticmethod
|
||||
def reverse_string_(s):
|
||||
"""'abc' --> 'bca'"""
|
||||
return ''.join(reversed(list(s)))
|
||||
|
||||
def make_glyph_range_(self, location, start, limit):
|
||||
"""("a.sc", "d.sc") --> {"a.sc", "b.sc", "c.sc", "d.sc"}"""
|
||||
result = set()
|
||||
@ -407,7 +412,8 @@ class Parser(object):
|
||||
raise FeatureLibError(
|
||||
"Bad range: \"%s\" and \"%s\" should have the same length" %
|
||||
(start, limit), location)
|
||||
rev = lambda s: ''.join(reversed(list(s))) # string reversal
|
||||
|
||||
rev = self.reverse_string_
|
||||
prefix = os.path.commonprefix([start, limit])
|
||||
suffix = rev(os.path.commonprefix([rev(start), rev(limit)]))
|
||||
if len(suffix) > 0:
|
||||
|
Loading…
x
Reference in New Issue
Block a user