|
28 | 28 | from ordereddict import OrderedDict |
29 | 29 |
|
30 | 30 | from copy import deepcopy |
31 | | -import pickle |
| 31 | +try: |
| 32 | + import cPickle as pickle |
| 33 | +except: |
| 34 | + import pickle |
| 35 | + |
32 | 36 | from glob import glob |
33 | 37 | import gzip |
34 | 38 | import inspect |
@@ -81,12 +85,12 @@ def _write_inputs(node): |
81 | 85 | if type(val) == str: |
82 | 86 | try: |
83 | 87 | func = create_function_from_source(val) |
84 | | - except RuntimeError, e: |
| 88 | + except RuntimeError: |
85 | 89 | lines.append("%s.inputs.%s = '%s'" % (nodename, key, val)) |
86 | 90 | else: |
87 | 91 | funcname = [name for name in func.func_globals |
88 | 92 | if name != '__builtins__'][0] |
89 | | - lines.append(cPickle.loads(val)) |
| 93 | + lines.append(pickle.loads(val)) |
90 | 94 | if funcname == nodename: |
91 | 95 | lines[-1] = lines[-1].replace(' %s(' % funcname, |
92 | 96 | ' %s_1(' % funcname) |
@@ -207,7 +211,7 @@ def _check_inputs(self, parameter): |
207 | 211 | return hasattr(self.inputs, parameter) |
208 | 212 |
|
209 | 213 | def _verify_name(self, name): |
210 | | - valid_name = bool(re.match('^[\w-]+$', name)) |
| 214 | + valid_name = bool(re.match(r'^[\w-]+$', name)) |
211 | 215 | if not valid_name: |
212 | 216 | raise Exception('the name must not contain any special characters') |
213 | 217 |
|
@@ -650,7 +654,7 @@ def export(self, filename=None, prefix="output", format="python", |
650 | 654 | lines.append(connect_template2 % line_args) |
651 | 655 | functionlines = ['# Functions'] |
652 | 656 | for function in functions: |
653 | | - functionlines.append(cPickle.loads(function).rstrip()) |
| 657 | + functionlines.append(pickle.loads(function).rstrip()) |
654 | 658 | all_lines = importlines + functionlines + lines |
655 | 659 |
|
656 | 660 | if not filename: |
|
0 commit comments