first
This commit is contained in:
commit
b6dce7d47b
|
@ -0,0 +1,139 @@
|
|||
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
share/python-wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.nox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
*.py,cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
cover/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
db.sqlite3-journal
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
.pybuilder/
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# IPython
|
||||
profile_default/
|
||||
ipython_config.py
|
||||
|
||||
# pyenv
|
||||
# For a library or package, you might want to ignore these files since the code is
|
||||
# intended to run in multiple environments; otherwise, check them in:
|
||||
# .python-version
|
||||
|
||||
# pipenv
|
||||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||
# install all needed dependencies.
|
||||
#Pipfile.lock
|
||||
|
||||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
||||
__pypackages__/
|
||||
|
||||
# Celery stuff
|
||||
celerybeat-schedule
|
||||
celerybeat.pid
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
.dmypy.json
|
||||
dmypy.json
|
||||
|
||||
# Pyre type checker
|
||||
.pyre/
|
||||
|
||||
# pytype static type analyzer
|
||||
.pytype/
|
||||
|
||||
# Cython debug symbols
|
||||
cython_debug/
|
|
@ -0,0 +1,20 @@
|
|||
import argparse, subprocess
|
||||
|
||||
|
||||
from . env import *
|
||||
|
||||
|
||||
# def handler(args):
|
||||
# while 1:
|
||||
# cmd = input(">>> ")
|
||||
# if cmd == "quit":
|
||||
# return
|
||||
# eval(cmd)
|
||||
|
||||
def handler(args):
|
||||
subprocess.run(['python', '-i', this])
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="REPL for pythonic file system management and navigation")
|
||||
# parser.add_argument('root', default='.', action='store', help="root to the package/path to the file")
|
||||
handler(parser.parse_args())
|
|
@ -0,0 +1,114 @@
|
|||
from subprocess import run, Popen
|
||||
from time import sleep
|
||||
from typing import Dict, List, Callable
|
||||
import inspect, os, platform, re, sys, warnings
|
||||
|
||||
from pyperclip import copy, paste
|
||||
from sl4ng import show, getsource, pop, unzip, main, join, regenerator, kill, kbd
|
||||
from filey import Thing, Place, File, Scanner, Library, mcd, search_iter, ffplay, convert
|
||||
import sl4ng
|
||||
|
||||
|
||||
this = __file__
|
||||
here = os.path.dirname(__file__)
|
||||
pwd = Place(os.getcwd())
|
||||
|
||||
unix = lambda path: copy(f"/mnt/{path}".replace(':','').replace('\\','/').lower())
|
||||
|
||||
architecture = platform.architecture()
|
||||
def clear():
|
||||
Popen('clear')
|
||||
sleep(.2)
|
||||
def cls():
|
||||
clear()
|
||||
show(map(repr, cd), head=False, tail=False)
|
||||
def cd(path):
|
||||
global pwd
|
||||
os.chdir(path)
|
||||
pwd.path = path
|
||||
def killfl():
|
||||
kill('fl64')
|
||||
kill('ilbridge')
|
||||
|
||||
|
||||
escaped = tuple(i for i in kbd() if re.escape(i) != i)
|
||||
def functions(module):
|
||||
isfunc = lambda x: inspect.isfunction(x[1])
|
||||
return tuple(filter(isfunc, (i[1] for i in inspect.getmembers(module))))
|
||||
|
||||
c = Place('c:/')
|
||||
e = Place('e:/')
|
||||
f = Place('f:/')
|
||||
kali = Place(r"\\wsl$\kali-linux\home\eli2and40")
|
||||
|
||||
user = Place('~')
|
||||
documents = user/'documents'
|
||||
root = c if c.exists else None
|
||||
appdata = user/'appdata'
|
||||
|
||||
downs = downloads = user / 'Downloads'
|
||||
tools = downs / 'tools'
|
||||
langs = downs / 'tools/languages' # need library class
|
||||
gosrc = Place(r'C:\Program Files\Go\src')
|
||||
web = Library(
|
||||
langs['css'],
|
||||
langs['html'],
|
||||
langs['javascript'],
|
||||
langs.up['web'],
|
||||
r"E:\Projects\web\jayess",
|
||||
)
|
||||
|
||||
dev = Place(r"e:/")
|
||||
sp = dev / 'shellpower'
|
||||
|
||||
gitting = dev / 'gitting'
|
||||
git = downs / "tools/git"
|
||||
clones = gitting/'gitclone/clones'
|
||||
ignore = clones / 'github/gitignore'
|
||||
mdn = gitting / r'gitclone\clones\mdn\content\files\en-us'
|
||||
brython = gitting / r'gitclone\clones\brython-dev\brython\www\doc\en'
|
||||
kendfss = clones['kendfss']
|
||||
|
||||
def igpy(path):
|
||||
"""
|
||||
Add a python .gitignore file to the given path
|
||||
"""
|
||||
home = pwd.path
|
||||
mode = "a" if '.gitignore' in os.listdir(path) else "w"
|
||||
os.chdir(path)
|
||||
with open('.gitignore', mode) as fob:
|
||||
pig = File(r"E:\gitting\gitclone\clones\github\gitignore\Python.gitignore").cat()
|
||||
fob.write(f'\n{pig}')
|
||||
os.chdir(home)
|
||||
|
||||
def iggo(path):
|
||||
"""
|
||||
Add a golang .gitignore file to the given path
|
||||
"""
|
||||
home = pwd.path
|
||||
mode = "a" if '.gitignore' in os.listdir(path) else "w"
|
||||
os.chdir(path)
|
||||
with open('.gitignore', mode) as fob:
|
||||
pig = File(r"E:\gitting\gitclone\clones\github\gitignore\Go.gitignore").cat()
|
||||
fob.write(f'\n{pig}')
|
||||
os.chdir(home)
|
||||
|
||||
|
||||
projects = dev / 'projects'
|
||||
monties = projects / 'monties'
|
||||
|
||||
site = dev / 'Languages\Python38-64\lib'
|
||||
docs = monties / 'docs'
|
||||
|
||||
prod = Place(r'f:/')
|
||||
flps = prod / 'programs/project_files/fl'
|
||||
|
||||
exotics = {
|
||||
"cdot": "·",
|
||||
}
|
||||
exords = {key: ord(val) for key, val in exotics.items()}
|
||||
tfs = [
|
||||
r'C:\Users\Kenneth\childlist.txt',
|
||||
r'C:\Users\Kenneth\file.txt',
|
||||
r'C:\Users\Kenneth\parentlist.txt',
|
||||
]
|
|
@ -0,0 +1,38 @@
|
|||
# CNS
|
||||
<!-- ![](https://live.staticflickr.com/6049/6323682453_f58f16b56b_w_d.jpg "credit to Nick Shillingford") -->
|
||||
<!-- <center><img src="https://live.staticflickr.com/6049/6323682453_f58f16b56b_w_d.jpg" ...></center> -->
|
||||
|
||||
CNS (Central Nervous System) is REPL for pythonic file system management and navigation.
|
||||
It essentially bundles relevant aspects of [filey](https://github.com/kendfss/filey) and [sl4ng](https://github.com/kendfss/sl4ng) into a shell-like environment.
|
||||
You can customize it to fit your system/workflow by editing the [env](./cns/env.py) file.
|
||||
|
||||
**why?** because you're worth it. It's usually faster than searching with windows on my miserably old setup. having everything handy makes it faster to control search specificity
|
||||
[**how?**](#usage)
|
||||
|
||||
### Usage
|
||||
|
||||
##### Start
|
||||
```shell
|
||||
$ cns
|
||||
```
|
||||
|
||||
##### Navigation
|
||||
```python
|
||||
>>> pwd
|
||||
Place(name=System32, dir=Windows)
|
||||
>>> cd(os.path.expanduser('~'))
|
||||
>>> pwd
|
||||
Place(name=Me, dir=User)
|
||||
```
|
||||
|
||||
##### Linear Search
|
||||
```python
|
||||
>>> show(downloads("name of that documentation file i seem to have misplaced/lost the will to look for manually", exts='pdf md htm'))
|
||||
search result #1.pdf
|
||||
search result #2.pdf
|
||||
...
|
||||
search result #n
|
||||
```
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
from setuptools import setup, find_packages
|
||||
|
||||
with open('readme.md', 'r') as fob:
|
||||
long_description = fob.read()
|
||||
with open('requirements.txt', 'r') as fob:
|
||||
requirements = fob.readlines()
|
||||
|
||||
setup(
|
||||
name='cns',
|
||||
version='1.0.0',
|
||||
author='Kenneth Sabalo',
|
||||
author_email='kennethsantanasablo@gmail.com',
|
||||
url='https://github.com/kendfss/cns',
|
||||
description="REPL for pythonic file system management and navigation",
|
||||
packages=find_packages(),
|
||||
classifiers=[
|
||||
"Programming Language :: Python :: 3",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
"Operating System :: OS Independent",
|
||||
],
|
||||
long_description=long_description,
|
||||
long_description_content_type='text/markdown',
|
||||
keywords='utilities operating path file system local server web',
|
||||
license='GNU GPLv3',
|
||||
requires=requirements,
|
||||
entry_points={
|
||||
'console_scripts': [
|
||||
'cns = cns.cli:main'
|
||||
]
|
||||
},
|
||||
python_requires='>=3.10',
|
||||
)
|
Loading…
Reference in New Issue