make sure an object is a list; used, for example, when a single file is passed into the parseParticleFile method
(obj)
| 276 | |
| 277 | #------------------------------------------------------------------------ |
| 278 | def ensure_list(obj): |
| 279 | """ |
| 280 | make sure an object is a list; used, for example, when a single |
| 281 | file is passed into the parseParticleFile method |
| 282 | """ |
| 283 | |
| 284 | import types |
| 285 | |
| 286 | if obj is None: |
| 287 | return [obj] |
| 288 | if not isinstance(obj, types.ListType): |
| 289 | return [obj] |
| 290 | return obj |
| 291 | |
| 292 | |
| 293 |