Skip to content

Commit 478ac00

Browse files
Fix linting errors for simulator.py
1 parent fab0e4b commit 478ac00

File tree

1 file changed

+31
-16
lines changed

1 file changed

+31
-16
lines changed

simulator.py

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,58 +7,73 @@
77
__version__ = '0.0.1'
88
__description__ = 'scripting simulator'
99

10+
1011
def json_hash(str):
11-
if str:
12-
return json.loads(str)
12+
if str:
13+
return json.loads(str)
1314

1415
# analytics -method=<method> -segment-write-key=<segmentWriteKey> [options]
1516

17+
1618
parser = argparse.ArgumentParser(description='send a segment message')
1719

1820
parser.add_argument('--writeKey', help='the Segment writeKey')
1921
parser.add_argument('--type', help='The Segment message type')
2022

2123
parser.add_argument('--userId', help='the user id to send the event as')
22-
parser.add_argument('--anonymousId', help='the anonymous user id to send the event as')
23-
parser.add_argument('--context', help='additional context for the event (JSON-encoded)')
24+
parser.add_argument(
25+
'--anonymousId', help='the anonymous user id to send the event as')
26+
parser.add_argument(
27+
'--context', help='additional context for the event (JSON-encoded)')
2428

2529
parser.add_argument('--event', help='the event name to send with the event')
26-
parser.add_argument('--properties', help='the event properties to send (JSON-encoded)')
30+
parser.add_argument(
31+
'--properties', help='the event properties to send (JSON-encoded)')
2732

28-
parser.add_argument('--name', help='name of the screen or page to send with the message')
33+
parser.add_argument(
34+
'--name', help='name of the screen or page to send with the message')
2935

30-
parser.add_argument('--traits', help='the identify/group traits to send (JSON-encoded)')
36+
parser.add_argument(
37+
'--traits', help='the identify/group traits to send (JSON-encoded)')
3138

3239
parser.add_argument('--groupId', help='the group id')
3340

3441
options = parser.parse_args()
3542

43+
3644
def failed(status, msg):
3745
raise Exception(msg)
3846

47+
3948
def track():
40-
analytics.track(options.userId, options.event, anonymous_id = options.anonymousId,
41-
properties = json_hash(options.properties), context = json_hash(options.context))
49+
analytics.track(options.userId, options.event, anonymous_id=options.anonymousId,
50+
properties=json_hash(options.properties), context=json_hash(options.context))
51+
4252

4353
def page():
44-
analytics.page(options.userId, name = options.name, anonymous_id = options.anonymousId,
45-
properties = json_hash(options.properties), context = json_hash(options.context))
54+
analytics.page(options.userId, name=options.name, anonymous_id=options.anonymousId,
55+
properties=json_hash(options.properties), context=json_hash(options.context))
56+
4657

4758
def screen():
48-
analytics.screen(options.userId, name = options.name, anonymous_id = options.anonymousId,
49-
properties = json_hash(options.properties), context = json_hash(options.context))
59+
analytics.screen(options.userId, name=options.name, anonymous_id=options.anonymousId,
60+
properties=json_hash(options.properties), context=json_hash(options.context))
61+
5062

5163
def identify():
52-
analytics.identify(options.userId, anonymous_id = options.anonymousId,
53-
traits = json_hash(options.traits), context = json_hash(options.context))
64+
analytics.identify(options.userId, anonymous_id=options.anonymousId,
65+
traits=json_hash(options.traits), context=json_hash(options.context))
66+
5467

5568
def group():
5669
analytics.group(options.userId, options.groupId, json_hash(options.traits),
57-
json_hash(options.context), anonymous_id = options.anonymousId)
70+
json_hash(options.context), anonymous_id=options.anonymousId)
71+
5872

5973
def unknown():
6074
print()
6175

76+
6277
analytics.write_key = options.writeKey
6378
analytics.on_error = failed
6479
analytics.debug = True

0 commit comments

Comments
 (0)