Blame view

flaskr/core.py 919 Bytes
e0a7b516   Goutte   Try out ABC.
1
import abc
5e995dfe   Antoine Goutenoir   Refactor how we c...
2
import importlib
984b691d   Goutte   Add the core libr...
3
4
5
from datetime import datetime
from uuid import uuid4

5e995dfe   Antoine Goutenoir   Refactor how we c...
6
7
from .content import content

984b691d   Goutte   Add the core libr...
8
9
10
11
12
13

def generate_unique_id():
    """
    :return: a unique identifier that can be sorted chronologically.
    """
    return datetime.now().strftime('%Y-%m-%d_%H:%M:%S_') + str(uuid4())[0:4]
e0a7b516   Goutte   Try out ABC.
14
15


5e995dfe   Antoine Goutenoir   Refactor how we c...
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
def get_emission_models():
    emission_models_confs = content.models
    emission_models = []

    for model_conf in emission_models_confs:
        model_file = model_conf.file
        the_module = importlib.import_module("flaskr.laws.%s" % model_file)

        model = the_module.EmissionModel(model_conf)
        # model.configure(extra_model_conf)

        emission_models.append(model)

    return emission_models


models = get_emission_models()
e0a7b516   Goutte   Try out ABC.
33
34


5e995dfe   Antoine Goutenoir   Refactor how we c...
35
# unused
e0a7b516   Goutte   Try out ABC.
36
37
38
39
class FootprintEstimatorDriver(abc.ABCMeta):
    @abc.abstractmethod
    def get_travel_footprint(self, from_location, to_location):  # TBD
        pass