Commit 980af6f2 authored by Pierre Dittgen's avatar Pierre Dittgen
Browse files

Formatting using black

parent e3e1264a
......@@ -71,7 +71,7 @@ CONCEPT_TO_CODE_MAP = {
def generate_tsv_from_csv_data_line(csv_code, csv_name, cols, ds_dir):
""" Parse data, generates time series dans return series info list """
"""Parse data, generates time series dans return series info list"""
# TODO
return []
......@@ -112,10 +112,10 @@ def norm_period_values(period_values, freq):
class CSVLineHelper:
""" Handy class that helps parsing CSV time series """
"""Handy class that helps parsing CSV time series"""
def __init__(self, csv_code, csv_name, ds_dir: Path, header_cols):
""" Initializes instance computing period_infos """
"""Initializes instance computing period_infos"""
self.csv_code = csv_code
self.csv_name = csv_name
......@@ -164,7 +164,7 @@ class CSVLineHelper:
return ["NA" if elt in ("", "-", "***") else elt for elt in obs_values]
def generate_tsv_from_csv_row(self, cols):
""" Generates all TSV from a CSV line """
"""Generates all TSV from a CSV line"""
ts_infos = []
......@@ -301,7 +301,7 @@ def generate_dataset(
def write_dataset_json(
json_filepath: Path, ds_code, ds_name, series_info, with_concept=False
):
""" Writes dataset.json """
"""Writes dataset.json"""
dataset_data = {
"code": ds_code,
"name": ds_name,
......@@ -363,7 +363,7 @@ def clean_csv_files(source_dir: Path):
def write_category_tree_json(json_filepath):
""" Creates category_tree data and saves it as a json file """
"""Creates category_tree data and saves it as a json file"""
category_tree_data = [
{"code": "iip", "name": DATASETS_INFO["iip"]},
{"code": "sanzi", "name": DATASETS_INFO["sanzi"]},
......@@ -372,7 +372,7 @@ def write_category_tree_json(json_filepath):
def main():
""" Converts downloaded CSV files into datasets and time series """
"""Converts downloaded CSV files into datasets and time series"""
parser = argparse.ArgumentParser(
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
)
......
......@@ -7,14 +7,14 @@ from pathlib import Path
def write_json_file(file_path: Path, data):
""" Writes data the json way to file_path """
"""Writes data the json way to file_path"""
with file_path.open("wt", encoding="utf-8") as json_fd:
json.dump(data, json_fd, ensure_ascii=False, indent=2, sort_keys=True)
def write_category_json_file(file_path, categories_info, dataset_info):
""" Write category_tree.json from declarative data """
"""Write category_tree.json from declarative data"""
category_data = []
for cat in categories_info:
children = []
......@@ -36,10 +36,10 @@ def write_category_json_file(file_path, categories_info, dataset_info):
def write_dataset_json_file(file_path, dataset_info, datasets_info):
""" Write dataset.json from declarative data """
"""Write dataset.json from declarative data"""
def compute_dim_values_labels(dim_info):
""" Computes dimensions_values_labels dict """
"""Computes dimensions_values_labels dict"""
data = dict()
for code, _, values in dim_info:
# print('Values = {}'.format(values))
......@@ -47,7 +47,7 @@ def write_dataset_json_file(file_path, dataset_info, datasets_info):
return data
def compute_series_info(series_info):
""" Computes series info """
"""Computes series info"""
data = dict(
code=series_info[0],
name=series_info[1],
......
......@@ -100,7 +100,7 @@ def process_resource(resource: MetiResource):
def download_binary_file(url, file_path: Path):
""" Download url into binary file """
"""Download url into binary file"""
logger.info("Downloading %s from %s ... ", str(file_path), url)
req = requests.get(url, stream=True)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment