bugged
stringlengths 4
228k
| fixed
stringlengths 0
96.3M
| __index_level_0__
int64 0
481k
|
|---|---|---|
def __init__ (self,parent,ID,title,pos=wx.DefaultPosition,size=wx.DefaultSize, style = wx.DEFAULT_FRAME_STYLE | wx.VSCROLL | wx.HSCROLL, name = "frame"): wx.MDIParentFrame.__init__(self,parent,ID,title,pos,size,style) self.winCount = 0
|
def __init__ (self,parent,ID,title,pos=wx.DefaultPosition,size=wx.DefaultSize, style = wx.DEFAULT_FRAME_STYLE | wx.VSCROLL | wx.HSCROLL, name = "frame"): wx.MDIParentFrame.__init__(self,parent,ID,title,pos,size,style) self.winCount = 0
| 6,100
|
def __init__ (self,parent,ID,title,pos=wx.DefaultPosition,size=wx.DefaultSize, style = wx.DEFAULT_FRAME_STYLE | wx.VSCROLL | wx.HSCROLL, name = "frame"): wx.MDIParentFrame.__init__(self,parent,ID,title,pos,size,style) self.winCount = 0
|
def __init__ (self,parent,ID,title,pos=wx.DefaultPosition,size=wx.DefaultSize, style = wx.DEFAULT_FRAME_STYLE | wx.VSCROLL | wx.HSCROLL, name = "frame"): wx.MDIParentFrame.__init__(self,parent,ID,title,pos,size,style) self.winCount = 0
| 6,101
|
def __init__ (self,parent,ID,title,pos=wx.DefaultPosition,size=wx.DefaultSize, style = wx.DEFAULT_FRAME_STYLE | wx.VSCROLL | wx.HSCROLL, name = "frame"): wx.MDIParentFrame.__init__(self,parent,ID,title,pos,size,style) self.winCount = 0
|
def __init__ (self,parent,ID,title,pos=wx.DefaultPosition,size=wx.DefaultSize, style = wx.DEFAULT_FRAME_STYLE | wx.VSCROLL | wx.HSCROLL, name = "frame"): wx.MDIParentFrame.__init__(self,parent,ID,title,pos,size,style) self.winCount = 0
| 6,102
|
def __init__ (self,parent,ID,title,pos=wx.DefaultPosition,size=wx.DefaultSize, style = wx.DEFAULT_FRAME_STYLE | wx.VSCROLL | wx.HSCROLL, name = "frame"): wx.MDIParentFrame.__init__(self,parent,ID,title,pos,size,style) self.winCount = 0
|
def __init__ (self,parent,ID,title,pos=wx.DefaultPosition,size=wx.DefaultSize, style = wx.DEFAULT_FRAME_STYLE | wx.VSCROLL | wx.HSCROLL, name = "frame"): wx.MDIParentFrame.__init__(self,parent,ID,title,pos,size,style) self.winCount = 0
| 6,103
|
def OpenFile(self,path): child = self.GetActiveChild() if child == None: maximizeNewWindow = False else: maximizeNewWindow = child.IsMaximized() file = open(path ,"r") textContent = file.read() file.close() if textContent[0:5] == '{\\rtf': win = self.OnNewRTFWindow(None) win.rtfSubWin.LoadFile(path) courierFont = wx.Font(10,wx.MODERN,wx.NORMAL,wx.NORMAL,False,"Courier New") textAttr = wx.TextAttr(wx.NullColour, wx.NullColour, courierFont) textAttr.SetFlags(wx.TEXT_ATTR_FONT_SIZE) #win.rtfSubWin.SetStyle(0,win.rtfSubWin.GetLastPosition(), textAttr) # we first need to convert rtf to something better... #win = self.OnNewCodeWindow(None) #newTextContent = PySCLang.Rtf2Ascii(textContent) <--- this looks very bad #win.codeSubWin.AddText(newTextContent) else : win = self.OnNewCodeWindow(None) win.codeSubWin.AddText(textContent) win.originalFilePath = path win.SetTitle(path) if maximizeNewWindow : win.Maximize(True) win.isModified = 0 win.SetSubWinFocus() return win
|
def OpenFile(self,path): child = self.GetActiveChild() if child == None: maximizeNewWindow = False else: maximizeNewWindow = child.IsMaximized() file = open(path ,"r") textContent = file.read() file.close() if textContent[0:5] == '{\\rtf': win = self.OnNewRTFWindow(None) win.rtfSubWin.LoadFile(path) courierFont = wx.Font(10,wx.MODERN,wx.NORMAL,wx.NORMAL,False,"Courier New") textAttr = wx.TextAttr(wx.NullColour, wx.NullColour, courierFont) textAttr.SetFlags(wx.TEXT_ATTR_FONT_SIZE) #win.rtfSubWin.SetStyle(0,win.rtfSubWin.GetLastPosition(), textAttr) # we first need to convert rtf to something better... #win = self.OnNewCodeWindow(None) #newTextContent = PySCLang.Rtf2Ascii(textContent) <--- this looks very bad #win.codeSubWin.AddText(newTextContent) else: win = self.OnNewCodeWindow(None) win.codeSubWin.AddText(textContent) win.originalFilePath = path win.SetTitle(path) if maximizeNewWindow : win.Maximize(True) win.isModified = 0 win.SetSubWinFocus() return win
| 6,104
|
def OnSaveFile(self,evt): activeWin = self.GetActiveChild( ); self.OnSaveFileInWin(evt,activeWin) # yssr
|
def OnSaveFile(self,evt): activeWin = self.GetActiveChild( ); self.OnSaveFileInWin(evt,activeWin) # yssr
| 6,105
|
def OnSaveFileInWin(self,evt,activeWin): if activeWin == self.logWin: return None # yssr if activeWin == None: # TODO : disable menu items dynamically instead wx.MessageBox("ERROR : No document is active") else: # fileDlg = wx.FileDialog(self,style=wx.SAVE) path = activeWin.originalFilePath # path = fileDlg.GetPath() if path == "": self.OnSaveFileAsInWin(evt,activeWin) else: file = open(path ,"w" ) content = activeWin.codeSubWin.GetText() file.write(content) file.close() activeWin.SetTitle(path) # yssr activeWin.isModified = 0 # yssr
|
def OnSaveFileInWin(self,evt,activeWin): if activeWin == self.logWin: return None # yssr if activeWin == None: # TODO : disable menu items dynamically instead wx.MessageBox("ERROR : No document is active") else: # fileDlg = wx.FileDialog(self,style=wx.SAVE) path = activeWin.originalFilePath # path = fileDlg.GetPath() if path == "": self.OnSaveFileAsInWin(evt,activeWin) else: file = open(path ,"w" ) content = activeWin.codeSubWin.GetText() file.write(content) file.close() activeWin.SetTitle(path) # yssr activeWin.isModified = 0 # yssr
| 6,106
|
def OnAccelF2(self,evt): #wx.MessageBox("OnAccelF2") self.OnArrangeWindows(evt)
|
def OnAccelF2(self,evt): #wx.MessageBox("OnAccelF2") self.OnArrangeWindows(evt)
| 6,107
|
def OnCloseWindow(self, event): # TODO : make sure users are asked to save docs !!! deal with rtf file saving shouldVeto = 0 for win in self.GetChildren(): if type(win) == PsycolliderCodeWin: if not self.IsAllowedToCloseWindow(win): shouldVeto = 1 break if shouldVeto: event.Veto() else: self.Destroy()
|
def OnCloseWindow(self, event): # TODO : make sure users are asked to save docs !!! deal with rtf file saving shouldVeto = 0 for win in self.GetChildren(): if type(win) == PsycolliderCodeWin: if not self.IsAllowedToCloseWindow(win): shouldVeto = 1 break if shouldVeto: event.Veto() else: self.Destroy()
| 6,108
|
def GoToHelpFile(self): # TODO : test this : most help files don't open. remove trailing and leading spaces from sel, too, since wxTextCtrl is behaving strangely activeChild = self.GetActiveChild() if not activeChild == self.logWin: # yssr sel = string.strip(str(activeChild.GetSelectedText())) else : sel = "" # yssr foundFilePath = "" filePath = "" if sel == "-" : sel = "subtraction" # "subtraction.rtf" elif sel == "/" : sel = "division" # "division.rtf" elif sel == "*" : sel = "(W32) multiplication" # from "*.rtf" elif sel == "**": sel = "(W32) exponentiation" # from "**.rtf" elif sel == "<" : sel = "(W32) less than" # from "<.rtf" elif sel == "<=": sel = "(W32) less than or equal" # from "<=.rtf" elif sel == ">" : sel = "(W32) greater than" # from ">.rtf" elif sel == ">=": sel = "(W32) greater than or equal" # from ">=.rtf" if sel != "": for helpFolder in [gHelpFolder, os.path.expanduser(gUserExtensionFolder)]: for folderPath, foldersInPath, fileNamesInFolder in os.walk(helpFolder): # don't visit CVS directories if 'CVS' in foldersInPath: foldersInPath.remove('CVS') for fileName in fileNamesInFolder: filePath = os.path.join(folderPath, fileName) if fileName == sel + ".help.rtf": foundFilePath = filePath break if fileName == sel + ".rtf": foundFilePath = filePath break # for fileName # if file is found, let's break if foundFilePath != "": break # for folderPath, .... # if file is found, let's break if foundFilePath != "": break if foundFilePath == "": foundFilePath = os.path.join(gHelpFolder,"Help.help.rtf") self.OpenFile(foundFilePath)
|
def GoToHelpFile(self): # TODO : test this : most help files don't open. remove trailing and leading spaces from sel, too, since wxTextCtrl is behaving strangely activeChild = self.GetActiveChild() if not activeChild == self.logWin: # yssr sel = string.strip(str(activeChild.GetSelectedText())) else : sel = "" # yssr foundFilePath = "" filePath = "" if sel == "-" : sel = "subtraction" # "subtraction.rtf" elif sel == "/" : sel = "division" # "division.rtf" elif sel == "*" : sel = "(W32) multiplication" # from "*.rtf" elif sel == "**": sel = "(W32) exponentiation" # from "**.rtf" elif sel == "<" : sel = "(W32) less than" # from "<.rtf" elif sel == "<=": sel = "(W32) less than or equal" # from "<=.rtf" elif sel == ">" : sel = "(W32) greater than" # from ">.rtf" elif sel == ">=": sel = "(W32) greater than or equal" # from ">=.rtf" if sel != "": for helpFolder in [gHelpFolder, os.path.expanduser(gUserExtensionFolder)]: for folderPath, foldersInPath, fileNamesInFolder in os.walk(helpFolder): # don't visit CVS directories if 'CVS' in foldersInPath: foldersInPath.remove('CVS') for fileName in fileNamesInFolder: filePath = os.path.join(folderPath, fileName) if fileName == sel + ".help.rtf": foundFilePath = filePath break if fileName == sel + ".rtf": foundFilePath = filePath break # for fileName # if file is found, let's break if foundFilePath != "": break # for folderPath, .... # if file is found, let's break if foundFilePath != "": break if foundFilePath == "": foundFilePath = os.path.join(gHelpFolder,"Help.help.rtf") self.OpenFile(foundFilePath)
| 6,109
|
def GoToHelpFile(self): # TODO : test this : most help files don't open. remove trailing and leading spaces from sel, too, since wxTextCtrl is behaving strangely activeChild = self.GetActiveChild() if not activeChild == self.logWin: # yssr sel = string.strip(str(activeChild.GetSelectedText())) else : sel = "" # yssr foundFilePath = "" filePath = "" if sel == "-" : sel = "subtraction" # "subtraction.rtf" elif sel == "/" : sel = "division" # "division.rtf" elif sel == "*" : sel = "(W32) multiplication" # from "*.rtf" elif sel == "**": sel = "(W32) exponentiation" # from "**.rtf" elif sel == "<" : sel = "(W32) less than" # from "<.rtf" elif sel == "<=": sel = "(W32) less than or equal" # from "<=.rtf" elif sel == ">" : sel = "(W32) greater than" # from ">.rtf" elif sel == ">=": sel = "(W32) greater than or equal" # from ">=.rtf" if sel != "": for helpFolder in [gHelpFolder, os.path.expanduser(gUserExtensionFolder)]: for folderPath, foldersInPath, fileNamesInFolder in os.walk(helpFolder): # don't visit CVS directories if 'CVS' in foldersInPath: foldersInPath.remove('CVS') for fileName in fileNamesInFolder: filePath = os.path.join(folderPath, fileName) if fileName == sel + ".help.rtf": foundFilePath = filePath break if fileName == sel + ".rtf": foundFilePath = filePath break # for fileName # if file is found, let's break if foundFilePath != "": break # for folderPath, .... # if file is found, let's break if foundFilePath != "": break if foundFilePath == "": foundFilePath = os.path.join(gHelpFolder,"Help.help.rtf") self.OpenFile(foundFilePath)
|
def GoToHelpFile(self): # TODO : test this : most help files don't open. remove trailing and leading spaces from sel, too, since wxTextCtrl is behaving strangely activeChild = self.GetActiveChild() if not activeChild == self.logWin: # yssr sel = string.strip(str(activeChild.GetSelectedText())) else : sel = "" # yssr foundFilePath = "" filePath = "" if sel == "-" : sel = "subtraction" # "subtraction.rtf" elif sel == "/" : sel = "division" # "division.rtf" elif sel == "*" : sel = "(W32) multiplication" # from "*.rtf" elif sel == "**": sel = "(W32) exponentiation" # from "**.rtf" elif sel == "<" : sel = "(W32) less than" # from "<.rtf" elif sel == "<=": sel = "(W32) less than or equal" # from "<=.rtf" elif sel == ">" : sel = "(W32) greater than" # from ">.rtf" elif sel == ">=": sel = "(W32) greater than or equal" # from ">=.rtf" if sel != "": for helpFolder in [gHelpFolder, os.path.expanduser(gUserExtensionFolder)]: for folderPath, foldersInPath, fileNamesInFolder in os.walk(helpFolder): # don't visit CVS directories if 'CVS' in foldersInPath: foldersInPath.remove('CVS') for fileName in fileNamesInFolder: filePath = os.path.join(folderPath, fileName) if fileName == sel + ".help.rtf": foundFilePath = filePath break if fileName == sel + ".rtf": foundFilePath = filePath break # for fileName # if file is found, let's break if foundFilePath != "": break # for folderPath, .... # if file is found, let's break if foundFilePath != "": break if foundFilePath == "": foundFilePath = os.path.join(gHelpFolder,"Help.help.rtf") self.OpenFile(foundFilePath)
| 6,110
|
def GoToHelpFile(self): # TODO : test this : most help files don't open. remove trailing and leading spaces from sel, too, since wxTextCtrl is behaving strangely activeChild = self.GetActiveChild() if not activeChild == self.logWin: # yssr sel = string.strip(str(activeChild.GetSelectedText())) else : sel = "" # yssr foundFilePath = "" filePath = "" if sel == "-" : sel = "subtraction" # "subtraction.rtf" elif sel == "/" : sel = "division" # "division.rtf" elif sel == "*" : sel = "(W32) multiplication" # from "*.rtf" elif sel == "**": sel = "(W32) exponentiation" # from "**.rtf" elif sel == "<" : sel = "(W32) less than" # from "<.rtf" elif sel == "<=": sel = "(W32) less than or equal" # from "<=.rtf" elif sel == ">" : sel = "(W32) greater than" # from ">.rtf" elif sel == ">=": sel = "(W32) greater than or equal" # from ">=.rtf" if sel != "": for helpFolder in [gHelpFolder, os.path.expanduser(gUserExtensionFolder)]: for folderPath, foldersInPath, fileNamesInFolder in os.walk(helpFolder): # don't visit CVS directories if 'CVS' in foldersInPath: foldersInPath.remove('CVS') for fileName in fileNamesInFolder: filePath = os.path.join(folderPath, fileName) if fileName == sel + ".help.rtf": foundFilePath = filePath break if fileName == sel + ".rtf": foundFilePath = filePath break # for fileName # if file is found, let's break if foundFilePath != "": break # for folderPath, .... # if file is found, let's break if foundFilePath != "": break if foundFilePath == "": foundFilePath = os.path.join(gHelpFolder,"Help.help.rtf") self.OpenFile(foundFilePath)
|
def GoToHelpFile(self): # TODO : test this : most help files don't open. remove trailing and leading spaces from sel, too, since wxTextCtrl is behaving strangely activeChild = self.GetActiveChild() if not activeChild == self.logWin: # yssr sel = string.strip(str(activeChild.GetSelectedText())) else : sel = ""# yssr foundFilePath = "" filePath = "" if sel == "-" : sel = "subtraction" # "subtraction.rtf" elif sel == "/" : sel = "division"# "division.rtf" elif sel == "*" : sel = "(W32) multiplication"# from "*.rtf" elif sel == "**": sel = "(W32) exponentiation"# from "**.rtf" elif sel == "<" : sel = "(W32) less than" # from "<.rtf" elif sel == "<=": sel = "(W32) less than or equal"# from "<=.rtf" elif sel == ">" : sel = "(W32) greater than"# from ">.rtf" elif sel == ">=": sel = "(W32) greater than or equal" # from ">=.rtf" if sel != "": for helpFolder in [gHelpFolder, os.path.expanduser(gUserExtensionFolder)]: for folderPath, foldersInPath, fileNamesInFolder in os.walk(helpFolder): # don't visit CVS directories if 'CVS' in foldersInPath: foldersInPath.remove('CVS') for fileName in fileNamesInFolder: filePath = os.path.join(folderPath, fileName) if fileName == sel + ".help.rtf": foundFilePath = filePath break if fileName == sel + ".rtf": foundFilePath = filePath break # for fileName # if file is found, let's break if foundFilePath != "": break # for folderPath, .... # if file is found, let's break if foundFilePath != "": break if foundFilePath == "": foundFilePath = os.path.join(gHelpFolder,"Help.help.rtf") self.OpenFile(foundFilePath)
| 6,111
|
def WriteInLogWindow(text): if wx.GetApp().theMainFrame == None: sys.stdout.write(text) else: wx.GetApp().theMainFrame.logWin.logSubWin.AppendText(text)
|
def WriteInLogWindow(text): if wx.GetApp().theMainFrame == None: sys.stdout.write(text) else: wx.GetApp().theMainFrame.logWin.logSubWin.AppendText(text)
| 6,112
|
def WriteInLogWindow(text): if wx.GetApp().theMainFrame == None: sys.stdout.write(text) else: wx.GetApp().theMainFrame.logWin.logSubWin.AppendText(text)
|
def WriteInLogWindow(text): if wx.GetApp().theMainFrame == None: sys.stdout.write(text) else: wx.GetApp().theMainFrame.logWin.logSubWin.AppendText(text)
| 6,113
|
def add_path_resolver(cls, tag, path, kind=None): if not 'yaml_path_resolvers' in cls.__dict__: cls.yaml_path_resolvers = cls.yaml_path_resolvers.copy() new_path = [] for element in path: if isinstance(element, (list, tuple)): if len(element) == 2: node_check, index_check = element elif len(element) == 1: node_check = element[0] index_check = True else: raise ResolverError("Invalid path element: %s" % element) else: node_check = None index_check = element if node_check is str: node_check = ScalarNode elif node_check is list: node_check = SequenceNode elif node_check is map: node_check = MappingNode elif node_check not in [ScalarNode, SequenceNode, MappingNode] \ and not isinstance(node_check, basestring) \ and node_check is not None: raise ResolverError("Invalid node checker: %s" % node_check) if not isinstance(index_check, (basestring, int)) \ and index_check is not None: raise ResolverError("Invalid index checker: %s" % index_check) new_path.append((node_check, index_check)) if kind is str: kind = ScalarNode elif kind is list: kind = SequenceNode elif kind is map: kind = MappingNode elif kind not in [ScalarNode, SequenceNode, MappingNode] \ and kind is not None: raise ResolverError("Invalid node kind: %s" % kind) cls.yaml_path_resolvers[tuple(new_path), kind] = tag
|
def add_path_resolver(cls, tag, path, kind=None): if not 'yaml_path_resolvers' in cls.__dict__: cls.yaml_path_resolvers = cls.yaml_path_resolvers.copy() new_path = [] for element in path: if isinstance(element, (list, tuple)): if len(element) == 2: node_check, index_check = element elif len(element) == 1: node_check = element[0] index_check = True else: raise ResolverError("Invalid path element: %s" % element) else: node_check = None index_check = element if node_check is str: node_check = ScalarNode elif node_check is list: node_check = SequenceNode elif node_check is dict: node_check = MappingNode elif node_check not in [ScalarNode, SequenceNode, MappingNode] \ and not isinstance(node_check, basestring) \ and node_check is not None: raise ResolverError("Invalid node checker: %s" % node_check) if not isinstance(index_check, (basestring, int)) \ and index_check is not None: raise ResolverError("Invalid index checker: %s" % index_check) new_path.append((node_check, index_check)) if kind is str: kind = ScalarNode elif kind is list: kind = SequenceNode elif kind is map: kind = MappingNode elif kind not in [ScalarNode, SequenceNode, MappingNode] \ and kind is not None: raise ResolverError("Invalid node kind: %s" % kind) cls.yaml_path_resolvers[tuple(new_path), kind] = tag
| 6,114
|
def add_path_resolver(cls, tag, path, kind=None): if not 'yaml_path_resolvers' in cls.__dict__: cls.yaml_path_resolvers = cls.yaml_path_resolvers.copy() new_path = [] for element in path: if isinstance(element, (list, tuple)): if len(element) == 2: node_check, index_check = element elif len(element) == 1: node_check = element[0] index_check = True else: raise ResolverError("Invalid path element: %s" % element) else: node_check = None index_check = element if node_check is str: node_check = ScalarNode elif node_check is list: node_check = SequenceNode elif node_check is map: node_check = MappingNode elif node_check not in [ScalarNode, SequenceNode, MappingNode] \ and not isinstance(node_check, basestring) \ and node_check is not None: raise ResolverError("Invalid node checker: %s" % node_check) if not isinstance(index_check, (basestring, int)) \ and index_check is not None: raise ResolverError("Invalid index checker: %s" % index_check) new_path.append((node_check, index_check)) if kind is str: kind = ScalarNode elif kind is list: kind = SequenceNode elif kind is map: kind = MappingNode elif kind not in [ScalarNode, SequenceNode, MappingNode] \ and kind is not None: raise ResolverError("Invalid node kind: %s" % kind) cls.yaml_path_resolvers[tuple(new_path), kind] = tag
|
def add_path_resolver(cls, tag, path, kind=None): if not 'yaml_path_resolvers' in cls.__dict__: cls.yaml_path_resolvers = cls.yaml_path_resolvers.copy() new_path = [] for element in path: if isinstance(element, (list, tuple)): if len(element) == 2: node_check, index_check = element elif len(element) == 1: node_check = element[0] index_check = True else: raise ResolverError("Invalid path element: %s" % element) else: node_check = None index_check = element if node_check is str: node_check = ScalarNode elif node_check is list: node_check = SequenceNode elif node_check is map: node_check = MappingNode elif node_check not in [ScalarNode, SequenceNode, MappingNode] \ and not isinstance(node_check, basestring) \ and node_check is not None: raise ResolverError("Invalid node checker: %s" % node_check) if not isinstance(index_check, (basestring, int)) \ and index_check is not None: raise ResolverError("Invalid index checker: %s" % index_check) new_path.append((node_check, index_check)) if kind is str: kind = ScalarNode elif kind is list: kind = SequenceNode elif kind is dict: kind = MappingNode elif kind not in [ScalarNode, SequenceNode, MappingNode] \ and kind is not None: raise ResolverError("Invalid node kind: %s" % kind) cls.yaml_path_resolvers[tuple(new_path), kind] = tag
| 6,115
|
def parse_node(self, block=False, indentless_sequence=False): if self.check_token(AliasToken): token = self.get_token() event = AliasEvent(token.value, token.start_mark, token.end_mark) self.state = self.states.pop() else: anchor = None tag = None start_mark = end_mark = tag_mark = None if self.check_token(AnchorToken): token = self.get_token() start_mark = token.start_mark end_mark = token.end_mark anchor = token.value if self.check_token(TagToken): token = self.get_token() tag_mark = token.start_mark end_mark = token.end_mark tag = token.value elif self.check_token(TagToken): token = self.get_token() start_mark = tag_mark = token.start_mark end_mark = token.end_mark tag = token.value if self.check_token(AnchorToken): token = self.get_token() end_mark = token.end_mark anchor = token.value if tag is not None and tag != u'!': handle, suffix = tag if handle is not None: if handle not in self.tag_handles: raise ParserError("while parsing a node", start_mark, "found undefined tag handle %r" % handle.encode('utf-8'), tag_mark) tag = self.tag_handles[handle]+suffix else: tag = suffix #if tag == u'!': # raise ParserError("while parsing a node", start_mark, # "found non-specific tag '!'", tag_mark, # "Please check 'http://pyyaml.org/wiki/YAMLNonSpecificTag' and share your opinion.") if start_mark is None: start_mark = end_mark = self.peek_token().start_mark event = None collection_events = None implicit = (tag is None or tag == u'!') if indentless_sequence and self.check_token(BlockEntryToken): end_mark = self.peek_token().end_mark event = SequenceStartEvent(anchor, tag, implicit, start_mark, end_mark) self.state = self.parse_indentless_sequence_entry else: if self.check_token(ScalarToken): token = self.get_token() end_mark = token.end_mark if (token.plain and tag is None) or tag == u'!': implicit = (True, False) elif tag is None: implicit = (False, True) else: implicit = (False, False) event = ScalarEvent(anchor, tag, implicit, token.value, start_mark, end_mark, style=token.style) self.state = self.states.pop() elif self.check_token(FlowSequenceStartToken): end_mark = self.peek_token().end_mark event = SequenceStartEvent(anchor, tag, implicit, start_mark, end_mark, flow_style=True) self.state = self.parse_flow_sequence_first_entry elif self.check_token(FlowMappingStartToken): end_mark = self.peek_token().end_mark event = MappingStartEvent(anchor, tag, implicit, start_mark, end_mark, flow_style=True) self.state = self.parse_flow_mapping_first_key elif block and self.check_token(BlockSequenceStartToken): end_mark = self.peek_token().start_mark event = SequenceStartEvent(anchor, tag, implicit, start_mark, end_mark, flow_style=False) self.state = self.parse_block_sequence_first_entry elif block and self.check_token(BlockMappingStartToken): end_mark = self.peek_token().start_mark event = MappingStartEvent(anchor, tag, implicit, start_mark, end_mark, flow_style=False) self.state = self.parse_block_mapping_first_key elif anchor is not None or tag is not None: # Empty scalars are allowed even if a tag or an anchor is # specified. event = ScalarEvent(anchor, tag, (implicit, False), u'', start_mark, end_mark) self.state = self.states.pop() else: if block: node = 'block' else: node = 'flow' token = self.peek_token() raise ParserError("while scanning a %s node" % node, start_mark, "expected the node content, but found %r" % token.id, token.start_mark) return event
|
def parse_node(self, block=False, indentless_sequence=False): if self.check_token(AliasToken): token = self.get_token() event = AliasEvent(token.value, token.start_mark, token.end_mark) self.state = self.states.pop() else: anchor = None tag = None start_mark = end_mark = tag_mark = None if self.check_token(AnchorToken): token = self.get_token() start_mark = token.start_mark end_mark = token.end_mark anchor = token.value if self.check_token(TagToken): token = self.get_token() tag_mark = token.start_mark end_mark = token.end_mark tag = token.value elif self.check_token(TagToken): token = self.get_token() start_mark = tag_mark = token.start_mark end_mark = token.end_mark tag = token.value if self.check_token(AnchorToken): token = self.get_token() end_mark = token.end_mark anchor = token.value if tag is not None and tag != u'!': handle, suffix = tag if handle is not None: if handle not in self.tag_handles: raise ParserError("while parsing a node", start_mark, "found undefined tag handle %r" % handle.encode('utf-8'), tag_mark) tag = self.tag_handles[handle]+suffix else: tag = suffix #if tag == u'!': # raise ParserError("while parsing a node", start_mark, # "found non-specific tag '!'", tag_mark, # "Please check 'http://pyyaml.org/wiki/YAMLNonSpecificTag' and share your opinion.") if start_mark is None: start_mark = end_mark = self.peek_token().start_mark event = None implicit = (tag is None or tag == u'!') if indentless_sequence and self.check_token(BlockEntryToken): end_mark = self.peek_token().end_mark event = SequenceStartEvent(anchor, tag, implicit, start_mark, end_mark) self.state = self.parse_indentless_sequence_entry else: if self.check_token(ScalarToken): token = self.get_token() end_mark = token.end_mark if (token.plain and tag is None) or tag == u'!': implicit = (True, False) elif tag is None: implicit = (False, True) else: implicit = (False, False) event = ScalarEvent(anchor, tag, implicit, token.value, start_mark, end_mark, style=token.style) self.state = self.states.pop() elif self.check_token(FlowSequenceStartToken): end_mark = self.peek_token().end_mark event = SequenceStartEvent(anchor, tag, implicit, start_mark, end_mark, flow_style=True) self.state = self.parse_flow_sequence_first_entry elif self.check_token(FlowMappingStartToken): end_mark = self.peek_token().end_mark event = MappingStartEvent(anchor, tag, implicit, start_mark, end_mark, flow_style=True) self.state = self.parse_flow_mapping_first_key elif block and self.check_token(BlockSequenceStartToken): end_mark = self.peek_token().start_mark event = SequenceStartEvent(anchor, tag, implicit, start_mark, end_mark, flow_style=False) self.state = self.parse_block_sequence_first_entry elif block and self.check_token(BlockMappingStartToken): end_mark = self.peek_token().start_mark event = MappingStartEvent(anchor, tag, implicit, start_mark, end_mark, flow_style=False) self.state = self.parse_block_mapping_first_key elif anchor is not None or tag is not None: # Empty scalars are allowed even if a tag or an anchor is # specified. event = ScalarEvent(anchor, tag, (implicit, False), u'', start_mark, end_mark) self.state = self.states.pop() else: if block: node = 'block' else: node = 'flow' token = self.peek_token() raise ParserError("while scanning a %s node" % node, start_mark, "expected the node content, but found %r" % token.id, token.start_mark) return event
| 6,116
|
def parse_node(self, block=False, indentless_sequence=False): if self.check_token(AliasToken): token = self.get_token() event = AliasEvent(token.value, token.start_mark, token.end_mark) self.state = self.states.pop() else: anchor = None tag = None start_mark = end_mark = tag_mark = None if self.check_token(AnchorToken): token = self.get_token() start_mark = token.start_mark end_mark = token.end_mark anchor = token.value if self.check_token(TagToken): token = self.get_token() tag_mark = token.start_mark end_mark = token.end_mark tag = token.value elif self.check_token(TagToken): token = self.get_token() start_mark = tag_mark = token.start_mark end_mark = token.end_mark tag = token.value if self.check_token(AnchorToken): token = self.get_token() end_mark = token.end_mark anchor = token.value if tag is not None and tag != u'!': handle, suffix = tag if handle is not None: if handle not in self.tag_handles: raise ParserError("while parsing a node", start_mark, "found undefined tag handle %r" % handle.encode('utf-8'), tag_mark) tag = self.tag_handles[handle]+suffix else: tag = suffix #if tag == u'!': # raise ParserError("while parsing a node", start_mark, # "found non-specific tag '!'", tag_mark, # "Please check 'http://pyyaml.org/wiki/YAMLNonSpecificTag' and share your opinion.") if start_mark is None: start_mark = end_mark = self.peek_token().start_mark event = None collection_events = None implicit = (tag is None or tag == u'!') if indentless_sequence and self.check_token(BlockEntryToken): end_mark = self.peek_token().end_mark event = SequenceStartEvent(anchor, tag, implicit, start_mark, end_mark) self.state = self.parse_indentless_sequence_entry else: if self.check_token(ScalarToken): token = self.get_token() end_mark = token.end_mark if (token.plain and tag is None) or tag == u'!': implicit = (True, False) elif tag is None: implicit = (False, True) else: implicit = (False, False) event = ScalarEvent(anchor, tag, implicit, token.value, start_mark, end_mark, style=token.style) self.state = self.states.pop() elif self.check_token(FlowSequenceStartToken): end_mark = self.peek_token().end_mark event = SequenceStartEvent(anchor, tag, implicit, start_mark, end_mark, flow_style=True) self.state = self.parse_flow_sequence_first_entry elif self.check_token(FlowMappingStartToken): end_mark = self.peek_token().end_mark event = MappingStartEvent(anchor, tag, implicit, start_mark, end_mark, flow_style=True) self.state = self.parse_flow_mapping_first_key elif block and self.check_token(BlockSequenceStartToken): end_mark = self.peek_token().start_mark event = SequenceStartEvent(anchor, tag, implicit, start_mark, end_mark, flow_style=False) self.state = self.parse_block_sequence_first_entry elif block and self.check_token(BlockMappingStartToken): end_mark = self.peek_token().start_mark event = MappingStartEvent(anchor, tag, implicit, start_mark, end_mark, flow_style=False) self.state = self.parse_block_mapping_first_key elif anchor is not None or tag is not None: # Empty scalars are allowed even if a tag or an anchor is # specified. event = ScalarEvent(anchor, tag, (implicit, False), u'', start_mark, end_mark) self.state = self.states.pop() else: if block: node = 'block' else: node = 'flow' token = self.peek_token() raise ParserError("while scanning a %s node" % node, start_mark, "expected the node content, but found %r" % token.id, token.start_mark) return event
|
def parse_node(self, block=False, indentless_sequence=False): if self.check_token(AliasToken): token = self.get_token() event = AliasEvent(token.value, token.start_mark, token.end_mark) self.state = self.states.pop() else: anchor = None tag = None start_mark = end_mark = tag_mark = None if self.check_token(AnchorToken): token = self.get_token() start_mark = token.start_mark end_mark = token.end_mark anchor = token.value if self.check_token(TagToken): token = self.get_token() tag_mark = token.start_mark end_mark = token.end_mark tag = token.value elif self.check_token(TagToken): token = self.get_token() start_mark = tag_mark = token.start_mark end_mark = token.end_mark tag = token.value if self.check_token(AnchorToken): token = self.get_token() end_mark = token.end_mark anchor = token.value if tag is not None and tag != u'!': handle, suffix = tag if handle is not None: if handle not in self.tag_handles: raise ParserError("while parsing a node", start_mark, "found undefined tag handle %r" % handle.encode('utf-8'), tag_mark) tag = self.tag_handles[handle]+suffix else: tag = suffix #if tag == u'!': # raise ParserError("while parsing a node", start_mark, # "found non-specific tag '!'", tag_mark, # "Please check 'http://pyyaml.org/wiki/YAMLNonSpecificTag' and share your opinion.") if start_mark is None: start_mark = end_mark = self.peek_token().start_mark event = None collection_events = None implicit = (tag is None or tag == u'!') if indentless_sequence and self.check_token(BlockEntryToken): end_mark = self.peek_token().end_mark event = SequenceStartEvent(anchor, tag, implicit, start_mark, end_mark) self.state = self.parse_indentless_sequence_entry else: if self.check_token(ScalarToken): token = self.get_token() end_mark = token.end_mark if (token.plain and tag is None) or tag == u'!': implicit = (True, False) elif tag is None: implicit = (False, True) else: implicit = (False, False) event = ScalarEvent(anchor, tag, implicit, token.value, start_mark, end_mark, style=token.style) self.state = self.states.pop() elif self.check_token(FlowSequenceStartToken): end_mark = self.peek_token().end_mark event = SequenceStartEvent(anchor, tag, implicit, start_mark, end_mark, flow_style=True) self.state = self.parse_flow_sequence_first_entry elif self.check_token(FlowMappingStartToken): end_mark = self.peek_token().end_mark event = MappingStartEvent(anchor, tag, implicit, start_mark, end_mark, flow_style=True) self.state = self.parse_flow_mapping_first_key elif block and self.check_token(BlockSequenceStartToken): end_mark = self.peek_token().start_mark event = SequenceStartEvent(anchor, tag, implicit, start_mark, end_mark, flow_style=False) self.state = self.parse_block_sequence_first_entry elif block and self.check_token(BlockMappingStartToken): end_mark = self.peek_token().start_mark event = MappingStartEvent(anchor, tag, implicit, start_mark, end_mark, flow_style=False) self.state = self.parse_block_mapping_first_key elif anchor is not None or tag is not None: # Empty scalars are allowed even if a tag or an anchor is # specified. event = ScalarEvent(anchor, tag, (implicit, False), u'', start_mark, end_mark) self.state = self.states.pop() else: if block: node = 'block' else: node = 'flow' token = self.peek_token() raise ParserError("while parsing a %s node" % node, start_mark, "expected the node content, but found %r" % token.id, token.start_mark) return event
| 6,117
|
def parse_block_sequence_entry(self): if self.check_token(BlockEntryToken): token = self.get_token() if not self.check_token(BlockEntryToken, BlockEndToken): self.states.append(self.parse_block_sequence_entry) return self.parse_block_node() else: self.state = self.parse_block_sequence_entry return self.process_empty_scalar(token.end_mark) if not self.check_token(BlockEndToken): token = self.peek_token() raise ParserError("while scanning a block collection", self.marks[-1], "expected <block end>, but found %r" % token.id, token.start_mark) token = self.get_token() event = SequenceEndEvent(token.start_mark, token.end_mark) self.state = self.states.pop() self.marks.pop() return event
|
def parse_block_sequence_entry(self): if self.check_token(BlockEntryToken): token = self.get_token() if not self.check_token(BlockEntryToken, BlockEndToken): self.states.append(self.parse_block_sequence_entry) return self.parse_block_node() else: self.state = self.parse_block_sequence_entry return self.process_empty_scalar(token.end_mark) if not self.check_token(BlockEndToken): token = self.peek_token() raise ParserError("while parsing a block collection", self.marks[-1], "expected <block end>, but found %r" % token.id, token.start_mark) token = self.get_token() event = SequenceEndEvent(token.start_mark, token.end_mark) self.state = self.states.pop() self.marks.pop() return event
| 6,118
|
def parse_block_mapping_key(self): if self.check_token(KeyToken): token = self.get_token() if not self.check_token(KeyToken, ValueToken, BlockEndToken): self.states.append(self.parse_block_mapping_value) return self.parse_block_node_or_indentless_sequence() else: self.state = self.parse_block_mapping_value return self.process_empty_scalar(token.end_mark) if not self.check_token(BlockEndToken): token = self.peek_token() raise ParserError("while scanning a block mapping", self.marks[-1], "expected <block end>, but found %r" % token.id, token.start_mark) token = self.get_token() event = MappingEndEvent(token.start_mark, token.end_mark) self.state = self.states.pop() self.marks.pop() return event
|
def parse_block_mapping_key(self): if self.check_token(KeyToken): token = self.get_token() if not self.check_token(KeyToken, ValueToken, BlockEndToken): self.states.append(self.parse_block_mapping_value) return self.parse_block_node_or_indentless_sequence() else: self.state = self.parse_block_mapping_value return self.process_empty_scalar(token.end_mark) if not self.check_token(BlockEndToken): token = self.peek_token() raise ParserError("while parsing a block mapping", self.marks[-1], "expected <block end>, but found %r" % token.id, token.start_mark) token = self.get_token() event = MappingEndEvent(token.start_mark, token.end_mark) self.state = self.states.pop() self.marks.pop() return event
| 6,119
|
def parse_flow_sequence_entry(self, first=False): if not self.check_token(FlowSequenceEndToken): if not first: if self.check_token(FlowEntryToken): self.get_token() else: token = self.peek_token() raise ParserError("while scanning a flow sequence", self.marks[-1], "expected ',' or ']', but got %r" % token.id, token.start_mark) if self.check_token(KeyToken): token = self.get_token() event = MappingStartEvent(None, None, True, token.start_mark, token.end_mark, flow_style=True) self.state = self.parse_flow_sequence_entry_mapping_key return event elif not self.check_token(FlowSequenceEndToken): self.states.append(self.parse_flow_sequence_entry) return self.parse_flow_node() token = self.get_token() event = SequenceEndEvent(token.start_mark, token.end_mark) self.state = self.states.pop() self.marks.pop() return event
|
def parse_flow_sequence_entry(self, first=False): if not self.check_token(FlowSequenceEndToken): if not first: if self.check_token(FlowEntryToken): self.get_token() else: token = self.peek_token() raise ParserError("while parsing a flow sequence", self.marks[-1], "expected ',' or ']', but got %r" % token.id, token.start_mark) if self.check_token(KeyToken): token = self.get_token() event = MappingStartEvent(None, None, True, token.start_mark, token.end_mark, flow_style=True) self.state = self.parse_flow_sequence_entry_mapping_key return event elif not self.check_token(FlowSequenceEndToken): self.states.append(self.parse_flow_sequence_entry) return self.parse_flow_node() token = self.get_token() event = SequenceEndEvent(token.start_mark, token.end_mark) self.state = self.states.pop() self.marks.pop() return event
| 6,120
|
def parse_flow_sequence_entry(self, first=False): if not self.check_token(FlowSequenceEndToken): if not first: if self.check_token(FlowEntryToken): self.get_token() else: token = self.peek_token() raise ParserError("while scanning a flow sequence", self.marks[-1], "expected ',' or ']', but got %r" % token.id, token.start_mark) if self.check_token(KeyToken): token = self.get_token() event = MappingStartEvent(None, None, True, token.start_mark, token.end_mark, flow_style=True) self.state = self.parse_flow_sequence_entry_mapping_key return event elif not self.check_token(FlowSequenceEndToken): self.states.append(self.parse_flow_sequence_entry) return self.parse_flow_node() token = self.get_token() event = SequenceEndEvent(token.start_mark, token.end_mark) self.state = self.states.pop() self.marks.pop() return event
|
def parse_flow_sequence_entry(self, first=False): if not self.check_token(FlowSequenceEndToken): if not first: if self.check_token(FlowEntryToken): self.get_token() else: token = self.peek_token() raise ParserError("while scanning a flow sequence", self.marks[-1], "expected ',' or ']', but got %r" % token.id, token.start_mark) if self.check_token(KeyToken): token = self.peek_token() event = MappingStartEvent(None, None, True, token.start_mark, token.end_mark, flow_style=True) self.state = self.parse_flow_sequence_entry_mapping_key return event elif not self.check_token(FlowSequenceEndToken): self.states.append(self.parse_flow_sequence_entry) return self.parse_flow_node() token = self.peek_token() event = SequenceEndEvent(token.start_mark, token.end_mark) self.state = self.states.pop() self.marks.pop() return event
| 6,121
|
def parse_flow_mapping_key(self, first=False): if not self.check_token(FlowMappingEndToken): if not first: if self.check_token(FlowEntryToken): self.get_token() else: token = self.peek_token() raise ParserError("while scanning a flow mapping", self.marks[-1], "expected ',' or '}', but got %r" % token.id, token.start_mark) if self.check_token(KeyToken): token = self.get_token() if not self.check_token(ValueToken, FlowEntryToken, FlowMappingEndToken): self.states.append(self.parse_flow_mapping_value) return self.parse_flow_node() else: self.state = self.parse_flow_mapping_value return self.process_empty_scalar(token.end_mark) elif not self.check_token(FlowMappingEndToken): self.states.append(self.parse_flow_mapping_empty_value) return self.parse_flow_node() token = self.get_token() event = MappingEndEvent(token.start_mark, token.end_mark) self.state = self.states.pop() self.marks.pop() return event
|
def parse_flow_mapping_key(self, first=False): if not self.check_token(FlowMappingEndToken): if not first: if self.check_token(FlowEntryToken): self.get_token() else: token = self.peek_token() raise ParserError("while parsing a flow mapping", self.marks[-1], "expected ',' or '}', but got %r" % token.id, token.start_mark) if self.check_token(KeyToken): token = self.get_token() if not self.check_token(ValueToken, FlowEntryToken, FlowMappingEndToken): self.states.append(self.parse_flow_mapping_value) return self.parse_flow_node() else: self.state = self.parse_flow_mapping_value return self.process_empty_scalar(token.end_mark) elif not self.check_token(FlowMappingEndToken): self.states.append(self.parse_flow_mapping_empty_value) return self.parse_flow_node() token = self.get_token() event = MappingEndEvent(token.start_mark, token.end_mark) self.state = self.states.pop() self.marks.pop() return event
| 6,122
|
def __init__(self, config): parameters = yaml.load_document(config) self.replaces = parameters['replaces'] self.substitutions = {} for domain, items in [('Token', parameters['tokens']), ('Event', parameters['events'])]: for code in items: name = ''.join([part.capitalize() for part in code.split('-')]+[domain]) cls = getattr(yaml, name) value = items[code] if value: if 'start' in value: self.substitutions[cls, -1] = value['start'] if 'end' in value: self.substitutions[cls, +1] = value['end']
|
def __init__(self, config): parameters = yaml.load(config) self.replaces = parameters['replaces'] self.substitutions = {} for domain, items in [('Token', parameters['tokens']), ('Event', parameters['events'])]: for code in items: name = ''.join([part.capitalize() for part in code.split('-')]+[domain]) cls = getattr(yaml, name) value = items[code] if value: if 'start' in value: self.substitutions[cls, -1] = value['start'] if 'end' in value: self.substitutions[cls, +1] = value['end']
| 6,123
|
def highlight(self, input): if isinstance(input, str): if input.startswith(codecs.BOM_UTF16_LE): input = unicode(input, 'utf-16-le') elif input.startswith(codecs.BOM_UTF16_BE): input = unicode(input, 'utf-16-be') else: input = unicode(input, 'utf-8') tokens = yaml.parse(input, Parser=iter) events = yaml.parse(input) markers = [] number = 0 for token in tokens: number += 1 if token.start_mark.index != token.end_mark.index: cls = token.__class__ if (cls, -1) in self.substitutions: markers.append([token.start_mark.index, +2, number, self.substitutions[cls, -1]]) if (cls, +1) in self.substitutions: markers.append([token.end_mark.index, -2, number, self.substitutions[cls, +1]]) number = 0 for event in events: number += 1 cls = event.__class__ if (cls, -1) in self.substitutions: markers.append([event.start_mark.index, +1, number, self.substitutions[cls, -1]]) if (cls, +1) in self.substitutions: markers.append([event.end_mark.index, -1, number, self.substitutions[cls, +1]]) markers.sort() markers.reverse() chunks = [] position = len(input) for index, weight1, weight2, substitution in markers: if index < position: chunk = input[index:position] for substring, replacement in self.replaces: chunk = chunk.replace(substring, replacement) chunks.append(chunk) position = index chunks.append(substitution) chunks.reverse() result = u''.join(chunks) return result.encode('utf-8')
|
def highlight(self, input): if isinstance(input, str): if input.startswith(codecs.BOM_UTF16_LE): input = unicode(input, 'utf-16-le') elif input.startswith(codecs.BOM_UTF16_BE): input = unicode(input, 'utf-16-be') else: input = unicode(input, 'utf-8') tokens = yaml.scan(input) events = yaml.parse(input) markers = [] number = 0 for token in tokens: number += 1 if token.start_mark.index != token.end_mark.index: cls = token.__class__ if (cls, -1) in self.substitutions: markers.append([token.start_mark.index, +2, number, self.substitutions[cls, -1]]) if (cls, +1) in self.substitutions: markers.append([token.end_mark.index, -2, number, self.substitutions[cls, +1]]) number = 0 for event in events: number += 1 cls = event.__class__ if (cls, -1) in self.substitutions: markers.append([event.start_mark.index, +1, number, self.substitutions[cls, -1]]) if (cls, +1) in self.substitutions: markers.append([event.end_mark.index, -1, number, self.substitutions[cls, +1]]) markers.sort() markers.reverse() chunks = [] position = len(input) for index, weight1, weight2, substitution in markers: if index < position: chunk = input[index:position] for substring, replacement in self.replaces: chunk = chunk.replace(substring, replacement) chunks.append(chunk) position = index chunks.append(substitution) chunks.reverse() result = u''.join(chunks) return result.encode('utf-8')
| 6,124
|
def construct_yaml_float(self, node): value = str(self.construct_scalar(node)) value = value.replace('_', '') sign = +1 if value[0] == '-': sign = -1 if value[0] in '+-': value = value[1:] if value.lower() == '.inf': return sign*self.inf_value elif value.lower() == '.nan': return self.nan_value elif ':' in value: digits = [float(part) for part in value.split(':')] digits.reverse() base = 1 value = 0.0 for digit in digits: value += digit*base base *= 60 return sign*value else: return float(value)
|
def construct_yaml_float(self, node): value = str(self.construct_scalar(node)) value = value.replace('_', '') sign = +1 if value[0] == '-': sign = -1 if value[0] in '+-': value = value[1:] if value.lower() == '.inf': return sign*self.inf_value elif value.lower() == '.nan': return self.nan_value elif ':' in value: digits = [float(part) for part in value.split(':')] digits.reverse() base = 1 value = 0.0 for digit in digits: value += digit*base base *= 60 return sign*value else: return float(value)
| 6,125
|
def scan_plain(self): # See the specification for details. # We add an additional restriction for the flow context: # plain scalars in the flow context cannot contain ',', ':' and '?'. # We also keep track of the `allow_simple_key` flag here. # Indentation rules are loosed for the flow context. chunks = [] start_mark = self.get_mark() end_mark = start_mark indent = self.indent+1 # We allow zero indentation for scalars, but then we need to check for # document separators at the beginning of the line. #if indent == 0: # indent = 1 spaces = [] while True: length = 0 if self.peek() == u'#': break while True: ch = self.peek(length) if ch in u'\0 \t\r\n\x85\u2028\u2029' \ or (not self.flow_level and ch == u':' and self.peek(length+1) in u'\0 \t\r\n\x28\u2028\u2029') \ or (self.flow_level and ch in u',:?[]{}'): break length += 1 # It's not clear what we should do with ':' in the flow context. if (self.flow_level and ch == u':' and self.peek(length+1) not in u'\0 \t\r\n\x28\u2028\u2029,[]{}'): self.forward(length) raise ScannerError("while scanning a plain scalar", start_mark, "found unexpected ':'", self.get_mark(), "Please check http://pyyaml.org/wiki/YAMLColonInFlowContext for details.") if length == 0: break self.allow_simple_key = False chunks.extend(spaces) chunks.append(self.prefix(length)) self.forward(length) end_mark = self.get_mark() spaces = self.scan_plain_spaces(indent, start_mark) if not spaces or self.peek() == u'#' \ or (not self.flow_level and self.column < indent): break return ScalarToken(u''.join(chunks), True, start_mark, end_mark)
|
def scan_plain(self): # See the specification for details. # We add an additional restriction for the flow context: # plain scalars in the flow context cannot contain ',', ':' and '?'. # We also keep track of the `allow_simple_key` flag here. # Indentation rules are loosed for the flow context. chunks = [] start_mark = self.get_mark() end_mark = start_mark indent = self.indent+1 # We allow zero indentation for scalars, but then we need to check for # document separators at the beginning of the line. #if indent == 0: # indent = 1 spaces = [] while True: length = 0 if self.peek() == u'#': break while True: ch = self.peek(length) if ch in u'\0 \t\r\n\x85\u2028\u2029' \ or (not self.flow_level and ch == u':' and self.peek(length+1) in u'\0 \t\r\n\x85\u2028\u2029') \ or (self.flow_level and ch in u',:?[]{}'): break length += 1 # It's not clear what we should do with ':' in the flow context. if (self.flow_level and ch == u':' and self.peek(length+1) not in u'\0 \t\r\n\x28\u2028\u2029,[]{}'): self.forward(length) raise ScannerError("while scanning a plain scalar", start_mark, "found unexpected ':'", self.get_mark(), "Please check http://pyyaml.org/wiki/YAMLColonInFlowContext for details.") if length == 0: break self.allow_simple_key = False chunks.extend(spaces) chunks.append(self.prefix(length)) self.forward(length) end_mark = self.get_mark() spaces = self.scan_plain_spaces(indent, start_mark) if not spaces or self.peek() == u'#' \ or (not self.flow_level and self.column < indent): break return ScalarToken(u''.join(chunks), True, start_mark, end_mark)
| 6,126
|
def scan_plain(self): # See the specification for details. # We add an additional restriction for the flow context: # plain scalars in the flow context cannot contain ',', ':' and '?'. # We also keep track of the `allow_simple_key` flag here. # Indentation rules are loosed for the flow context. chunks = [] start_mark = self.get_mark() end_mark = start_mark indent = self.indent+1 # We allow zero indentation for scalars, but then we need to check for # document separators at the beginning of the line. #if indent == 0: # indent = 1 spaces = [] while True: length = 0 if self.peek() == u'#': break while True: ch = self.peek(length) if ch in u'\0 \t\r\n\x85\u2028\u2029' \ or (not self.flow_level and ch == u':' and self.peek(length+1) in u'\0 \t\r\n\x28\u2028\u2029') \ or (self.flow_level and ch in u',:?[]{}'): break length += 1 # It's not clear what we should do with ':' in the flow context. if (self.flow_level and ch == u':' and self.peek(length+1) not in u'\0 \t\r\n\x28\u2028\u2029,[]{}'): self.forward(length) raise ScannerError("while scanning a plain scalar", start_mark, "found unexpected ':'", self.get_mark(), "Please check http://pyyaml.org/wiki/YAMLColonInFlowContext for details.") if length == 0: break self.allow_simple_key = False chunks.extend(spaces) chunks.append(self.prefix(length)) self.forward(length) end_mark = self.get_mark() spaces = self.scan_plain_spaces(indent, start_mark) if not spaces or self.peek() == u'#' \ or (not self.flow_level and self.column < indent): break return ScalarToken(u''.join(chunks), True, start_mark, end_mark)
|
def scan_plain(self): # See the specification for details. # We add an additional restriction for the flow context: # plain scalars in the flow context cannot contain ',', ':' and '?'. # We also keep track of the `allow_simple_key` flag here. # Indentation rules are loosed for the flow context. chunks = [] start_mark = self.get_mark() end_mark = start_mark indent = self.indent+1 # We allow zero indentation for scalars, but then we need to check for # document separators at the beginning of the line. #if indent == 0: # indent = 1 spaces = [] while True: length = 0 if self.peek() == u'#': break while True: ch = self.peek(length) if ch in u'\0 \t\r\n\x85\u2028\u2029' \ or (not self.flow_level and ch == u':' and self.peek(length+1) in u'\0 \t\r\n\x28\u2028\u2029') \ or (self.flow_level and ch in u',:?[]{}'): break length += 1 # It's not clear what we should do with ':' in the flow context. if (self.flow_level and ch == u':' and self.peek(length+1) not in u'\0 \t\r\n\x85\u2028\u2029,[]{}'): self.forward(length) raise ScannerError("while scanning a plain scalar", start_mark, "found unexpected ':'", self.get_mark(), "Please check http://pyyaml.org/wiki/YAMLColonInFlowContext for details.") if length == 0: break self.allow_simple_key = False chunks.extend(spaces) chunks.append(self.prefix(length)) self.forward(length) end_mark = self.get_mark() spaces = self.scan_plain_spaces(indent, start_mark) if not spaces or self.peek() == u'#' \ or (not self.flow_level and self.column < indent): break return ScalarToken(u''.join(chunks), True, start_mark, end_mark)
| 6,127
|
def check_document_end(self):
|
def check_document_end(self):
| 6,128
|
def represent_object(self, data): # We use __reduce__ API to save the data. data.__reduce__ returns # a tuple of length 2-5: # (function, args, state, listitems, dictitems)
|
def represent_object(self, data): # We use __reduce__ API to save the data. data.__reduce__ returns # a tuple of length 2-5: # (function, args, state, listitems, dictitems)
| 6,129
|
def write_single_quoted(self, text, split=True): self.write_indicator(u'\'', True) spaces = False breaks = False start = end = 0 while end <= len(text): ch = None if end < len(text): ch = text[end] if spaces: if ch is None or ch != u' ': if start+1 == end and self.column > self.best_width and split \ and start != 0 and end != len(text): self.write_indent() else: data = text[start:end] self.column += len(data) if self.encoding: data = data.encode(self.encoding) self.stream.write(data) start = end elif breaks: if ch is None or ch not in u'\n\x85\u2028\u2029': if text[start] == u'\n': self.write_line_break() for br in text[start:end]: if br == u'\n': self.write_line_break() else: self.write_line_break(br) self.write_indent() start = end else: if ch is None or ch in u' \n\x85\u2028\u2029' or ch == u'\'': if start < end: data = text[start:end] self.column += len(data) if self.encoding: data = data.encode(self.encoding) self.stream.write(data) start = end if ch == u'\'': data = u'\'\'' self.column += 2 if self.encoding: data = data.encode(self.encoding) self.stream.write(data) start = end + 1 if ch is not None: spaces = (ch == u' ') breaks = (ch in u'\n\x85\u2028\u2029') end += 1 self.write_indicator(u'\'', False)
|
def write_single_quoted(self, text, split=True): self.write_indicator(u'\'', True) spaces = False breaks = False start = end = 0 while end <= len(text): ch = None if end < len(text): ch = text[end] if spaces: if ch is None or ch != u' ': if start+1 == end and self.column > self.best_width and split \ and start != 0 and end != len(text): self.write_indent() else: data = text[start:end] self.column += len(data) if self.encoding: data = data.encode(self.encoding) self.stream.write(data) start = end elif breaks: if ch is None or ch not in u'\n\x85\u2028\u2029': if text[start] == u'\n': self.write_line_break() for br in text[start:end]: if br == u'\n': self.write_line_break() else: self.write_line_break(br) self.write_indent() start = end else: if ch is None or ch in u' \n\x85\u2028\u2029' or ch == u'\'': if start < end: data = text[start:end] self.column += len(data) if self.encoding: data = data.encode(self.encoding) self.stream.write(data) start = end if ch == u'\'': data = u'\'\'' self.column += 2 if self.encoding: data = data.encode(self.encoding) self.stream.write(data) start = end + 1 if ch is not None: spaces = (ch == u' ') breaks = (ch in u'\n\x85\u2028\u2029') end += 1 self.write_indicator(u'\'', False)
| 6,130
|
def choose_scalar_style(self): if self.analysis is None: self.analysis = self.analyze_scalar(self.event.value) if self.event.style == '"' or self.canonical: return '"' if not self.event.style and self.event.implicit[0]: if (not (self.simple_key_context and (self.analysis.empty or self.analysis.multiline)) and (self.flow_level and self.analysis.allow_flow_plain or (not self.flow_level and self.analysis.allow_block_plain))): return '' if self.event.style and self.event.style in '|>': if not self.flow_level and self.analysis.allow_block: return self.event.style if not self.event.style or self.event.style == '\'': if (self.analysis.allow_single_quoted and not (self.simple_key_context and self.analysis.multiline)): return '\'' return '"'
|
def choose_scalar_style(self): if self.analysis is None: self.analysis = self.analyze_scalar(self.event.value) if self.event.style == '"' or self.canonical: return '"' if not self.event.style and self.event.implicit[0]: if (not (self.simple_key_context and (self.analysis.empty or self.analysis.multiline)) and (self.flow_level and self.analysis.allow_flow_plain or (not self.flow_level and self.analysis.allow_block_plain))): return '' if self.event.style and self.event.style in '|>': if (not self.flow_level and not self.simple_key_context and self.analysis.allow_block): return self.event.style if not self.event.style or self.event.style == '\'': if (self.analysis.allow_single_quoted and not (self.simple_key_context and self.analysis.multiline)): return '\'' return '"'
| 6,131
|
def analyze_scalar(self, scalar):
|
def analyze_scalar(self, scalar):
| 6,132
|
def _testMarks(self, test_name, marks_filename): inputs = file(marks_filename, 'rb').read().split('---\n')[1:] for input in inputs: index = 0 line = 0 column = 0 while input[index] != '*': if input[index] == '\n': line += 1 column = 0 else: column += 1 index += 1 mark = Mark(test_name, line, column, unicode(input), index) snippet = mark.get_snippet(indent=2, max_length=79) #print "INPUT:" #print input #print "SNIPPET:" #print snippet self.failUnless(isinstance(snippet, str)) self.failUnlessEqual(snippet.count('\n'), 1) data, pointer = snippet.split('\n') self.failUnless(len(data) < 82) self.failUnlessEqual(data[len(pointer)-1], '*')
|
def _testMarks(self, test_name, marks_filename): inputs = file(marks_filename, 'rb').read().split('---\n')[1:] for input in inputs: index = 0 line = 0 column = 0 while input[index] != '*': if input[index] == '\n': line += 1 column = 0 else: column += 1 index += 1 mark = Mark(test_name, index, line, column, unicode(input), index) snippet = mark.get_snippet(indent=2, max_length=79) #print "INPUT:" #print input #print "SNIPPET:" #print snippet self.failUnless(isinstance(snippet, str)) self.failUnlessEqual(snippet.count('\n'), 1) data, pointer = snippet.split('\n') self.failUnless(len(data) < 82) self.failUnlessEqual(data[len(pointer)-1], '*')
| 6,133
|
def compose_document(self):
|
def compose_document(self):
| 6,134
|
def resolve(self, kind, value, implicit): if kind is ScalarNode and implicit[0]: if value == u'': resolvers = self.yaml_implicit_resolvers.get(u'', []) else: resolvers = self.yaml_implicit_resolvers.get(value[0], []) resolvers += self.yaml_implicit_resolvers.get(None, []) for tag, regexp in resolvers: if regexp.match(value): return tag implicit = implicit[1] if self.yaml_path_resolvers: exact_paths = self.resolver_exact_paths[-1] if kind in exact_paths: return exact_paths[kind] if None in exact_paths: return exact_paths[None] if kind is ScalarNode: return self.DEFAULT_SCALAR_TAG elif kind is SequenceNode: return self.DEFAULT_SEQUENCE_TAG elif kind is MappingNode: return self.DEFAULT_MAPPING_TAG
|
def resolve(self, kind, value, implicit): if kind is ScalarNode and implicit[0]: if value == u'': resolvers = self.yaml_implicit_resolvers.get(u'', []) else: resolvers = self.yaml_implicit_resolvers.get(value[0], []) resolvers += self.yaml_implicit_resolvers.get(None, []) for tag, regexp in resolvers: if regexp.match(value): return tag implicit = implicit[1] if self.yaml_path_resolvers: exact_paths = self.resolver_exact_paths[-1] if kind in exact_paths: return exact_paths[kind] if None in exact_paths: return exact_paths[None] if kind is ScalarNode: return self.DEFAULT_SCALAR_TAG elif kind is SequenceNode: return self.DEFAULT_SEQUENCE_TAG elif kind is MappingNode: return self.DEFAULT_MAPPING_TAG
| 6,135
|
def download_url(url, overwrite=False): """Download a url to the local cache @overwrite: if True overwrite an existing local copy otherwise don't """ localPath = get_local_path(url) if overwrite and not(os.path.exists(localPath)): urllib.urlretrieve(url, localPath)
|
def download_url(url, overwrite=False): """Download a url to the local cache @overwrite: if True overwrite an existing local copy otherwise don't """ localPath = get_local_path(url) if overwrite or not(os.path.exists(localPath)): urllib.urlretrieve(url, localPath)
| 6,136
|
def matrix2quaternion(m): s = math.sqrt(abs(m[0][0] + m[1][1] + m[2][2] + m[3][3])) if s == 0.0: x = abs(m[2][1] - m[1][2]) y = abs(m[0][2] - m[2][0]) z = abs(m[1][0] - m[0][1]) if (x >= y) and (x >= z): return 1.0, 0.0, 0.0, 0.0 elif (y >= x) and (y >= z): return 0.0, 1.0, 0.0, 0.0 else: return 0.0, 0.0, 1.0, 0.0 return quaternion_normalize([ -(m[2][1] - m[1][2]) / (2.0 * s), -(m[0][2] - m[2][0]) / (2.0 * s), -(m[1][0] - m[0][1]) / (2.0 * s), 0.5 * s, ])
|
def matrix2quaternion(m): tr = 1.0 + m[0][0] + m[1][1] + m[2][2] if tr > .00001: s = math.sqrt(tr) w = s / 2.0 s = 0.5 / s x = (m[1][2] - m[2][1]) * s y = (m[2][0] - m[0][2]) * s z = (m[0][1] - m[1][0]) * s elif m[0][0] > m[1][1] and m[0][0] > m[2][2]: s = math.sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]) x = s / 2.0 s = 0.5 / s y = (m[0][1] + m[1][0]) * s z = (m[2][0] + m[0][2]) * s w = (m[1][2] - m[2][1]) * s elif m[1][1] > m[2][2]: s = math.sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]) y = s / 2.0 s = 0.5 / s x = (m[0][1] + m[1][0]) * s z = (m[1][2] + m[2][1]) * s w = (m[2][0] - m[0][2]) * s else: s = math.sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]) z = s / 2.0 s = 0.5 / s x = (m[2][0] + m[0][2]) * s y = (m[1][2] + m[2][1]) * s w = (m[0][1] - m[1][0]) * s return w, x, y, z
| 6,137
|
def save_frame(): for obj in self.meshes: data = Blender.NMesh.GetRawFromObject(obj.getName()) m = obj.getMatrix() # action/frame/mesh/vertices for nv in self.objvertmaps[obj.getName()]: v = data.verts[nv] t = [0, 0, 0] t[0] = m[0][0]*v[0] + m[1][0]*v[1] + m[2][0]*v[2] + m[3][0] t[1] = m[0][1]*v[0] + m[1][1]*v[1] + m[2][1]*v[2] + m[3][1] t[2] = m[0][2]*v[0] + m[1][2]*v[1] + m[2][2]*v[2] + m[3][2] t[0] *= ZOOM t[1] *= ZOOM t[2] *= ZOOM self.file.write(struct.pack("=fff", t[1], -t[2], t[0]))
|
def save_frame(): for obj in self.meshes: data = Blender.NMesh.GetRawFromObject(obj.getName()) m = obj.getMatrix() # action/frame/mesh/vertices for nv in self.objvertmaps[obj.getName()]: v = data.verts[nv] t = [0, 0, 0] t[0] = m[0][0]*v[0] + m[1][0]*v[1] + m[2][0]*v[2] + m[3][0] t[1] = m[0][1]*v[0] + m[1][1]*v[1] + m[2][1]*v[2] + m[3][1] t[2] = m[0][2]*v[0] + m[1][2]*v[1] + m[2][2]*v[2] + m[3][2] t[0] *= ZOOM t[1] *= ZOOM t[2] *= ZOOM self.file.write(struct.pack("=fff", t[1], -t[2], t[0]))
| 6,138
|
def save_frame(): for obj in self.meshes: data = Blender.NMesh.GetRawFromObject(obj.getName()) m = obj.getMatrix() # action/frame/mesh/vertices for nv in self.objvertmaps[obj.getName()]: v = data.verts[nv] t = [0, 0, 0] t[0] = m[0][0]*v[0] + m[1][0]*v[1] + m[2][0]*v[2] + m[3][0] t[1] = m[0][1]*v[0] + m[1][1]*v[1] + m[2][1]*v[2] + m[3][1] t[2] = m[0][2]*v[0] + m[1][2]*v[1] + m[2][2]*v[2] + m[3][2] t[0] *= ZOOM t[1] *= ZOOM t[2] *= ZOOM self.file.write(struct.pack("=fff", t[1], -t[2], t[0]))
|
def save_frame(): for obj in self.meshes: data = Blender.NMesh.GetRawFromObject(obj.getName()) m = obj.getMatrix() # action/frame/mesh/vertices for nv in self.objvertmaps[obj.getName()]: v = data.verts[nv] t = [0, 0, 0] t[0] = m[0][0]*v[0] + m[1][0]*v[1] + m[2][0]*v[2] + m[3][0] t[1] = m[0][1]*v[0] + m[1][1]*v[1] + m[2][1]*v[2] + m[3][1] t[2] = m[0][2]*v[0] + m[1][2]*v[1] + m[2][2]*v[2] + m[3][2] t[0] *= ZOOM t[1] *= ZOOM t[2] *= ZOOM self.file.write(struct.pack("=fff", t[1], -t[2], t[0]))
| 6,139
|
def mapvertex(index, u, v): for mv in xrange(0, len(vertexmap)): if vertexmap[mv] == index and uvs[mv] == (u, v): return mv vertexmap.append(index) uvs.append( (u, v) ) return len(vertexmap)-1
|
def mapvertex(index, u, v): for mv in xrange(0, len(vertexmap)): if vertexmap[mv] == index and uvs[mv] == (u, v): return mv vertexmap.append(index) uvs.append( (u, v) ) return len(vertexmap)-1
| 6,140
|
def mapvertex(index, u, v): for mv in xrange(0, len(vertexmap)): if vertexmap[mv] == index and uvs[mv] == (u, v): return mv vertexmap.append(index) uvs.append( (u, v) ) return len(vertexmap)-1
|
def mapvertex(index, u, v): for mv in xrange(0, len(vertexmap)): if vertexmap[mv] == index and uvs[mv] == (u, v): return mv vertexmap.append(index) uvs.append( (u, v) ) return len(vertexmap)-1
| 6,141
|
def mapvertex(index, u, v): for mv in xrange(0, len(vertexmap)): if vertexmap[mv] == index and uvs[mv] == (u, v): return mv vertexmap.append(index) uvs.append( (u, v) ) return len(vertexmap)-1
|
def mapvertex(index, u, v): for mv in xrange(0, len(vertexmap)): if vertexmap[mv] == index and uvs[mv] == (u, v): return mv vertexmap.append(index) uvs.append( (u, v) ) return len(vertexmap)-1
| 6,142
|
def mapvertex(index, u, v): for mv in xrange(0, len(vertexmap)): if vertexmap[mv] == index and uvs[mv] == (u, v): return mv vertexmap.append(index) uvs.append( (u, v) ) return len(vertexmap)-1
|
def mapvertex(index, u, v): for mv in xrange(0, len(vertexmap)): if vertexmap[mv] == index and uvs[mv] == (u, v): return mv vertexmap.append(index) uvs.append( (u, v) ) return len(vertexmap)-1
| 6,143
|
def mapvertex(index, u, v): for mv in xrange(0, len(vertexmap)): if vertexmap[mv] == index and uvs[mv] == (u, v): return mv vertexmap.append(index) uvs.append( (u, v) ) return len(vertexmap)-1
|
def mapvertex(index, u, v): for mv in xrange(0, len(vertexmap)): if vertexmap[mv] == index and uvs[mv] == (u, v): return mv vertexmap.append(index) uvs.append( (u, v) ) return len(vertexmap)-1
| 6,144
|
def mapvertex(index, u, v): for mv in xrange(0, len(vertexmap)): if vertexmap[mv] == index and uvs[mv] == (u, v): return mv vertexmap.append(index) uvs.append( (u, v) ) return len(vertexmap)-1
|
def mapvertex(index, u, v): for mv in xrange(0, len(vertexmap)): if vertexmap[mv] == index and uvs[mv] == (u, v): return mv vertexmap.append(index) uvs.append( (u, v) ) return len(vertexmap)-1
| 6,145
|
def mapvertex(index, u, v): for mv in xrange(0, len(vertexmap)): if vertexmap[mv] == index and uvs[mv] == (u, v): return mv vertexmap.append(index) uvs.append( (u, v) ) return len(vertexmap)-1
|
def mapvertex(index, u, v): for mv in xrange(0, len(vertexmap)): if vertexmap[mv] == index and uvs[mv] == (u, v): return mv vertexmap.append(index) uvs.append( (u, v) ) return len(vertexmap)-1
| 6,146
|
def mapvertex(index, u, v): for mv in xrange(0, len(vertexmap)): if vertexmap[mv] == index and uvs[mv] == (u, v): return mv vertexmap.append(index) uvs.append( (u, v) ) return len(vertexmap)-1
|
def mapvertex(index, u, v): for mv in xrange(0, len(vertexmap)): if vertexmap[mv] == index and uvs[mv] == (u, v): return mv vertexmap.append(index) uvs.append( (u, v) ) return len(vertexmap)-1
| 6,147
|
def h_include (self, dict): """ Called when an \\include macro is found. This includes files into the source in a way very similar to \\input, except that LaTeX also creates .aux files for them, so we have to notice this. """ if not dict["arg"]: return if self.include_only and not self.include_only.has_key(dict["arg"]): return file, _ = self.input_file(dict["arg"], dict) if file: if file[-4:] == ".tex": file = file[:-4] aux = basename(file) + ".aux" self.removed_files.append(aux) self.aux_old[aux] = None if exists(aux): self.aux_md5[aux] = md5_file(aux) else: self.aux_md5[aux] = None
|
def h_include (self, dict): """ Called when an \\include macro is found. This includes files into the source in a way very similar to \\input, except that LaTeX also creates .aux files for them, so we have to notice this. """ if not dict["arg"]: return if self.include_only and not self.include_only.has_key(dict["arg"]): return file, _ = self.input_file(dict["arg"], dict) if file: aux = dict["arg"] + ".aux" self.removed_files.append(aux) self.aux_old[aux] = None if exists(aux): self.aux_md5[aux] = md5_file(aux) else: self.aux_md5[aux] = None
| 6,148
|
def includegraphics (self, dict): """ This method is triggered by th \\includegraphics macro, it looks for the graphics file specified as argument and adds it either to the dependencies or to the list of graphics not found. """ name = dict["arg"] suffixes = self.suffixes
|
def includegraphics (self, dict): """ This method is triggered by th \\includegraphics macro, it looks for the graphics file specified as argument and adds it either to the dependencies or to the list of graphics not found. """ name = dict["arg"] suffixes = self.suffixes
| 6,149
|
def includegraphics (self, dict): """ This method is triggered by th \\includegraphics macro, it looks for the graphics file specified as argument and adds it either to the dependencies or to the list of graphics not found. """ name = dict["arg"] suffixes = self.suffixes
|
def includegraphics (self, dict): """ This method is triggered by th \\includegraphics macro, it looks for the graphics file specified as argument and adds it either to the dependencies or to the list of graphics not found. """ name = dict["arg"] suffixes = self.suffixes
| 6,150
|
def main (self, cmdline): self.env = Environment(self.msg) self.modules = []
|
def main (self, cmdline): self.env = Environment(self.msg) self.modules = []
| 6,151
|
def main (self, cmdline): self.env = Environment(self.msg) self.modules = []
|
def main (self, cmdline): self.env = Environment(self.msg) self.modules = []
| 6,152
|
def update_seq (self): """ Update the regular expression used to match macro calls using the keys in the `hook' dictionary. We don't match all control sequences for obvious efficiency reasons. """ self.seq = re.compile("\
|
def update_seq (self): """ Update the regular expression used to match macro calls using the keys in the `hook' dictionary. We don't match all control sequences for obvious efficiency reasons. """ self.seq = re.compile("\
| 6,153
|
def execute (self, prog, env={}, pwd=None, out=None): """ Silently execute an external program. The `prog' argument is the list of arguments for the program, `prog[0]' is the program name. The `env' argument is a dictionary with definitions that should be added to the environment when running the program. The standard output is passed line by line to the `out' function (or discarded by default). The error output is parsed and messages from Kpathsea are processed (to indicate e.g. font compilation). """ self.msg(1, _("executing: %s") % string.join(prog)) if pwd: self.msg(2, _(" in directory %s") % pwd) if env != {}: self.msg(2, _(" with environment: %r") % env)
|
def execute (self, prog, env={}, pwd=None, out=None): """ Silently execute an external program. The `prog' argument is the list of arguments for the program, `prog[0]' is the program name. The `env' argument is a dictionary with definitions that should be added to the environment when running the program. The standard output is passed line by line to the `out' function (or discarded by default). The error output is parsed and messages from Kpathsea are processed (to indicate e.g. font compilation). """ self.msg(1, _("executing: %s") % string.join(prog)) if pwd: self.msg(2, _(" in directory %s") % pwd) if env != {}: self.msg(2, _(" with environment: %r") % env)
| 6,154
|
def execute (self, prog, env={}, pwd=None, out=None): """ Silently execute an external program. The `prog' argument is the list of arguments for the program, `prog[0]' is the program name. The `env' argument is a dictionary with definitions that should be added to the environment when running the program. The standard output is passed line by line to the `out' function (or discarded by default). The error output is parsed and messages from Kpathsea are processed (to indicate e.g. font compilation). """ self.msg(1, _("executing: %s") % string.join(prog)) if pwd: self.msg(2, _(" in directory %s") % pwd) if env != {}: self.msg(2, _(" with environment: %r") % env)
|
def execute (self, prog, env={}, pwd=None, out=None): """ Silently execute an external program. The `prog' argument is the list of arguments for the program, `prog[0]' is the program name. The `env' argument is a dictionary with definitions that should be added to the environment when running the program. The standard output is passed line by line to the `out' function (or discarded by default). The error output is parsed and messages from Kpathsea are processed (to indicate e.g. font compilation). """ self.msg(1, _("executing: %s") % string.join(prog)) if pwd: self.msg(2, _(" in directory %s") % pwd) if env != {}: self.msg(2, _(" with environment: %r") % env)
| 6,155
|
def show_errors (self): """ Display all errors that occured during compilation. Return 0 if there was no error. """ pos = ["(no file)"] last_file = None showing = 0 # 1 if we are showing an error's text skipping = 0 # 1 if we are skipping text until a new line something = 0 # 1 if some error was displayed for line in self.lines: line = line.rstrip() if line == "": skipping = 0 elif skipping: pass elif showing: self.msg(0, line) if line[0:2] == "l." or line[0:3] == "***": showing = 0 skipping = 1 else: self.update_file(line, pos) elif line[0] == "!": if pos[-1] != last_file: last_file = pos[-1] self.msg(0, _("in file %s:") % last_file) self.msg(0, line) showing = 1 something = 1 else:
|
def show_errors (self): """ Display all errors that occured during compilation. Return 0 if there was no error. """ pos = ["(no file)"] last_file = None showing = 0 # 1 if we are showing an error's text skipping = 0 # 1 if we are skipping text until a new line something = 0 # 1 if some error was displayed for line in self.lines: line = line.rstrip() if line == "": skipping = 0 elif skipping: pass elif showing: self.msg(0, line) if line[0:2] == "l." or line[0:3] == "***": showing = 0 skipping = 1 else: self.update_file(line, pos) elif line[0] == "!": if pos[-1] != last_file: last_file = pos[-1] self.msg(0, _("in file %s:") % last_file) self.msg(0, line) showing = 1 something = 1 else:
| 6,156
|
def show_errors (self): """ Display all errors that occured during compilation. Return 0 if there was no error. """ pos = ["(no file)"] last_file = None showing = 0 # 1 if we are showing an error's text skipping = 0 # 1 if we are skipping text until a new line something = 0 # 1 if some error was displayed for line in self.lines: line = line.rstrip() if line == "": skipping = 0 elif skipping: pass elif showing: self.msg(0, line) if line[0:2] == "l." or line[0:3] == "***": showing = 0 skipping = 1 else: self.update_file(line, pos) elif line[0] == "!": if pos[-1] != last_file: last_file = pos[-1] self.msg(0, _("in file %s:") % last_file) self.msg(0, line) showing = 1 something = 1 else:
|
def show_errors (self): """ Display all errors that occured during compilation. Return 0 if there was no error. """ pos = ["(no file)"] last_file = None showing = 0 # 1 if we are showing an error's text skipping = 0 # 1 if we are skipping text until a new line something = 0 # 1 if some error was displayed for line in self.lines: line = line.rstrip() if line == "": skipping = 0 elif skipping: pass elif showing: self.msg(0, line) if line[0:2] == "l." or line[0:3] == "***": showing = 0 skipping = 1 elif line[0] == "!": if pos[-1] != last_file: last_file = pos[-1] self.msg(0, _("in file %s:") % last_file) self.msg(0, line) showing = 1 something = 1 else:
| 6,157
|
def __init__ (self, doc, source, target, transcript): """ Initialize the index, by specifying the source file (generated by LaTeX), the target file (the output of makeindex) and the transcript (e.g. .ilg) file. Transcript is used by glosstex.py. """ self.doc = doc self.pbase = doc.src_base self.source = doc.src_base + "." + source self.target = doc.src_base + "." + target self.transcript = doc.src_base + "." + transcript if os.path.exists(self.source): self.md5 = md5_file(self.source) else: self.md5 = None
|
def __init__ (self, doc, source, target, transcript): """ Initialize the index, by specifying the source file (generated by LaTeX), the target file (the output of makeindex) and the transcript (e.g. .ilg) file. Transcript is used by glosstex.py. """ self.doc = doc self.source = doc.src_base + "." + source self.target = doc.src_base + "." + target self.transcript = doc.src_base + "." + transcript if os.path.exists(self.source): self.md5 = md5_file(self.source) else: self.md5 = None
| 6,158
|
def post_compile (self): """ Run makeindex if needed, with appropriate options and environment. """ if not os.path.exists(self.source): msg.log(_("strange, there is no %s") % self.source, pkg="index") return 0 if not self.run_needed(): return 0
|
def post_compile (self): """ Run makeindex if needed, with appropriate options and environment. """ if not os.path.exists(self.source): msg.log(_("strange, there is no %s") % self.source, pkg="index") return 0 if not self.run_needed(): return 0
| 6,159
|
def post_compile (self): """ Run makeindex if needed, with appropriate options and environment. """ if not os.path.exists(self.source): msg.log(_("strange, there is no %s") % self.source, pkg="index") return 0 if not self.run_needed(): return 0
|
def post_compile (self): """ Run makeindex if needed, with appropriate options and environment. """ if not os.path.exists(self.source): msg.log(_("strange, there is no %s") % self.source, pkg="index") return 0 if not self.run_needed(): return 0
| 6,160
|
def show_errors (self): """ Display all errors that occured during compilation. Return 0 if there was no error. """ pos = ["(no file)"] last_file = None showing = 0 # 1 if we are showing an error's text skipping = 0 # 1 if we are skipping text until a new line something = 0 # 1 if some error was displayed for line in self.lines: line = line.rstrip() if line == "": skipping = 0 elif skipping: pass elif showing: self.msg(0, line) if line[0:2] == "l." or line[0:3] == "***": showing = 0 skipping = 1 else: self.update_file(line, pos) elif line[0] == "!": if pos[-1] != last_file: last_file = pos[-1] self.msg(0, _("in file %s:") % last_file) self.msg(0, line) showing = 1 something = 1 else:
|
def show_errors (self): """ Display all errors that occured during compilation. Return 0 if there was no error. """ pos = ["(no file)"] last_file = None showing = 0 # 1 if we are showing an error's text skipping = 0 # 1 if we are skipping text until a new line something = 0 # 1 if some error was displayed for line in self.lines: line = line.rstrip() if line == "": skipping = 0 elif skipping: pass elif showing: self.msg(0, line) if line[0:2] == "l." or line[0:3] == "***": showing = 0 skipping = 1 else: self.update_file(line, pos) elif line[0] == "!": if pos[-1] != last_file: last_file = pos[-1] self.msg(0, _("in file %s:") % last_file) self.msg(0, line) showing = 1 something = 1 else:
| 6,161
|
def show_errors (self): """ Display all errors that occured during compilation. Return 0 if there was no error. """ pos = ["(no file)"] last_file = None showing = 0 # 1 if we are showing an error's text skipping = 0 # 1 if we are skipping text until a new line something = 0 # 1 if some error was displayed for line in self.lines: line = line.rstrip() if line == "": skipping = 0 elif skipping: pass elif showing: self.msg(0, line) if line[0:2] == "l." or line[0:3] == "***": showing = 0 skipping = 1 else: self.update_file(line, pos) elif line[0] == "!": if pos[-1] != last_file: last_file = pos[-1] self.msg(0, _("in file %s:") % last_file) self.msg(0, line) showing = 1 something = 1 else:
|
def show_errors (self): """ Display all errors that occured during compilation. Return 0 if there was no error. """ pos = ["(no file)"] last_file = None showing = 0 # 1 if we are showing an error's text skipping = 0 # 1 if we are skipping text until a new line something = 0 # 1 if some error was displayed for line in self.lines: line = line.rstrip() if line == "": skipping = 0 elif skipping: pass elif showing: self.msg(0, line) if line[0:2] == "l." or line[0:3] == "***": showing = 0 skipping = 1 elif line[0] == "!": if pos[-1] != last_file: last_file = pos[-1] self.msg(0, _("in file %s:") % last_file) self.msg(0, line) showing = 1 something = 1 else:
| 6,162
|
def includegraphics (self, dict): """ This method is triggered by th \\includegraphics macro, it looks for the graphics file specified as argument and adds it either to the dependencies or to the list of graphics not found. """ name = dict["arg"] suffixes = self.suffixes
|
def includegraphics (self, dict): """ This method is triggered by th \\includegraphics macro, it looks for the graphics file specified as argument and adds it either to the dependencies or to the list of graphics not found. """ name = dict["arg"] suffixes = self.suffixes
| 6,163
|
def includegraphics (self, dict): """ This method is triggered by th \\includegraphics macro, it looks for the graphics file specified as argument and adds it either to the dependencies or to the list of graphics not found. """ name = dict["arg"] suffixes = self.suffixes
|
def includegraphics (self, dict): """ This method is triggered by th \\includegraphics macro, it looks for the graphics file specified as argument and adds it either to the dependencies or to the list of graphics not found. """ name = dict["arg"] suffixes = self.suffixes
| 6,164
|
def __init__ (self, target, source, env): sources = [] self.include(source, sources) env.msg(2, "%s is made from %r" % (target, sources)) self.leaf = DependLeaf(sources) Depend.__init__(self, [target], {source: self.leaf}) self.env = env self.base = source[:-3] self.cmd = ["mpost", "--interaction=batchmode", self.base] if env.src_path != "": cmd = [ "env", "MPINPUTS=:%s:%s" % (self.env.src_path, os.getenv("MPINPUTS", ""))] + cmd
|
def __init__ (self, target, source, env): sources = [] self.include(source, sources) env.msg(2, _("%s is made from %r") % (target, sources)) self.leaf = DependLeaf(sources) Depend.__init__(self, [target], {source: self.leaf}) self.env = env self.base = source[:-3] self.cmd = ["mpost", "--interaction=batchmode", self.base] if env.src_path != "": cmd = [ "env", "MPINPUTS=:%s:%s" % (self.env.src_path, os.getenv("MPINPUTS", ""))] + cmd
| 6,165
|
def run (self): self.env.msg(0, "running Metapost on %s.mp..." % self.base) self.env.execute(self.cmd)
|
def run (self): self.env.msg(0, _("running Metapost on %s.mp...") % self.base) self.env.execute(self.cmd)
| 6,166
|
def run (self): self.env.msg(0, "running Metapost on %s.mp..." % self.base) self.env.execute(self.cmd)
|
def run (self): self.env.msg(0, "running Metapost on %s.mp..." % self.base) self.env.execute(self.cmd)
| 6,167
|
def run (self): self.env.msg(0, "running Metapost on %s.mp..." % self.base) self.env.execute(self.cmd)
|
def run (self): self.env.msg(0, "running Metapost on %s.mp..." % self.base) self.env.execute(self.cmd)
| 6,168
|
def parse (self, errors=0, boxes=0, refs=0, warnings=0): """ Parse the log file for relevant information. The named arguments are booleans that indicate which information should be extracted: - errors: all errors - boxes: bad boxes - refs: warnings about references - warnings: all other warnings The function returns a generator. Each generated item is a dictionary that contains (some of) the following entries: - kind: the kind of information ("error", "box", "ref", "warning") - text: the text of the error or warning - code: the piece of code that caused an error - file, line, last, pkg: as used by Message.format_pos. """ if not self.lines: return last_file = None pos = [last_file] page = 1 parsing = 0 # 1 if we are parsing an error's text skipping = 0 # 1 if we are skipping text until an empty line something = 0 # 1 if some error was found prefix = None # the prefix for warning messages from packages accu = "" # accumulated text from the previous line for line in self.lines: line = line[:-1] # remove the line feed
|
def parse (self, errors=0, boxes=0, refs=0, warnings=0): """ Parse the log file for relevant information. The named arguments are booleans that indicate which information should be extracted: - errors: all errors - boxes: bad boxes - refs: warnings about references - warnings: all other warnings The function returns a generator. Each generated item is a dictionary that contains (some of) the following entries: - kind: the kind of information ("error", "box", "ref", "warning") - text: the text of the error or warning - code: the piece of code that caused an error - file, line, last, pkg: as used by Message.format_pos. """ if not self.lines: return last_file = None pos = [last_file] page = 1 parsing = 0 # 1 if we are parsing an error's text skipping = 0 # 1 if we are skipping text until an empty line something = 0 # 1 if some error was found prefix = None # the prefix for warning messages from packages accu = "" # accumulated text from the previous line for line in self.lines: line = line[:-1] # remove the line feed
| 6,169
|
def __init__ (self, doc, source, target, transcript): """ Initialize the index, by specifying the source file (generated by LaTeX), the target file (the output of makeindex) and the transcript (e.g. .ilg) file. Transcript is used by glosstex.py. """ self.doc = doc self.pbase = doc.src_base self.source = doc.src_base + "." + source self.target = doc.src_base + "." + target self.transcript = doc.src_base + "." + transcript if os.path.exists(self.source): self.md5 = md5_file(self.source) else: self.md5 = None
|
def __init__ (self, doc, source, target, transcript): """ Initialize the index, by specifying the source file (generated by LaTeX), the target file (the output of makeindex) and the transcript (e.g. .ilg) file. Transcript is used by glosstex.py. """ self.doc = doc self.pbase = doc.src_base self.source = doc.src_base + "." + source self.target = doc.src_base + "." + target self.transcript = doc.src_base + "." + transcript if os.path.exists(self.source): self.md5 = md5_file(self.source) else: self.md5 = None
| 6,170
|
def post_compile (self): """ Run makeindex if needed, with appropriate options and environment. """ if not os.path.exists(self.source): msg.log(_("strange, there is no %s") % self.source, pkg="index") return 0 if not self.run_needed(): return 0
|
def post_compile (self): """ Run makeindex if needed, with appropriate options and environment. """ if not os.path.exists(self.source): msg.log(_("strange, there is no %s") % self.source, pkg="index") return 0 if not self.run_needed(): return 0
| 6,171
|
def post_compile (self): """ Run makeindex if needed, with appropriate options and environment. """ if not os.path.exists(self.source): msg.log(_("strange, there is no %s") % self.source, pkg="index") return 0 if not self.run_needed(): return 0
|
def post_compile (self): """ Run makeindex if needed, with appropriate options and environment. """ if not os.path.exists(self.source): msg.log(_("strange, there is no %s") % self.source, pkg="index") return 0 if not self.run_needed(): return 0
| 6,172
|
def makeindex (self, dict): """ Register the standard index. """ self.indices["default"] = Index(self.doc, "idx", "ind", "ilg")
|
def makeindex (self, dict): """ Register the standard index. """ self.indices["default"] = Index(self.doc, "idx", "ind", "ilg")
| 6,173
|
def newindex (self, dict): """ Register a new index. """ m = re_newindex.match(dict["line"]) if not m: return index = dict["arg"] d = m.groupdict() self.indices[index] = Index(self.doc, d["idx"], d["ind"], "ilg") msg.log(_("index %s registered") % index, pkg="index")
|
def newindex (self, dict): """ Register a new index. """ m = re_newindex.match(dict["line"]) if not m: return index = dict["arg"] d = m.groupdict() self.register(index, d["idx"], d["ind"], "ilg") msg.log(_("index %s registered") % index, pkg="index")
| 6,174
|
def command (self, cmd, args): indices = self.indices if len(args) > 0: m = re_optarg.match(args[0]) if m: for index in m.group("list").split(","): if indices.has_key(index): indices[index].command(cmd, args[1:]) else: for index in indices.values(): index.command(cmd, args)
|
def command (self, cmd, args): indices = self.indices if len(args) > 0: m = re_optarg.match(args[0]) if m: for index in m.group("list").split(","): if indices.has_key(index): indices[index].command(cmd, args[1:]) else: for index in indices.values(): index.command(cmd, args)
| 6,175
|
def find_input (self, name): """ Look for a source file with the given name, and return either the complete path to the actual file or None if the file is not found. """ for path in self.path: test = join(path, name) if exists(test): return test elif exists(test + ".tex"): return test + ".tex" return None
|
def find_input (self, name): """ Look for a source file with the given name, and return either the complete path to the actual file or None if the file is not found. """ for path in self.path: test = join(path, name) if exists(test) and isfile(test): return test elif exists(test + ".tex"): return test + ".tex" return None
| 6,176
|
def find_input (self, name): """ Look for a source file with the given name, and return either the complete path to the actual file or None if the file is not found. """ for path in self.path: test = join(path, name) if exists(test): return test elif exists(test + ".tex"): return test + ".tex" return None
|
def find_input (self, name): """ Look for a source file with the given name, and return either the complete path to the actual file or None if the file is not found. """ for path in self.path: test = join(path, name) if exists(test): return test elif exists(test + ".tex") and isfile(test + ".tex"): return test + ".tex" return None
| 6,177
|
def main (self, cmdline): self.env = Environment(self.msg) self.modules = []
|
def main (self, cmdline): self.env = Environment(self.msg) self.modules = []
| 6,178
|
def main (self, cmdline): self.env = Environment(self.msg) self.modules = []
|
def main (self, cmdline): self.env = Environment(self.msg) self.modules = []
| 6,179
|
def parse (self, errors=0, boxes=0, refs=0, warnings=0): """ Parse the log file for relevant information. The named arguments are booleans that indicate which information should be extracted: - errors: all errors - boxes: bad boxes - refs: warnings about references - warnings: all other warnings The function returns a generator. Each generated item is a dictionary that contains (some of) the following entries: - kind: the kind of information ("error", "box", "ref", "warning") - text: the text of the error or warning - code: the piece of code that caused an error - file, line, last, pkg: as used by Message.format_pos. """ if not self.lines: return last_file = None pos = [last_file] page = 1 parsing = 0 # 1 if we are parsing an error's text skipping = 0 # 1 if we are skipping text until an empty line something = 0 # 1 if some error was found prefix = None # the prefix for warning messages from packages accu = "" # accumulated text from the previous line for line in self.lines: line = line[:-1] # remove the line feed
|
def parse (self, errors=0, boxes=0, refs=0, warnings=0): """ Parse the log file for relevant information. The named arguments are booleans that indicate which information should be extracted: - errors: all errors - boxes: bad boxes - refs: warnings about references - warnings: all other warnings The function returns a generator. Each generated item is a dictionary that contains (some of) the following entries: - kind: the kind of information ("error", "box", "ref", "warning") - text: the text of the error or warning - code: the piece of code that caused an error - file, line, last, pkg: as used by Message.format_pos. """ if not self.lines: return last_file = None pos = [last_file] page = 1 parsing = 0 # 1 if we are parsing an error's text skipping = 0 # 1 if we are skipping text until an empty line something = 0 # 1 if some error was found prefix = None # the prefix for warning messages from packages accu = "" # accumulated text from the previous line for line in self.lines: line = line[:-1] # remove the line feed
| 6,180
|
def check (source, target, suffixes=suffixes): if self.env.may_produce(source): return 0 if suffixes == [""]: return 1 for suffix in suffixes: if source[-len(suffix):] == suffix: return 0 return 1
|
def check (source, target, suffixes=suffixes): if exists(target) and self.env.may_produce(source): return 0 if suffixes == [""]: return 1 for suffix in suffixes: if source[-len(suffix):] == suffix: return 0 return 1
| 6,181
|
def do_setup (): """ Run the setup() function from the distutils with appropriate arguments. """ from distutils.core import setup try: mandir = expand_vars(settings.sub, settings.sub["mandir"]) except NameError: mandir = "man" setup( name = "rubber", version = settings.sub["version"], description = "The Rubber system for building LaTeX documents", long_description = """\
|
def do_setup (): """ Run the setup() function from the distutils with appropriate arguments. """ from distutils.core import setup try: mandir = expand_vars(settings.sub, settings.sub["mandir"]) except NameError: mandir = "man" setup( name = "rubber", version = settings.sub["version"], description = "The Rubber system for building LaTeX documents", long_description = """\
| 6,182
|
def register (self, name, dict={}): """ Attempt to register a package with the specified name. If a module is found, create an object from the module's class called `Module', passing it the environment and `dict' as arguments. This dictionary describes the command that caused the registration. """ r = self.load_module(name, "rubber.modules") if r == 0: self.env.msg(3, _("no support found for %s") % name) return 1 elif r == 2: self.env.msg(3, _("module %s already registered") % name) return 1 mod = self.modules[name].Module(self.env, dict) self.env.msg(2, _("module %s registered") % name) self.objects[name] = mod return 0
|
def register (self, name, dict={}): """ Attempt to register a package with the specified name. If a module is found, create an object from the module's class called `Module', passing it the environment and `dict' as arguments. This dictionary describes the command that caused the registration. """ r = self.load_module(name, "rubber.modules") if r == 0: self.env.msg(3, _("no support found for %s") % name) return 1 elif r == 2: self.env.msg(3, _("module %s already registered") % name) return 1 mod = self.modules[name].Module(self.env, dict) self.env.msg(2, _("module %s registered") % name) self.objects[name] = mod return 0
| 6,183
|
def update_file (self, line, stack): """ Parse the given line of log file for file openings and closings and update the list `stack'. Newly opened files are at the end, therefore stack[0] is the main source while stack[-1] is the current one. """ m = re_file.search(line) if not m: return while m: file = m.group("file") if file: stack.append(file) else: del stack[-1] line = line[m.end():] m = re_file.search(line) return
|
def update_file (self, line, stack): """ Parse the given line of log file for file openings and closings and update the list `stack'. Newly opened files are at the end, therefore stack[0] is the main source while stack[-1] is the current one. """ m = re_file.search(line) if not m: return while m: if line[m.start()] == '(': stack.append(m.group("file")) else: del stack[-1] line = line[m.end():] m = re_file.search(line) return
| 6,184
|
def clean (self): """ Remove all generated files related to the index. """ for file in self.source, self.target: if exists(file): self.env.msg(1, _("removing %s") % file) os.unlink(file)
|
def clean (self): """ Remove all generated files related to the index. """ for file in self.source, self.target, self.pbase + ".ilg": if exists(file): self.env.msg(1, _("removing %s") % file) os.unlink(file)
| 6,185
|
def errors (self): """ Returns true if there was an error during the compilation. """ for line in self.lines: if line[0] == "!": return 1 return 0
|
def errors (self): """ Returns true if there was an error during the compilation. """ for line in self.lines: if line[0] == "!": return string.find(line, "warning:") != -1 return 0
| 6,186
|
def command (self, cmd, arg): """ Execute the rubber command 'cmd' with argument 'arg'. This is called when a command is found in the source file or in a configuration file. A command name of the form 'foo.bar' is considered to be a command 'bar' for module 'foo'. """ if cmd == "depend": file = self.conf.find_input(arg) if file: self.depends[file] = DependLeaf([file]) else: self.msg(1, _("dependency '%s' not found") % arg)
|
def command (self, cmd, arg): """ Execute the rubber command 'cmd' with argument 'arg'. This is called when a command is found in the source file or in a configuration file. A command name of the form 'foo.bar' is considered to be a command 'bar' for module 'foo'. """ if cmd == "clean": self.removed_files.append(arg) elif cmd == "depend": file = self.conf.find_input(arg) if file: self.depends[file] = DependLeaf([file]) else: self.msg(1, _("dependency '%s' not found") % arg)
| 6,187
|
def h_tableofcontents (self, dict): self.watch_file(self.base + ".toc")
|
def h_tableofcontents (self, dict): self.watch_file(self.base + ".toc")
| 6,188
|
def h_listoffigures (self, dict): self.watch_file(self.base + ".lof")
|
def h_listoffigures (self, dict): self.watch_file(self.base + ".lof")
| 6,189
|
def h_listoftables (self, dict): self.watch_file(self.base + ".lot")
|
def h_listoftables (self, dict): self.watch_file(self.base + ".lot")
| 6,190
|
def make (self): """ Make the destination file. This recursively makes all dependencies, then compiles the target if dependencies were modified. The semantics of the return value is the following: - 0 means that the process failed somewhere (in this node or in one of its dependencies) - 1 means that nothing had to be done - 2 means that something was recompiled (therefore nodes that depend on this one have to be remade) """ must_make = 0 for src in self.sources.values(): ret = src.make() if ret == 0: return 0 if ret == 2: must_make = 1 if must_make or self.should_make(): if self.run(): return 0 self.date = time.time() return 2 return 1
|
def make (self): """ Make the destination file. This recursively makes all dependencies, then compiles the target if dependencies were modified. The semantics of the return value is the following: - 0 means that the process failed somewhere (in this node or in one of its dependencies) - 1 means that nothing had to be done - 2 means that something was recompiled (therefore nodes that depend on this one have to be remade) """ must_make = 0 for src in self.sources.values(): ret = src.make() if ret == 0: return 0 if ret == 2: must_make = 1 if must_make or self.should_make(): if self.run(): return 0 self.date = int(time.time()) return 2 return 1
| 6,191
|
def error (self, file, line, text, code): """ This method is called when the parsing of the log file found an error. The arguments are, respectively, the name of the file and the line number where the error occurred, the description of the error, and the offending code (up to the error). """ self.write(0, _("\nline %d in %s:\n %s") % (line, file, text)) if string.strip(code) != "": self.write(0, " --> " + code)
|
def error (self, file, line, text, code): """ This method is called when the parsing of the log file found an error. The arguments are, respectively, the name of the file and the line number where the error occurred, the description of the error, and the offending code (up to the error). """ self.write(0, _("\nline %d in %s:\n %s") % (line, file, text)) if code: self.write(0, " --> " + code)
| 6,192
|
def register (self, name, dict={}): """ Attempt to register a package with the specified name. If a module is found, create an object from the module's class called `Module', passing it the environment and `dict' as arguments. This dictionary describes the command that caused the registration. """ r = self.load_module(name, "rubber.modules") if r == 0: self.env.msg(3, _("no support found for %s") % name) return 1 elif r == 2: self.env.msg(3, _("module %s already registered") % name) return 1 mod = self.modules[name].Module(self.env, dict) self.env.msg(2, _("module %s registered") % name) self.objects[name] = mod return 0
|
def register (self, name, dict={}): """ Attempt to register a package with the specified name. If a module is found, create an object from the module's class called `Module', passing it the environment and `dict' as arguments. This dictionary describes the command that caused the registration. """ r = self.load_module(name, "rubber.modules") if r == 0: self.env.msg(3, _("no support found for %s") % name) return 1 elif r == 2: self.env.msg(3, _("module %s already registered") % name) return 1 mod = self.modules[name].Module(self.env, dict) self.env.msg(2, _("module %s registered") % name) self.objects[name] = mod return 0
| 6,193
|
def show_errors (self): """ Display all errors that occured during compilation. Return 0 if there was no error. """ pos = ["(no file)"] last_file = None parsing = 0 # 1 if we are parsing an error's text skipping = 0 # 1 if we are skipping text until an empty line something = 0 # 1 if some error was found for line in self.lines: line = line.rstrip() if line == "": skipping = 0 elif skipping: pass elif parsing: m = re_line.match(line) if m: parsing = 0 skipping = 1 self.msg.error(pos[-1], int(m.group("line")), error, line[m.end():]) elif line[0:3] == "***": parsing = 0 skipping = 1 self.msg.abort(error, line[4:]) elif line[0] == "!": error = line[2:] parsing = 1 something = 1 else: # Here there is no error to show, so we use the text of the # line to track the source file name. However, there might be # confusing text in the log file, in particular when there is # an overfull/underfull box message (the text following this # is extracted from the source, and the extract may contain # unbalanced parentheses). Therefore we take care of this # specifically.
|
def show_errors (self): """ Display all errors that occured during compilation. Return 0 if there was no error. """ pos = ["(no file)"] last_file = None parsing = 0 # 1 if we are parsing an error's text skipping = 0 # 1 if we are skipping text until an empty line something = 0 # 1 if some error was found for line in self.lines: line = line.rstrip() if line == "": skipping = 0 elif skipping: pass elif parsing: m = re_line.match(line) if m: parsing = 0 skipping = 1 self.msg.error(pos[-1], int(m.group("line")), error, m.group("text")) elif line[0:3] == "***": parsing = 0 skipping = 1 self.msg.abort(error, line[4:]) elif line[0] == "!": error = line[2:] parsing = 1 something = 1 else: # Here there is no error to show, so we use the text of the # line to track the source file name. However, there might be # confusing text in the log file, in particular when there is # an overfull/underfull box message (the text following this # is extracted from the source, and the extract may contain # unbalanced parentheses). Therefore we take care of this # specifically.
| 6,194
|
def set_style (self, style): """ Define the bibliography style used. This method is called when \\bibliographystyle is found. If the style file is found in the current directory, it is considered a dependency. """ old_bst = self.style + ".bst" if exists(old_bst) and self.env.depends.has_key(old_bst): del self.env.depends[old_bst]
|
def set_style (self, style): """ Define the bibliography style used. This method is called when \\bibliographystyle is found. If the style file is found in the current directory, it is considered a dependency. """ old_bst = self.style + ".bst" if exists(old_bst) and self.env.depends.has_key(old_bst): del self.env.depends[old_bst]
| 6,195
|
def register (self, name, dict={}): """ Attempt to register a package with the specified name. If a module is found, create an object from the module's class called `Module', passing it the environment and `dict' as arguments. This dictionary describes the command that caused the registration. """ r = self.load_module(name, "rubber.modules") if r == 0: self.env.msg(3, _("no support found for %s") % name) return 1 elif r == 2: self.env.msg(3, _("module %s already registered") % name) return 1 mod = self.modules[name].Module(self.env, dict) self.env.msg(2, _("module %s registered") % name) self.objects[name] = mod return 0
|
def register (self, name, dict={}): """ Attempt to register a package with the specified name. If a module is found, create an object from the module's class called `Module', passing it the environment and `dict' as arguments. This dictionary describes the command that caused the registration. """ r = self.load_module(name, "rubber.modules") if r == 0: self.env.msg(3, _("no support found for %s") % name) return 1 elif r == 2: self.env.msg(3, _("module %s already registered") % name) return 1 mod = self.modules[name].Module(self.env, dict) self.env.msg(2, _("module %s registered") % name) self.objects[name] = mod return 0
| 6,196
|
def update_file (self, line, stack): """ Parse the given line of log file for file openings and closings and update the list `stack'. Newly opened files are at the end, therefore stack[0] is the main source while stack[-1] is the current one. """ m = re_file.search(line) if not m: return while m: if line[m.start()] == '(': stack.append(m.group("file")) else: del stack[-1] line = line[m.end():] m = re_file.search(line) return
|
def update_file (self, line, stack): """ Parse the given line of log file for file openings and closings and update the list `stack'. Newly opened files are at the end, therefore stack[1] is the main source while stack[-1] is the current one. The first element, stack[0], contains the string \"(no file)\" for errors that may happen outside the source. """ m = re_file.search(line) if not m: return while m: if line[m.start()] == '(': stack.append(m.group("file")) else: del stack[-1] line = line[m.end():] m = re_file.search(line) return
| 6,197
|
def show_errors (self): """ Display all errors that occured during compilation. Return 0 if there was no error. """ pos = ["(no file)"] last_file = None showing = 0 something = 0 for line in self.lines: line = line.rstrip() if line == "": continue if showing: self.msg(0, line) if line[0:2] == "l." or line[0:3] == "***": showing = 0 else: self.update_file(line, pos) else: if line[0] == "!": if pos[-1] != last_file: last_file = pos[-1] self.msg(0, _("in file %s:") % last_file) self.msg(0, line) showing = 1 something = 1 else: self.update_file(line, pos) return something
|
def show_errors (self): """ Display all errors that occured during compilation. Return 0 if there was no error. """ pos = ["(no file)"] last_file = None showing = 0 skipping = 0 something = 0 for line in self.lines: line = line.rstrip() if line == "": continue if showing: self.msg(0, line) if line[0:2] == "l." or line[0:3] == "***": showing = 0 else: self.update_file(line, pos) else: if line[0] == "!": if pos[-1] != last_file: last_file = pos[-1] self.msg(0, _("in file %s:") % last_file) self.msg(0, line) showing = 1 something = 1 else: self.update_file(line, pos) return something
| 6,198
|
def show_errors (self): """ Display all errors that occured during compilation. Return 0 if there was no error. """ pos = ["(no file)"] last_file = None showing = 0 something = 0 for line in self.lines: line = line.rstrip() if line == "": continue if showing: self.msg(0, line) if line[0:2] == "l." or line[0:3] == "***": showing = 0 else: self.update_file(line, pos) else: if line[0] == "!": if pos[-1] != last_file: last_file = pos[-1] self.msg(0, _("in file %s:") % last_file) self.msg(0, line) showing = 1 something = 1 else: self.update_file(line, pos) return something
|
def show_errors (self): """ Display all errors that occured during compilation. Return 0 if there was no error. """ pos = ["(no file)"] last_file = None showing = 0 something = 0 for line in self.lines: line = line.rstrip() if line == "": skipping = 0 elif skipping: pass elif showing: self.msg(0, line) if line[0:2] == "l." or line[0:3] == "***": showing = 0 else: self.update_file(line, pos) else: if line[0] == "!": if pos[-1] != last_file: last_file = pos[-1] self.msg(0, _("in file %s:") % last_file) self.msg(0, line) showing = 1 something = 1 else: self.update_file(line, pos) return something
| 6,199
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.