Commits

Lynn Rees committed acdff55

- changed function names in psiutils

  • Participants
  • Parent commits 277ae8c

Comments (0)

Files changed (5)

 from cStringIO import StringIO
 from xml.dom import XHTML_NAMESPACE as htmlns
 from Ft.Xml.Domlette import NonvalidatingReader as nr
-from psiutils import iscomment, sattr, hattr, isname, iselement
-from psiutils import stripWS, getTagsByAttribute, getTagsInList, gattr
-from psiutils import tostring, getTags, getAllTagsNS, istext, rattr 
+from psiutils import stripWS, tagsbyAttr, tagsinList, attget
+from psiutils import tostring, tags, tagsbyNS, istext, attdel 
+from psiutils import iscomment, attset, hasatt, isname, iselement
 from xml.sax.saxutils import escape, _outputwrapper, writetext, writeattr
     
 
 class HTMLformat(xml.sax.ContentHandler):
 
-    from htmlweights import inline, empty, head
+    from htmldefs import inline, empty, head
     
     _encoding = 'iso-8859-1'
 
 
 def htmlprep(file):
     html = htmldom(file)
-    widthtags = list(getTagsInList(html, tagsWithAttribute('width')))
+    widthtags = list(tagsinList(html, tagsWithAttribute('width')))
     fixwidths(makegrid(html, widthtags))
     fixspans(html)
     notrwidth(html)
     return listhtml(tostring(htmlprep(file)))
 
 def tagsWithAttribute(attr):
-    from htmlweights import html2css
+    from htmldefs import html2css
     return [i for i in html2css if attr in html2css.get(i)]
 
 def makegrid(doc, structure):
                 if temp not in grid: grid.append(temp)
             grid.append([node])
     if len(temp): grid.append(temp)
-    rowspans = list(getTagsByAttribute(doc, 'rowspan'))
+    rowspans = list(tagsbyAttr(doc, 'rowspan'))
     if len(rowspans):
         for td in rowspans:
             trs, sibs = [], ['td.parentNode']
-            for x in range(int(gattr(td, 'rowspan'))-1):
+            for x in range(int(attget(td, 'rowspan'))-1):
                 sibs.append('.nextSibling')
                 if eval(''.join(sibs)): trs.append(eval(''.join(sibs)))
             for nodelist in grid:
 def fixwidths(grid):
 
     def haswidth(node):
-        return hattr(node, 'width')
+        return hasatt(node, 'width')
 
     def getwidth(node):
-        return gattr(node, 'width')    
+        return attget(node, 'width')    
 
     def setwidth(node, width):
-        sattr(node, 'width', width)
+        attset(node, 'width', width)
                 
     def regtest(nodelist):
         for i in nodelist:
             if len(percents) > 1 and regtest(nodelist): mixed = True
             for node in percents:
                 width = round((float(getwidth(node).strip('%'))*0.01)*pwidth)
-                sattr(node, 'width', str(int(width)))
+                attset(node, 'width', str(int(width)))
             for node in nowidths: setwidth(node, str(portion))
             if mixed:
                 tds = []
                                 tr.appendChild(t)
                             setwidth(td, str(tcount))
                             if len(share):
-                                for n, v in share.iteritems(): sattr(td, n, v)
-                            sattr(table, 'border', '0')
-                            sattr(table, 'cellspacing', '0')
-                            sattr(table, 'cellpadding', '0')                            
+                                for n, v in share.iteritems(): attset(td, n, v)
+                            attset(table, 'border', '0')
+                            attset(table, 'cellspacing', '0')
+                            attset(table, 'cellpadding', '0')                            
                             setwidth(table, str(tcount))
                             td.appendChild(table)
                             table.appendChild(tr)
             mixed = None
 
 def notrwidth(doc):
-    trs = list(getTags(doc, htmlns, 'tr'))
+    trs = list(tags(doc, htmlns, 'tr'))
     for tr in trs: tr.removeAttributeNS(None, 'width')
 
 def fixspans(doc):
-    tables = list(getTags(doc, htmlns, 'table'))
+    tables = list(tags(doc, htmlns, 'table'))
     for table in tables:
         trcount, tdcount = 0, 0
         for tr in table.childNodes:
         for tr in table.childNodes:
             for td in tr.childNodes:
                 if iselement(td):
-                    if hattr(td, 'rowspan'):
-                        if int(gattr(td, 'rowspan')) > trcount:
-                            sattr(td, 'rowspan', str(trcount))
-                    elif hattr(td, 'colspan'):
-                        if int(gattr(td, 'colspan')) > tdcount:
-                            sattr(td, 'colspan', str(tdcount))
+                    if hasatt(td, 'rowspan'):
+                        if int(attget(td, 'rowspan')) > trcount:
+                            attset(td, 'rowspan', str(trcount))
+                    elif hasatt(td, 'colspan'):
+                        if int(attget(td, 'colspan')) > tdcount:
+                            attset(td, 'colspan', str(tdcount))
         grid, temp = [], []
         for tr in table.childNodes:
             if iselement(tr) and isname(tr, 'tr'):
                 for td in tr.childNodes:
                     if iselement(td) and isname(td, 'td'): temp.append(td)
         if len(temp): grid.append(temp)
-        rowspans = list(getTagsByAttribute(table, 'rowspan'))
+        rowspans = list(tagsbyAttr(table, 'rowspan'))
         if len(rowspans):
             for td in rowspans:
                 trs, sibs = [], ['td.parentNode']
-                for x in range(int(gattr(td, 'rowspan'))-1):
+                for x in range(int(attget(td, 'rowspan'))-1):
                     sibs.append('.nextSibling')
                     if eval(''.join(sibs)): trs.append(eval(''.join(sibs)))
                 for nodelist in grid:
                         if tr.firstChild in nodelist: nodelist.insert(loc, td)
         for nodelist in grid:
             for td in nodelist:
-                if hattr(td, 'colspan'):
+                if hasatt(td, 'colspan'):
                     index = nodelist.index(td)
-                    colspan = int(gattr(td, 'colspan'))
+                    colspan = int(attget(td, 'colspan'))
                     offset, largest = len(nodelist[:index]), 0
                     for nlist in grid:
                         actual = len(nlist[index:-offset])
                             if actual > largest:
                                 count = 0
                                 for i in nlist[index:-offset]:
-                                    if hattr(i, 'colspan'):
-                                        count += int(gattr(i, 'colspan'))
+                                    if hasatt(i, 'colspan'):
+                                        count += int(attget(i, 'colspan'))
                                 if count != colspan: largest = actual
-                    if largest: sattr(td, 'colspan', str(largest))
-                    if int(gattr(td, 'colspan')) <= 1:
-                        rattr(td, 'colspan')
+                    if largest: attset(td, 'colspan', str(largest))
+                    if int(attget(td, 'colspan')) <= 1:
+                        attdel(td, 'colspan')
         
 def cssplit1(csstring):
     css = csstring.replace('\n', '').split('}')
         
     import urllib    
     cssdict, count = dict(), 1
-    for tag in getTagsInList(doc, ['style', 'link']):
+    for tag in tagsinList(doc, ['style', 'link']):
         if isname(tag, 'link'):
-            if gattr(tag, 'rel') == 'stylesheet':
-                url = gattr(tag, 'href')
+            if attget(tag, 'rel') == 'stylesheet':
+                url = attget(tag, 'href')
                 if url.find('http:') != -1: style = urllib.urlopen(url).read()
                 else: style = open(urllib.url2pathname(url)).read()
                 fullsplit(style)
         elif isname(tag, 'style'):
             for i in tag.childNodes:
                 if istext(i) or iscomment(i): fullsplit(i.data)
-    for tag in getTagsByAttribute(doc, 'style'):
+    for tag in tagsbyAttr(doc, 'style'):
         subcss = dict()
-        for cmd, value in cssplit2(gattr(tag, 'style')): subcss[cmd] = value
+        for cmd, value in cssplit2(attget(tag, 'style')): subcss[cmd] = value
         if subcss not in cssdict.values():
             cssdict[''.join(['.ecss', str(count)])] = subcss
             count += 1    
     def recss(cdict):
         return '; '.join(['%s: %s' % (i, j) for i, j in cdict.iteritems()])
 
-    from htmlweights import html2css
+    from htmldefs import html2css
     import types
     if 'embed' in kwargs: embed = 1
     else: embed = None
     if 'file' in kwargs: file = kwargs['file']
     else: file = None
-    css, tags, count = getcss(doc), list(getAllTagsNS(htmlns, doc)), 1
+    css, tags, count = getcss(doc), list(tagsbyNS(htmlns, doc)), 1
     for tag in tags:
         if tag.localName in html2css:
             delete, map = list(), html2css.get(tag.localName)
                 for i in delete: del tag.attributes[i]
             if len(tcss):
                 for cmd, value in cssplit2('; '.join(tcss)): scss[cmd] = value
-                if hattr(tag, 'class'):
-                    scss.update(css.get(''.join(['.', gattr(tag, 'class')])))
-                    rattr(tag, 'class')
-                if hattr(tag, 'style'):
+                if hasatt(tag, 'class'):
+                    scss.update(css.get(''.join(['.', attget(tag, 'class')])))
+                    attdel(tag, 'class')
+                if hasatt(tag, 'style'):
                     style = css.get(getattr(tag, 'style'))
                     for cmd, value in cssplit2(style): scss[cmd] = value
-                    rattr(tag, 'style')
+                    attdel(tag, 'style')
                 if scss not in css.values():
                     classvalue = ''.join(['css', str(count)])
                     css[''.join(['.', classvalue])] = scss
                 elif scss in css.values():
                     for i, j in css.iteritems():
                         if j == scss: classvalue = i.strip('.')
-                if embed or file: sattr(tag, 'class', classvalue)
-                else: sattr(tag, 'style', recss(scss))
+                if embed or file: attset(tag, 'class', classvalue)
+                else: attset(tag, 'style', recss(scss))
     if embed or file:
         cssgather = [('%s {%s}' % (i, recss(css.get(i)))) for i in css]
         cssgather.sort()
         cssmaster = '\n'.join(cssgather)
-        for i in getTagsInList(doc, ['style', 'link']):
+        for i in tagsinList(doc, ['style', 'link']):
             if isname(i, 'link'):
-                if hattr(i, 'rel'):
-                    if gattr(i, 'rel') == 'stylesheet':
+                if hasatt(i, 'rel'):
+                    if attget(i, 'rel') == 'stylesheet':
                         i.parentNode.removeChild(i)
             elif isname(i, 'style'): i.parentNode.removeChild(i)
         if kwargs:
             if embed:
                 style = doc.createElementNS(htmlns, 'style')
                 style.appendChild(doc.createComment(cssmaster))
-                list(getTags(doc, htmlns, 'head'))[0].appendChild(style)
+                list(tags(doc, htmlns, 'head'))[0].appendChild(style)
             elif file:
                 import urllib
                 open(file, 'wb').write(cssmaster)
                 style = doc.createElementNS(htmlns, 'link')
-                sattr(style, 'rel', 'stylesheet')
-                sattr(style, 'href', urllib.pathname2url(file))
-            sattr(style, 'type', 'text/css')
-            list(getTags(doc, htmlns, 'head'))[0].appendChild(style)
+                attset(style, 'rel', 'stylesheet')
+                attset(style, 'href', urllib.pathname2url(file))
+            attset(style, 'type', 'text/css')
+            list(tags(doc, htmlns, 'head'))[0].appendChild(style)
     '''Autogenerates a PSI map of a datasource.'''
 
     # Retrieves XML tags by name attributes and name attribute 
-    from psiutils import getTagsByName as _getTagsByName
-    from psiutils import getName as _getName
+    from psiutils import tagsbyName as _tagsbyName
+    from psiutils import getname as _getname
     from psiutils import psins as _psins
     # Class for PSI collections and resources
     from som import Collection as _col
                 # nr reads a string into cDomlette and HTML tidier
                 from Ft.Xml.Domlette import NonvalidatingReader as nr
                 from mx.Tidy import tidy
-                from psiutils import rattr
+                from psiutils import attdel
                 # Reader Exceptions and mimetype detector
                 import mimetypes as mt                
                 from Ft.Xml import ReaderException as rex
                 self._rex, self._mt, self._dohtml = rex, mt, True
-                self._rattr = rattr
+                self._attdel = attdel
             # Flag for recursive processing
             elif arg == 'dorec': self._dorec = True
             # Flag to map archive contents
             elif arg == 'doarc':
                 # Archive and mimetype detector
-                from psiutils import isarchive as isarchive
+                from psiutils import isarchive
                 import mimetypes as mt
                 self._isarchive, self._mt, self._doarc = isarchive, mt, True
         # If input or output paths are specified...
                         # If the parent is found
                         if parent:
                             # Move down DOM tree
-                            if sp[depth] == getName(parent):
+                            if sp[depth] == getname(parent):
                                 parents[key] = parent
                             # Remove any parent that doesn't fit path
                             else: del parents[key]
                     findparent(depth)
 
         # Get collections matching parent name
-        matches = self._getTagsByName(root, None, 'collection', sp[depth])
-        getName = self._getName
+        matches = self._tagsbyName(root, None, 'collection', sp[depth])
+        getname = self._getname
         # Set to None if no children found
         if len(matches) == 0: return None
         # If more than one match, narrow down
                 # Weed out collections with different parents
                 for match in matches:
                     parent = match.parentNode                    
-                    if parent and sp[depth] == getName(parent):
+                    if parent and sp[depth] == getname(parent):
                         parents[matches.index(match)] = parent
                 # If more that one parent, narrow down parents
                 findparent(depth)
             if sp[0] == '': del sp[0]
             if sp[-1] == '': del sp[-1]
             # Insert root into each path
-            sp.insert(0, self._getName(root))
+            sp.insert(0, self._getname(root))
             # Adjust full path if necessary
             try: fp = fullpaths[pp]
             except NameError: fp = path
             if self._current != sp[-2]: self._cp = self._getparent(sp, root)
             self._cp.insertBefore(temp, self._cp.firstChild)
             # Keep parent collection current
-            self._current = self._getName(self._cp)
+            self._current = self._getname(self._cp)
         # If no parent is found, attach collection to document root
         except AttributeError:
             # Make first collection under root
             root.insertBefore(temp, root.firstChild)
             # Keep parent current
-            self._cp, self._current = temp, self._getName(temp)
+            self._cp, self._current = temp, self._getname(temp)
 
     def _resource(self, rn, pn):
         '''makes PSI resource element
         # Extract only first child for cleanliness
         html = html.firstChild
         # Avoids issue with HTML docs made up of comments
-        try: self._rattr(html, 'xmlns')
+        try: self._attdel(html, 'xmlns')
         except AttributeError: pass
         # Return HTML
         return html
 __author__  = 'L. C. Rees (xanimal@users.sf.net)'
 
 import os
-from psiutils import sattr, rattr
-from Ft.Xml.Domlette import NonvalidatingReader
-from psiutils import toxmlfile, getTags, getName, getClass, stripWS, psins
+from psiutils import attset, attdel
+from Ft.Xml.Domlette import NonvalidatingReader as nr
+from psiutils import toxmlfile, tags, getname, getClass, stripws, psins
 
 rsrc, fld, fmnt, cls, nm = u'resource', u'field', u'fragment', u'class', u'name'
 
 class Processor:
 
     def _expandFragments(self, source, target):
-        fields = [f for f in getTags(source, psins, fld)]
-        fragments = [f for f in getTags(target, psins, fmnt)]
+        fields = [f for f in tags(source, psins, fld)]
+        fragments = [f for f in tags(target, psins, fmnt)]
         for fragment in fragments:
             fclass = getClass(fragment)
             for field in fields:
-                if fclass == getName(field):
+                if fclass == getname(field):
                     for child in fragment.childNodes:
                         clone = child.cloneNode(1)
                         field.parentNode.insertBefore(clone, field)
     def _expand(self, lo, fragment, end):
         for resource in lo:
             for master in self._templates:
-                if getClass(resource) == getName(master):
+                if getClass(resource) == getname(master):
                     child = master.cloneNode(1)
-                    sattr(child, nm, getName(resource))
-                    rattr(child, cls)
+                    attset(child, nm, getname(resource))
+                    attdel(child, cls)
                     fragment(child, resource)                
                     resource.parentNode.appendChild(child)
                     resource.parentNode.removeChild(resource)
     
     def _cleanUnexpanded(self):
         for resource in self._unexpanded:
-            name = getName(resource)
+            name = getname(resource)
             for template in self._templates:
-                if name == getName(template): self._unexpanded.remove(resource)
+                if name == getname(template): self._unexpanded.remove(resource)
             
     def _expandTemplates(self):
         self._expand(self._templates, self._expandFragments, self._cleanTemplates)
         self._cleanUnexpanded()
     
     def _exportPack(self, child, resource):
-        self._exports[getName(resource)] = child.firstChild
+        self._exports[getname(resource)] = child.firstChild
             
     def _expandResources(self):    
         self._expand(self._unexpanded, self._expandFragments, self._exportPack)
     def _expandFragmentsDW(self, source, target):
         tbe = 'InstanceBeginEditable name="%s"'
         tee = 'InstanceEndEditable'
-        fields = [f for f in getTags(source, psins, fld)]
-        fragments = [f for f in getTags(target, psins, fmnt)]
+        fields = [f for f in tags(source, psins, fld)]
+        fragments = [f for f in tags(target, psins, fmnt)]
         for fragment in fragments:
             fclass = getClass(fragment)
             for field in fields:
-                if fclass == getName(field):
+                if fclass == getname(field):
                     pn = field.parentNode
                     ppn = pn.parentNode.insertBefore
-                    ttbe = self._doc.createComment(tbe % getName(field))
+                    ttbe = self._doc.createComment(tbe % getname(field))
                     ttee = self._doc.createComment(tee)
                     ppn(ttbe, field.parentNode)
                     for child in fragment.childNodes:
         dwtemplates = [d.cloneNode(1) for d in self._templates]
         for i in dwtemplates:
             for master in self._templates:
-                if getClass(i) == getName(master):
+                if getClass(i) == getname(master):
                     child = master.cloneNode(1)
-                    sattr(child, nm, getName(i))
-                    rattr(child, cls)
+                    attset(child, nm, getname(i))
+                    attdel(child, cls)
                     self._expandFragmentsDW(child, i)                
                     dwtemplates.remove(i)
                     dwtemplates.append(child)
                     i = child
-                fields = [f for f in getTags(i, psins, fld)]           
+                fields = [f for f in tags(i, psins, fld)]           
                 for field in fields:
                     pn = field.parentNode
                     ppn = pn.parentNode.insertBefore
-                    ttbe = self._doc.createComment(tbe % getName(field))
+                    ttbe = self._doc.createComment(tbe % getname(field))
                     ttee = self._doc.createComment(tee)
                     ppn(ttbe, pn)
                     ppn(ttee, pn.nextSibling)
-                    ph = self._doc.createTextNode(getName(i))
+                    ph = self._doc.createTextNode(getname(i))
                     field.parentNode.replaceChild(ph, field)
-                self._exports['/Templates/%s.dwt' % getName(i)] = i.firstChild
+                self._exports['/Templates/%s.dwt' % getname(i)] = i.firstChild
         self._expand(self._templates, self._expandFragments, self._cleanTemplates)
         self._cleanUnexpanded()
     
         ttee = self._doc.createComment(tee)
         instance.insertBefore(ttbe, instance.firstChild)
         instance.appendChild(ttee)
-        self._exports[getName(resource)] = instance  
+        self._exports[getname(resource)] = instance  
     
     def _exportResourcesDW(self):
         for i in self._exports:
                         toxmlfile(self._exports.get(i), i[1:])
 
     def read(self, file):
-        self._doc = NonvalidatingReader.parseUri(file)
+        self._doc = nr.parseUri(file)
 
     def todreamweaverMX(self, file=None):
         self._exports = {}
-        if file: self._doc = NonvalidatingReader.parseUri(file)
-        stripWS(self._doc)
-        names = [getName(i) for i in getTags(self._doc, psins, rsrc)]
-        classes = [getClass(i) for i in getTags(self._doc, psins, rsrc)]
-        self._unexpanded = [i for i in getTags(self._doc, psins, rsrc)
+        if file: self._doc = nr.parseUri(file)
+        stripws(self._doc)
+        names = [getname(i) for i in tags(self._doc, psins, rsrc)]
+        classes = [getClass(i) for i in tags(self._doc, psins, rsrc)]
+        self._unexpanded = [i for i in tags(self._doc, psins, rsrc)
                             if getClass(i) in names]
-        self._templates = [i for i in getTags(self._doc, psins, rsrc)
-                           if getName(i) in classes]
+        self._templates = [i for i in tags(self._doc, psins, rsrc)
+                           if getname(i) in classes]
         self._expandTemplatesDW()
         self._expandResourcesDW()
         self._exportResourcesDW()
 
     def tostatic(self, file=None):        
         self._exports = {}
-        if file: self._doc = NonvalidatingReader.parseUri(file)
-        stripWS(self._doc)
-        names = [getName(i) for i in getTags(self._doc, psins, rsrc)]
-        classes = [getClass(i) for i in getTags(self._doc, psins, rsrc)]
-        self._unexpanded = [i for i in getTags(self._doc, psins, rsrc)
+        if file: self._doc = nr.parseUri(file)
+        stripws(self._doc)
+        names = [getname(i) for i in tags(self._doc, psins, rsrc)]
+        classes = [getClass(i) for i in tags(self._doc, psins, rsrc)]
+        self._unexpanded = [i for i in tags(self._doc, psins, rsrc)
                             if getClass(i) in names]
-        self._templates = [i for i in getTags(self._doc, psins, rsrc)
-                           if getName(i) in classes]
+        self._templates = [i for i in tags(self._doc, psins, rsrc)
+                           if getname(i) in classes]
         self._expandTemplates()
         self._expandResources()
         self._exportResources()
             for cn in self._domwalk(child, func): yield cn
         return
 
-    def getTagsByAttribute(self, node, attr):
+    def tagsbyAttr(self, node, attr):
         '''Finds elements by attribute
     
         node -- node to search
         attr -- local attribute name'''
-        func = lambda n: self.iselement(n) and self.hattr(n, attr)
+        func = lambda n: self.iselement(n) and self.hasatt(n, attr)
         return self._domwalk(node, func)            
 
-    def getFirstTagByAttribute(self, node, attr):
+    def firstTagByAttr(self, node, attr):
         '''Finds the first element with an attribute
 
         node -- node to search
         attr -- local attribute name'''
-        return getTagsByAttribute(node, attr).next()
+        return tagsbyAttr(node, attr).next()
     
-    def getTagsInList(self, node, taglist):
+    def tagsinList(self, node, taglist):
         '''Finds elements by local tag name in list
 
         node -- node to search
         func = lambda n: self.iselement(n) and n.localName in taglist
         return self._domwalk(node, func)
 
-    def getFirstTagInList(self, node, taglist):
+    def firstTagByList(self, node, taglist):
         '''Finds first element in a node by local tag name in a list
 
         node -- node to search        
         taglist -- list of local tag names'''
-        return self.getTagsInList(node, taglist).next()
+        return self.tagsinList(node, taglist).next()
     
-    def getTags(self, node, ns, local):
+    def tags(self, node, ns, local):
         '''Finds elements by namespace and local tag name
 
         node -- node to search
                           self.isname(n, local))
         return self._domwalk(node, func)
         
-    def getFirstTag(self, node, ns, local):
+    def firstTag(self, node, ns, local):
         '''Finds the first element with a namespace and local tag name
 
         node -- node to search
         ns -- namespace
         local -- local tag name'''
-        return self.getTags(node, ns, local).next()
+        return self.tags(node, ns, local).next()
 
-    def getTagsByName(self, node, ns, local, name):
+    def tagsbyName(self, node, ns, local, name):
         '''Finds the first element with a namespace and local tag name
 
         node -- node to search
         ns -- namespace
         local -- local tag name
         name -- local tag attribute name'''
-        return [i for i in self.getTags(node, ns, local) 
-            if self.getName(i) == name]
+        return [i for i in self.tags(node, ns, local) 
+            if self.getname(i) == name]
 
-    def getAllTagsNS(self, ns, node):
+    def tagsbyNS(self, ns, node):
         '''Get all elements in a node
     
         node -- node to search'''
         node -- node to search'''
         return self._domwalk(node, lambda n: self.istext(n))
 
-    def stripWS(self, node):
+    def stripws(self, node):
         '''Finds text nodes containing useless whitespace.
 
         node -- node to search'''
         # Delete useless whitespace nodes
         for text in ws: text.parentNode.removeChild(text)
 
-    def getName(self, node):
+    def getname(self, node):
         '''Returns a node's name attribute.
 
         node -- node to get the name of'''
         return node.getAttributeNS(None, 'name')
 
-    def getClass(self, node):
+    def getclass(self, node):
         '''Returns a node's class attribute.
 
         node -- node to get the class of'''
         return node.getAttributeNS(None, 'class')    
 
-    def gattr(self, node, attr):
+    def attget(self, node, attr):
         return node.getAttributeNS(None, attr)
 
-    def hattr(self, node, attr):            
+    def hasatt(self, node, attr):            
         return node.hasAttributeNS(None, attr)    
 
-    def rattr(self, node, attr):
+    def attdel(self, node, attr):
         node.removeAttributeNS(None, attr)
 
-    def sattr(self, node, attr, value):
+    def attset(self, node, attr, value):
         node.setAttributeNS(None, attr, value)
 
     def isname(self, node, name):
     def iscomment(self, node):
         if node.nodeType == self.Node.COMMENT_NODE: return True
 
+__all__ = ['isns', 'attremove', 'attget', 'attset', 'hasatt', 'isname', 'istext',
+    'getname', 'tags', 'getText', 'stripws', 'tostring', 'getclass',
+    'iselement', 'iscomment', 'isarchive', 'toxmlfile', 'toprettyxml',
+    'firstTag', 'tagsbyNS', 'tagsinList', 'tagsbyName',
+    'firstTagByList', 'tagsbyAttr', 'firstTagByAttr']
 _inst = Utils()
+tags = _inst.tags
 isns = _inst.isns
-rattr = _inst.rattr
-gattr = _inst.gattr
-sattr = _inst.sattr
-hattr = _inst.hattr
+attdel = _inst.attdel
+attget = _inst.attget
+attset = _inst.attset
+hasatt = _inst.hasatt
 isname = _inst.isname
 istext = _inst.istext
-getName = _inst.getName
-getTags = _inst.getTags
+getname = _inst.getname
 getText = _inst.getText
-stripWS = _inst.stripWS
+stripws = _inst.stripws
 tostring = _inst.tostring
-getClass = _inst.getClass
+getclass = _inst.getclass
+firstTag = _inst.firstTag
+tagsbyNS = _inst.tagsbyNS
 iselement = _inst.iselement
 iscomment = _inst.iscomment
 isarchive = _inst.isarchive
 toxmlfile = _inst.toxmlfile
+tagsinList = _inst.tagsinList
+tagsbyName = _inst.tagsbyName
+tagsbyAttr = _inst.tagsbyAttr
 toprettyxml = _inst.toprettyxml
-getFirstTag = _inst.getFirstTag
-getAllTagsNS = _inst.getAllTagsNS
-getTagsInList = _inst.getTagsInList
-getTagsByName = _inst.getTagsByName
-getFirstTagInList = _inst.getFirstTagInList
-getTagsByAttribute = _inst.getTagsByAttribute
-getFirstTagByAttribute = _inst.getFirstTagByAttribute
+firstTagByList = _inst.firstTagByList
+firstTagByAttr = _inst.firstTagByAttr
 corresponding class that ensures correct PSI output.'''
 
 ## Element and Document classes from DOM
-from psiutils import rattr, sattr, gattr
+from psiutils import attdel, attset, attget
 from xml.dom.minidom import Element, Document
 
 
         ## Raise error if unacceptable value entered
         if value not in av: raise AttributeError, msg
         ## Otherwise, set the DOM attribute
-        else: sattr(self, name, value)         
+        else: attset(self, name, value)         
 
     def removeChildren(self, childList=None):
         '''Removes unwanted child nodes
             Arguments:
             name -- name of PSI node'''
             self.name = name
-            sattr(self, u'name', name)
+            attset(self, u'name', name)
 
         def _removeByName(self, childList, name):
             '''Removes unwanted child nodes by name
             childlist -- list of specific nodes
             child -- specific child node'''
             for i in childList:
-                if gattr(i, u'name') == name: return i
+                if attget(i, u'name') == name: return i
         
     class Ref:
 
             Arguments:
             ref -- reference to another PSI node'''
             self.ref = ref
-            sattr(self, u'ref', ref)
+            attset(self, u'ref', ref)
             
     class Class:
 
             Arguments:
             Class -- A node charateristics are inherited from'''
             self.parentClass = Class
-            sattr(self, u'class', Class)
+            attset(self, u'class', Class)
 
     class NCR(Name, Ref, Class):
 
             Arguments:
             start -- a PSI node's start time'''
             self.start = start
-            sattr(self, u'start', start)
+            attset(self, u'start', start)
 
         def setEnd(self, end):
             '''Sets the end attribute of a PSI node
             Arguments:
             end -- a PSI node's end time'''
             self.end = end
-            sattr(self, u'end', end)
+            attset(self, u'end', end)
             
     class Match:
 
             Arguments:
             match -- a value a PSI node must match'''
             self.match = match
-            sattr(self, u'match', match)
+            attset(self, u'match', match)
             
     class State:
 
         type -- the tie breaker in a version conflict'''
         av = ('name', 'class', 'ref', 'state', 'action', 'start', 'end')
         msg = '''value must be string "name", "class", "ref"
-                "state", "action", "start", or "end"'''
+            "state", "action", "start", or "end"'''
         self._attchecker(u'type', type, msg, av)