You are only browsing one thread in the discussion! All comments are available on the post page.

Return

Moxvallix ,
@Moxvallix@sopuli.xyz avatar

Just checking over the list of supported files, does it preview just plain .txt files at all?

Nies221 OP ,
@Nies221@lemmy.world avatar

.txt or plain text files without extension are supported.

Moxvallix ,
@Moxvallix@sopuli.xyz avatar

Sweet.

ulfi ,
@ulfi@troet.cafe avatar

@Nies221 @Moxvallix
Do you use the info from 'file' command (api) ?

Nies221 OP ,
@Nies221@lemmy.world avatar

To get the size of archives and folders:
os.stat(filename).st_size # for folders you have to use it together with os.walk()

To get the list of files inside an archive I use the zipfile, rarfile and tarfile modules.
For the file type, I either extract the extension from the name or I use a bash command via subprocess:file --mime-type filepath
subprocess is used if there is no extension (as often happens with text files).

I preferred to use subprocess to avoid having to increase the number of dependencies needed.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • [email protected]
  • All magazines