/[papo]/papo/xot/exotic.py
ViewVC logotype

Diff of /papo/xot/exotic.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by jlenton, Thu Jul 31 18:55:07 2003 UTC revision 1.2 by jlenton, Wed Sep 3 21:41:38 2003 UTC
# Line 1  Line 1 
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    
# Line 51  def main(): Line 51  def main():
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
# Line 70  def main(): Line 70  def main():
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()
# Line 90  def main(): Line 91  def main():
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)
# Line 102  def main(): Line 105  def main():
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)

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26