Commit b4727d55 authored by Penom Nom's avatar Penom Nom

tx_ng6_upgrade.php is updated with a function to update typo3 sys_refindex....

tx_ng6_upgrade.php is updated with a function to update typo3 sys_refindex. Also update jflow extparser
parent f434b465
......@@ -16,6 +16,8 @@
#
import os
from jflow.component import Component
class ExternalParser(object):
def parse_directory(self, component_directory):
......@@ -28,3 +30,86 @@ class ExternalParser(object):
def parse(self, component_file):
raise NotImplementedError
def build_component(self, component_name, fn_define_parameters, **kwargs):
"""
Build and return an external component. The 3 methods get_abstraction, get_command and define_parameters must
be defined. Any other attribut can be added to the class definition using **kwargs
@param component_name: new component type name
@param fn_define_parameters: callable which overload the define_parameters function of component
@param kwargs: any other method or attribut that must be added or overloaded in this new class definition
"""
assert hasattr(fn_define_parameters, '__call__'), "The fn_define_parameters attribut must be callable"
options = {'define_parameters' : fn_define_parameters }
if kwargs :
for key, val in kwargs.items() :
options[key] = val
ComponentType = type(component_name, (_SerializableNestedComponent,),options)
setattr(_ExternalComponentFactory, component_name, ComponentType)
return ComponentType
class _NestedClassGetter(object):
"""
Altered version of what stands here :
http://stackoverflow.com/questions/1947904/how-can-i-pickle-a-nested-class-in-python
_NestedClassGetter is a callable that will be called by __reduce__ for serialization
and that will provide us with an instance of our nested class
used for nested object serialization.
When called with the containing class as the first argument,
and the name of the nested class as the second argument,
returns an instance of the nested class.
"""
def __call__(self, containing_class, class_name):
nested_class = getattr(containing_class, class_name)
# make an instance of a simple object, for which we can change the __class__ later on.
nested_instance = _NestedClassGetter()
# set the class of the instance, the __init__ will never be called on the class
# but the original state will be set later on by pickle.
nested_instance.__class__ = nested_class
return nested_instance
class _SerializableNestedComponent(Component):
"""
the component class used to create our serializable components
"""
def __init__(self):
Component.__init__(self)
def __set_state__(self, state):
self.__dict__ = state.copy()
def __reduce__(self):
state = self.__dict__.copy()
return (_NestedClassGetter(), (_ExternalComponentFactory, self.__class__.__name__, ), state, )
class _ExternalComponentFactory(object):
"""
_ExternalComponentFactory will contain all created external component types
"""
pass
class _serializable_nested_function(object):
"""
callable object used for the serialization of custom types
"""
def __init__(self):
self._container = object.__class__
def __set_state__(self, state):
self.__dict__ = state.copy()
def __reduce__(self):
state = self.__dict__.copy()
return (_NestedClassGetter(), (self._container, self.__class__.__name__, ), state, )
......@@ -146,6 +146,9 @@ class tx_nG6_upgrade {
// add sample support
tx_nG6_upgrade::upgrade_samples();
// update typo3 tables
tx_nG6_upgrade::updade_sys_refindex();
}
function set_storage_size($data_storage) {
......@@ -308,6 +311,29 @@ class tx_nG6_upgrade {
$GLOBALS['TYPO3_DB']->sql_query($queryAlterTxNG6SampleAddColumns);
}
function updade_sys_refindex(){
/*
* Update path to template files in sys_refindex
*/
$GLOBALS['TYPO3_DB']-> exec_UPDATEquery('sys_refindex',
"softref_id='fileadminReferences.8' AND ref_table='_FILE' AND tablename='sys_template' " ,
array('ref_string' => 'typo3conf/ext/nG6/template/css/ie6.css'));
$GLOBALS['TYPO3_DB']-> exec_UPDATEquery('sys_refindex',
"softref_id='fileadminReferences.11' AND ref_table='_FILE' AND tablename='sys_template' " ,
array('ref_string' => 'typo3conf/ext/nG6/template/images/picto-home.png'));
$GLOBALS['TYPO3_DB']-> exec_UPDATEquery('sys_refindex',
"softref_id='fileadminReferences.14' AND ref_table='_FILE' AND tablename='sys_template' " ,
array('ref_string' => 'typo3conf/ext/nG6/template/index.html'));
$GLOBALS['TYPO3_DB']-> exec_UPDATEquery('sys_refindex',
"softref_id='fileadminReferences.2' AND ref_table='_FILE' AND tablename='sys_template' " ,
array('ref_string' => 'typo3conf/ext/nG6/template/css/style.css'));
$GLOBALS['TYPO3_DB']-> exec_UPDATEquery('sys_refindex',
"softref_id='fileadminReferences.5' AND ref_table='_FILE' AND tablename='sys_template' " ,
array('ref_string' => 'typo3conf/ext/nG6/res/css/bootstrap.min.css'));
}
/*
* version 1.2
*------------------------------------------------------------*/
......
......@@ -21,74 +21,10 @@ import copy
import fnmatch
import xml.etree.ElementTree as ET
from jflow.component import Component
from jflow.extparser import ExternalParser
from jflow.parameter import OutputFile
import argparse
"""
For nested class serialization, I use a modified version of what is stated here :
http://stackoverflow.com/questions/1947904/how-can-i-pickle-a-nested-class-in-python
_MobyleComponentFactory will contain all created mobyle classes.
_NestedClassGetter is a callable that will be called by __reduce__ for serialization
and that will provide us with an instance of our nested class
_SerializableNestedComponent is the component class used to create our mobyle classes
"""
class _NestedClassGetter(object):
"""
used for nested object serialization.
When called with the containing class as the first argument,
and the name of the nested class as the second argument,
returns an instance of the nested class.
"""
def __call__(self, containing_class, class_name):
nested_class = getattr(containing_class, class_name)
# make an instance of a simple object, for which we can change the __class__ later on.
nested_instance = _NestedClassGetter()
# set the class of the instance, the __init__ will never be called on the class
# but the original state will be set later on by pickle.
nested_instance.__class__ = nested_class
return nested_instance
class _SerializableNestedComponent(Component):
"""
For serialization of nested Component
"""
def __init__(self):
Component.__init__(self)
def __set_state__(self, state):
self.__dict__ = state.copy()
def __reduce__(self):
state = self.__dict__.copy()
return (_NestedClassGetter(), (_MobyleComponentFactory, self.__class__.__name__, ), state, )
class _MobyleComponentFactory(object): pass
"""
callable object used for the serialization of custom types
"""
class _serializable_nested_function(object):
def __init__(self):
self._container = object.__class__
def __set_state__(self, state):
self.__dict__ = state.copy()
def __reduce__(self):
state = self.__dict__.copy()
return (_NestedClassGetter(), (self._container, self.__class__.__name__, ), state, )
class MobyleParser(ExternalParser):
def parse(self, component_file):
......@@ -160,7 +96,7 @@ class MobyleParser(ExternalParser):
vlist = param['flist'].keys()
# custom string type depending on vlist for keys and convert to flist
class flist_type(_serializable_nested_function):
class flist_type(jflow.extparser._serializable_nested_function):
def __call__(self, vvv):
if vvv in vlist :
return eval(param['flist'][vvv])
......@@ -268,14 +204,8 @@ class MobyleParser(ExternalParser):
component_name = root.find(".//head/name").text.replace('-', ' ').replace('_', ' ')
component_name = "".join(component_name.title().split())
MobyleComponent = type(component_name, (_SerializableNestedComponent,),{
'get_command' : fn_get_command,
'get_abstraction' : fn_get_abstraction,
'define_parameters' : fn_define_parameters
})
setattr(_MobyleComponentFactory, component_name, MobyleComponent)
return MobyleComponent
return self.build_component(component_name, fn_define_parameters, get_command = fn_get_command, get_abstraction = fn_get_abstraction)
def _parseParameter(self, parameterNode):
attrs = parameterNode.attrib
......
......@@ -33,7 +33,7 @@ def fastq(ifile):
# only check the first 10 sequences
if nb_seq == 10: break
except:
raise jflow.InvalidFormatError("Error: The provided file '" + ifile + "' is not a fastq file!")
raise jflow.InvalidFormatError("The provided file '" + ifile + "' is not a fastq file!")
def fasta(ifile):
try:
......@@ -44,7 +44,7 @@ def fasta(ifile):
# only check the first 10 sequences
if nb_seq == 10: break
except:
raise jflow.InvalidFormatError("Error: The provided file '" + ifile + "' is not a fasta file!")
raise jflow.InvalidFormatError("The provided file '" + ifile + "' is not a fasta file!")
def sff(ifile):
try:
......@@ -55,5 +55,5 @@ def sff(ifile):
# only check the first 10 sequences
if nb_seq == 10: break
except:
raise jflow.InvalidFormatError("Error: The provided file '" + ifile + "' is not a sff file!")
raise jflow.InvalidFormatError("The provided file '" + ifile + "' is not a sff file!")
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment