<?xml version="1.0"?>
<paste-with-annotations>
  <paste>
    <number>
      <integer>5997</integer>
    </number>
    <user>
      <string>sbp</string>
    </user>
    <title>
      <string>Location Date File Reader thing for crschmidt (still horrid, but a step in a nice direction)</string>
    </title>
    <contents>
      <string>class LocationDataReader(object): 
   def __init__(self, uri, parent): 
      self.uri = uri
      self.parent = parent

      self.title = None
      self.uripattern = None
      self.tabnames = {}
      self.places = {}

      self.parse()

   def parse(self): 
      self.openuri()
      try: self.head()
      except Exception, e: 
         msg = 'This file is invalid and raised the error: %r'
         appuifw.note(msg % e, 'error')
         self.parent.restart()

      for line in self.u: 
         line = line.rstrip('\r\n')
         try: 
            # p and q need naming better
            code, p, q = line.split('\t', 2)
            self.places[code][p] = unicode(q)
            appuifw.app.body.add(u&quot;.&quot;)
         except: 
            msg = u&quot;\nThe following line is ill formed: %s&quot; % line
            appuifw.app.body.add(msg)

   def openuri(self, uri=None): 
      if uri is None: 
         uri = self.uri

      try: self.u = urllib.urlopen(self.uri)
      except Exception, e: 
         msg = 'That URI produced an error: %r. Restarting.'
         appuifw.note(msg % e, 'error')
         return

   def head(self): 
      line = self.u.next().rstrip('\r\n')
      while line.startswith('#'): 
         line = self.u.next().rstrip('\r\n')
      self.title = unicode(line)
      self.urlpattern = self.u.next().rstrip('\r\n')

      for item in self.u.next().rstrip('\r\n').split('\t'):
         longname, code = item.split('::', 1)
         places[code] = dict()
         tab[code] = unicode(longname)
</string>
    </contents>
    <universal-time>
      <integer>3318088259</integer>
    </universal-time>
    <channel>
      <string>#swhack</string>
    </channel>
    <colorization-mode>
      <string>None</string>
    </colorization-mode>
    <maybe-spam>
      <null/>
    </maybe-spam>
    <is-unicode>
      <null/>
    </is-unicode>
  </paste>
  <annotation>
    <number>
      <integer>5</integer>
    </number>
    <user>
      <string>sbp</string>
    </user>
    <title>
      <string>Typos, &amp;c.</string>
    </title>
    <contents>
      <string># Orginal by: crschmidt
# Refactoring by: sbp
# Insight and ideas by: deltab

class LocationDataReader(object):
   def __init__(self, uri, parent):
      self.uri = uri
      self.parent = parent

      self.title = None
      self.uripattern = None
      self.tabnames = {}
      self.places = {}

      self.parse()

   def openuri(self, uri=None):
      if uri is None:
         uri = self.uri

      try: self.u = urllib.urlopen(uri)
      except Exception, e:
         msg = 'That URI produced an error: %r. Restarting.'
         appuifw.note(msg % e, 'error')
         return

   def getline(self):
      while 1:
         try: rawline = self.u.next()
         except StopIteration: return None
         if not rawline.startswith('#'): break
      return rawline.rstrip()

   def head(self):
      self.title = unicode(self.getline())
      self.urlpattern = self.getline()

      for item in self.getline().split('\t'): 
         longname, area = item.split('::', 1)
         self.places[area] = {}
         self.tabnames[area] = unicode(longname)

   def safehead(self):
      try: self.head()
      except Exception, e:
         msg = 'This file is invalid and raised the error: %r'
         appuifw.note(msg % e, 'error')
         self.parent.restart()

   def body(self):
      while 1:
         line = self.getline()
         if line is None: break
         try:
            area, camera, name = line.split('\t', 2)
            self.places[area][camera] = unicode(name)
            appuifw.app.body.add(u'.')
         except:
            msg = u'\nThe following line is ill-formed: %s' % line
            appuifw.app.body.add(msg)

   def parse(self):
      self.openuri()
      self.safehead()
      self.body()
</string>
    </contents>
    <universal-time>
      <integer>3318089698</integer>
    </universal-time>
    <channel>
      <string>#swhack</string>
    </channel>
    <colorization-mode>
      <string></string>
    </colorization-mode>
    <maybe-spam>
      <null/>
    </maybe-spam>
    <is-unicode>
      <null/>
    </is-unicode>
  </annotation>
  <annotation>
    <number>
      <integer>4</integer>
    </number>
    <user>
      <string>sbp</string>
    </user>
    <title>
      <string>Mmm... teamwork.</string>
    </title>
    <contents>
      <string>class LocationDataReader(object):
   def __init__(self, uri, parent):
      self.uri = uri
      self.parent = parent

      self.title = None
      self.uripattern = None
      self.tabnames = {}
      self.places = {}

      self.parse()

   def openuri(self, uri=None):
      if uri is None:
         uri = self.uri

      try: self.u = urllib.urlopen(uri)
      except Exception, e:
         msg = 'That URI produced an error: %r. Restarting.'
         appuifw.note(msg % e, 'error')
         return

   def getline(self): 
      while 1: 
         try: rawline = self.u.next()
         except StopIteration: return None # thanks deltab
         if not rawline.startswith('#'): break
      return rawline.rstrip()

   def head(self): 
      self.title = unicode(self.getline())
      self.urlpattern = self.getline()

      for item in self.getline().split('\t'):
         longname, area = item.split('::', 1)
         self.places[area] = {}
         self.tab[area] = unicode(longname)

   def safehead(self): 
      try: self.head()
      except Exception, e:
         msg = 'This file is invalid and raised the error: %r'
         appuifw.note(msg % e, 'error')
         self.parent.restart()

   def body(self):
      while 1:
         line = self.getline()
         if line is None: break
         try:
            area, camera, name = line.split('\t', 2)
            self.places[area][camera] = unicode(name)
            appuifw.app.body.add(u'.')
         except:
            msg = u'\nThe following line is ill formed: %s' % line
            appuifw.app.body.add(msg)

   def parse(self):
      self.openuri()
      self.safehead()
      self.body()
</string>
    </contents>
    <universal-time>
      <integer>3318089526</integer>
    </universal-time>
    <channel>
      <string>#swhack</string>
    </channel>
    <colorization-mode>
      <string></string>
    </colorization-mode>
    <maybe-spam>
      <null/>
    </maybe-spam>
    <is-unicode>
      <null/>
    </is-unicode>
  </annotation>
  <annotation>
    <number>
      <integer>3</integer>
    </number>
    <user>
      <string>sbp</string>
    </user>
    <title>
      <string>Where would we be if not for decrudination?</string>
    </title>
    <contents>
      <string>class LocationDataReader(object):
   def __init__(self, uri, parent):
      self.uri = uri
      self.parent = parent

      self.title = None
      self.uripattern = None
      self.tabnames = {}
      self.places = {}

      self.parse()

   def openuri(self, uri=None):
      if uri is None:
         uri = self.uri

      try: self.u = urllib.urlopen(uri)
      except Exception, e:
         msg = 'That URI produced an error: %r. Restarting.'
         appuifw.note(msg % e, 'error')
         return

   def getline(self):
      try: rawline = self.u.next()
      except StopIteration: return None # thanks deltab
      return line.rstrip()

   def head(self):
      line = self.getline()
      while line.startswith('#'):
         line = self.getline()
      self.title = unicode(line)
      self.urlpattern = self.getline()

      for item in self.getline().split('\t'):
         longname, code = item.split('::', 1)
         self.places[code] = {}
         self.tab[code] = unicode(longname)

   def body(self): 
      while 1:
         line = self.getline()
         if line is None: break
         try:
            code, num, desc = line.split('\t', 2)
            self.places[code][num] = unicode(desc)
            appuifw.app.body.add(u'.')
         except:
            msg = u'\nThe following line is ill formed: %s' % line
            appuifw.app.body.add(msg)

   def parse(self):
      self.openuri()
      try: self.head()
      except Exception, e:
         msg = 'This file is invalid and raised the error: %r'
         appuifw.note(msg % e, 'error')
         self.parent.restart()
      self.body()
