markup: move functionality to library

This commit is contained in:
2019-10-18 15:14:05 -07:00
parent 5282f7cb2f
commit 94c1a419dc
5 changed files with 104 additions and 24 deletions

View File

@ -1,3 +1,7 @@
import os
import shutil
def pdf_rect(rect, container_height):
x1 = min(rect[0], rect[2])
y1 = max(rect[1], rect[3])
@ -64,3 +68,15 @@ class Rect(object):
def __repr__(self):
return 'Rect[l={}, t={}, r={}, b={}]'.format(int(self.left), int(self.top), int(self.right), int(self.bottom))
def ensure_dir(dir):
if not os.path.exists(dir):
os.makedirs(dir)
os.chmod(dir, 0o775)
shutil.chown(dir, group='procat')
def set_file_perms(file):
os.chmod(file, 0o664)
shutil.chown(file, group='procat')