Skip to content

Commit 4a3ac22

Browse files
committed
Fixing formatting and minimal pep8
1 parent 64cd61d commit 4a3ac22

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

about_code_tool/genattrib.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,13 @@
2525
from about import Collector
2626
import genabout
2727

28-
import codecs
2928
import csv
3029
import errno
31-
import fnmatch
32-
import getopt
33-
import httplib
3430
import logging
3531
import optparse
36-
import posixpath
37-
import socket
38-
import string
3932
import sys
40-
import urlparse
4133

42-
from collections import namedtuple
43-
from datetime import datetime
44-
from email.parser import HeaderParser
45-
from os import listdir, walk
46-
from os.path import exists, dirname, join, abspath, isdir, basename, normpath
47-
from StringIO import StringIO
34+
from os.path import exists, dirname, join, abspath, isdir, basename
4835

4936
LOG_FILENAME = 'error.log'
5037

@@ -75,12 +62,13 @@
7562
limitations under the License.
7663
"""
7764

65+
7866
def component_subset_to_sublist(input_list):
79-
sublist = []
8067
sublist = [row["about_file"] for row in input_list
8168
if "about_file" in row.keys()]
8269
return sublist
8370

71+
8472
def update_path_to_about(input_list):
8573
output_list = []
8674
for row in input_list:
@@ -92,46 +80,54 @@ def update_path_to_about(input_list):
9280
output_list.append(row)
9381
return output_list
9482

83+
9584
def convert_dict_key_to_lower_case(input_list):
9685
output_list = []
9786
for line in input_list:
98-
dict = {}
87+
lower_dict = {}
9988
for key in line:
100-
dict[key.lower()] = line[key]
101-
output_list.append(dict)
89+
lower_dict[key.lower()] = line[key]
90+
output_list.append(lower_dict)
10291
return output_list
10392

93+
10494
def check_about_file_existance_and_format(input_list):
10595
try:
10696
for row in input_list:
107-
# Force the path to start with the '/' to map with the project structure
97+
# Force the path to start with the '/' to map with the project
98+
# structure
10899
if not row['about_file'].startswith('/'):
109100
row['about_file'] = '/' + row['about_file']
110101
return input_list
111-
except Exception as e:
102+
except Exception:
112103
return []
113104

105+
114106
USAGE_SYNTAX = """\
115107
Input can be a file or directory.
116108
Output of rendered template must be a file (e.g. .html).
117109
Component List must be a .csv file which has at least an "about_file" column.
118110
"""
119111

112+
120113
VERBOSITY_HELP = """\
121114
Print more or fewer verbose messages while processing ABOUT files
122115
0 - Do not print any warning or error messages, just a total count (default)
123116
1 - Print error messages
124117
2 - Print error and warning messages
125118
"""
126119

120+
127121
TEMPLATE_LOCATION_HELP = """\
128122
Use the custom template for the Attribution Generation
129123
"""
130124

125+
131126
MAPPING_HELP = """\
132127
Configure the mapping key from the MAPPING.CONFIG
133128
"""
134129

130+
135131
def main(parser, options, args):
136132
overwrite = options.overwrite
137133
verbosity = options.verbosity
@@ -167,7 +163,7 @@ def main(parser, options, args):
167163
# UnicodeEncodeError: 'ascii' codec can't encode character
168164
# FIXME: these two lines do not make sense
169165
reload(sys)
170-
sys.setdefaultencoding('utf-8')
166+
sys.setdefaultencoding('utf-8') # @UndefinedVariable
171167

172168
if not exists(input_path):
173169
print('Input path does not exist.')
@@ -235,6 +231,7 @@ def main(parser, options, args):
235231
# we should never reach this
236232
assert False, "Unsupported option(s)."
237233

234+
238235
def get_parser():
239236
class MyFormatter(optparse.IndentedHelpFormatter):
240237
def _format_text(self, text):
@@ -280,9 +277,12 @@ def format_option(self, option):
280277
help='Display current version, license notice, and copyright notice')
281278
parser.add_option('--overwrite', action='store_true',
282279
help='Overwrites the output file if it exists')
283-
parser.add_option('--verbosity', type=int, help=VERBOSITY_HELP)
284-
parser.add_option('--template_location', type='string', help=TEMPLATE_LOCATION_HELP)
285-
parser.add_option('--mapping', action='store_true', help=MAPPING_HELP)
280+
parser.add_option('--verbosity', type=int,
281+
help=VERBOSITY_HELP)
282+
parser.add_option('--template_location', type='string',
283+
help=TEMPLATE_LOCATION_HELP)
284+
parser.add_option('--mapping', action='store_true',
285+
help=MAPPING_HELP)
286286
return parser
287287

288288

0 commit comments

Comments
 (0)