Skip to content

Commit 30b1234

Browse files
author
Shakeel Mohamed
committed
Final bits of code cleanup & simplification
1 parent 0b1d678 commit 30b1234

File tree

8 files changed

+16
-16
lines changed

8 files changed

+16
-16
lines changed

splunklib/modularinput/event.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Event(object):
2323
To write an input to a stream, call the write_to function, passing in a stream.
2424
"""
2525
def __init__(self, data=None, stanza=None, time=None, host=None, index=None, source=None,
26-
sourceType=None, done=True, unbroken=True):
26+
sourcetype=None, done=True, unbroken=True):
2727
"""There are no required parameters for constructing an Event
2828
2929
Example with minimal configuration:
@@ -43,7 +43,7 @@ def __init__(self, data=None, stanza=None, time=None, host=None, index=None, sou
4343
host="localhost",
4444
index="main",
4545
source="Splunk",
46-
sourceType="misc",
46+
sourcetype="misc",
4747
done=True,
4848
unbroken=True
4949
)
@@ -54,7 +54,7 @@ def __init__(self, data=None, stanza=None, time=None, host=None, index=None, sou
5454
:param host: string, the event's host, ex: localhost
5555
:param index: string, the index this event is specified to write to, or None if default index
5656
:param source: string, the source of this event, or None to have Splunk guess
57-
:param sourceType: string, source type currently set on this event, or None to have Splunk guess
57+
:param sourcetype: string, source type currently set on this event, or None to have Splunk guess
5858
:param done: boolean, is this a complete Event? False if an Event fragment
5959
:param unbroken: boolean, Is this event completely encapsulated in this Event object?
6060
"""
@@ -63,7 +63,7 @@ def __init__(self, data=None, stanza=None, time=None, host=None, index=None, sou
6363
self.host = host
6464
self.index = index
6565
self.source = source
66-
self.sourceType = sourceType
66+
self.sourceType = sourcetype
6767
self.stanza = stanza
6868
self.time = time
6969
self.unbroken = unbroken
@@ -72,7 +72,7 @@ def write_to(self, stream):
7272
"""Write an XML representation of self, an Event object, to the given stream
7373
7474
The Event object will only be written if its data field is defined,
75-
else a ValueError is raised.
75+
otherwise a ValueError is raised.
7676
7777
:param stream: stream to write XML to
7878
"""

splunklib/modularinput/input_definition.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def __eq__(self, other):
3636
return self.metadata == other.metadata and self.inputs == other.inputs
3737

3838
@staticmethod
39-
def parse_input_definition(stream):
39+
def parse(stream):
4040
"""Parse a stream containing XML into an InputDefinition.
4141
4242
:param stream: stream containing XML to parse

splunklib/modularinput/script.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def run_script(self, args, event_writer, input_stream):
6161
if len(args) == 0:
6262
# This script is running as an input. Input definitions will be passed on stdin
6363
# as XML, and the script will write events on stdout and log entries on stderr.
64-
input_definition = InputDefinition.parse_input_definition(input_stream)
64+
input_definition = InputDefinition.parse(input_stream)
6565
self.stream_events(input_definition, event_writer)
6666
event_writer.close()
6767
return 0
@@ -78,7 +78,7 @@ def run_script(self, args, event_writer, input_stream):
7878
return 0
7979

8080
elif args[0].lower() == "--validate-arguments":
81-
validation_definition = ValidationDefinition.parse_validation_definition(input_stream)
81+
validation_definition = ValidationDefinition.parse(input_stream)
8282
try:
8383
self.validate_input(validation_definition)
8484
return 0

splunklib/modularinput/validation_definition.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def __eq__(self, other):
3737
return self.metadata == other.metadata and self.parameters == other.parameters
3838

3939
@staticmethod
40-
def parse_validation_definition(stream):
40+
def parse(stream):
4141
"""Creates a ValidationDefinition from a provided stream containing XML.
4242
4343
The XML typically will look like

tests/modularinput/test_event.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def test_xml_of_event_with_more_configuration(self):
6262
host="localhost",
6363
index="main",
6464
source="hilda",
65-
sourceType="misc",
65+
sourcetype="misc",
6666
done=True,
6767
unbroken=True
6868
)
@@ -88,7 +88,7 @@ def test_writing_events_on_event_writer(self):
8888
host="localhost",
8989
index="main",
9090
source="hilda",
91-
sourceType="misc",
91+
sourcetype="misc",
9292
done=True,
9393
unbroken=True
9494
)

tests/modularinput/test_input_definition.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class InputDefinitionTestCase(unittest.TestCase):
2222
def test_parse_inputdef_with_zero_inputs(self):
2323
"""Check parsing of XML that contains only metadata"""
2424

25-
found = InputDefinition.parse_input_definition(open("data/conf_with_0_inputs.xml"))
25+
found = InputDefinition.parse(open("data/conf_with_0_inputs.xml"))
2626

2727
expectedDefinition = InputDefinition()
2828
expectedDefinition.metadata = {
@@ -37,7 +37,7 @@ def test_parse_inputdef_with_zero_inputs(self):
3737
def test_parse_inputdef_with_two_inputs(self):
3838
"""Check parsing of XML that contains 2 inputs"""
3939

40-
found = InputDefinition.parse_input_definition(open("data/conf_with_2_inputs.xml"))
40+
found = InputDefinition.parse(open("data/conf_with_2_inputs.xml"))
4141

4242
expectedDefinition = InputDefinition()
4343
expectedDefinition.metadata = {
@@ -67,7 +67,7 @@ def test_attempt_to_parse_malformed_input_definition_will_throw_exception(self):
6767
"""Does malformed XML cause the expected exception."""
6868

6969
with self.assertRaises(ValueError):
70-
found = InputDefinition.parse_input_definition(open("data/conf_with_invalid_inputs.xml"))
70+
found = InputDefinition.parse(open("data/conf_with_invalid_inputs.xml"))
7171

7272
if __name__ == "__main__":
7373
unittest.main()

tests/modularinput/test_script.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def stream_events(self, inputs, ew):
182182
host="localhost",
183183
index="main",
184184
source="hilda",
185-
sourceType="misc",
185+
sourcetype="misc",
186186
done=True,
187187
unbroken=True
188188
)

tests/modularinput/test_validation_definition.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
class ValidationDefinitionTestCase(unittest.TestCase):
2121
def test_validation_definition_parse(self):
2222
"""Check that parsing produces expected result"""
23-
found = ValidationDefinition.parse_validation_definition(open("data/validation.xml"))
23+
found = ValidationDefinition.parse(open("data/validation.xml"))
2424

2525
expected = ValidationDefinition()
2626
expected.metadata = {

0 commit comments

Comments
 (0)