1

I have a folder with Python source code. All files are being opened with double click with Text Editor, also the "problematic" one. All files have .py extension.

The "problematic" file has a green Qt icon and I didn't find a way to remove it. Reset and set default application (that now is Text Editor) didn't help.

Ubuntu 20.04

enter image description here

$ file -i MyHTMLParser.py 
MyHTMLParser.py: text/x-python; charset=us-ascii

$ file MyHTMLParser.py 
MyHTMLParser.py: Python script, ASCII text executable

$ file -i Scanner.py 
Scanner.py: text/x-python; charset=utf-8

$ file Scanner.py 
Scanner.py: Python script, UTF-8 Unicode text executable, with CRLF line terminators

First line of MyHTMLParser.py:

from html.parser import HTMLParser

First line of Scanner.py:

from PyQt5 import QtCore

text/x-qml MIME type is shown from Properties

enter image description here

That type is not present in

/etc/mime.types

I really can't understand where that information is stored.

UPDATED 'N'

I wrote a script that remove all \r\n line endings and UTF-8 characters. Now Scanner_new.py has the same type of MyHTMLParser.py, but nothing is changed:

$ file -i MyHTMLParser.py 
MyHTMLParser.py: text/x-python; charset=us-ascii

$ file MyHTMLParser.py 
MyHTMLParser.py: Python script, ASCII text executable

$ file -i Scanner_new.py 
Scanner_new.py: text/x-python; charset=us-ascii

$ file Scanner_new.py 
Scanner_new.py: Python script, ASCII text executable

enter image description here

2
  • 1
    Could you run the file commands on both files ? In linux the file extension (here .py) havr no meaning. The file type is found by analyzing the start of the file - for script code by looking at the she-bang in first line, so maybe also check that for differences.
    – Soren A
    Oct 14, 2021 at 14:59
  • Updated OP. Maybe the problem is that Scanner.py was edited also on Windows? It is a multiplatform application, but where is stored that information??? I'll write a script that replace \r\n line endings with \r, then try to remove UTF-8 characters
    – Francesco
    Oct 14, 2021 at 15:58

1 Answer 1

1

I found the solution. The problem isn't the line ending or the characters set (UTF-8, ASCII...). If in the file there is the sentence "import QtCore" (never mind if as start line or in the middle of the file) the icon will be the Qt one.

enter image description here

I don't known who is responsible for the parsing, as soon as I click Ctrl+S (with or without "import QtCore") the icon changes

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .