MCPcopy Index your code
hub / github.com/aws/aws-cli / OSUtils

Class OSUtils

awscli/s3transfer/utils.py:252–337  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

250
251
252class OSUtils:
253 _MAX_FILENAME_LEN = 255
254
255 def get_file_size(self, filename):
256 return os.path.getsize(filename)
257
258 def open_file_chunk_reader(self, filename, start_byte, size, callbacks):
259 return ReadFileChunk.from_filename(
260 filename, start_byte, size, callbacks, enable_callbacks=False
261 )
262
263 def open_file_chunk_reader_from_fileobj(
264 self,
265 fileobj,
266 chunk_size,
267 full_file_size,
268 callbacks,
269 close_callbacks=None,
270 ):
271 return ReadFileChunk(
272 fileobj,
273 chunk_size,
274 full_file_size,
275 callbacks=callbacks,
276 enable_callbacks=False,
277 close_callbacks=close_callbacks,
278 )
279
280 def open(self, filename, mode):
281 return open(filename, mode)
282
283 def remove_file(self, filename):
284 """Remove a file, noop if file does not exist."""
285 # Unlike os.remove, if the file does not exist,
286 # then this method does nothing.
287 try:
288 os.remove(filename)
289 except OSError:
290 pass
291
292 def rename_file(self, current_filename, new_filename):
293 rename_file(current_filename, new_filename)
294
295 def is_special_file(cls, filename):
296 """Checks to see if a file is a special UNIX file.
297
298 It checks if the file is a character special device, block special
299 device, FIFO, or socket.
300
301 :param filename: Name of the file
302
303 :returns: True if the file is a special file. False, if is not.
304 """
305 # If it does not exist, it must be a new file so it cannot be
306 # a special file.
307 if not os.path.exists(filename):
308 return False
309 mode = os.stat(filename).st_mode

Callers 15

_create_s3_transferMethod · 0.90
setUpMethod · 0.90
setUpMethod · 0.90
setUpMethod · 0.90
test_get_file_sizeMethod · 0.90
test_open_fileMethod · 0.90
test_rename_fileMethod · 0.90
setUpMethod · 0.90

Calls

no outgoing calls

Tested by 15

_create_s3_transferMethod · 0.72
setUpMethod · 0.72
setUpMethod · 0.72
test_get_file_sizeMethod · 0.72
test_open_fileMethod · 0.72
test_rename_fileMethod · 0.72
setUpMethod · 0.72
setUpMethod · 0.72