-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from paritytrading/features/quickfix
philadelphia-generate: Add QuickFIX support
- Loading branch information
Showing
6 changed files
with
102 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[dialect] | ||
name=Example | ||
class-name-prefix=Example | ||
package-name=com.example.fix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import xml.etree.ElementTree | ||
|
||
from . import model | ||
|
||
|
||
def read_messages(filename): | ||
def message(elem): | ||
name = elem.get('name') | ||
msgtype = elem.get('msgtype') | ||
return model.Message(name=name, msg_type=msgtype) | ||
root = xml.etree.ElementTree.parse(filename).find('messages') | ||
return [message(elem) for elem in root.findall('message')] | ||
|
||
|
||
def read_fields(filename): | ||
def value(elem): | ||
enum = elem.get('enum') | ||
description = elem.get('description') | ||
return model.Value(name=description, value=enum) | ||
def field(root): | ||
number = root.get('number') | ||
name = root.get('name') | ||
type_ = _type(root) | ||
if name == 'MsgType' or not type_: | ||
values = [] | ||
else: | ||
values = [value(elem) for elem in root.findall('value')] | ||
return model.Field(tag=number, name=name, type_=type_, values=values) | ||
root = xml.etree.ElementTree.parse(filename).find('fields') | ||
return sorted([field(elem) for elem in root.findall('field')], | ||
key=lambda field: int(field.tag)) | ||
|
||
|
||
_TYPES = { | ||
'CHAR': 'char', | ||
'INT': 'int', | ||
'MULTIPLECHARVALUE': 'char', | ||
'MULTIPLESTRINGVALUE': 'String', | ||
'NUMINGROUP': 'int', | ||
'STRING': 'String', | ||
} | ||
|
||
|
||
def _type(elem): | ||
type_ = elem.get('type') | ||
return _TYPES.get(type_) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters