Skip to content

Commit 0448475

Browse files
committed
Style changes
1 parent 78c351f commit 0448475

11 files changed

Lines changed: 171 additions & 158 deletions

File tree

‎setup.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ def _add_file(f):
6868
ext = Extension(
6969
name='softioc._extension',
7070
sources = sources,
71-
include_dirs=[epicscorelibs.path.include_path, devIocStats_src, devIocStats_os, devIocStats_default],
71+
include_dirs=[
72+
epicscorelibs.path.include_path,
73+
devIocStats_src, devIocStats_os, devIocStats_default
74+
],
7275
dsos = ['epicscorelibs.lib.dbCore', 'epicscorelibs.lib.Com'],
7376
define_macros = get_config_var('CPPFLAGS'),
7477
extra_compile_args = get_config_var('CXXFLAGS'),
@@ -96,5 +99,5 @@ def install_for_development(self):
9699
"numpy>=1.18",
97100
"epicsdbbuilder>=1.4"
98101
],
99-
zip_safe = False, # setuptools_dso is not compatible with eggs!
102+
zip_safe = False, # setuptools_dso is not compatible with eggs!
100103
)

‎softioc/__main__.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ def main(args=None):
1010
parser = ArgumentParser()
1111
parser.add_argument("--version", action="version", version=__version__)
1212
parser.add_argument("script", help="The python script to run")
13-
parser.add_argument("arg", help="Any arguments to pass to the script", nargs="*")
13+
parser.add_argument(
14+
"arg", help="Any arguments to pass to the script", nargs="*")
1415
parsed_args = parser.parse_args(args)
1516
# Execute as subprocess
16-
subprocess.Popen([sys.executable, parsed_args.script, *parsed_args.arg]).communicate()
17+
cmd = [sys.executable, parsed_args.script, *parsed_args.arg]
18+
subprocess.Popen(cmd).communicate()
1719

1820

1921
if __name__ == "__main__":

‎softioc/alarm.py‎

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
11
# Severity code definitions taken from EPICS alarm.h
2-
NO_ALARM = 0
3-
MINOR_ALARM = 1
4-
MAJOR_ALARM = 2
5-
INVALID_ALARM = 3
2+
NO_ALARM = 0
3+
MINOR_ALARM = 1
4+
MAJOR_ALARM = 2
5+
INVALID_ALARM = 3
66

77
# Some alarm code definitions taken from EPICS alarm.h
8-
READ_ALARM = 1
9-
WRITE_ALARM = 2
10-
HIHI_ALARM = 3
11-
HIGH_ALARM = 4
12-
LOLO_ALARM = 5
13-
LOW_ALARM = 6
14-
STATE_ALARM = 7
15-
COS_ALARM = 8
16-
COMM_ALARM = 9
17-
TIMEOUT_ALARM = 10
18-
HW_LIMIT_ALARM = 11
19-
CALC_ALARM = 12
20-
SCAN_ALARM = 13
21-
LINK_ALARM = 14
22-
SOFT_ALARM = 15
23-
BAD_SUB_ALARM = 16
24-
UDF_ALARM = 17
25-
DISABLE_ALARM = 18
26-
SIMM_ALARM = 19
27-
READ_ACCESS_ALARM = 20
28-
WRITE_ACCESS_ALARM = 21
29-
8+
READ_ALARM = 1
9+
WRITE_ALARM = 2
10+
HIHI_ALARM = 3
11+
HIGH_ALARM = 4
12+
LOLO_ALARM = 5
13+
LOW_ALARM = 6
14+
STATE_ALARM = 7
15+
COS_ALARM = 8
16+
COMM_ALARM = 9
17+
TIMEOUT_ALARM = 10
18+
HW_LIMIT_ALARM = 11
19+
CALC_ALARM = 12
20+
SCAN_ALARM = 13
21+
LINK_ALARM = 14
22+
SOFT_ALARM = 15
23+
BAD_SUB_ALARM = 16
24+
UDF_ALARM = 17
25+
DISABLE_ALARM = 18
26+
SIMM_ALARM = 19
27+
READ_ACCESS_ALARM = 20
28+
WRITE_ACCESS_ALARM = 21

‎softioc/builder.py‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
from epicsdbbuilder import *
88
from epicscorelibs import path
9-
from epicscorelibs.ioc import iocshRegisterCommon, registerRecordDeviceDriver, pdbbase
9+
from epicscorelibs.ioc import \
10+
iocshRegisterCommon, registerRecordDeviceDriver, pdbbase
1011

1112
iocshRegisterCommon()
1213
dbLoadDatabase("base.dbd", os.path.join(path.base_path, "dbd"))
@@ -18,7 +19,7 @@
1819
InitialiseDbd()
1920
LoadDbdFile(os.path.join(os.path.dirname(__file__), 'device.dbd'))
2021

21-
from . import pythonSoftIoc
22+
from . import pythonSoftIoc # noqa
2223
PythonDevice = pythonSoftIoc.PythonDevice()
2324

2425

@@ -40,34 +41,33 @@ def _in_record(record, name, **fields):
4041

4142

4243
def aIn(name, LOPR=None, HOPR=None, **fields):
43-
return _in_record('ai', name,
44-
LOPR = LOPR, HOPR = HOPR, **fields)
44+
return _in_record(
45+
'ai', name, LOPR = LOPR, HOPR = HOPR, **fields)
4546

4647
def aOut(name, LOPR=None, HOPR=None, **fields):
4748
fields.setdefault('DRVL', LOPR)
4849
fields.setdefault('DRVH', HOPR)
49-
return PythonDevice.ao(name,
50-
LOPR = LOPR, HOPR = HOPR, **fields)
50+
return PythonDevice.ao(
51+
name, LOPR = LOPR, HOPR = HOPR, **fields)
5152

5253

5354
def boolIn(name, ZNAM=None, ONAM=None, **fields):
5455
return _in_record('bi', name, ZNAM = ZNAM, ONAM = ONAM, **fields)
5556

5657
def boolOut(name, ZNAM=None, ONAM=None, **fields):
57-
return PythonDevice.bo(name,
58-
OMSL = 'supervisory',
59-
ZNAM = ZNAM, ONAM = ONAM, **fields)
58+
return PythonDevice.bo(
59+
name, OMSL = 'supervisory', ZNAM = ZNAM, ONAM = ONAM, **fields)
6060

6161

6262
def longIn(name, LOPR=None, HOPR=None, EGU=None, **fields):
6363
fields.setdefault('MDEL', -1)
64-
return _in_record('longin', name,
65-
EGU = EGU, LOPR = LOPR, HOPR = HOPR, **fields)
64+
return _in_record(
65+
'longin', name, EGU = EGU, LOPR = LOPR, HOPR = HOPR, **fields)
6666

6767
def longOut(name, DRVL=None, DRVH=None, EGU=None, **fields):
68-
return PythonDevice.longout(name,
69-
OMSL = 'supervisory',
70-
DRVL = DRVL, DRVH = DRVH, EGU = EGU, **fields)
68+
return PythonDevice.longout(
69+
name, OMSL = 'supervisory', DRVL = DRVL, DRVH = DRVH, EGU = EGU,
70+
**fields)
7171

7272

7373
# Field name prefixes for mbbi/mbbo records.

‎softioc/device.py‎

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def __init__(self, name, **kargs):
9696
else:
9797
self.__on_update = None
9898

99-
self.__validate = kargs.pop('validate', None)
99+
self.__validate = kargs.pop('validate', None)
100100
self.__always_update = kargs.pop('always_update', False)
101101
self._value = kargs.pop('initial_value', None)
102102
self.__enable_write = True
@@ -213,32 +213,36 @@ def get(self):
213213
def _Device(Base, record_type, rval=False, mlst=False, default=0):
214214
'''Wrapper for generating simple records.'''
215215
val_field = 'RVAL' if rval else 'VAL'
216+
216217
class GenericDevice(Base):
217218
_record_type_ = record_type
218219
_device_name_ = 'devPython_' + record_type
219-
_val_field_ = val_field
220-
_default_ = default
221-
_fields_ = ['UDF', val_field]
222-
if mlst: _fields_.append('MLST')
220+
_val_field_ = val_field
221+
_default_ = default
222+
_fields_ = ['UDF', val_field]
223+
if mlst:
224+
_fields_.append('MLST')
223225

