Thanks Dave - appreciate the hard work.

I have been using the module querypy.py (Attached) with previous releases.

Think I have found an issue in the latest release.

----
def __make_tag__(name, **kwargs):
  class tmp: pass
  tmp_dict = dict(Tag.__dict__)  # This is 232 the problem line.
  tmp.__name__ = name
---

Traceback (most recent call last):

  File ldservergui.py, line 8, in Initialize

  File , line 0, in _stub_##2

  File c:\Code\MN2\moodnews.py, line 9, in Initialize

  File , line 0, in _stub_##2

  File c:\Code\MN2\querypy.py, line 241, in Initialize

  File querypy, line unknown, in __make_tag__

  File c:\Code\MN2\querypy.py, line 232, in __make_tag__

NotImplementedError: The method or operation is not implemented.

On Dec 20, 2007 7:57 PM, Dave Fugate <[EMAIL PROTECTED]> wrote:
>
>
>
>
> Hello IronPython Community,
>
>
>
> Just in time for the holidays we have released IronPython 2.0 Alpha 7!
> There's been numerous changes to IronPython in the past month and a half.
> Most notably a lot of work has been done to get usage of the 'yield'
> statement compatible with CPython 2.5.  There might be a few more changes
> that need to be made, but by and far IP now adheres to PEP 342.  Another
> notable change brings the code closer to the new hosting API spec we
> published on this mailing list.  The next couple of releases should finish
> that work.
>
>
>
> After careful consideration of your valuable feedback we've determined that
> 2.0A7 will be the last 2.0 release to be built and fully tested by us under
> Visual Studio 2005 tools.  Beginning with 2.0 Alpha 8, IronPython.sln
> (included in the source zip file) will be upgraded to VS 2008 format and we
> will only run our full test suite against binaries built from this.  The
> 2005 version of IronPython.sln will then be deprecated although it will
> remain in the source zip file alongside IronPython.sln under the new name of
> IronPython2005.sln for some time.  At this point it's unclear whether we'll
> continue to update IronPython2005.sln.
>
>
>
> Last but not least, a number of bugs have been closed:
>
> 10581 - Python25: Characters of hex values are uppercase in IP while they're
> lowercase in CPython 2.5
>
> 8961 - Cannot run globals().keys() after accessing the dictionary keys
> method of a function
>
> 12965 - __doc__ broken
>
> 1689 - Raising attribute error from __getattr__ doesn't propagate out,
> instead we throw a new attribute error
>
> 11491 - problem parsing conditional expression
>
> 8074 - ipy hangs if imported namespaces contain numbers
>
> 4716 - items = globals().items() in a module (not at console)
>
> 10637 - Function object missing func_closure Closed
>
> 6707 - Trivial: IronPython.Hosting.PythonEngine().Sys.prefix is set to None
>
> 6770 - callable(__builtins__) has different results in ipy and Cpy
>
> 3953 - Trivial: Can convert float infinity to long in IronPython
>
> 11103 - Trivial: 'ipy.exe -c "something"' prints out the results of
> "something" to stdout
>
> 10856 - __doc__ does not show up in dir() output on load (and has wrong
> contents)
>
> 2267 - sys.winver missing?
>
> 1352 - Trivial: Open paren at end-of-line raises SyntaxError in interactive
> console
>
> 12141 - Microsoft.Scripting.MethodBinder.ToString()
>
> 5446 - socket.getaddrinfo(...) proto parameter
>
> 5757 - PythonFile is not thread-safe
>
> 10474 - Need to ignore null paths in sys.path
>
>
>
> We'd like to thank everyone in the community who reported these to make a
> better release: Jan Szumiec, arman0, orbital56, Seo Sanghyeon, glchapman,
> tscottw, jacobg23, brucec, leppie, and Christopher Baus.
>
>
>
> You can download IronPython 2.0 Alpha 7 at:
> https://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=IronPython&ReleaseId=8189
>
>
>
> The IronPython Team
>
>
>
>
>
> IMPORTANT NOTES
>
> ToyScript, a small scripting language built on top of the DLR, is merely a
> DLR sample and not some new scripting language Microsoft has created.  Also,
> ToyScript is not intended to be distributed with IronPython on a permanent
> basis.
> _______________________________________________
> Users mailing list
> [email protected]
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>



-- 
Davy Mitchell
Blog - http://www.latedecember.co.uk/sites/personal/davy/
Twitter - http://twitter.com/daftspaniel
Skype - daftspaniel                                          needgod.com
"""
* Copyright (c) 2007, Bjorn Kempen
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
  *     * Redistributions of source code must retain the above copyright
  *       notice, this list of conditions and the following disclaimer.
  *     * Redistributions in binary form must reproduce the above copyright
  *       notice, this list of conditions and the following disclaimer in the
  *       documentation and/or other materials provided with the distribution.
  *     * Neither the name of Bjorn Kempen nor the
  *       names of its contributors may be used to endorse or promote products
  *       derived from this software without specific prior written permission.
  *
  * THIS SOFTWARE IS PROVIDED BY Bjorn Kempen ``AS IS'' AND ANY
  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  * DISCLAIMED. IN NO EVENT SHALL Bjorn Kempen BE LIABLE FOR ANY
  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""

class MustBeEmptyException(Exception):
  def __init__(self, *args, **kwargs):
    super(MustBeEmptyException, self).__init__(self, *args, **kwargs)
    
class NoSuchParentException(Exception):
  def __init__(self, *args, **kwargs):
    super(NoSuchParentException, self).__init__(self, *args, **kwargs)

class NoSuchChildException(Exception):
  def __init__(self, *args, **kwargs):
    super(NoSuchChildException, self).__init__(self, *args, **kwargs)

def doctype_html4_strict():
  """Returns the doctype for HTML4 Strict."""
  return """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd";>"""

def doctype_html4_transitional():
  """Returns the doctype for HTML4 Transitional."""
  return """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd";>"""

def doctype_html4_frameset():
  """Returns the doctype for HTML4 Frameset."""
  return """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd";>"""

def doctype_xhtml_strict():
  """Returns the doctype for XHTML 1.0 Strict."""
  return """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>"""

def doctype_xhtml_transitional():
  """Returns the doctype for XHTML 1.0 Transitional."""
  return """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>"""

def doctype_xhtml_frameset():
  """Returns the doctype for XHTML 1.0 Frameset."""
  return """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd";>"""

def use_lowercase(yesorno):
  """Sets up querypy to output it's tags in lowercase instead of uppercase by passing a True parameter to this function. If querypy is set up for XHTML then lowercase tags are enabled by default. The default is uppercase."""
  Tag.use_lowercase = yesorno

def use_xhtml(yesorno):
  """Sets up querypy to output XHTML 1.0 instead of HTML4 when a True parameter is passed to this function. Default is HTML4."""
  use_lowercase(True)
  Tag.xhtml = yesorno

class Tag(object):
  xhtml = False
  use_lowercase = False
  empty = False
  noendtag = False
  depracated = False

  def __init__(self, **kwargs):
    if "Class" in kwargs:
      kwargs["class"] = kwargs.pop("Class")
    self.attrs = kwargs
    self.children = []
    self.parent = None

    self.name = self.__class__.__name__
    self.level = 0
    self.is_inline = False


  def copy(self):
    """ Creates a deep copy of this tag (and it's children).
returns: The copy """
    import copy
    return copy.deepcopy(self)
    
  def __getitem__(self, item):
    return self.attrs[item]
    
  def __setitem__(self, item, val):
    self.attrs[item] = val
      
  def add(self, child):
    """ Adds the other_tag as a child to this tag. If other_tag is a list, set or tuple all tags in the sequence are added.
returns: Itself """
    if self.empty:
      raise MustBeEmptyException()
      
    if type(child) == str:
      child = TextTag(child)
    elif type(child) in (list, tuple, set):
      for c in child:
        self.add(c)
      return self
        
    self.children.append(child)

    child.parent = self
    child.set_lvl(self.level+1)
    return self

  def rmv(self, child):
    """ Removes other_tag from the children of this tag.
returns: Itself"""
    if self.empty:
      raise MustBeEmptyException()
    return self

  def __add__(self, child):
    """tag1 + tag2 => tag1.add(tag2)"""
    return self.add(child)

  def __sub__(self, child):
    """tag1 - tag2 => tag1.rmv(tag2)"""
    return self.rmv(child)

  def set_lvl(self, lvl):
    self.level = lvl
    for child in self.children:
      child.set_lvl(lvl+1)

  def inline(self):
    """Marks this tag as inline, meaning that it will be printed without linebreaks.
returns: Itself """
    self.is_inline = True
    return self
  
  def __str__(self):
    if self.is_inline:
      rval = "".join([x.inline() for x in self.children])
      if self.noendtag:
        if Tag.xhtml:
          return " "*self.level + self.tag_start[:-1] + "/>"
        else:
          return " "*self.level + self.tag_start + rval
      else:
        return " "*self.level + self.tag_start + rval + self.tag_end

    rval = "\n".join([str(x) for x in self.children])
    if self.noendtag:
      if Tag.xhtml:
        return " "*self.level + self.tag_start[:-1] + "/>"
      else:
        return " "*self.level + self.tag_start + " " + rval
    else:
      return " "*self.level + self.tag_start + "\n" + rval + "\n" + " "*self.level + self.tag_end

  def get_parent(self, level):
    """Gets a parent to this tag. If level is 1 then the direct parent is returned. Otherwise the parent at level levels up is returned.
returns: The parent """
    if not self.parent:
      raise NoSuchParentException()
    elif level < 1:
      raise NoSuchParentException()
    elif level == 1:
      return self.parent
    else:
      return self.parent.get_parent(level-1)
      
  def get_child(self, arg):
    """ If child is an integer, returns the child at that position. If child is a Tag class, return all children matching that class.
returns: The child/children """
    if type(arg) == int:
      if arg <= len(self.children):
        return self.children[arg]
    else:
      children = [x for x in self.children if isinstance(x, arg)]
      if children:
        if len(children) == 1:
          return children[0]
        return children
    raise NoSuchChildException()

  def __rshift__(self, arg):
    """tag >> x => tag.get_child(x)"""
    return self.get_child(arg)

  def __lshift__(self, arg):
    """tag << x => tag.get_parent(x)"""
    return self.get_parent(arg)

  #doesnt use the decorator syntax to work in py <2.4
  def _get_tag_start(self):
    if Tag.use_lowercase:
      tagname = self.name.lower()
    else:
      tagname = self.name
    if self.attrs:
      return "<%s %s>" % (tagname, " ".join(["%s=\"%s\"" % (a, self.attrs[a]) for a in self.attrs]))
    return "<%s>" % tagname
  tag_start = property(_get_tag_start)

  #doesnt use the decorator syntax to work in py <2.4
  def _get_tag_end(self):
    if Tag.use_lowercase:
      tagname = self.name.lower()
    else:
      tagname = self.name

    return "</%s>" % tagname
  tag_end = property(_get_tag_end)

def __make_tag__(name, **kwargs):
  class tmp: pass
  tmp_dict = dict(Tag.__dict__)
  tmp.__name__ = name

  for arg in kwargs:
    tmp_dict[arg] = kwargs[arg]

  tmp.__dict__ = tmp_dict  
  return tmp

A = __make_tag__("A")
ABBR = __make_tag__("ABBR")
ACRONYM = __make_tag__("ACRONYM")
ADDRESS = __make_tag__("ADDRESS")
APPLET = __make_tag__("APPLET", depracated=True)
AREA = __make_tag__("AREA", noendtag=True, empty=True)
B = __make_tag__("B")
BASE = __make_tag__("BASE", noendtag=True, empty=True)
BASEFONT = __make_tag__("BASEFONT", noendtag=True, empty=True, depracated=True)
BDO = __make_tag__("BDO")
BIG = __make_tag__("BIG")
BLOCKQUOTE = __make_tag__("BLOCKQUOTE")
BODY = __make_tag__("BODY")
BR = __make_tag__("BR", noendtag=True, empty=True)
BUTTON = __make_tag__("BUTTON")
CAPTION = __make_tag__("CAPTION")
CENTER = __make_tag__("CENTER", depracated=True)
CITE = __make_tag__("CITE")
CODE = __make_tag__("CODE")
COL = __make_tag__("COL", noendtag=True, empty=True)
COLGROUP = __make_tag__("COLGROUP")
DD = __make_tag__("DD")
DEL = __make_tag__("DEL")
DFN = __make_tag__("DFN")
DIR = __make_tag__("DIR", depracated=True)
DIV = __make_tag__("DIV")
DL = __make_tag__("DL")
DT = __make_tag__("DT")
EM = __make_tag__("EM")
FIELDSET = __make_tag__("FIELDSET")
FONT = __make_tag__("FONT", depracated=True)
FORM = __make_tag__("FORM")
FRAME = __make_tag__("FRAME", noendtag=True, empty=True)
FRAMESET = __make_tag__("FRAMESET")
H1 = __make_tag__("H1")
H2 = __make_tag__("H2")
H3 = __make_tag__("H3")
H4 = __make_tag__("H4")
H5 = __make_tag__("H5")
H6 = __make_tag__("H6")
HEAD = __make_tag__("HEAD")
HR = __make_tag__("HR", noendtag=True, empty=True)
HTML = __make_tag__("HTML")
I = __make_tag__("I")
IFRAME = __make_tag__("IFRAME")
IMG = __make_tag__("IMG", noendtag=True, empty=True)
INPUT = __make_tag__("INPUT", noendtag=True, empty=True)
INS = __make_tag__("INS")
ISINDEX = __make_tag__("ISINDEX", noendtag=True, empty=True, depracated=True)
KBD = __make_tag__("KBD")
LABEL = __make_tag__("LABEL")
LEGEND = __make_tag__("LEGEND")
LI = __make_tag__("LI")
LINK = __make_tag__("LINK", noendtag=True, empty=True)
MAP = __make_tag__("MAP")
MENU = __make_tag__("MENU", depracated=True)
META = __make_tag__("META", noendtag=True, empty=True)
NOFRAMES = __make_tag__("NOFRAMES")
NOSCRIPT = __make_tag__("NOSCRIPT")
OBJECT = __make_tag__("OBJECT")
OL = __make_tag__("OL")
OPTGROUP = __make_tag__("OPTGROUP")
OPTION = __make_tag__("OPTION")
P = __make_tag__("P")
PARAM = __make_tag__("PARAM", noendtag=True, empty=True)
PRE = __make_tag__("PRE",
  __str__=lambda self: " "*self.level + self.tag_start + \
   "\n" + "\n".join([str(x)[x.level:] for x in self.children]) + \
   "\n" + " "*self.level + self.tag_end) # fix indentation
Q = __make_tag__("Q")
S = __make_tag__("S", depracated=True)
SAMP = __make_tag__("SAMP")
SCRIPT = __make_tag__("SCRIPT")
SELECT = __make_tag__("SELECT")
SMALL = __make_tag__("SMALL")
SPAN = __make_tag__("SPAN")
STRIKE = __make_tag__("STRIKE", depracated=True)
STRONG = __make_tag__("STRONG")
STYLE = __make_tag__("STYLE")
SUB = __make_tag__("SUB")
SUP = __make_tag__("SUP")
TABLE = __make_tag__("TABLE")
TBODY = __make_tag__("TBODY")
TD = __make_tag__("TD")
TEXTAREA = __make_tag__("TEXTAREA")
TFOOT = __make_tag__("TFOOT")
TH = __make_tag__("TH")
THEAD = __make_tag__("THEAD")
TITLE = __make_tag__("TITLE")
TR = __make_tag__("TR")
TT = __make_tag__("TT")
U = __make_tag__("U", depracated=True)
UL = __make_tag__("UL")
VAR = __make_tag__("VAR")

class TextTag(Tag):
  def __init__(self, text):
    super(TextTag, self).__init__(name="Text")
    self.text = text
  def __str__(self):
    return " "*self.level + self.text
  def inline(self):
    return self.text
_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to