Restructure to Python package

This commit is contained in:
Ian Adam Naval 2015-02-26 16:47:39 -05:00
parent e363bfd13c
commit 26cb8a5ed7
12 changed files with 75 additions and 9 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
__pycache__
*.pyc
*.egg-info

44
README.md Normal file
View File

@ -0,0 +1,44 @@
psh
===
Augmented Unix Userland shell inspired by Windows PowerShell, written in Python.
Requirements
------------
* Python 3+
* pip
Installing
----------
Preferably, you would use a separate virtual env
```
pip install -r requirements.txt
pip install -e . # installs the 'psh' package in editable mode
```
Running
-------
From Python shell:
```
from psh.run import main
main()
```
From Unix shell:
```
python -m psh.run
```
Testing
-------
From Unix shell:
```
py.test
```

0
psh/__init__.py Normal file
View File

View File

@ -4,8 +4,8 @@ import os
import readline
import shlex
from commands import registered_cmds
import example_cmd
from psh.commands import registered_cmds
import psh.example_cmd
DEFAULT_HISTORY_FILE = "~/.psh_history"

View File

@ -1,4 +1,4 @@
from commands import BaseCommand, register_cmd
from psh.commands import BaseCommand, register_cmd
@register_cmd

View File

@ -1,4 +1,4 @@
from commands import BaseCommand
from psh.commands import BaseCommand
class Printer(BaseCommand):

View File

@ -1,5 +1,5 @@
from formatters import Printer
from commands import BaseCommand
from psh.formatters import Printer
from psh.commands import BaseCommand
class RawCommand(BaseCommand):

View File

@ -1,8 +1,8 @@
import os
import os.path
from formatters import *
from raw_commands import RawCommand
from psh.formatters import *
from psh.raw_commands import RawCommand
# Load all of the commands in the path into the global namespace as raw
# commands.
@ -15,7 +15,7 @@ for path in os.environ['PATH'].split(':'):
def main():
from console import HistoryConsole
from psh.console import HistoryConsole
console = HistoryConsole(globals())
console.interact("Augmented Unix Userland")

1
requirements.txt Normal file
View File

@ -0,0 +1 @@
pytest

20
setup.py Normal file
View File

@ -0,0 +1,20 @@
import os
from setuptools import setup
# Utility function to read the README file.
# Used for the long_description. It's nice, because now 1) we have a top level
# README file and 2) it's easier to type in the README file than to put a raw
# string in below ...
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
setup(
name = "psh",
version = "0.0.1",
author = "WPI Augmented Unix Userland MQP",
author_email = "jsh@wpi.edu",
description = ("Simple Unix shell inspired by PowerShell"),
license = "MIT",
packages=['psh'],
long_description=read('README.md'),
)