MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / get_file_info

Function get_file_info

src/scancode/api.py:339–368  ·  view source on GitHub ↗

Return a mapping of file information collected for the file at `location`.

(location, **kwargs)

Source from the content-addressed store, hash-verified

337
338
339def get_file_info(location, **kwargs):
340 """
341 Return a mapping of file information collected for the file at `location`.
342 """
343 result = {}
344
345 # TODO: move date and size these to the inventory collection step???
346 result['date'] = get_last_modified_date(location) or None
347 result['size'] = getsize(location) or 0
348
349 sha1, md5, sha256, sha1_git = multi_checksums(
350 location=location,
351 checksum_names=('sha1', 'md5', 'sha256', 'sha1_git')
352 ).values()
353 result['sha1'] = sha1
354 result['md5'] = md5
355 result['sha256'] = sha256
356 result['sha1_git'] = sha1_git
357
358 collector = get_type(location)
359 result['mime_type'] = collector.mimetype_file or None
360 result['file_type'] = collector.filetype_file or None
361 result['programming_language'] = collector.programming_language or None
362 result['is_binary'] = bool(collector.is_binary)
363 result['is_text'] = bool(collector.is_text)
364 result['is_archive'] = bool(collector.is_archive)
365 result['is_media'] = bool(collector.is_media)
366 result['is_source'] = bool(collector.is_source)
367 result['is_script'] = bool(collector.is_script)
368 return result

Callers

nothing calls this directly

Calls 5

get_last_modified_dateFunction · 0.90
multi_checksumsFunction · 0.90
get_typeFunction · 0.85
boolFunction · 0.85
valuesMethod · 0.45

Tested by

no test coverage detected