From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1MTglP-0003dv-RB for garchives@archives.gentoo.org; Wed, 22 Jul 2009 18:42:04 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 3008CE01C4; Wed, 22 Jul 2009 18:42:02 +0000 (UTC) Received: from mail-bw0-f227.google.com (mail-bw0-f227.google.com [209.85.218.227]) by pigeon.gentoo.org (Postfix) with ESMTP id 9B072E01B5; Wed, 22 Jul 2009 18:42:01 +0000 (UTC) Received: by bwz27 with SMTP id 27so362754bwz.34 for ; Wed, 22 Jul 2009 11:42:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:from:to:cc :in-reply-to:references:content-type:date:message-id:mime-version :x-mailer; bh=b3yLd+vt6C4FdVSGRzW3L6pu/A/bMrEZ54U9MLvZRWc=; b=eZ0HqKWRqSN8U0lrDXvvDbY/aAJWsOFm9oXlHoVQrRqZgnwjzSkNzGPChgS3onJZmp f54Nm9jrkUSCKjrStNXZSN3eHG+tctbWxbNBiDq4zm4BWK2tKfBW1EIRcyJqLaX8u4TF gSueIPXFyBL2nEw9099w61kjNTim7PvxXJeeE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:cc:in-reply-to:references:content-type:date :message-id:mime-version:x-mailer; b=NUv/g4GtXYXdrOsYvLs5RvxHEmi7PLZA7gKA+Pidmz0ct3q50wWUhhZsMNT5+fqKdy E8hLkra/LqgmGM3bDa5dcVlwjxcwHkuJPGnxEVvdXHoKOLpC3WHtSr8olPa4mhmcoMsM 3Z2cxNVGFvba6uw1Pxtie8u89rADSn037dKDE= Received: by 10.103.173.15 with SMTP id a15mr640563mup.59.1248288120793; Wed, 22 Jul 2009 11:42:00 -0700 (PDT) Received: from ?192.168.127.16? (magdalene.ist.utl.pt [193.136.161.161]) by mx.google.com with ESMTPS id e10sm3409406muf.44.2009.07.22.11.41.59 (version=SSLv3 cipher=RC4-MD5); Wed, 22 Jul 2009 11:41:59 -0700 (PDT) Subject: [gentoo-dev] Re: Progress on Universal Select Tool From: =?ISO-8859-1?Q?S=E9rgio?= Almeida To: Gentoo SoC Cc: Gentoo Dev In-Reply-To: <1245163715.14589.515.camel@thedude> References: <1245163715.14589.515.camel@thedude> Content-Type: multipart/signed; micalg="pgp-sha1"; protocol="application/pgp-signature"; boundary="=-A8ued1YUaxygYy98zAvy" Date: Wed, 22 Jul 2009 19:41:57 +0100 Message-Id: <1248288117.7494.34.camel@thedude> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org Mime-Version: 1.0 X-Mailer: Evolution 2.26.1 X-Archives-Salt: e38a681c-3da3-45c6-baab-73384f922d50 X-Archives-Hash: 65a492531678320371c14e3f9fb5e776 --=-A8ued1YUaxygYy98zAvy Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello, This has been a very productive week regarding uselect. I'm still not doing any commits as uselect can still break your python environment while testing and i don't have the time to learn how to handle branches in git. Status: * Fully Converted all action types to new module syntax * Infinite symlinking dependency fully working * Runnable Actions now support dynamic usage showing An example fully commented module follows ### Start of Module #!/usr/bin/env python # Copyright 1999-2009 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # python.py mephx.x@gmail.com=20 # (will explain .py instead of .uselect below) # still lacking vim/emacs python line from umodule import *=20 # We Create The Module module =3D Module(name =3D "python", description =3D "Python Version Switcher", version =3D "0.1", author =3D"mephx.x@gmail.com") # We Create a Linking Action action_bin =3D Action (name =3D 'bin', description =3D "Change Python's Version", type =3D "sym") # We Create a Link link_python =3D Link(alias =3D "python", target =3D "/usr/bin/python", pref= ix =3D "/usr/bin/", regexp =3D "python([0-9]+\.[0-9]+$)") # We Create Another Link link_python_config =3D Link(alias =3D "python-config", target =3D "/usr/bin/python-config", prefix =3D "/usr/bin/", regexp =3D "python([0-9]+\.[0-9]+)-config$") # Make the link "python_config" depend of "link_python" link_python.add_link(link_python_config) # Add the link to the action action_bin.add_link(python) # Add the action to the module module.add_action(action_bin) # We create a simple runnable action that "tests" python environment test =3D Action (name =3D 'test', description =3D 'Test Python Environment'= , type =3D 'runnable') # We add the parameters/arguments test.add_parameter('') test.add_parameter('[]') # We add the usage code test.add_usage("""#!/usr/bin/python print "Python Test will echo * " print "Usage can be multi-line Yay!" print "" for i in range(5): print "Usage can have dynamic options! " + str(i) """) # We add the action code test.add_code("""#!/usr/bin/python import sys def is_number(s): try: int(s) return True except ValueError: return False =09 argv =3D sys.argv[1:] times =3D sys.argv[1:][0] if is_number(times): times =3D int(times)=09 if len(argv) >=3D 2: what =3D sys.argv[1:][1] else:=20 what =3D 'Hello World...' print str(what) * times else: print 'Invalid Option(s)' exit(1) exit(0) """) # We add the action to the module module.add_action(test) ### End of Module So... what's the output of this? ### Start Examples * uselect=20 Usage: uselect =20 Options: -v (*) Verbose Mode -nc (*) No Colors -version (*) Version Information Modules: python (*) Python Version Switcher gcc (*) Python GCC Version Switcher * uselect python Usage: uselect python =20 Module python: Author: mephx.x@gmail.com Version: 0.1 Actions: bin Change Python's Version test Test Python Environment * uselect python bin Usage: uselect python bin ... =20 Change Python's Version 0 - /usr/bin/python2.6 - (>) 1 - /usr/bin/python2.6-config - (>) 2 - /usr/bin/python2.5-config - (!) 3 - /usr/bin/python2.5 - (!) 4 - /usr/bin/python2.6-config - (>) 5 - /usr/bin/python2.5-config - (!) * uselect python bin 2 Setting /usr/bin/python2.5-config success! Setting /usr/bin/python2.6 success * uselect python bin (again) Usage: uselect python bin ... =20 Change Python's Version 0 - /usr/bin/python2.6 - (>) 1 - /usr/bin/python2.6-config - (!) 2 - /usr/bin/python2.5-config - (>) 3 - /usr/bin/python2.5 - (!) 4 - /usr/bin/python2.6-config - (>) 5 - /usr/bin/python2.5-config - (!) * uselect python test Usage: uselect python test []=20 Test Python Environment Python Test will echo * Usage can be multi-line Yay! =09 Usage can have dynamic options! 0 Usage can have dynamic options! 1 Usage can have dynamic options! 2 Usage can have dynamic options! 3 Usage can have dynamic options! 4 * uselect python test 10 "yeah! " yeahyeahyeahyeahyeahyeahyeahyeahyeahyeah I guess this is all for the past week. Symlinking dependency really cranked my brain and almost got me stuck. Next steps: * add the --system option for system-wide changes * Implement env actions * Structure folders ".uselect/" (probabily will have a bin folder and a env.d folder) * Start structuring uprofile application and api * Profiles will be xml/json (and will use this part of code to uselect too) * Call for ideas * Python gurus: Atm i'm retrieving the module from .uselect files this way: =20 def get_modules(self): self.modules =3D [] for module in filesystem.list_dir(modules_dir): if re.match('__init__.py$', module): continue match =3D re.match('(.*).py$', module) if match: import modules modname =3D match.group(1) modpath =3D 'modules.'+ modname __import__(modpath) module =3D eval(modpath + '.module') self.modules.append(module) =09 =20 This is a bit ugly. Should there be a better way? I can't seem to achieve one. This is the reason why new modules are still called module.py and not module.uselect as should be. =20 * If you are a developer of any eselect modules or something-config please reply with suggestions. All ideas are welcome. * Everyone else:=20 User profiles will stand in ~/.uselect Folder Profiles will stand in $FOLDER/.uselect What about group profiles? =20 Modules like bash-completion work in a "env.d" style. Should an action type be created for actions like these (I believe they are very common). =20 Well, all ideas are welcome again. P.S: I have successfully passed the first midterm evaluation. Thanks to everyone that has contributed to this new project, especially my mentor S=C3=A9bastien Fabbro (bicatali). Cheers, S=C3=A9rgio =20 --=20 S=C3=A9rgio Almeida - mephx.x@gmail.com mephx @ freenode --=-A8ued1YUaxygYy98zAvy Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEABECAAYFAkpnXW4ACgkQQXumuXcKj07bBACgr2NjZV47yIc6gWMS87YBzi/c /f0An14LASC0mX1UfLRsnJ6Xp/PQSfSj =FLRT -----END PGP SIGNATURE----- --=-A8ued1YUaxygYy98zAvy--