...
 
Commits (2)
......@@ -18,7 +18,7 @@
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http:>www.gnu.org/licenses/>.
# along with this program. If not, see <https://www.gnu.org/licenses/>.
"""Convert series from DREES macro economic database to DB.nomics JSON and TSV formats."""
......@@ -51,8 +51,6 @@ PROVIDER = {
"drees-direction-de-la-recherche-des-etudes-de-l-evaluation-et-des-statistiques",
}
TARGET_REPOSITORY_URL = "git@git.nomics.world:dbnomics-json-data/drees-json-data.git"
def main():
parser = argparse.ArgumentParser()
......
......@@ -18,79 +18,34 @@
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http:>www.gnu.org/licenses/>.
# along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
Fetch series from DREES (Direction de la recherche, des études, de l’évaluation et des statistiques).
"""Fetch series from DREES (Direction de la recherche, des études, de l’évaluation et des statistiques).
See http://www.data.drees.sante.gouv.fr/ReportFolders/reportFolders.aspx?IF_ActivePath=P,304,305
"""
import argparse
import logging
import os
import subprocess
import sys
import requests
TARGET_REPOSITORY_URL = "git@git.nomics.world:dbnomics-source-data/drees-source-data.git"
EXCEL_FILE_NAME = "LA PROTECTION SOCIALE EN FRANCE ET EN EUROPE - De 1959 à 2015.xls"
EXCEL_URL = "http://www.data.drees.sante.gouv.fr/TableViewer/document.aspx?ReportId=3012"
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
'target_dir',
help='path of target directory containing DREES series in source format',
)
parser.add_argument(
'--debug',
action='store_true',
help='display logging messages from debug level',
)
parser.add_argument(
'--push',
action='store_true',
help='push commits to remote Git server',
)
parser.add_argument('target_dir', help='path of target directory containing DREES series in source format')
args = parser.parse_args()
logging.basicConfig(level=logging.DEBUG if args.debug else logging.WARNING)
if not os.path.exists(args.target_dir):
subprocess.check_call(['git', 'clone', TARGET_REPOSITORY_URL, args.target_dir])
# Remove all tracked files.
subprocess.check_call(
['git', 'rm', '--ignore-unmatch', '-r', '.'],
cwd=args.target_dir,
)
response = requests.get(EXCEL_URL)
excel_file_path = os.path.join(args.target_dir, EXCEL_FILE_NAME)
with open(excel_file_path, "wb") as excel_file:
excel_file.write(response.content)
subprocess.check_call(
['git', 'add', EXCEL_FILE_NAME],
cwd=args.target_dir,
)
# Note: Ignore error occuring when there is nothing to commit.
subprocess.call(
['git', 'commit', '-m', 'New fetch'],
cwd=args.target_dir,
)
if args.push:
# Note: Ignore error occuring when there is nothing to push.
subprocess.call(
['git', 'push', 'origin', 'master'],
cwd=args.target_dir,
)
if __name__ == '__main__':
sys.exit(main())