'''
Convert finance statistics: From JSON to CSV.

Update log: (date / version / author : comments)
2018-02-19 / 1.0.0 / Du Jiang : Creation
                                Support Yahoo Finance stock
'''

from collections import OrderedDict
import csv
import getopt
import json
import sys
from time import localtime, strftime, time

# Global variables.
# The value can be updated by command line options.
__data_type = None
__json_file_path = None
__csv_file_path = None

__Constants = None


class Constants_Base(object):
    '''
    Use a class to keep constant variables.
    '''
    RESULT = "Result"
    RESULT_ERROR = "Error"

    INVENTORIES = "Inventories"
    RECORD = "Record"
    INVENTORY_DATA = "Inventory data"

    URL = "URL"


class Constants_YahooStock(Constants_Base):
    STOCK_INFO = "Stock info"
    STOCK_INFO_NAME = "Name"
    STOCK_INFO_EXCHANGE = "Exchange"
    STOCK_INFO_TICKER = "Ticker"

    MARKET_INFO = "Market info"

    MARKET_INFO_FILTER = ["200-Day Moving Average",
                          "5 Year Average Dividend Yield",