rem
stringlengths 0
322k
| add
stringlengths 0
2.05M
| context
stringlengths 8
228k
|
---|---|---|
id = dump_contents_entry(subentry, id, parent_id)
|
sublast = last and subentry is entry[-1] print " (@book_id, %d, %d, %s, %s)%s" % (parent_id, subentry.number, quote(subentry.name.encode('utf-8')), quote(subentry.link.encode('utf-8')), (sublast and not len(subentry)) and ";" or ",") id = dump_contents_entry(subentry, id, sublast)
|
def dump_contents_entry(entry, id, parent_id): print " (@book_id, %d, %d, %s, %s)," % (parent_id, entry.number, quote(entry.name.encode('utf-8')), quote(entry.link.encode('utf-8'))) parent_id = id id = parent_id + 1 for subentry in entry: id = dump_contents_entry(subentry, id, parent_id) return id
|
print "INSERT INTO `pages` (book_id, path, data) VALUES" for path in archive.list(): data = archive.open(path).read() print " (@book_id, %s, %s)," % (quote(path.encode('utf-8')), quote(data)) print ";"
|
print "INSERT INTO `pages` (book_id, path, content) VALUES" paths = archive.list() for path in paths: last = path is paths[-1] content = archive.open(path).read() print " (@book_id, %s, %s)%s" % (quote(path.encode('utf-8')), quote(content), last and ';' or ',')
|
def dump_archive(archive): print "INSERT INTO `pages` (book_id, path, data) VALUES" for path in archive.list(): data = archive.open(path).read() print " (@book_id, %s, %s)," % (quote(path.encode('utf-8')), quote(data)) print ";"
|
import sys from DevHelp import factory
|
from HTB import factory
|
def main(): import sys from DevHelp import factory for arg in sys.argv[1:]: try: book = factory(arg) except: raise dump(book)
|
os.path.join(os.getenv('HOME'), '.devhelp2', 'books'),
|
os.path.join(os.getenv('HOME', ''), '.devhelp2', 'books'),
|
def __init__(self, search_path = None): Book.CachingFactory.__init__(self) self._search_path = [ os.path.join(os.getenv('HOME'), '.devhelp2', 'books'), '/usr/share/gtk-doc/html'] if search_path is not None: self._search_path.extend(search_path) self._path_hash = {}
|
for name in os.listdir(dir): spec = os.path.join(dir, name, name + '.devhelp') if os.path.isfile(spec): self._path_hash[name] = spec enum.append(name)
|
if os.path.isdir(dir): for name in os.listdir(dir): spec = os.path.join(dir, name, name + '.devhelp') if os.path.isfile(spec): self._path_hash[name] = spec enum.append(name)
|
def enumerate_uncached(self): enum = Book.List() self._path_hash = {} for dir in self._search_path: for name in os.listdir(dir): spec = os.path.join(dir, name, name + '.devhelp') if os.path.isfile(spec): self._path_hash[name] = spec enum.append(name)
|
item._parentref = weakred.ref(self)
|
item._parentref = weakref.ref(self)
|
def insert(self, index, item): item._parentref = weakred.ref(self) item.number = index + 1 self._children.insert(index, item) self._renumber()
|
return self,_children[0]
|
return self._children[0]
|
def _get_children(self): """Get the first child."""
|
return urlparse.urljoin(base, link)
|
return urlparse.urljoin(self.base, link)
|
def translate_link(self, link): if self.base is None: return link else: return urlparse.urljoin(base, link)
|
self.book.default = self.translate(link)
|
self.book.default = self.translate_link(link)
|
def start_book(self, name, title, link, base = None, **dummy): assert len(self.contents_stack) == 1
|
parser.parser(open(spec))
|
parser.parse(open(spec))
|
def __init__(self, spec): DevHelpBook.__init__(self)
|
if self.entry:
|
if self.entry is not None:
|
def handle_starttag(self, tag, attrs): attrs = dict(attrs) if tag == 'object': if attrs['type'] == 'text/sitemap': self.entry = Book.IndexEntry(None) elif tag == 'param': if self.entry: if attrs['name'] == 'Name': if self.entry.name is None: self.entry.name = attrs['value'].strip() elif attrs['name'] == 'Local': self.entry.links.append(attrs['value'])
|
if self.entry:
|
if self.entry is not None:
|
def handle_endtag(self, tag): if tag == 'object': if self.entry: self.book.index.append(self.entry) self.entry = None
|
def test_extract(): for arg in sys.argv[1:]: title, body = extract_html(open(arg, "rt").read()) print `title` print print `body` print print
|
def extract(path, content): """Extract the title and body of a document in plaintext.""" type = guess_type(path) if type == 'text/html': return extract_html(content) elif type == 'text/plain': return None, content else: return None, None
|
|
path, anchor = split_link(subentry.link)
|
path, anchor = subentry.link is None and ('', '') or split_link(subentry.link)
|
def dump_contents_entries(entry, parent_number, cont = 0): number = parent_number + 1 for subentry in entry: name = subentry.name path, anchor = split_link(subentry.link) sys.stdout.write(cont and ',\n ' or '\n ') sys.stdout.write('(' + ', '.join(quote(literal('@book_id'), number, parent_number, name, path, anchor)) + ')') cont = 1 number = dump_contents_entries(subentry, number, cont) return number
|
def OnLinkClicked(self, link): self.m_Frame.NotifyPageChanged()
|
def OnLinkClicked(self, link): self.m_Frame.NotifyPageChanged()
|
|
import Generic book_factory = Generic.BookFactory()
|
def AddBooks(self): import Generic book_factory = Generic.BookFactory() root = self.m_ContentsBox.AddRoot("Books") for name in book_factory.enumerate(): book = book_factory.book(name) self.AddBook(root, book)
|
|
h = book.page(link).read() self.m_HtmlWin.SetPage(h)
|
if 0: html = book.page(link).read() self.m_HtmlWin.SetPage(html) else: location = self.Location(book, link) print location self.m_HtmlWin.LoadPage(location)
|
def OnContentsSel(self, event): item = event.GetItem() (book, link) = self.m_ContentsBox.GetPyData(item) h = book.page(link).read() self.m_HtmlWin.SetPage(h)
|
if __name__ == "__main__":
|
def main():
|
def OnToolbar(self, event): if event.GetId() == wxID_HTML_PANEL: if not (self.m_Splitter and self.m_NavigPan): return if self.m_Splitter.IsSplit(): self.sashpos = self.m_Splitter.GetSashPosition() self.m_Splitter.Unsplit(self.m_NavigPan); #m_Cfg.navig_on = FALSE else: self.m_NavigPan.Show(TRUE) self.m_HtmlWin.Show(TRUE) self.m_Splitter.SplitVertically(self.m_NavigPan, self.m_HtmlWin, self.sashpos) #m_Cfg.navig_on = TRUE
|
return path[1:]
|
return path[8:]
|
def filter(self, path): if path[:8] == '/sample/': return path[1:] else: return None
|
self.entry.link = value
|
self.entry.links.append(value)
|
def handle_param(self, name, value): if name == 'Name': self.entry.name = value elif name == 'Local': self.entry.link = value
|
if self.node:
|
if self.node is not None:
|
def handle_starttag(self, tag, attrs): attrs = dict(attrs) if tag == 'ul': if len(self.contents_stack) == 0: node = self.book.contents else: assert self.node is not None node = self.node self.contents_stack.append(node) self.node = None elif tag == 'object': if attrs['type'] == 'text/sitemap': self.node = Book.ContentsEntry(None, None) else: self.node = None elif tag == 'param': if self.node: if attrs['name'] == 'Name': self.node.name = attrs['value'].strip() elif attrs['name'] == 'Local': self.node.link = attrs['value']
|
if self.node:
|
if self.node is not None:
|
def handle_endtag(self, tag): if tag == 'ul': self.contents_stack.pop() elif tag == 'object': if self.node: self.contents_stack[-1].append(self.node)
|
_html_title_re = re.compile(r'<title(?:\s.*?)?>(.*?)</title>', re.IGNORECASE | re.DOTALL) _html_body_re = re.compile(r'<body(?:\s.*?)?>(.*?)</body>', re.IGNORECASE | re.DOTALL)
|
_html_title_re = re.compile(r'<title(?:\s.*?)?>(.*?)</title\s*>', re.IGNORECASE | re.DOTALL) _html_body_re = re.compile(r'<body(?:\s.*?)?>(.*?)</body\s*>', re.IGNORECASE | re.DOTALL)
|
def html_entity_decode(s, encoding = 'iso-8859-1'): """Decode HTML entities in a string into Unicode.""" r = [] p = 0 mo = _html_entity_re.search(s, p) while mo: r.append(s[p:mo.start()].decode(encoding)) i = mo.lastindex e = mo.group(i) try: if i == 1: c = htmlentitydefs.name2codepoint[e] elif i == 2: c = int(e) elif i == 3: c = int(e, 16) else: assert 0 r.append(unichr(c)) except KeyError: r.append(mo.group(0)) p = mo.end() mo = _html_entity_re.search(s, p) r.append(s[p:].decode(encoding)) return u''.join(r)
|
toolBar = self.CreateToolBar(wxNO_BORDER | wxTB_HORIZONTAL | wxTB_DOCKABLE | wxTB_FLAT) toolBar.SetMargins((2, 2))
|
toolBar = self.CreateToolBar(wxNO_BORDER | wxTB_HORIZONTAL | wxTB_FLAT)
|
def __init__(self, parent, id, title, style = wxHF_DEFAULT_STYLE): wxFrame.__init__(self,parent,-4, title, style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)
|
self.m_TitleFormat = ''
|
self.m_HtmlWin = m_HtmlWin self.m_TitleFormat = '%s'
|
def __init__(self, parent, id, title, style = wxHF_DEFAULT_STYLE): wxFrame.__init__(self,parent,-4, title, style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)
|
notebook_page = 0
|
def __init__(self, parent, id, title, style = wxHF_DEFAULT_STYLE): wxFrame.__init__(self,parent,-4, title, style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)
|
|
dummy = wxPanel(m_NavigNotebook, wxID_HTML_INDEXPAGE)
|
panel = wxPanel(m_NavigNotebook, wxID_HTML_INDEXPAGE)
|
def __init__(self, parent, id, title, style = wxHF_DEFAULT_STYLE): wxFrame.__init__(self,parent,-4, title, style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)
|
topsizer.Add(0, 10) dummy.SetAutoLayout(TRUE) dummy.SetSizer(topsizer) if style & wxHF_BOOKMARKS and 0: m_Bookmarks = wxComboBox(dummy, wxID_HTML_BOOKMARKSLIST, '', wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY | wxCB_SORT) m_Bookmarks.Append("(bookmarks)") for i in range(m_BookmarksNames.GetCount()): m_Bookmarks.Append(m_BookmarksNames[i]) m_Bookmarks.SetSelection(0) bmpbt1 = wxBitmapButton(dummy, wxID_HTML_BOOKMARKSADD, wxArtProvider.GetBitmap(wxART_ADD_BOOKMARK, wxART_HELP_BROWSER)) bmpbt2 = wxBitmapButton(dummy, wxID_HTML_BOOKMARKSREMOVE, wxArtProvider.GetBitmap(wxART_DEL_BOOKMARK, wxART_HELP_BROWSER)) bmpbt1.SetToolTipString("Add current page to bookmarks") bmpbt2.SetToolTipString("Remove current page from bookmarks") sizer = wxBoxSizer(wxHORIZONTAL) sizer.Add(m_Bookmarks, 1, wxALIGN_CENTRE_VERTICAL | wxRIGHT, 5) sizer.Add(bmpbt1, 0, wxALIGN_CENTRE_VERTICAL | wxRIGHT, 2) sizer.Add(bmpbt2, 0, wxALIGN_CENTRE_VERTICAL, 0) topsizer.Add(sizer, 0, wxEXPAND | wxLEFT | wxBOTTOM | wxRIGHT, 10) m_ContentsBox = wxTreeCtrl(dummy, wxID_HTML_TREECTRL, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER | wxTR_HAS_BUTTONS | wxTR_HIDE_ROOT | wxTR_LINES_AT_ROOT)
|
panel.SetAutoLayout(TRUE) panel.SetSizer(topsizer) m_ContentsBox = wxTreeCtrl(panel, wxID_HTML_TREECTRL, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER | wxTR_HAS_BUTTONS | wxTR_HIDE_ROOT | wxTR_LINES_AT_ROOT)
|
def __init__(self, parent, id, title, style = wxHF_DEFAULT_STYLE): wxFrame.__init__(self,parent,-4, title, style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)
|
topsizer.Add(m_ContentsBox, 1, wxEXPAND | wxLEFT | wxBOTTOM | wxRIGHT, 2) m_NavigNotebook.AddPage(dummy, "Contents") m_ContentsPage = notebook_page notebook_page += 1
|
topsizer.Add(m_ContentsBox, 1, wxEXPAND | wxALL) m_NavigNotebook.AddPage(panel, "Contents")
|
def __init__(self, parent, id, title, style = wxHF_DEFAULT_STYLE): wxFrame.__init__(self,parent,-4, title, style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)
|
dummy = wxPanel(m_NavigNotebook, wxID_HTML_INDEXPAGE);
|
panel = wxPanel(m_NavigNotebook, wxID_HTML_INDEXPAGE);
|
def __init__(self, parent, id, title, style = wxHF_DEFAULT_STYLE): wxFrame.__init__(self,parent,-4, title, style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)
|
dummy.SetAutoLayout(TRUE) dummy.SetSizer(topsizer) m_IndexText = wxTextCtrl(dummy, wxID_HTML_INDEXTEXT, '', wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER) m_IndexButton = wxButton(dummy, wxID_HTML_INDEXBUTTON, "Find") m_IndexButtonAll = wxButton(dummy, wxID_HTML_INDEXBUTTONALL, "Show all") m_IndexCountInfo = wxStaticText(dummy, wxID_HTML_COUNTINFO, '', wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT | wxST_NO_AUTORESIZE) m_IndexList = wxListBox(dummy, wxID_HTML_INDEXLIST, wxDefaultPosition, wxDefaultSize, style=wxLB_SINGLE) m_IndexButton.SetToolTipString("Display all index items that contain given substring. Search is case insensitive.") m_IndexButtonAll.SetToolTipString("Show all items in index") topsizer.Add(m_IndexText, 0, wxEXPAND | wxALL, 10) btsizer = wxBoxSizer(wxHORIZONTAL) btsizer.Add(m_IndexButton, 0, wxRIGHT, 2) btsizer.Add(m_IndexButtonAll) topsizer.Add(btsizer, 0, wxALIGN_RIGHT | wxLEFT | wxRIGHT | wxBOTTOM, 10) topsizer.Add(m_IndexCountInfo, 0, wxEXPAND | wxLEFT | wxRIGHT, 2) topsizer.Add(m_IndexList, 1, wxEXPAND | wxALL, 2) m_NavigNotebook.AddPage(dummy, "Index") m_IndexPage = notebook_page notebook_page += 1
|
panel.SetAutoLayout(TRUE) panel.SetSizer(topsizer) m_IndexText = wxTextCtrl(panel, wxID_HTML_INDEXTEXT, '', wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER) m_IndexList = wxListBox(panel, wxID_HTML_INDEXLIST, wxDefaultPosition, wxDefaultSize, style=wxLB_SINGLE) topsizer.Add(m_IndexText, 0, wxEXPAND | wxALL) topsizer.Add(m_IndexList, 1, wxEXPAND | wxALL) m_NavigNotebook.AddPage(panel, "Index")
|
def __init__(self, parent, id, title, style = wxHF_DEFAULT_STYLE): wxFrame.__init__(self,parent,-4, title, style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)
|
dummy.SetAutoLayout(TRUE) dummy.SetSizer(sizer) m_SearchText = wxTextCtrl(dummy, wxID_HTML_SEARCHTEXT, '', wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER) m_SearchChoice = wxChoice(dummy, wxID_HTML_SEARCHCHOICE, wxDefaultPosition, wxDefaultSize) m_SearchCaseSensitive = wxCheckBox(dummy, -1, "Case sensitive") m_SearchWholeWords = wxCheckBox(dummy, -1, "Whole words only") m_SearchButton = wxButton(dummy, wxID_HTML_SEARCHBUTTON, "Search") m_SearchButton.SetToolTipString("Search contents of help book(s) for all occurences of the text you typed above") m_SearchList = wxListBox(dummy, wxID_HTML_SEARCHLIST, wxDefaultPosition, wxDefaultSize, style=wxLB_SINGLE)
|
panel.SetAutoLayout(TRUE) panel.SetSizer(sizer) m_SearchText = wxTextCtrl(panel, wxID_HTML_SEARCHTEXT, '', wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER) m_SearchChoice = wxChoice(panel, wxID_HTML_SEARCHCHOICE, wxDefaultPosition, wxDefaultSize) m_SearchCaseSensitive = wxCheckBox(panel, -1, "Case sensitive") m_SearchWholeWords = wxCheckBox(panel, -1, "Whole words only") m_SearchList = wxListBox(panel, wxID_HTML_SEARCHLIST, wxDefaultPosition, wxDefaultSize, style=wxLB_SINGLE)
|
def __init__(self, parent, id, title, style = wxHF_DEFAULT_STYLE): wxFrame.__init__(self,parent,-4, title, style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)
|
sizer.Add(m_SearchText, 0, wxEXPAND | wxALL, 10) sizer.Add(m_SearchChoice, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 10) sizer.Add(m_SearchCaseSensitive, 0, wxLEFT | wxRIGHT, 10) sizer.Add(m_SearchWholeWords, 0, wxLEFT | wxRIGHT, 10) sizer.Add(m_SearchButton, 0, wxALL | wxALIGN_RIGHT, 8) sizer.Add(m_SearchList, 1, wxALL | wxEXPAND, 2) m_NavigNotebook.AddPage(dummy, "Search") m_SearchPage = notebook_page notebook_page += 1
|
sizer.Add(m_SearchText, 0, wxEXPAND | wxALL) sizer.Add(m_SearchChoice, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM) sizer.Add(m_SearchCaseSensitive, 0, wxLEFT | wxRIGHT) sizer.Add(m_SearchWholeWords, 0, wxLEFT | wxRIGHT) sizer.Add(m_SearchList, 1, wxEXPAND | wxALL) m_NavigNotebook.AddPage(panel, "Search") if style & wxHF_BOOKMARKS: panel = wxPanel(m_NavigNotebook, wxID_HTML_INDEXPAGE); topsizer = wxBoxSizer(wxVERTICAL) panel.SetAutoLayout(TRUE) panel.SetSizer(topsizer) m_BookmarksList = wxListBox(panel, wxID_HTML_INDEXLIST, wxDefaultPosition, wxDefaultSize, style=wxLB_SINGLE) topsizer.Add(m_BookmarksList, 1, wxEXPAND | wxALL) m_NavigNotebook.AddPage(panel, "Bookmarks")
|
def __init__(self, parent, id, title, style = wxHF_DEFAULT_STYLE): wxFrame.__init__(self,parent,-4, title, style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)
|
woptionsBitmap = wxArtProvider_GetBitmap(wxART_HELP_SETTINGS, wxART_HELP_BROWSER) assert wpanelBitmap.Ok() and wbackBitmap.Ok() and wforwardBitmap.Ok() and wupnodeBitmap.Ok() and wupBitmap.Ok() and wdownBitmap.Ok() and wopenBitmap.Ok() and wprintBitmap.Ok() and woptionsBitmap.Ok()
|
assert wpanelBitmap.Ok() and wbackBitmap.Ok() and wforwardBitmap.Ok() and wupnodeBitmap.Ok() and wupBitmap.Ok() and wdownBitmap.Ok() and wopenBitmap.Ok() and wprintBitmap.Ok()
|
def AddToolBarButtons(self, toolBar, style): wpanelBitmap = wxArtProvider_GetBitmap(wxART_HELP_SIDE_PANEL, wxART_HELP_BROWSER) wbackBitmap = wxArtProvider_GetBitmap(wxART_GO_BACK, wxART_HELP_BROWSER) wforwardBitmap = wxArtProvider_GetBitmap(wxART_GO_FORWARD, wxART_HELP_BROWSER) wupnodeBitmap = wxArtProvider_GetBitmap(wxART_GO_TO_PARENT, wxART_HELP_BROWSER) wupBitmap = wxArtProvider_GetBitmap(wxART_GO_UP, wxART_HELP_BROWSER) wdownBitmap = wxArtProvider_GetBitmap(wxART_GO_DOWN, wxART_HELP_BROWSER) wopenBitmap = wxArtProvider_GetBitmap(wxART_FILE_OPEN, wxART_HELP_BROWSER) wprintBitmap = wxArtProvider_GetBitmap(wxART_PRINT, wxART_HELP_BROWSER) woptionsBitmap = wxArtProvider_GetBitmap(wxART_HELP_SETTINGS, wxART_HELP_BROWSER)
|
if style & wxHF_PRINT or style & wxHF_OPEN_FILES: toolBar.AddSeparator() if style & wxHF_OPEN_FILES: toolBar.AddSimpleTool(wxID_HTML_OPENFILE, wopenBitmap, "Open HTML document")
|
def AddToolBarButtons(self, toolBar, style): wpanelBitmap = wxArtProvider_GetBitmap(wxART_HELP_SIDE_PANEL, wxART_HELP_BROWSER) wbackBitmap = wxArtProvider_GetBitmap(wxART_GO_BACK, wxART_HELP_BROWSER) wforwardBitmap = wxArtProvider_GetBitmap(wxART_GO_FORWARD, wxART_HELP_BROWSER) wupnodeBitmap = wxArtProvider_GetBitmap(wxART_GO_TO_PARENT, wxART_HELP_BROWSER) wupBitmap = wxArtProvider_GetBitmap(wxART_GO_UP, wxART_HELP_BROWSER) wdownBitmap = wxArtProvider_GetBitmap(wxART_GO_DOWN, wxART_HELP_BROWSER) wopenBitmap = wxArtProvider_GetBitmap(wxART_FILE_OPEN, wxART_HELP_BROWSER) wprintBitmap = wxArtProvider_GetBitmap(wxART_PRINT, wxART_HELP_BROWSER) woptionsBitmap = wxArtProvider_GetBitmap(wxART_HELP_SETTINGS, wxART_HELP_BROWSER)
|
|
toolBar.AddSeparator() toolBar.AddSimpleTool(wxID_HTML_OPTIONS, woptionsBitmap, "Display options dialog")
|
def OnToolbar(self, event): if event.GetId() == wxID_HTML_PANEL: if not (self.m_Splitter and self.m_NavigPan): return if self.m_Splitter.IsSplit(): self.sashpos = self.m_Splitter.GetSashPosition() self.m_Splitter.Unsplit(self.m_NavigPan); else: self.m_NavigPan.Show(TRUE) self.m_HtmlWin.Show(TRUE) self.m_Splitter.SplitVertically(self.m_NavigPan, self.m_HtmlWin, self.sashpos)
|
def AddToolBarButtons(self, toolBar, style): wpanelBitmap = wxArtProvider_GetBitmap(wxART_HELP_SIDE_PANEL, wxART_HELP_BROWSER) wbackBitmap = wxArtProvider_GetBitmap(wxART_GO_BACK, wxART_HELP_BROWSER) wforwardBitmap = wxArtProvider_GetBitmap(wxART_GO_FORWARD, wxART_HELP_BROWSER) wupnodeBitmap = wxArtProvider_GetBitmap(wxART_GO_TO_PARENT, wxART_HELP_BROWSER) wupBitmap = wxArtProvider_GetBitmap(wxART_GO_UP, wxART_HELP_BROWSER) wdownBitmap = wxArtProvider_GetBitmap(wxART_GO_DOWN, wxART_HELP_BROWSER) wopenBitmap = wxArtProvider_GetBitmap(wxART_FILE_OPEN, wxART_HELP_BROWSER) wprintBitmap = wxArtProvider_GetBitmap(wxART_PRINT, wxART_HELP_BROWSER) woptionsBitmap = wxArtProvider_GetBitmap(wxART_HELP_SETTINGS, wxART_HELP_BROWSER)
|
ID_ABOUT=101 ID_OPEN=102 ID_BUTTON1=110 ID_EXIT=200 class MainWindow(wxFrame): def __init__(self,parent,id,title): self.dirname='' wxFrame.__init__(self,parent,-4, title, style=wxDEFAULT_FRAME_STYLE| wxNO_FULL_REPAINT_ON_RESIZE) self.control = wxTextCtrl(self, 1, style=wxTE_MULTILINE) self.CreateStatusBar() filemenu= wxMenu() filemenu.Append(ID_OPEN, "&Open"," Open a file to edit") filemenu.AppendSeparator() filemenu.Append(ID_ABOUT, "&About"," Information about this program") filemenu.AppendSeparator() filemenu.Append(ID_EXIT,"E&xit"," Terminate the program") menuBar = wxMenuBar() menuBar.Append(filemenu,"&File") self.SetMenuBar(menuBar) EVT_MENU(self, ID_ABOUT, self.OnAbout) EVT_MENU(self, ID_EXIT, self.OnExit) EVT_MENU(self, ID_OPEN, self.OnOpen) self.sizer2 = wxBoxSizer(wxHORIZONTAL) self.buttons=[] for i in range(0,6): self.buttons.append(wxButton(self, ID_BUTTON1+i, "Button &"+`i`)) self.sizer2.Add(self.buttons[i],1,wxEXPAND) self.sizer=wxBoxSizer(wxVERTICAL) self.sizer.Add(self.control,1,wxEXPAND) self.sizer.Add(self.sizer2,0,wxEXPAND) self.SetSizer(self.sizer) self.SetAutoLayout(1) self.sizer.Fit(self) self.Show(1) def OnAbout(self,e): d= wxMessageDialog( self, " A sample editor \n" " in wxPython","About Sample Editor", wxOK) d.ShowModal() d.Destroy() def OnExit(self,e): self.Close(true) def OnOpen(self,e): """ Open a file""" dlg = wxFileDialog(self, "Choose a file", self.dirname, "", "*.*", wxOPEN) if dlg.ShowModal() == wxID_OK: self.filename=dlg.GetFilename() self.dirname=dlg.GetDirectory() f=open(os.path.join(self.dirname, self.filename),'r') self.control.SetValue(f.read()) f.close() dlg.Destroy() app = wxPySimpleApp() frame = MyFrame(None, -1, "Sample editor") frame.Show(1) app.MainLoop()
|
if __name__ == "__main__": app = wxPySimpleApp() frame = MyFrame(None, -1, "HTML Help Books") frame.Show(TRUE) app.MainLoop()
|
def AddToolBarButtons(self, toolBar, style): wpanelBitmap = wxArtProvider_GetBitmap(wxART_HELP_SIDE_PANEL, wxART_HELP_BROWSER) wbackBitmap = wxArtProvider_GetBitmap(wxART_GO_BACK, wxART_HELP_BROWSER) wforwardBitmap = wxArtProvider_GetBitmap(wxART_GO_FORWARD, wxART_HELP_BROWSER) wupnodeBitmap = wxArtProvider_GetBitmap(wxART_GO_TO_PARENT, wxART_HELP_BROWSER) wupBitmap = wxArtProvider_GetBitmap(wxART_GO_UP, wxART_HELP_BROWSER) wdownBitmap = wxArtProvider_GetBitmap(wxART_GO_DOWN, wxART_HELP_BROWSER) wopenBitmap = wxArtProvider_GetBitmap(wxART_FILE_OPEN, wxART_HELP_BROWSER) wprintBitmap = wxArtProvider_GetBitmap(wxART_PRINT, wxART_HELP_BROWSER) woptionsBitmap = wxArtProvider_GetBitmap(wxART_HELP_SETTINGS, wxART_HELP_BROWSER)
|
print "hi"
|
def _extract_callback(h, ui, base_path): if ui.path[:1] != '/': return chmlib.CHM_ENUMERATOR_CONTINUE path = os.path.join(base_path, ui.path[1:]) if ui.length != 0: print "--> %s" % ui.path try: fout = open(path, "wb") except IOError: return chmlib.CHM_ENUMERATOR_FAILURE offset = 0L remain = ui.length while remain: buffer = chmlib.chm_retrieve_object(h, ui, offset, 32768) print "hi" if buffer: fout.write(buffer) print len(buffer) print remain assert len(buffer) <= remain offset += len(buffer) remain -= len(buffer) else: sys.stderr.write("incomplete file: %s\n" % ui.path); else: if rmkdir(path) == -1: return chmlib.CHM_ENUMERATOR_FAILURE return chmlib.CHM_ENUMERATOR_CONTINUE
|
|
print "%d: seek(%d, %d)" % (self.n, offset, whence)
|
if 0: print "%d: seek(%d, %d)" % (self.n, offset, whence)
|
def seek(self, offset, whence): if self.n == 0 and whence == 0: whence = 2 elif whence < 0: whence = 1 self.n += 1
|
class MyFileSystemHandler(wxFileSystemHandler):
|
class BookFileSystemHandler(wxFileSystemHandler):
|
def seek(self, offset, whence): if self.n == 0 and whence == 0: whence = 2 elif whence < 0: whence = 1 self.n += 1
|
return self.GetProtocol(location) == 'hh'
|
return self.GetProtocol(location) == 'book'
|
def CanOpen(self, location): return self.GetProtocol(location) == 'hh'
|
print name, link
|
def OpenFile(self, fs, location): if 0: name = self.GetLeftLocation(location) link = self.GetRightLocation(location) else: link = self.GetRightLocation(location) words = filter(None, link.split('/')) name = words[0] link = '/'.join(words[1:]) print name, link book = book_factory.book(name) anchor = self.GetAnchor(location) mimetype = self.GetMimeTypeFromExt(location) f = book.page(link) stream = wxInputStream(file_wrapper(f)) print location, mimetype, anchor return wxFSFile(stream, location, mimetype, anchor, wxDateTime_Now())
|
|
f = book.page(link) stream = wxInputStream(file_wrapper(f)) print location, mimetype, anchor
|
stream = wxInputStream(file_wrapper(book.get(link)))
|
def OpenFile(self, fs, location): if 0: name = self.GetLeftLocation(location) link = self.GetRightLocation(location) else: link = self.GetRightLocation(location) words = filter(None, link.split('/')) name = words[0] link = '/'.join(words[1:]) print name, link book = book_factory.book(name) anchor = self.GetAnchor(location) mimetype = self.GetMimeTypeFromExt(location) f = book.page(link) stream = wxInputStream(file_wrapper(f)) print location, mimetype, anchor return wxFSFile(stream, location, mimetype, anchor, wxDateTime_Now())
|
wxFileSystem_AddHandler(MyFileSystemHandler()) wxHF_TOOLBAR = 0x0001 wxHF_CONTENTS = 0x0002 wxHF_INDEX = 0x0004 wxHF_SEARCH = 0x0008 wxHF_BOOKMARKS = 0x0010 wxHF_PRINT = 0x0040 wxHF_FLAT_TOOLBAR = 0x0080 wxHF_MERGE_BOOKS = 0x0100 wxHF_ICONS_BOOK = 0x0200 wxHF_ICONS_BOOK_CHAPTER = 0x0400 wxHF_ICONS_FOLDER = 0x0000 wxHF_DEFAULT_STYLE = (wxHF_TOOLBAR | wxHF_CONTENTS | wxHF_INDEX | wxHF_SEARCH | wxHF_BOOKMARKS | wxHF_PRINT) wxID_HIGHEST = 100 wxID_HTML_PANEL = wxID_HIGHEST + 2 wxID_HTML_BACK = wxID_HIGHEST + 3 wxID_HTML_FORWARD = wxID_HIGHEST + 4 wxID_HTML_UPNODE = wxID_HIGHEST + 5 wxID_HTML_UP = wxID_HIGHEST + 6 wxID_HTML_DOWN = wxID_HIGHEST + 7 wxID_HTML_PRINT = wxID_HIGHEST + 8 wxID_HTML_OPENFILE = wxID_HIGHEST + 9 wxID_HTML_OPTIONS = wxID_HIGHEST + 10 wxID_HTML_BOOKMARKSLIST = wxID_HIGHEST + 11 wxID_HTML_BOOKMARKSADD = wxID_HIGHEST + 12 wxID_HTML_BOOKMARKSREMOVE = wxID_HIGHEST + 13 wxID_HTML_TREECTRL = wxID_HIGHEST + 14 wxID_HTML_INDEXPAGE = wxID_HIGHEST + 15 wxID_HTML_INDEXLIST = wxID_HIGHEST + 16 wxID_HTML_INDEXTEXT = wxID_HIGHEST + 17 wxID_HTML_INDEXBUTTON = wxID_HIGHEST + 18 wxID_HTML_INDEXBUTTONALL = wxID_HIGHEST + 19 wxID_HTML_NOTEBOOK = wxID_HIGHEST + 20 wxID_HTML_SEARCHPAGE = wxID_HIGHEST + 21 wxID_HTML_SEARCHTEXT = wxID_HIGHEST + 22 wxID_HTML_SEARCHLIST = wxID_HIGHEST + 23 wxID_HTML_SEARCHBUTTON = wxID_HIGHEST + 24 wxID_HTML_SEARCHCHOICE = wxID_HIGHEST + 25 wxID_HTML_COUNTINFO = wxID_HIGHEST + 26 class MyHtmlHelpHtmlWindow(wxHtmlWindow):
|
wxFileSystem_AddHandler(BookFileSystemHandler()) style_TOOLBAR = 0x0001 style_CONTENTS = 0x0002 style_INDEX = 0x0004 style_SEARCH = 0x0008 style_BOOKMARKS = 0x0010 style_OPEN_FILES = 0x0020 style_PRINT = 0x0040 style_FLAT_TOOLBAR = 0x0080 style_MERGE_BOOKS = 0x0100 style_ICONS_BOOK = 0x0200 style_ICONS_BOOK_CHAPTER= 0x0400 style_ICONS_FOLDER = 0x0000 style_DEFAULT_STYLE = (style_TOOLBAR | style_CONTENTS | style_INDEX | style_SEARCH | style_BOOKMARKS | style_PRINT) id_PANEL = 1002 id_BACK = 1003 id_FORWARD = 1004 id_UPNODE = 1005 id_UP = 1006 id_DOWN = 1007 id_PRINT = 1008 id_OPENFILE = 1009 id_OPTIONS = 1010 id_BOOKMARKSLIST = 1011 id_BOOKMARKSADD = 1012 id_BOOKMARKSREMOVE = 1013 id_TREECTRL = 1014 id_INDEXPAGE = 1015 id_INDEXLIST = 1016 id_INDEXTEXT = 1017 id_INDEXBUTTON = 1018 id_INDEXBUTTONALL = 1019 id_NOTEBOOK = 1020 id_SEARCHPAGE = 1021 id_SEARCHTEXT = 1022 id_SEARCHLIST = 1023 id_SEARCHBUTTON = 1024 id_SEARCHCHOICE = 1025 id_COUNTINFO = 1026 class MyHtmlWindow(wxHtmlWindow):
|
def OpenFile(self, fs, location): if 0: name = self.GetLeftLocation(location) link = self.GetRightLocation(location) else: link = self.GetRightLocation(location) words = filter(None, link.split('/')) name = words[0] link = '/'.join(words[1:]) print name, link book = book_factory.book(name) anchor = self.GetAnchor(location) mimetype = self.GetMimeTypeFromExt(location) f = book.page(link) stream = wxInputStream(file_wrapper(f)) print location, mimetype, anchor return wxFSFile(stream, location, mimetype, anchor, wxDateTime_Now())
|
self.m_Frame = frame class MyFrame(wxFrame): def __init__(self, parent, id, title, style = wxHF_DEFAULT_STYLE): wxFrame.__init__(self,parent,-4, title, style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)
|
self.frame = frame def OnLinkClicked(self, link): self.frame.NotifyPageChanged() class BookFrame(wxFrame): def __init__(self, parent, id, title, style = style_DEFAULT_STYLE): wxFrame.__init__(self, parent, -4, title, style = wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE)
|
def __init__(self, frame, parent): wxHtmlWindow.__init__(self, parent) self.m_Frame = frame
|
toolBar = self.CreateToolBar(wxNO_BORDER | wxTB_HORIZONTAL | wxTB_FLAT) self.AddToolBarButtons(toolBar, style) toolBar.Realize() EVT_TOOL_RANGE(self, wxID_HTML_PANEL, wxID_HTML_OPTIONS, self.OnToolbar) if style & (wxHF_CONTENTS | wxHF_INDEX | wxHF_SEARCH):
|
if style & style_TOOLBAR: self.toolBar = self.CreateToolBar(wxNO_BORDER | wxTB_HORIZONTAL | wxTB_FLAT) self.toolBar.AddSimpleTool( id_PANEL, wxArtProvider_GetBitmap(wxART_HELP_SIDE_PANEL, wxART_HELP_BROWSER), "Show/hide navigation panel") self.toolBar.AddSeparator() self.toolBar.AddSimpleTool( id_BACK, wxArtProvider_GetBitmap(wxART_GO_BACK, wxART_HELP_BROWSER), "Go back") self.toolBar.AddSimpleTool( id_FORWARD, wxArtProvider_GetBitmap(wxART_GO_FORWARD, wxART_HELP_BROWSER), "Go forward") self.toolBar.AddSeparator() self.toolBar.AddSimpleTool( id_UPNODE, wxArtProvider_GetBitmap(wxART_GO_TO_PARENT, wxART_HELP_BROWSER), "Go one level up in document hierarchy") self.toolBar.AddSimpleTool( id_UP, wxArtProvider_GetBitmap(wxART_GO_UP, wxART_HELP_BROWSER), "Previous page") self.toolBar.AddSimpleTool( id_DOWN, wxArtProvider_GetBitmap(wxART_GO_DOWN, wxART_HELP_BROWSER), "Next page") if style & style_OPEN_FILES: self.toolBar.AddTool( id_OPENFILE, wxArtProvider_GetBitmap(wxART_FILE_OPEN, wxART_HELP_BROWSER), "Open HTML document") if style & style_PRINT: self.toolBar.AddSimpleTool( id_PRINT, wxArtProvider_GetBitmap(wxART_PRINT, wxART_HELP_BROWSER), "Print this page") self.toolBar.Realize() EVT_TOOL_RANGE(self, id_PANEL, id_OPTIONS, self.OnToolbar) if style & (style_CONTENTS | style_INDEX | style_SEARCH):
|
def __init__(self, parent, id, title, style = wxHF_DEFAULT_STYLE): wxFrame.__init__(self,parent,-4, title, style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)
|
m_Splitter = wxSplitterWindow(self, -1) self.m_Splitter = m_Splitter m_HtmlWin = MyHtmlHelpHtmlWindow(self, m_Splitter) m_NavigPan = wxPanel(m_Splitter, -1) self.m_NavigPan = m_NavigPan m_NavigNotebook = wxNotebook(m_NavigPan, wxID_HTML_NOTEBOOK, wxDefaultPosition, wxDefaultSize) nbs = wxNotebookSizer(m_NavigNotebook)
|
self.splitter = wxSplitterWindow(self, -1) self.htmlWindow = MyHtmlWindow(self, self.splitter) self.navigationPanel = wxPanel(self.splitter, -1) self.navigationNotebook = wxNotebook(self.navigationPanel, id_NOTEBOOK, wxDefaultPosition, wxDefaultSize) navigationNotebookSizer = wxNotebookSizer(self.navigationNotebook)
|
def __init__(self, parent, id, title, style = wxHF_DEFAULT_STYLE): wxFrame.__init__(self,parent,-4, title, style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)
|
navigSizer = wxBoxSizer(wxVERTICAL) navigSizer.Add(nbs, 1, wxEXPAND) m_NavigPan.SetAutoLayout(TRUE) m_NavigPan.SetSizer(navigSizer)
|
navigationSizer = wxBoxSizer(wxVERTICAL) navigationSizer.Add(navigationNotebookSizer, 1, wxEXPAND) self.navigationPanel.SetAutoLayout(TRUE) self.navigationPanel.SetSizer(navigationSizer)
|
def __init__(self, parent, id, title, style = wxHF_DEFAULT_STYLE): wxFrame.__init__(self,parent,-4, title, style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)
|
m_HtmlWin = wxHtmlWindow(self) self.m_HtmlWin = m_HtmlWin self.m_TitleFormat = '%s' m_HtmlWin.SetRelatedFrame(self, self.m_TitleFormat) m_HtmlWin.SetRelatedStatusBar(0) if style & wxHF_CONTENTS: panel = wxPanel(m_NavigNotebook, wxID_HTML_INDEXPAGE) topsizer = wxBoxSizer(wxVERTICAL)
|
self.htmlWindow = wxHtmlWindow(self) self.titleFormat = '%s' self.htmlWindow.SetRelatedFrame(self, self.titleFormat) self.htmlWindow.SetRelatedStatusBar(0) if style & style_CONTENTS: contentsPage = wxPanel(self.navigationNotebook, id_INDEXPAGE) contentsSizer = wxBoxSizer(wxVERTICAL)
|
def __init__(self, parent, id, title, style = wxHF_DEFAULT_STYLE): wxFrame.__init__(self,parent,-4, title, style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)
|
panel.SetAutoLayout(TRUE) panel.SetSizer(topsizer) m_ContentsBox = wxTreeCtrl(panel, wxID_HTML_TREECTRL, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER | wxTR_HAS_BUTTONS | wxTR_HIDE_ROOT | wxTR_LINES_AT_ROOT) self.m_ContentsBox = m_ContentsBox EVT_TREE_SEL_CHANGED(self, wxID_HTML_TREECTRL, self.OnContentsSel)
|
contentsPage.SetAutoLayout(TRUE) contentsPage.SetSizer(contentsSizer) self.contentsTree = wxTreeCtrl( contentsPage, id_TREECTRL, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER | wxTR_HAS_BUTTONS | wxTR_HIDE_ROOT | wxTR_LINES_AT_ROOT)
|
def __init__(self, parent, id, title, style = wxHF_DEFAULT_STYLE): wxFrame.__init__(self,parent,-4, title, style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)
|
topsizer.Add(m_ContentsBox, 1, wxEXPAND | wxALL) m_NavigNotebook.AddPage(panel, "Contents") if style & wxHF_INDEX: panel = wxPanel(m_NavigNotebook, wxID_HTML_INDEXPAGE); topsizer = wxBoxSizer(wxVERTICAL) panel.SetAutoLayout(TRUE) panel.SetSizer(topsizer) m_IndexText = wxTextCtrl(panel, wxID_HTML_INDEXTEXT, '', wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER) m_IndexList = wxListBox(panel, wxID_HTML_INDEXLIST, wxDefaultPosition, wxDefaultSize, style=wxLB_SINGLE) topsizer.Add(m_IndexText, 0, wxEXPAND | wxALL) topsizer.Add(m_IndexList, 1, wxEXPAND | wxALL) m_NavigNotebook.AddPage(panel, "Index") if style & wxHF_SEARCH: panel = wxPanel(m_NavigNotebook, wxID_HTML_INDEXPAGE); sizer = wxBoxSizer(wxVERTICAL) panel.SetAutoLayout(TRUE) panel.SetSizer(sizer) m_SearchText = wxTextCtrl(panel, wxID_HTML_SEARCHTEXT, '', wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER) m_SearchChoice = wxChoice(panel, wxID_HTML_SEARCHCHOICE, wxDefaultPosition, wxDefaultSize) m_SearchCaseSensitive = wxCheckBox(panel, -1, "Case sensitive") m_SearchWholeWords = wxCheckBox(panel, -1, "Whole words only") m_SearchList = wxListBox(panel, wxID_HTML_SEARCHLIST, wxDefaultPosition, wxDefaultSize, style=wxLB_SINGLE)
|
EVT_TREE_SEL_CHANGED(self, id_TREECTRL, self.OnContentsSel) contentsSizer.Add(self.contentsTree, 1, wxEXPAND | wxALL) self.navigationNotebook.AddPage(contentsPage, "Contents") if style & style_INDEX: indexPage = wxPanel(self.navigationNotebook, id_INDEXPAGE); indexSizer = wxBoxSizer(wxVERTICAL) indexPage.SetAutoLayout(TRUE) indexPage.SetSizer(indexSizer) self.indexText = wxTextCtrl( indexPage, id_INDEXTEXT, '', wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER) self.indexList = wxListBox( indexPage, id_INDEXLIST, wxDefaultPosition, wxDefaultSize, style = wxLB_SINGLE) indexSizer.Add(self.indexText, 0, wxEXPAND | wxALL) indexSizer.Add(self.indexList, 1, wxEXPAND | wxALL) self.navigationNotebook.AddPage(indexPage, "Index") if style & style_SEARCH: searchPage = wxPanel(self.navigationNotebook, id_INDEXPAGE); searchSizer = wxBoxSizer(wxVERTICAL) searchPage.SetAutoLayout(TRUE) searchPage.SetSizer(searchSizer) self.searchText = wxTextCtrl(searchPage, id_SEARCHTEXT, '', wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER) self.searchChoice = wxChoice(searchPage, id_SEARCHCHOICE, wxDefaultPosition, wxDefaultSize) self.searchCaseSensitive = wxCheckBox(searchPage, -1, "Case sensitive") self.searchWholeWords = wxCheckBox(searchPage, -1, "Whole words only") self.searchList = wxListBox(searchPage, id_SEARCHLIST, wxDefaultPosition, wxDefaultSize, style=wxLB_SINGLE)
|
def __init__(self, parent, id, title, style = wxHF_DEFAULT_STYLE): wxFrame.__init__(self,parent,-4, title, style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)
|
sizer.Add(m_SearchText, 0, wxEXPAND | wxALL) sizer.Add(m_SearchChoice, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM) sizer.Add(m_SearchCaseSensitive, 0, wxLEFT | wxRIGHT) sizer.Add(m_SearchWholeWords, 0, wxLEFT | wxRIGHT) sizer.Add(m_SearchList, 1, wxEXPAND | wxALL) m_NavigNotebook.AddPage(panel, "Search") if style & wxHF_BOOKMARKS: panel = wxPanel(m_NavigNotebook, wxID_HTML_INDEXPAGE); topsizer = wxBoxSizer(wxVERTICAL) panel.SetAutoLayout(TRUE) panel.SetSizer(topsizer) m_BookmarksList = wxListBox(panel, wxID_HTML_INDEXLIST, wxDefaultPosition, wxDefaultSize, style=wxLB_SINGLE) topsizer.Add(m_BookmarksList, 1, wxEXPAND | wxALL) m_NavigNotebook.AddPage(panel, "Bookmarks") m_HtmlWin.Show(TRUE)
|
searchSizer.Add(self.searchText, 0, wxEXPAND | wxALL) searchSizer.Add(self.searchChoice, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM) searchSizer.Add(self.searchCaseSensitive, 0, wxLEFT | wxRIGHT) searchSizer.Add(self.searchWholeWords, 0, wxLEFT | wxRIGHT) searchSizer.Add(self.searchList, 1, wxEXPAND | wxALL) self.navigationNotebook.AddPage(searchPage, "Search") if style & style_BOOKMARKS: bookmarksPage = wxPanel(self.navigationNotebook, id_INDEXPAGE); bookmarksSizer = wxBoxSizer(wxVERTICAL) bookmarksPage.SetAutoLayout(TRUE) bookmarksPage.SetSizer(bookmarksSizer) self.bookmarksList = wxListBox(bookmarksPage, id_INDEXLIST, wxDefaultPosition, wxDefaultSize, style=wxLB_SINGLE) bookmarksSizer.Add(self.bookmarksList, 1, wxEXPAND | wxALL) self.navigationNotebook.AddPage(bookmarksPage, "Bookmarks") self.htmlWindow.Show(TRUE)
|
def __init__(self, parent, id, title, style = wxHF_DEFAULT_STYLE): wxFrame.__init__(self,parent,-4, title, style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)
|
if navigSizer: navigSizer.SetSizeHints(m_NavigPan) m_NavigPan.Layout() class Cfg: pass m_Cfg = Cfg() m_Cfg.navig_on = 1 m_Cfg.sashpos = 250
|
if navigationSizer: navigationSizer.SetSizeHints(self.navigationPanel) self.navigationPanel.Layout() self.navigation = 1 self.sashpos = 250
|
def __init__(self, parent, id, title, style = wxHF_DEFAULT_STYLE): wxFrame.__init__(self,parent,-4, title, style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)
|
if m_NavigPan and m_Splitter: m_Splitter.SetMinimumPaneSize(20) if m_Cfg.navig_on: m_Splitter.SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos) if m_Cfg.navig_on: m_NavigPan.Show(TRUE) m_Splitter.SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos)
|
if self.navigationPanel and self.splitter: self.splitter.SetMinimumPaneSize(20) if self.navigation: self.splitter.SplitVertically(self.navigationPanel, self.htmlWindow, self.sashpos) if self.navigation: self.navigationPanel.Show(TRUE) self.splitter.SplitVertically(self.navigationPanel, self.htmlWindow, self.sashpos)
|
def __init__(self, parent, id, title, style = wxHF_DEFAULT_STYLE): wxFrame.__init__(self,parent,-4, title, style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)
|
m_NavigPan.Show(FALSE) m_Splitter.Initialize(m_HtmlWin)
|
self.navigationPanel.Show(FALSE) self.splitter.Initialize(htmlWindow)
|
def __init__(self, parent, id, title, style = wxHF_DEFAULT_STYLE): wxFrame.__init__(self,parent,-4, title, style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)
|
def AddToolBarButtons(self, toolBar, style): wpanelBitmap = wxArtProvider_GetBitmap(wxART_HELP_SIDE_PANEL, wxART_HELP_BROWSER) wbackBitmap = wxArtProvider_GetBitmap(wxART_GO_BACK, wxART_HELP_BROWSER) wforwardBitmap = wxArtProvider_GetBitmap(wxART_GO_FORWARD, wxART_HELP_BROWSER) wupnodeBitmap = wxArtProvider_GetBitmap(wxART_GO_TO_PARENT, wxART_HELP_BROWSER) wupBitmap = wxArtProvider_GetBitmap(wxART_GO_UP, wxART_HELP_BROWSER) wdownBitmap = wxArtProvider_GetBitmap(wxART_GO_DOWN, wxART_HELP_BROWSER) wopenBitmap = wxArtProvider_GetBitmap(wxART_FILE_OPEN, wxART_HELP_BROWSER) wprintBitmap = wxArtProvider_GetBitmap(wxART_PRINT, wxART_HELP_BROWSER) assert wpanelBitmap.Ok() and wbackBitmap.Ok() and wforwardBitmap.Ok() and wupnodeBitmap.Ok() and wupBitmap.Ok() and wdownBitmap.Ok() and wopenBitmap.Ok() and wprintBitmap.Ok() toolBar.AddSimpleTool(wxID_HTML_PANEL, wpanelBitmap, "Show/hide navigation panel") toolBar.AddSeparator() toolBar.AddSimpleTool(wxID_HTML_BACK, wbackBitmap, "Go back") toolBar.AddSimpleTool(wxID_HTML_FORWARD, wforwardBitmap, "Go forward") toolBar.AddSeparator() toolBar.AddSimpleTool(wxID_HTML_UPNODE, wupnodeBitmap, "Go one level up in document hierarchy") toolBar.AddSimpleTool(wxID_HTML_UP, wupBitmap, "Previous page") toolBar.AddSimpleTool(wxID_HTML_DOWN, wdownBitmap, "Next page") if style & wxHF_PRINT: toolBar.AddSimpleTool(wxID_HTML_PRINT, wprintBitmap, "Print this page")
|
def AddToolBarButtons(self, toolBar, style): wpanelBitmap = wxArtProvider_GetBitmap(wxART_HELP_SIDE_PANEL, wxART_HELP_BROWSER) wbackBitmap = wxArtProvider_GetBitmap(wxART_GO_BACK, wxART_HELP_BROWSER) wforwardBitmap = wxArtProvider_GetBitmap(wxART_GO_FORWARD, wxART_HELP_BROWSER) wupnodeBitmap = wxArtProvider_GetBitmap(wxART_GO_TO_PARENT, wxART_HELP_BROWSER) wupBitmap = wxArtProvider_GetBitmap(wxART_GO_UP, wxART_HELP_BROWSER) wdownBitmap = wxArtProvider_GetBitmap(wxART_GO_DOWN, wxART_HELP_BROWSER) wopenBitmap = wxArtProvider_GetBitmap(wxART_FILE_OPEN, wxART_HELP_BROWSER) wprintBitmap = wxArtProvider_GetBitmap(wxART_PRINT, wxART_HELP_BROWSER)
|
|
root = self.m_ContentsBox.AddRoot("Books")
|
root = self.contentsTree.AddRoot("Books")
|
def AddBooks(self): root = self.m_ContentsBox.AddRoot("Books") for name in book_factory.enumerate(): book = book_factory.book(name) book.name = name self.AddBook(root, book)
|
child = self.m_ContentsBox.AppendItem(node, book.title()) self.m_ContentsBox.SetPyData(child, (book, book.link())) contents = book.contents() self.AddContents(child, book, contents) def AddContents(self, node, book, contents): for entry in contents:
|
child = self.contentsTree.AppendItem(node, book.title) self.contentsTree.SetPyData(child, (book, book.default)) self.AddContents(child, book, book.contents) def AddContents(self, tree_node, book, toc_node): for toc_child in toc_node.childs:
|
def AddBook(self, node, book): child = self.m_ContentsBox.AppendItem(node, book.title()) self.m_ContentsBox.SetPyData(child, (book, book.link())) contents = book.contents() self.AddContents(child, book, contents)
|
child = self.m_ContentsBox.AppendItem(node, entry.title())
|
name = toc_child.name
|
def AddContents(self, node, book, contents): for entry in contents: if wxUSE_UNICODE: child = self.m_ContentsBox.AppendItem(node, entry.title()) else: child = self.m_ContentsBox.AppendItem(node, entry.title().encode('iso-8859-1', 'replace')) self.m_ContentsBox.SetPyData(child, (book, entry.link())) self.AddContents(child, book, entry.childs())
|
child = self.m_ContentsBox.AppendItem(node, entry.title().encode('iso-8859-1', 'replace')) self.m_ContentsBox.SetPyData(child, (book, entry.link())) self.AddContents(child, book, entry.childs())
|
name = toc_child.name.encode('iso-8859-1', 'replace') tree_child = self.contentsTree.AppendItem(tree_node, name) self.contentsTree.SetPyData(tree_child, (book, toc_child.link)) self.AddContents(tree_child, book, toc_child) def AddIndex(self, book, index): for entry in index: if wxUSE_UNICODE: term = entry.term else: term = entry.term.encode('iso-8859-1', 'replace') self.indexList.Append(term)
|
def AddContents(self, node, book, contents): for entry in contents: if wxUSE_UNICODE: child = self.m_ContentsBox.AppendItem(node, entry.title()) else: child = self.m_ContentsBox.AppendItem(node, entry.title().encode('iso-8859-1', 'replace')) self.m_ContentsBox.SetPyData(child, (book, entry.link())) self.AddContents(child, book, entry.childs())
|
return 'hh:/%s/%s' % (book.name, link)
|
return 'book:/%s/%s' % (book.name, link)
|
def Location(self, book, link): return 'hh:/%s/%s' % (book.name, link)
|
(book, link) = self.m_ContentsBox.GetPyData(item)
|
(book, link) = self.contentsTree.GetPyData(item)
|
def OnContentsSel(self, event): item = event.GetItem() (book, link) = self.m_ContentsBox.GetPyData(item) if 0: html = book.page(link).read() self.m_HtmlWin.SetPage(html) else: location = self.Location(book, link) print location self.m_HtmlWin.LoadPage(location)
|
html = book.page(link).read() self.m_HtmlWin.SetPage(html)
|
html = book.get(link).read() self.htmlWindow.SetPage(html)
|
def OnContentsSel(self, event): item = event.GetItem() (book, link) = self.m_ContentsBox.GetPyData(item) if 0: html = book.page(link).read() self.m_HtmlWin.SetPage(html) else: location = self.Location(book, link) print location self.m_HtmlWin.LoadPage(location)
|
print location self.m_HtmlWin.LoadPage(location)
|
self.htmlWindow.LoadPage(location)
|
def OnContentsSel(self, event): item = event.GetItem() (book, link) = self.m_ContentsBox.GetPyData(item) if 0: html = book.page(link).read() self.m_HtmlWin.SetPage(html) else: location = self.Location(book, link) print location self.m_HtmlWin.LoadPage(location)
|
if event.GetId() == wxID_HTML_PANEL: if not (self.m_Splitter and self.m_NavigPan):
|
if event.GetId() == id_PANEL: if not (self.splitter and self.navigationPanel):
|
def OnToolbar(self, event): if event.GetId() == wxID_HTML_PANEL: if not (self.m_Splitter and self.m_NavigPan): return if self.m_Splitter.IsSplit(): self.sashpos = self.m_Splitter.GetSashPosition() self.m_Splitter.Unsplit(self.m_NavigPan); #m_Cfg.navig_on = FALSE else: self.m_NavigPan.Show(TRUE) self.m_HtmlWin.Show(TRUE) self.m_Splitter.SplitVertically(self.m_NavigPan, self.m_HtmlWin, self.sashpos) #m_Cfg.navig_on = TRUE
|
if self.m_Splitter.IsSplit(): self.sashpos = self.m_Splitter.GetSashPosition() self.m_Splitter.Unsplit(self.m_NavigPan);
|
if self.splitter.IsSplit(): self.sashpos = self.splitter.GetSashPosition() self.splitter.Unsplit(self.navigationPanel); self.navigation = 1
|
def OnToolbar(self, event): if event.GetId() == wxID_HTML_PANEL: if not (self.m_Splitter and self.m_NavigPan): return if self.m_Splitter.IsSplit(): self.sashpos = self.m_Splitter.GetSashPosition() self.m_Splitter.Unsplit(self.m_NavigPan); #m_Cfg.navig_on = FALSE else: self.m_NavigPan.Show(TRUE) self.m_HtmlWin.Show(TRUE) self.m_Splitter.SplitVertically(self.m_NavigPan, self.m_HtmlWin, self.sashpos) #m_Cfg.navig_on = TRUE
|
self.m_NavigPan.Show(TRUE) self.m_HtmlWin.Show(TRUE) self.m_Splitter.SplitVertically(self.m_NavigPan, self.m_HtmlWin, self.sashpos)
|
self.navigationPanel.Show(TRUE) self.htmlWindow.Show(TRUE) self.splitter.SplitVertically(self.navigationPanel, self.htmlWindow, self.sashpos) self.navigation = 1 def NotifyPageChanged(self): pass
|
def OnToolbar(self, event): if event.GetId() == wxID_HTML_PANEL: if not (self.m_Splitter and self.m_NavigPan): return if self.m_Splitter.IsSplit(): self.sashpos = self.m_Splitter.GetSashPosition() self.m_Splitter.Unsplit(self.m_NavigPan); #m_Cfg.navig_on = FALSE else: self.m_NavigPan.Show(TRUE) self.m_HtmlWin.Show(TRUE) self.m_Splitter.SplitVertically(self.m_NavigPan, self.m_HtmlWin, self.sashpos) #m_Cfg.navig_on = TRUE
|
frame = MyFrame(None, -1, "HTML Help Books")
|
frame = BookFrame(None, -1, "HTML Help Books")
|
def main(): app = wxPySimpleApp() frame = MyFrame(None, -1, "HTML Help Books") frame.Show(TRUE) app.MainLoop()
|
parser = HHCParser(self)
|
parser = HHCParser(self.book)
|
def handle_entry(self, code, data): if code == 0: parser = HHCParser(self) parser.parse(self.book.archive[data]) elif code == 1: parser = HHKParser(self) parser.parse(self.book.archive[data]) elif code == 2: self.book.contents.link = data elif code == 3: self.book.contents.name = data
|
parser = HHKParser(self)
|
parser = HHKParser(self.book)
|
def handle_entry(self, code, data): if code == 0: parser = HHCParser(self) parser.parse(self.book.archive[data]) elif code == 1: parser = HHKParser(self) parser.parse(self.book.archive[data]) elif code == 2: self.book.contents.link = data elif code == 3: self.book.contents.name = data
|
logger.info(value) logger.info(self.format)
|
def convertFromCode(self, value, item=None): if value=='now': return DateTime.now() elif not value: return else: logger.info(value) logger.info(self.format) # DateTime.strptime is not available on Windows return DateTime.DateTime(*time.strptime(value, self.format)[:6])
|
|
full_name = self._child_name(name, subname)
|
full_name = self._child_name(formname, subname)
|
def show(self, item, name, template_type, template_getter, global_namespace={}): value = getattr(item, name) subfields = [] for subname, field_type in self.fields: full_name = self._child_name(name, subname) proxied_item = self._Proxy(item, {full_name: value[subname]}) subfields.append(field_type.show(proxied_item, full_name, template_type, template_getter, global_namespace)) namespace = global_namespace.copy() namespace['subfields'] = subfields return FieldType.show(self, item, name, template_type, template_getter, namespace)
|
self.__config = config
|
self._config = config
|
def __init__(self, config): self.__config = config
|
return repr(self.__config)
|
return repr(self._config)
|
def __repr__(self): return repr(self.__config)
|
return iter(self.__config)
|
return iter(self._config)
|
def __iter__(self): return iter(self.__config)
|
return self.__config_dict[name]
|
return self._config_dict[name] def iteritems(self): return iter(self._config)
|
def __getitem__(self, name): return self.__config_dict[name]
|
return self.__config_dict.iterkeys() def iteritems(self): return self.__config_dict.iteritems() def __config_dict(self): return dict(self.__config) __config_dict = qUtils.CachedAttribute(__config_dict)
|
for fn, ft in self: yield fn def items(self): return self._config[:] def keys(self): return [fn for fn, ft in self] def _config_dict(self): return dict(self._config) _config_dict = qUtils.CachedAttribute(_config_dict)
|
def iterkeys(self): return self.__config_dict.iterkeys()
|
[(fn, ft) for fn, ft in self.__config if hasattr(ft, 'store')])
|
[(fn, ft) for fn, ft in self._config if hasattr(ft, 'store')])
|
def external(self): return FieldDescriptions( [(fn, ft) for fn, ft in self.__config if hasattr(ft, 'store')])
|
[(fn, ft) for fn, ft in self.__config if not hasattr(ft, 'store')])
|
[(fn, ft) for fn, ft in self._config if not hasattr(ft, 'store')])
|
def main(self): return FieldDescriptions( [(fn, ft) for fn, ft in self.__config if not hasattr(ft, 'store')])
|
query = Query("%s=" % name, Param(value))
|
query = Query("%s=" % name, Param(self.convertToDB(value, item)))
|
def convertFromForm(self, form, name, item=None): value = STRING.convertFromForm(self, form, name, item)
|
dbFalse - database value of False (default 0)"""
|
dbFalse - database value of False (default 0) bool(dbTrue) must be True and bool(dbFalse) must be False"""
|
def getIndexLabel(self, value): views = [FOREIGN_DROP.getLabel(self, i) for i in value] return ', '.join(views)
|
from FieldTypes import IMAGE
|
from qFieldTypes import IMAGE
|
def do_delete(self, item): from FieldTypes import IMAGE from glob import glob for field_name, field_type in item.stream.itemExtFields.items(): if isinstance(field_type, IMAGE): image = getattr(item, field_name) for old_path in glob(image.pattern+'.*'): os.remove(old_path)
|
from FieldTypes import IMAGE
|
from qFieldTypes import IMAGE
|
def do_make(self, item): from FieldTypes import IMAGE from glob import glob for field_name, field_type in item.stream.itemExtFields.items(): if isinstance(field_type, IMAGE): image = getattr(item, field_name) if image: fp = self.writer.getFP(image.path) fp.write(open(field_type.editRoot+image.path).read()) fp.close() else: path = None for old_path in glob(image.pattern+'.*'): if old_path!=path: os.remove(old_path)
|
stream = self._retrieve_stream(item)
|
stream = self.itemField._retrieve_stream(item)
|
def convertFromForm(self, form, name, item): value = form.getlist(name) stream = self._retrieve_stream(item) return self.convertFromCode( [stream.fields.id.convertFromString(id, item) \ for id in value], item)
|
def parseaddr(addr): ''' decode header to unicode and aprse it '''
|
def getaddr(addr): ''' extract address from encoded header '''
|
def parseaddr(addr): ''' decode header to unicode and aprse it ''' uni_addr = [] for chunk, charset in email.Header.decode_header(addr): if charset: uni_addr += unicode(chunk, charset) else: uni_addr += chunk uni_addr = u''.join(uni_addr) return email.Utils.parseaddr(uni_addr)
|
return email.Utils.parseaddr(uni_addr)
|
return email.Utils.parseaddr(uni_addr)[1].encode('us-ascii')
|
def parseaddr(addr): ''' decode header to unicode and aprse it ''' uni_addr = [] for chunk, charset in email.Header.decode_header(addr): if charset: uni_addr += unicode(chunk, charset) else: uni_addr += chunk uni_addr = u''.join(uni_addr) return email.Utils.parseaddr(uni_addr)
|
addr = parseaddr(message['to'])[1]
|
addr = getaddr(message['to'])
|
def send(self, message): #addr = email.Utils.parseaddr(message['to'])[1] addr = parseaddr(message['to'])[1] logger.info('Sending mail to %s', addr)
|
perms = self.user.getPermissions( self.isNew and field_type.createPermissions or field_type.permissions)
|
if self.isNew: permissions = field_type.createPermissions else: permissions = field_type.permissions perms = self.user.getPermissions(permissions)
|
def allowedFields(self, item): # assume item.type=='item' itemFieldsOrder = [] for field_name, field_type in item.fields.iteritems(): perms = self.user.getPermissions( self.isNew and field_type.createPermissions or field_type.permissions) if ('w' in perms or 'r' in perms) and \ not (self.isNew and field_type.omitForNew): itemFieldsOrder.append(field_name) return itemFieldsOrder
|
perms = self.user.getPermissions(self.isNew and field_type.createPermissions or field_type.permissions)
|
if self.isNew: permissions = field_type.createPermissions else: permissions = field_type.permissions perms = self.user.getPermissions(permissions)
|
def showField(self, item, name): '''Return representation of field in editor interface''' field_type = item.fields[name] stream_perms = self.user.getPermissions(item.stream.permissions) perms = self.user.getPermissions(self.isNew and field_type.createPermissions or field_type.permissions) if 'w' in stream_perms and 'w' in perms: template_type = 'edit' elif 'r' in perms: template_type = 'view' else: return '' return field_type.show(item, name, template_type, self.edit.getFieldTemplate, self.fieldGlobalNamespace) # XXX namespace
|
user.checkPermission('w', isNew and field_type.createPermissions or field_type.permissions):
|
user.checkPermission('w', permissions):
|
def storableFields(self, item, user, isNew=0): itemFieldsOrder = [] id_field_name = item.fields.idFieldName for field_name, field_type in item.fields.iteritems(): if field_name!=id_field_name and \ user.checkPermission('w', isNew and field_type.createPermissions or field_type.permissions): itemFieldsOrder.append(field_name) return itemFieldsOrder
|
file_name = file_list[0]
|
file_name = '/'.join(os.path.split(file_list[0]))
|
def path(self): if self.body: return self.pattern+'.'+self._image.format.lower() else: from glob import glob file_list = glob(self.field_type.editRoot+self.pattern+'.*') if file_list: file_name = file_list[0] return file_name[len(self.field_type.editRoot):]
|
allowedFields = qUtils.CachedAttribute(getAllowedFields)
|
allowedFields = qUtils.CachedAttribute(getAllowedFields, 'allowedFields')
|
def getAllowedFields(self, obj=None): if obj is None: obj = self.object # assume obj.type=='item' stream = obj.stream item_fields = stream.allItemFields itemFieldsOrder = [] for field_name in stream.itemFieldsOrder: field_type = item_fields[field_name] perms = self.edUser.getPermissions(field_type.permissions) if 'w' in perms or 'r' in perms and \ not (self.isNew and field_type.omitForNew): itemFieldsOrder.append(field_name) return itemFieldsOrder
|
allowedIndexFields = qUtils.CachedAttribute(getAllowedIndexFields)
|
allowedIndexFields = qUtils.CachedAttribute(getAllowedIndexFields, 'allowedIndexFields')
|
def getAllowedIndexFields(self, obj=None): if obj is None: obj = self.object # assume obj.type=='stream': stream = obj item_fields = stream.allStreamFields itemFieldsOrder = [] if self.edUser.checkPermission('x', stream.permissions): for field_name in stream.itemFieldsOrder+\ getattr(stream, 'joinFields', {}).keys(): field_type = item_fields[field_name] if self.edUser.checkPermission('r', field_type.indexPermissions): itemFieldsOrder.append(field_name) return itemFieldsOrder
|
isStreamUpdatable = qUtils.CachedAttribute(checkIfStreamUpdatable)
|
isStreamUpdatable = qUtils.CachedAttribute(checkIfStreamUpdatable, 'isStreamUpdatable') def checkIfStreamUnbindable(self, obj=None): if obj is None: obj = self.object return hasattr(obj, 'joinField') and \ self.edUser.checkPermission('w', brick.allItemFields[brick.joinField].indexPermissions) isStreamUnbindable = qUtils.CachedAttribute(checkIfStreamUnbindable, 'isStreamUnbindable') def checkIfStreamCreatable(self, obj=None): if obj is None: obj = self.object return self.edUser.checkPermission('c', obj.permissions) isStreamCreatable= qUtils.CachedAttribute(checkIfStreamCreatable, 'isStreamCreatable') def checkIfStreamDeletable(self, obj=None): if obj is None: obj = self.object return self.edUser.checkPermission('d', obj.permissions) isStreamDeletable= qUtils.CachedAttribute(checkIfStreamDeletable, 'isStreamDeletable')
|
def checkIfStreamUpdatable(self, obj=None): if obj is None: obj = self.object allowedIndexFields = self.allowedIndexFields else: allowedIndexFields = self.getAllowedIndexFields(obj) # assume obj.type=='stream': stream = obj if self.edUser.checkPermission('w', stream.permissions): item_fields = stream.allStreamFields for field_name in allowedIndexFields: field_type = item_fields[field_name] if self.edUser.checkPermission('w', field_type.indexPermissions): return 1 return 0
|
class Authentication:
|
class Authentication(object):
|
def getUser(self, login=None): if login: table, fields, condition, group, order = self.constructQuery() condition = self.dbConn.join( [condition, Query('%s=' % self.loginField, Param(login))]) items = self.itemsByQuery(table, fields, condition, group=group) if items: return items[0] # return default "False" user return self.createNewItem()
|
return user
|
return user else: return stream.getUser(None)
|
def login(self, publisher, request, response, form): login, passwd, perm_login = [form.getfirst(name) for name in \ ('login', 'passwd', 'perm_login')] # crypt method used below only supports string types try: passwd = str(passwd) except UnicodeEncodeError: passwd = None
|
def __init__(self, templateStream, paramStream, paramName, prefix=None,
|
def __init__(self, templateStream, paramStream, paramName, format=None, prefix=None,
|
def __init__(self, templateStream, paramStream, paramName, prefix=None, streamParams=None, titleTemplate=None): self.templateStream = templateStream self.paramStream = paramStream self.paramName = paramName self.titleTemplate = titleTemplate if prefix is None: self.prefix = paramStream else: self.prefix = prefix self.streamParams = self.defaultStreamParams() if streamParams: self.streamParams.update(streamParams)
|
if prefix is None: self.prefix = paramStream
|
if format is None: self.prefix = (prefix or paramStream)+'/' self.suffix = ''
|
def __init__(self, templateStream, paramStream, paramName, prefix=None, streamParams=None, titleTemplate=None): self.templateStream = templateStream self.paramStream = paramStream self.paramName = paramName self.titleTemplate = titleTemplate if prefix is None: self.prefix = paramStream else: self.prefix = prefix self.streamParams = self.defaultStreamParams() if streamParams: self.streamParams.update(streamParams)
|
self.prefix = prefix
|
self.prefix, self.suffix = format
|
def __init__(self, templateStream, paramStream, paramName, prefix=None, streamParams=None, titleTemplate=None): self.templateStream = templateStream self.paramStream = paramStream self.paramName = paramName self.titleTemplate = titleTemplate if prefix is None: self.prefix = paramStream else: self.prefix = prefix self.streamParams = self.defaultStreamParams() if streamParams: self.streamParams.update(streamParams)
|
parts = stream_path.split('/') if len(parts)>=2 and '/'.join(parts[:-1])==self.prefix:
|
if stream_path.startswith(self.prefix) and \ stream_path.endswith(self.suffix): param_item_id_str = stream_path[len(self.prefix):] if self.suffix: param_item_id_str = param_item_id_str[:-len(self.suffix)]
|
def match(self, site, stream_path, tag=None): parts = stream_path.split('/') if len(parts)>=2 and '/'.join(parts[:-1])==self.prefix: param_stream = site.retrieveStream(self.paramStream, tag=site.transmitTag(tag)) try: param_item_id = \ param_stream.fields.id.convertFromString(parts[-1]) except ValueError: return param_item = param_stream.retrieveItem(param_item_id) if param_item is None: # no such item return params = self.streamParams.copy() params[self.paramName] = param_item if self.titleTemplate is not None: params['title'] = interpolateString(self.titleTemplate, params) return self.templateStream, params else: return
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.