forked from importers/git-importer
Move modules into lib subdir
This commit is contained in:
86
lib/binary.py
Normal file
86
lib/binary.py
Normal file
@@ -0,0 +1,86 @@
|
||||
import pathlib
|
||||
|
||||
BINARY = {
|
||||
".7z",
|
||||
".bsp",
|
||||
".bz2",
|
||||
".gem",
|
||||
".gz",
|
||||
".jar",
|
||||
".lz",
|
||||
".lzma",
|
||||
".obscpio",
|
||||
".oxt",
|
||||
".pdf",
|
||||
".png",
|
||||
".rpm",
|
||||
".tbz",
|
||||
".tbz2",
|
||||
".tgz",
|
||||
".ttf",
|
||||
".txz",
|
||||
".whl",
|
||||
".xz",
|
||||
".zip",
|
||||
".zst",
|
||||
}
|
||||
|
||||
|
||||
def is_binary_or_large(filename, size):
|
||||
"""Decide if is a binary file based on the extension or size"""
|
||||
binary_suffix = BINARY
|
||||
non_binary_suffix = {
|
||||
".1",
|
||||
".8",
|
||||
".SUSE",
|
||||
".asc",
|
||||
".c",
|
||||
".cabal",
|
||||
".cfg",
|
||||
".changes",
|
||||
".conf",
|
||||
".desktop",
|
||||
".dif",
|
||||
".diff",
|
||||
".dsc",
|
||||
".el",
|
||||
".html",
|
||||
".in",
|
||||
".init",
|
||||
".install",
|
||||
".keyring",
|
||||
".kiwi",
|
||||
".logrotate",
|
||||
".macros",
|
||||
".md",
|
||||
".obsinfo",
|
||||
".pamd",
|
||||
".patch",
|
||||
".pl",
|
||||
".pom",
|
||||
".py",
|
||||
".rpmlintrc",
|
||||
".rules",
|
||||
".script",
|
||||
".service",
|
||||
".sh",
|
||||
".sig",
|
||||
".sign",
|
||||
".spec",
|
||||
".sysconfig",
|
||||
".test",
|
||||
".txt",
|
||||
".xml",
|
||||
".xml",
|
||||
".yml",
|
||||
}
|
||||
|
||||
suffix = pathlib.Path(filename).suffix
|
||||
if suffix in binary_suffix:
|
||||
return True
|
||||
if suffix in non_binary_suffix:
|
||||
return False
|
||||
if size >= 6 * 1024:
|
||||
return True
|
||||
|
||||
return False
|
Reference in New Issue
Block a user