Browse Source

Restructure to Python package

Ian Adam Naval 4 years ago
parent
commit
26cb8a5ed7
12 changed files with 75 additions and 9 deletions
  1. 1
    0
      .gitignore
  2. 44
    0
      README.md
  3. 0
    0
      psh/__init__.py
  4. 0
    0
      psh/commands.py
  5. 2
    2
      psh/console.py
  6. 1
    1
      psh/example_cmd.py
  7. 1
    1
      psh/formatters.py
  8. 2
    2
      psh/raw_commands.py
  9. 3
    3
      psh/run.py
  10. 0
    0
      psh/tree.py
  11. 1
    0
      requirements.txt
  12. 20
    0
      setup.py

+ 1
- 0
.gitignore View File

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

+ 44
- 0
README.md View File

@@ -0,0 +1,44 @@
1
+psh
2
+===
3
+
4
+Augmented Unix Userland shell inspired by Windows PowerShell, written in Python.
5
+
6
+Requirements
7
+------------
8
+
9
+* Python 3+
10
+* pip
11
+
12
+Installing
13
+----------
14
+
15
+Preferably, you would use a separate virtual env
16
+
17
+```
18
+pip install -r requirements.txt
19
+pip install -e .  # installs the 'psh' package in editable mode
20
+```
21
+
22
+Running
23
+-------
24
+
25
+From Python shell:
26
+
27
+```
28
+from psh.run import main
29
+main()
30
+```
31
+
32
+From Unix shell:
33
+```
34
+python -m psh.run
35
+```
36
+
37
+Testing
38
+-------
39
+
40
+From Unix shell:
41
+
42
+```
43
+py.test
44
+```

+ 0
- 0
psh/__init__.py View File


commands.py → psh/commands.py View File


console.py → psh/console.py View File

@@ -4,8 +4,8 @@ import os
4 4
 import readline
5 5
 import shlex
6 6
 
7
-from commands import registered_cmds
8
-import example_cmd
7
+from psh.commands import registered_cmds
8
+import psh.example_cmd
9 9
 
10 10
 DEFAULT_HISTORY_FILE = "~/.psh_history"
11 11
 

example_cmd.py → psh/example_cmd.py View File

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

formatters.py → psh/formatters.py View File

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

raw_commands.py → psh/raw_commands.py View File

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

main.py → psh/run.py View File

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

tree.py → psh/tree.py View File


+ 1
- 0
requirements.txt View File

@@ -0,0 +1 @@
1
+pytest

+ 20
- 0
setup.py View File

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

Loading…
Cancel
Save