Changes between Version 2 and Version 4 of Ticket #2138


Ignore:
Timestamp:
2013-12-18T00:04:53Z (11 years ago)
Author:
zooko
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #2138 – Description

    v2 v4  
    1 This makes it so that emacs knows the intended character encoding, BOM,
    2 end-of-line markers, and standard line-width of these files.
     1This makes it so that emacs knows the intended character encoding, BOM, end-of-line markers, standard line-width, and tabs-vs-spaces policy for these files.
    32
    4 Also this is a form of documentation. It means that you should put only
    5 utf-8-encoded things into text files, only utf-8-encoded things into source
    6 code files (and actually you should write only put ASCII-encoded things except
    7 possibly in comments or docstrings!), and that you should line-wrap everything
    8 at 77 columns wide.
     3This is also a form of documentation. It means that you should put only utf-8-encoded things into text files, only utf-8-encoded things into source code files (and actually you should write only put ASCII-encoded things except possibly in comments or docstrings!), and that you should line-wrap everything at 77 columns wide.
    94
    10 It also specifies that text files should start with a "utf-8 BOM". (Brian
    11 questions the point of this, and my answer is that it adds information and
    12 doesn't hurt. Whether that information will ever be useful is an open
    13 question.)
     5It also specifies that text files should start with a "utf-8 BOM". (Brian questions the point of this, and my answer is that it adds information and doesn't hurt. Whether that information will ever be useful is an open question.)
    146
    15 It also specifies that text files should have unix-style ('\n') end-of-line
    16 markers, not windows-style or old-macos-style.
     7It also specifies that text files should have unix-style end-of-line markers (i.e. '\n'), not windows-style or old-macos-style.
    178
    18 I generated this patch by writing and running the following script, and then
    19 reading the resulting diff to make sure it was correct. I then undid the
    20 changes that the script had done to the files inside the
    21 "setuptools-0.6c16dev4.egg" directory before committing the patch.
     9For Python source code files, it also specifies that you should not insert tab characters (so you should use spaces for Python block structure).
    2210
     11I generated this patch by writing and running the following script, and then reading the resulting diff to make sure it was correct. I then undid the changes that the script had done to the files inside the "setuptools-0.6c16dev4.egg" directory before committing the patch.
     12
     13------- begin appended script::
    2314{{{
     15#!/usr/bin/env python
     16# -*- coding: utf-8-with-signature-unix; fill-column: 77 -*-
     17
    2418import os
    2519
     
    4034
    4135                if len(formattedlines) == 0:
    42                     return
     36                    continue
    4337
    4438                outfo = open(fname, 'w')
     
    5246                if firstline.startswith(u"#!"):
    5347                    outfo.write(firstline.encode('utf-8'))
    54                     outfo.write(commentsign.encode('utf-8'))
    55                     outfo.write("-*- coding: utf-8-with-signature-unix; fill-column: 77 -*-\n".encode('utf-8'))
     48                    outfo.write(commentsign+"-*- coding: utf-8-with-signature-unix; fill-column: 77 -*-\n".encode('utf-8'))
     49                    if ext == '.py':
     50                        outfo.write(commentsign+"-*- indent-tabs-mode: nil -*-\n".encode('utf-8'))
    5651                else:
    57                     outfo.write(commentsign.encode('utf-8'))
    58                     outfo.write("-*- coding: utf-8-with-signature-unix; fill-column: 77 -*-\n".encode('utf-8'))
    59                     if (commentsign in firstline) and ("-*-" in firstline) and ("coding:" in firstline):
     52                    outfo.write(commentsign+"-*- coding: utf-8-with-signature-unix; fill-column: 77 -*-\n".encode('utf-8'))
     53                    if ext == '.py':
     54                        outfo.write(commentsign+"-*- indent-tabs-mode: nil -*-\n".encode('utf-8'))
     55                    if (firstline.strip().startswith(commentsign)) and ("-*-" in firstline) and ("coding:" in firstline):
    6056                        print "warning there was already a coding line %r in %r"  % (firstline, fname)
    6157                    else:
     
    6359
    6460                for l in formattedlines:
    65                     if (commentsign in l) and ("-*-" in l) and ("coding:" in l):
     61                    if (l.strip().startswith(commentsign)) and ("-*-" in l) and ("coding:" in l):
    6662                        print "warning there was already a coding line %r in %r"  % (l, fname)
    6763                    else: