Skip to content
Snippets Groups Projects
Commit 1992c746 authored by magnus2142's avatar magnus2142
Browse files

removed magic dependecy and used pythons mimetypes library

parent 356eb263
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,7 @@ import json
import os
from typing import Dict, List
import requests
import magic
import mimetypes
from bbcli.utils.URL_builder import Builder, URL_builder
from bbcli.services.utils.content_builder import ContentBuilder
from bbcli.entities.content_builder_entitites import FileContent, GradingOptions, StandardOptions, FileOptions, WeblinkOptions
......@@ -124,13 +124,15 @@ def create_file(session: requests.Session, course_id: str, parent_id: str, title
file_dst: str, file_options: FileOptions, standard_options: StandardOptions) -> Dict:
uploaded_file = upload_file(session, file_dst)
mime = magic.Magic(mime=True)
mime_type = mime.from_file(file_dst)
with open(file_dst, 'rb') as f:
file_name = os.path.basename(f.name)
mime_type = mimetypes.guess_type(f.name)
file_content = FileContent(uploaded_file['id'], file_name, mime_type)
if mime_type:
file_content = FileContent(uploaded_file['id'], file_name, mime_type[0])
else:
click.Abort()
data = content_builder\
.add_parent_id(parent_id)\
......
......@@ -8,7 +8,6 @@ beautifulsoup4==4.10.0
lxml==4.8.0
anytree==2.8.0
html2text==2020.1.16
python-magic==0.4.25
python-dateutil==2.8.2
tabulate==0.8.9
pwinput==1.0.2
......
......@@ -19,7 +19,6 @@ requires = [
'shellingham',
'anytree',
'html2text',
'python-magic',
'python-dateutil',
'tabulate==0.8.9',
'pwinput',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment