def assert_symbian_policy_file(self, filename, value=None, exception=False): if exception: try: fileutils.read_symbian_policy_content(filename) assert "Should fail while loading '%s'." % filename except: pass else: assert fileutils.read_symbian_policy_content(filename) == value
def is_selected(self, path): """ Determines if the path is selected by this selector. """ current_dir = os.path.abspath(os.path.dirname(path)) logger.debug('is_selected: current dir = ' + current_dir + ' ' + str(os.path.exists(current_dir))) result = False policy_file = None # finding the distribution policy from the filelist. for filename in self._policy_files: if os.sep != '\\': for f in os.listdir(current_dir): if f.lower() == filename.lower(): policy_file = os.path.join(current_dir, f) logger.debug('Using Policy file: ' + policy_file) break elif os.path.exists(os.path.join(current_dir, filename)): policy_file = os.path.join(current_dir, filename) logger.debug('Using Policy file: ' + policy_file) break policy_value = None if policy_file is None: logger.error("POLICY_ERROR: Policy file not found under '%s' using names [%s]" % (current_dir, ", ".join(self._policy_files))) policy_value = archive.mappers.MISSING_POLICY else: try: policy_value = fileutils.read_symbian_policy_content(policy_file) except Exception: logger.warning('POLICY_ERROR: Exception thrown parsing policy file: ' + policy_file) policy_value = archive.mappers.MISSING_POLICY # loop through the possible values for value in self.values: (val, negate) = self.get_value_and_negate(value) logger.debug('Policy value: ' + str(policy_value) + ' ' + val) if (not negate and policy_value == val) or (negate and policy_value != val): return True return False