224226
GenericDevice.__name__ = record_type
225227
return GenericDevice
226228

227-
_In = ProcessDeviceSupportIn
229+
_In = ProcessDeviceSupportIn
228230
_Out = ProcessDeviceSupportOut
229-
def _Device_In (type, **kargs):
231+
232+
def _Device_In(type, **kargs):
230233
return _Device(_In, type, **kargs)
234+
231235
def _Device_Out(type, rval=False, mlst=True):
232236
return _Device(_Out, type, rval=rval, mlst=mlst, default=None)
233237

234-
longin = _Device_In ('longin')
235-
longout = _Device_Out('longout')
236-
bi = _Device_In ('bi', rval=True)
237-
bo = _Device_Out('bo', rval=True)
238-
stringin = _Device_In ('stringin', mlst=False, default='')
239-
stringout = _Device_Out('stringout', mlst=False)
240-
mbbi = _Device_In ('mbbi', rval=True)
241-
mbbo = _Device_Out('mbbo', rval=True)
238+
longin = _Device_In('longin')
239+
longout = _Device_Out('longout')
240+
bi = _Device_In('bi', rval=True)
241+
bo = _Device_Out('bo', rval=True)
242+
stringin = _Device_In('stringin', mlst=False, default='')
243+
stringout = _Device_Out('stringout', mlst=False)
244+
mbbi = _Device_In('mbbi', rval=True)
245+
mbbo = _Device_Out('mbbo', rval=True)
242246

243247

244248
NO_CONVERT = 2
@@ -254,10 +258,10 @@ def _Device_Out(type, rval=False, mlst=True):
254258
class ai(ProcessDeviceSupportIn):
255259
_record_type_ = 'ai'
256260
_device_name_ = 'devPython_ai'
257-
_val_field_ = 'VAL'
258-
_default_ = 0.0
259-
_fields_ = ['UDF', 'VAL']
260-
_dset_extra_ = dset_process_linconv
261+
_val_field_ = 'VAL'
262+
_default_ = 0.0
263+
_fields_ = ['UDF', 'VAL']
264+
_dset_extra_ = dset_process_linconv
261265

262266
def _process(self, record):
263267
_value = self._value
@@ -271,9 +275,9 @@ def _process(self, record):
271275
class ao(ProcessDeviceSupportOut):
272276
_record_type_ = 'ao'
273277
_device_name_ = 'devPython_ao'
274-
_val_field_ = 'VAL'
275-
_fields_ = ['UDF', 'VAL', 'MLST']
276-
_dset_extra_ = dset_process_linconv
278+
_val_field_ = 'VAL'
279+
_fields_ = ['UDF', 'VAL', 'MLST']
280+
_dset_extra_ = dset_process_linconv
277281

278282
def init_record(self, record):
279283
self.__super.init_record(record)
@@ -304,12 +308,14 @@ def _read_value(self, record):
304308

305309
def _write_value(self, record, value):
306310
value = numpy.require(value, dtype = self.dtype)
307-
if value.shape == (): value.shape = (1,)
311+
if value.shape == ():
312+
value.shape = (1,)
308313
assert value.ndim == 1, 'Can\'t write multidimensional arrays'
309314

310315
nelm = record.NELM
311316
nord = len(value)
312-
if nord > nelm: nord = nelm
317+
if nord > nelm:
318+
nord = nelm
313319
memmove(
314320
record.BPTR, value.ctypes.data_as(c_void_p),
315321
self.dtype.itemsize * nord)
@@ -319,7 +325,7 @@ def _write_value(self, record, value):
319325
class waveform(WaveformBase, ProcessDeviceSupportIn):
320326
_record_type_ = 'waveform'
321327
_device_name_ = 'devPython_waveform'
322-
_default_ = ()
328+
_default_ = ()
323329

