Skip to content

Commit

Permalink
Updating readme to reflect option to use environment variables, bumpi…
Browse files Browse the repository at this point in the history
…ng up minor version
  • Loading branch information
abhishek-anand committed Sep 16, 2016
1 parent 0080ddb commit 91f321a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,27 @@ By default, Pysession will record each shell run and save to a Gist. However it
>>> PySession.off()
```

Alternatively, to persist your choice of not saving sessions for some extended period of time, set an environment variable PYSESSION_SAVE_OFF to True.
`export PYSESSION_SAVE_OFF=True`


##### To turn back on saving for a session

``` python
>>> PySession.on()
```


##### To save to a local file instead of Gist

``` python
>>> PySession.local()
```

To always save your sessions to local file, set an environment variable PYSESSION_SAVE_LOCALLY to True.
`export PYSESSION_SAVE_LOCALLY=True`

The file is saved with a name `session.py` You can change this by setting the environment variable PYSESSION_FILENAME to your desired filename.
`export PYSESSION_FILENAME=some_file_name.py`


12 changes: 10 additions & 2 deletions pysession.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,13 @@ def off(cls):
@classmethod
def local(cls):
"""Switch to saving the current session to a local file."""
cls.save = True
cls.save_locally = True

@classmethod
def gist(cls):
"""Switch to saving the current session to a secret gist."""
cls.save = True
cls.save_locally = False

@classmethod
Expand Down Expand Up @@ -171,7 +173,7 @@ def custom_hook(etype, evalue, traceback):


def process_history():
"""Processes python sheell history to an array of code lines"""
"""Processes python shell history to an array of code lines"""
end_index = len(PySession.ipython_history) - 1 if PySession.is_ipython \
else readline.get_current_history_length()

Expand All @@ -183,7 +185,13 @@ def process_history():
line = PySession.ipython_history[i]
else:
line = readline.get_history_item(i)
if line.strip() in ['exit' or 'exit()']: # remove 'exit' from code

# remove 'exit' and PySession keywords from code
if line.strip() in ['PySession.local()',
'PySession.gist()',
'PySession.off()',
'exit',
'exit()']:
continue
lines_of_code.append(line)

Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@

setup(
name='pysession',
version='0.1.2',
version='0.2',
description='Automatically save python interpreter session code to a file or secret Gist',
author='Fallible',
author_email='[email protected]',
url='https://github.com/FallibleInc/pysession',
download_url='https://github.com/FallibleInc/pysession/tarball/0.1.2',
download_url='https://github.com/FallibleInc/pysession/tarball/0.2',
py_modules=['pysession'],
install_requires=[],
classifiers=[
Expand Down

0 comments on commit 91f321a

Please sign in to comment.