MCPcopy Create free account
hub / github.com/s3tools/s3cmd / InvalidationBatch

Class InvalidationBatch

S3/CloudFront.py:280–327  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

278 return str(self.info)
279
280class InvalidationBatch(object):
281 ## Example:
282 ##
283 ## <InvalidationBatch>
284 ## <Path>/image1.jpg</Path>
285 ## <Path>/image2.jpg</Path>
286 ## <Path>/videos/movie.flv</Path>
287 ## <Path>/sound%20track.mp3</Path>
288 ## <CallerReference>my-batch</CallerReference>
289 ## </InvalidationBatch>
290
291 def __init__(self, reference = None, distribution = None, paths = []):
292 if reference:
293 self.reference = reference
294 else:
295 if not distribution:
296 distribution="0"
297 self.reference = "%s.%s.%s" % (distribution,
298 datetime.strftime(datetime.now(),"%Y%m%d%H%M%S"),
299 random.randint(1000,9999))
300 self.paths = []
301 self.add_objects(paths)
302
303 def add_objects(self, paths):
304 self.paths.extend(paths)
305
306 def get_reference(self):
307 return self.reference
308
309 def get_printable_tree(self):
310 tree = ET.Element("InvalidationBatch")
311 for path in self.paths:
312 if len(path) < 1 or path[0] != "/":
313 path = "/" + path
314 appendXmlTextNode("Path", path, tree)
315 appendXmlTextNode("CallerReference", self.reference, tree)
316 return tree
317
318 def __unicode__(self):
319 return decode_from_s3(ET.tostring(self.get_printable_tree()))
320
321 def __str__(self):
322 if PY3:
323 # Return unicode
324 return ET.tostring(self.get_printable_tree(), encoding="unicode")
325 else:
326 # Return bytes
327 return ET.tostring(self.get_printable_tree())
328
329class CloudFront(object):
330 operations = {

Callers 1

InvalidateObjectsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…