Exemplo n.º 1
0
 def get_auto_deps(self, items):
     deps = []
     for item in items:
         if item == self:
             continue
         if (
             (
                 item.ITEM_TYPE_NAME == "file" and
                 is_subdirectory(item.name, self.name)
             )
             or
             (
                 item.ITEM_TYPE_NAME in ("file", "symlink") and
                 item.name == self.name
             )
         ):
             raise BundleError(_(
                 "{item1} (from bundle '{bundle1}') blocking path to "
                 "{item2} (from bundle '{bundle2}')"
             ).format(
                 item1=item.id,
                 bundle1=item.bundle.name,
                 item2=self.id,
                 bundle2=self.bundle.name,
             ))
         elif item.ITEM_TYPE_NAME in ("directory", "symlink"):
             if is_subdirectory(item.name, self.name):
                 deps.append(item.id)
     return deps
Exemplo n.º 2
0
 def get_auto_deps(self, items):
     deps = []
     for item in items:
         if item.ITEM_TYPE_NAME == "file" and is_subdirectory(item.name, self.name):
             raise BundleError(
                 _("{item1} (from bundle '{bundle1}') blocking path to " "{item2} (from bundle '{bundle2}')").format(
                     item1=item.id, bundle1=item.bundle.name, item2=self.id, bundle2=self.bundle.name
                 )
             )
         elif item.ITEM_TYPE_NAME == "user" and item.name == self.attributes["owner"]:
             if item.attributes["delete"]:
                 raise BundleError(
                     _(
                         "{item1} (from bundle '{bundle1}') depends on item "
                         "{item2} (from bundle '{bundle2}') which is set to be deleted"
                     ).format(item1=self.id, bundle1=self.bundle.name, item2=item.id, bundle2=item.bundle.name)
                 )
             else:
                 deps.append(item.id)
         elif item.ITEM_TYPE_NAME == "group" and item.name == self.attributes["group"]:
             if item.attributes["delete"]:
                 raise BundleError(
                     _(
                         "{item1} (from bundle '{bundle1}') depends on item "
                         "{item2} (from bundle '{bundle2}') which is set to be deleted"
                     ).format(item1=self.id, bundle1=self.bundle.name, item2=item.id, bundle2=item.bundle.name)
                 )
             else:
                 deps.append(item.id)
         elif item.ITEM_TYPE_NAME in ("directory", "symlink"):
             if is_subdirectory(item.name, self.name):
                 deps.append(item.id)
     return deps
Exemplo n.º 3
0
 def get_auto_deps(self, items):
     deps = []
     for item in items:
         if item == self:
             continue
         if ((
                 item.ITEM_TYPE_NAME == "file" and
                 is_subdirectory(item.name, self.name)
             ) or (
                 item.ITEM_TYPE_NAME in ("file", "symlink") and
                 item.name == self.name
         )):
             raise BundleError(_(
                 "{item1} (from bundle '{bundle1}') blocking path to "
                 "{item2} (from bundle '{bundle2}')"
             ).format(
                 item1=item.id,
                 bundle1=item.bundle.name,
                 item2=self.id,
                 bundle2=self.bundle.name,
             ))
         elif item.ITEM_TYPE_NAME == "user" and item.name == self.attributes['owner']:
             if item.attributes['delete']:
                 raise BundleError(_(
                     "{item1} (from bundle '{bundle1}') depends on item "
                     "{item2} (from bundle '{bundle2}') which is set to be deleted"
                 ).format(
                     item1=self.id,
                     bundle1=self.bundle.name,
                     item2=item.id,
                     bundle2=item.bundle.name,
                 ))
             else:
                 deps.append(item.id)
         elif item.ITEM_TYPE_NAME == "group" and item.name == self.attributes['group']:
             if item.attributes['delete']:
                 raise BundleError(_(
                     "{item1} (from bundle '{bundle1}') depends on item "
                     "{item2} (from bundle '{bundle2}') which is set to be deleted"
                 ).format(
                     item1=self.id,
                     bundle1=self.bundle.name,
                     item2=item.id,
                     bundle2=item.bundle.name,
                 ))
             else:
                 deps.append(item.id)
         elif item.ITEM_TYPE_NAME in ("directory", "symlink"):
             if is_subdirectory(item.name, self.name):
                 deps.append(item.id)
     return deps
Exemplo n.º 4
0
 def get_auto_deps(self, items):
     deps = set()
     for item in items:
         if item == self:
             continue
         if ((item.ITEM_TYPE_NAME == "file"
              and is_subdirectory(item.name, self.name))
                 or (item.ITEM_TYPE_NAME in ("file", "symlink")
                     and item.name == self.name)):
             raise BundleError(
                 _("{item1} (from bundle '{bundle1}') blocking path to "
                   "{item2} (from bundle '{bundle2}')").format(
                       item1=item.id,
                       bundle1=item.bundle.name,
                       item2=self.id,
                       bundle2=self.bundle.name,
                   ))
         if (item.ITEM_TYPE_NAME == "directory" and item.name == self.name):
             if item.attributes['purge']:
                 raise BundleError(
                     _("cannot git_deploy into purged directory {}").format(
                         item.name))
             else:
                 deps.add(item.id)
     return deps
Exemplo n.º 5
0
 def test_relative(self):
     with self.assertRaises(ValueError):
         text.is_subdirectory("/foo", "bar")
Exemplo n.º 6
0
 def test_slash(self):
     self.assertFalse(text.is_subdirectory("/foo", "/foo\/bar"))
Exemplo n.º 7
0
 def test_identical(self):
     self.assertFalse(text.is_subdirectory("/foo", "/foo"))
Exemplo n.º 8
0
 def test_root(self):
     self.assertTrue(text.is_subdirectory("/", "/foo"))
Exemplo n.º 9
0
 def test_simple_substr(self):
     self.assertFalse(text.is_subdirectory("/foo/bar", "/foo/barbaz"))
Exemplo n.º 10
0
 def test_simple_subdir(self):
     self.assertTrue(text.is_subdirectory("/foo/bar", "/foo/bar/baz"))