コード例 #1
0
 def startElement(self, name, attrs):
     if not name in self.knownTags:
         if not self.ignore_missing_tags:
             print "Error: Unknown Master element '%s'." % name
             sys.exit()
         elif not name in self.unknown_tags:
             self.unknown_tags.append(name)
     self.stack.append(name)
     if name == 'master':
         self.master = model.Master()
         self.master.id = int(attrs['id'])
     elif name == "image":
         img = model.ImageInfo()
         img.height = attrs["height"]
         img.imageType = attrs["type"]
         img.uri = attrs["uri"]
         img.uri150 = attrs["uri150"]
         img.width = attrs["width"]
         self.master.images.append(img)
         if len(attrs) != 5:
             print "ATTR ERROR"
             print attrs
             sys.exit()
     elif name == "video":
         vid = model.Video()
         vid.duration = attrs["duration"]
         vid.embed = attrs["embed"]
         vid.uri = attrs["src"]
         self.master.videos.append(vid)
     elif name == "artist":
         self.master.artists.append(model.ArtistCredit())
コード例 #2
0
ファイル: seed.py プロジェクト: aroundthesea/supply-cache
def load_master(session):
    f = open("seed_data/u.master")
    rows = f.read().split("\n")
    f.close()

    for line in rows:
        row = line.split("|")
        name = row[0]
        email = row[1]
        phone_num = row[2]
        full_address = row[3]
        lat = row[4]
        lng = row[5]
        supply_type = row[6]
        extra_comment = row[-1]

        master = model.Master(name=name,
                              email=email,
                              phone_num=phone_num,
                              full_address=full_address,
                              lat=lat,
                              lng=lng,
                              supply_type=supply_type,
                              extra_comment=extra_comment)
        user = model.User(name=name, email=email, phone_num=phone_num)
        location = model.Location(full_address=full_address, lat=lat, lng=lng)
        supply = model.Supply(supply_type=supply_type)
        comment = model.Comment(extra_comment=extra_comment)

        model.session.add(master)
        model.session.add(user)
        model.session.add(location)
        model.session.add(supply)
        model.session.add(comment)
コード例 #3
0
    def startElement(self, name, attrs):
        if not name in self.knownTags:
            if not self.ignore_missing_tags:
                print "Error: Unknown Master element '%s'." % name
                sys.exit()
            elif not name in self.unknown_tags:
                self.unknown_tags.append(name)
        self.stack.append(name)

        if name == 'master':
            self.master = model.Master()
            self.master.id = int(attrs['id'])

        elif name == 'artist':
            ma = model.ReleaseArtist()
            self.master.artists.append(ma)
コード例 #4
0
 def startElement(self, name, attrs):
     if not name in self.knownTags:
         if not self.ignore_missing_tags:
             print "Error: Unknown Master element '%s'." % name
             sys.exit()
         elif not name in self.unknown_tags:
             self.unknown_tags.append(name)
     self.stack.append(name)
     if name == 'master':
         self.master = model.Master()
         self.master.id = int(attrs['id'])
     elif name == "image":
         img = model.ImageInfo()
         img.height = attrs["height"]
         img.imageType = attrs["type"]
         img.uri = attrs["uri"]
         img.uri150 = attrs["uri150"]
         img.width = attrs["width"]
         self.master.images.append(img)
         if len(attrs) != 5:
             print "ATTR ERROR"
             print attrs
             sys.exit()