Commits

Cat's Eye Technologies committed be9dbda

Local cookies take precedence over global cookies.

Comments (0)

Files changed (3)

   build_command make ansi && make INSTALL_TOP=`pwd`/install install
 
 */*/perl-5.*
-  C_INCLUDE_PATH="" build_command ./Configure -des -Dprefix=`pwd`/install && make && make install
+  build_command C_INCLUDE_PATH="" ./Configure -des -Dprefix=`pwd`/install && C_INCLUDE_PATH="" make && make install
 
 */erlang/otp
   build_command ./otp_build all

src/toolshelf/commands/which.py

 
 def which(shelf, args):
     for arg in args:
-        linkname = os.path.join(shelf.bin_link_farm.dirname, arg)
+        linkname = os.path.join(shelf.link_farms['bin'].dirname, arg)
         if os.path.islink(linkname):
             filename = os.readlink(linkname)
             print filename

src/toolshelf/toolshelf.py

 class Cookies(object):
     def __init__(self, shelf):
         self.shelf = shelf
-        self._hint_map = None
+        self._hint_maps = None
         self.filenames = []
 
     def add_file(self, filename):
             self.filenames.append(filename)
 
     def _load_hints(self):
-        self._hint_map = {}
+        self._hint_maps = []
         for filename in self.filenames:
             self._load_hints_from_file(filename)
 
     def _load_hints_from_file(self, filename):
+        hint_map = {}
         with open(filename, 'r') as hints_file:
             spec_key = None
             for line in hints_file:
                 line = line.strip()
+                if line == '' or line.startswith('#'):
+                    continue
                 found_hint = False
                 for hint_name in HINT_NAMES:
                     pattern = r'^%s\s+(.*?)\s*$' % hint_name
                         self.shelf.debug("Adding hint '%s %s' to %s" %
                             (hint_name, hint_value, spec_key)
                         )
-                        self._hint_map[spec_key][hint_name] = hint_value
+                        hint_map[spec_key][hint_name] = hint_value
                         if (hint_name == 'rectify_permissions' and
                             hint_value not in ('yes', 'no')):
                             raise ValueError(
                             )
                         found_hint = True
                         break
-                if found_hint or line == '' or line.startswith('#'):
-                    continue
-                spec_key = line
-                self._hint_map.setdefault(spec_key, {})
+                if not found_hint:  # ... then we found a spec
+                    spec_key = line
+                    hint_map.setdefault(spec_key, {})
+        self._hint_maps.append(hint_map)
 
     @property
-    def hint_map(self):
-        if self._hint_map is None:
+    def hint_maps(self):
+        if self._hint_maps is None:
             self._load_hints()
-        return self._hint_map
+        return self._hint_maps
 
     def apply_hints(self, source):
-        for key in self.hint_map:
-            pattern = fnmatch.translate(key)
-            match = re.match(pattern, source.name)
-            if match:
-                source.hints.update(self.hint_map[key])
+        for hint_map in self.hint_maps:
+            found_in_map = False
+            for (key, hints) in hint_map.iteritems():
+                pattern = fnmatch.translate(key)
+                match = re.match(pattern, source.name)
+                if match:
+                    source.hints.update(hints)
+                    found_in_map = True
+            if found_in_map:
+                break
 
 
 class Blacklist(object):
         if cookies is None:
             cookies = Cookies(self)
             cookies.add_file(os.path.join(
-                self.dir, '.toolshelf', 'cookies.catalog'
+                self.dir, '.toolshelf', 'local-cookies.catalog'
             ))
             cookies.add_file(os.path.join(
-                self.dir, '.toolshelf', 'local-cookies.catalog'
+                self.dir, '.toolshelf', 'cookies.catalog'
             ))
         self.cookies = cookies