Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
Printrun
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
machinery
Printrun
Commits
efaf64de
Commit
efaf64de
authored
Jun 01, 2011
by
Keegi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid using func_doc to store alias definition
parent
c829cbc4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
9 deletions
+7
-9
pronsole.py
pronsole.py
+7
-9
No files found.
pronsole.py
View file @
efaf64de
...
@@ -39,7 +39,7 @@ class pronsole(cmd.Cmd):
...
@@ -39,7 +39,7 @@ class pronsole(cmd.Cmd):
self
.
bedtemps
=
{
"pla"
:
"60"
,
"abs"
:
"110"
,
"off"
:
"0"
}
self
.
bedtemps
=
{
"pla"
:
"60"
,
"abs"
:
"110"
,
"off"
:
"0"
}
self
.
percentdone
=
0
self
.
percentdone
=
0
self
.
tempreadings
=
""
self
.
tempreadings
=
""
self
.
aliases
=
[]
self
.
aliases
=
{}
def
scanserial
(
self
):
def
scanserial
(
self
):
"""scan for available ports. return a list of device names."""
"""scan for available ports. return a list of device names."""
...
@@ -74,7 +74,7 @@ class pronsole(cmd.Cmd):
...
@@ -74,7 +74,7 @@ class pronsole(cmd.Cmd):
if
l
==
""
:
if
l
==
""
:
# list aliases
# list aliases
if
len
(
self
.
aliases
):
if
len
(
self
.
aliases
):
self
.
print_topics
(
"Aliases, to display type: alias <name>"
,
self
.
aliases
,
15
,
80
)
self
.
print_topics
(
"Aliases, to display type: alias <name>"
,
self
.
aliases
.
keys
()
,
15
,
80
)
else
:
else
:
print
"No aliases defined, to define see: help alias"
print
"No aliases defined, to define see: help alias"
return
return
...
@@ -82,17 +82,17 @@ class pronsole(cmd.Cmd):
...
@@ -82,17 +82,17 @@ class pronsole(cmd.Cmd):
alias_name
=
alias_l
[
0
]
alias_name
=
alias_l
[
0
]
if
len
(
alias_l
)
<
2
:
if
len
(
alias_l
)
<
2
:
# display alias
# display alias
if
alias_name
in
self
.
aliases
:
if
alias_name
in
self
.
aliases
.
keys
()
:
print
self
.
__dict__
[
"do_"
+
alias_name
]
.
func_doc
print
"Alias '"
+
alias_name
+
"' stands for '"
+
self
.
aliases
[
alias_name
]
+
"'"
else
:
else
:
print
"Alias '"
+
alias_name
+
"' is not defined"
print
"Alias '"
+
alias_name
+
"' is not defined"
return
return
alias_name
,
alias_def
=
alias_l
alias_name
,
alias_def
=
alias_l
if
alias_def
.
lower
()
==
"/d"
:
if
alias_def
.
lower
()
==
"/d"
:
# delete alias
# delete alias
if
alias_name
in
self
.
aliases
:
if
alias_name
in
self
.
aliases
.
keys
()
:
delattr
(
self
,
"do_"
+
alias_name
)
delattr
(
self
,
"do_"
+
alias_name
)
self
.
aliases
.
remove
(
alias_name
)
del
self
.
aliases
[
alias_name
]
print
"Alias '"
+
alias_name
+
"' removed"
print
"Alias '"
+
alias_name
+
"' removed"
return
return
else
:
else
:
...
@@ -100,10 +100,8 @@ class pronsole(cmd.Cmd):
...
@@ -100,10 +100,8 @@ class pronsole(cmd.Cmd):
return
return
# (re)define an alias
# (re)define an alias
func
=
lambda
args
,
self
=
self
,
alias_def
=
alias_def
:
self
.
onecmd
(
" "
.
join
((
alias_def
,
args
)))
func
=
lambda
args
,
self
=
self
,
alias_def
=
alias_def
:
self
.
onecmd
(
" "
.
join
((
alias_def
,
args
)))
func
.
func_doc
=
"Alias '"
+
alias_name
+
"' stands for '"
+
alias_def
+
"'"
self
.
aliases
[
alias_name
]
=
alias_def
setattr
(
self
,
"do_"
+
alias_name
,
func
)
setattr
(
self
,
"do_"
+
alias_name
,
func
)
if
alias_name
not
in
self
.
aliases
:
self
.
aliases
.
append
(
alias_name
)
def
help_alias
(
self
):
def
help_alias
(
self
):
print
"Create/modify/view aliases: alias <name> [<command>]"
print
"Create/modify/view aliases: alias <name> [<command>]"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment