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
47298bba
Commit
47298bba
authored
Jun 07, 2011
by
Keegi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove alias command in favour of macro
parent
7db2f9b0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
49 deletions
+3
-49
pronsole.py
pronsole.py
+3
-49
No files found.
pronsole.py
View file @
47298bba
...
...
@@ -72,60 +72,14 @@ class pronsole(cmd.Cmd):
def
help_gcodes
(
self
):
print
"Gcodes are passed through to the printer as they are"
def
do_alias
(
self
,
l
):
if
l
==
""
:
# list aliases
if
len
(
self
.
aliases
):
self
.
print_topics
(
"Aliases, to display type: alias <name>"
,
self
.
aliases
.
keys
(),
15
,
80
)
else
:
print
"No aliases defined, to define see: help alias"
return
alias_l
=
l
.
split
(
None
,
1
)
alias_name
=
alias_l
[
0
]
if
len
(
alias_l
)
<
2
:
# display alias
if
alias_name
in
self
.
aliases
.
keys
():
print
"Alias '"
+
alias_name
+
"' stands for '"
+
self
.
aliases
[
alias_name
]
+
"'"
else
:
print
"Alias '"
+
alias_name
+
"' is not defined"
return
alias_name
,
alias_def
=
alias_l
if
alias_def
.
lower
()
==
"/d"
:
# delete alias
if
alias_name
in
self
.
aliases
.
keys
():
delattr
(
self
.
__class__
,
"do_"
+
alias_name
)
del
self
.
aliases
[
alias_name
]
print
"Alias '"
+
alias_name
+
"' removed"
return
else
:
print
"Alias '"
+
alias_name
+
"' is not defined"
return
# (re)define an alias
if
alias_name
not
in
self
.
aliases
.
keys
()
and
hasattr
(
self
.
__class__
,
"do_"
+
alias_name
):
print
"Name '"
+
alias_name
+
"' is already being used by built-in command"
return
func
=
lambda
self
,
args
,
alias_def
=
alias_def
:
self
.
onecmd
(
" "
.
join
((
alias_def
,
args
)))
self
.
aliases
[
alias_name
]
=
alias_def
setattr
(
self
.
__class__
,
"do_"
+
alias_name
,
func
)
setattr
(
self
.
__class__
,
"help_"
+
alias_name
,
lambda
self
=
self
,
alias_name
=
alias_name
:
self
.
subhelp_alias
(
alias_name
))
def
help_alias
(
self
):
print
"Create/modify/view aliases: alias <name> [<command>]"
print
"if <command> is not specified, displays the alias definition"
print
"without arguments, displays list of all defined aliases"
print
"To remove an alias: alias <name> /d"
def
complete_alias
(
self
,
text
,
line
,
begidx
,
endidx
):
def
complete_macro
(
self
,
text
,
line
,
begidx
,
endidx
):
if
(
len
(
line
.
split
())
==
2
and
line
[
-
1
]
!=
" "
)
or
(
len
(
line
.
split
())
==
1
and
line
[
-
1
]
==
" "
):
return
[
i
for
i
in
self
.
aliase
s
.
keys
()
if
i
.
startswith
(
text
)]
return
[
i
for
i
in
self
.
macro
s
.
keys
()
if
i
.
startswith
(
text
)]
elif
(
len
(
line
.
split
())
==
3
or
(
len
(
line
.
split
())
==
2
and
line
[
-
1
]
==
" "
)):
return
self
.
completenames
(
text
)
return
[
"/D"
,
"/S"
]
+
self
.
completenames
(
text
)
else
:
return
[]
def
subhelp_alias
(
self
,
alias_name
):
print
"'"
+
alias_name
+
"' is alias for '"
+
self
.
aliases
[
alias_name
]
+
"'"
def
hook_macro
(
self
,
l
):
ls
=
l
.
lstrip
()
ws
=
l
[:
len
(
l
)
-
len
(
ls
)]
# just leading whitespace
...
...
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