當前位置: 首頁>>代碼示例>>Python>>正文


Python Datasets.last_update方法代碼示例

本文整理匯總了Python中dlstats.fetchers._commons.Datasets.last_update方法的典型用法代碼示例。如果您正苦於以下問題:Python Datasets.last_update方法的具體用法?Python Datasets.last_update怎麽用?Python Datasets.last_update使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在dlstats.fetchers._commons.Datasets的用法示例。


在下文中一共展示了Datasets.last_update方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_constructor

# 需要導入模塊: from dlstats.fetchers._commons import Datasets [as 別名]
# 或者: from dlstats.fetchers._commons.Datasets import last_update [as 別名]
    def test_constructor(self):

        # nosetests -s -v dlstats.tests.fetchers.test__commons:DatasetTestCase.test_constructor
        
        with self.assertRaises(ValueError):
            Datasets(is_load_previous_version=False)
            
        f = Fetcher(provider_name="p1", is_indexes=False)
                
        d = Datasets(provider_name="p1", 
                    dataset_code="d1",
                    name="d1 Name",
                    doc_href="http://www.example.com",
                    fetcher=f, 
                    is_load_previous_version=False)
        d.dimension_list.update_entry("country", "country", "country")

        self.assertTrue(isinstance(d.series, Series))
        self.assertTrue(isinstance(d.dimension_list, CodeDict))
        self.assertTrue(isinstance(d.attribute_list, CodeDict))
        
        bson = d.bson
        self.assertEqual(bson['provider_name'], "p1")
        self.assertEqual(bson["dataset_code"], "d1")
        self.assertEqual(bson["name"], "d1 Name")
        self.assertEqual(bson["doc_href"], "http://www.example.com")
        self.assertTrue(isinstance(bson["dimension_list"], dict))
        self.assertTrue(isinstance(bson["attribute_list"], dict))
        self.assertIsNone(bson["last_update"])
        self.assertEqual(bson["slug"], "p1-d1")

        #TODO: last_update        
        d.last_update = datetime.now()
開發者ID:MichelJuillard,項目名稱:dlstats,代碼行數:35,代碼來源:test__commons.py

示例2: upsert_dataset

# 需要導入模塊: from dlstats.fetchers._commons import Datasets [as 別名]
# 或者: from dlstats.fetchers._commons.Datasets import last_update [as 別名]
    def upsert_dataset(self, dataset_code):
        
        settings = self._get_datasets_settings()[dataset_code]
        
        dataset = Datasets(provider_name=self.provider_name, 
                           dataset_code=dataset_code, 
                           name=settings["name"], 
                           doc_href='http://www.bea.gov', 
                           fetcher=self)
        
        url = settings["metadata"]["url"]
        filename = settings["metadata"]["filename"]
        sheet_name = settings["metadata"]["sheet_name"]

        sheet = self._get_sheet(url, filename, sheet_name)
        fetcher_data = BeaData(dataset, url=url, sheet=sheet)
        
        if dataset.last_update and fetcher_data.release_date >= dataset.last_update and not self.force_update: 
            comments = "update-date[%s]" % fetcher_data.release_date
            raise errors.RejectUpdatedDataset(provider_name=self.provider_name,
                                              dataset_code=dataset_code,
                                              comments=comments)
        
        
        dataset.last_update = fetcher_data.release_date
        dataset.series.data_iterator = fetcher_data
        
        return dataset.update_database()
開發者ID:Menandalbee,項目名稱:dlstats,代碼行數:30,代碼來源:bea.py

示例3: upsert_dataset

# 需要導入模塊: from dlstats.fetchers._commons import Datasets [as 別名]
# 或者: from dlstats.fetchers._commons.Datasets import last_update [as 別名]
    def upsert_dataset(self, dataset_code):
        """Updates data in Database for selected datasets
        """
        self.get_selected_datasets()

        doc = self.db[constants.COL_DATASETS].find_one(
            {"provider_name": self.provider_name, "dataset_code": dataset_code}, {"dataset_code": 1, "last_update": 1}
        )

        dataset_settings = self.selected_datasets[dataset_code]

        if doc and doc["last_update"] >= dataset_settings["last_update"]:
            comments = "update-date[%s]" % doc["last_update"]
            raise errors.RejectUpdatedDataset(
                provider_name=self.provider_name, dataset_code=dataset_code, comments=comments
            )

        dataset = Datasets(
            provider_name=self.provider_name,
            dataset_code=dataset_code,
            name=dataset_settings["name"],
            doc_href=dataset_settings["metadata"].get("doc_href"),
            last_update=None,
            fetcher=self,
        )
        dataset.last_update = dataset_settings["last_update"]

        dataset.series.data_iterator = EurostatData(dataset)

        return dataset.update_database()
開發者ID:srault95,項目名稱:dlstats,代碼行數:32,代碼來源:eurostat.py

示例4: upsert_sna

