mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-11-03 03:16:10 -06:00 
			
		
		
		
	Fixes how a language code like chi-sim is treated in the checks
This commit is contained in:
		@@ -1,3 +1,4 @@
 | 
				
			|||||||
 | 
					import shutil
 | 
				
			||||||
import subprocess
 | 
					import subprocess
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from django.conf import settings
 | 
					from django.conf import settings
 | 
				
			||||||
@@ -7,10 +8,16 @@ from django.core.checks import Warning
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def get_tesseract_langs():
 | 
					def get_tesseract_langs():
 | 
				
			||||||
    with subprocess.Popen(["tesseract", "--list-langs"], stdout=subprocess.PIPE) as p:
 | 
					    proc = subprocess.run(
 | 
				
			||||||
        stdout, stderr = p.communicate()
 | 
					        [shutil.which("tesseract"), "--list-langs"],
 | 
				
			||||||
 | 
					        capture_output=True,
 | 
				
			||||||
 | 
					    )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return stdout.decode().strip().split("\n")[1:]
 | 
					    # Decode bytes to string, split on newlines, trim out the header
 | 
				
			||||||
 | 
					    proc_lines = proc.stdout.decode("utf8", errors="ignore").strip().split("\n")[1:]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # Replace _ with - to convert two part languages to the expected code
 | 
				
			||||||
 | 
					    return [x.replace("_", "-") for x in proc_lines]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@register()
 | 
					@register()
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user