Exemple #1
0
def set_nationality(data):
    __pg_request(
        conf.get_conf('queries.conf')['set_nat'].replace(
            '%LABEL%', data['label']).replace('%FULL%', data['full_name']))
    log.write_log(
        'appli.log',
        'm_IO.set_nationality | add new nationality : ' + data['label'])
    return True
Exemple #2
0
def get_notes_spe(film_id):
    log.write_log(
        'appli.log',
        'm_IO.get_notes_films_spec | Get note table link with film name for one specific film'
    )
    return __pg_request(
        conf.get_conf('queries.conf')['get_notes_spec'].replace(
            '%FILMID%', film_id))
Exemple #3
0
def get_conf(file_name):

    try:
        file = open(os.path.dirname(os.path.abspath(__file__)) + os.path.sep + 'config' + os.path.sep + file_name, 'r')  
        lines = file.readlines()
        file.close()
    except ValueError:
        print 'Unable to open the log file ' + str(file_name) + str('\n')
        log.write_log('appli.log', 'm_conf.get_conf | unable to open the conf file '+ str(file_name))
    data = {}
    for line in lines:
        data[line.split('|')[0]] = line.split('|')[1][:-1:]
    return data
Exemple #4
0
def set_film(data_film):
    __pg_request(
        conf.get_conf('queries.conf')['set_film'].replace(
            '%NAME%',
            data_film['name']).replace('%CDATE%',
                                       data_film['creation']).replace(
                                           '%RESUME%', data_film['resume']))
    for director in data_film['directors'].split(','):
        __pg_request(
            conf.get_conf('queries.conf')['set_film_creator'].replace(
                '%NAME%', data_film['name']).replace('%CREATOR%', director))
    log.write_log('appli.log',
                  'm_IO.set_film | Create a new film ' + data_film['name'])
    return True
Exemple #5
0
def set_director(data_director):
    #insert director
    __pg_request(
        conf.get_conf('queries.conf')['set_director'].replace(
            '%NAME%', data_director['name']).replace(
                '%BIRTH%', data_director['birth']).replace(
                    '%DEATH%', data_director['death']).replace("''", 'null'))
    for i in data_director['nationalities'].split(','):
        #insert nationalities
        __pg_request(
            conf.get_conf('queries.conf')['set_director_nat'].replace(
                '%NAME%', data_director['name']).replace('%NATID%', i))
    log.write_log(
        'appli.log',
        'm_IO.set_director | Create a new director ' + data_director['name'])
    return True
Exemple #6
0
def set_note(data_note):
    __pg_request(
        conf.get_conf('queries.conf')['set_note'].replace(
            '%NOTEBY%', data_note['note_by']).replace(
                '%FNOTE%', data_note['final_note']).replace(
                    '%ART%', data_note['art_note']).replace(
                        '%STORY%', data_note['story_note']).replace(
                            '%FUN%', data_note['fun_note']).replace(
                                '%FILM%', data_note['film_id']).replace(
                                    '%COM%',
                                    data_note['comment'].replace("'", "''")))
    log.write_log(
        'appli.log',
        'm_IO.get_notes_films | Get note table link with film name for one specific film'
    )
    return True
Exemple #7
0
def get_directors_nat():

    data_nat = {}
    # compress director nat into list l[name] = {nat1, nat2}
    for record in __pg_request(
            conf.get_conf('queries.conf')['get_director_nat']):
        if record[0] in data_nat.keys():
            data_nat[record[0]] = data_nat[record[0]] + ', ' + record[2]
        else:
            data_nat[record[0]] = record[2]

    directors = []
    for director in __pg_request(
            conf.get_conf('queries.conf')['get_director']):

        tmp = []
        for item in list(director):
            tmp.append(item)
        tmp.append(data_nat[director[0]])
        directors.append(tuple(tmp))

    log.write_log('appli.log',
                  'm_IO.get_director_nat | Get directors with nationality')
    return directors
Exemple #8
0
def get_directors_short():
    log.write_log('appli.log',
                  'm_IO.get_director_short | Get directors name and ID')
    return __pg_request(conf.get_conf('queries.conf')['get_creator_short'])
Exemple #9
0
def get_directors():
    log.write_log('appli.log', 'm_IO.get_director | Get directors')
    return __pg_request(conf.get_conf('queries.conf')['get_director'])
Exemple #10
0
def get_nationalities():
    log.write_log('appli.log', 'm_IO.get_nationalities | Get nationalities')
    return __pg_request(conf.get_conf('queries.conf')['get_nat'])
Exemple #11
0
def get_notes_films():
    log.write_log('appli.log',
                  'm_IO.get_notes_films | Get note table link with film name')
    return __pg_request(conf.get_conf('queries.conf')['get_notes'])
Exemple #12
0
def get_notes():
    log.write_log('appli.log', 'm_IO.get_notes | Get note table AS IS')
    return __pg_request(conf.get_conf('queries.conf')['get_notes_full'])
Exemple #13
0
def get_films():
    log.write_log('appli.log', 'm_IO.get_films | Get films without director')
    return __pg_request(conf.get_conf('queries.conf')['get_films_full'])