Skip to content

Commit b88125a

Browse files
committed
black formatting
1 parent 8ab5314 commit b88125a

3 files changed

Lines changed: 32 additions & 31 deletions

File tree

roku/scripting.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,24 @@
44
import time
55
from collections import namedtuple
66

7-
SCRIPT_RE = re.compile(r"(?P<command>\w+)(?:\:(?P<param>[\w\s]+))?(?:\@(?P<count>\d+))?(?:\*(?P<sleep>[\d\.]+))?") # noqa
7+
SCRIPT_RE = re.compile(
8+
r"(?P<command>\w+)(?:\:(?P<param>[\w\s]+))?(?:\@(?P<count>\d+))?(?:\*(?P<sleep>[\d\.]+))?"
9+
) # noqa
810

9-
Command = namedtuple('Command', ['command', 'param', 'count', 'sleep'])
11+
Command = namedtuple("Command", ["command", "param", "count", "sleep"])
1012

11-
logger = logging.getLogger('roku.scripting')
13+
logger = logging.getLogger("roku.scripting")
1214

1315

1416
def load_script(path, params=None, raw=False):
1517
if not os.path.exists(path):
16-
raise ValueError(f'script at {path} not found')
18+
raise ValueError(f"script at {path} not found")
1719
with open(path) as infile:
1820
content = infile.read()
1921
if params:
2022
content = content.format(**params)
2123
if not raw:
22-
content = content.strip().split('\n')
24+
content = content.strip().split("\n")
2325
return content
2426

2527

@@ -31,8 +33,8 @@ def parse_script(script):
3133
m = SCRIPT_RE.match(line)
3234
if m:
3335
data = m.groupdict()
34-
data['count'] = int(data['count'] or 1)
35-
data['sleep'] = float(data['sleep']) if data['sleep'] else None
36+
data["count"] = int(data["count"] or 1)
37+
data["sleep"] = float(data["sleep"]) if data["sleep"] else None
3638
commands.append(Command(**data))
3739
return commands
3840

roku/tests/conftest.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44

55

66
class Fauxku(Roku):
7-
87
def __init__(self, *args, **kwargs):
98
super(Fauxku, self).__init__(*args, **kwargs)
109
self._calls = []
1110

1211
def _call(self, method, path, *args, **kwargs):
1312
self._calls.append((method, path, args, kwargs))
14-
return ''
13+
return ""
1514

1615
def calls(self):
1716
return self._calls
@@ -22,15 +21,15 @@ def last_call(self):
2221

2322
@pytest.fixture
2423
def roku():
25-
return Fauxku('0.0.0.0')
24+
return Fauxku("0.0.0.0")
2625

2726

2827
@pytest.fixture
2928
def apps(roku):
3029
faux_apps = [
31-
Application('11', '1.0.1', 'Fauxku Channel Store', roku),
32-
Application('22', '2.0.2', 'Faux Netflix', roku),
33-
Application('33', '3.0.3', 'Faux YouTube', roku),
34-
Application('44HL', '4.0.4', 'Faux Hulu', roku),
30+
Application("11", "1.0.1", "Fauxku Channel Store", roku),
31+
Application("22", "2.0.2", "Faux Netflix", roku),
32+
Application("33", "3.0.3", "Faux YouTube", roku),
33+
Application("44HL", "4.0.4", "Faux Hulu", roku),
3534
]
3635
return faux_apps

roku/tests/test_scripting.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from roku import scripting
44

55

6-
SCRIPT_PATH = 'roku/tests/scripts/testscript.txt'
6+
SCRIPT_PATH = "roku/tests/scripts/testscript.txt"
77

88

99
def test_loading():
@@ -12,8 +12,8 @@ def test_loading():
1212

1313
def test_loading_params():
1414
params = {
15-
'avar': 'here',
16-
'notavar': 'missing',
15+
"avar": "here",
16+
"notavar": "missing",
1717
}
1818
content = scripting.load_script(SCRIPT_PATH, params=params, raw=True)
1919
assert "literal:here" in content
@@ -22,48 +22,48 @@ def test_loading_params():
2222

2323
def test_loading_notfound():
2424
with pytest.raises(ValueError):
25-
scripting.load_script('thisisnotarealscript.txt')
25+
scripting.load_script("thisisnotarealscript.txt")
2626

2727

2828
def test_parse_command_only():
29-
content = ('home',)
29+
content = ("home",)
3030
script = scripting.parse_script(content)
3131
command = script[0]
32-
assert command == scripting.Command('home', None, 1, None)
32+
assert command == scripting.Command("home", None, 1, None)
3333

3434

3535
def test_parse_command_param():
36-
content = ('literal:barbecue',)
36+
content = ("literal:barbecue",)
3737
script = scripting.parse_script(content)
3838
command = script[0]
39-
assert command == scripting.Command('literal', 'barbecue', 1, None)
39+
assert command == scripting.Command("literal", "barbecue", 1, None)
4040

4141

4242
def test_parse_command_count():
43-
content = ('left@10',)
43+
content = ("left@10",)
4444
script = scripting.parse_script(content)
4545
command = script[0]
46-
assert command == scripting.Command('left', None, 10, None)
46+
assert command == scripting.Command("left", None, 10, None)
4747

4848

4949
def test_parse_command_sleep():
50-
content = ('left*2',)
50+
content = ("left*2",)
5151
script = scripting.parse_script(content)
5252
command = script[0]
53-
assert command == scripting.Command('left', None, 1, 2.0)
53+
assert command == scripting.Command("left", None, 1, 2.0)
5454

5555

5656
def test_parse_command_all():
57-
content = ('literal:barbecue@3*5.1',)
57+
content = ("literal:barbecue@3*5.1",)
5858
script = scripting.parse_script(content)
5959
command = script[0]
60-
assert command == scripting.Command('literal', 'barbecue', 3, 5.1)
60+
assert command == scripting.Command("literal", "barbecue", 3, 5.1)
6161

6262

6363
def test_run_script(roku):
64-
content = ('home', 'literal:x')
64+
content = ("home", "literal:x")
6565
script = scripting.parse_script(content)
6666
scripting.run_script(roku, script)
6767
calls = roku.calls()
68-
assert 'keypress/Home' in calls[0][1]
69-
assert 'keypress/Lit_x' in calls[1][1]
68+
assert "keypress/Home" in calls[0][1]
69+
assert "keypress/Lit_x" in calls[1][1]

0 commit comments

Comments
 (0)