# 需要導入模塊: from dlstats.fetchers._commons import Datasets [as 別名]
# 或者: from dlstats.fetchers._commons.Datasets import last_update [as 別名]
 def upsert_sna(self, url, dataset_code):
     dataset = Datasets(self.provider_name,dataset_code,
                        fetcher=self)
     sna_data = EsriData(dataset,url)
     dataset.name = self.dataset_name[dataset_code]
     dataset.doc_href = 'http://www.esri.cao.go.jp/index-e.html'
     dataset.last_update = sna_data.release_date
     dataset.series.data_iterator = sna_data
     dataset.update_database()
開發者ID:Salimeh,項目名稱:dlstats,代碼行數:11,代碼來源:esri.py

示例5: upsert_gem

# 需要導入模塊: from dlstats.fetchers._commons import Datasets [as 別名]
# 或者: from dlstats.fetchers._commons.Datasets import last_update [as 別名]
 def upsert_gem(self, dataset_code):
     d = DATASETS[dataset_code]
     url = d['url']
     dataset = Datasets(provider_name=self.provider_name, 
                        dataset_code=dataset_code, 
                        name=d['name'], 
                        doc_href=d['doc_href'], 
                        fetcher=self)
     gem_data = GemData(dataset, url)
     dataset.last_update = gem_data.release_date
     dataset.series.data_iterator = gem_data
     dataset.update_database()
開發者ID:MichelJuillard,項目名稱:dlstats,代碼行數:14,代碼來源:world_bank.py

示例6: upsert_dataset

# 需要導入模塊: from dlstats.fetchers._commons import Datasets [as 別名]
# 或者: from dlstats.fetchers._commons.Datasets import last_update [as 別名]
 def upsert_dataset(self, dataset_code, sheet):    
     start = time.time()
     logger.info("upsert dataset[%s] - START" % (dataset_code))
     
     dataset = Datasets(self.provider_name,dataset_code,
                        fetcher=self)
     bea_data = BeaData(dataset,self.url, sheet)
     dataset.name = dataset_code
     dataset.doc_href = 'http://www.bea.gov/newsreleases/national/gdp/gdpnewsrelease.htm'
     dataset.last_update = bea_data.release_date
     dataset.series.data_iterator = bea_data
     dataset.update_database()
     self.update_metas(dataset_code)
     end = time.time() - start
     logger.info("upsert dataset[%s] - END - time[%.3f seconds]" % (dataset_code, end))
開發者ID:MichelJuillard,項目名稱:dlstats,代碼行數:17,代碼來源:bea.py

示例7: upsert_dataset

# 需要導入模塊: from dlstats.fetchers._commons import Datasets [as 別名]
# 或者: from dlstats.fetchers._commons.Datasets import last_update [as 別名]
 def upsert_dataset(self, dataset_code):
     
     if not DATASETS.get(dataset_code):
         raise Exception("This dataset is unknown" + dataset_code)
             
     dataset = Datasets(provider_name=self.provider_name, 
                        dataset_code=dataset_code, 
                        name=DATASETS[dataset_code]['name'], 
                        doc_href=DATASETS[dataset_code]['doc_href'],
                        fetcher=self)
     dataset.last_update = clean_datetime()
     
     dataset.series.data_iterator = OECD_Data(dataset, 
                                              sdmx_filter=DATASETS[dataset_code]['sdmx_filter'])
     
     return dataset.update_database()
開發者ID:Menandalbee,項目名稱:dlstats,代碼行數:18,代碼來源:oecd.py

示例8: upsert_dataset

# 需要導入模塊: from dlstats.fetchers._commons import Datasets [as 別名]
# 或者: from dlstats.fetchers._commons.Datasets import last_update [as 別名]
    def upsert_dataset(self, dataset_code):

        self._load_structure_dataflows()
        self._load_structure_concepts()

        dataset = Datasets(provider_name=self.provider_name,
                           dataset_code=dataset_code,
                           name=None,
                           doc_href=None,
                           fetcher=self)
        dataset.last_update = clean_datetime()

        insee_data = INSEE_Data(dataset)
        dataset.series.data_iterator = insee_data

        return dataset.update_database()
開發者ID:Widukind,項目名稱:dlstats,代碼行數:18,代碼來源:insee.py

示例9: upsert_dataset

# 需要導入模塊: from dlstats.fetchers._commons import Datasets [as 別名]
# 或者: from dlstats.fetchers._commons.Datasets import last_update [as 別名]
    def upsert_dataset(self, dataset_code):

        self._load_structure()

        dataset = Datasets(
            provider_name=self.provider_name,
            dataset_code=dataset_code,
            name=None,
            doc_href=self.provider.website,
            fetcher=self,
        )
        dataset.last_update = utils.clean_datetime()

        _data = ECB_Data(dataset=dataset)
        dataset.series.data_iterator = _data
        return dataset.update_database()
開發者ID:srault95,項目名稱:dlstats,代碼行數:18,代碼來源:ecb.py

示例10: upsert_dataset

