def test_config_dict_to_string(self): self.assertTrue(gf.config_dict_to_string({}) == u"") self.assertTrue(gf.config_dict_to_string({u"k1": u"v1"}) == u"k1=v1") self.assertTrue( (gf.config_dict_to_string({u"k1": u"v1", u"k2": u"v2"}) == u"k1=v1|k2=v2") or (gf.config_dict_to_string({u"k1": u"v1", u"k2": u"v2"}) == u"k2=v2|k1=v1") )
def test_config_dict_to_string(self): self.assertTrue(gf.config_dict_to_string({}) == u"") self.assertTrue(gf.config_dict_to_string({u"k1": u"v1"}) == u"k1=v1") self.assertTrue((gf.config_dict_to_string({ u"k1": u"v1", u"k2": u"v2" }) == u"k1=v1|k2=v2") or (gf.config_dict_to_string({ u"k1": u"v1", u"k2": u"v2" }) == u"k2=v2|k1=v1"))
def _analyze_xml_config(self, config_contents=None): """ Analyze the given container and return the corresponding job. If ``config_contents`` is ``None``, try reading it from the XML config file inside the container. :param string config_contents: the contents of the XML config file :rtype: :class:`~aeneas.job.Job` """ self.log(u"Analyzing container with XML config string") if config_contents is None: self.log(u"Analyzing container with XML config file") config_entry = self.container.entry_config_xml self.log([u"Found XML config entry '%s'", config_entry]) config_dir = os.path.dirname(config_entry) self.log([u"Directory of XML config entry: '%s'", config_dir]) self.log([u"Reading XML config entry: '%s'", config_entry]) config_contents = self.container.read_entry(config_entry) else: self.log(u"Analyzing container with XML config contents") config_dir = "" self.log(u"Converting config contents into job config dict") job_parameters = gf.config_xml_to_dict( config_contents, result=None, parse_job=True ) self.log(u"Converting config contents into tasks config dict") tasks_parameters = gf.config_xml_to_dict( config_contents, result=None, parse_job=False ) self.log(u"Calculating the path of the sync map root directory") sync_map_root_directory = gf.norm_join( config_dir, job_parameters[gc.PPN_JOB_OS_HIERARCHY_PREFIX] ) job_os_hierarchy_type = job_parameters[gc.PPN_JOB_OS_HIERARCHY_TYPE] self.log([u"Path of the sync map root directory: '%s'", sync_map_root_directory]) self.log(u"Converting job config dict into job config string") config_string = gf.config_dict_to_string(job_parameters) job = Job(config_string) for task_parameters in tasks_parameters: self.log(u"Converting task config dict into task config string") config_string = gf.config_dict_to_string(task_parameters) self.log([u"Creating task with config string '%s'", config_string]) try: custom_id = task_parameters[gc.PPN_TASK_CUSTOM_ID] except KeyError: custom_id = "" task_info = [ custom_id, gf.norm_join( config_dir, task_parameters[gc.PPN_TASK_IS_TEXT_FILE_XML] ), gf.norm_join( config_dir, task_parameters[gc.PPN_TASK_IS_AUDIO_FILE_XML] ) ] self.log([u"Creating task: '%s'", str(task_info)]) task = self._create_task( task_info, config_string, sync_map_root_directory, job_os_hierarchy_type ) job.add_task(task) return job
def _analyze_xml_config(self, config_contents=None): """ Analyze the given container and return the corresponding job. If ``config_contents`` is ``None``, try reading it from the XML config file inside the container. :param config_contents: the contents of the XML config file :type config_contents: string :rtype: :class:`aeneas.job.Job` """ # TODO break this function down into smaller functions self._log("Analyzing container with XML config string") if config_contents is None: self._log("Analyzing container with XML config file") config_entry = self.container.entry_config_xml self._log(["Found XML config entry '%s'", config_entry]) config_dir = os.path.dirname(config_entry) self._log(["Directory of XML config entry: '%s'", config_dir]) self._log(["Reading XML config entry: '%s'", config_entry]) config_contents = self.container.read_entry(config_entry) else: self._log("Analyzing container with XML config contents") config_dir = "" # remove BOM #self._log("Removing BOM") #config_contents = gf.remove_bom(config_contents) # get the job parameters and tasks parameters self._log("Converting config contents into job config dict") job_parameters = gf.config_xml_to_dict( config_contents, result=None, parse_job=True ) self._log("Converting config contents into tasks config dict") tasks_parameters = gf.config_xml_to_dict( config_contents, result=None, parse_job=False ) # compute the root directory for the sync map files self._log("Calculating the path of the sync map root directory") sync_map_root_directory = gf.norm_join( config_dir, job_parameters[gc.PPN_JOB_OS_HIERARCHY_PREFIX] ) job_os_hierarchy_type = job_parameters[gc.PPN_JOB_OS_HIERARCHY_TYPE] self._log(["Path of the sync map root directory: '%s'", sync_map_root_directory]) # create the Job object to be returned self._log("Converting job config dict into job config string") config_string = gf.config_dict_to_string(job_parameters) job = Job(config_string) # create the Task objects for task_parameters in tasks_parameters: self._log("Converting task config dict into task config string") config_string = gf.config_dict_to_string(task_parameters) self._log(["Creating task with config string '%s'", config_string]) try: custom_id = task_parameters[gc.PPN_TASK_CUSTOM_ID] except KeyError: custom_id = "" task_info = [ custom_id, gf.norm_join( config_dir, task_parameters[gc.PPN_TASK_IS_TEXT_FILE_XML] ), gf.norm_join( config_dir, task_parameters[gc.PPN_TASK_IS_AUDIO_FILE_XML] ) ] self._log(["Creating task: '%s'", str(task_info)]) task = self._create_task( task_info, config_string, sync_map_root_directory, job_os_hierarchy_type ) job.add_task(task) # return the Job return job
def _analyze_xml_config(self, config_contents=None): """ Analyze the given container and return the corresponding job. If ``config_contents`` is ``None``, try reading it from the XML config file inside the container. :param string config_contents: the contents of the XML config file :rtype: :class:`~aeneas.job.Job` """ self.log(u"Analyzing container with XML config string") if config_contents is None: self.log(u"Analyzing container with XML config file") config_entry = self.container.entry_config_xml self.log([u"Found XML config entry '%s'", config_entry]) config_dir = os.path.dirname(config_entry) self.log([u"Directory of XML config entry: '%s'", config_dir]) self.log([u"Reading XML config entry: '%s'", config_entry]) config_contents = self.container.read_entry(config_entry) else: self.log(u"Analyzing container with XML config contents") config_dir = "" self.log(u"Converting config contents into job config dict") job_parameters = gf.config_xml_to_dict(config_contents, result=None, parse_job=True) self.log(u"Converting config contents into tasks config dict") tasks_parameters = gf.config_xml_to_dict(config_contents, result=None, parse_job=False) self.log(u"Calculating the path of the sync map root directory") sync_map_root_directory = gf.norm_join( config_dir, job_parameters[gc.PPN_JOB_OS_HIERARCHY_PREFIX]) job_os_hierarchy_type = job_parameters[gc.PPN_JOB_OS_HIERARCHY_TYPE] self.log([ u"Path of the sync map root directory: '%s'", sync_map_root_directory ]) self.log(u"Converting job config dict into job config string") config_string = gf.config_dict_to_string(job_parameters) job = Job(config_string) for task_parameters in tasks_parameters: self.log(u"Converting task config dict into task config string") config_string = gf.config_dict_to_string(task_parameters) self.log([u"Creating task with config string '%s'", config_string]) try: custom_id = task_parameters[gc.PPN_TASK_CUSTOM_ID] except KeyError: custom_id = "" task_info = [ custom_id, gf.norm_join(config_dir, task_parameters[gc.PPN_TASK_IS_TEXT_FILE_XML]), gf.norm_join(config_dir, task_parameters[gc.PPN_TASK_IS_AUDIO_FILE_XML]) ] self.log([u"Creating task: '%s'", str(task_info)]) task = self._create_task(task_info, config_string, sync_map_root_directory, job_os_hierarchy_type) job.add_task(task) return job
def _analyze_xml_config(self, config_contents=None): """ Analyze the given container and return the corresponding job. If ``config_contents`` is ``None``, try reading it from the XML config file inside the container. :param config_contents: the contents of the XML config file :type config_contents: string :rtype: :class:`aeneas.job.Job` """ # TODO break this function down into smaller functions self._log("Analyzing container with XML config string") if config_contents is None: self._log("Analyzing container with XML config file") config_entry = self.container.entry_config_xml self._log(["Found XML config entry '%s'", config_entry]) config_dir = os.path.dirname(config_entry) self._log(["Directory of XML config entry: '%s'", config_dir]) self._log(["Reading XML config entry: '%s'", config_entry]) config_contents = self.container.read_entry(config_entry) else: self._log("Analyzing container with XML config contents") config_dir = "" # remove BOM #self._log("Removing BOM") #config_contents = gf.remove_bom(config_contents) # get the job parameters and tasks parameters self._log("Converting config contents into job config dict") job_parameters = gf.config_xml_to_dict(config_contents, result=None, parse_job=True) self._log("Converting config contents into tasks config dict") tasks_parameters = gf.config_xml_to_dict(config_contents, result=None, parse_job=False) # compute the root directory for the sync map files self._log("Calculating the path of the sync map root directory") sync_map_root_directory = gf.norm_join( config_dir, job_parameters[gc.PPN_JOB_OS_HIERARCHY_PREFIX]) job_os_hierarchy_type = job_parameters[gc.PPN_JOB_OS_HIERARCHY_TYPE] self._log([ "Path of the sync map root directory: '%s'", sync_map_root_directory ]) # create the Job object to be returned self._log("Converting job config dict into job config string") config_string = gf.config_dict_to_string(job_parameters) job = Job(config_string) # create the Task objects for task_parameters in tasks_parameters: self._log("Converting task config dict into task config string") config_string = gf.config_dict_to_string(task_parameters) self._log(["Creating task with config string '%s'", config_string]) try: custom_id = task_parameters[gc.PPN_TASK_CUSTOM_ID] except KeyError: custom_id = "" task_info = [ custom_id, gf.norm_join(config_dir, task_parameters[gc.PPN_TASK_IS_TEXT_FILE_XML]), gf.norm_join(config_dir, task_parameters[gc.PPN_TASK_IS_AUDIO_FILE_XML]) ] self._log(["Creating task: '%s'", str(task_info)]) task = self._create_task(task_info, config_string, sync_map_root_directory, job_os_hierarchy_type) job.add_task(task) # return the Job return job