File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -743,6 +743,9 @@ def is_source(self):
743743 return False
744744
745745 elif self .is_java_source is True or self .is_c_source is True :
746+ return False
747+ # Combined check for all specifically recognized source types
748+ elif self .is_java_source or self .is_c_source or self .is_julia_source :
746749 return True
747750
748751 elif self .filetype_pygment or self .is_script is True :
@@ -758,9 +761,19 @@ def programming_language(self):
758761 string.
759762 """
760763 if self .is_source :
764+ # If the custom extension check found Julia, use that name explicitly
765+ if self .is_julia_source :
766+ return "Julia"
761767 return self .filetype_pygment or ""
762768 return ""
763769
770+ @property
771+ def is_julia_source (self ):
772+ """
773+ Return True if the file is Julia source code based on .jl extension.
774+ """
775+ return self .is_file and self .location .lower ().endswith (".jl" )
776+
764777 @property
765778 def is_c_source (self ):
766779 C_EXTENSIONS = set (
Original file line number Diff line number Diff line change @@ -230,6 +230,17 @@ def test_compiled_elf_so_2(self):
230230 assert get_filetype (test_file ) in expected
231231 assert get_filetype_pygment (test_file ) == ""
232232
233+ def test_programming_language_detection_for_julia (self ):
234+ # Create a temporary julia file
235+ test_file = self .get_temp_file ('test.jl' )
236+ with open (test_file , 'w' ) as f :
237+ f .write ('println("Hello Julia")' )
238+
239+ # Get the type and check identification
240+ T = get_type (test_file )
241+ assert is_source (test_file )
242+ assert T .programming_language == "Julia"
243+
233244 @pytest .mark .xfail (
234245 on_mac or on_windows ,
235246 reason = "Somehow we get really weird results on macOS with libmagic 5.38 and mac, win32 on libmagic 5.39: "
You can’t perform that action at this time.
0 commit comments