当前位置: 首页>>代码示例>>Python>>正文


Python Song.songFile方法代码示例

本文整理汇总了Python中song.Song.songFile方法的典型用法代码示例。如果您正苦于以下问题:Python Song.songFile方法的具体用法?Python Song.songFile怎么用?Python Song.songFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在song.Song的用法示例。


在下文中一共展示了Song.songFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: parse

# 需要导入模块: from song import Song [as 别名]
# 或者: from song.Song import songFile [as 别名]
    def parse(self):
        song = Song()
        #song.name = self.name
        token = self._tokens.dequeue()
        #TODO Parse the file and build a complete Song object to be returned
        for x in range(0, self._tokens.size() + 1):
            if (token.type == 0 and token.value == "song"):
                token = self._tokens.dequeue()
                while(token):
                    if (token.type == 1 and token.value == "song"):
                        #print("done")
                        #print(song.verses)
                        return song
                        break
                    elif (token.type == 0 and token.value == "name"):
                        token = self._tokens.dequeue()
                        while(token):
                            if (token.type == 4 or token.type == 2 or token.type == 3):
                                song.name = str(token.value)
                                print(token.value)
                                token = self._tokens.dequeue()
                                if (token.type == 1 and token.value == "name"):
                                    token = self._tokens.dequeue()
                                    print("hello")
                                    break
                                else:
                                    print("Parse Error")
                                    break
                            else:
                                print("Invalid type for name tag")
                                break
                    elif (token.type == 0 and token.value == "backgroundColor"):
                        token = self._tokens.dequeue()
                        while(token):
                            if (self.colors == 3):
                                self.colors = 0
                                #print("gettin somewhere")
                                song.backgroundColor = (self.red, self.green, self.blue)
                                token = self._tokens.dequeue()
                                break
                            elif (token.type == 0 and token.value == "red"):
                                token = self._tokens.dequeue()
                                if (token.type == 2 or token.type == 3):
                                    self.red = token.value
                                    self.color = self.color + self.red
                                    self.colors += 1 
                                    token = self._tokens.dequeue()
                                    if (token.type == 1 and token.value == "red"):
                                        token = self._tokens.dequeue()
                                    else:
                                        print("Parse Error")
                                        break
                                else:
                                    print("Parse Error")
                                    break
                            elif (token.type == 0 and token.value == "blue"):
                                token = self._tokens.dequeue()
                                if (token.type == 2 or token.type == 3):
                                    self.blue = token.value
                                    self.color = self.color + (self.blue * 256)
                                    self.colors += 1
                                    token = self._tokens.dequeue()
                                    if (token.type == 1 and token.value == "blue"):
                                        token = self._tokens.dequeue()
                                    else:
                                        print("Parse Error")
                                        break
                                else:
                                    print("Parse Error")
                                    break
                            elif (token.type == 0 and token.value == "green"):
                                token = self._tokens.dequeue()
                                if (token.type == 2 or token.type == 3):
                                    self.green = token.value
                                    self.color = self.color + (self.green * 256)
                                    self.colors += 1
                                    token = self._tokens.dequeue()
                                    if (token.type == 1 and token.value == "green"):
                                        token = self._tokens.dequeue()
                                    else:
                                        print("Parse Error")
                                        break
                                else:
                                    print("Parse Error")
                                    break
                            else:
                                print("Invalid type for backgroundcolor tag")
                                break
                    elif (token.type == 0 and token.value == "soundFile"):
                        token = self._tokens.dequeue()
                        while(token):
                            if (token.type == 4):
                                song.songFile = token.value
                                token = self._tokens.dequeue()
                                if (token.type == 1 and token.value == "soundFile"):
                                    token = self._tokens.dequeue()
                                    break
                                else:
                                    print("Parse Error")
                                    break
#.........这里部分代码省略.........
开发者ID:chocobear,项目名称:karaoke,代码行数:103,代码来源:xmlparser.py


注:本文中的song.Song.songFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。