Back to index

python-biopython  1.60
Public Member Functions | Public Attributes
Bio.Nexus.Nexus.Commandline Class Reference

List of all members.

Public Member Functions

def __init__

Public Attributes

 options
 command

Detailed Description

Represent a commandline as command and options.

Definition at line 472 of file Nexus.py.


Constructor & Destructor Documentation

def Bio.Nexus.Nexus.Commandline.__init__ (   self,
  line,
  title 
)

Definition at line 475 of file Nexus.py.

00475 
00476     def __init__(self, line, title):
00477         self.options={}
00478         options=[]
00479         self.command=None
00480         try:
00481             #Assume matrix (all other command lines have been stripped of \n)
00482             self.command, options = line.strip().split('\n', 1)
00483         except ValueError: #Not matrix
00484             #self.command,options=line.split(' ',1)  #no: could be tab or spaces (translate...)
00485             self.command=line.split()[0]
00486             options=' '.join(line.split()[1:])
00487         self.command = self.command.strip().lower()
00488         if self.command in SPECIAL_COMMANDS:   # special command that need newlines and order of options preserved
00489             self.options=options.strip()
00490         else:    
00491             if len(options) > 0:
00492                 try: 
00493                     options = options.replace('=', ' = ').split()
00494                     valued_indices=[(n-1,n,n+1) for n in range(len(options)) if options[n]=='=' and n!=0 and n!=len((options))]
00495                     indices = []
00496                     for sl in valued_indices:
00497                         indices.extend(sl)
00498                     token_indices = [n for n in range(len(options)) if n not in indices]
00499                     for opt in valued_indices:
00500                         #self.options[options[opt[0]].lower()] = options[opt[2]].lower()
00501                         self.options[options[opt[0]].lower()] = options[opt[2]]
00502                     for token in token_indices:
00503                         self.options[options[token].lower()] = None
00504                 except ValueError:
00505                     raise NexusError('Incorrect formatting in line: %s' % line)
                

Here is the caller graph for this function:


Member Data Documentation

Definition at line 478 of file Nexus.py.

Definition at line 476 of file Nexus.py.


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