├── .gitignore ├── LICENSE ├── README.md ├── data ├── PotterScript.jpg └── import_serious.png ├── potterscript ├── __init__.py ├── pottershell.py ├── quotes.py ├── random.py ├── release.py └── spells.py └── setup.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | 27 | # PyInstaller 28 | # Usually these files are written by a python script from a template 29 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 30 | *.manifest 31 | *.spec 32 | 33 | # Installer logs 34 | pip-log.txt 35 | pip-delete-this-directory.txt 36 | 37 | # Unit test / coverage reports 38 | htmlcov/ 39 | .tox/ 40 | .coverage 41 | .coverage.* 42 | .cache 43 | nosetests.xml 44 | coverage.xml 45 | *,cover 46 | .hypothesis/ 47 | 48 | # Translations 49 | *.mo 50 | *.pot 51 | 52 | # Django stuff: 53 | *.log 54 | local_settings.py 55 | 56 | # Flask stuff: 57 | instance/ 58 | .webassets-cache 59 | 60 | # Scrapy stuff: 61 | .scrapy 62 | 63 | # Sphinx documentation 64 | docs/_build/ 65 | 66 | # PyBuilder 67 | target/ 68 | 69 | # IPython Notebook 70 | .ipynb_checkpoints 71 | 72 | # pyenv 73 | .python-version 74 | 75 | # celery beat schedule file 76 | celerybeat-schedule 77 | 78 | # dotenv 79 | .env 80 | 81 | # virtualenv 82 | venv/ 83 | ENV/ 84 | 85 | # Spyder project settings 86 | .spyderproject 87 | 88 | # Rope project settings 89 | .ropeproject 90 | 91 | # Vim/Swap files 92 | *.swp 93 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Himanshu Mishra 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PotterScript 2 | The one language that Harry always used, but never spoke of. 3 | 4 | # About 5 | PotterScript is an interpreted language, similar to Muggle world's 6 | [Python](https://en.wikipedia.org/wiki/Python_(programming_language)), 7 | which is believed to be developed by Harry Potter during his stay at 8 | Hogwarts School of Witchcraft and Wizardry. 9 | 10 | # Installation 11 | 12 | ```sh 13 | $ git clone https://github.com/OrkoHunter/PotterScript.git 14 | $ cd PotterScript/ 15 | $ python3 setup.py install 16 | ``` 17 | 18 | Make sure you use Python 3. Use `sudo` in case of permission issue. 19 | 20 | # Usage 21 | 22 | Start the interactive shell. 23 | 24 | ```sh 25 | $ potterscript 26 | ``` 27 | 28 | 29 | 30 | # Feature Requests 31 | 32 | PotterScript is a fun toy project. If you're a Harry Potter fan, then please tell 33 | what would you expect from this. 34 | 35 | [Link to submit feature request](http://goo.gl/forms/TvBKkZVlle) 36 | 37 | # Credits 38 | 39 | This project is heavily inspired from [TrumpScript](https://github.com/samshadwell/TrumpScript) 40 | and with good muggle intentions. 41 | -------------------------------------------------------------------------------- /data/PotterScript.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OrkoHunter/PotterScript/594edcb0dbf65bc2abb5e159766879811abf17a0/data/PotterScript.jpg -------------------------------------------------------------------------------- /data/import_serious.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OrkoHunter/PotterScript/594edcb0dbf65bc2abb5e159766879811abf17a0/data/import_serious.png -------------------------------------------------------------------------------- /potterscript/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OrkoHunter/PotterScript/594edcb0dbf65bc2abb5e159766879811abf17a0/potterscript/__init__.py -------------------------------------------------------------------------------- /potterscript/pottershell.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | import atexit 3 | import os 4 | import platform 5 | import rlcompleter 6 | import readline 7 | import sys 8 | import traceback 9 | 10 | from potterscript import release 11 | 12 | def main(): 13 | 14 | histfile = os.path.join(os.path.expanduser("~"), ".python_history") 15 | 16 | try: 17 | readline.read_history_file(histfile) 18 | except FileNotFoundError: 19 | pass 20 | 21 | atexit.register(readline.write_history_file, histfile) 22 | 23 | uname = platform.uname() 24 | 25 | readline.parse_and_bind('tab: complete') 26 | print("Python {} {}".format(platform.python_version(), platform.python_build())) 27 | print() 28 | print("PotterScript {} ({})".format(release.__version__, release.__date__)) 29 | print("[{}] on {} {}".format(platform.python_compiler(), uname.system, uname.release)) 30 | print("Type \"help\", \"copyright\", \"credits\" or \"license\" for more information.") 31 | print() 32 | 33 | Q_NO = 1 # Prompt index 34 | 35 | class colors: 36 | INPUT = '\033[92m' 37 | OUTPUT = '\033[91m' 38 | ENDC = '\033[0m' 39 | 40 | while(True): 41 | try: 42 | query = input("In [" + colors.INPUT + str(Q_NO) + colors.ENDC + "]: ") 43 | if query != '': 44 | if query[-1] == ":": 45 | # Take subsequent queries 46 | while(True): 47 | query_ = input(" ...: ") 48 | if query_ != "": 49 | query += "\n" + query_ 50 | else: 51 | break 52 | # Process 53 | try: 54 | out = eval(query) 55 | if not "print(" in query: 56 | print(colors.OUTPUT + "Out[" + str(Q_NO) + "]:" + colors.ENDC, end=" ") 57 | print(out) 58 | print() 59 | except SyntaxError: 60 | try: 61 | exec(query) 62 | except SyntaxError as e: 63 | print(colors.OUTPUT, end="") 64 | print("-------------------------------------------------") 65 | print(e) 66 | print(colors.ENDC, end="") 67 | print("Syntax Error in last line.") 68 | except ImportError as e: 69 | module = str(e).split()[-1] 70 | print(colors.OUTPUT, end="") 71 | print("-------------------------------------------------") 72 | print("ImportError Traceback (most recent call last):") 73 | print(colors.ENDC, end="") 74 | traceback.print_stack() 75 | print("\n{}: import of {} blocked by dementors.".format(type(e).__name__, module)) 76 | except NameError as e: 77 | name = str(e).split()[1] 78 | print(colors.OUTPUT, end="") 79 | print("-------------------------------------------------") 80 | print("NameError Traceback (most recent call last):") 81 | print(colors.ENDC, end="") 82 | traceback.print_stack() 83 | print("\n{}: Bloody Hell, what is {} ?".format(type(e).__name__, name)) 84 | except Exception as e: 85 | print(colors.OUTPUT, end="") 86 | print("-------------------------------------------------") 87 | print("Exception Traceback (most recent call last):") 88 | print(colors.ENDC, end="") 89 | traceback.print_stack() 90 | print("\n{}: {}".format(type(e).__name__, e)) 91 | print() 92 | except Exception as e: 93 | print(colors.OUTPUT, end="") 94 | print("-------------------------------------------------") 95 | print("{}:".format(type(e).__name__) + colors.ENDC, end=" ") 96 | print("{}".format(e)) 97 | print() 98 | 99 | Q_NO += 1 100 | else: 101 | print() 102 | except KeyboardInterrupt: 103 | print("\nKeyboardInterrupt\n") 104 | except EOFError: 105 | try: 106 | prompt = input("\nDo you really want to exit ([y]/n)? ") 107 | if not prompt.strip() in ('n', 'N'): 108 | sys.exit(0) 109 | else: 110 | print() 111 | except EOFError: 112 | print() 113 | sys.exit(0) 114 | 115 | if __name__ == '__main__': 116 | main() -------------------------------------------------------------------------------- /potterscript/quotes.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | def gen_random(): 4 | index = random.randint(0, len(quotes) - 1) 5 | return quotes[index] 6 | 7 | quotes = ('Happiness can be found, even in the darkest of times, if one only remembers to turn on the light. - Albus Dumbledore', 8 | 'Indeed, your failure to understand that there are things much worse than death has always been your greatest weakness. - Albus Dumbledore to Voldemort', 9 | 'If you want to know what a man’s like, take a good look at how he treats his inferiors, not his equals. - Sirius Black', 10 | 'Curiosity is not a sin… But we should exercise caution with our curiosity… yes, indeed. - Albus Dumbledore', 11 | 'In dreams, we enter a world that’s entirely our own. - Albus Dumbledore', 12 | 'We did it, we bashed them, wee Potter’s the one, and Voldy’s gone moldy, so now let’s have fun! - Peeves’ Victory Song', 13 | 'To the well-organized mind, death is but the next great adventure. - Albus Dumbledore', 14 | 'We must try not to sink beneath our anguish, Harry, but battle on. - Albus Dumbledore', 15 | 'Fear of a name increases fear of the thing itself. - Albus Dumbledore', 16 | 'You sort of start thinking anything’s possible if you’ve got enough nerve. - Ginny Weasley', 17 | 'Hearing voices no one else can hear isn’t a good sign, even in the wizarding world. - Ron to Harry', 18 | 'It is our choices… that show what we truly are, far more than our abilities. - Albus Dumbledore', 19 | 'Never trust anything that can think for itself if you can’t see where it keeps its brain. - Arthur Weasley', 20 | 'There is no good or evil: only power and those too weak to seek it. - Quirinus Quirrell', 21 | 'Indifference and neglect often do much more damage than outright dislike. - Albus Dumbledore', 22 | 'The truth is a beautiful and terrible thing, and should therefore be treated with caution. - Albus Dumbledore', 23 | 'Youth cannot know how age thinks and feels. But old men are guilty if they forget what it was to be young. - Albus Dumbledore', 24 | 'Harry, suffering like this proves you are still a man! This pain is part of being human … the fact that you can feel pain \ 25 | like this is your greatest strength. - Order of the Pheonix', 26 | 'Numbing the pain for a while will make it worse when you finally feel it. - Albus Dumbledore', 27 | 'An invisible barrier separated him from the rest of the world. He was – he had always been a marked man. - Order of the Pheonix', 28 | 'He chose the boy he thought most likely to be a danger to him … and notice this, Harry. He chose, not the pureblood \ 29 | (which according to his creed, is the only kind of wizard worth being or knowing), but the half-blood, like himself. \ 30 | He saw himself in you before he had ever seen you, and in marking you with that scar, he did not kill you, as he intended, \ 31 | but gave you powers, and a future, which have fitted you to escape him not once, but four times so far. - Dumbledore to Harry', 32 | 'The mind is not a book, to be opened at will and examined at leisure. Thoughts are not etched on the inside of skulls, to be \ 33 | perused by an invader. The mind is a complex and many-layered thing. - Severus Snape', 34 | 'As much money and life as you could want! The two things most human beings would choose above all – the trouble is, \ 35 | humans do have a knack of choosing precisely those things that are worst for them. - Albus Dumbledore', 36 | 'It takes a great deal of bravery to stand up to our enemies, but just as much to stand up to our friends. - Albus Dumbledore', 37 | 'When you have seen as much of life as I have, you will not underestimate the power of obsessive love. - Albus Dumbledore', 38 | 'Age is foolish and forgetful when it underestimates youth. - Dumbledore to Harry', 39 | 'People find it far easier to forgive others for being wrong than being right. - Albus Dumbledore', 40 | 'Ah, music. A magic beyond all we do here! - Albus Dumbledore', 41 | 'It is the unknown we fear when we look upon death and darkness, nothing more. - Albus Dumbledore', 42 | 'We must try not to sink beneath our anguish, Harry, but battle on. - Albus Dumbledore', 43 | 'At these times… I use the Pensieve. One simply siphons the excess thoughts from one’s mind, pours them into the basin, \ 44 | and examines them at one’s leisure. - Albus Dumbledore', 45 | 'Where your treasure is, there will your heart be also. - Albus Dumbledore', 46 | 'The flesh reflects the madness within. - Remus', 47 | 'The best of us must sometimes eat our words. - Albus Dumbledore', 48 | 'Wit beyond measure is man\'s greatest treasure. - Luna', 49 | 'I can teach you how to bewitch the mind and ensnare the senses. - Severus Snape', 50 | 'I can make bad things happen to people who annoy me. I can make them hurt if I want to. - Tom Riddle', 51 | 'It does not do to dwell on dreams and forget to live... - Albus Dumbledore', 52 | 'To have been loved so deeply...will give us some protection forever. - Albus Dumbledore', 53 | 'You fail to recognize that it matters not what someone is born, but what they grow to be. - Albus Dumbledore', 54 | 'Books! And cleverness! There are more important things--friendship and bravery... - Hermione', 55 | 'I open at the close. - Albus Dumbledore', 56 | 'The ones we love never truly leave us. - Sirius', 57 | 'The Dark Lord shall rise again. - Wormtail', 58 | 'I solemnly swear that I\'m up to no good. - Fred and George', 59 | 'I don\'t go looking for trouble. Trouble usually finds me. - Harry', 60 | 'The usual rules do not seem to apply to you... - Snape', 61 | 'I have played my part well. - Snape', 62 | 'Always... - Severus Snape' 63 | ) 64 | -------------------------------------------------------------------------------- /potterscript/random.py: -------------------------------------------------------------------------------- 1 | """Random generator of potterscript.""" 2 | 3 | from potterscript import spells, quotes 4 | 5 | def spell(): 6 | return spells.gen_random() 7 | 8 | def quote(): 9 | return quotes.gen_random() 10 | -------------------------------------------------------------------------------- /potterscript/release.py: -------------------------------------------------------------------------------- 1 | """Release file for PotterScript""" 2 | 3 | name = 'potterscript' 4 | major = '0' 5 | minor = '1.0' 6 | 7 | __version__ = major + '.' + minor 8 | 9 | __date__ = 'July 31 2016, 00:09:34' 10 | 11 | __description__ = 'The one language that Harry always used but never spoke of.' 12 | 13 | __author__ = 'Himanshu Mishra' 14 | __email__ = 'himanshumishra@iitkgp.ac.in' 15 | -------------------------------------------------------------------------------- /potterscript/spells.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | def gen_random(): 4 | index = random.randint(0, len(spells) - 1) 5 | return spells[index] 6 | 7 | spells = ('Accio', 8 | 'Aguamenti', 9 | 'Alohomora', 10 | 'Anapneo', 11 | 'Aparecium', 12 | 'Avada Kedavra', 13 | 'Avis', 14 | 'Capacious Extremis', 15 | 'Cave Inimicum', 16 | 'Colloportus', 17 | 'Confringo', 18 | 'Confundo', 19 | 'Crucio', 20 | 'Defodio', 21 | 'Deletrius', 22 | 'Densaugeo', 23 | 'Deprimo', 24 | 'Descendo', 25 | 'Diffindo', 26 | 'Duro', 27 | 'Engorgio', 28 | 'Episkey', 29 | 'Erecto', 30 | 'Evanesco', 31 | 'Expecto Patronum', 32 | 'Expelliarmus', 33 | 'Expulso', 34 | 'Ferula', 35 | 'Finite Incantatem', 36 | 'Flagrate', 37 | 'Furnunculus', 38 | 'Geminio', 39 | 'Glisseo', 40 | 'Homenum Revelio', 41 | 'Impedimenta', 42 | 'Imperio', 43 | 'Impervius', 44 | 'Incarcerous', 45 | 'Incendio', 46 | 'Langlock', 47 | 'Legilimens', 48 | 'Levicorpus', 49 | 'Liberacorpus', 50 | 'Locomotor', 51 | 'Locomotor Mortis', 52 | 'Lumos', 53 | 'Meteolojinx Recanto', 54 | 'Mobiliarbus', 55 | 'Mobilicorpus', 56 | 'Morsmordre', 57 | 'Muffliato', 58 | 'Nox', 59 | 'Obliviate', 60 | 'Obscuro', 61 | 'Oppugno', 62 | 'Orchideous', 63 | 'Pack', 64 | 'Petrificus Totalus', 65 | 'Piertotum Locomotor', 66 | 'Point Me', 67 | 'Portus', 68 | 'Prior Incantato', 69 | 'Protego', 70 | 'Protego Horribilis', 71 | 'Protego Totalum', 72 | 'Quietus', 73 | 'Reducio', 74 | 'Reducto', 75 | 'Relashio', 76 | 'Rennervate', 77 | 'Reparo', 78 | 'Repello Muggletum', 79 | 'Rictusempra', 80 | 'Riddikulus', 81 | 'Salvio Hexia', 82 | 'Scourgify', 83 | 'Sectumsempra', 84 | 'Serpensortia', 85 | 'Silencio', 86 | 'Sonorus', 87 | 'Specialis Revelio', 88 | 'Stupefy', 89 | 'Tarantallegra', 90 | 'Tergeo', 91 | 'Waddiwasi', 92 | 'Wingardium Leviosa') 93 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | import sys 5 | from setuptools import setup 6 | 7 | if sys.argv[-1] == 'setup.py': 8 | print('To install, run \'python setup.py install\'') 9 | print() 10 | 11 | if sys.version[0] < '3': 12 | print("Please install with Python 3. Aborting installation.") 13 | sys.exit(0) 14 | 15 | sys.path.insert(0, 'potterscript') 16 | import release 17 | 18 | if __name__ == "__main__": 19 | setup( 20 | name = release.name, 21 | version = release.__version__, 22 | author = release.__author__, 23 | author_email = release.__email__, 24 | description = release.__description__, 25 | url='https://github.com/OrkoHunter/PotterScript', 26 | keywords='Harry Potter Programming Language Potter Script', 27 | packages = ['potterscript'], 28 | license = 'MIT License', 29 | entry_points = { 30 | 'console_scripts': [ 31 | 'potterscript = potterscript.pottershell:main', 32 | ] 33 | }, 34 | install_requires = [], 35 | test_suite = 'nose.collector', 36 | tests_require = ['nose>=0.10.1'] 37 | ) 38 | --------------------------------------------------------------------------------