Skip to content
This repository has been archived by the owner on May 26, 2021. It is now read-only.

Relative paths for config and datapackage #35

Merged
merged 1 commit into from
Aug 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion data_quality/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ def generate(generator_name, endpoint, config_file_path, generator_class_path, f
file_types = list(file_type)
config = utilities.load_json_config(config_file_path)
if not config_file_path:
config['data_dir'] = utilities.resolve_dir_name(os.getcwd(), config['data_dir'])
default_config_path = os.path.join(os.getcwd(), 'dq_config.json')
config['data_dir'] = utilities.resolve_dir_name(default_config_path,
config['data_dir'])
utilities.resolve_dir(config['data_dir'])

if generator_name not in generators._built_in_generators.keys():
Expand Down
10 changes: 2 additions & 8 deletions data_quality/tasks/initialize_datapackage.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ def initialize_config(self):
config = utilities.load_json_config(init_config_path)
else:
config = utilities.load_json_config(None)
config['data_dir'] = utilities.resolve_dir_name(init_config_path,
config['data_dir'])
config['cache_dir'] = utilities.resolve_dir_name(init_config_path,
config['cache_dir'])

with io.open(init_config_path, mode='w+', encoding='utf-8') as new_config:
new_json_config = json.dumps(config, indent=4, sort_keys=True)
Expand All @@ -55,9 +51,7 @@ def initialize_datapackage(self, config):

datapkg_file_path = config.get('datapackage_file', '')
if not datapkg_file_path or not os.path.isabs(datapkg_file_path):
data_dir_path = os.path.normpath(config['data_dir'])
datapkg_dir_path = os.path.dirname(data_dir_path)
datapkg_file_path = os.path.join(datapkg_dir_path, 'datapackage.json')
datapkg_file_path = os.path.join(self.workspace_path, 'datapackage.json')

datapkg_file_path = os.path.abspath(datapkg_file_path)
if not os.path.exists(datapkg_file_path):
Expand All @@ -67,7 +61,7 @@ def initialize_datapackage(self, config):
resource_path = config.get(resource.descriptor['name'],
resource.descriptor['path'])
resource.descriptor['path'] = os.path.join(config['data_dir'],
resource_path)
resource_path)
json_datapkg = json.dumps(default_datapkg.to_dict(), indent=4)
new_datapkg.write(compat.str(json_datapkg))
print(('A new "datapackage.json" file has been created at {0}. '
Expand Down