11import os
2+ from pathlib import Path
3+
24import larray as la
35
46
5- _TEST_DIR = os . path . join ( os . path . dirname ( __file__ ), 'tests' )
7+ _TEST_DIR = Path ( __file__ ). parent / 'tests'
68
7- EXAMPLE_FILES_DIR = os . path . join ( _TEST_DIR , 'data' )
9+ EXAMPLE_FILES_DIR = _TEST_DIR / 'data'
810AVAILABLE_EXAMPLE_DATA = {
9- 'demography' : os . path . join ( EXAMPLE_FILES_DIR , 'demography.h5' ) ,
10- 'demography_eurostat' : os . path . join ( EXAMPLE_FILES_DIR , 'demography_eurostat.h5' )
11+ 'demography' : EXAMPLE_FILES_DIR / 'demography.h5' ,
12+ 'demography_eurostat' : EXAMPLE_FILES_DIR / 'demography_eurostat.h5'
1113}
12- EXAMPLE_EXCEL_TEMPLATES_DIR = os . path . join ( _TEST_DIR , 'excel_template' )
14+ EXAMPLE_EXCEL_TEMPLATES_DIR = _TEST_DIR / 'excel_template'
1315
1416
15- def get_example_filepath (fname ):
17+ def get_example_filepath (fname ) -> Path :
1618 r"""Return absolute path to an example file if exist.
1719
1820 Parameters
@@ -33,8 +35,8 @@ def get_example_filepath(fname):
3335 --------
3436 >>> fpath = get_example_filepath('examples.xlsx')
3537 """
36- fpath = os . path . abspath ( os . path . join ( EXAMPLE_FILES_DIR , fname ))
37- if not os . path . exists (fpath ):
38+ fpath = ( EXAMPLE_FILES_DIR / fname ). absolute ( )
39+ if not fpath . exists ():
3840 AVAILABLE_EXAMPLE_FILES = os .listdir (EXAMPLE_FILES_DIR )
3941 raise ValueError (f"Example file { fname } does not exist. "
4042 f"Available example files are: { AVAILABLE_EXAMPLE_FILES } " )
0 commit comments