Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- from lxml import etree
- # input:
- # <RangeEntry minFrequency="" maxFrequency="" mode="" step="" color=""></RangeEntry>
- # output:
- ## Tag name ; color
- #AM ; #c0c0c0
- #
- ## Frequency ; Name ; Modulation ; Bandwidth; Tags
- # 500000; 123 ; LSB ; 2700; Untagged
- # 579800; 321 ; Narrow FM ; 10000; Untagged
- # 596400; ttt ; AM ; 10000; Untagged
- # 596400; ttt ; CW-L ; 500; Untagged
- modulation_mapping = {
- 'AM': {'mode': 'AM', 'bandwidth': 10000},
- 'LSB': {'mode': 'LSB', 'bandwidth': 2700},
- 'USB': {'mode': 'USB', 'bandwidth': 2700},
- 'CW': {'mode': 'CW-L', 'bandwidth': 500},
- 'NFM': {'mode': 'Narrow FM', 'bandwidth': 10000},
- 'WFM': {'mode': 'WFM (mono)', 'bandwidth': 160000},}
- with open('BandPlan.xml') as input:
- tree = etree.parse(input)
- data = tree.xpath('/ArrayOfRangeEntry/*')
- print("""# Tag name; color
- Untagged; #c0c0c0
- # Frequency; Name; Modulation; Bandwidth; Tags""")
- for record in data:
- print('{0}; {1}; {2}; {3}; {4}'.format(record.get('minFrequency'), '{0} ['.format(record.text), modulation_mapping[record.get('mode')]['mode'], modulation_mapping[record.get('mode')]['bandwidth'], 'Untagged'))
- print('{0}; {1}; {2}; {3}; {4}'.format(record.get('maxFrequency'), '{0} ]'.format(record.text), modulation_mapping[record.get('mode')]['mode'], modulation_mapping[record.get('mode')]['bandwidth'], 'Untagged'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement