Skip to content

Commit 837b2ba

Browse files
committed
Merge pull request #2 from crazyh/master
Fix broken pip compatibility, hardcode python2.7 dependency
2 parents c2312e9 + e97d03b commit 837b2ba

File tree

5 files changed

+41
-42
lines changed

5 files changed

+41
-42
lines changed

output.py

Lines changed: 0 additions & 37 deletions
This file was deleted.

pyobfuscate

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python2.7
22
# -*-mode: python; coding: utf-8 -*-
33
#
44
# pyobfuscate - Python source code obfuscator
@@ -36,7 +36,43 @@ import re
3636
import ast
3737

3838
import astor
39-
from output import BaseWriter, StdoutWriter, FileWriter
39+
40+
import os
41+
import shutil
42+
from tempfile import mkstemp
43+
44+
45+
class BaseWriter(object):
46+
def write(self, raw_str):
47+
raise NotImplemented()
48+
49+
def close(self):
50+
pass
51+
52+
53+
class StdoutWriter(BaseWriter):
54+
def write(self, raw_str):
55+
sys.stdout.write(raw_str)
56+
57+
58+
class FileWriter(BaseWriter):
59+
def __init__(self, file_name):
60+
self.target_filename = file_name
61+
_, self.temp_filename = mkstemp()
62+
self.file_obj = open(self.temp_filename, 'w')
63+
64+
def write(self, raw_str):
65+
self.file_obj.write(raw_str)
66+
67+
def close(self):
68+
self.file_obj.close()
69+
try:
70+
shutil.copyfile(self.temp_filename, self.target_filename)
71+
except IOError:
72+
print >> sys.stderr, 'Failed to write to the file. ' \
73+
'The obfuscated content is left in temporary file %s' % self.temp_filename
74+
raise
75+
os.unlink(self.temp_filename)
4076

4177
TOKENBLANKS=1
4278
MAX_STRING_RECURSION = 10

pyobfuscate-install

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python2.7
22
# pyobfuscate - Python source code obfuscator
33
#
44
# Copyright 2004-2007 Peter Astrand <astrand@cendio.se> for Cendio AB

pyobfuscate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python2.7
22
#
33
# Execute the file with the same name as myself minus the extension.
44
# Author: Peter Astrand <astrand@cendio.se>

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python2.7
22

33
DESCRIPTION = """\
44
Python source code obfuscator

0 commit comments

Comments
 (0)