1 |
""" foo |
""" foo |
2 |
""" |
""" |
3 |
import sys, getopt, os, stat, cPickle |
import sys, getopt, os, stat, cPickle, os.path |
4 |
import Exporters |
import Exporters |
5 |
#import Xot <-- moved down for performance reasons |
#import Xot <-- moved down for performance reasons |
6 |
|
|
51 |
export = True |
export = True |
52 |
options = {} |
options = {} |
53 |
exporter_help = False |
exporter_help = False |
54 |
hook_names = [] |
hook_names = '' |
55 |
for o, a in opts: |
for o, a in opts: |
56 |
if o in ("-r", "--repickle"): |
if o in ("-r", "--repickle"): |
57 |
repickle = True |
repickle = True |
70 |
(a, ", ".join(Exporters.desc)) |
(a, ", ".join(Exporters.desc)) |
71 |
exporter = a |
exporter = a |
72 |
if o in ("-k", "--hooks"): |
if o in ("-k", "--hooks"): |
73 |
hook_names = a.split(',') |
hook_names = a |
74 |
if o in ("-O", "--options"): |
if o in ("-O", "--options"): |
75 |
options = dict(map(lambda _: (_.split(':') + [1])[:2], |
options = dict(map(lambda _: (_.split(':') + [1])[:2], |
76 |
a.split(','))) |
a.split(','))) |
77 |
|
|
78 |
Exporter = __import__('Exporters.%s' % exporter, globals(), locals(), [exporter]) |
Exporter = __import__('Exporters.%s' % exporter, |
79 |
|
globals(), locals(), [exporter]) |
80 |
if exporter_help: |
if exporter_help: |
81 |
print Exporter.__doc__.strip() |
print Exporter.__doc__.strip() |
82 |
sys.exit() |
sys.exit() |
91 |
|
|
92 |
file = args[0] |
file = args[0] |
93 |
fs = os.stat(file) |
fs = os.stat(file) |
94 |
pickled = '.%s.pickle' % file |
pickled = os.path.join(os.path.dirname(file), |
95 |
|
'.%s.%s.pickle' % (os.path.basename(file), |
96 |
|
hook_names)) |
97 |
ps = None |
ps = None |
98 |
try: |
try: |
99 |
ps = os.stat(pickled) |
ps = os.stat(pickled) |
105 |
p=open(pickled) |
p=open(pickled) |
106 |
xot=cPickle.load(p) |
xot=cPickle.load(p) |
107 |
else: |
else: |
108 |
xot=Xot.new(file, *hook_names) |
xot=Xot.new(file, *(hook_names.split(','))) |
109 |
if pickle: |
if pickle: |
110 |
p=open(pickled, 'w') |
p=open(pickled, 'w') |
111 |
cPickle.dump(xot, p, True) |
cPickle.dump(xot, p, True) |