[Dev OpenGP] [48] Let's clean some stuff! |
[ Thread Index |
Date Index
| More opengp.tuxfamily.org/development Archives
]
Revision: 48
Author: alband85
Date: 2009-03-18 13:06:58 +0100 (Wed, 18 Mar 2009)
Log Message:
-----------
Let's clean some stuff!
Added Paths:
-----------
trunk/CA/
Removed Paths:
-------------
trunk/src/AbstractMethod.py
trunk/src/DomElementMethods/
trunk/src/DomElementMethods-test.py
trunk/src/Metaclass.py
trunk/src/OgpCore.py
trunk/src/OgpLDAPConsts.py
trunk/src/Plugin.py
trunk/src/merge-test.py
trunk/src/ogpconsole
trunk/src/text.py
trunk/src/xslt/
Deleted: trunk/src/AbstractMethod.py
===================================================================
--- trunk/src/AbstractMethod.py 2009-03-18 09:55:12 UTC (rev 47)
+++ trunk/src/AbstractMethod.py 2009-03-18 12:06:58 UTC (rev 48)
@@ -1,52 +0,0 @@
-# See http://code.activestate.com/recipes/266468/ for further details
-#
-# Note for further versions: http://docs.python.org/library/abc.html
-# Abstract base classes will be supported in Python 2.6
-
-
-class AbstractMethod (object):
- """Defines a class to create abstract methods
-
- @example:
- class Foo:
- foo = AbstractMethod('foo')
- """
-
- def __init__(self, func):
- """Constructor
-
- @params func: name of the function (used when raising an
- exception).
- @type func: str
- """
- self._function = func
-
- def __get__(self, obj, type):
- """Get callable object
-
- @returns An instance of AbstractMethodHelper.
-
- This trickery is needed to get the name of the class for which
- an abstract method was requested, otherwise it would be
- sufficient to include a __call__ method in the AbstractMethod
- class itself.
- """
- return self.AbstractMethodHelper(self._function, type)
-
-class AbstractMethodHelper (object):
- """Abstract method helper class
-
- An AbstractMethodHelper instance is a callable object that
- represents an abstract method.
- """
- def __init__(self, func, cls):
- self._function = func
- self._class = cls
-
- def __call__(self, *args, **kwargs):
- """Call abstract method
-
- Raises a TypeError, because abstract methods can not be
- called.
- """
- raise TypeError('Abstract method `' + self._class.__name__ + '.' + self._function + '\' called')
Deleted: trunk/src/DomElementMethods-test.py
===================================================================
--- trunk/src/DomElementMethods-test.py 2009-03-18 09:55:12 UTC (rev 47)
+++ trunk/src/DomElementMethods-test.py 2009-03-18 12:06:58 UTC (rev 48)
@@ -1,74 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*
-from lxml.etree import *
-from DomElementMethods import *
-
-obj = Element("rootelement")
-obj2 = Element("rootelement")
-
-print "------ BLOCKING ------"
-print obj.toString()
-obj.blocking = True
-print obj.toString()
-obj.blocking = False
-print obj.toString()
-print "------- ADD --------"
-elt = Element("inserted")
-elt2 = Element("inserted")
-obj.append(elt)
-try:
- obj.append(elt2)
-except OgpXmlError:
- print "crash"
-
-print obj.toString()
-
-print "------ DEL -------"
-print obj.toString()
-obj.delElements()
-print obj.toString()
-
-print "------ EXTEND -------"
-print obj.toString()
-try:
- obj.extend([elt, elt2])
-except:
- print "crash"
-print obj.toString()
-obj.delElements()
-elt3 = Element("pouet3")
-obj.extend([elt, elt3])
-print obj.toString()
-
-print "--------- MERGE ----------"
-print (obj.text is None)
-print (obj2.text is None)
-obj.delElements()
-obj2.delElements()
-obj.append(elt)
-obj2.append(elt3)
-print obj.toString()
-print obj2.toString()
-obj2.merge(obj)
-print tostring(obj2)
-
-print " Avec du texte maintenant"
-obj3 = Element("AAA")
-obj4 = Element("AAA")
-obj3.text = "pouet"
-obj4.text = "I'm not dead"
-print tostring(obj3)
-print tostring(obj4)
-obj4.merge(obj3)
-print tostring(obj3)
-print tostring(obj4)
-
-print " -------SETTEXT----------"
-obj.delElements()
-obj.append(elt)
-print obj.toString()
-obj.text = "toto"
-print obj.text
-print obj.toString()
-
-
Deleted: trunk/src/Metaclass.py
===================================================================
--- trunk/src/Metaclass.py 2009-03-18 09:55:12 UTC (rev 47)
+++ trunk/src/Metaclass.py 2009-03-18 12:06:58 UTC (rev 48)
@@ -1,51 +0,0 @@
-# For more informations, see http://code.activestate.com/recipes/266468/
-
-from AbstractMethod import AbstractMethod
-
-class Metaclass (type):
-
- def __init__(cls, name, bases, *args, **kwargs):
- """Configure a new class
-
- @param cls: Class object
- @param name: Name of the class
- @param bases: All base classes for cls
- """
- super(Metaclass, cls).__init__(cls, name, bases, *args, **kwargs)
-
- # Detach cls.new() from class Metaclass, and make it a method
- # of cls.
- cls.__new__ = staticmethod(cls.new)
-
- # Find all abstract methods, and assign the resulting list to
- # cls.__abstractmethods__, so we can read that variable when a
- # request for allocation (__new__) is done.
- abstractmethods = []
- ancestors = list(cls.__mro__)
- ancestors.reverse() # Start with __builtin__.object
- for ancestor in ancestors:
- for clsname, clst in ancestor.__dict__.items():
- if isinstance(clst, AbstractMethod):
- abstractmethods.append(clsname)
- else:
- if clsname in abstractmethods:
- abstractmethods.remove(clsname)
-
- abstractmethods.sort()
- setattr(cls, '__abstractmethods__', abstractmethods)
-
- def new(self, cls, *args, **kwargs):
- """Allocator for class cls
-
- @param self: Class object for which an instance should be
- created.
-
- @param cls: Same as self.
- """
- if len(cls.__abstractmethods__):
- raise NotImplementedError('Can\'t instantiate class `' + \
- cls.__name__ + '\';\n' + \
- 'Abstract methods: ' + \
- ", ".join(cls.__abstractmethods__))
-
- return object.__new__(self)
Deleted: trunk/src/OgpCore.py
===================================================================
--- trunk/src/OgpCore.py 2009-03-18 09:55:12 UTC (rev 47)
+++ trunk/src/OgpCore.py 2009-03-18 12:06:58 UTC (rev 48)
@@ -1,94 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*
-
-import ldap
-import ldap.modlist as modlist
-from OgpLDAPConsts import *
-
-class OgpCore(object):
-
- __instance = None
-
- def __init__(self, uri, dn=None, passwd=None, certs=None):
- """ Create singleton instance """
- # Check whether we already have an instance
- if OgpCore.__instance is None:
- # Create and remember instance
- OgpCore.__instance = OgpCore.__ogpcore(uri, dn, passwd, certs)
- # Store instance reference as the only member in the handle
- self.__dict__['OgpCore__instance'] = OgpCore.__instance
-
- def __getattr__(self, attr):
- """ Delegate access to implementation """
- return getattr(self.__instance, attr)
-
- def __setattr__(self, attr, value):
- """ Delegate access to implementation """
- return setattr(self.__instance, attr, value)
-
- def getInstance():
- return OgpCore.__instance
- getInstance = staticmethod(getInstance)
-
- class __ogpcore:
-
- def __init__(self, uri, dn=None, passwd=None, certs=None):
- """
- Initlialize connection to LDAP server.
- uri: ldap://host:port
- dn: usdr dn
- passwd: user password
- certs: path to cert file (.pem)
- """
- self.l = ldap.initialize(uri)
- self.l.simple_bind_s(dn, passwd)
-
- def __del__(self):
- self.l.unbind_s()
-
- def createOU(self, dn, description=None):
- attrs = {}
- attrs['objectclass'] = OgpLDAPConsts.OBJECTCLASS_OU
- attrs[OgpLDAPConsts.ATTR_OGPSOA] = OgpLDAPConsts.VALUE_OGPSOA
- attrs[OgpLDAPConsts.ATTR_DESCRIPTION] = description
- attrs[OgpLDAPConsts.ATTR_CONFIG] = OgpLDAPConsts.VALUE_CONFIG
- self.__add(dn, attrs)
-
- def deleteDN(self, dn):
- #self.__delete(dn)
- pass
-
-
- def __add(self, dn, attrs):
- ldif = modlist.addModlist(attrs)
- self.l.add_s(dn,ldif)
-
- def __delete(self, dn):
- self.l.delete_s(dn)
-
- def createMachine(self, dn, others={}):
- attrs = others
- attrs['objectClass'] = OgpLDAPConsts.OBJECTCLASS_MACHINE
- attrs[OgpLDAPConsts.ATTR_OGPSOA] = OgpLDAPConsts.VALUE_OGPSOA
- try:
- attrs[OgpLDAPConsts.ATTR_SAMACCOUNTNAME]
- except:
- attrs[OgpLDAPConsts.ATTR_SAMACCOUNTNAME] = OgpLDAPConsts.VALUE_SAMACCOUNTNAME
- try:
- attrs[OgpLDAPConsts.ATTR_OBJECTSID]
- except:
- attrs[OgpLDAPConsts.ATTR_OBJECTSID] = OgpLDAPConsts.VALUE_OBJECTSID
- attrs[OgpLDAPConsts.ATTR_CONFIG] = OgpLDAPConsts.VALUE_CONFIG
- self.__add(dn, attrs)
-
- def merge(self, parent, child):
- pass
-
- def xml2conf(self, xml, xslt):
- return # TODO
-
- def pullPluginConf(self, dn, pluginName, fullTree=False):
- pass
-
- def pushPluginConf(self, dn, conf):
- pass
Deleted: trunk/src/OgpLDAPConsts.py
===================================================================
--- trunk/src/OgpLDAPConsts.py 2009-03-18 09:55:12 UTC (rev 47)
+++ trunk/src/OgpLDAPConsts.py 2009-03-18 12:06:58 UTC (rev 48)
@@ -1,19 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*
-
-class OgpLDAPConsts:
-
- OBJECTCLASS_OU = "oGPOrganizationalUnit"
- OBJECTCLASS_MACHINE = "oGPComputer"
-
- ATTR_DESCRIPTION = "description"
- ATTR_CONFIG = "oGPXMLConfig"
- ATTR_SAMACCOUNTNAME = "sAMAccountName"
- ATTR_OBJECTSID = "objectSid"
- ATTR_OGPSOA = "oGPSOA"
- ATTR_MACHINECERTIFICATE = "oGPMachineCertificate"
-
- VALUE_CONFIG = "<conf></conf>"
- VALUE_SAMACCOUNTNAME = "N/A"
- VALUE_OBJECTSID = "\0"
- VALUE_OGPSOA = "0"
Deleted: trunk/src/Plugin.py
===================================================================
--- trunk/src/Plugin.py 2009-03-18 09:55:12 UTC (rev 47)
+++ trunk/src/Plugin.py 2009-03-18 12:06:58 UTC (rev 48)
@@ -1,49 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*
-
-from Metaclass import Metaclass
-from AbstractMethod import AbstractMethod
-
-class Plugin (object):
- __metaclass__ = Metaclass
-
- def __init__(self, dn):
- self.__dn = dn
-
- def getPluginFromName(plugin):
- return
- getPluginFromName = staticmethod('getPluginFromName')
-
- # Abstract methods
- #mergeDescription = AbstractMethod('mergeDescription')
-
- def getName():
- return ""
-
- def installConf(self):
- pass
-
- def help(self, cmd):
- pass
-
- def runCommand(self, argv):
- pass
-
- def update(self):
- """
- Commit changes
- """
- pass
-
- def cancel(self):
- """
- Do not commit and delete changes.
- """
- pass
-
- def pullFile(self, file, fullTree=False):
- pass
-
- def pushFile(self, file, content):
- pass
-
Deleted: trunk/src/merge-test.py
===================================================================
--- trunk/src/merge-test.py 2009-03-18 09:55:12 UTC (rev 47)
+++ trunk/src/merge-test.py 2009-03-18 12:06:58 UTC (rev 48)
@@ -1,13 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*
-from lxml.etree import *
-from DomElementMethods import *
-import StringIO
-
-parent=fromstring('<ogp><a>parent</a><b block="True">parent</b><c><parent/></c></ogp>', OGP_PARSER)
-child=fromstring('<ogp><a>child</a><b>child</b><c><child/></c></ogp>', OGP_PARSER)
-
-print "parent :\n" + parent.toString()
-print "child :\n" + child.toString()
-parent.merge(child)
-print "merge :\n" + parent.toString()
Deleted: trunk/src/ogpconsole
===================================================================
--- trunk/src/ogpconsole 2009-03-18 09:55:12 UTC (rev 47)
+++ trunk/src/ogpconsole 2009-03-18 12:06:58 UTC (rev 48)
@@ -1,3 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*
-
Deleted: trunk/src/text.py
===================================================================
--- trunk/src/text.py 2009-03-18 09:55:12 UTC (rev 47)
+++ trunk/src/text.py 2009-03-18 12:06:58 UTC (rev 48)
@@ -1,9 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*
-from DomElementMethods import *
-
-obj = Element("AAA")
-obj.text = "pouet"
-print obj.text
-obj.tail = "test"
-print tostring(obj)