Changeset 6df4b11 for fedd


Ignore:
Timestamp:
May 17, 2010 10:44:46 AM (15 years ago)
Author:
Ted Faber <faber@…>
Branches:
axis_example, compt_changes, info-ops, master, version-3.01, version-3.02
Children:
4b6909e
Parents:
baf19c6
Message:

Check both sides of the constraint match (!). Add lax option to output
solutions that do not match all required constraints.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedd/compose.py

    rbaf19c6 r6df4b11  
    4646        self.add_option('--format', dest='format', default="xml",
    4747                help='Output file format')
     48        self.add_option('--lax', dest='lax', default=False,
     49                action='store_true',
     50                help='allow solutions where unrequired constraints fail')
    4851
    4952    @staticmethod
     
    151154    for c in candidates:
    152155        if not c.match:
    153             match = None
     156            rmatch = None   # Match to a required constraint
     157            umatch = None   # Match to an unrequired constraint
    154158            for a in c.accepts:
    155159                for can in provides.get(a,[]):
     
    159163                    if can.name != c.name and can.name[2] != c.name[2] and \
    160164                            not can.match:
    161                         match = can
     165                        # Now check that the candidate also accepts c
     166                        for ca in can.accepts:
     167                            if ca in c.provides:
     168                                if can.required: rmatch = can
     169                                else: umatch = can
     170                                break
     171                       
    162172                        # Within providers, prefer matches against required
    163                         # composition points
    164                         if can.required:
     173                        # composition points.
     174                        if rmatch:
    165175                            break
    166176                # Within acceptance categories, prefer matches against required
    167177                # composition points
    168                 if match and match.required:
     178                if rmatch:
    169179                    break
    170180
    171             # Done checking all possible matches.
     181            # Move the better match over to the match variable
     182            if rmatch: match = rmatch
     183            elif umatch: match = umatch
     184            else: match = None
     185
     186            # Done checking all possible matches.  Record the match or note an
     187            # unmatched candidate.
    172188            if match:
    173189                match.match = c
     
    540556    if not meet_constraints([c for c in constraints if c.required],
    541557            provides, accepts):
    542         sys.exit("Could not meet all required constraints")
     558        if opts.lax:
     559            warn("warning: could not meet all required constraints")
     560        else:
     561            sys.exit("Failed: could not meet all required constraints")
    543562
    544563    meet_constraints([ c for c in constraints if not c.match ],
Note: See TracChangeset for help on using the changeset viewer.