pushdit
Installation
pip install pushdit
Import
from pushdit import pushd, popd, pushit
Features
pushd:
- Tool that stores directories in a queue
- Directory path MUST EXIST or FileNotFoundError
- CWD will always be placed at the end of the queue
import os
>>> pushd
- C:\Users\Antsthebul\Desktop\pushit;
>>> pushd('tests')
>>> pushd
- C:\Users\Antsthebul\Desktop\pushit\tests;
0 tests
1 pushit
>>> os.getcwd()
'C:\\Users\\Antsthebul\\Desktop\\pushit\\tests'
Instead of having to use a seperate command to view CWD AND directory queue, pushd will echo the CWD as well as the directories that have been added to the queue. This is similar operation to the pushd and dirs commands in Linux. The list of directories that pushd echoes, will be displayed in the order they were inserted, 0 being most recent. This is the order they will be switched to on default operation when using pushit() as a contenxtmanager, otherwise when calling popd(), will remove dir from back of queue.
When pushd recives a <..directory..>, unless specified pushd will move program to that directory. See examples below..
Adding to 'front' of queue (Default)
>>> pushd
- C:\Users\Antsthebul\Desktop\pushit;
>>> pushd('tests/pushtest1')
>>> pushd
- C:\Users\Antsthebul\Desktop\pushit\tests\pushtest1;
0 pushtest1
1 pushit
Adding to end of queue
>>> pushd
- C:\Users\Antsthebul\Desktop\pushit;
>>> pushd('tests/pushtest1', right=True)
>>> pushd
- C:\Users\Antsthebul\Desktop\pushit\tests\pushtest1;
0 pushit
1 pushtest1
>>> os.getcwd()
'C:\\Users\\Antsthebul\\Desktop\\pushit\\tests\\pushtest1'
Preventing directory change
>>> pushd('pushtest2', chdir=False) # was in tests\pushtest1 when called
>>> pushd
- C:\Users\Antsthebul\Desktop\pushit\tests\pushtest1;
0 pushtest2
1 pushit
2 pushtest1
Clear entire queue and return to inital location of call (cwd @ runtime)
>>> pushd.clear()
>>> pushd
- C:\Users\Antsthebul\Desktop\pushit;
Relative paths ok!
>>> pushd('tests/pushtest1/pushtest2')
>>> pushd
- C:\Users\Antsthebul\Desktop\pushit\tests\pushtest1\pushtest2;
0 pushtest2
1 pushit
>>> pushd('../..')
>>> pushd
- C:\Users\Antsthebul\Desktop\pushit\tests;
0 tests
1 pushtest2
2 pushit
Even this...thing..
>>> pushd
- C:\Users\Ansthebul\Desktop\pushit;
>>> pushd('~/documents')
>>> pushd
- C:\Users\Ansthebul\documents;
0 documents
1 pushit
popd
Remove single directory from back of queue, like pop()
>>> pushd('pushtest2', chdir=False)
>>> popd()
'C:\\Users\\Antsthbul\\pushit\\tests\\pushtest1'
>>> pushd
- C:\Users\Antsthebul\Desktop\pushit\tests\pushtest1;
0 pushtest2
1 pushit
Specify directory to be removed
- Feature unavailable
pushit
Where it all comes together..
no args
- The pushd queue must be populated
>>> pushd('tests', chdir=False)
>>> pushd('tests/pushtest1', chdir=False)
>>> pushd('tests/pushtest1/pushtest2', chdir=False)
>>> pushd()
>>> pushd
- C:\Users\Antsthebul\Desktop\\pushit;
0 pushtest2
1 pushtest1
2 tests
3 pushit
>>> with pushit() as lvl1:
... print('Do stuff here')
... print(os.getcwd())
... print()
... with pushit() as lvl2:
... print('Do more stuff here')
... print(os.getcwd())
... print()
... with pushit() as lvl3:
... print('OK i think you get the idea')
... print(os.getcwd())
... print()
... print('Back in lvl2')
... print(lvl2)
... print('inside lvl1')
... print(lvl1)
Do stuff here
C:\Users\Antsthebul\Desktop\pushit\tests\pushtest1\pushtest2
Do more stuff here
C:\Users\Ansthebul\Desktop\pushit\tests\pushtest1
OK i think you get the idea
C:\Users\Ansthebul\Desktop\pushit\tests
Back in lvl2
- C:\Users\Ansthebul\Desktop\pushit\tests\pushtest1;
inside lvl1
- C:\Users\Ansthebul\Desktop\pushit\tests\pushtest1\pushtest2;
0 pushit
>>> pushd
- C:\Users\Ansthebul\Desktop\pushit;
0 pushit
>>> os.getcwd()
C:\Users\Antsthebul\Desktop\pushit
with args
>>> pushd
- C:\Users\Antsthebul\Desktop\\pushit;
>>> with pushit('tests/pushtest1/pushest2'):
... print(os.getcwd())
C:\Users\Antsthebul\Desktop\pushit\tests\pushtest1\pushtest2
>>> os.getcwd()
'C:\\Users\\Antsthebul\\Desktop\\pushit'
Release files for pushdit 0.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pushdit-0.0.7.tar.gz | 21.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pushdit-0.0.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 39.5 kB
Release files / pushdit-0.0.7.tar.gz
| Download URL | pushdit-0.0.7.tar.gz |
|---|---|
| Size | 21.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
867696eeb0f2ab5e1002d6ce4b9c3527d7c877136bbc85b59e1f4eb66ae68de1
|
|
BLAKE2b-256 checksum How to use checksums |
d7916b221a371d9c79df2d9101db911a688e7e160176146cba9b7cf213fbde1b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.8.5
|
Release files / pushdit-0.0.7-py3-none-any.whl
| Download URL | pushdit-0.0.7-py3-none-any.whl |
|---|---|
| Size | 18.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cc4ba2aa42869bbe24c79727e847c61d89adabaf547e2b12e2e4ed7731d5382a
|
|
BLAKE2b-256 checksum How to use checksums |
8669b41e8ccaaf67ebbe84994e01d3e666cab45e184e46efcac98c8303f63733
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.8.5
|