324330
# Because arrays are mutable values it's ever so easy to accidentially call
325331
# set() with a value which subsequently changes. To avoid this common class
@@ -338,7 +344,8 @@ def set(self, value,
338344

339345
value = numpy.require(value, dtype = self.dtype)
340346
self._value = (+value, severity, alarm, timestamp)
341-
if value.shape == (): value.shape = (1,)
347+
if value.shape == ():
348+
value.shape = (1,)
342349
assert value.ndim == 1, 'Can\'t write multidimensional arrays'
343350

344351
self.trigger()

‎softioc/device_core.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ def __init__(cls, name, bases, dict):
2828
# Binds cls.__super_cls().method to the appropriate superclass
2929
# class method. Unfortunately the .__super form doesn't work
3030
# with class methods, only instance methods.
31-
setattr(cls, '_%s__super_cls' % name,
31+
setattr(
32+
cls, '_%s__super_cls' % name,
3233
classmethod(lambda child: super(cls, child)))
3334
# Finally call the class initialisatio nmethod.
3435
cls.__init_class__()
@@ -104,7 +105,7 @@ def __init_class__(cls):
104105
# Now construct the device support table. We build on the common
105106
# base and add any device specific definitions here.
106107
class DSET(DSET_BASE):
107-
_fields_ = cls._dset_extra_[0]
108+
_fields_ = cls._dset_extra_[0]
108109
_record_offsets_ = cls._dset_extra_[1]
109110
dset = DSET(
110111
number = len(DSET_BASE._fields_) + len(DSET._fields_) - 1)

‎softioc/extension.c‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
#endif
2020

2121
/* Reference stealing version of PyDict_SetItemString */
22-
static void set_dict_item_steal(PyObject *dict, const char *name, PyObject *py_value)
22+
static void set_dict_item_steal(
23+
PyObject *dict, const char *name, PyObject *py_value)
2324
{
2425
PyDict_SetItemString(dict, name, py_value);
2526
Py_DECREF(py_value);
@@ -57,25 +58,23 @@ static PyObject *get_DBF_values(PyObject *self, PyObject *args)
5758

5859
/* Given an array of field names, this routine looks up each field name in
5960
* the EPICS database and returns the corresponding field offset. */
60-
6161
static PyObject *get_field_offsets(PyObject *self, PyObject *args)
6262
{
63-
int status;
6463
const char *record_type;
65-
PyObject *dict = PyDict_New();
66-
6764
if (!PyArg_ParseTuple(args, "s", &record_type))
6865
return NULL;
6966

7067
DBENTRY dbentry;
7168
dbInitEntry(pdbbase, &dbentry);
7269

73-
status = dbFindRecordType(&dbentry, record_type);
70+
int status = dbFindRecordType(&dbentry, record_type);
7471
if (status != 0)
7572
printf("Unable to find record type \"%s\" (error %d)\n",
7673
record_type, status);
7774
else
7875
status = dbFirstField(&dbentry, 0);
76+
77+
PyObject *dict = PyDict_New();
7978
while (status == 0)
8079
{
8180
const char * field_name = dbGetFieldName(&dbentry);
@@ -106,9 +105,11 @@ static PyObject *db_put_field(PyObject *self, PyObject *args)
106105

107106
struct dbAddr dbAddr;
108107
if (dbNameToAddr(name, &dbAddr))
109-
return PyErr_Format(PyExc_RuntimeError, "dbNameToAddr failed for %s", name);
108+
return PyErr_Format(
109+
PyExc_RuntimeError, "dbNameToAddr failed for %s", name);
110110
if (dbPutField(&dbAddr, dbrType, pbuffer, length))
111-
return PyErr_Format(PyExc_RuntimeError, "dbPutField failed for %s", name);
111+
return PyErr_Format(
112+
PyExc_RuntimeError, "dbPutField failed for %s", name);
112113
Py_RETURN_NONE;
113114
}
114115

@@ -200,6 +201,7 @@ void EpicsPvPutHook(struct asTrapWriteMessage *pmessage, int after)
200201
pmessage->userPvt = value;
201202
}
202203

204+
203205
static PyObject *install_pv_logging(PyObject *self, PyObject *args)
204206
{
205207
const char *acf_file;

0 commit comments

Comments
 (0)