Commits

Wang Dingwei committed 204b7d6

added support for exclud_pn

  • Participants
  • Parent commits 61c8248

Comments (0)

Files changed (1)

         self.models = setting.models
         self.name = setting.failpath
         self.exclude = setting.exclude
+        self.exclude_pn = setting.exclude_pn
         self.actions = []
         
     def match(self, order):
             (order.shipmode != '' and order.shipmode in self.exclude)):
             return None
         sdr = SDR(order.sdrlines)
+        
         # compare with OS mapping table
         if not self.os_table.matches(sdr):
             e = "Unsupported OS type."
             logger.info(e)
             return MatchObj(self.name, e)
+        
         # compare with app table
         unknown = self.app_table.missed_srvs(sdr)
         if not unknown:
             return None
+
         # compare with whitelist
         unknown = self.whitelist.missed_srvs(unknown)
+
+        # Check for excluded SRV
+        for u in unknown[:]:
+            if u.pn in self.exclude_pn:
+                unknown.remove(u)
+
+        # Return match result, or None
         if unknown:
             e = "Unknown parts: %s" % ','.join([u.pn for u in unknown])
             logger.info(e)
                 rule.app_table = self.cfg.get(sect, 'app_table')
                 rule.whitelist = self.cfg.get(sect, 'whitelist')
                 rule.models = set([m.strip() for m in
-                                   self.cfg.get(sect, 'model').split(',')])
+                        self.cfg.get(sect, 'model').split(',')])
                 rule.exclude = set([m.strip() for m in 
-                                    self.cfg.get(sect,'exclude_mod').split(',')])
+                        self.cfg.get(sect,'exclude_mod').split(',')])
+                rule.exclude_pn = set([m.strip() for m in 
+                        self.cfg.get(sect, 'exclude_pn').split(',')])
                 rule.failpath = sect
                 configs.append(rule)
         return configs