コード例 #1
0
ファイル: swaml.py プロジェクト: BackupTheBerlios/swaml-svn
class SWAML(CommandLineUI):
    """
    Main class of SWAML project
    
    @author: Sergio Fdez
    @license: GPL
    """

    def parseArgs(self, argv):
        """
        Getting params of default input
        
        @param argv: arguments values array
        """
        
        if not self.config.parse(argv):
            self.usage()
            
        #self.config.show()

    def __init__(self, argv):
        """
        main method
        @param argv: values of inline arguments
        @param base: base dir
        """
        
        path = __file__.split('/')
        base = '/'.join(path[:-1]) + '/'
        CommandLineUI.__init__(self, 'swaml', base)
        
        self.config = Configuration()        
        
        for arg in argv:
            if arg == "-h" or arg == "--help":
                self.usage()
            elif arg == "-v" or arg == "--verbose":
                self.config.set('verbose', True)
                
        self.config.setAgent('http://swaml.berlios.de/doap.rdf')
        self.parseArgs(argv)
        self.list = MailingList(self.config)
        messages = self.list.publish()
        print str(messages), 'messages procesed'
コード例 #2
0
class ConfigWizard(CommandLineUI):
    """
    SWAML's config wizard
    
    @author: Sergio Fdez
    @license: GPL
    """
    
    def requestData(self):
        """
        Queries the user a new configuration
        """
        
        self.config = Configuration()
        
        print 'Write your configuration options:'
        print '(default value goes between [...])'
        
        for var in self.config.config.keys():
            defaultValue = str(self.config.config[var])
            value = raw_input('\t - ' + var + '[' + defaultValue + ']: ')
            if (len(value) > 0):
                self.config.set(var, value)
    
    def printData(self):
        """
        Dump on hard disk the configuration
        """
        
        ini = ConfigParser.ConfigParser()
        
        ini.add_section(self.section)
        
        for var in self.config.config.keys():
            ini.set(self.section, var, str(self.config.config[var]))
                     
        try:
            file = open(self.output, 'w+')
            ini.write(file)
            file.flush()
            file.close()
            print 'new config file created in', self.output, 'with chosen parameters'
        except IOError, detail:
            print 'Error exporting coordinates config file: ' + str(detail)
コード例 #3
0
class ConfigWizard(CommandLineUI):
    """
    SWAML's config wizard
    
    @author: Sergio Fdez
    @license: GPL
    """
    def requestData(self):
        """
        Queries the user a new configuration
        """

        self.config = Configuration()

        print 'Write your configuration options:'
        print '(default value goes between [...])'

        for var in self.config.config.keys():
            defaultValue = str(self.config.config[var])
            value = raw_input('\t - ' + var + '[' + defaultValue + ']: ')
            if (len(value) > 0):
                self.config.set(var, value)

    def printData(self):
        """
        Dump on hard disk the configuration
        """

        ini = ConfigParser.ConfigParser()

        ini.add_section(self.section)

        for var in self.config.config.keys():
            ini.set(self.section, var, str(self.config.config[var]))

        try:
            file = open(self.output, 'w+')
            ini.write(file)
            file.flush()
            file.close()
            print 'new config file created in', self.output, 'with chosen parameters'
        except IOError, detail:
            print 'Error exporting coordinates config file: ' + str(detail)
コード例 #4
0
class SWAML(CommandLineUI):
    """
    Main class of SWAML project
    
    @author: Sergio Fdez
    @license: GPL
    """
    def parseArgs(self, argv):
        """
        Getting params of default input
        
        @param argv: arguments values array
        """

        if not self.config.parse(argv):
            self.usage()

        #self.config.show()

    def __init__(self, argv):
        """
        main method
        @param argv: values of inline arguments
        @param base: base dir
        """

        path = __file__.split('/')
        base = '/'.join(path[:-1]) + '/'
        CommandLineUI.__init__(self, 'swaml', base)

        self.config = Configuration()

        for arg in argv:
            if arg == "-h" or arg == "--help":
                self.usage()
            elif arg == "-v" or arg == "--verbose":
                self.config.set('verbose', True)

        self.config.setAgent('http://swaml.berlios.de/doap.rdf')
        self.parseArgs(argv)
        self.list = MailingList(self.config)
        messages = self.list.publish()
        print str(messages), 'messages procesed'
コード例 #5
0
ファイル: swaml.py プロジェクト: BackupTheBerlios/swaml-svn
class SWAML:
    """
    Main class of SWAML project
    
    @author: Sergio Fdez
    @license: GPL
    """

    def parseArgs(self, argv):
        """
        Getting params of default input
        
        @param argv: arguments values array
        """

        if not self.config.parse(argv):
            self.usage()

        # self.config.show()

    def usage(self):
        """
        Print help to use SWAML
        
        @todo: locate better name for format vars
        """

        print """
Usage: swaml.py configfile [options]
        
'swaml' transform the archives of a mailing list (in mbox format) into a semantic web friendly format (RDF in XML).

   'configfile'      : path to a configuration file compatible with RFC822.

Options:
   -v, --verbose     : turn on verbose mode.
   -V, --version     : show version.
   -h, --help        : print this help message and exit.

Report bugs to: <http://swaml.berlios.de/bugs>

"""
        sys.exit()

    def __init__(self, argv):
        """
        main method
        @param argv: values of inline arguments
        """

        self.config = Configuration()

        for arg in argv:
            if arg == "-h" or arg == "--help":
                self.usage()
            elif arg == "-v" or arg == "--verbose":
                self.config.set("verbose", True)

        self.config.setAgent(__agent__)
        self.parseArgs(argv)
        self.list = MailingList(self.config)
        messages = self.list.publish()
        print str(messages), "messages procesed"
コード例 #6
0
class SWAML:
    """
    Main class of SWAML project
    
    @author: Sergio Fdez
    @license: GPL
    """
    def parseArgs(self, argv):
        """
        Getting params of default input
        
        @param argv: arguments values array
        """

        if not self.config.parse(argv):
            self.usage()

        #self.config.show()

    def usage(self):
        """
        Print help to use SWAML
        
        @todo: locate better name for format vars
        """

        print """
Usage: swaml.py configfile [options]
        
'swaml' transform the archives of a mailing list (in mbox format) into a semantic web friendly format (RDF in XML).

   'configfile'      : path to a configuration file compatible with RFC822.

Options:
   -v, --verbose     : turn on verbose mode.
   -V, --version     : show version.
   -h, --help        : print this help message and exit.

Report bugs to: <http://swaml.berlios.de/bugs>

"""
        sys.exit()

    def __init__(self, argv):
        """
        main method
        @param argv: values of inline arguments
        """

        self.config = Configuration()

        for arg in argv:
            if arg == "-h" or arg == "--help":
                self.usage()
            elif arg == "-v" or arg == "--verbose":
                self.config.set('verbose', True)

        self.config.setAgent('http://swaml.berlios.de/doap.rdf')
        self.parseArgs(argv)
        self.list = MailingList(self.config)
        messages = self.list.publish()
        print str(messages), 'messages procesed'