file_source API documentation

# Module file_source

Show source.

    from sofine.plugins import plugin_base as plugin_base
    from optparse import OptionParser
    import json

    def get_keys(path):
        """
    * `path` - `string`. The path to the file_source configuration file

    Retrieves a set of keys found in the file named in the `path` arg.
    Keys must be written in a valid JSON object, which has a single key
    `keys` and a JSON array of valid JSON values for keys.

        // Example
        {"keys" : ["AAPL", "MSFT"]}

    Provided as a helper to the plugin class and also as a convenience for clients
    to retrieve the keys found in a given file at `path.` A common use case might be to
    store a list of keys at `path` and start a chained sofine call with the call to
    `file_source` to retrieve a static set of keys to then pass to other plugins that
    don't add keys themselves but just retrieve attributes for the keys passed to them.
    """
        file_source_json = None
        with open(path) as f:
            file_source_json = json.load(f)
        return file_source_json['keys']

    class FileSource(plugin_base.PluginBase):

        def __init__(self):
            """
    * `self.name = 'file_source'`
    * `self.group = 'standard'`
    * `self.schema = []`

    This is a dynamic plugin for which adds_keys() is True but it only
    provides keys to the data set, not attributes for those keys. So
    it's schema property is [].

    * `self.adds_keys = True`

    This plugin adds keys from it's file.
    """
            super(FileSource, self).__init__()
            self.name = 'file_source'
            self.group = 'standard'
            self.schema = []
            self.adds_keys = True

        def get_data(self, keys, args):
            """
    * `keys` - `list`. The list of keys to process. Should be empty for this plugin which
    in any case will ignore the argument.
    * `args` - `'list`. The args for calling this plugin. There is one, the path to the
    file with the keys to be retrieved.

    Loads a set of keys found in the file named in the `path` arg, which
    is the first and only element in `args`.

        // Example:
        {"keys" : ["AAPL", "MSFT"]}
    """
            path = args[0]
            new_keys = get_keys(path)
            data = dict.fromkeys(new_keys, {})
            return data

        def parse_args(self, argv):
            """`[-p|--path]` - Path to the file listing the keys to load into this data source.
    """
            usage = """
    [-p|--path] - Path to the file listing the keys to load into this data source.
    """
            parser = OptionParser(usage=usage)

            parser.add_option("-p", "--path",
                            action="store", dest="path",
                            help="Path to the file listing the keys to load into this data source. Required.")

            (opts, args) = parser.parse_args(argv)

            is_valid = True
            if not opts.path:
                print "Invalid argument error."
                print """
    Your args:
      path {0}""".format(opts.path)
                print usage
                is_valid = False

            return is_valid, [opts.path]

    plugin = FileSource

## Functions

def get_keys(

path)

- `path` - `string`. The path to the file_source configuration file

Retrieves a set of keys found in the file named in the `path` arg. Keys must be written in a valid JSON object, which has a single key `keys` and a JSON array of valid JSON values for keys.

    // Example
    {"keys" : ["AAPL", "MSFT"]}

Provided as a helper to the plugin class and also as a convenience for clients to retrieve the keys found in a given file at `path.` A common use case might be to store a list of keys at `path` and start a chained sofine call with the call to `file_source` to retrieve a static set of keys to then pass to other plugins that don't add keys themselves but just retrieve attributes for the keys passed to them.

Show source.

    def get_keys(path):
        """
    * `path` - `string`. The path to the file_source configuration file

    Retrieves a set of keys found in the file named in the `path` arg.
    Keys must be written in a valid JSON object, which has a single key
    `keys` and a JSON array of valid JSON values for keys.

        // Example
        {"keys" : ["AAPL", "MSFT"]}

    Provided as a helper to the plugin class and also as a convenience for clients
    to retrieve the keys found in a given file at `path.` A common use case might be to
    store a list of keys at `path` and start a chained sofine call with the call to
    `file_source` to retrieve a static set of keys to then pass to other plugins that
    don't add keys themselves but just retrieve attributes for the keys passed to them.
    """
        file_source_json = None
        with open(path) as f:
            file_source_json = json.load(f)
        return file_source_json['keys']

## Classes

class FileSource

Show source.

    class FileSource(plugin_base.PluginBase):

        def __init__(self):
            """
    * `self.name = 'file_source'`
    * `self.group = 'standard'`
    * `self.schema = []`

    This is a dynamic plugin for which adds_keys() is True but it only
    provides keys to the data set, not attributes for those keys. So
    it's schema property is [].

    * `self.adds_keys = True`

    This plugin adds keys from it's file.
    """
            super(FileSource, self).__init__()
            self.name = 'file_source'
            self.group = 'standard'
            self.schema = []
            self.adds_keys = True

        def get_data(self, keys, args):
            """
    * `keys` - `list`. The list of keys to process. Should be empty for this plugin which
    in any case will ignore the argument.
    * `args` - `'list`. The args for calling this plugin. There is one, the path to the
    file with the keys to be retrieved.

    Loads a set of keys found in the file named in the `path` arg, which
    is the first and only element in `args`.

        // Example:
        {"keys" : ["AAPL", "MSFT"]}
    """
            path = args[0]
            new_keys = get_keys(path)
            data = dict.fromkeys(new_keys, {})
            return data

        def parse_args(self, argv):
            """`[-p|--path]` - Path to the file listing the keys to load into this data source.
    """
            usage = """
    [-p|--path] - Path to the file listing the keys to load into this data source.
    """
            parser = OptionParser(usage=usage)

            parser.add_option("-p", "--path",
                            action="store", dest="path",
                            help="Path to the file listing the keys to load into this data source. Required.")

            (opts, args) = parser.parse_args(argv)

            is_valid = True
            if not opts.path:
                print "Invalid argument error."
                print """
    Your args:
      path {0}""".format(opts.path)
                print usage
                is_valid = False

            return is_valid, [opts.path]

#### Instance variables

var adds_keys

var group

var name

var schema

#### Methods

def __init__(

self)

- `self.name = 'file_source'`
- `self.group = 'standard'`
- `self.schema = []`

This is a dynamic plugin for which adds_keys() is True but it only provides keys to the data set, not attributes for those keys. So it's schema property is [].

- `self.adds_keys = True`

This plugin adds keys from it's file.

Show source.

    def __init__(self):
        """
    elf.name = 'file_source'`
    elf.group = 'standard'`
    elf.schema = []`
     is a dynamic plugin for which adds_keys() is True but it only
    ides keys to the data set, not attributes for those keys. So
     schema property is [].
    elf.adds_keys = True`
     plugin adds keys from it's file.

        super(FileSource, self).__init__()
        self.name = 'file_source'
        self.group = 'standard'
        self.schema = []
        self.adds_keys = True

def get_data(

self, keys, args)

- `keys` - `list`. The list of keys to process. Should be empty for this plugin which in any case will ignore the argument.
- `args` - `'list`. The args for calling this plugin. There is one, the path to the file with the keys to be retrieved.

Loads a set of keys found in the file named in the `path` arg, which is the first and only element in `args`.

    // Example:
    {"keys" : ["AAPL", "MSFT"]}

Show source.

    def get_data(self, keys, args):
        """
    eys` - `list`. The list of keys to process. Should be empty for this plugin which
    ny case will ignore the argument.
    rgs` - `'list`. The args for calling this plugin. There is one, the path to the
     with the keys to be retrieved.
    s a set of keys found in the file named in the `path` arg, which
    he first and only element in `args`.
    // Example:
    {"keys" : ["AAPL", "MSFT"]}
        path = args[0]
        new_keys = get_keys(path)
        data = dict.fromkeys(new_keys, {})
        return data

def parse_args(

self, argv)

`[-p|--path]` - Path to the file listing the keys to load into this data source.

Show source.

    def parse_args(self, argv):
        """`[-p|--path]` - Path to the file listing the keys to load into this data source.
        usage = """
    --path] - Path to the file listing the keys to load into this data source.
        parser = OptionParser(usage=usage)
        parser.add_option("-p", "--path",
                        action="store", dest="path",
                        help="Path to the file listing the keys to load into this data source. Required.")
        (opts, args) = parser.parse_args(argv)

        is_valid = True
        if not opts.path:
            print "Invalid argument error."
            print """
     args:
    th {0}""".format(opts.path)
            print usage
            is_valid = False
        return is_valid, [opts.path]

class plugin

Show source.

    class FileSource(plugin_base.PluginBase):

        def __init__(self):
            """
    * `self.name = 'file_source'`
    * `self.group = 'standard'`
    * `self.schema = []`

    This is a dynamic plugin for which adds_keys() is True but it only
    provides keys to the data set, not attributes for those keys. So
    it's schema property is [].

    * `self.adds_keys = True`

    This plugin adds keys from it's file.
    """
            super(FileSource, self).__init__()
            self.name = 'file_source'
            self.group = 'standard'
            self.schema = []
            self.adds_keys = True

        def get_data(self, keys, args):
            """
    * `keys` - `list`. The list of keys to process. Should be empty for this plugin which
    in any case will ignore the argument.
    * `args` - `'list`. The args for calling this plugin. There is one, the path to the
    file with the keys to be retrieved.

    Loads a set of keys found in the file named in the `path` arg, which
    is the first and only element in `args`.

        // Example:
        {"keys" : ["AAPL", "MSFT"]}
    """
            path = args[0]
            new_keys = get_keys(path)
            data = dict.fromkeys(new_keys, {})
            return data

        def parse_args(self, argv):
            """`[-p|--path]` - Path to the file listing the keys to load into this data source.
    """
            usage = """
    [-p|--path] - Path to the file listing the keys to load into this data source.
    """
            parser = OptionParser(usage=usage)

            parser.add_option("-p", "--path",
                            action="store", dest="path",
                            help="Path to the file listing the keys to load into this data source. Required.")

            (opts, args) = parser.parse_args(argv)

            is_valid = True
            if not opts.path:
                print "Invalid argument error."
                print """
    Your args:
      path {0}""".format(opts.path)
                print usage
                is_valid = False

            return is_valid, [opts.path]

#### Instance variables

var adds_keys

Inheritance: `plugin`.`adds_keys`

var group

Inheritance: `plugin`.`group`

var name

Inheritance: `plugin`.`name`

var schema

Inheritance: `plugin`.`schema`

#### Methods

def __init__(

self)

Inheritance: `plugin`.`__init__`

- `self.name = 'file_source'`
- `self.group = 'standard'`
- `self.schema = []`

This is a dynamic plugin for which adds_keys() is True but it only provides keys to the data set, not attributes for those keys. So it's schema property is [].

- `self.adds_keys = True`

This plugin adds keys from it's file.

Show source.

    def __init__(self):
        """
    elf.name = 'file_source'`
    elf.group = 'standard'`
    elf.schema = []`
     is a dynamic plugin for which adds_keys() is True but it only
    ides keys to the data set, not attributes for those keys. So
     schema property is [].
    elf.adds_keys = True`
     plugin adds keys from it's file.

        super(FileSource, self).__init__()
        self.name = 'file_source'
        self.group = 'standard'
        self.schema = []
        self.adds_keys = True

def get_data(

self, keys, args)

Inheritance: `plugin`.`get_data`

- `keys` - `list`. The list of keys to process. Should be empty for this plugin which in any case will ignore the argument.
- `args` - `'list`. The args for calling this plugin. There is one, the path to the file with the keys to be retrieved.

Loads a set of keys found in the file named in the `path` arg, which is the first and only element in `args`.

    // Example:
    {"keys" : ["AAPL", "MSFT"]}

Show source.

    def get_data(self, keys, args):
        """
    eys` - `list`. The list of keys to process. Should be empty for this plugin which
    ny case will ignore the argument.
    rgs` - `'list`. The args for calling this plugin. There is one, the path to the
     with the keys to be retrieved.
    s a set of keys found in the file named in the `path` arg, which
    he first and only element in `args`.
    // Example:
    {"keys" : ["AAPL", "MSFT"]}
        path = args[0]
        new_keys = get_keys(path)
        data = dict.fromkeys(new_keys, {})
        return data

def parse_args(

self, argv)

Inheritance: `plugin`.`parse_args`

`[-p|--path]` - Path to the file listing the keys to load into this data source.

Show source.

    def parse_args(self, argv):
        """`[-p|--path]` - Path to the file listing the keys to load into this data source.
        usage = """
    --path] - Path to the file listing the keys to load into this data source.
        parser = OptionParser(usage=usage)
        parser.add_option("-p", "--path",
                        action="store", dest="path",
                        help="Path to the file listing the keys to load into this data source. Required.")
        (opts, args) = parser.parse_args(argv)

        is_valid = True
        if not opts.path:
            print "Invalid argument error."
            print """
     args:
    th {0}""".format(opts.path)
            print usage
            is_valid = False
        return is_valid, [opts.path]

Documentation generated by `pdoc` 0.2.4. pdoc is in the public domain with the UNLICENSE.