ServerPortfolio  2.0
Python parsers and server
 All Classes Namespaces Files Functions Variables Properties Pages
Public Member Functions | Public Attributes | Static Private Attributes | List of all members
serverportfolio.Parsers.Abstract.AbstractParser Class Reference

Define 2 abstract methods which need to be overridden by the Parsers
and a generic algorithm (run_parser) for parsing the data. More...

Inheritance diagram for serverportfolio.Parsers.Abstract.AbstractParser:
Inheritance graph
[legend]
Collaboration diagram for serverportfolio.Parsers.Abstract.AbstractParser:
Collaboration graph
[legend]

Public Member Functions

def __init__
 Constructor. More...
 
def create_url
 Store links to stocks to update, dictionary 'symbol' : Stock object. More...
 
def parse
 Parse the text file (html, CSV,...) More...
 
def run_parser
 Main function to call for running the parser. More...
 
def clean
 Reset internal data members after a parsing. More...
 
def store_stock_copy
 Make a local copy of the Stock objects (linked of the original in DictionaryStocks in fact) into a local dictionary. More...
 
def update_stock
 Update the local stocks with the new retrieved data. More...
 
def get_symbol_from_code
 Retrieve the symbol (or Stock) from the code_yahoo or code_bourso. More...
 

Public Attributes

 url
 save url, useful for reporting errors and exceptions More...
 
 e_action
 enumeration (EAction) of the type of query to perform More...
 
 option_post
 
 local_stock
 
 list_return_data
 

Static Private Attributes

 __metaclass__ = ABCMeta
 

Detailed Description

Define 2 abstract methods which need to be overridden by the Parsers
and a generic algorithm (run_parser) for parsing the data.

Definition at line 29 of file Abstract.py.

Constructor & Destructor Documentation

def serverportfolio.Parsers.Abstract.AbstractParser.__init__ (   self,
  e_action 
)

Constructor.

Parameters
e_actionGlobalDicts.EAction

Definition at line 34 of file Abstract.py.

Member Function Documentation

def serverportfolio.Parsers.Abstract.AbstractParser.clean (   self)

Reset internal data members after a parsing.

Because parsers can be re-used, it deletes previous data
Most (if not all) of the data member belongs to the abtract base class, the default may be sufficient for most of the specific parsers

Definition at line 152 of file Abstract.py.

References serverportfolio.Parsers.Abstract.AbstractParser.url.

def serverportfolio.Parsers.Abstract.AbstractParser.create_url (   self)

Store links to stocks to update, dictionary 'symbol' : Stock object.

Contain all parsed data by one query, include multiple stocks query List of template_parser Source of the data is the parser name : YQL/YCSV/BOURSO, set in ParserFactory Abstract method to create the URL

Definition at line 55 of file Abstract.py.

def serverportfolio.Parsers.Abstract.AbstractParser.get_symbol_from_code (   self,
  code,
  code_type 
)

Retrieve the symbol (or Stock) from the code_yahoo or code_bourso.

Needed for parsing multiple CSV data, if order is not fixed.

Parameters
coderead from the CSV line
code_type'code_yahoo' or 'code_bourso'

Definition at line 211 of file Abstract.py.

References serverportfolio.Parsers.Abstract.AbstractParser.url.

Referenced by serverportfolio.Parsers.YahooYQL.YahooYQL.parse_fund(), and serverportfolio.Parsers.YahooCSV.YahooCSV.parse_fund().

Here is the caller graph for this function:

def serverportfolio.Parsers.Abstract.AbstractParser.parse (   self,
  s 
)

Parse the text file (html, CSV,...)

Definition at line 60 of file Abstract.py.

def serverportfolio.Parsers.Abstract.AbstractParser.run_parser (   self,
  stock,
  option_post = None 
)

Main function to call for running the parser.

Regroup the different steps in one call:

Parameters
stocka stock symbol or a list of st.symb. "CAC40" or ["CAC40","GSZ"]
Returns
dict_data : dictionary with extracted data throw PortfolioError

Definition at line 82 of file Abstract.py.

def serverportfolio.Parsers.Abstract.AbstractParser.store_stock_copy (   self,
  list_stock 
)

Make a local copy of the Stock objects (linked of the original in DictionaryStocks in fact) into a local dictionary.

Precondition
Stock must be valid (not InvalidStock) changed accept InvalidStock but does not add to the local dictionary
Parameters
listof stock symbols

Definition at line 163 of file Abstract.py.

References serverportfolio.Parsers.Abstract.AbstractParser.e_action, and serverportfolio.Parsers.Abstract.AbstractParser.local_stock.

def serverportfolio.Parsers.Abstract.AbstractParser.update_stock (   self)

Member Data Documentation

serverportfolio.Parsers.Abstract.AbstractParser.__metaclass__ = ABCMeta
staticprivate

Definition at line 30 of file Abstract.py.

serverportfolio.Parsers.Abstract.AbstractParser.e_action
serverportfolio.Parsers.Abstract.AbstractParser.list_return_data
serverportfolio.Parsers.Abstract.AbstractParser.local_stock
serverportfolio.Parsers.Abstract.AbstractParser.option_post
serverportfolio.Parsers.Abstract.AbstractParser.url

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