1
1
# -*- coding: utf-8 -*-
2
- import json
3
- from wolframclient .logger .utils import setup_logging_to_file
4
- from wolframclient .utils .api import os
5
- __all__ = [ 'create_dir_if_missing' , 'dir_test_data' , 'json_config' ]
2
+ from __future__ import absolute_import , print_function , unicode_literals
6
3
7
- def create_dir_if_missing (path ):
8
- ''' Create the directory structure represented by a `path`.
9
-
10
- Path can represent a file or a directory depending if it ends with
11
- a path separator.
12
-
13
- If the path represents a file, the parent directory is created, otherwise
14
- the directory itself is created.
15
- '''
16
- file_dir = os .dirname (path )
17
- if not os .exists (file_dir ):
18
- os .makedirs (file_dir )
4
+ from wolframclient .tests .configure import json_config , create_dir_if_missing , dir_test_data
19
5
20
- def dir_test_data ():
21
- ''' Return path to the data directory in tests'''
22
- current_file_dir = os .dirname (__file__ )
23
- return os .path_join (current_file_dir , 'data' )
24
-
25
-
26
- log_file = os .environ .get ('WOLFRAMCLIENT_PY_LOG_FILE' , None )
27
- if log_file is not None :
28
- create_dir_if_missing (log_file )
29
- setup_logging_to_file (log_file )
30
-
31
- json_config = None
32
- json_config_path = os .environ .get ('WOLFRAMCLIENT_PY_JSON_CONFIG' , None )
33
- if json_config_path is not None :
34
- expended_path = os .expanduser (os .expandvars (json_config_path ))
35
- try :
36
- with open (expended_path , 'r' ) as fp :
37
- json_config = json .load (fp )
38
- except :
39
- raise ValueError ('Failed to find json configuration file %s' % json_config_path )
6
+ __all__ = ['create_dir_if_missing' , 'dir_test_data' , 'json_config' ]
0 commit comments