</string>
    </contents>
    <universal-time>
      <integer>3318088988</integer>
    </universal-time>
    <channel>
      <string>#swhack</string>
    </channel>
    <colorization-mode>
      <string></string>
    </colorization-mode>
    <maybe-spam>
      <null/>
    </maybe-spam>
    <is-unicode>
      <null/>
    </is-unicode>
  </annotation>
  <annotation>
    <number>
      <integer>2</integer>
    </number>
    <user>
      <string>sbp</string>
    </user>
    <title>
      <string>Even more &amp;c.</string>
    </title>
    <contents>
      <string>class LocationDataReader(object):
   def __init__(self, uri, parent):
      self.uri = uri
      self.parent = parent

      self.title = None
      self.uripattern = None
      self.tabnames = {}
      self.places = {}

      self.parse()

   def parse(self):
      self.openuri()
      try: self.head()
      except Exception, e:
         msg = 'This file is invalid and raised the error: %r'
         appuifw.note(msg % e, 'error')
         self.parent.restart()

      while 1:
         line = self.getline()
         if line is None: break
         try:
            code, num, desc = line.split('\t', 2)
            self.places[code][num] = unicode(desc)
            appuifw.app.body.add(u'.')
         except:
            msg = u'\nThe following line is ill formed: %s' % line
            appuifw.app.body.add(msg)

   def openuri(self, uri=None):
      if uri is None:
         uri = self.uri

      try: self.u = urllib.urlopen(uri)
      except Exception, e:
         msg = 'That URI produced an error: %r. Restarting.'
         appuifw.note(msg % e, 'error')
         return

   def head(self):
      line = self.getline()
      while line.startswith('#'):
         line = self.getline()
      self.title = unicode(line)
      self.urlpattern = self.getline()

      for item in self.getline().split('\t'):
         longname, code = item.split('::', 1)
         self.places[code] = {}
         self.tab[code] = unicode(longname)

   def getline(self):
      rawline = self.u.next()
      if not line: return None
      return line.rstrip()
</string>
    </contents>
    <universal-time>
      <integer>3318088809</integer>
    </universal-time>
    <channel>
      <string>#swhack</string>
    </channel>
    <colorization-mode>
      <string></string>
    </colorization-mode>
    <maybe-spam>
      <null/>
    </maybe-spam>
    <is-unicode>
      <null/>
    </is-unicode>
  </annotation>
  <annotation>
    <number>
      <integer>1</integer>
    </number>
    <user>
      <string>sbp</string>
    </user>
    <title>
      <string>Further decrudination</string>
    </title>
    <contents>
      <string>class LocationDataReader(object):
   def __init__(self, uri, parent):
      self.uri = uri
      self.parent = parent

      self.title = None
      self.uripattern = None
      self.tabnames = {}
      self.places = {}

      self.parse()

   def parse(self):
      self.openuri()
      try: self.head()
      except Exception, e:
         msg = 'This file is invalid and raised the error: %r'
         appuifw.note(msg % e, 'error')
         self.parent.restart()

      while 1:
         line = self.getline()
         if line is None: break
         try:
            # p and q need naming better
            code, p, q = line.split('\t', 2)
            self.places[code][p] = unicode(q)
            appuifw.app.body.add(u&quot;.&quot;)
         except:
            msg = u&quot;\nThe following line is ill formed: %s&quot; % line
            appuifw.app.body.add(msg)

   def openuri(self, uri=None):
      if uri is None:
         uri = self.uri

      try: self.u = urllib.urlopen(uri)
      except Exception, e:
         msg = 'That URI produced an error: %r. Restarting.'
         appuifw.note(msg % e, 'error')
         return

   def head(self):
      line = self.getline()
      while line.startswith('#'):
         line = self.getline()
      self.title = unicode(line)
      self.urlpattern = self.getline()

      for item in self.getline().split('\t'): 
         longname, code = item.split('::', 1)
         places[code] = dict()
         tab[code] = unicode(longname)

   def getline(self): 
      rawline = self.u.next()
      if not line: return None
      return line.rstrip('\r\n')
</string>
    </contents>
    <universal-time>
      <integer>3318088658</integer>
    </universal-time>
    <channel>
      <string>#swhack</string>
    </channel>
    <colorization-mode>
      <string></string>
    </colorization-mode>
    <maybe-spam>
      <null/>
    </maybe-spam>
    <is-unicode>
      <null/>
    </is-unicode>
  </annotation>
</paste-with-annotations>