Skip to content

Commit 415f1cb

Browse files
committed
Renamed locals_in_py to self_in_py
This more accurately reflects what it controls
1 parent 0f8f90c commit 415f1cb

File tree

14 files changed

+24
-26
lines changed

14 files changed

+24
-26
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
## 0.9.26 (January 26, 2020)
22
* Breaking changes
3+
* Renamed `locals_in_py` attribute of `cmd2.Cmd` to `self_in_py`
34
* The following public attributes of `cmd2.Cmd` are no longer settable at runtime by end users:
45
* `continuation_prompt`
5-
* `locals_in_py`
6+
* `self_in_py`
67
* `prompt`
78

89
## 0.9.25 (January 26, 2020)

README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -318,14 +318,11 @@ example/transcript_regex.txt:
318318
# regexes on prompts just make the trailing space obvious
319319
(Cmd) set
320320
allow_style: Terminal
321-
continuation_prompt: >/ /
322321
debug: False
323322
echo: False
324323
editor: /.*?/
325324
feedback_to_output: False
326-
locals_in_py: True
327325
maxrepeats: 3
328-
prompt: (Cmd)/ /
329326
quiet: False
330327
timing: False
331328
```
@@ -350,14 +347,14 @@ Open source projects using cmd2
350347

351348
Here are a few examples of open-source projects which use `cmd2`:
352349

350+
* [Jok3r](http://www.jok3r-framework.com)
351+
* Network & Web Pentest Automation Framework
353352
* [CephFS Shell](http://docs.ceph.com/docs/master/cephfs/cephfs-shell/)
354353
* [Ceph](https://ceph.com/) is a distributed object, block, and file storage platform
355354
* [JSShell](https://github.com/Den1al/JSShell)
356355
* An interactive multi-user web JavaScript shell
357356
* [psiTurk](https://psiturk.org)
358357
* An open platform for science on Amazon Mechanical Turk
359-
* [Jok3r](http://www.jok3r-framework.com)
360-
* Network & Web Pentest Automation Framework
361358
* [Poseidon](https://github.com/CyberReboot/poseidon)
362359
* Leverages software-defined networks (SDNs) to acquire and then feed network traffic to a number of machine learning techniques
363360
* [Unipacker](https://github.com/unipacker/unipacker)

cmd2/cmd2.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def __init__(self, completekey: str = 'tab', stdin=None, stdout=None, *,
181181
super().__init__(completekey=completekey, stdin=stdin, stdout=stdout)
182182

183183
# Attributes which should NOT be dynamically settable via the set command at runtime
184-
# To prevent a user from altering these with the py/ipy commands, remove locals_in_py from the
184+
# To prevent a user from altering these with the py/ipy commands, remove self_in_py from the
185185
# settable dictionary during your applications's __init__ method.
186186
self.default_to_shell = False # Attempt to run unrecognized commands as shell commands
187187
self.quit_on_sigint = False # Quit the loop on interrupt instead of just resetting prompt
@@ -221,7 +221,7 @@ def __init__(self, completekey: str = 'tab', stdin=None, stdout=None, *,
221221
self.continuation_prompt = '> '
222222

223223
# Allow access to your application in embedded Python shells and scripts py via self
224-
self.locals_in_py = False
224+
self.self_in_py = False
225225

226226
# Commands to exclude from the help menu and tab completion
227227
self.hidden_commands = ['eof', '_relative_load', '_relative_run_script']
@@ -3118,7 +3118,7 @@ def py_quit():
31183118
self.py_locals['quit'] = py_quit
31193119
self.py_locals['exit'] = py_quit
31203120

3121-
if self.locals_in_py:
3121+
if self.self_in_py:
31223122
self.py_locals['self'] = self
31233123
elif 'self' in self.py_locals:
31243124
del self.py_locals['self']
@@ -3238,7 +3238,7 @@ def load_ipy(cmd2_app: Cmd, py_bridge: PyBridge):
32383238
exec("{} = py_bridge".format(cmd2_app.py_bridge_name))
32393239

32403240
# Add self variable pointing to cmd2_app, if allowed
3241-
if cmd2_app.locals_in_py:
3241+
if cmd2_app.self_in_py:
32423242
exec("self = cmd2_app")
32433243

32443244
# Delete these names from the environment so IPython can't use them

docs/features/embedded_python_shells.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ arguments, it enters an interactive Python session. The session can call
88
your cmd2 application while maintaining isolation.
99

1010
You may optionally enable full access to to your application by setting
11-
``locals_in_py`` to ``True``. Enabling this flag adds ``self`` to the python
11+
``self_in_py`` to ``True``. Enabling this flag adds ``self`` to the python
1212
session, which is a reference to your Cmd2 application. This can be useful for
1313
debugging your application.
1414

docs/features/initialization.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ capabilities which you may wish to utilize while initializing the app::
3939
self.continuation_prompt = '... '
4040

4141
# Allow access to your application in py and ipy via self
42-
self.locals_in_py = True
42+
self.self_in_py = True
4343

4444
# Set the default category name
4545
self.default_category = 'cmd2 Built-in Commands'
@@ -125,7 +125,7 @@ override:
125125
of results in a Python script or interactive console. Built-in commands don't
126126
make use of this. It is purely there for user-defined commands and
127127
convenience.
128-
- **locals_in_py**: if ``True`` allow access to your application in *py*
128+
- **self_in_py**: if ``True`` allow access to your application in *py*
129129
command via ``self`` (Default: ``False``)
130130
- **macros**: dictionary of macro names and their values
131131
- **max_completion_items**: max number of CompletionItems to display during
@@ -139,7 +139,7 @@ override:
139139
``app``)
140140
- **py_locals**: dictionary that defines specific variables/functions available
141141
in Python shells and scripts (provides more fine-grained control than making
142-
everything available with **locals_in_py**)
142+
everything available with **self_in_py**)
143143
- **quiet**: if ``True`` then completely suppress nonessential output (Default:
144144
``False``)
145145
- **quit_on_sigint**: if ``True`` quit the main loop on interrupt instead of

examples/basic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def __init__(self):
2222
self.intro = style('Welcome to PyOhio 2019 and cmd2!', fg='red', bg='white', bold=True) + ' 😀'
2323

2424
# Allow access to your application in py and ipy via self
25-
self.locals_in_py = True
25+
self.self_in_py = True
2626

2727
# Set the default category name
2828
self.default_category = 'cmd2 Built-in Commands'

examples/cmd_as_argument.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def __init__(self):
3333
# Set use_ipython to True to enable the "ipy" command which embeds and interactive IPython shell
3434
super().__init__(allow_cli_args=False, use_ipython=True, multiline_commands=['orate'], shortcuts=shortcuts)
3535

36-
self.locals_in_py = True
36+
self.self_in_py = True
3737
self.maxrepeats = 3
3838
# Make maxrepeats settable at runtime
3939
self.settable['maxrepeats'] = 'max repetitions for speak command'

examples/hello_cmd2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
# Set "use_ipython" to True to include the ipy command if IPython is installed, which supports advanced interactive
1313
# debugging of your application via introspection on self.
1414
app = cmd2.Cmd(use_ipython=True, persistent_history_file='cmd2_history.dat')
15-
app.locals_in_py = True # Enable access to "self" within the py command
15+
app.self_in_py = True # Enable access to "self" within the py command
1616
app.debug = True # Show traceback if/when an exception occurs
1717
sys.exit(app.cmdloop())

examples/initialization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def __init__(self):
3333
self.continuation_prompt = '... '
3434

3535
# Allow access to your application in py and ipy via self
36-
self.locals_in_py = True
36+
self.self_in_py = True
3737

3838
# Set the default category name
3939
self.default_category = 'cmd2 Built-in Commands'

examples/override_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@
1919
if __name__ == '__main__':
2020
import sys
2121
app = cmd2.Cmd(use_ipython=True, persistent_history_file='cmd2_history.dat')
22-
app.locals_in_py = True # Enable access to "self" within the py command
22+
app.self_in_py = True # Enable access to "self" within the py command
2323
app.debug = True # Show traceback if/when an exception occurs
2424
sys.exit(app.cmdloop())

0 commit comments

Comments
 (0)