<commit_before>#! /usr/bin/python
# -*- coding: utf-8 -*-
#-----------------------------------------------------------------------------
# Name:     DriverCli.py
# Purpose:
# Author:   <NAME> <<EMAIL>>
# Created:  16/07/2008
#-----------------------------------------------------------------------------
#  Copyright (2008)  Armadeus Systems
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
#-----------------------------------------------------------------------------
# Revision list :
#
# Date       By        Changes
#
#-----------------------------------------------------------------------------

__doc__ = ""
__version__ = "1.0.0"
__versionTime__ = "16/07/2008"
__author__ = "<NAME> <<EMAIL>>"

from periphondemand.bin.define import *
from periphondemand.bin.utils.basecli  import BaseCli
from periphondemand.bin.utils.settings import Settings
from periphondemand.bin.utils.error    import Error
from periphondemand.bin.utils.display  import Display
from periphondemand.bin.utils          import wrappersystem as sy

display  = Display()
settings = Settings()

class DriverCli(BaseCli):
    """
    """

    def __init__(self,parent):
        BaseCli.__init__(self,parent)
        self.driver = settings.active_project.driver
        self.project = settings.active_project

    def testIfToolChainSelected(self):
        if self.driver==None:
            raise Error("No toolchain selected (use selecttoolchain command)")

    def complete_generateproject(self,text,line,begidx,endidx):
        toollist = []
        try:
            toollist = self.completeargs(text,line,"[drivertoolchain]")
        except Exception,e:
            print e
        return toollist

    def do_generateproject(self,line):
        """\
Usage : generateproject
generate a project drivers directory with templates
        """
        try:
            self.testIfToolChainSelected()
            self.driver.generateProject()
            self.driver.fillAllTemplates()
        except Error,e:
            print display
            print e
            return
        print display

    def do_filltemplates(self,line):
        """\
Usage : filltemplates
fill drivers templates
        """
        try:
            self.testIfToolChainSelected()
            self.driver.fillAllTemplates()
        except Error,e:
            print display
            print e
            return
        print display

    def do_copydrivers(self,line):
        """\
Usage : copydrivers
copy drivers file in software developpement tree. Developpement tree
directory must be selected with setprojecttree
        """
        try:
            self.testIfToolChainSelected()
            self.driver.copyBSPDrivers()
        except Error,e:
            print display
            print e
            return
        print display

    def complete_selectprojecttree(self,text,line,begidx,endidx):
        """complete selectprojecttree command directories """
        path = line.split(" ")[1]
        if path.find("/") == -1: # sub
            path = ""
        elif text.split() == "": # sub/sub/
            path = "/".join(path)+"/"
        else: # sub/sub
            path = "/".join(path.split("/")[0:-1]) + "/"
        listdir = sy.listDirectory(path)
        return self.completelist(line,text,listdir)

    def do_selectprojecttree(self,line):
        """\
Usage : setprojecttree [directory]
select software developpement tree, to copy driver
        """
        try:
            self.testIfToolChainSelected()
            self.checkargs(line,"[osdirectory]")
            self.driver.setBSPDirectory(line)<commit_msg>[bin][commandline][drivercli] do not check arguments consistency for selectprojecttree<commit_after>#! /usr/bin/python
# -*- coding: utf-8 -*-
#-----------------------------------------------------------------------------
# Name:     DriverCli.py
# Purpose:
# Author:   <NAME> <<EMAIL>>
# Created:  16/07/2008
#-----------------------------------------------------------------------------
#  Copyright (2008)  Armadeus Systems
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
#-----------------------------------------------------------------------------
# Revision list :
#
# Date       By        Changes
#
#-----------------------------------------------------------------------------

__doc__ = ""
__version__ = "1.0.0"
__versionTime__ = "16/07/2008"
__author__ = "<NAME> <<EMAIL>>"

from periphondemand.bin.define import *
from periphondemand.bin.utils.basecli  import BaseCli
from periphondemand.bin.utils.settings import Settings
from periphondemand.bin.utils.error    import Error
from periphondemand.bin.utils.display  import Display
from periphondemand.bin.utils          import wrappersystem as sy

display  = Display()
settings = Settings()

class DriverCli(BaseCli):
    """
    """

    def __init__(self,parent):
        BaseCli.__init__(self,parent)
        self.driver = settings.active_project.driver
        self.project = settings.active_project

    def testIfToolChainSelected(self):
        if self.driver==None:
            raise Error("No toolchain selected (use selecttoolchain command)")

    def complete_generateproject(self,text,line,begidx,endidx):
        toollist = []
        try:
            toollist = self.completeargs(text,line,"[drivertoolchain]")
        except Exception,e:
            print e
        return toollist

    def do_generateproject(self,line):
        """\
Usage : generateproject
generate a project drivers directory with templates
        """
        try:
            self.testIfToolChainSelected()
            self.driver.generateProject()
            self.driver.fillAllTemplates()
        except Error,e:
            print display
            print e
            return
        print display

    def do_filltemplates(self,line):
        """\
Usage : filltemplates
fill drivers templates
        """
        try:
            self.testIfToolChainSelected()
            self.driver.fillAllTemplates()
        except Error,e:
            print display
            print e
            return
        print display

    def do_copydrivers(self,line):
        """\
Usage : copydrivers
copy drivers file in software developpement tree. Developpement tree
directory must be selected with setprojecttree
        """
        try:
            self.testIfToolChainSelected()
            self.driver.copyBSPDrivers()
        except Error,e:
            print display
            print e
            return
        print display

    def complete_selectprojecttree(self,text,line,begidx,endidx):
        """complete selectprojecttree command directories """
        path = line.split(" ")[1]
        if path.find("/") == -1: # sub
            path = ""
        elif text.split() == "": # sub/sub/
            path = "/".join(path)+"/"
        else: # sub/sub
            path = "/".join(path.split("/")[0:-1]) + "/"
        listdir = sy.listDirectory(path)
        return self.completelist(line,text,listdir)

    def do_selectprojecttree(self,line):
        """\
Usage : setprojecttree [directory]
select software developpement tree, to copy driver
        """
        try:
            self.testIfToolChainSelected()
            self.driver.setBSPDirectory(line)
{'fraction_non_alphanumeric': 0.16157102539981186, 'fraction_numerical': 0.01011288805268109, 'mean_word_length': 1.9551772063933286, 'pattern_counts': {'":': 2, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1535014', 'n_tokens_mistral': 2252, 'n_tokens_neox': 2161, 'n_words': 645}