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 1SZgcg-0005xQ-6n for garchives@archives.gentoo.org; Wed, 30 May 2012 10:59:26 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 3FF41E05ED; Wed, 30 May 2012 10:58:59 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id F2D50E05ED for ; Wed, 30 May 2012 10:58:58 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 27B761B4022 for ; Wed, 30 May 2012 10:58:58 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 04BF3E543A for ; Wed, 30 May 2012 10:58:55 +0000 (UTC) From: "André Erdmann" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "André Erdmann" Message-ID: <1338375503.d42aeffc50fdee5f835b06910f0792ba079e4ddc.dywi@gentoo> Subject: [gentoo-commits] proj/R_overlay:master commit in: roverlay/ X-VCS-Repository: proj/R_overlay X-VCS-Files: roverlay/ebuildjob.py X-VCS-Directories: roverlay/ X-VCS-Committer: dywi X-VCS-Committer-Name: André Erdmann X-VCS-Revision: d42aeffc50fdee5f835b06910f0792ba079e4ddc X-VCS-Branch: master Date: Wed, 30 May 2012 10:58:55 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: b2d87f54-44ee-4793-a867-b8d1cad193fd X-Archives-Hash: 2eeca09032907474a04e8c7bebd8d013 commit: d42aeffc50fdee5f835b06910f0792ba079e4ddc Author: Andre Erdmann mailerd de> AuthorDate: Wed May 30 10:56:32 2012 +0000 Commit: Andr=C3=A9 Erdmann mailerd de> CommitDate: Wed May 30 10:58:23 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/R_overlay.git= ;a=3Dcommit;h=3Dd42aeffc roverlay, ebuildjob: fix imports, run () creates an ebuild now --- roverlay/ebuildjob.py | 105 ++++++++++++++++++++++++++++++++++++++++++-= ------ 1 files changed, 90 insertions(+), 15 deletions(-) diff --git a/roverlay/ebuildjob.py b/roverlay/ebuildjob.py index 0861b22..171150c 100644 --- a/roverlay/ebuildjob.py +++ b/roverlay/ebuildjob.py @@ -2,11 +2,12 @@ # Copyright 2006-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 =20 -from roverlay import ebuildcreator.EbuildCreator -from roverlay import fileio.DescriptionReader -from roverlay import ebuild.Ebuild +from roverlay.fileio import DescriptionReader +from roverlay.ebuild import Ebuild =20 class EbuildJob: + STATUS_LIST =3D [ 'INIT', 'BUSY', 'WAIT', 'SUCCESS', 'FAIL' ] + STATUS_MAP =3D dict ( ( name, code ) for code, name in enumerate ( STA= TUS_LIST ) ) =20 @classmethod def __init__ ( self, package_file, dep_resolver=3DNone ): @@ -14,10 +15,26 @@ class EbuildJob: self.dep_resolver =3D dep_resolver # get description reader from args? self.description_reader =3D DescriptionReader() - self.ebuild =3D Ebuild() =20 - self.status =3D 0 # todo + self.ebuild =3D None =20 + self._status =3D 0 # todo + + # --- end of __init__ (...) --- + + @staticmethod + def get_statuscode ( status_id ): + if status_id =3D=3D 'ALL': + return EbuildJob.STATUS_LIST + elif isinstance ( status_id, int ): + if status_id > 0 and status_id < len ( STATUS_LIST ): + return EbuildJob.STATUS_LIST [status_id] + elif status_id in EbuildJob.STATUS_MAP: + return EbuildJob.STATUS_MAP [status_id] + + return None + + # --- end of get_statuscode (...) --- =20 @classmethod def status ( self, expected_status=3DNone ): @@ -28,18 +45,35 @@ class EbuildJob: * expected_status -- if not None: check if this job's state is expecte= d_status """ if expected_status: - return self.status - else: - return bool ( self.status =3D=3D expected_status ) + if isinstance ( expected_status, int ): + return bool ( self._status =3D=3D expected_status ) + elif expected_status in EbuildJob.STATUS_MAP: + return bool ( self._status =3D=3D EbuildJob.STATUS_MAP [expected_sta= tus] ) + else: + return False + + return self._status + + # --- end of status (...) --- =20 @classmethod def get_ebuild ( self ): """Returns the Ebuild that is created by this object. Note that you sh= ould check the status with status ( $TODO::EBUILD_READY ) before trying to = use the Ebuild. + ##fixme: it is guaranteed that self.ebuild is None unless the Ebuild i= s successfully created## """ return self.ebuild =20 + # --- end of get_ebuild (...) --- + + @classmethod + def _set_status ( self, new_status ): + self._status =3D EbuildJob.get_statuscode ( new_status ) + return True + + # --- end of _set_status (...) --- + =20 @classmethod def run ( self ): @@ -49,17 +83,58 @@ class EbuildJob: """ =20 # check status - ## + if not self.status ( 'INIT' ): + return + + if not self._set_status ( 'BUSY' ): + return False =20 read_data =3D self.description_reader.readfile ( self.package_file ) =20 - if read_data is None + if read_data is None: # set status accordingly - return None + self._set_status ( 'FAIL' ) + return False =20 - # transfer data from read_data to self.ebuild - # have to resolve deps here - # + fileinfo =3D read_data ['fileinfo'] + desc =3D read_data ['description_data'] + + ebuild =3D Ebuild() + + have_description =3D False + + print ( str ( desc ) ) + + if 'Title' in desc: + have_description =3D True + ebuild.add ( 'DESCRIPTION', desc ['Title'] ) + + if 'Description' in desc: + have_description =3D True + ebuild.add ( 'DESCRIPTION', ( '// ' if have_description else '' ) + d= esc ['Description'] ) + + if not have_description: + ebuild.add ( 'DESCRIPTION', '' ) + del have_description + + # origin is todo (sync module knows the package origin) + ebuild.add ( 'PKG_ORIGIN', 'CRAN' ) + + ebuild.add ( 'PKG_FILE', fileinfo ['package_file'] ) + + ebuild.add ( 'ebuild_header', [ '# test header' ], False ) + + ## have to resolve deps here + + # enter status that allows transferring ebuild -> self.ebuild + if self._set_status ( 'WAIT' ): + # finalize self.ebuild: forced text creation + make it readonly + if ebuild.prepare ( True, True ): + self.ebuild =3D ebuild + return self._set_status ( 'SUCCESS' ) + + self._set_status ( 'FAIL' ) + return False =20 - return None =20 + # --- end of run (...) ---