Exemplo n.º 1
0
 def handle(self, *args, **options):
     super(Command, self).handle(*args, **options)
     translation.activate(options.get("language"))
     for survey in self.surveys:
         LOGGER.info("Generating results for '%s'", survey)
         exporters = []
         if options["csv"]:
             exporters.append(Survey2Csv(survey))
         if options["tex"] or options["pdf"]:
             configuration_file = options.get("configuration_file")
             if configuration_file is None:
                 msg = "No configuration file given, using default values for '{}'.".format(survey)
                 LOGGER.info(msg)
             configuration = Configuration(configuration_file)
             exporters.append(Survey2Tex(survey, configuration))
         for exporter in exporters:
             if options["force"] or exporter.need_update():
                 exporter.generate_file()
                 if options["pdf"] and isinstance(exporter, Survey2Tex):
                     exporter.generate_pdf()
             else:
                 LOGGER.warning(
                     "\t- %s's %s were already generated use the --force (-f) option to generate anyway.",
                     survey,
                     exporter._get_x(),
                 )
Exemplo n.º 2
0
    def handle(self, *args, **options):
        super(Command, self).handle(*args, **options)
        translation.activate(options.get("language"))
        if not options["csv"] and not options["tex"] and not options["pdf"]:
            exit("Nothing to do : add option --tex or --pdf, --csv,  or both.")
        if self.survey is None:
            surveys = Survey.objects.all()
        else:
            surveys = [self.survey]
        for survey in surveys:
            LOGGER.info("Generating results for '%s'", survey)
            exporters = []
            if options["csv"]:
                exporters.append(Survey2Csv(survey))
            if options["tex"] or options["pdf"]:
                configuration_file = options.get("configuration_file")
                if configuration_file is None:
                    msg = "No configuration file given, using default values."
                    LOGGER.warning(msg)
                configuration = Configuration(configuration_file)
                exporters.append(Survey2Tex(survey, configuration))
            for exporter in exporters:
                if options["force"] or exporter.need_update():
                    exporter.generate_file()
                    if options["pdf"] and type(exporter) is Survey2Tex:
                        exporter.generate_pdf()
                else:
                    LOGGER.info("\t- %s's %s were already generated use the\
 --force (-f) option to generate anyway.", survey, exporter._get_X())
Exemplo n.º 3
0
 def test_custom_class_fail_import(self):
     """ We have an error message if the type is impossible to import. """
     conf = Configuration(
         os.path.join(self.conf_dir, "custom_class_doesnt_exists.yaml"))
     self.test_survey = Survey.objects.get(name="Test survëy")
     fail_import = Survey2Tex(self.test_survey, conf).survey_to_x()
     should_contain = [
         "could not render", "not a standard type",
         "importable valid Question2Tex child class", "'raw'", "'sankey'",
         "'pie'", "'cloud'", "'square'", "'polar'"
     ]
     for text in should_contain:
         self.assertIn(text, fail_import)
Exemplo n.º 4
0
 def setUp(self):
     TestManagement.setUp(self)
     conf = Configuration(os.path.join(self.conf_dir, "test_conf.yaml"))
     self.generic = Survey2Tex(self.survey, conf)
     self.test_survey = Survey.objects.get(name="Test survëy")
     self.specific = Survey2Tex(self.test_survey, conf)