Python Forum
a less challenging project idea
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
a less challenging project idea
#1
this one is not as hard as my last one. it is more about getting all the details right so it works correctly and gracefully in all cases. it processes a file. if names are given it first checks for any files it cannot process such as because the file is missing, lack of permission, or not enough space to write the result. it should abort for any error before processing any file, including the case of a duplicate file name. it MUST handle files with UTF-8 characters correctly (not mangling them and counting them correctly). it MUST work in Python3 because it MUST work when/where there is no Python2. if it also works in Python2, that's OK. if no file names are given, it reads stdin and writes the result to stdout.

the processing to do is untabify the file contents. it can support options to specify unusual tabs.

an advanced version will recognize tabified Python code and normalize it to accepted standards, eliminating the tabs and using normal indentation.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
There has been a script for normalizing python files for a long time, the reindent script, originally written by Tim Peters.

A missing part of your specs is to describe precisely what you mean by 'untabifying' the file's contents.
Reply
#3
my spec would start by specifying that it applies only to character streams that have a sense of horizontal position in their context, are considered text, and have one or more tab characters (as defined by ASCII or Unicode). then i need to define semantics. untabifying would mean to create an equivalent text character stream with zero tab characters.

how it is to behave with CR characters in the stream? i don't know.

other issues can apply in many programming languages, such as tabs inside quoted literals.

(Apr-05-2019, 09:47 AM)Gribouillis Wrote: There has been a script for normalizing python files for a long time, the reindent script, originally written by Tim Peters.

A missing part of your specs is to describe precisely what you mean by 'untabifying' the file's contents.

so, is that where we get Programmer named Tim?

he did not seem to address tabs in quoted literals.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Idea of project dibax10 2 2,075 Nov-26-2019, 08:57 PM
Last Post: dibax10
  a challenging project idea Skaperen 4 3,025 Apr-04-2019, 02:46 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020