Skip to content

Commit 07342fa

Browse files
MarkusHackspacherespg
authored andcommitted
PEP8 improvements
demiangomez#111 Have some suggestions todo pep8
1 parent ccd7e09 commit 07342fa

File tree

1 file changed

+11
-28
lines changed

1 file changed

+11
-28
lines changed

com/AlterETM.py

+11-28
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ def print_params(cnn, stnlist):
8787
% (station['NetworkCode'], station['StationCode']), as_dict=True)
8888

8989
for p in params:
90-
print(' %s.%s %-5s %-5s %2i' \
91-
% (station['NetworkCode'], station['StationCode'], p['soln'], p['object'], p['terms']))
90+
print(' %s.%s %-5s %-5s %2i' % (station['NetworkCode'], station['StationCode'],
91+
p['soln'], p['object'], p['terms']))
9292

9393

9494
def insert_modify_param(parser, cnn, stnlist, args):
@@ -103,26 +103,16 @@ def insert_modify_param(parser, cnn, stnlist, args):
103103

104104
# create a bunch object to save all the params that will enter the database
105105
tpar = Bunch()
106-
tpar.NetworkCode = None
107-
tpar.StationCode = None
108-
tpar.soln = None
109-
tpar.object = None
110-
tpar.terms = None
111-
tpar.frequencies = None
112-
tpar.jump_type = None
113-
tpar.relaxation = None
114-
tpar.Year = None
115-
tpar.DOY = None
116-
tpar.action = None
106+
tpar.NetworkCode = tpar.StationCode = tpar.soln = tpar.object = tpar.terms = tpar.frequencies = None
107+
tpar.jump_type = tpar.relaxation = tpar.Year = tpar.DOY = tpar.action = None
117108

118109
ftype = args.function_type[0]
119-
remove_eq = False
120-
remove_mec = False
110+
remove_eq = remove_mec = False
121111

122112
try:
123113
if ftype == 'p':
124114
tpar.object = 'polynomial'
125-
tpar.terms = int(args.function_type[1])
115+
tpar.terms = int(args.function_type[1])
126116

127117
if tpar.terms <= 0:
128118
parser.error('polynomial terms should be > 0')
@@ -145,8 +135,7 @@ def insert_modify_param(parser, cnn, stnlist, args):
145135
date, _ = Utils.process_date([args.function_type[3]])
146136

147137
# recover the year and doy
148-
tpar.Year = date.year
149-
tpar.DOY = date.doy
138+
tpar.Year, tpar.DOY = date.year, date.doy
150139

151140
except Exception as e:
152141
parser.error('while parsing jump date: ' + str(e))
@@ -161,7 +150,7 @@ def insert_modify_param(parser, cnn, stnlist, args):
161150
parser.error('jump type == 1 but no relaxation parameter, please specify relaxation')
162151

163152
elif ftype == 'q':
164-
tpar.object = 'periodic'
153+
tpar.object = 'periodic'
165154
tpar.frequencies = [float(1/float(p)) for p in args.function_type[1:]]
166155

167156
elif ftype == 't':
@@ -178,7 +167,7 @@ def insert_modify_param(parser, cnn, stnlist, args):
178167
for soln in args.solution_type:
179168
tpar.NetworkCode = station['NetworkCode']
180169
tpar.StationCode = station['StationCode']
181-
tpar.soln = soln
170+
tpar.soln = soln
182171

183172
station_soln = "%s.%s (%s)" % (station['NetworkCode'], station['StationCode'], soln)
184173

@@ -197,8 +186,7 @@ def insert_modify_param(parser, cnn, stnlist, args):
197186
pyETM.CO_SEISMIC_JUMP)]:
198187
if eq.magnitude <= float(args.function_type[1]):
199188
# this earthquake should be removed, fill in the data
200-
tpar.Year = eq.date.year
201-
tpar.DOY = eq.date.doy
189+
tpar.Year, tpar.DOY = jump.date.year, jump.date.doy
202190
tpar.jump_type = 1
203191
tpar.relaxation = None
204192
tpar.action = '-'
@@ -222,8 +210,7 @@ def insert_modify_param(parser, cnn, stnlist, args):
222210

223211
if sdate[0] <= jump.date <= sdate[1]:
224212
# this jump should be removed, fill in the data
225-
tpar.Year = jump.date.year
226-
tpar.DOY = jump.date.doy
213+
tpar.Year, tpar.DOY = jump.date.year, jump.date.doy
227214
tpar.jump_type = 0
228215
tpar.relaxation = None
229216
tpar.action = '-'
@@ -244,11 +231,8 @@ def apply_change(cnn, station, tpar, soln):
244231
# check if solution exists for this station
245232
try:
246233
epar = cnn.get('etm_params', ppar, list(ppar.keys()))
247-
248234
print(' >> Found a set of matching parameters for station ' + station_soln)
249-
250235
print(' -- Deleting ' + station_soln)
251-
252236
cnn.delete('etm_params', **epar)
253237

254238
except Exception:
@@ -257,7 +241,6 @@ def apply_change(cnn, station, tpar, soln):
257241
cnn.insert('etm_params', **tpar)
258242
# insert replaces the uid field
259243
del tpar.uid
260-
261244
print(' -- Inserting %s for %s' % (tpar.object, station_soln))
262245

263246

0 commit comments

Comments
 (0)