示例#1
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 version(self):
        print "SWAML 0.0.5",  #TODO: __init__.__version__
        sys.exit()

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

        if (base == None):
            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 == "--version":
                self.version()

        self.config.setAgent(
            'http://swaml.berlios.de/doap.rdf')  #TODO: how __init__.__agent__?
        self.parseArgs(argv)
        self.list = MailingList(self.config)
        messages = self.list.publish()
        print str(messages), 'messages procesed'
示例#2
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 version(self):
        print "SWAML 0.0.5", #TODO: __init__.__version__
        sys.exit()

    def __init__(self, argv, base=None):
        """
        main method
        @param argv: values of inline arguments
        """
        
        if (base == None):
            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 == "--version":
                self.version()
                
        self.config.setAgent('http://swaml.berlios.de/doap.rdf') #TODO: how __init__.__agent__?
        self.parseArgs(argv)
        self.list = MailingList(self.config)
        messages = self.list.publish()
        print str(messages), 'messages procesed'
示例#3
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(__agent__)
        self.parseArgs(argv)
        self.list = MailingList(self.config)
        messages = self.list.publish()
        print str(messages), "messages procesed"
示例#4
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'
示例#5
0
class SWAML:
    """
    Main class of SWAML project
    
    @autor: Sergio Fdez
    @license: GPL
    """

    def parseArgs(self, argv):
        """
        Getting params of default input
        """

        try:
            opts, args = getopt.getopt(argv, "d:u:m:f:k:h", ["dir=","url=","mbox=","format=","kml=","help"])
        except getopt.GetoptError:
            self.usage()

        for opt, arg in opts:
            if opt in ("-h", "--help"):
                self.usage()
            elif opt in ("-d", "--dir") and arg:
                self.config.set("dir", arg)
            elif opt in ("-u", "--url") and arg:
                self.config.set("url", arg)
            elif opt in ("-m", "--mbox") and arg:
                self.config.set("mbox", arg)
            elif opt in ("-f", "--format") and arg:
                self.config.set("format", arg)
            elif opt in ("-k", "--kml") and arg:
                self.config.set("kml", arg)                                      
            else:
                self.usage()
                
        #self.config.show()


    def usage(self):
        """
        Print help to use SWAML
        
        @todo: locate better name for format vars
        """
        
        print """
Usage: swaml.py [OPTIONS]
        
'swaml' transform the archives of a mailing list (in mbox format) into a semantic web friendly format (RDF in XML).

Options:

   -d DIR, --dir=DIR            : use DIR to publish the RDF files; 'archive/' is used by default.

   -u URL, --url=URL            : base URL to browse archives.

   -m MBOX, --mbox=MBOX         : open MBOX file, 'mbox' by default value.

   -f FORMAT, --format=FORMAT   : path pattern to store the messages. FORMAT is an string that can contain following keys:

                                   	'DD': number of day that message was sent
                                   	'MM': number of month that message was sent
                                   	'MMM': short month string that message was sent
                                   	'MMMM': long month string that message was sent
                                   	'YYYY': year that message was sent
                                   	'ID': message numeric id

                                  The string 'YYYY-MMM/messageID.rdf' is used by default, but you can compose the string
                                  as you want (for example something like 'YYYY/MM/DD/ID.rdf').
   
   -k {yes/no}, --kml={yes/no]  : flag to activate export KML support.                                 

   -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()
        self.config.setAgent(__url__)
        self.parseArgs(argv)
        self.list = MailingList(self.config)
        messages = self.list.publish()
        print str(messages), 'messages procesed'