~bkerensa/ubuntu-dev-tools/fix-for-1068049

« back to all changes in this revision

Viewing changes to wrap-and-sort

  • Committer: Benjamin Drung
  • Date: 2010-12-27 14:20:49 UTC
  • Revision ID: bdrung@ubuntu.com-20101227142049-gjhs9f9icj2c2q8o
Make pylint a little bit happier.

Show diffs side-by-side

added added

removed removed

Lines of Context:
87
87
 
88
88
class Install(object):
89
89
    def __init__(self, filename):
 
90
        self.content = None
 
91
        self.filename = None
90
92
        self.open(filename)
91
93
 
92
94
    def open(self, filename):
97
99
    def save(self, filename=None):
98
100
        if filename:
99
101
            self.filename = filename
100
 
        f = open(self.filename, "w")
101
 
        f.write("".join(self.content))
102
 
        f.close()
 
102
        install_file = open(self.filename, "w")
 
103
        install_file.write("".join(self.content))
 
104
        install_file.close()
103
105
 
104
106
    def sort(self):
105
107
        self.content = sorted(self.content)
120
122
    param = [x for x in unsorted_list if x.startswith("${")]
121
123
    return sorted(normal) + sorted(param)
122
124
 
123
 
def main(options):
 
125
def wrap_and_sort(options):
124
126
    debdir = lambda x: os.path.join(options.debian_directory, x)
125
127
 
126
 
    control_files = filter(os.path.isfile,
127
 
                           [debdir("control"), debdir("control.in")])
 
128
    possible_control_files = [debdir("control"), debdir("control.in")]
 
129
    control_files = [f for f in possible_control_files if os.path.isfile(f)]
128
130
    for control_file in control_files:
129
131
        if options.verbose:
130
132
            print control_file
135
137
                              options.sort_binary_packages, options.keep_first)
136
138
        control.save()
137
139
 
138
 
    copyright_files = filter(os.path.isfile,
139
 
                             [debdir("copyright"), debdir("copyright.in")])
 
140
    possible_copyright_files = [debdir("copyright"), debdir("copyright.in")]
 
141
    copyright_files = [f for f in possible_copyright_files if os.path.isfile(f)]
140
142
    for copyright_file in copyright_files:
141
143
        if options.verbose:
142
144
            print copyright_file
152
154
        install.sort()
153
155
        install.save()
154
156
 
155
 
if __name__ == "__main__":
 
157
def main():
156
158
    script_name = os.path.basename(sys.argv[0])
157
159
    usage = "%s [options]" % (script_name)
158
160
    epilog = "See %s(1) for more info." % (script_name)
196
198
                                                   options.debian_directory)
197
199
        sys.exit(1)
198
200
 
199
 
    main(options)
 
201
    wrap_and_sort(options)
 
202
 
 
203
if __name__ == "__main__":
 
204
    main()