Beispiel #1
0
def fetchResourceData(dataset_id):
    '''
  Fetch resource information from datasets.

  '''
    #
    # Creates a dataset instance
    # and collects an array with the
    # resource ids.
    #
    d = Dataset(dataset_id)
    d.info()
    resources = d.resources()
    resource_data = []
    for resource in resources:
        data = {
            k: Resource(resource).info()[k]
            for k in _fields(config, 'resources')
        }
        resource_data.append(data)

    #
    # Selects only the fields
    # of interest from the dictionary.
    #
    return resource_data
  def test_dataset_keys(self):
    '''
    classes.dataset:  Test that the Dataset classe returns the right keys.

    '''
    result = Dataset('ebola-cases-2014').info()

    for key in self.keys:
      self.assertIn(key, result.keys())
    def test_dataset_keys(self):
        '''
    classes.dataset:  Test that the Dataset classe returns the right keys.

    '''
        result = Dataset('ebola-cases-2014').info()

        for key in self.keys:
            self.assertIn(key, result.keys())
def fetchResourceData(dataset_id):
  '''
  Fetch resource information from datasets.

  '''
  #
  # Creates a dataset instance
  # and collects an array with the
  # resource ids.
  #
  d = Dataset(dataset_id)
  d.info()
  resources = d.resources()
  resource_data = []
  for resource in resources:
    data = { k: Resource(resource).info()[k] for k in _fields(config, 'resources') }
    resource_data.append(data)

  #
  # Selects only the fields
  # of interest from the dictionary.
  #
  return resource_data
Beispiel #5
0
def fetchClassData(key=None, id=None):
    '''
  Loads data from specified CKAN object class.

  '''
    classes = {
        'users': User(id),
        'countries': Country(id),
        'datasets': Dataset(id),
        'revisions': Revision(id),
        'resources': Resource(id),
        'gallery_items': GalleryItem(id),
        'organizations': Organization(id)
    }

    #
    # Selects only the fields
    # of interest from the dictionary.
    #
    result = {k: classes[key].info()[k] for k in _fields(config, key)}
    return result