-
Notifications
You must be signed in to change notification settings - Fork 0
/
ecli_template.py
93 lines (73 loc) · 2.23 KB
/
ecli_template.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# -*- coding: utf-8 -*-
# vi:sw=4 ts=4
"""
:mod:`ecli_template` -- ECLI extension template
===============================================
.. module:: ecli_template
:synopsis: DESCRIPTION
.. moduleauthor:: x <y@z>
"""
from __future__ import print_function
import os
import sys
import time
import logging
# IPython
import IPython.utils.traitlets as traitlets
from IPython.core.error import UsageError
# ECLI
from ecli_core import AliasedPV
from ecli_plugin import ECLIPlugin
import ecli_util as util
from ecli_util import (get_plugin, get_core_plugin)
from ecli_util import (ECLIError, ECLIExport)
from ecli_util.magic_args import (ecli_magic_args, argument)
logger = logging.getLogger('ECLI.Template')
# Loading of this extension
def load_ipython_extension(ipython):
return util.generic_load_ext(ipython, ECLITemplate, logger=logger, globals_=globals())
def unload_ipython_extension(ipython):
return util.generic_unload_ext(ipython, ECLITemplate)
class ECLITemplate(ECLIPlugin):
"""
DESCRIPTION
"""
VERSION = 1
REQUIRES = [('ECLICore', 1)]
EXPORTS = {} # see __init__
_callbacks = []
param = traitlets.List(traitlets.Unicode,
default_value=('m1', 'm2'),
config=True)
param2 = traitlets.Int(8, config=True)
def __init__(self, shell, config):
# ECLITemplate.EXPORTS = {}
super(ECLITemplate, self).__init__(shell=shell, config=config)
logger.debug('Initializing ECLI plugin ECLITemplate')
def _param_changed(self, *args):
pass
@property
def logger(self):
return logger
@ECLIExport
def export_function(self):
"""
This function will be easily accessible by the user if this
plugin is loaded.
@ECLIExport functions can also be defined outside of this class.
"""
pass
@ecli_magic_args(ECLITemplate)
@argument('pv', type=AliasedPV, nargs='+',
help='PV')
def command(margs, self, args):
"""
$ command pv
Desc
"""
# margs is the magic arguments instance
# self is the instance of your plugin class
# args is the pre-parsed argparse Namespace:
# for %command pv_name
# args.pv would be equal to "pv_name"
pass