# 需要導入模塊: from dlstats.fetchers._commons import Datasets [as 別名]
# 或者: from dlstats.fetchers._commons.Datasets import last_update [as 別名]
    def upsert_dataset(self, dataset_code):

        self.get_selected_datasets()

        dataset_settings = self.selected_datasets[dataset_code]

        dataset = Datasets(
            provider_name=self.provider_name, dataset_code=dataset_code, name=dataset_settings["name"], fetcher=self
        )

        if dataset_code in DATASETS:
            dataset.series.data_iterator = ExcelData(dataset, DATASETS[dataset_code]["url"])
            dataset.doc_href = DATASETS[dataset_code]["doc_href"]
        else:
            dataset.last_update = clean_datetime()
            dataset.series.data_iterator = WorldBankAPIData(dataset, dataset_settings)

        return dataset.update_database()
開發者ID:srault95,項目名稱:dlstats,代碼行數:20,代碼來源:world_bank.py

示例11: upsert_weo_issue

# 需要導入模塊: from dlstats.fetchers._commons import Datasets [as 別名]
# 或者: from dlstats.fetchers._commons.Datasets import last_update [as 別名]
 def upsert_weo_issue(self, url, dataset_code):
     
     settings = DATASETS[dataset_code]
     
     dataset = Datasets(provider_name=self.provider_name, 
                        dataset_code=dataset_code, 
                        name=settings['name'], 
                        doc_href=settings['doc_href'], 
                        fetcher=self)
     
     weo_data = WeoData(dataset, url)
     dataset.last_update = weo_data.release_date        
     dataset.attribute_list.update_entry('flags','e','Estimated')
     dataset.series.data_iterator = weo_data
     try:
         dataset.update_database()
         self.update_metas(dataset_code)
     except Exception as err:
         logger.error(str(err))
開發者ID:MichelJuillard,項目名稱:dlstats,代碼行數:21,代碼來源:imf.py

示例12: _common_tests

# 需要導入模塊: from dlstats.fetchers._commons import Datasets [as 別名]
# 或者: from dlstats.fetchers._commons.Datasets import last_update [as 別名]
    def _common_tests(self):

        self._collections_is_empty()

        self.filepath = get_filepath(self.dataset_code)
        self.assertTrue(os.path.exists(self.filepath))

        # provider.update_database
        self.fetcher.provider.update_database()
        provider = self.db[constants.COL_PROVIDERS].find_one({"name": self.fetcher.provider_name})
        self.assertIsNotNone(provider)

        dataset = Datasets(
            provider_name=self.fetcher.provider_name,
            dataset_code=self.dataset_code,
            name=DATASETS[self.dataset_code]["name"],
            last_update=DATASETS[self.dataset_code]["last_update"],
            fetcher=self.fetcher,
        )

        # manual Data for iterator
        fetcher_data = esri.EsriData(dataset, make_url(self), filename=DATASETS[self.dataset_code]["filename"])
        dataset.series.data_iterator = fetcher_data
        dataset.last_update = DATASETS[self.dataset_code]["last_update"]
        dataset.update_database()

        self.dataset = self.db[constants.COL_DATASETS].find_one(
            {"provider_name": self.fetcher.provider_name, "dataset_code": self.dataset_code}
        )

        self.assertIsNotNone(self.dataset)

        dimensions = self.dataset["dimension_list"]
        self.assertEqual(len(dimensions), DATASETS[self.dataset_code]["dimension_count"])
        for c in dimensions["concept"]:
            self.assertIn(c[1], DATASETS["series_names"])

        series = self.db[constants.COL_SERIES].find(
            {"provider_name": self.fetcher.provider_name, "dataset_code": self.dataset_code}
        )

        self.assertEqual(series.count(), DATASETS[self.dataset_code]["series_count"])
開發者ID:MichelJuillard,項目名稱:dlstats,代碼行數:44,代碼來源:test_esri.py

示例13: upsert_dataset

# 需要導入模塊: from dlstats.fetchers._commons import Datasets [as 別名]
# 或者: from dlstats.fetchers._commons.Datasets import last_update [as 別名]
    def upsert_dataset(self, dataset_code):
        """Updates data in Database for selected datasets
        :dset: dataset_code
        :returns: None"""
        self.get_selected_datasets()
        
        start = time.time()
        logger.info("upsert dataset[%s] - START" % (dataset_code))

        self.dataset_settings = self.selected_datasets[dataset_code]
        url = self.make_url()
        dataset = Datasets(self.provider_name,dataset_code,
                           fetcher=self)
        dataset.name = self.dataset_settings['name']
        dataset.doc_href = self.dataset_settings['metadata']['doc_href']
        dataset.last_update = self.dataset_settings['last_update']
        data_iterator = EsriData(dataset,url,filename=dataset_code)
        dataset.series.data_iterator = data_iterator
        dataset.update_database()
        end = time.time() - start
        logger.info("upsert dataset[%s] - END - time[%.3f seconds]" % (dataset_code, end))
開發者ID:MichelJuillard,項目名稱:dlstats,代碼行數:23,代碼來源:esri.py


注:本文中的dlstats.fetchers._commons.Datasets.last_update方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。