Exemplo n.º 1
0
# python 2.7.11 raise the following error
#    UnicodeEncodeError: 'ascii' codec can't encode character u'\x96' in position 17: ordinal not in range(128)
# to prevent it the following three lines are added:
# See: http://stackoverflow.com/questions/21129020/how-to-fix-unicodedecodeerror-ascii-codec-cant-decode-byte
if sys.version_info < (3,):
    reload(sys)
    sys.setdefaultencoding('utf8')

# jsonstat
import istat

if __name__ == "__main__":
    # cache_dir where to store downloaded data file
    JSONSTAT_HOME = os.path.join(os.path.dirname(__file__), "..")
    cache_dir = os.path.normpath(os.path.join(JSONSTAT_HOME, "istat-tests", "fixtures", "istat_cached"))
    istat.cache_dir(cache_dir)

    # print all istat area
    for area in istat.areas():
        print(area)

    # print istat dataset contained into area 'Prices'
    area_name = 'Prices'
    print("--- list dataset in area {}".format(area_name))
    area = istat.area(area_name)
    for istat_dataset in area.datasets():
        print(istat_dataset)

    # print some info about istat dataset 'DCSP_IPAB'
    dataset_name = 'DCSP_IPAB'
    print("--- list dimensions for dataset {}".format(dataset_name))
Exemplo n.º 2
0
#    UnicodeEncodeError: 'ascii' codec can't encode character u'\x96' in position 17: ordinal not in range(128)
# to prevent it the following three lines are added:
# See: http://stackoverflow.com/questions/21129020/how-to-fix-unicodedecodeerror-ascii-codec-cant-decode-byte
if sys.version_info < (3, ):
    reload(sys)
    sys.setdefaultencoding('utf8')

# jsonstat
import istat

if __name__ == "__main__":
    # cache_dir where to store downloaded data file
    JSONSTAT_HOME = os.path.join(os.path.dirname(__file__), "..")
    cache_dir = os.path.normpath(
        os.path.join(JSONSTAT_HOME, "istat-tests", "fixtures", "istat_cached"))
    istat.cache_dir(cache_dir)

    # print all istat area
    for area in istat.areas():
        print(area)

    # print istat dataset contained into area 'Prices'
    area_name = 'Prices'
    print("--- list dataset in area {}".format(area_name))
    area = istat.area(area_name)
    for istat_dataset in area.datasets():
        print(istat_dataset)

    # print some info about istat dataset 'DCSP_IPAB'
    dataset_name = 'DCSP_IPAB'
    print("--- list dimensions for dataset {}".format(dataset_name))
Exemplo n.º 3
0
 def test_cache_dir(self):
     istat.cache_dir('/tmp')
     cd = istat.cache_dir()
     self.assertEqual(cd, '/tmp')
def test_cache_dir(tmpdir):
    istat.cache_dir(str(tmpdir))
    cd = istat.cache_dir()
    assert cd == str(tmpdir)