mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 22:51:32 +00:00
Remove extension -> language mapping from backend (move to frontend)
This commit is contained in:
parent
a7e2a08166
commit
ade210c4fc
@ -14,13 +14,11 @@ class FileManager:
|
||||
self.exclude = ['__pycache__']
|
||||
self._workdir = working_directory
|
||||
self.filename = selected_file or self._relpath(self.files[0])
|
||||
self.language = map_file_extension_to_language(self.filename)
|
||||
|
||||
def select_file(self, filename):
|
||||
if not filename in self.files:
|
||||
raise EnvironmentError('No such file in workdir!')
|
||||
self.filename = filename
|
||||
self.language = map_file_extension_to_language(self.filename)
|
||||
|
||||
@property
|
||||
def files(self):
|
||||
@ -81,7 +79,6 @@ class SourceCodeEventHandler(EventHandlerBase, SupervisorMixin):
|
||||
|
||||
def attach_fileinfo(self, data):
|
||||
data['filename'] = self.filemanager.filename
|
||||
data['language'] = self.filemanager.language
|
||||
data['files'] = self.filemanager.files
|
||||
|
||||
def handle_event(self, anchor, data_json):
|
||||
@ -92,20 +89,3 @@ class SourceCodeEventHandler(EventHandlerBase, SupervisorMixin):
|
||||
|
||||
def cleanup(self):
|
||||
self.monitor.stop()
|
||||
|
||||
|
||||
def map_file_extension_to_language(filename):
|
||||
language_map = {
|
||||
'.py': 'python',
|
||||
'.js': 'javascript',
|
||||
'.html': 'html',
|
||||
'.css': 'css',
|
||||
'.java': 'java',
|
||||
'.cpp': 'c_cpp',
|
||||
'.hpp': 'c_cpp',
|
||||
'.c': 'c_cpp',
|
||||
'.h': 'c_cpp',
|
||||
'.cs': 'csharp'
|
||||
}
|
||||
_, extension = splitext(filename)
|
||||
return language_map.get(extension, 'text')
|
Loading…
Reference in New Issue
Block a user