Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
Helper Class Reference

Public Member Functions

def __init__
 
def __repr__
 
def __call__
 
def interact
 
def help
 
def intro
 
def list
 
def listkeywords
 
def listtopics
 
def showtopic
 
def listmodules
 

Data Fields

 input
 
 output
 
 docdir
 

Static Public Attributes

dictionary keywords
 
dictionary topics
 

Detailed Description

Definition at line 1375 of file pydoc.py.

Constructor & Destructor Documentation

def __init__ (   self,
  input,
  output 
)

Definition at line 1486 of file pydoc.py.

1487  def __init__(self, input, output):
1488  self.input = input
1489  self.output = output
1490  self.docdir = None
1491  execdir = os.path.dirname(sys.executable)
1492  homedir = os.environ.get('PYTHONHOME')
1493  for dir in [os.environ.get('PYTHONDOCS'),
1494  homedir and os.path.join(homedir, 'doc'),
1495  os.path.join(execdir, 'doc'),
1496  '/usr/doc/python-docs-' + split(sys.version)[0],
1497  '/usr/doc/python-' + split(sys.version)[0],
1498  '/usr/doc/python-docs-' + sys.version[:3],
1499  '/usr/doc/python-' + sys.version[:3]]:
1500  if dir and os.path.isdir(os.path.join(dir, 'lib')):
1501  self.docdir = dir

Member Function Documentation

def __call__ (   self,
  request = None 
)

Definition at line 1508 of file pydoc.py.

References NNTP.help(), Helper.help(), InteractiveConsole.interact(), Helper.interact(), Cmd.intro, and Helper.intro().

1509  def __call__(self, request=None):
1510  if request is not None:
1511  self.help(request)
1512  else:
1513  self.intro()
1514  self.interact()
1515  self.output.write('''
1516 You are now leaving help and returning to the Python interpreter.
1517 If you want to ask for help on a particular object directly from the
1518 interpreter, you can type "help(object)". Executing "help('string')"
1519 has the same effect as typing a particular string at the help> prompt.
1520 ''')
def __repr__ (   self)

Definition at line 1502 of file pydoc.py.

References inspect.stack().

1503  def __repr__(self):
1504  if inspect.stack()[1][3] == '?':
1505  self()
1506  return ''
1507  return '<pydoc.Helper instance>'
def help (   self,
  request 
)

Definition at line 1534 of file pydoc.py.

References pydoc.doc(), Cmd.intro, Helper.intro(), Helper.listkeywords(), Helper.listmodules(), Helper.listtopics(), Helper.showtopic(), and dospath.split().

1535  def help(self, request):
1536  if type(request) is type(''):
1537  if request == 'help': self.intro()
1538  elif request == 'keywords': self.listkeywords()
1539  elif request == 'topics': self.listtopics()
1540  elif request == 'modules': self.listmodules()
1541  elif request[:8] == 'modules ':
1542  self.listmodules(split(request)[1])
1543  elif self.keywords.has_key(request): self.showtopic(request)
1544  elif self.topics.has_key(request): self.showtopic(request)
1545  elif request: doc(request, 'Help on %s:')
1546  elif isinstance(request, Helper): self()
1547  else: doc(request, 'Help on %s:')
1548  self.output.write('\n')
def interact (   self)

Definition at line 1521 of file pydoc.py.

References NNTP.help(), Helper.help(), string.lower(), pydoc.replace(), and string.strip().

1522  def interact(self):
1523  self.output.write('\n')
1524  while 1:
1525  self.output.write('help> ')
1526  self.output.flush()
1527  try:
1528  request = self.input.readline()
1529  if not request: break
1530  except KeyboardInterrupt: break
1531  request = strip(replace(request, '"', '', "'", ''))
1532  if lower(request) in ['q', 'quit']: break
1533  self.help(request)
def intro (   self)

Definition at line 1549 of file pydoc.py.

1550  def intro(self):
1551  self.output.write('''
1552 Welcome to Python %s! This is the online help utility.
1553 
1554 If this is your first time using Python, you should definitely check out
1555 the tutorial on the Internet at http://www.python.org/doc/tut/.
1556 
1557 Enter the name of any module, keyword, or topic to get help on writing
1558 Python programs and using Python modules. To quit this help utility and
1559 return to the interpreter, just type "quit".
1560 
1561 To get a list of available modules, keywords, or topics, type "modules",
1562 "keywords", or "topics". Each module also comes with a one-line summary
1563 of what it does; to list the modules whose summaries contain a given word
1564 such as "spam", type "modules spam".
1565 ''' % sys.version[:3])
def list (   self,
  items,
  columns = 4,
  width = 80 
)

Definition at line 1566 of file pydoc.py.

1567  def list(self, items, columns=4, width=80):
1568  items = items[:]
1569  items.sort()
1570  colw = width / columns
1571  rows = (len(items) + columns - 1) / columns
1572  for row in range(rows):
1573  for col in range(columns):
1574  i = col * rows + row
1575  if i < len(items):
1576  self.output.write(items[i])
1577  if col < columns - 1:
1578  self.output.write(' ' + ' ' * (colw-1 - len(items[i])))
1579  self.output.write('\n')
def listkeywords (   self)

Definition at line 1580 of file pydoc.py.

References POP3.list(), fifo.list, NNTP.list(), MiniFieldStorage.list, FieldStorage.list, and Helper.list().

1581  def listkeywords(self):
1582  self.output.write('''
1583 Here is a list of the Python keywords. Enter any keyword to get more help.
1584 
1585 ''')
1586  self.list(self.keywords.keys())
def listmodules (   self,
  key = '' 
)

