Skip to content

Commit c0aac46

Browse files
committed
Wallace and Commit: The Curse of the Were-Rabgit
0 parents  commit c0aac46

File tree

5 files changed

+105
-0
lines changed

5 files changed

+105
-0
lines changed

.gitignore

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
*.py[co]
2+
3+
# Packages
4+
*.egg
5+
*.egg-info
6+
dist
7+
build
8+
eggs
9+
parts
10+
bin
11+
var
12+
sdist
13+
develop-eggs
14+
.installed.cfg
15+
16+
# Installer logs
17+
pip-log.txt
18+
19+
# Unit test / coverage reports
20+
.coverage
21+
.tox
22+
23+
#Translations
24+
*.mo

README.md

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#FuckItPy
2+
### The Python Error Steamroller
3+
FuckItPy uses state-of-the-art technology to make sure your Python code runs
4+
whether it has any right to or not.
5+
6+
## Technology
7+
Through a process known as *Exec-Rinse-And-Repeat*, FuckItPy repeatedly
8+
compiles your code, detecting errors and slicing offending lines out of the script.
9+
10+
## API
11+
**fuckit('your_shitty_module')**
12+
Use this to replace an import that is raising exceptions on import. Just change
13+
`import your_shitty_module` to `fuckit('your_shitty_module')`.
14+
15+
This will keep evaluating your code until all errors have been sliced off like
16+
mold on a piece of perfectly good bread. Whether or not the remaining code is
17+
even worth executing, we don't know. We also don't particularly care.
18+
19+
##License
20+
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
21+
Version 2, December 2004
22+
23+
Copyright (C) 2013 AJ Alt
24+
25+
Everyone is permitted to copy and distribute verbatim or modified
26+
copies of this license document, and changing it is allowed as long
27+
as the name is changed.
28+
29+
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
30+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
31+
32+
0. You just DO WHAT THE FUCK YOU WANT TO.
33+
34+
## Attribution
35+
36+
This module is inspired by Matt Diamond's [FuckIt.js](https://github.com/mattdiamond/fuckitjs)

broke.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
def f():
2+
piss
3+
4+
let's just assume this is a big module of shitty code.
5+
6+
x = y
7+
y = x
8+
1 / 0 # Oh shhhiiiiiii
9+
10+
var = "Are you proud of what you've done?"

fuckit.py

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import inspect
2+
import imp
3+
import ast
4+
import types
5+
import sys
6+
import traceback
7+
import functools
8+
9+
def fuckit(victim):
10+
if isinstance(victim, (str, unicode)):
11+
file, pathname, description = imp.find_module(victim)
12+
source = file.read()
13+
while True:
14+
try:
15+
code = compile(source, pathname, 'exec')
16+
module = types.ModuleType(victim)
17+
module.__file__ = pathname
18+
sys.modules[victim] = module
19+
exec code in module.__dict__
20+
except Exception as exc:
21+
lineno = getattr(exc, 'lineno',
22+
traceback.extract_tb(sys.exc_info()[2])[-1][1])
23+
lines = source.splitlines()
24+
del lines[lineno - 1]
25+
source = '\n'.join(lines)
26+
else:
27+
break
28+
inspect.stack()[1][0].f_locals[victim] = module

test.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from fuckit import fuckit
2+
3+
#import broke
4+
fuckit('broke')
5+
6+
print broke.var
7+

0 commit comments

Comments
 (0)