File: define.py

package info (click to toggle)
pyxb 1.2.3%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 63,792 kB
  • ctags: 48,994
  • sloc: python: 235,928; sh: 803; xml: 657; makefile: 57
file content (20 lines) | stat: -rw-r--r-- 658 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from __future__ import print_function
import dict
import urllib2
import pyxb.utils.domutils as domutils
import sys

word = 'xml'
if 1 < len(sys.argv):
    word = sys.argv[1]

# Create a REST-style query to retrieve the information about this dictionary.
uri = 'http://services.aonaware.com/DictService/DictService.asmx/Define?word=%s' % (word,)
rxml = urllib2.urlopen(uri).read()
resp = dict.CreateFromDOM(domutils.StringToDOM(rxml))

print('Definitions of %s:' % (resp.Word,))
for definition in resp.Definitions.Definition:
    print('From %s (%s):' % (definition.Dictionary.Name, definition.Dictionary.Id))
    print(definition.WordDefinition)
    print()