Definition at line 1639 of file pydoc.py.

References pydoc.apropos(), pydoc.callback, gettext.find(), POP3.list(), fifo.list, NNTP.list(), MiniFieldStorage.list, FieldStorage.list, Helper.list(), and imaplib.run().

1640  def listmodules(self, key=''):
1641  if key:
1642  self.output.write('''
1643 Here is a list of matching modules. Enter any module name to get more help.
1644 
1645 ''')
1646  apropos(key)
1647  else:
1648  self.output.write('''
1649 Please wait a moment while I gather a list of all available modules...
1650 
1651 ''')
1652  modules = {}
1653  def callback(path, modname, desc, modules=modules):
1654  if modname and modname[-9:] == '.__init__':
1655  modname = modname[:-9] + ' (package)'
1656  if find(modname, '.') < 0:
1657  modules[modname] = 1
1658  ModuleScanner().run(callback)
1659  self.list(modules.keys())
1660  self.output.write('''
1661 Enter any module name to get more help. Or, type "modules spam" to search
1662 for modules whose descriptions contain the word "spam".
1663 ''')
def listtopics (   self)

Definition at line 1587 of file pydoc.py.

References POP3.list(), fifo.list, NNTP.list(), MiniFieldStorage.list, FieldStorage.list, and Helper.list().

1588  def listtopics(self):
1589  self.output.write('''
1590 Here is a list of available topics. Enter any topic name to get more help.
1591 
1592 ''')
1593  self.list(self.topics.keys())
def showtopic (   self,
  topic 
)

Definition at line 1594 of file pydoc.py.

References Helper.docdir, dospath.join(), aifc.open(), pydoc.pager(), pydoc.replace(), Helper.showtopic(), dospath.split(), and string.strip().

1595  def showtopic(self, topic):
1596  if not self.docdir:
1597  self.output.write('''
1598 Sorry, topic and keyword documentation is not available because the Python
1599 HTML documentation files could not be found. If you have installed them,
1600 please set the environment variable PYTHONDOCS to indicate their location.
1601 ''')
1602  return
1603  target = self.topics.get(topic, self.keywords.get(topic))
1604  if not target:
1605  self.output.write('no documentation found for %s\n' % repr(topic))
1606  return
1607  if type(target) is type(''):
1608  return self.showtopic(target)
1609 
1610  filename, xrefs = target
1611  filename = self.docdir + '/' + filename + '.html'
1612  try:
1613  file = open(filename)
1614  except:
1615  self.output.write('could not read docs from %s\n' % filename)
1616  return
1617 
1618  divpat = re.compile('<div[^>]*navigat.*?</div.*?>', re.I | re.S)
1619  addrpat = re.compile('<address.*?>.*?</address.*?>', re.I | re.S)
1620  document = re.sub(addrpat, '', re.sub(divpat, '', file.read()))
1621  file.close()
1622 
1623  import htmllib, formatter, StringIO
1624  buffer = StringIO.StringIO()
1625  parser = htmllib.HTMLParser(
1627  parser.start_table = parser.do_p
1628  parser.end_table = lambda parser=parser: parser.do_p({})
1629  parser.start_tr = parser.do_br
1630  parser.start_td = parser.start_th = lambda a, b=buffer: b.write('\t')
1631  parser.feed(document)
1632  buffer = replace(buffer.getvalue(), '\xa0', ' ', '\n', '\n ')
1633  pager(' ' + strip(buffer) + '\n')
1634  if xrefs:
1635  buffer = StringIO.StringIO()
1636  formatter.DumbWriter(buffer).send_flowing_data(
1637  'Related help topics: ' + join(split(xrefs), ', ') + '\n')
1638  self.output.write('\n%s\n' % buffer.getvalue())

Field Documentation

docdir

Definition at line 1489 of file pydoc.py.

input

Definition at line 1487 of file pydoc.py.

dictionary keywords
static
Initial value:
1 = {
2  'and': 'BOOLEAN',
3  'assert': ('ref/assert', ''),
4  'break': ('ref/break', 'while for'),
5  'class': ('ref/class', 'CLASSES SPECIALMETHODS'),
6  'continue': ('ref/continue', 'while for'),
7  'def': ('ref/function', ''),
8  'del': ('ref/del', 'BASICMETHODS'),
9  'elif': 'if',
10  'else': ('ref/if', 'while for'),
11  'except': 'try',
12  'exec': ('ref/exec', ''),
13  'finally': 'try',
14  'for': ('ref/for', 'break continue while'),
15  'from': 'import',
16  'global': ('ref/global', 'NAMESPACES'),
17  'if': ('ref/if', 'TRUTHVALUE'),
18  'import': ('ref/import', 'MODULES'),
19  'in': ('ref/comparisons', 'SEQUENCEMETHODS2'),
20  'is': 'COMPARISON',
21  'lambda': ('ref/lambda', 'FUNCTIONS'),
22  'not': 'BOOLEAN',
23  'or': 'BOOLEAN',
24  'pass': 'PASS',
25  'print': ('ref/print', ''),
26  'raise': ('ref/raise', 'EXCEPTIONS'),
27  'return': ('ref/return', 'FUNCTIONS'),
28  'try': ('ref/try', 'EXCEPTIONS'),
29  'while': ('ref/while', 'break continue if TRUTHVALUE'),
30  }

Definition at line 1376 of file pydoc.py.

output

Definition at line 1488 of file pydoc.py.

dictionary topics
static

Definition at line 1407 of file pydoc.py.


The documentation for this class was generated from the following file: