Michal, The traceback details have changed with r198. The traceback follows the print you suggested. This results from running $ pythoscope gnome/gnutility.py from the root of $ bzr branch lp:~ktenney/+junk/docubi (r56) ============================================================ >>>"def grab(args):\n #logging.debug('entering grab()')\n grabber = Grabber(args)\n #logging.debug('we have grabber')\n grabber.run()\n #logging.debug('leaving grab()')\n getim(args[1])\n\n"<<< >>>'def getim(subtext):\n """Wrapper for Grabber.do_getim():\n copies ReST directives for last grab to the clipboard\n\n >>> from docubi.image import grabber; sssh = reload(grabber)\n >>> grabber.getim(\'hello\')\n >>>\n\n If you now paste, you should see domething like:\n\n.. |subtext| image:: /home/ktenney/work/docubi/chunks/image/8b13a8de-80f7-11dd-b3bf-001d92bbeeeb.png\n :align: middle\n\n """\n\n from docubi.image import grabber\n from gtk import Clipboard\n\n grabber = grabber.Grabber([\'grab\'])\n fname = grabber.get_ordered_files(1)[0]\n grabber.from_file(fname)\n text = grabber.do_getim(subtext)\n cb = Clipboard()\n cb.set_text(text)\n cb.store()\n\n'<<< >>>'def rename_data(directory, extension, newname):\n """Utility to change the name of the data dictionary in a set of pngs.\n\n >>> from docubi.image.grabber import rename_data\n >>> rename_data(\'/home/ktenney/work/docubi/images/grab\', \'png\', \'\')\n >>>\n """\n\n import os\n import annotate\n\n fnames = os.listdir(directory)\n print fnames\n for fname in fnames:\n if fname.endswith(extension):\n try:\n pngdata = annotate.get_tEXt(fname)\n print pngdata\n\n except:\n pass\n\n'<<< >>>'\ndef frames1():\n photo = \'test.jpg\'\n miter = imageframe.ImageFrame(001\n , width=50\n , size=(700,550)\n , outsidecolor=\'#ffffff\' #"#cc6633"\n , insidecolor="#546c1b"\n , cornerstyle="miter"\n , style="pattern"\n , savepath=\'.\'\n , content=photo\n )\n\n # round = ImageFrame(insidecolor = \'#99cccc\', outsidecolor=\'#ffccff\', cornerstyle = \'round\', style = \'pattern\')\n\n miter.save()\n\n bevel = imageframe.ImageFrame(002\n , width=50\n , size=(700,550)\n , outsidecolor="#eb2a61"\n , insidecolor="#181717"\n , cornerstyle="bevel"\n , style="pattern"\n , savepath=\'.\'\n , content=photo\n )\n bevel.save()\n\n'<<< >>>"\ndef annograb(command, filename):\n\n # run the command, then call 'convert x:' to initiate a screen grab\n subprocess.call(command)\n cmdline = ['convert', 'x:', filename]\n subprocess.call(cmdline)\n # subprocess.Popen(cmdline)\n # simple command lines tend to be strings, more complex are lists\n # the text chunk requires a string; convert lists if necessary\n try:\n # test for list\n command.append('isList?')\n command.pop()\n command = ' '.join(command)\n except AttributeError:\n pass\n data = {}\n data['cwd'] = os.getcwd()\n timeobj = datetime.datetime.utcnow()\n # time = timeobj.strftime('%Y-%m-%d %X')\n data['utctime'] = timeobj.isoformat()\n data['timestamp'] = str(time.time())\n data['login'] = os.getlogin()\n data['command'] = command\n # data = {'cmdline':command, 'cwd':cwd, 'utctime':utctime, 'timestamp':timestamp}\n anno = annotate.AnnotatePng(filename, data)\n anno.save()\n return anno.filename\n\n"<<< >>>'def aag1(cmdline):\n """Automatic annotation grab\n\n This version munges the command line to create the filename\n """\n filename = \'_\'.join(cmdline)\n # attempt to make the command line a legal filename\n filename = filename.replace(\'.\',\'DOT\')\n filename = filename.replace(\'/\',\'SLASH\')\n filename = filename + \'.png\'\n filename = annograb(cmdline, filename)\n return filename\n\n'<<< >>>'def aag2(command, filename):\n """Automatic annotation grab\n\n Just an alias for annograb, to compliment aag1\n """\n filename = annograb(command, filename)\n return filename\n\n\n\n'<<< >>>'#@nonl\n#@-node:<>\n#@nl\n#@+others\n#@+node:swapcolors\ndef swapcolors(im1, im2):\n """exchange the palettes of im1 and im2, and return the images\n """\n import os.path\n # do we have file names?\n # TODO error check file names\n if type(im1) == str:\n try:\n im1 = Image.open(im1)\n except :\n print "not a valid file name"\n return\n if type(im2) == str:\n try:\n im2 = Image.open(im2) \n except:\n pass\n \n # indexed images are required\n if im1.mode == "RGB":\n im1 = RGB2L(im1)\n if im2.mode == "RGB":\n im2 = RGB2L(im2)\n \n # 2 step process is required, get the palette, then put it\n p1 = im1.getpalette()\n p2 = im2.getpalette()\n im1.putpalette(p2)\n im2.putpalette(p1)\n \n #TODO if indexed images were passed, return indexed.\n return L2RGB(im1), L2RGB(im2)\n#@nonl\n#@-node:swapcolors\n#@+node:L2RGB\n'<<< >>>'def L2RGB(im):\n """convert an indexed image to RGB\n """\n \n return im.convert("RGB")\n#@nonl\n#@-node:L2RGB\n#@+node:RGB2L\n'<<< >>>'def RGB2L(im):\n """convert an RGB image to indexed\n """\n \n return im.convert("P", dither=Image.NONE, palette=Image.ADAPTIVE)\n#@nonl\n#@-node:RGB2L\n#@+node:makethumb\n'<<< >>>'def makethumb(imfilename, indexed=True, moreinfo = None):\n """ Create a thumbnail image according to the\n `Thumbnail Managing Standards `__\n \n """\n # TODO \n largepath = r\'c:\\temp\\image\\large\'\n normalpath = r\'c:\\temp\\image\\normal\'\n failpath = r\'c:\\temp\\image\\fail\'\n\n p = path.path(imfilename)\n if not p.exists():\n raise IOError, "file %s does not exist" % imfilename\n \n # the uri of the source file, for the Thumb:URI field of the thumbnail data\n # use the function Jason Orendorff sent me \n uri = pathToURL(p)\n \n # per the standard, the thumb filename is a hash of the URI of the source\n hash = md5.md5(uri)\n fnamehash = hash.hexdigest()\n sourcefilename = \'%s.png\' % fnamehash\n \n # the normal and large thumbs are written to different directories\n thumbfilename128 = p.joinpath(normalpath, sourcefilename)\n thumbfilename256 = p.joinpath(largepath, sourcefilename) \n \n info = PngImagePlugin.PngInfo()\n info.add_text("Thumb::URI", uri)\n info.add_text("Thumb::MTime", str(p.getmtime() ))\n # more info is a list of key, value 2-tuples \n if moreinfo:\n for pair in moreinfo:\n info.add_text(pair[0], pair[1])\n \n # is the file a valid image? \n # we get the above information before checking because we use\n # it to write \'fail\' images\n try:\n im = Image.open(imfilename)\n # if not, create an empty image and save to the /fail directory\n except IOError:\n im = Image.new("1", (1,1))\n thumbfilenamefailed = p.joinpath(failpath, sourcefilename)\n info.add_text("Description", "PIL was unable to open this file") \n im.save(thumbfilenamefailed, pnginfo = info)\n return\n \n im128 = _makethumb(im, 128)\n im256 = _makethumb(im, 256)\n \n # in the interest of smaller thumbs, make indexed files\n if indexed:\n im128 = RGB2L(im128)\n im256 = RGB2L(im256)\n \n im128.save(thumbfilename128, pnginfo = info)\n im256.save(thumbfilename256, pnginfo = info) \n \n \n \n \n \n#@+node:@url http://triq.net/~jens/thumbnail-spec/index.html\n#@-node:@url http://triq.net/~jens/thumbnail-spec/index.html\n#@-node:makethumb\n#@+node:_makethumb\n'<<< >>>'def _makethumb(im, size):\n \n w = im.size[0] ; h = im.size[1]\n \n # im is already smaller than the thumb\n if w <= size and h <= size:\n return im\n \n # landscape\n if w > h:\n factor = float(w) / float(size)\n width = size\n height = int(float(h) / factor)\n # portrait or square\n else:\n factor = float(h) / float(size)\n height = size\n width = int(float(w) / factor)\n \n return im.resize((width, height), Image.ANTIALIAS)\n#@nonl\n#@-node:_makethumb\n#@+node:setwallpaper\n'<<< >>>'def setwallpaper(imfilename):\n \n # ctypes home http://starship.python.net/crew/theller/ctypes/\n \n from ctypes import *\n import win32con\n\n windll.user32.SystemParametersInfoA(win32con.SPI_SETDESKWALLPAPER, 0, imfilename, win32con.SPIF_SENDWININICHANGE) \n#@nonl\n#@-node:setwallpaper\n#@+node:pathToURL\n'<<< >>>'def pathToUrl(p):\n """ courtesy of Jason Orendorff, author of the \'path\' module\n """\n pieces = path.splitall()\n urlPieces = [urllib.quote(x) for x in pieces]\n return \'file:///\' + \'/\'.join(urlPieces)\n#@nonl\n#@-node:pathToURL\n#@+node:class Mim\n#class Mim(im):\n# """Managed Image\n# """\n#@nonl\n#@-node:class Mim\n#@+node:getLgradient\n'<<< >>>'def getLgradient(length, startvalue, endvalue):\n """\n length, startvalue and endvalue are integers\n return a list of length @length which consists\n of a transition from startvalue to endvalue\n """\n \n # extent is the range of color values to transition between\n extent = (endvalue - startvalue)\n\n # increment is a measure of the space\n # between pixels, there are one fewer spaces\n # than pixels. \n # The increment needs float precision\n increment = float(extent)/(length-1)\n \n # store the values in a list\n gradientband = []\n # build the list\n index = 0\n while index < length:\n # int() acts like floor(), use round() to get\n # the nearest integer\n value = int(round(startvalue + (index*increment)))\n gradientband.append(value)\n index = index+1\n\n return gradientband\n#@nonl\n#@-node:getLgradient\n#@+node:getRGBgradient\n'<<< >>>'def getRGBgradient(width, startvalue, endvalue):\n """\n startvalue and endvalue are RGB tuples.\n split startvalue and endvalue into 3 bands, create\n a gradient of each band, recombine into RGB tuples\n and return the list of tuples\n """\n \n red = getLgradient(width, startvalue[0], endvalue[0])\n green = getLgradient(width, startvalue[1], endvalue[1])\n blue = getLgradient(width, startvalue[2], endvalue[2])\n \n result = [0] * width\n \n for index in range(width):\n result[index] = (red[index], green[index], blue[index])\n \n return result\n \n \n#@-node:getRGBgradient\n#@+node:get2dgradient\n'<<< >>>'def get2dgradient(width, west, east):\n """west and east are same length lists of values\n return a list containing data for an image\n each row of the image transitions from the west value\n to the corresponding east value\n """\n \n assert len(west) == len(east)\n \n result = []\n \n for value in range(len(west)):\n gradient = getRGBgradient(width, west[value], east[value])\n result = result + gradient\n \n return result\n \n#@-node:get2dgradient\n#@+node:class Gradient\n'<<< >>>'def getrow(im, y):\n """return a list of pixel values for row at position y\n """\n\n datalist = list(im.getdata())\n startvalue = y * im.size[0]\n endvalue = startvalue + im.size[0]\n return datalist[startvalue:endvalue]\n#@nonl\n#@-node:getrow\n#@+node:getcolumn\n'<<< >>>'def getcolumn(im, x):\n """return a list of pixel values for the column at position x\n """\n # the following code doesn\'t work.\n # .translate rotates around a center point, and any pixels not\n # covered by rotation of the original image are set to black\n # rotate im 90 CCW (270 cw) and fetch a row\n ##rotim = im.transpose(Image.ROTATE_270)\n ##return getimagerow(rotim, x)\n \n data = list(im.getdata())\n column = []\n \n imwidth = im.size[0]\n imheight = im.size[1]\n \n for pixel in range(x, imwidth, imheight):\n column.append(data[pixel])\n \n return column\n \n#@nonl\n#@-node:getcolumn\n#@-others\n#@-node:@file imageutils.py\n#@-leo\n'<<< >>>'def _check_filename(filename):\n """Insure filename exists, return fqname or raise AnnotationError \n\n >>> from image import annotate; sssh = reload(annotate)\n >>> testimage = annotate._test_image()\n >>> print annotate._check_filename(testimage)\n /tmp/_test_image.png\n >>> print annotate._check_filename(\'HeyNoWay.png\')\n Traceback (most recent call last):\n ...\n AnnotationError\n >>>\n """\n filename = os.path.join(os.getcwd(), filename)\n if not os.path.exists(filename):\n raise AnnotationError\n return filename\n\n'<<< >>>'def _test_image(tmpname=\'/tmp/_test_image.png\'):\n """Convenience method, create an annotated image, return filename.\n\n >>> from image import annotate; sssh = reload(annotate)\n >>> annotate._test_image()\n \'/tmp/_test_image.png\'\n >>> \n """\n im = Image.new(\'RGB\', (10,10))\n info = PngInfo()\n info.add_text(key=\'_key\', value=\'_value\')\n im.save(tmpname, pnginfo=info)\n return tmpname\n\n'<<< Ups, it seems internal Pythoscope error occured. Please file a bug report at https://bugs.launchpad.net/pythoscope ============================================================ Traceback (most recent call last): File "/home/ktenney/work/virtualenv/bin/pythoscope", line 8, in load_entry_point('pythoscope==0.3', 'console_scripts', 'pythoscope')() File "/home/ktenney/work/virtualenv/lib/python2.5/site-packages/pythoscope-0.3-py2.5.egg/pythoscope/__init__.py", line 155, in main generate_tests(args, force, template) File "/home/ktenney/work/virtualenv/lib/python2.5/site-packages/pythoscope-0.3-py2.5.egg/pythoscope/__init__.py", line 94, in generate_tests inspect_project(project) File "/home/ktenney/work/virtualenv/lib/python2.5/site-packages/pythoscope-0.3-py2.5.egg/pythoscope/inspector/__init__.py", line 10, in inspect_project updates = add_and_update_modules(project) + add_and_update_points_of_entry(project) File "/home/ktenney/work/virtualenv/lib/python2.5/site-packages/pythoscope-0.3-py2.5.egg/pythoscope/inspector/__init__.py", line 34, in add_and_update_modules static.inspect_module(project, modpath) File "/home/ktenney/work/virtualenv/lib/python2.5/site-packages/pythoscope-0.3-py2.5.egg/pythoscope/inspector/static.py", line 111, in inspect_module return inspect_code(project, path, read_file_contents(path)) File "/home/ktenney/work/virtualenv/lib/python2.5/site-packages/pythoscope-0.3-py2.5.egg/pythoscope/inspector/static.py", line 118, in inspect_code visitor = descend(tree, ModuleVisitor) File "/home/ktenney/work/virtualenv/lib/python2.5/site-packages/pythoscope-0.3-py2.5.egg/pythoscope/astvisitor.py", line 55, in descend visitor.visit(tree) File "/home/ktenney/work/virtualenv/lib/python2.5/site-packages/pythoscope-0.3-py2.5.egg/pythoscope/astvisitor.py", line 227, in visit self.visit_node(tree) File "/home/ktenney/work/virtualenv/lib/python2.5/site-packages/pythoscope-0.3-py2.5.egg/pythoscope/astvisitor.py", line 241, in visit_node getattr(self, method)(results) File "/home/ktenney/work/virtualenv/lib/python2.5/site-packages/pythoscope-0.3-py2.5.egg/pythoscope/astvisitor.py", line 263, in _visit_all self.visit(results['nodes']) File "/home/ktenney/work/virtualenv/lib/python2.5/site-packages/pythoscope-0.3-py2.5.egg/pythoscope/astvisitor.py", line 230, in visit self.visit(subtree) File "/home/ktenney/work/virtualenv/lib/python2.5/site-packages/pythoscope-0.3-py2.5.egg/pythoscope/astvisitor.py", line 227, in visit self.visit_node(tree) File "/home/ktenney/work/virtualenv/lib/python2.5/site-packages/pythoscope-0.3-py2.5.egg/pythoscope/astvisitor.py", line 241, in visit_node getattr(self, method)(results) File "/home/ktenney/work/virtualenv/lib/python2.5/site-packages/pythoscope-0.3-py2.5.egg/pythoscope/astvisitor.py", line 273, in _visit_function body=results['body']) File "/home/ktenney/work/virtualenv/lib/python2.5/site-packages/pythoscope-0.3-py2.5.egg/pythoscope/inspector/static.py", line 80, in visit_function if is_generator_definition(body): File "/home/ktenney/work/virtualenv/lib/python2.5/site-packages/pythoscope-0.3-py2.5.egg/pythoscope/inspector/static.py", line 56, in is_generator_definition return compile(unindent(str(code)), '', 'single').co_consts[0].co_flags & 0x20 != 0 AttributeError: 'int' object has no attribute 'co_flags' ============================================================ On Wed, Oct 8, 2008 at 5:07 AM, Michal Kwiatkowski