#!/usr/bin/env python

"""
  filemanager.py: provides methods for accessing project directories
"""

import os

# --------------------------FILE-MANAGER-UTILITY--------------------------#
class FileManager:
    fms = None
    root = None
    """
      first static call of this class must include project root path
      as the first argument. Therafter, static calls will return the
      instance containing the path.
    """

    @staticmethod
    def instance():
        if not FileManager.fms:
            FileManager.fms = FileManager()
        return FileManager.fms

    def __init__(self):
        pass

    def set_root(self, arg):
        self.fms.root = arg

    def root_dir(self):
        return self.root

    def inc_dir(self):
        """ calling this method will create ./var/inc directory structure """
        par = os.path.join(self.root, "var", "inc")
        if not os.path.exists(par):
            os.makedirs(par)
        return par

    def db_dir(self):
        """ calling this method will create ./var/db directory structure """
        par = os.path.join(self.root, "var", "db")
        if not os.path.exists(par):
            os.makedirs(par)
        return par

    def dir_for_symbol(self, symbol):
        """ calling this method will create ./etc/sym/x/xxx directory structure """
        dir = symbol.lower()
        ltr = dir[0]
        par = os.path.join(self.root, "etc", "sym", ltr, dir)
        if not os.path.exists(par):
            os.makedirs(par)
        return par

    def csv_dir(self):
        """ calling this method will create ./etc/csv directory structure """
        par = os.path.join(self.root, "etc", "csv")
        if not os.path.exists(par):
            os.makedirs(par)
        return par

# ---------------------------------EXPORT---------------------------------#
__all__ = ['FileManager']


# ----------------------------------MAIN----------------------------------#
def main():
    pass


if __name__ == '__main__':
    main()

@@ -103,16 +103,31 @@
 mport os
+%0Aimport urllib2
 %0A%0A# ----
@@ -1759,16 +1759,554 @@
 rn par%0A%0A
+    def get_csv(self,module):%0A        if not os._exists(os.path.join(self.csv_dir(),%22%7B%7D.csv%22.format(module))):%0A            url = urllib2.urlopen('http://www.pyfiapp.com/src/csv/%7B%7D.csv'.format(module))%0A            if url.getcode() == 200:%0A                src = url.read()%0A                dst = open(os.path.join(self.csv_dir(),%22%7B%7D.csv%22.format(module)),%22w+%22)%0A                dst.write(src)%0A                return 0%0A            else:%0A                raise ValueError('The required support file %7B%7D in etc/csv was not found'.format(module))%0A%0A%0A
 # ------

Add method to install data for modules linking to framework