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
8dd97e12
Commit
8dd97e12
authored
Aug 04, 2011
by
Keegi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Custom button customisation implemented
parent
353e51d6
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
116 additions
and
60 deletions
+116
-60
pronsole.py
pronsole.py
+27
-13
pronterface.py
pronterface.py
+89
-47
No files found.
pronsole.py
View file @
8dd97e12
...
...
@@ -153,11 +153,6 @@ class pronsole(cmd.Cmd):
self
.
end_macro
()
# pass the unprocessed line to regular command processor to not require empty line in .pronsolerc
return
self
.
onecmd
(
l
)
if
ls
.
startswith
(
'#'
):
return
if
ls
.
startswith
(
'!'
):
self
.
cur_macro
+=
ws
+
ls
[
1
:]
+
"
\n
"
# python mode
else
:
self
.
cur_macro
+=
ws
+
'self.onecmd("'
+
ls
+
'".format(*arg))
\n
'
# parametric command mode
self
.
cur_macro_def
+=
l
+
"
\n
"
def
end_macro
(
self
):
...
...
@@ -165,7 +160,7 @@ class pronsole(cmd.Cmd):
self
.
prompt
=
"PC>"
if
self
.
cur_macro_def
!=
""
:
self
.
macros
[
self
.
cur_macro_name
]
=
self
.
cur_macro_def
exec
self
.
cur_macro
macro
=
self
.
compile_macro
(
self
.
cur_macro_name
,
self
.
cur_macro_def
)
setattr
(
self
.
__class__
,
"do_"
+
self
.
cur_macro_name
,
lambda
self
,
largs
,
macro
=
macro
:
macro
(
self
,
*
largs
.
split
()))
setattr
(
self
.
__class__
,
"help_"
+
self
.
cur_macro_name
,
lambda
self
,
macro_name
=
self
.
cur_macro_name
:
self
.
subhelp_macro
(
macro_name
))
if
not
self
.
processing_rc
:
...
...
@@ -182,14 +177,37 @@ class pronsole(cmd.Cmd):
self
.
save_in_rc
(
macro_key
,
macro_def
)
else
:
print
"Empty macro - cancelled"
del
self
.
cur_macro
,
self
.
cur_macro_name
,
self
.
cur_macro_def
del
self
.
cur_macro_name
,
self
.
cur_macro_def
def
compile_macro_line
(
self
,
line
):
line
=
line
.
rstrip
()
ls
=
line
.
lstrip
()
ws
=
line
[:
len
(
line
)
-
len
(
ls
)]
# just leading whitespace
if
ls
==
""
or
ls
.
startswith
(
'#'
):
return
""
# no code
if
ls
.
startswith
(
'!'
):
return
ws
+
ls
[
1
:]
+
"
\n
"
# python mode
else
:
return
ws
+
'self.onecmd("'
+
ls
+
'".format(*arg))
\n
'
# parametric command mode
def
compile_macro
(
self
,
macro_name
,
macro_def
):
if
macro_def
.
strip
()
==
""
:
print
"Empty macro - cancelled"
return
pycode
=
"def macro(self,*arg):
\n
"
if
"
\n
"
not
in
macro_def
.
strip
():
pycode
+=
self
.
compile_macro_line
(
" "
+
macro_def
.
strip
())
else
:
lines
=
macro_def
.
split
(
"
\n
"
)
for
l
in
lines
:
pycode
+=
self
.
compile_macro_line
(
l
)
exec
pycode
return
macro
def
start_macro
(
self
,
macro_name
,
prev_definition
=
""
,
suppress_instructions
=
False
):
if
not
self
.
processing_rc
and
not
suppress_instructions
:
print
"Enter macro using indented lines, end with empty line"
self
.
cur_macro_name
=
macro_name
self
.
cur_macro_def
=
""
self
.
cur_macro
=
"def macro(self,*arg):
\n
"
self
.
onecmd
=
self
.
hook_macro
# override onecmd temporarily
self
.
prompt
=
"..>"
...
...
@@ -221,10 +239,6 @@ class pronsole(cmd.Cmd):
return
self
.
cur_macro_def
=
macro_def
self
.
cur_macro_name
=
macro_name
if
macro_def
.
startswith
(
"!"
):
self
.
cur_macro
=
"def macro(self,*arg):
\n
"
+
macro_def
[
1
:]
+
"
\n
"
else
:
self
.
cur_macro
=
"def macro(self,*arg):
\n
self.onecmd('"
+
macro_def
+
"'.format(*arg))
\n
"
self
.
end_macro
()
return
if
self
.
macros
.
has_key
(
macro_name
):
...
...
@@ -304,7 +318,7 @@ class pronsole(cmd.Cmd):
if
not
rc_cmd
.
lstrip
()
.
startswith
(
"#"
):
self
.
onecmd
(
rc_cmd
)
rc
.
close
()
if
hasattr
(
self
,
"cur_macro"
):
if
hasattr
(
self
,
"cur_macro
_def
"
):
self
.
end_macro
()
self
.
rc_loaded
=
True
finally
:
...
...
pronterface.py
View file @
8dd97e12
This diff is collapsed.
Click to expand it.
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