add file extraction to /tmp
This commit is contained in:
parent
d0368ac0f5
commit
e51f548c10
|
@ -21,6 +21,7 @@ import re
|
|||
import csv
|
||||
import sys
|
||||
import json
|
||||
import zipfile
|
||||
import datetime
|
||||
import logging
|
||||
from logging.config import dictConfig
|
||||
|
@ -105,9 +106,15 @@ def json_write_data(json_data, output):
|
|||
return False
|
||||
|
||||
|
||||
def extract_zip_to_tmp(filename):
|
||||
with zipfile.ZipFile(filename, 'r') as zipf:
|
||||
zipf.extractall('/tmp/')
|
||||
|
||||
|
||||
class ConcertoFormatter(object):
|
||||
name = 'concerto'
|
||||
output_file = 'concerto.json'
|
||||
output_file = '/tmp/concerto.json'
|
||||
expected_file = '/tmp/extract_prcit_planning_creche.csv'
|
||||
fieldnames = [
|
||||
'ID_LIE', 'DAT_JOUR_TMP', 'HEU_DEBUT_TMP', 'HEU_FIN_TMP',
|
||||
'NB_PLACESPOSS_TMP', 'NB_PLACESOCC_TMP', 'NB_PLACESRESFUT_TMP',
|
||||
|
@ -119,7 +126,8 @@ class ConcertoFormatter(object):
|
|||
|
||||
def format(self):
|
||||
agendas = []
|
||||
data = csv_get_dict_data(self.filename, fieldnames=self.fieldnames)
|
||||
extract_zip_to_tmp(self.filename)
|
||||
data = csv_get_dict_data(self.expected_file, fieldnames=self.fieldnames)
|
||||
for nursery, events in groupby(data, lambda x: x['LIB_NOM_LIE']):
|
||||
nursery_slug = slugify(nursery)
|
||||
agenda = {'slug': nursery_slug, 'label': unicode(nursery, errors='replace'),
|
||||
|
@ -143,7 +151,7 @@ class ConcertoFormatter(object):
|
|||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 2:
|
||||
logger.error('Invalid agrument number: concerto_2_chrono_format.py <file>')
|
||||
logger.error('Invalid agrument number: concerto_2_chrono_format.py <input>')
|
||||
sys.exit(1)
|
||||
|
||||
filename = sys.argv[1]
|
||||
|
|
Reference in New Issue