Skip to content

Commit

Permalink
python3.8 quick fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
znick committed Dec 7, 2023
1 parent 56d7d58 commit 9460698
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
14 changes: 6 additions & 8 deletions anytask/anyrb/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def upload_review_unsafe(self):

with unpack_files(self.event.file_set.all()) as files:
for f in files:
mime_type = magic.from_buffer(f.file.read(1024), mime=True)
mime_type = magic.from_buffer(f.file.read(2048), mime=True)
if mime_type[:4] != 'text':
continue

Expand All @@ -54,22 +54,20 @@ def upload_review_unsafe(self):

from difflib import unified_diff
fname = f.filename()
from_name = u'a/{0}'.format(fname)
to_name = u'b/{0}'.format(fname)
from_name = 'a/{0}'.format(fname)
to_name = 'b/{0}'.format(fname)

diff = [(u'diff --git {0} {1}'.format(from_name, to_name))]
from_name = u'/dev/null'

diff_content = unified_diff('',
file_content,
fromfile=from_name,
tofile=to_name.encode('utf-8'))
tofile=to_name)

for line in diff_content:
line = line.strip()
if isinstance(line, str):
diff.append(line.decode('utf-8'))
else:
diff.append(line)
diff.append(line)

files_diff.append(u'\n'.join(diff))

Expand Down
2 changes: 1 addition & 1 deletion anytask/anyrb/unpacker.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def __init__(self, path, filename):

@property
def file(self):
return open(self.path)
return open(self.path, 'rb')

def filename(self):
return self._filename
Expand Down
2 changes: 1 addition & 1 deletion anytask/settings_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
LANGUAGES = (('ru', u'Русский'),
('en', 'English'))

FILE_UPLOAD_PERMISSIONS = 644 # 0644
# FILE_UPLOAD_PERMISSIONS = 644 # 0644


AWS_ACCESS_KEY_ID = os.environ.get('AWS_ACCESS_KEY_ID')
Expand Down

0 comments on commit 9460698

Please sign in to comment.