Score:1

Same file type, different icon. How to reset it

us flag

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

Soren A avatar
mx flag
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.
Francesco avatar
us flag
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
Score:1
us flag

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

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.