Ejemplo n.º 1
0
 def test_shorten(self):
     self.assertEqual(
         '**.jill',
         safe_filename('jack',
                       '.jill',
                       digest=self.FixedDigest(2),
                       max_length=8))
Ejemplo n.º 2
0
 def test_shorten(self):
     self.assertEqual(
         "**.jill",
         safe_filename("jack",
                       ".jill",
                       digest=self.FixedDigest(2),
                       max_length=8))
Ejemplo n.º 3
0
def jarname(target, extension='.jar'):
  # TODO(John Sirois): incorporate version
  _, id_, _ = target.get_artifact_info()
  # Cap jar names quite a bit lower than the standard fs limit of 255 characters since these
  # artifacts will often be used outside pants and those uses may manipulate (expand) the jar
  # filenames blindly.
  return safe_filename(id_, extension, max_length=200)
Ejemplo n.º 4
0
def jarname(target, extension='.jar'):
  # TODO(John Sirois): incorporate version
  _, id_, _ = target.get_artifact_info()
  # Cap jar names quite a bit lower than the standard fs limit of 255 characters since these
  # artifacts will often be used outside pants and those uses may manipulate (expand) the jar
  # filenames blindly.
  return safe_filename(id_, extension, max_length=200)
Ejemplo n.º 5
0
 def test_shorten_readable(self):
     self.assertEqual(
         "j.**.e.jill",
         safe_filename("jackalope",
                       ".jill",
                       digest=self.FixedDigest(2),
                       max_length=11),
     )
Ejemplo n.º 6
0
 def test_shorten_fail(self):
     with self.assertRaises(ValueError):
         safe_filename("jack",
                       ".beanstalk",
                       digest=self.FixedDigest(3),
                       max_length=12)
Ejemplo n.º 7
0
def test_shorten_readable() -> None:
    assert "j.**.e.jill" == safe_filename("jackalope",
                                          ".jill",
                                          digest=FixedDigest(2),
                                          max_length=11)
Ejemplo n.º 8
0
 def test_noop(self):
     self.assertEqual('jack.jill',
                      safe_filename('jack', '.jill', max_length=9))
     self.assertEqual('jack.jill',
                      safe_filename('jack', '.jill', max_length=100))
Ejemplo n.º 9
0
 def compute_target_id(cls, address):
     """Computes a target id from the given address."""
     return safe_filename(address.path_safe_spec)
Ejemplo n.º 10
0
 def test_shorten(self):
   self.assertEqual('**.jill',
                    safe_filename('jack', '.jill', digest=self.FixedDigest(2), max_length=8))
Ejemplo n.º 11
0
 def compute_target_id(cls, address):
   """Computes a target id from the given address."""
   return safe_filename(address.path_safe_spec)
Ejemplo n.º 12
0
 def test_shorten_readable(self):
   self.assertEqual('j.**.e.jill',
                    safe_filename('jackalope', '.jill', digest=self.FixedDigest(2), max_length=11))
Ejemplo n.º 13
0
 def test_shorten_fail(self):
     with self.assertRaises(ValueError):
         safe_filename("jack", ".beanstalk", digest=self.FixedDigest(3), max_length=12)
Ejemplo n.º 14
0
 def test_shorten(self):
     self.assertEqual("**.jill", safe_filename("jack", ".jill", digest=self.FixedDigest(2), max_length=8))
Ejemplo n.º 15
0
 def test_noop(self):
     self.assertEqual("jack.jill", safe_filename("jack", ".jill", max_length=9))
     self.assertEqual("jack.jill", safe_filename("jack", ".jill", max_length=100))
Ejemplo n.º 16
0
 def test_bad_name(self):
     with self.assertRaises(ValueError):
         safe_filename(os.path.join("more", "than", "a", "name.game"))
Ejemplo n.º 17
0
def test_shorten_fail() -> None:
    with pytest.raises(ValueError):
        safe_filename("jack",
                      ".beanstalk",
                      digest=FixedDigest(3),
                      max_length=12)
Ejemplo n.º 18
0
 def test_bad_name(self):
   with pytest.raises(ValueError):
     safe_filename(os.path.join('more', 'than', 'a', 'name.game'))
Ejemplo n.º 19
0
 def test_noop(self):
   self.assertEqual('jack.jill', safe_filename('jack', '.jill', max_length=9))
   self.assertEqual('jack.jill', safe_filename('jack', '.jill', max_length=100))
Ejemplo n.º 20
0
 def test_shorten_readable(self):
   self.assertEqual('j.**.e.jill',
                    safe_filename('jackalope', '.jill', digest=self.FixedDigest(2), max_length=11))
Ejemplo n.º 21
0
 def test_shorten_fail(self):
   with pytest.raises(ValueError):
     safe_filename('jack', '.beanstalk', digest=self.FixedDigest(3), max_length=12)
Ejemplo n.º 22
0
 def test_bad_name(self):
     with self.assertRaises(ValueError):
         safe_filename(os.path.join("more", "than", "a", "name.game"))
Ejemplo n.º 23
0
 def _sha_file_by_id(self, id):
     return os.path.join(self._root, safe_filename(id, extension='.hash'))
Ejemplo n.º 24
0
 def test_shorten_fail(self):
     with pytest.raises(ValueError):
         safe_filename('jack',
                       '.beanstalk',
                       digest=self.FixedDigest(3),
                       max_length=12)
Ejemplo n.º 25
0
 def test_bad_name(self):
     with pytest.raises(ValueError):
         safe_filename(os.path.join('more', 'than', 'a', 'name.game'))
Ejemplo n.º 26
0
def test_noop() -> None:
    assert "jack.jill" == safe_filename("jack", ".jill", max_length=9)
    assert "jack.jill" == safe_filename("jack", ".jill", max_length=100)
Ejemplo n.º 27
0
 def test_noop(self):
     self.assertEqual("jack.jill",
                      safe_filename("jack", ".jill", max_length=9))
     self.assertEqual("jack.jill",
                      safe_filename("jack", ".jill", max_length=100))
Ejemplo n.º 28
0
def test_shorten() -> None:
    assert "**.jill" == safe_filename("jack",
                                      ".jill",
                                      digest=FixedDigest(2),
                                      max_length=8)
Ejemplo n.º 29
0
 def _sha_file_by_id(self, id):
   return os.path.join(self._root, safe_filename(id, extension='.hash'))
Ejemplo n.º 30
0
def test_bad_name() -> None:
    with pytest.raises(ValueError):
        safe_filename(os.path.join("more", "than", "a", "name.game"))