Guider

Doc


The Guider write templated .py or .md files for explaining how work a certain Module


View the Guider notebook on [NbViewer](http://nbviewer.ipython.org/url/shareyoursystem.ouvaton.org/Guider.ipynb)

Code



# -*- coding: utf-8 -*-
"""


<DefineSource>
@Date : Fri Nov 14 13:20:38 2014 \n
@Author : Erwan Ledoux \n\n
</DefineSource>


The Guider write templated .py or .md files for explaining how
work a certain Module

"""

#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Standards.Interfacers.Deployer"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Classer"
SYS.setSubModule(globals())
#</DefineAugmentation>

#<ImportSpecificModules>
import inspect
import os
import sys
#</ImportSpecificModules>

#<DefineFunctions>
ScriptStrAndExtensionStrTuplesList=[
    ('Latex','.tex'),
    ('Markdown','.md'),
    ('Python','.py'),
]
#</DefineFunctions>

#<DefineLocals>

GuidingDocumentMarkdownTextStr='''
<!--
FrozenIsBool False
-->

#<NameStr>

##Doc
----

<ModuleDocStr>

----

<small>
View the <NameStr> notebook on [NbViewer](http://nbviewer.ipython.org/url/shareyoursystem.ouvaton.org/<NameStr>.ipynb)
</small>

'''

GuidingGithubMarkdownTextStr='''
<!--
FrozenIsBool False
-->

##Code

----

<ClassDocStr>

----

```python
<CodeStr>

View the sources on Github

'''

GuidingOuvatonMarkdownTextStr='''

Concept and SubModules family

View the concept on Ouvaton

'''

GuidingClassMarkdownTextStr='''

More Descriptions at the level of the class

Special attributes of the Class are : '''

GuidingClassCodeTextStr='''

FrozenIsBool False

ImportModules

import ShareYourSystem as SYS from import

Definition the AttestedStr

SYS._attest( [ 'DefaultAttributeItemTuplesList is '+SYS._str( .Class.DefaultAttributeItemTuplesList, **{'RepresentingAlineaIsBool':False} ) ] )

Print

'''

GuidingInstanceMarkdownTextStr='''

More Descriptions at the level of the instances

A default call of an instance gives : '''

GuidingInstanceCodeTextStr='''

FrozenIsBool False

ImportModules

from ShareYourSystem.Standards.Classors import Attester from import

Definition the AttestedStr

SYS._attest( [ .Class() ] )

Print

''' GuidingSortStr='_'

</DefineLocals>

@DecorationClass() class GuiderClass(BaseClass):

#Definition
RepresentingKeyStrsList=[
                            'GuidingIndexStr',
                            'GuidingPageStr',
                            'GuidingBookStr',
                            'GuidingScriptStr',
                            'GuidedIndexStr'
                        ]

def default_init(self,
                    _GuidingIndexStr="",
                    _GuidingPageStr="",
                    _GuidingBookStr="",
                    _GuidingScriptStr="",
                    _GuidedIndexStr="",
                    **_KwargVariablesDict
                ):

    #Call the parent __init__ method
    BaseClass.__init__(self,**_KwargVariablesDict)

def do_guide(self):

    #Check
    if self.PackagingModuleVariable!=None:

        #Check
        if self.GuidingPageStr!="":

            if self.GuidingIndexStr=="":

                #Definition
                IndexesList=map(
                        int,
                        map(
                                lambda __KeyStr:
                                __KeyStr.split(
                                GuidingSortStr
                                )[0],
                            self.GuidedDict.values()
                            )
                    )

                #Definition the last index of Guide
                IndexInt=max(IndexesList) if len(IndexesList)>0 else -1

                #Define
                self.GuidingIndexStr="%02d"%(IndexInt+1)+GuidingSortStr

        #debug
        '''
        self.debug(('self.',self,['PackagedLocalFolderPathStr']))
        '''

        #Write a new file
        self.file(
                    self.GuidingIndexStr+GuidingSortStr+self.GuidingPageStr+self.GuidingBookStr+(
                                dict(
                    ScriptStrAndExtensionStrTuplesList
                    )
                        )[self.GuidingScriptStr],
                    'wt'
                )

        #Check
        if self.FiledHardVariable.mode=='wt':

            #Definition
            GuidingTextStrKeyStr='Guiding'+self.GuidingPageStr+self.GuidingScriptStr+'TextStr'

            #debug
            '''
            print('self.FiledHardVariable is ',self.FiledHardVariable)
            print('')
            '''

            #Definition
            GuidedTextStr=globals()[GuidingTextStrKeyStr]

            #debug
            '''
            print('GuidedTextStr is ',GuidedTextStr)
            print('')
            '''

            #Replace
            GuidedTextStr=GuidedTextStr.replace(
                                        '<NameStr>',
                                        self.FolderedNameStr
                                        )

            #debug
            '''
            print('GuidedTextStr is ',GuidedTextStr)
            print('')
            '''

            #Replace
            if self.FolderedNameStr=="ShareYourSystem":
                GuidedTextStr=GuidedTextStr.replace(
                    "from <ParentModuleStr> ",""
                )
            else:
                GuidedTextStr=GuidedTextStr.replace(
                        "<ParentModuleStr>",
                        self.FolderedParentModuleStr
                    ).replace(
                        "<GithubPathStr>",
                        self.PackagedModuleStr.replace('.','/')
                    ).replace(
                        "<ModuleDocStr>",
                        sys.modules[
                            self.PackagedModuleStr
                        ].__doc__.split('</DefineSource>\n'
                            )[-1].replace(
                            '\n','\n> '
                        )
                    ).replace(
                        "<CodeStr>",
                        inspect.getsource(
                            sys.modules[
                                self.PackagedModuleStr
                            ]
                        )
                    )

            #debug
            '''
            print('Guider l.194')
            print('self.FiledPathStr is',self.FiledPathStr)
            print('')
            '''

            #Write
            self.write(GuidedTextStr,**{'LoadingFormatStr':'txt'})

            #Close
            self.FiledHardVariable.close()

</DefineClass>

```

View the Guider sources on Github

Example

Let's create an empty class, which will automatically receive special attributes from the decorating ClassorClass, specially the NameStr, that should be the ClassStr without the TypeStr in the end.


In [3]:
#ImportModules
import ShareYourSystem as SYS
from ShareYourSystem.Guiders import Guider
from ShareYourSystem.Standards.Objects import Concluder

#Definition an instance
MyGuider=Guider.GuiderClass(
    ).package(
        Concluder
    ).guide(
        '001','Github','Doc','Markdown',
    )
    
#Definition the AttestedStr
SYS._attest(
    [
        'MyGuider is '+str(
            SYS._str(
                MyGuider,
                **{
                'RepresentingBaseKeyStrsListBool':False
                }
            )
        )
    ]
)



*****Start of the Attest *****

MyGuider is < (GuiderClass), 4540597072>
   /{ 
   /  '<New><Instance>IdInt' : 4540597072
   /  '<Spe><Class>GuidedIndexStr' : 
   /  '<Spe><Instance>GuidingBookStr' : Doc
   /  '<Spe><Instance>GuidingIndexStr' : 001
   /  '<Spe><Instance>GuidingPageStr' : Github
   /  '<Spe><Instance>GuidingScriptStr' : Markdown
   /}

*****End of the Attest *****


Scriptbooker

Doc


The Scriptbooker defines template of Mardown and Code Scriptbooks for readming a Module.


View the Scriptbooker notebook on [NbViewer](http://nbviewer.ipython.org/url/shareyoursystem.ouvaton.org/Scriptbooker.ipynb)

Code



# -*- coding: utf-8 -*-
"""


<DefineSource>
@Date : Fri Nov 14 13:20:38 2014 \n
@Author : Erwan Ledoux \n\n
</DefineSource>


The Scriptbooker defines template of Mardown and Code Scriptbooks for readming a Module.

"""

#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Guiders.Guider"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Classer"
SYS.setSubModule(globals())
#</DefineAugmentation>

#<ImportSpecificModules>
import os
Guider=BaseModule
#</ImportSpecificModules>

#<DefineClass>
@DecorationClass()
class ScriptbookerClass(BaseClass):

    #Definition
    RepresentingKeyStrsList=[
                                'ScriptbookingGuideTuplesList',
                                'ScriptbookedFileKeyStrsList',
                                'ScriptbookedNewGuideTuplesList',
                                'ScriptbookedOldGuideTuplesList'
                            ]

    def default_init(self,
                        _ScriptbookingGuideTuplesList=[
                            ('001','Document','Markdown'),
                            ('002','Github','Markdown'),
                            #('003','Ouvaton','Markdown')
                        ],
                        _ScriptbookedFileKeyStrsList=None,
                        _ScriptbookedNewGuideTuplesList=None,
                        _ScriptbookedOldGuideTuplesList=None,
                        **_KwargVariablesDict
                    ):

        #Call the parent __init__ method
        BaseClass.__init__(self,**_KwargVariablesDict)

    def do_scriptbook(self):

        #debug
        '''
        self.debug(('self.',self,['FolderedDirKeyStrsList']))
        '''

        #Definition
        self.ScriptbookedFileKeyStrsList=SYS._filter(
                lambda __DirKeyStr:
                any(
                    map(
                        lambda __ExtensionStr:
                        __DirKeyStr.endswith(
                            self.GuidingBookStr+__ExtensionStr
                        ),
                        ['.py','.md','.tex']
                )),
                self.FolderedDirKeyStrsList
        )

        #Definition
        ScriptbookedPageStrsList=map(
                                    lambda __ScriptbookerScriptbookFileKeyStr:
                                    Guider.GuidingSortStr.join(
                                        __ScriptbookerScriptbookFileKeyStr.split(
                                            Guider.GuidingSortStr)[1:]
                                        ),
                                    self.ScriptbookedFileKeyStrsList
                                )

        #set
        self.ScriptbookedSortDict=dict(
                zip(ScriptbookedPageStrsList,self.ScriptbookedFileKeyStrsList)
            )

        #debug
        '''
        self.debug(('self.',self,['ScriptbookedSortDict']))
        '''

        #Check
        if len(self.ScriptbookingGuideTuplesList)>0:

            #map
            ScriptbookedGuideTuplesList=map(
                    lambda __ScriptbookingGuideTuple:
                    list(__ScriptbookingGuideTuple)+[
                        __ScriptbookingGuideTuple[1]+self.GuidingBookStr+dict(
                        Guider.ScriptStrAndExtensionStrTuplesList
                        )[
                            __ScriptbookingGuideTuple[2]
                        ]
                    ],
                    self.ScriptbookingGuideTuplesList
                )

            #groupby
            [
                self.ScriptbookedNewGuideTuplesList,
                self.ScriptbookedOldGuideTuplesList
            ]=SYS.groupby(
                lambda __ScriptbookedGuideTuple:
                __ScriptbookedGuideTuple[3] not in self.ScriptbookedSortDict,
                ScriptbookedGuideTuplesList,
            )

            #debug
            '''
            self.debug(('self.',self,[
                            'ScriptbookedNewGuideTuplesList',
                            'ScriptbookedOldGuideTuplesList'
                        ]))
            '''

            #map a guide for the news
            map(
                lambda __ScriptbookingNewGuideTuple:
                self.guide(__ScriptbookingNewGuideTuple[0],
                            __ScriptbookingNewGuideTuple[1],
                            self.GuidingBookStr,
                            __ScriptbookingNewGuideTuple[2]),
                self.ScriptbookedNewGuideTuplesList
            )

            #check if we rewrite for the olds
            map(
                lambda __ScriptbookingOldGuideTuple:
                self.close() 
                if "#FrozenIsBool True" in self.load(
                    _FormatStr='txt',
                    **{
                        'FilingKeyStr':self.ScriptbookedSortDict[
                        __ScriptbookingOldGuideTuple[3]
                        ],
                        'FilingModeStr':'r'
                    }).LoadedReadVariable
                else self.close().guide(
                            __ScriptbookingOldGuideTuple[0],
                            __ScriptbookingOldGuideTuple[1],
                            self.GuidingBookStr,
                            __ScriptbookingOldGuideTuple[2],
                        ),
                self.ScriptbookedOldGuideTuplesList
            )

        #Return self
        #return self

#</DefineClass>

View the Scriptbooker sources on [Github](https://github.com/Ledoux/ShareYourSystem/tree/master/Pythonlogy/ShareYourSystem/Guiders/Scriptbooker)

Example

Let's create an empty class, which will automatically receive special attributes from the decorating ClassorClass, specially the NameStr, that should be the ClassStr without the TypeStr in the end.


In [7]:
#ImportModules
import ShareYourSystem as SYS
from ShareYourSystem.Guiders import Scriptbooker

#Definition of a Scriptbooker
MyScriptbooker=Scriptbooker.ScriptbookerClass(
    ).package(
        "ShareYourSystem.Standards.Objects.Object"
    ).scriptbook(
        **{
            'GuidingBookStr':'Doc'
        }
    )

#Definition the AttestedStr
SYS._attest(
    [
        'MyScriptbooker is '+SYS._str(
                MyScriptbooker,
                **{
                'RepresentingBaseKeyStrsListBool':False,
                'RepresentingAlineaIsBool':False
                }
        )
    ]
) 

#Print



*****Start of the Attest *****

MyScriptbooker is < (ScriptbookerClass), 4540655568>
   /{ 
   /  '<New><Instance>IdInt' : 4540655568
   /  '<New><Instance>ScriptbookedSortDict' : 
   /   /{ 
   /   /  'DocumentDoc.md' : 001_DocumentDoc.md
   /   /  'ExampleDoc.md' : 00_ExampleDoc.md
   /   /  'ExampleDoc.py' : 01_ExampleDoc.py
   /   /  'GithubDoc.md' : 002_GithubDoc.md
   /   /}
   /  '<Spe><Class>ScriptbookingGuideTuplesList' : 
   /   /[
   /   /  0 : ('001', 'Document', 'Markdown')
   /   /  1 : ('002', 'Github', 'Markdown')
   /   /]
   /  '<Spe><Instance>ScriptbookedFileKeyStrsList' : ['001_DocumentDoc.md', '002_GithubDoc.md', '00_ExampleDoc.md', '01_ExampleDoc.py']
   /  '<Spe><Instance>ScriptbookedNewGuideTuplesList' : []
   /  '<Spe><Instance>ScriptbookedOldGuideTuplesList' : 
   /   /[
   /   /  0 : ['001', 'Document', 'Markdown', 'DocumentDoc.md']
   /   /  1 : ['002', 'Github', 'Markdown', 'GithubDoc.md']
   /   /]
   /}

*****End of the Attest *****


Celler

Doc


The Celler defines template of Mardown and Code Cells for readming a Module.


View the Celler notebook on [NbViewer](http://nbviewer.ipython.org/url/shareyoursystem.ouvaton.org/Celler.ipynb)

Code



# -*- coding: utf-8 -*-
"""


<DefineSource>
@Date : Fri Nov 14 13:20:38 2014 \n
@Author : Erwan Ledoux \n\n
</DefineSource>


The Celler defines template of Mardown and Code Cells for readming a Module.

"""

#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Guiders.Scriptbooker"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Classer"
SYS.setSubModule(globals())
#</DefineAugmentation>

#<ImportSpecificModules>
import os
import six
import copy

#</ImportSpecificModules>

#<DefineLocals>
CellingInitDict={
                'metadata': {
                                'name': "",
                                'signature': ""
                            },
                'nbformat': 3,
                'nbformat_minor': 0,
                'worksheets': []
            }

CellingCodeCellDict={
                        'cell_type':'code',
                        'collapsed': False,
                        'input':[],
                        'language': "python",
                        'metadata': {'slideshow':{'slide_type':"slide"}},
                        'prompt_number':0
                    }

CellingOutputDict={
                        'output_type': "stream",
                        'stream': "stdout",
                        'text': [                                                       
                                ]
                    }

CellingMarkdownCellDict={
                            'source': "", 
                            'cell_type': 'markdown', 
                            'metadata': {'slideshow':{'slide_type':"slide"}}
                        } 
#</DefineLocals>


#<DefineClass>
@DecorationClass()
class CellerClass(BaseClass):

    #Definition
    RepresentingKeyStrsList=[
                                'CellingTextStr',
                                'CellingScriptStr',
                                'CelledOutputStr',
                                'CelledNoteDict'
                            ]

    def default_init(self,
                        _CellingTextStr="",
                        _CellingScriptStr="",
                        _CelledOutputStr="",
                        _CelledNoteDict=None,
                        **_KwargVariablesDict
                    ):

        #Call the parent __init__ method
        BaseClass.__init__(self,**_KwargVariablesDict)

    def do_cell(self):

        #Debug
        '''
        self.debug(
                    ('self.',self,[
                        'FolderingPathVariable',
                        #'CellingTextStr'
                        ]
                    )
                )
        '''

        #Check Code case
        if self.CellingScriptStr=='Python':

            #folder first
            self.folder()

            #Definition the self.CelledOutputStr
            if self.FolderingPathVariable!=os.getcwd()+'/':     

                #capture and six method
                self.CapturedPrintStrsList=[]
                self.capture()
                six.exec_(self.CellingTextStr,vars())
                self.CapturingStopBool=True
                self.CelledOutputStr='\n'.join(self.CapturedPrintStrsList)

            else:

                #Avoid the output of the corresponding NameStr because it will do a circular effect...
                self.CelledOutputStr=""


            #Debug
            '''
            self.debug(('self.',self,['CelledOutputStr']))
            '''

            #Return 
            self.CelledNoteDict=dict(
                copy.deepcopy(CellingCodeCellDict),
                **{
                    'input':map(    
                                lambda __LineStr:
                                __LineStr+'\n',
                                self.CellingTextStr.replace(
                                    "#FrozenIsBool True",""
                            ).replace(
                                "#FrozenIsBool False",""
                            ).replace(
                                '\t',
                                '    '
                            ).replace('    \n','\n').split('\n')
                        ),
                        "outputs":[
                        dict(
                            copy.copy(CellingOutputDict),
                                **
                                {
                                    "text":map( 
                                            lambda __LineStr:
                                            __LineStr+'\n',
                                            self.CelledOutputStr.split('\n')
                                        )
                                }
                            )
                        ]
                }
            )

        #Check Markdown case
        elif self.CellingScriptStr=='Markdown':

            self.CelledNoteDict=dict(
                copy.deepcopy(CellingMarkdownCellDict),
                **{
                        'source':self.CellingTextStr
                }
            )

#</DefineClass>

View the Celler sources on [Github](https://github.com/Ledoux/ShareYourSystem/tree/master/Pythonlogy/ShareYourSystem/Guiders/Celler)

Example

Let's create an empty class, which will automatically receive special attributes from the decorating ClassorClass, specially the NameStr, that should be the ClassStr without the TypeStr in the end.


In [11]:
#ImportModules
import ShareYourSystem as SYS
from ShareYourSystem.Guiders import Celler

#Definition an instance
MyCeller=Celler.CellerClass().load(
    **{
        'FolderingPathVariable':
        SYS.ShareYourSystemLocalFolderPathStr+'Pythonlogy/ShareYourSystem/Objects/Rebooter',
        'FilingKeyStr':'01_ExampleDoc.py'
    }
)
MyCeller.cell(MyCeller.LoadedReadVariable,'Python')
    
#Definition the AttestedStr
SYS._attest(
    [
        'MyCeller is '+SYS._str(
                MyCeller,
                **{
                'RepresentingBaseKeyStrsListBool':False,
                'RepresentingAlineaIsBool':False
                }
            )
    ]
)



*****Start of the Attest *****

MyCeller is < (CellerClass), 4540655440>
   /{ 
   /  '<New><Instance>IdInt' : 4540655440
   /  '<New><Instance>_CapturingStopBool' : True
   /  '<Spe><Instance>CelledNoteDict' : 
   /   /{ 
   /   /  'cell_type' : code
   /   /  'collapsed' : False
   /   /  'input' : ['#ImportModules\n', 'import ShareYourSystem as SYS\n', 'from ShareYourSystem.Standards.Classors import Classer\n', 'from ShareYourSystem.Standards.Objects import Rebooter\n', '\n', '#Definition \n', '@Classer.ClasserClass(**\n', '{\n', "    'ClassingSwitchMethodStrsList':['make']\n", '})\n', 'class MakerClass(Rebooter.RebooterClass):\n', '\n', '    #Definition\n', '    RepresentingKeyStrsList=[\n', "                                'MakingMyFloat',\n", "                                'MadeMyInt'\n", '                            ]\n', '\n', '    def default_init(self,\n', '                    _MakingMyFloat=0.,\n', '                    _MadeMyInt=0,\n', '                    **_KwarVariablesDict\n', '                ):\n', '        Rebooter.RebooterClass.__init__(self,**_KwarVariablesDict)\n', '\n', '    def do_make(self):\n', '    \n', '        #print\n', "        print('I am in the do_make of the Maker')\n", '\n', '        #cast\n', '        self.MadeMyInt=int(self.MakingMyFloat)\n', '\n', '#Definition\n', '@Classer.ClasserClass(**{\n', '    \'ClassingSwitchMethodStrsList\':["make"]\n', '})\n', 'class BuilderClass(MakerClass):\n', '\n', '    #Definition\n', '    RepresentingKeyStrsList=[\n', '                            ]\n', '\n', '    def default_init(self,\n', '                    **_KwarVariablesDict\n', '                ):\n', '        MakerClass.__init__(self,**_KwarVariablesDict)\n', '\n', '    def mimic_make(self):\n', '    \n', '        #print\n', "        print('I am in the mimic_make of the Builder')\n", '\n', '        #call the parent method\n', '        MakerClass.make(self)\n', '\n', '        #cast\n', '        self.MadeMyInt+=10\n', '\n', '    def do_build(self):\n', '        pass\n', '\n', '\n', '#Definition an instance\n', 'MyBuilder=BuilderClass()\n', '\n', '#Print\n', "print('Before make, MyBuilder is ')\n", 'SYS._print(MyBuilder,**{\n', "    'RepresentingKeyStrsList':[\n", "    'MakingMyFloat',\n", "    'MadeMyInt',\n", '    ]\n', '})\n', '\n', '#make once\n', 'MyBuilder.make(3.)\n', '\n', '#Print\n', "print('After the first make, MyBuilder is ')\n", 'SYS._print(MyBuilder,**{\n', "    'RepresentingKeyStrsList':[\n", "    'MakingMyFloat',\n", "    'MadeMyInt',\n", '    ]\n', '})\n', '\n', '#make again\n', 'MyBuilder.make(5.)\n', '\n', '#Print\n', "print('After the second make, MyBuilder is ')\n", 'SYS._print(MyBuilder,**{\n', "    'RepresentingKeyStrsList':[\n", "    'MakingMyFloat',\n", "    'MadeMyInt',\n", '    ]\n', '})\n', '\n', '#make again\n', "print('Now we reboot')\n", 'MyBuilder.reboot(\n', "                    #_NameStrsList=['Maker','Builder'],\n", "                    #_DoStrsList=['Make'],\n", '                    #_AllDoBool=True,\n', '                    #_AllNameBool=True,\n', '                )\n', '\n', '#Print\n', "print('After the reboot, MyBuilder is ')\n", 'SYS._print(MyBuilder,**{\n', "    'RepresentingKeyStrsList':[\n", "    'MakingMyFloat',\n", "    'MadeMyInt',\n", '    ]\n', '})\n', '\n', '#make again\n', 'MyBuilder.make(8.)\n', '\n', '#Definition the AttestedStr\n', 'SYS._attest(\n', '    [\n', "        'MyBuilder is '+SYS._str(\n", '        MyBuilder,\n', '        **{\n', "            'RepresentingAlineaIsBool':False,\n", "            'RepresentingKeyStrsList':[\n", "                'MakingMyFloat',\n", "                'MadeMyInt',\n", "                'RebootedWatchBoolKeyStrsList'\n", '            ]\n', '            }\n', '        )\n', '    ]\n', ') \n']
   /   /  'language' : python
   /   /  'metadata' : 
   /   /   /{ 
   /   /   /  'slideshow' : 
   /   /   /   /{ 
   /   /   /   /  'slide_type' : slide
   /   /   /   /}
   /   /   /}
   /   /  'outputs' : 
   /   /   /[
   /   /   /  0 : 
   /   /   /   /{ 
   /   /   /   /  'output_type' : stream
   /   /   /   /  'stream' : stdout
   /   /   /   /  'text' : ['Before make, MyBuilder is \n', '< (BuilderClass), 4540622736>\n', '   /{ \n', "   /  '<Base><Class>MadeMyInt' : 0\n", "   /  '<Base><Class>MakingMyFloat' : 0.0\n", "   /  '<New><Instance>IdInt' : 4540622736\n", '   /}\n', 'I am in the mimic_make of the Builder\n', 'I am in the do_make of the Maker\n', 'After the first make, MyBuilder is \n', '< (BuilderClass), 4540622736>\n', '   /{ \n', "   /  '<New><Instance>IdInt' : 4540622736\n", "   /  '<Spe><Instance>MadeMyInt' : 13\n", "   /  '<Spe><Instance>MakingMyFloat' : 3.0\n", '   /}\n', 'After the second make, MyBuilder is \n', '< (BuilderClass), 4540622736>\n', '   /{ \n', "   /  '<New><Instance>IdInt' : 4540622736\n", "   /  '<Spe><Instance>MadeMyInt' : 13\n", "   /  '<Spe><Instance>MakingMyFloat' : 3.0\n", '   /}\n', 'Now we reboot\n', 'After the reboot, MyBuilder is \n', '< (BuilderClass), 4540622736>\n', '   /{ \n', "   /  '<New><Instance>IdInt' : 4540622736\n", "   /  '<Spe><Instance>MadeMyInt' : 0\n", "   /  '<Spe><Instance>MakingMyFloat' : 3.0\n", '   /}\n', 'I am in the mimic_make of the Builder\n', 'I am in the do_make of the Maker\n', '\n', '\n', '*****Start of the Attest *****\n', '\n', 'MyBuilder is < (BuilderClass), 4540622736>\n', '   /{ \n', "   /  '<New><Instance>IdInt' : 4540622736\n", "   /  '<Spe><Instance>MadeMyInt' : 18\n", "   /  '<Spe><Instance>MakingMyFloat' : 8.0\n", "   /  '<Spe><Instance>RebootedWatchBoolKeyStrsList' : []\n", '   /}\n', '\n', '*****End of the Attest *****\n', '\n', '\n']
   /   /   /   /}
   /   /   /]
   /   /  'prompt_number' : 0
   /   /}
   /  '<Spe><Instance>CelledOutputStr' : Before make, MyBuilder is 
< (BuilderClass), 4540622736>
   /{ 
   /  '<Base><Class>MadeMyInt' : 0
   /  '<Base><Class>MakingMyFloat' : 0.0
   /  '<New><Instance>IdInt' : 4540622736
   /}
I am in the mimic_make of the Builder
I am in the do_make of the Maker
After the first make, MyBuilder is 
< (BuilderClass), 4540622736>
   /{ 
   /  '<New><Instance>IdInt' : 4540622736
   /  '<Spe><Instance>MadeMyInt' : 13
   /  '<Spe><Instance>MakingMyFloat' : 3.0
   /}
After the second make, MyBuilder is 
< (BuilderClass), 4540622736>
   /{ 
   /  '<New><Instance>IdInt' : 4540622736
   /  '<Spe><Instance>MadeMyInt' : 13
   /  '<Spe><Instance>MakingMyFloat' : 3.0
   /}
Now we reboot
After the reboot, MyBuilder is 
< (BuilderClass), 4540622736>
   /{ 
   /  '<New><Instance>IdInt' : 4540622736
   /  '<Spe><Instance>MadeMyInt' : 0
   /  '<Spe><Instance>MakingMyFloat' : 3.0
   /}
I am in the mimic_make of the Builder
I am in the do_make of the Maker


*****Start of the Attest *****

MyBuilder is < (BuilderClass), 4540622736>
   /{ 
   /  '<New><Instance>IdInt' : 4540622736
   /  '<Spe><Instance>MadeMyInt' : 18
   /  '<Spe><Instance>MakingMyFloat' : 8.0
   /  '<Spe><Instance>RebootedWatchBoolKeyStrsList' : []
   /}

*****End of the Attest *****


   /  '<Spe><Instance>CellingScriptStr' : Python
   /  '<Spe><Instance>CellingTextStr' : #ImportModules
import ShareYourSystem as SYS
from ShareYourSystem.Standards.Classors import Classer
from ShareYourSystem.Standards.Objects import Rebooter

#Definition 
@Classer.ClasserClass(**
{
	'ClassingSwitchMethodStrsList':['make']
})
class MakerClass(Rebooter.RebooterClass):

	#Definition
	RepresentingKeyStrsList=[
								'MakingMyFloat',
								'MadeMyInt'
							]

	def default_init(self,
					_MakingMyFloat=0.,
					_MadeMyInt=0,
					**_KwarVariablesDict
				):
		Rebooter.RebooterClass.__init__(self,**_KwarVariablesDict)

	def do_make(self):
		
		#print
		print('I am in the do_make of the Maker')

		#cast
		self.MadeMyInt=int(self.MakingMyFloat)

#Definition
@Classer.ClasserClass(**{
	'ClassingSwitchMethodStrsList':["make"]
})
class BuilderClass(MakerClass):

	#Definition
	RepresentingKeyStrsList=[
							]

	def default_init(self,
					**_KwarVariablesDict
				):
		MakerClass.__init__(self,**_KwarVariablesDict)

	def mimic_make(self):
		
		#print
		print('I am in the mimic_make of the Builder')

		#call the parent method
		MakerClass.make(self)

		#cast
		self.MadeMyInt+=10

	def do_build(self):
		pass


#Definition an instance
MyBuilder=BuilderClass()

#Print
print('Before make, MyBuilder is ')
SYS._print(MyBuilder,**{
	'RepresentingKeyStrsList':[
	'MakingMyFloat',
	'MadeMyInt',
	]
})

#make once
MyBuilder.make(3.)

#Print
print('After the first make, MyBuilder is ')
SYS._print(MyBuilder,**{
	'RepresentingKeyStrsList':[
	'MakingMyFloat',
	'MadeMyInt',
	]
})

#make again
MyBuilder.make(5.)

#Print
print('After the second make, MyBuilder is ')
SYS._print(MyBuilder,**{
	'RepresentingKeyStrsList':[
	'MakingMyFloat',
	'MadeMyInt',
	]
})

#make again
print('Now we reboot')
MyBuilder.reboot(
					#_NameStrsList=['Maker','Builder'],
					#_DoStrsList=['Make'],
					#_AllDoBool=True,
					#_AllNameBool=True,
				)

#Print
print('After the reboot, MyBuilder is ')
SYS._print(MyBuilder,**{
	'RepresentingKeyStrsList':[
	'MakingMyFloat',
	'MadeMyInt',
	]
})

#make again
MyBuilder.make(8.)

#Definition the AttestedStr
SYS._attest(
	[
		'MyBuilder is '+SYS._str(
		MyBuilder,
		**{
			'RepresentingAlineaIsBool':False,
			'RepresentingKeyStrsList':[
				'MakingMyFloat',
				'MadeMyInt',
				'RebootedWatchBoolKeyStrsList'
			]
			}
		)
	]
) 
   /}

*****End of the Attest *****


Notebooker

Doc


The Notebooker takes piece of .md,.py,.tex files for putting them in a IPython Notebook


View the Notebooker notebook on [NbViewer](http://nbviewer.ipython.org/url/shareyoursystem.ouvaton.org/Notebooker.ipynb)

Code



# -*- coding: utf-8 -*-
"""


<DefineSource>
@Date : Fri Nov 14 13:20:38 2014 \n
@Author : Erwan Ledoux \n\n
</DefineSource>


The Notebooker takes piece of .md,.py,.tex files for putting them in a IPython Notebook

"""

#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Guiders.Celler"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Classer"
SYS.setSubModule(globals())
#</DefineAugmentation>

#<ImportSpecificModules>
import copy
import os
import sys

from ShareYourSystem.Standards.Interfacers import Filer,Loader
from ShareYourSystem.Guiders import Guider
import importlib
Celler=BaseModule
#</ImportSpecificModules>

#<DefineClass>
@DecorationClass()
class NotebookerClass(BaseClass):

    #Definition
    RepresentingKeyStrsList=[
                                'NotebookingFileKeyStr',
                                'NotebookingWriteBool',
                                'NotebookedTextStrsList',
                                'NotebookedCodeDict',
                                'NotebookedPageStrsList',
                                'NotebookedSubslideStrsList'
                            ]

    def default_init(self,
                        _NotebookingFileKeyStr="",
                        _NotebookingWriteBool=True,
                        _NotebookedTextStrsList=None,
                        _NotebookedCodeDict=None,
                        _NotebookedPageStrsList=None,
                        _NotebookedSubslideStrsList=None,
                        **_KwargVariablesDict
                    ):

        #Call the parent __init__ method
        BaseClass.__init__(self,**_KwargVariablesDict)

    def do_notebook(self):

        #debug
        '''
        self.debug(('self.',self,['NotebookingFileKeyStr']))
        '''

        #Check
        if self.NotebookingFileKeyStr!="":

            #debug
            '''
            self.debug(('self.',self,['ScriptbookedSortDict']))
            '''

            #map
            self.NotebookedTextStrsList=map(
                    lambda __ScriptbookedFileKeyStr:
                    self.load(**{
                                    'FilingKeyStr':__ScriptbookedFileKeyStr
                                }
                    ).LoadedReadVariable,
                    sorted(self.ScriptbookedSortDict.values())
                )

            #map
            self.NotebookedScriptStrsList=map(
                    lambda __ScriptbookedFileKeyStr:
                    SYS.flip(
                        dict(
                                    Guider.ScriptStrAndExtensionStrTuplesList
                            )
                    )[
                        '.'+__ScriptbookedFileKeyStr.split('.')[-1]
                    ],
                    sorted(self.ScriptbookedSortDict.values())
                )

            #debug
            '''
            self.debug(('self.',self,[
                    'NotebookedTextStrsList',
                    'NotebookedScriptStrsList'
                ]))
            '''

            #Update
            self.LoadingFormatStr='json'

            #file first
            self.file(
                        self.NotebookingFileKeyStr,
                        'w'
                    )

            #Copy
            self.NotebookedCodeDict=copy.copy(Celler.CellingInitDict)

            #Fill the cells
            self.NotebookedCodeDict['worksheets']=[
                {
                    'cells':map(
                        lambda __NotebookedTextStr,__NotebookedScriptStr,__IndexInt:
                            dict(
                                self.cell(
                                    __NotebookedTextStr,
                                    __NotebookedScriptStr
                                ).CelledNoteDict,
                                **{
                                    'prompt_number':__IndexInt,
                                }
                            ),
                            self.NotebookedTextStrsList,
                            self.NotebookedScriptStrsList,
                            xrange(len(self.NotebookedTextStrsList))
                        )
                }
            ]

            #map
            self.NotebookedPageStrsList=map(
                    lambda __FileKeyStr:
                    Guider.GuidingSortStr.join(
                        __FileKeyStr.split('.')[0].split(
                            Guider.GuidingSortStr
                        )[1:]
                    ),
                    sorted(self.ScriptbookedSortDict.values())
                )

            #map
            self.NotebookedSubslideStrsList=map(
                    lambda __NotebookedPageStr,__PageIndexInt:
                    'slide'
                    if  __PageIndexInt==0
                    else
                    'subslide' 
                    if self.NotebookedPageStrsList[__PageIndexInt-1]!=__NotebookedPageStr
                    else '-',
                    self.NotebookedPageStrsList,
                    xrange(len(self.NotebookedPageStrsList))
                )

            #debug
            '''
            self.debug(
                [
                    ('self.',self,['NotebookedSubslideStrsList']),
                    "self.NotebookedCodeDict['worksheets'][0]['cells'] is "+SYS._str(
                        self.NotebookedCodeDict['worksheets'][0]['cells'])
                ]
            )
            '''

            #Specify the page/slide
            map(
                lambda __CellDict,__NotebookedSubslideStr:
                __CellDict['metadata']['slideshow'].__setitem__(
                        "slide_type",
                        __NotebookedSubslideStr
                    )
                ,
                self.NotebookedCodeDict['worksheets'][0]['cells'],
                self.NotebookedSubslideStrsList
            )

            #debug
            '''
            self.debug(
                [
                    "self.NotebookedCodeDict['worksheets'][0]['cells'] is "+SYS._str(
                        self.NotebookedCodeDict['worksheets'][0]['cells'])
                ]
            )
            '''

            #debug
            '''
            self.debug(
                        ('self.',self,[
                                            'NotebookingWriteBool',
                                            'NotebookedCodeDict',
                                        ])
                    )
            '''

            #Check
            if self.NotebookingWriteBool:

                #debug
                '''
                self.debug(
                            ('self.',self,[
                                                'FolderingPathVariable',
                                                'FilingKeyStr',
                                                'LoadingFormatStr'
                                            ])
                        )
                '''

                #Write
                self.write(self.NotebookedCodeDict)

                #Close
                self.FiledHardVariable.close()


        #Return self
        #return self

#</DefineClass>

View the Notebooker sources on Github

Example

Let's create an empty class, which will automatically receive special attributes from the decorating ClassorClass, specially the NameStr, that should be the ClassStr without the TypeStr in the end.


In [15]:
#ImportModules
import ShareYourSystem as SYS
from ShareYourSystem.Guiders import Notebooker

#Definition a Notebooker
MyNotebooker=Notebooker.NotebookerClass(
    ).package(
        'ShareYourSystem.Standards.Objects.Concluder'
    ).scriptbook(
        **{
            'GuidingBookStr':'Doc'
        }
    ).notebook(
        'Presentation.ipynb'
)

#Definition the AttestedStr
SYS._attest(
    [
        'MyNotebooker is '+SYS._str(
        MyNotebooker,
        **{
            'RepresentingBaseKeyStrsListBool':False,
            'RepresentingAlineaIsBool':False
        }
        )
    ]
)  

#Print



*****Start of the Attest *****

MyNotebooker is < (NotebookerClass), 4540657552>
   /{ 
   /  '<New><Instance>IdInt' : 4540657552
   /  '<New><Instance>NotebookedScriptStrsList' : ['Markdown', 'Markdown', 'Markdown', 'Python']
   /  '<New><Instance>ScriptbookedSortDict' : 
   /   /{ 
   /   /  'DocumentDoc.md' : 001_DocumentDoc.md
   /   /  'ExampleDoc.md' : 00_ExampleDoc.md
   /   /  'ExampleDoc.py' : 01_ExampleDoc.py
   /   /  'GithubDoc.md' : 002_GithubDoc.md
   /   /}
   /  '<New><Instance>_CapturingStopBool' : True
   /  '<Spe><Class>NotebookingWriteBool' : True
   /  '<Spe><Instance>NotebookedCodeDict' : 
   /   /{ 
   /   /  'metadata' : 
   /   /   /{ 
   /   /   /  'name' : 
   /   /   /  'signature' : 
   /   /   /}
   /   /  'nbformat' : 3
   /   /  'nbformat_minor' : 0
   /   /  'worksheets' : 
   /   /   /[
   /   /   /  0 : 
   /   /   /   /{ 
   /   /   /   /  'cells' : 
   /   /   /   /   /[
   /   /   /   /   /  0 : 
   /   /   /   /   /   /{ 
   /   /   /   /   /   /  'cell_type' : markdown
   /   /   /   /   /   /  'metadata' : 
   /   /   /   /   /   /   /{ 
   /   /   /   /   /   /   /  'slideshow' : 
   /   /   /   /   /   /   /   /{ 
   /   /   /   /   /   /   /   /  'slide_type' : slide
   /   /   /   /   /   /   /   /}
   /   /   /   /   /   /   /}
   /   /   /   /   /   /  'prompt_number' : 0
   /   /   /   /   /   /  'source' : 
<!--
FrozenIsBool False
-->

#Concluder

##Doc
----


> 
> A Concluder
> 
> 

----

<small>
View the Concluder notebook on [NbViewer](http://nbviewer.ipython.org/url/shareyoursystem.ouvaton.org/Concluder.ipynb)
</small>


   /   /   /   /   /   /}
   /   /   /   /   /  1 : 
   /   /   /   /   /   /{ 
   /   /   /   /   /   /  'cell_type' : markdown
   /   /   /   /   /   /  'metadata' : 
   /   /   /   /   /   /   /{ 
   /   /   /   /   /   /   /  'slideshow' : 
   /   /   /   /   /   /   /   /{ 
   /   /   /   /   /   /   /   /  'slide_type' : subslide
   /   /   /   /   /   /   /   /}
   /   /   /   /   /   /   /}
   /   /   /   /   /   /  'prompt_number' : 1
   /   /   /   /   /   /  'source' : 
<!--
FrozenIsBool False
-->

##Code

----

<ClassDocStr>

----

```python
# -*- coding: utf-8 -*-
"""


<DefineSource>
@Date : Fri Nov 14 13:20:38 2014 \n
@Author : Erwan Ledoux \n\n
</DefineSource>


A Concluder

"""

#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Standards.Objects.Conditioner"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Tester"
SYS.setSubModule(globals())
#</DefineAugmentation>

#<ImportSpecificModules>
#</ImportSpecificModules>

#<DefineClass>
@DecorationClass()
class ConcluderClass(BaseClass):
	
	#Definition
	RepresentingKeyStrsList=[
									'ConcludingTestVariable',
									'ConcludingConditionVariable',
									'ConcludedConditionIsBoolsList',
									'ConcludedIsBool'
								]

	def default_init(self,
				_ConcludingTestVariable=None,
				_ConcludingConditionVariable=None,
				_ConcludedConditionIsBoolsList=None,
				_ConcludedIsBool=True,
				**_KwargVariablesDict
				):

		#Call the parent init method
		BaseClass.__init__(self,**_KwargVariablesDict)

	def do_conclude(self):
		""" """

		#debug
		'''
		self.debug(('self.',self,['ConcludingConditionVariable']))
		'''
		
		#Apply __getitem__
		self.ConcludedConditionIsBoolsList=map(
				lambda __ConcludingConditionTuple:
				self.condition(
						self.ConcludingTestVariable[
							__ConcludingConditionTuple[0]
						] if type(
							__ConcludingConditionTuple[0])
						in SYS.StrTypesList else __ConcludingConditionTuple[0],
						__ConcludingConditionTuple[1],
						__ConcludingConditionTuple[2]
					).ConditionedIsBool,
				self.ConcludingConditionVariable
			)

		#all
		self.ConcludedIsBool=all(self.ConcludedConditionIsBoolsList)

		#Return self
		#return self
#</DefineClass>

```

<small>
View the Concluder sources on <a href="https://github.com/Ledoux/ShareYourSystem/tree/master/Pythonlogy/ShareYourSystem/Objects/Concluder" target="_blank">Github</a>
</small>


   /   /   /   /   /   /}
   /   /   /   /   /  2 : 
   /   /   /   /   /   /{ 
   /   /   /   /   /   /  'cell_type' : markdown
   /   /   /   /   /   /  'metadata' : 
   /   /   /   /   /   /   /{ 
   /   /   /   /   /   /   /  'slideshow' : 
   /   /   /   /   /   /   /   /{ 
   /   /   /   /   /   /   /   /  'slide_type' : subslide
   /   /   /   /   /   /   /   /}
   /   /   /   /   /   /   /}
   /   /   /   /   /   /  'prompt_number' : 2
   /   /   /   /   /   /  'source' : 
<!---
FrozenIsBool True
-->

##Example

Let's do a simple conclude call
   /   /   /   /   /   /}
   /   /   /   /   /  3 : 
   /   /   /   /   /   /{ 
   /   /   /   /   /   /  'cell_type' : code
   /   /   /   /   /   /  'collapsed' : False
   /   /   /   /   /   /  'input' : ['\n', '#ImportModules\n', 'import ShareYourSystem as SYS\n', 'from ShareYourSystem.Standards.Objects import Concluder\n', 'import operator\n', '\n', '#Definition of an instance Concluder and make it print hello\n', 'MyConcluder=Concluder.ConcluderClass().conclude(\n', "    {'MyColorStr':'Black','MySuperInt':6},\n", '    [\n', '        (\'MyColorStr\',operator.eq,"Black"),\n', "        ('MySuperInt',operator.gt,3),\n", '        (1,operator.eq,1)\n', '    ]\n', ')\n', '    \n', '#Definition the AttestedStr\n', 'SYS._attest(\n', '    [\n', "        'MyConcluder is '+SYS._str(\n", '        MyConcluder,\n', '        **{\n', "            'RepresentingBaseKeyStrsListBool':False,\n", "            'RepresentingAlineaIsBool':False\n", '            }\n', '        ),\n', '    ]\n', ') \n', '\n', '#Print\n', '\n', '\n', '\n', '\n', '\n']
   /   /   /   /   /   /  'language' : python
   /   /   /   /   /   /  'metadata' : 
   /   /   /   /   /   /   /{ 
   /   /   /   /   /   /   /  'slideshow' : 
   /   /   /   /   /   /   /   /{ 
   /   /   /   /   /   /   /   /  'slide_type' : -
   /   /   /   /   /   /   /   /}
   /   /   /   /   /   /   /}
   /   /   /   /   /   /  'outputs' : 
   /   /   /   /   /   /   /[
   /   /   /   /   /   /   /  0 : 
   /   /   /   /   /   /   /   /{ 
   /   /   /   /   /   /   /   /  'output_type' : stream
   /   /   /   /   /   /   /   /  'stream' : stdout
   /   /   /   /   /   /   /   /  'text' : ['\n', '\n', '*****Start of the Attest *****\n', '\n', 'MyConcluder is < (ConcluderClass), 4540757008>\n', '   /{ \n', "   /  '<New><Instance>IdInt' : 4540757008\n", "   /  '<Spe><Instance>ConcludedConditionIsBoolsList' : \n", '   /   /[\n', '   /   /  0 : True\n', '   /   /  1 : True\n', '   /   /  2 : True\n', '   /   /]\n', "   /  '<Spe><Instance>ConcludedIsBool' : True\n", "   /  '<Spe><Instance>ConcludingConditionVariable' : \n", '   /   /[\n', '   /   /  0 : \n', '   /   /   /(\n', '   /   /   /  0 : MyColorStr\n', '   /   /   /  1 : <built-in function eq>\n', '   /   /   /  2 : Black\n', '   /   /   /)\n', '   /   /  1 : \n', '   /   /   /(\n', '   /   /   /  0 : MySuperInt\n', '   /   /   /  1 : <built-in function gt>\n', '   /   /   /  2 : 3\n', '   /   /   /)\n', '   /   /  2 : \n', '   /   /   /(\n', '   /   /   /  0 : 1\n', '   /   /   /  1 : {...}< (builtin_function_or_method), 4522748384>\n', '   /   /   /  2 : 1\n', '   /   /   /)\n', '   /   /]\n', "   /  '<Spe><Instance>ConcludingTestVariable' : \n", '   /   /{ \n', "   /   /  'MyColorStr' : Black\n", "   /   /  'MySuperInt' : 6\n", '   /   /}\n', '   /}\n', '\n', '*****End of the Attest *****\n', '\n', '\n']
   /   /   /   /   /   /   /   /}
   /   /   /   /   /   /   /]
   /   /   /   /   /   /  'prompt_number' : 3
   /   /   /   /   /   /}
   /   /   /   /   /]
   /   /   /   /}
   /   /   /]
   /   /}
   /  '<Spe><Instance>NotebookedPageStrsList' : ['DocumentDoc', 'GithubDoc', 'ExampleDoc', 'ExampleDoc']
   /  '<Spe><Instance>NotebookedSubslideStrsList' : ['slide', 'subslide', 'subslide', '-']
   /  '<Spe><Instance>NotebookedTextStrsList' : ['\n<!--\nFrozenIsBool False\n-->\n\n#Concluder\n\n##Doc\n----\n\n\n> \n> A Concluder\n> \n> \n\n----\n\n<small>\nView the Concluder notebook on [NbViewer](http://nbviewer.ipython.org/url/shareyoursystem.ouvaton.org/Concluder.ipynb)\n</small>\n\n', '\n<!--\nFrozenIsBool False\n-->\n\n##Code\n\n----\n\n<ClassDocStr>\n\n----\n\n```python\n# -*- coding: utf-8 -*-\n"""\n\n\n<DefineSource>\n@Date : Fri Nov 14 13:20:38 2014 \\n\n@Author : Erwan Ledoux \\n\\n\n</DefineSource>\n\n\nA Concluder\n\n"""\n\n#<DefineAugmentation>\nimport ShareYourSystem as SYS\nBaseModuleStr="ShareYourSystem.Standards.Objects.Conditioner"\nDecorationModuleStr="ShareYourSystem.Standards.Classors.Tester"\nSYS.setSubModule(globals())\n#</DefineAugmentation>\n\n#<ImportSpecificModules>\n#</ImportSpecificModules>\n\n#<DefineClass>\n@DecorationClass()\nclass ConcluderClass(BaseClass):\n\t\n\t#Definition\n\tRepresentingKeyStrsList=[\n\t\t\t\t\t\t\t\t\t\'ConcludingTestVariable\',\n\t\t\t\t\t\t\t\t\t\'ConcludingConditionVariable\',\n\t\t\t\t\t\t\t\t\t\'ConcludedConditionIsBoolsList\',\n\t\t\t\t\t\t\t\t\t\'ConcludedIsBool\'\n\t\t\t\t\t\t\t\t]\n\n\tdef default_init(self,\n\t\t\t\t_ConcludingTestVariable=None,\n\t\t\t\t_ConcludingConditionVariable=None,\n\t\t\t\t_ConcludedConditionIsBoolsList=None,\n\t\t\t\t_ConcludedIsBool=True,\n\t\t\t\t**_KwargVariablesDict\n\t\t\t\t):\n\n\t\t#Call the parent init method\n\t\tBaseClass.__init__(self,**_KwargVariablesDict)\n\n\tdef do_conclude(self):\n\t\t""" """\n\n\t\t#debug\n\t\t\'\'\'\n\t\tself.debug((\'self.\',self,[\'ConcludingConditionVariable\']))\n\t\t\'\'\'\n\t\t\n\t\t#Apply __getitem__\n\t\tself.ConcludedConditionIsBoolsList=map(\n\t\t\t\tlambda __ConcludingConditionTuple:\n\t\t\t\tself.condition(\n\t\t\t\t\t\tself.ConcludingTestVariable[\n\t\t\t\t\t\t\t__ConcludingConditionTuple[0]\n\t\t\t\t\t\t] if type(\n\t\t\t\t\t\t\t__ConcludingConditionTuple[0])\n\t\t\t\t\t\tin SYS.StrTypesList else __ConcludingConditionTuple[0],\n\t\t\t\t\t\t__ConcludingConditionTuple[1],\n\t\t\t\t\t\t__ConcludingConditionTuple[2]\n\t\t\t\t\t).ConditionedIsBool,\n\t\t\t\tself.ConcludingConditionVariable\n\t\t\t)\n\n\t\t#all\n\t\tself.ConcludedIsBool=all(self.ConcludedConditionIsBoolsList)\n\n\t\t#Return self\n\t\t#return self\n#</DefineClass>\n\n```\n\n<small>\nView the Concluder sources on <a href="https://github.com/Ledoux/ShareYourSystem/tree/master/Pythonlogy/ShareYourSystem/Objects/Concluder" target="_blank">Github</a>\n</small>\n\n', "\n<!---\nFrozenIsBool True\n-->\n\n##Example\n\nLet's do a simple conclude call", '\n#ImportModules\nimport ShareYourSystem as SYS\nfrom ShareYourSystem.Standards.Objects import Concluder\nimport operator\n\n#Definition of an instance Concluder and make it print hello\nMyConcluder=Concluder.ConcluderClass().conclude(\n\t{\'MyColorStr\':\'Black\',\'MySuperInt\':6},\n\t[\n\t\t(\'MyColorStr\',operator.eq,"Black"),\n\t\t(\'MySuperInt\',operator.gt,3),\n\t\t(1,operator.eq,1)\n\t]\n)\n\t\t\n#Definition the AttestedStr\nSYS._attest(\n\t[\n\t\t\'MyConcluder is \'+SYS._str(\n\t\tMyConcluder,\n\t\t**{\n\t\t\t\'RepresentingBaseKeyStrsListBool\':False,\n\t\t\t\'RepresentingAlineaIsBool\':False\n\t\t\t}\n\t\t),\n\t]\n) \n\n#Print\n\n\n\t\n\n']
   /  '<Spe><Instance>NotebookingFileKeyStr' : Presentation.ipynb
   /}

*****End of the Attest *****


Nbconverter

Doc


The Nbconverter


View the Nbconverter notebook on [NbViewer](http://nbviewer.ipython.org/url/shareyoursystem.ouvaton.org/Nbconverter.ipynb)

Code



# -*- coding: utf-8 -*-
"""


<DefineSource>
@Date : Fri Nov 14 13:20:38 2014 \n
@Author : Erwan Ledoux \n\n
</DefineSource>


The Nbconverter

"""

#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Guiders.Notebooker"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Classer"
SYS.setSubModule(globals())
#</DefineAugmentation>

#<ImportSpecificModules>
import collections
import copy
import json
import os
import sys
Filer=BaseModule
#</ImportSpecificModules>

#<DefineFunctions>
def getNbconvertedMarkdownCellDictsListWithCodeCellDict(_CellDict):
    return [
                {
                    'source': "```python\n"+"".join(
                        map(
                                lambda __LineStr:
                                __LineStr.replace('\t','    '),
                                _CellDict['input']
                            )
                    )+"\n```\n", 
                    'cell_type': 'markdown', 
                    'metadata': {}
                }
            ]+[
                    {
                        'source': "```console\n>>>\n"+"".join(
                            _CellDict['outputs'][0]['text'])+"\n```\n", 
                        'cell_type': 'markdown', 
                        'metadata': {}
                    } 
            ] if len(_CellDict['outputs'])>0 else []

#</DefineFunctions>

#<DefineLocals>
NbconvertingFilePrefixStr=""
#</DefineLocals>

#<DefineClass>
@DecorationClass()
class NbconverterClass(BaseClass):

    #Definition
    RepresentingKeyStrsList=[
                                'NbconvertingFileKeyStr'
                            ]

    def default_init(self,
                        _NbconvertingFileKeyStr="",
                        _NbconvertingFormatStr="Markdown",
                        **_KwargVariablesDict
                    ):

        #Call the parent __init__ method
        BaseClass.__init__(self,**_KwargVariablesDict)

    def do_nbconvert(self):

        #debug
        '''
        self.debug(('self.',self,['FiledHardVariable']))
        '''

        #Check
        if self.NbconvertingFormatStr=="Markdown":

            #debug
            '''
            self.debug(
                        'worksheets are before the markdown '+Representer.represent(
                            self.NbconvertedNotebookDict['worksheets'][0],**{'RepresentingAlineaIsBool':False})
                    )
            '''

            #Transform the code cells into Nbconverted cells
            NbconvertedWorksheetsList=SYS.flat(
                map(
                    lambda __CellDict:
                    getNbconvertedMarkdownCellDictsListWithCodeCellDict(
                        __CellDict
                    ) 
                    if __CellDict['cell_type']=='code'
                    else __CellDict,
                    self.NotebookedCodeDict['worksheets'][0]['cells']
                    )
            )

            #debug
            '''
            self.debug(
                        'NbconvertedWorksheetsList is '+SYS._str(
                            NbconvertedWorksheetsList,**{'RepresentingAlineaIsBool':False})
                        )
            '''

            #set the dict
            self.NotebookedCodeDict['worksheets'][0]['cells']=NbconvertedWorksheetsList

            #debug
            '''
            self.debug(('self.',self,['FilingKeyStr']))
            '''

            #Write
            self.file(
                        self.NbconvertingFileKeyStr.replace('.md','.ipynb'),
                        'w'
            ).write(
                self.NotebookedCodeDict,**{
                    'LoadingFormatStr':'json'
                }
            ).FiledHardVariable.close()

            #debug
            '''
            self.debug(('self.',self,[
                                        'FilingKeyStr',
                                        'FilingModeStr',
                                        'FiledPathStr'
                                    ]))
            '''

            #Definition the NbconvertedCommandStr
            NbconvertedCommandStr=SYS.IPythonPathStr+" nbconvert --to markdown --output "+self.FiledPathStr.replace('.ipynb','')+" "+self.FiledPathStr

        elif self.NbconvertingFormatStr=='Slide':

            #Definition the NbconvertedCommandStr
            NbconvertedCommandStr=SYS.IPythonPathStr+" nbconvert --to slides --output "+self.FiledPathStr.replace('.ipynb','')+" "+self.FiledPathStr

            #debug
            '''
            self.debug(
                        'NbconvertedCommandStr is '+NbconvertedCommandStr,
                        ('self.',self,['FiledPathStr'])
                    )
            '''

        #debug
        '''
        self.debug('NbconvertedCommandStr is '+NbconvertedCommandStr)
        '''

        #Convert
        os.popen(NbconvertedCommandStr)

        #set the name
        if self.NbconvertingFormatStr=='Slide':

            #popen
            os.popen(
                    'mv '+self.FiledPathStr.replace(
                    '.ipynb','.slides.html'
                    )+' '+self.FiledPathStr.replace(
                    '.ipynb','.html'
                )
            )

            #change the reveal.js directory
            self.load(**{
                    'FilingKeyStr':self.FiledPathStr.split('/')[-1].replace(
                        '.ipynb',
                        '.html'
                    ),
                    'LoadingFormatStr':'txt'
                })

            self.LoadedReadVariable=self.LoadedReadVariable.replace(
                'reveal.js/','reveal/'
            ).replace(
                "Reveal.initialize({",
                #"Reveal.initialize({"
                "Reveal.initialize({width: 1000,height: 400,margin: 0.,minScale: 0.5,maxScale: 1.0,"
            )   


            #chunk
            DocumentedOldChunkStrsList=SYS.chunk(
                        ['<code class="language-python">','</code>'],
                        self.LoadedReadVariable,
                        **{'ChunksInt':"All"}
                    )

            #debug
            '''
            self.debug(
                        [
                            'self.DocumentedOldChunkStrsList is ',
                            str(DocumentedOldChunkStrsList)
                        ]
                    )
            '''

            #map
            DocumentedNewChunkStrsList=copy.deepcopy(DocumentedOldChunkStrsList)
            map(
                    lambda __ChunkStr,__ChunkIndexInt:
                    map(
                            lambda __RemoveStr:
                             DocumentedNewChunkStrsList.__setitem__(
                                __ChunkIndexInt,
                                DocumentedNewChunkStrsList[__ChunkIndexInt].replace(
                                    __RemoveStr,
                                    ''
                                )
                            ),
                            map(
                                    lambda __KeyStr:
                                    '<span class="'+__KeyStr+'">',
                                    [
                                        "built_in",
                                        "comment",
                                        "keyword",
                                        "params",
                                        "string",
                                        "number",
                                        "title",
                                        "function",
                                        "decorator",
                                        "class",
                                        #"highlight",
                                        #"kn",
                                        #"c",
                                        #"n",
                                        #"p",
                                        #"o"
                                    ]
                            )+['</span>']
                    ),
                    DocumentedOldChunkStrsList,
                    xrange(len(DocumentedOldChunkStrsList))
                )

            #debug
            '''
            self.debug(
                        [
                            'self.DocumentedNewChunkStrsList is ',
                            str(DocumentedNewChunkStrsList)
                        ]
                    )
            '''

            #replace
            map(
                    lambda __DocumentedOldChunkStr,__DocumentedNewChunkStr:
                    self.__setattr__(
                            'LoadedReadVariable',
                            self.LoadedReadVariable.replace(__DocumentedOldChunkStr,__DocumentedNewChunkStr)
                        ),
                    DocumentedOldChunkStrsList,
                    DocumentedNewChunkStrsList
                )

            #write
            self.write(self.LoadedReadVariable).close()

        #Return self
        #return self    

#</DefineClass>

View the Nbconverter sources on Github

Example

Let's create a Slide Presentation like file


In [19]:
#ImportModules
import ShareYourSystem as SYS
from ShareYourSystem.Guiders import Nbconverter

#Definition a Nbconverter
MyNbconverter=Nbconverter.NbconverterClass().package(
        'ShareYourSystem.Standards.Objects.Concluder'
    ).scriptbook(
        **{
            'GuidingBookStr':'Doc'
        }
    ).notebook(
        'Presentation.ipynb'
    ).nbconvert(
        'Readme.md',
        'Slide'
)
    
#Definition the AttestedStr
SYS._attest(
    [
        'MyNbconverter is '+SYS._str(
        MyNbconverter,
        **{
            'RepresentingBaseKeyStrsListBool':False,
            'RepresentingAlineaIsBool':False
            }
        )
    ]
)  

#Print



*****Start of the Attest *****

MyNbconverter is < (NbconverterClass), 4540813520>
   /{ 
   /  '<New><Instance>IdInt' : 4540813520
   /  '<New><Instance>NotebookedScriptStrsList' : ['Markdown', 'Markdown', 'Markdown', 'Python']
   /  '<New><Instance>ScriptbookedSortDict' : 
   /   /{ 
   /   /  'DocumentDoc.md' : 001_DocumentDoc.md
   /   /  'ExampleDoc.md' : 00_ExampleDoc.md
   /   /  'ExampleDoc.py' : 01_ExampleDoc.py
   /   /  'GithubDoc.md' : 002_GithubDoc.md
   /   /}
   /  '<New><Instance>_CapturingStopBool' : True
   /  '<Spe><Instance>NbconvertingFileKeyStr' : Readme.md
   /}

*****End of the Attest *****


Installer

Doc


The Installer collects ModuleStrs to write


View the Installer notebook on [NbViewer](http://nbviewer.ipython.org/url/shareyoursystem.ouvaton.org/Installer.ipynb)

Code



# -*- coding: utf-8 -*-
"""


<DefineSource>
@Date : Fri Nov 14 13:20:38 2014 \n
@Author : Erwan Ledoux \n\n
</DefineSource>


The Installer collects ModuleStrs to write 

"""

#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Guiders.Nbconverter"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Classer"
SYS.setSubModule(globals())
#</DefineAugmentation>

#<ImportSpecificModules>
import os
import copy
from ShareYourSystem.Standards.Interfacers import Loader,Writer
#</ImportSpecificModules>

#<DefineLocals>
InstallingSysFolderPathStr=SYS.PythonlogyLocalFolderPathStr
InstallingLibraryFolderPathStr=InstallingSysFolderPathStr+'/docs/LibraryReference/'
#</DefineLocals>

#<DefineClass>
@DecorationClass(**{
    'ClassingSwitchMethodStrsList':['install']
})
class InstallerClass(BaseClass):

    #Definition
    RepresentingKeyStrsList=[
                                    'InstallingModuleStrsList',
                                    'InstallingAllBool'
                                ]

    def default_init(self,
                        _InstallingModuleStrsList=None,
                        _InstallingAllBool=False,
                        **_KwargVariablesDict
                    ):

        #Call the parent __init__ method
        BaseClass.__init__(self,**_KwargVariablesDict)


    def do_install(self):

        #Definition
        self.load(
            **{
                'FolderingPathVariable':InstallingSysFolderPathStr,
                'FilingKeyStr':'setup.py'
            }
        )

        #chunk to set the InstalledModuleStrsList
        InstalledPackageStr=SYS.chunk(
            ['packages=[','],'],self.LoadedReadVariable
        )[0]
        InstalledTextStrsList=InstalledPackageStr.split('\n')
        InstalledTextStrListsList=SYS._filter(
            lambda __InstalledChunkList:
            len(__InstalledChunkList)>0,
            map(
                    lambda __InstalledTextStr:
                    SYS.chunk(
                        ["'ShareYourSystem","',"],
                        __InstalledTextStr
                    ),
                    InstalledTextStrsList
            )
        )

        self.InstallingModuleStrsList=map(
            lambda __InstalledTextStrList:
            ('ShareYourSystem'+__InstalledTextStrList[0])
            if __InstalledTextStrList[0]!="'"
            else 'ShareYourSystem',
            InstalledTextStrListsList
        )

        #debug
        '''
        self.debug(('self.',self,['InstallingModuleStrsList']))
        '''

        #map
        self.InstalledModulePathStrsList=map(
            lambda __InstallingModuleStr:
            __InstallingModuleStr.replace('.','/'),
            self.InstallingModuleStrsList
        )

        #debug
        '''
        self.debug(('self.',self,['InstalledModulePathStrsList']))
        '''

        #set with all the NameStrs
        self.InstalledNameStrsList=map(
                    lambda __InstalledModulePathStr:
                    __InstalledModulePathStr.split('/')[-1],
                    self.InstalledModulePathStrsList
            )

        #Return self
        #return self

#</DefineClass>

View the Installer sources on Github

Example

Let's create an empty class, which will automatically receive special attributes from the decorating ClassorClass, specially the NameStr, that should be the ClassStr without the TypeStr in the end.


In [23]:
#ImportModules
import ShareYourSystem as SYS
from ShareYourSystem.Guiders import Installer

#Definition a Installer instance
MyInstaller=Installer.InstallerClass().install(_AllBool=True)

#Definition the AttestedStr
SYS._attest(
    [
        'MyInstaller is '+SYS._str(
        MyInstaller,
        **{
            'RepresentingBaseKeyStrsListBool':False
        }
        )
    ]
)  

#Print



*****Start of the Attest *****

MyInstaller is < (InstallerClass), 4540557008>
   /{ 
   /  '<New><Instance>IdInt' : 4540557008
   /  '<New><Instance>InstalledModulePathStrsList' : ['ShareYourSystem', 'ShareYourSystem/Objects/Object', 'ShareYourSystem/Objects/Initiator', 'ShareYourSystem/Classors/Classor', 'ShareYourSystem/Classors/Defaultor', 'ShareYourSystem/Classors/Doer', 'ShareYourSystem/Classors/Deriver', 'ShareYourSystem/Classors/Propertiser', 'ShareYourSystem/Classors/Inspecter', 'ShareYourSystem/Classors/Representer', 'ShareYourSystem/Objects/Printer', 'ShareYourSystem/Objects/Debugger', 'ShareYourSystem/Functers/Functer', 'ShareYourSystem/Classors/Attester', 'ShareYourSystem/Classors/Tester', 'ShareYourSystem/Functers/Functer', 'ShareYourSystem/Functers/Hooker', 'ShareYourSystem/Functers/Triggerer', 'ShareYourSystem/Objects/Conditioner', 'ShareYourSystem/Objects/Concluder', 'ShareYourSystem/Classors/Observer', 'ShareYourSystem/Classors/Binder', 'ShareYourSystem/Classors/Watcher', 'ShareYourSystem/Classors/Resetter', 'ShareYourSystem/Classors/Switcher', 'ShareYourSystem/Classors/Mimicker', 'ShareYourSystem/Objects/Caller', 'ShareYourSystem/Objects/Cloner', 'ShareYourSystem/Classors/Classer', 'ShareYourSystem/Objects/Rebooter', 'ShareYourSystem/Functers/Argumenter', 'ShareYourSystem/Functers/Imitater', 'ShareYourSystem/Functers/Alerter', 'ShareYourSystem/Interfacers/Interfacer', 'ShareYourSystem/Interfacers/Folderer', 'ShareYourSystem/Objects/Packager', 'ShareYourSystem/Interfacers/Filer', 'ShareYourSystem/Interfacers/Closer', 'ShareYourSystem/Interfacers/Loader', 'ShareYourSystem/Interfacers/Writer', 'ShareYourSystem/Interfacers/Deployer', 'ShareYourSystem/Interfacers/Hdformater', 'ShareYourSystem/Interfacers/Capturer', 'ShareYourSystem/Interfacers/Processer', 'ShareYourSystem/Interfacers/Statuser', 'ShareYourSystem/Interfacers/Killer', 'ShareYourSystem/Interfacers/Directer', 'ShareYourSystem/Guiders/Guider', 'ShareYourSystem/Guiders/Scriptbooker', 'ShareYourSystem/Guiders/Celler', 'ShareYourSystem/Guiders/Notebooker', 'ShareYourSystem/Guiders/Nbconverter', 'ShareYourSystem/Guiders/Installer', 'ShareYourSystem/Guiders/Documenter', 'ShareYourSystem/Guiders/Documenter', 'ShareYourSystem/Itemizers/Itemizer', 'ShareYourSystem/Itemizers/Getter', 'ShareYourSystem/Itemizers/Setter', 'ShareYourSystem/Itemizers/Deleter', 'ShareYourSystem/Itemizers/Attributer', 'ShareYourSystem/Itemizers/Restricter', 'ShareYourSystem/Itemizers/Pather', 'ShareYourSystem/Itemizers/Grasper', 'ShareYourSystem/Itemizers/Sharer', 'ShareYourSystem/Itemizers/Executer', 'ShareYourSystem/Applyiers/Applyier', 'ShareYourSystem/Applyiers/Mapper', 'ShareYourSystem/Applyiers/Picker', 'ShareYourSystem/Applyiers/Gatherer', 'ShareYourSystem/Applyiers/Updater', 'ShareYourSystem/Itemizers/Pointer', 'ShareYourSystem/Applyiers/Linker', 'ShareYourSystem/Applyiers/Weaver', 'ShareYourSystem/Applyiers/Filterer', 'ShareYourSystem/Noders/Noder', 'ShareYourSystem/Functers/Outputer', 'ShareYourSystem/Noders/Appender', 'ShareYourSystem/Noders/Instancer', 'ShareYourSystem/Noders/Adder', 'ShareYourSystem/Noders/Distinguisher', 'ShareYourSystem/Noders/Parenter', 'ShareYourSystem/Noders/Collecter', 'ShareYourSystem/Applyiers/Pusher', 'ShareYourSystem/Applyiers/Producer', 'ShareYourSystem/Noders/Catcher', 'ShareYourSystem/Noders/Attentioner', 'ShareYourSystem/Noders/Coupler', 'ShareYourSystem/Noders/Settler', 'ShareYourSystem/Applyiers/Commander', 'ShareYourSystem/Walkers/Walker', 'ShareYourSystem/Walkers/Cumulater', 'ShareYourSystem/Walkers/Visiter', 'ShareYourSystem/Walkers/Recruiter', 'ShareYourSystem/Walkers/Mobilizer', 'ShareYourSystem/Walkers/Router', 'ShareYourSystem/Walkers/Grabber', 'ShareYourSystem/Applyiers/Poker', 'ShareYourSystem/Noders/Connecter', 'ShareYourSystem/Noders/Networker', 'ShareYourSystem/Noders/Transmitter', 'ShareYourSystem/Noders/Grouper', 'ShareYourSystem/Noders/Structurer', 'ShareYourSystem/Noders/Organizer', 'ShareYourSystem/Storers/Storer', 'ShareYourSystem/Databasers', 'ShareYourSystem/Databasers/Databaser', 'ShareYourSystem/Databasers/Modeler', 'ShareYourSystem/Databasers/Tabularer', 'ShareYourSystem/Databasers/Tabler', 'ShareYourSystem/Databasers/Rower', 'ShareYourSystem/Databasers/Inserter', 'ShareYourSystem/Databasers/Retriever', 'ShareYourSystem/Databasers/Findoer', 'ShareYourSystem/Databasers/Recoverer', 'ShareYourSystem/Databasers/Shaper', 'ShareYourSystem/Databasers/Merger', 'ShareYourSystem/Databasers/Joiner', 'ShareYourSystem/Databasers/Hierarchizer', 'ShareYourSystem/Storers/Grider', 'ShareYourSystem/Storers/Explorer', 'ShareYourSystem/Storers/Controller', 'ShareYourSystem/Databasers/Featurer', 'ShareYourSystem/Databasers/Recuperater', 'ShareYourSystem/Ploters/Ploter', 'ShareYourSystem/Ploters/Axer', 'ShareYourSystem/Ploters/Paneler', 'ShareYourSystem/Ploters/Figurer', 'ShareYourSystem/Ploters/Pyploter', 'ShareYourSystem/Tutorials/Incrementer', 'ShareYourSystem/Tutorials/Decrementer', 'ShareYourSystem/Tutorials/Multiplier', 'ShareYourSystem/Tutorials/Sumer', 'ShareYourSystem/Tutorials/Modulizer', 'ShareYourSystem/Simulaters/Simulater', 'ShareYourSystem/Simulaters/Runner', 'ShareYourSystem/Simulaters/Moniter', 'ShareYourSystem/Simulaters/Populater', 'ShareYourSystem/Simulaters/Dynamizer', 'ShareYourSystem/Simulaters/Lifer', 'ShareYourSystem/Simulaters/Rater', 'ShareYourSystem/Simulaters/Brianer', 'ShareYourSystem/Simulaters/Pydelayer', 'ShareYourSystem/Muzikers/Muziker', 'ShareYourSystem/Muzikers/Vexflower', 'ShareYourSystem/Muzikers/Permuter', 'ShareYourSystem/Muzikers/Differenciater', 'ShareYourSystem/Muzikers/Pooler', 'ShareYourSystem/Muzikers/Harmonizer', 'ShareYourSystem/Objects', 'ShareYourSystem/Classors', 'ShareYourSystem/Functers', 'ShareYourSystem/Interfacers', 'ShareYourSystem/Guiders', 'ShareYourSystem/Itemizers', 'ShareYourSystem/Applyiers', 'ShareYourSystem/Walkers', 'ShareYourSystem/Noders', 'ShareYourSystem/Storers', 'ShareYourSystem/Databasers', 'ShareYourSystem/Ploters', 'ShareYourSystem/Tutorials', 'ShareYourSystem/Simulaters', "ShareYourSystem/Muzikers'", "ShareYourSystem':["]
   /  '<New><Instance>InstalledNameStrsList' : ['ShareYourSystem', 'Object', 'Initiator', 'Classor', 'Defaultor', 'Doer', 'Deriver', 'Propertiser', 'Inspecter', 'Representer', 'Printer', 'Debugger', 'Functer', 'Attester', 'Tester', 'Functer', 'Hooker', 'Triggerer', 'Conditioner', 'Concluder', 'Observer', 'Binder', 'Watcher', 'Resetter', 'Switcher', 'Mimicker', 'Caller', 'Cloner', 'Classer', 'Rebooter', 'Argumenter', 'Imitater', 'Alerter', 'Interfacer', 'Folderer', 'Packager', 'Filer', 'Closer', 'Loader', 'Writer', 'Deployer', 'Hdformater', 'Capturer', 'Processer', 'Statuser', 'Killer', 'Directer', 'Guider', 'Scriptbooker', 'Celler', 'Notebooker', 'Nbconverter', 'Installer', 'Documenter', 'Documenter', 'Itemizer', 'Getter', 'Setter', 'Deleter', 'Attributer', 'Restricter', 'Pather', 'Grasper', 'Sharer', 'Executer', 'Applyier', 'Mapper', 'Picker', 'Gatherer', 'Updater', 'Pointer', 'Linker', 'Weaver', 'Filterer', 'Noder', 'Outputer', 'Appender', 'Instancer', 'Adder', 'Distinguisher', 'Parenter', 'Collecter', 'Pusher', 'Producer', 'Catcher', 'Attentioner', 'Coupler', 'Settler', 'Commander', 'Walker', 'Cumulater', 'Visiter', 'Recruiter', 'Mobilizer', 'Router', 'Grabber', 'Poker', 'Connecter', 'Networker', 'Transmitter', 'Grouper', 'Structurer', 'Organizer', 'Storer', 'Databasers', 'Databaser', 'Modeler', 'Tabularer', 'Tabler', 'Rower', 'Inserter', 'Retriever', 'Findoer', 'Recoverer', 'Shaper', 'Merger', 'Joiner', 'Hierarchizer', 'Grider', 'Explorer', 'Controller', 'Featurer', 'Recuperater', 'Ploter', 'Axer', 'Paneler', 'Figurer', 'Pyploter', 'Incrementer', 'Decrementer', 'Multiplier', 'Sumer', 'Modulizer', 'Simulater', 'Runner', 'Moniter', 'Populater', 'Dynamizer', 'Lifer', 'Rater', 'Brianer', 'Pydelayer', 'Muziker', 'Vexflower', 'Permuter', 'Differenciater', 'Pooler', 'Harmonizer', 'Objects', 'Classors', 'Functers', 'Interfacers', 'Guiders', 'Itemizers', 'Applyiers', 'Walkers', 'Noders', 'Storers', 'Databasers', 'Ploters', 'Tutorials', 'Simulaters', "Muzikers'", "ShareYourSystem':["]
   /  '<Spe><Instance>InstallingAllBool' : True
   /  '<Spe><Instance>InstallingModuleStrsList' : ['ShareYourSystem', 'ShareYourSystem.Standards.Objects.Object', 'ShareYourSystem.Standards.Objects.Initiator', 'ShareYourSystem.Standards.Classors.Classor', 'ShareYourSystem.Standards.Classors.Defaultor', 'ShareYourSystem.Standards.Classors.Doer', 'ShareYourSystem.Standards.Classors.Deriver', 'ShareYourSystem.Standards.Classors.Propertiser', 'ShareYourSystem.Standards.Classors.Inspecter', 'ShareYourSystem.Standards.Classors.Representer', 'ShareYourSystem.Standards.Interfacers.Printer', 'ShareYourSystem.Standards.Objects.Debugger', 'ShareYourSystem.Functers.Functer', 'ShareYourSystem.Standards.Classors.Attester', 'ShareYourSystem.Standards.Classors.Tester', 'ShareYourSystem.Functers.Functer', 'ShareYourSystem.Functers.Hooker', 'ShareYourSystem.Functers.Triggerer', 'ShareYourSystem.Standards.Objects.Conditioner', 'ShareYourSystem.Standards.Objects.Concluder', 'ShareYourSystem.Standards.Classors.Observer', 'ShareYourSystem.Standards.Classors.Binder', 'ShareYourSystem.Standards.Classors.Watcher', 'ShareYourSystem.Standards.Classors.Resetter', 'ShareYourSystem.Standards.Classors.Switcher', 'ShareYourSystem.Standards.Classors.Mimicker', 'ShareYourSystem.Standards.Objects.Caller', 'ShareYourSystem.Standards.Objects.Cloner', 'ShareYourSystem.Standards.Classors.Classer', 'ShareYourSystem.Standards.Objects.Rebooter', 'ShareYourSystem.Functers.Argumenter', 'ShareYourSystem.Functers.Imitater', 'ShareYourSystem.Functers.Alerter', 'ShareYourSystem.Standards.Interfacers.Interfacer', 'ShareYourSystem.Standards.Interfacers.Folderer', 'ShareYourSystem.Standards.Objects.Packager', 'ShareYourSystem.Standards.Interfacers.Filer', 'ShareYourSystem.Standards.Interfacers.Closer', 'ShareYourSystem.Standards.Interfacers.Loader', 'ShareYourSystem.Standards.Interfacers.Writer', 'ShareYourSystem.Standards.Interfacers.Deployer', 'ShareYourSystem.Standards.Interfacers.Hdformater', 'ShareYourSystem.Standards.Interfacers.Capturer', 'ShareYourSystem.Standards.Interfacers.Processer', 'ShareYourSystem.Standards.Interfacers.Statuser', 'ShareYourSystem.Standards.Interfacers.Killer', 'ShareYourSystem.Standards.Interfacers.Directer', 'ShareYourSystem.Guiders.Guider', 'ShareYourSystem.Guiders.Scriptbooker', 'ShareYourSystem.Guiders.Celler', 'ShareYourSystem.Guiders.Notebooker', 'ShareYourSystem.Guiders.Nbconverter', 'ShareYourSystem.Guiders.Installer', 'ShareYourSystem.Guiders.Documenter', 'ShareYourSystem.Guiders.Documenter', 'ShareYourSystem.Standards.Itemizers.Itemizer', 'ShareYourSystem.Standards.Itemizers.Getter', 'ShareYourSystem.Standards.Itemizers.Setter', 'ShareYourSystem.Standards.Itemizers.Deleter', 'ShareYourSystem.Standards.Itemizers.Attributer', 'ShareYourSystem.Standards.Itemizers.Restricter', 'ShareYourSystem.Standards.Itemizers.Pather', 'ShareYourSystem.Standards.Itemizers.Grasper', 'ShareYourSystem.Standards.Itemizers.Sharer', 'ShareYourSystem.Standards.Itemizers.Executer', 'ShareYourSystem.Applyiers.Applyier', 'ShareYourSystem.Applyiers.Mapper', 'ShareYourSystem.Applyiers.Picker', 'ShareYourSystem.Applyiers.Gatherer', 'ShareYourSystem.Applyiers.Updater', 'ShareYourSystem.Standards.Itemizers.Pointer', 'ShareYourSystem.Applyiers.Linker', 'ShareYourSystem.Applyiers.Weaver', 'ShareYourSystem.Applyiers.Filterer', 'ShareYourSystem.Standards.Noders.Noder', 'ShareYourSystem.Functers.Outputer', 'ShareYourSystem.Standards.Noders.Appender', 'ShareYourSystem.Standards.Noders.Instancer', 'ShareYourSystem.Standards.Noders.Adder', 'ShareYourSystem.Standards.Noders.Distinguisher', 'ShareYourSystem.Standards.Noders.Parenter', 'ShareYourSystem.Standards.Noders.Collecter', 'ShareYourSystem.Applyiers.Pusher', 'ShareYourSystem.Applyiers.Producer', 'ShareYourSystem.Standards.Noders.Catcher', 'ShareYourSystem.Standards.Noders.Attentioner', 'ShareYourSystem.Standards.Noders.Coupler', 'ShareYourSystem.Standards.Noders.Settler', 'ShareYourSystem.Applyiers.Commander', 'ShareYourSystem.Standards.Walkers.Walker', 'ShareYourSystem.Standards.Walkers.Cumulater', 'ShareYourSystem.Standards.Walkers.Visiter', 'ShareYourSystem.Standards.Walkers.Recruiter', 'ShareYourSystem.Standards.Walkers.Mobilizer', 'ShareYourSystem.Standards.Walkers.Router', 'ShareYourSystem.Standards.Walkers.Grabber', 'ShareYourSystem.Applyiers.Poker', 'ShareYourSystem.Standards.Noders.Connecter', 'ShareYourSystem.Standards.Noders.Networker', 'ShareYourSystem.Standards.Noders.Transmitter', 'ShareYourSystem.Standards.Noders.Grouper', 'ShareYourSystem.Standards.Noders.Structurer', 'ShareYourSystem.Standards.Noders.Organizer', 'ShareYourSystem.Storers.Storer', 'ShareYourSystem.Standards.Modelers', 'ShareYourSystem.Standards.Modelers.Databaser', 'ShareYourSystem.Standards.Modelers.Modeler', 'ShareYourSystem.Standards.Modelers.Tabularer', 'ShareYourSystem.Standards.Modelers.Tabler', 'ShareYourSystem.Standards.Modelers.Rower', 'ShareYourSystem.Standards.Modelers.Inserter', 'ShareYourSystem.Standards.Modelers.Retriever', 'ShareYourSystem.Standards.Modelers.Findoer', 'ShareYourSystem.Standards.Modelers.Recoverer', 'ShareYourSystem.Standards.Modelers.Shaper', 'ShareYourSystem.Standards.Modelers.Merger', 'ShareYourSystem.Standards.Modelers.Joiner', 'ShareYourSystem.Standards.Modelers.Hierarchizer', 'ShareYourSystem.Storers.Grider', 'ShareYourSystem.Storers.Explorer', 'ShareYourSystem.Storers.Controller', 'ShareYourSystem.Standards.Modelers.Featurer', 'ShareYourSystem.Standards.Modelers.Recuperater', 'ShareYourSystem.Ploters.Ploter', 'ShareYourSystem.Ploters.Axer', 'ShareYourSystem.Ploters.Paneler', 'ShareYourSystem.Ploters.Figurer', 'ShareYourSystem.Ploters.Pyploter', 'ShareYourSystem.Tutorials.Incrementer', 'ShareYourSystem.Tutorials.Decrementer', 'ShareYourSystem.Tutorials.Multiplier', 'ShareYourSystem.Tutorials.Sumer', 'ShareYourSystem.Tutorials.Modulizer', 'ShareYourSystem.Specials.Simulaters.Simulater', 'ShareYourSystem.Specials.Simulaters.Runner', 'ShareYourSystem.Specials.Simulaters.Moniter', 'ShareYourSystem.Specials.Simulaters.Populater', 'ShareYourSystem.Specials.Simulaters.Dynamizer', 'ShareYourSystem.Specials.Simulaters.Lifer', 'ShareYourSystem.Specials.Simulaters.Rater', 'ShareYourSystem.Specials.Simulaters.Brianer', 'ShareYourSystem.Specials.Simulaters.Pydelayer', 'ShareYourSystem.Muzikers.Muziker', 'ShareYourSystem.Muzikers.Vexflower', 'ShareYourSystem.Muzikers.Permuter', 'ShareYourSystem.Muzikers.Differenciater', 'ShareYourSystem.Muzikers.Pooler', 'ShareYourSystem.Muzikers.Harmonizer', 'ShareYourSystem.Standards.Objects', 'ShareYourSystem.Standards.Classors', 'ShareYourSystem.Functers', 'ShareYourSystem.Standards.Interfacers', 'ShareYourSystem.Guiders', 'ShareYourSystem.Standards.Itemizers', 'ShareYourSystem.Applyiers', 'ShareYourSystem.Standards.Walkers', 'ShareYourSystem.Standards.Noders', 'ShareYourSystem.Storers', 'ShareYourSystem.Standards.Modelers', 'ShareYourSystem.Ploters', 'ShareYourSystem.Tutorials', 'ShareYourSystem.Specials.Simulaters', "ShareYourSystem.Muzikers'", "ShareYourSystem':["]
   /}

*****End of the Attest *****


Documenter

Doc


The Documenter


View the Documenter notebook on [NbViewer](http://nbviewer.ipython.org/url/shareyoursystem.ouvaton.org/Documenter.ipynb)

Code



# -*- coding: utf-8 -*-
"""


<DefineSource>
@Date : Fri Nov 14 13:20:38 2014 \n
@Author : Erwan Ledoux \n\n
</DefineSource>


The Documenter

"""

#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Guiders.Documenter"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Classer"
SYS.setSubModule(globals())
#</DefineAugmentation>

#<ImportSpecificModules>
import collections
import os
import copy
import sys
from ShareYourSystem.Standards.Classors import Doer
from ShareYourSystem.Guiders import Celler
Readmer=BaseModule
#</ImportSpecificModules>

#<DefineLocals>
DocumentingOntologyLocalFolderPathStr=SYS.ShareYourSystemLocalFolderPathStr+'Ouvaton/'
DocumentingNbviewerLocalFolderPathStr=SYS.ShareYourSystemLocalFolderPathStr+'Ouvaton/'
DocumentingDocumentLocalFolderPathStr=SYS.ShareYourSystemLocalFolderPathStr+'docs/LibraryReference/'
DocumentingOntologyOuvatonFolderPathStr='/httpdocs/slides/'
DocumentingNbviewerOuvatonFolderPathStr='/httpdocs/ipython/'
#</DefineLocals>

#<DefineFunctions>
def getDocumentedReadmeInstanceVariableWithFolderPathStr(
        _InstanceVariable,_FolderPathStr
    ):

    #file first
    return _InstanceVariable.notebook(
            **{
                'FolderingPathVariable':_FolderPathStr,
                'GuidingBookStr':"Doc",
                'NotebookingFileKeyStr':"Presentation.ipynb"
            }
    ).nbconvert("Readme.md")
#</DefineFunctions>


#<DefineClass>
@DecorationClass()
class DocumenterClass(BaseClass):

    #Definition
    RepresentingKeyStrsList=[
                                'DocumentingConceptFolderPathStr',
                                'DocumentingSubReadmeIsBool',
                                'DocumentingConceptReadmeIsBool',
                                'DocumentingConceptDocumentIsBool',
                                'DocumentingConceptSlideIsBool',
                                'DocumentingSiteDocumentIsBool',
                                'DocumentedConceptModule',
                                'DocumentedConceptModuleStr',
                                'DocumentedConceptModuleFolderPathStr',
                                'DocumentedSubNameStrsList',
                                'DocumentedSubModulesList',
                                'DocumentedSubModuleStrsList',
                                'DocumentedSubModuleLocalFolderPathStrsList',
                                #'DocumentedPresentationsDictsList',
                                #'DocumentedConceptNotebookDict'
                            ]

    def default_init(self,
                        _DocumentingConceptFolderPathStr="",
                        _DocumentingSubReadmeIsBool=True,
                        _DocumentingConceptReadmeIsBool=True,
                        _DocumentingConceptDocumentIsBool=True,
                        _DocumentingConceptSlideIsBool=True,
                        _DocumentingSiteDocumentIsBool=True,
                        _DocumentedConceptModule=None,
                        _DocumentedConceptModuleStr="",
                        _DocumentedConceptModuleFolderPathStr="",
                        _DocumentedSubNameStrsList=None,
                        _DocumentedSubModulesList=None,
                        _DocumentedSubModuleStrsList=None,
                        _DocumentedSubModuleLocalFolderPathStrsList=None,
                        _DocumentedPresentationsDictsList=None,
                        _DocumentedConceptNotebookDict=None,
                        **_KwargVariablesDict
                    ):

        #Call the parent __init__ method
        BaseClass.__init__(self,**_KwargVariablesDict)

    def do_inform(self):

        #debug
        '''
        self.debug(('self.',self,['DocumentingSubReadmeIsBool','DocumentingConceptDocumentIsBool']))
        '''

        #install first
        self.install()

        #Check
        if self.DocumentingConceptFolderPathStr=="":
            self.DocumentingConceptFolderPathStr='ShareYourSystem'.join(
                os.getcwd().split('ShareYourSystem')[:-1]
            )+'ShareYourSystem/'

        #debug
        '''
        self.debug(('self.',self,['DocumentingConceptFolderPathStr']))
        '''

        #debug
        self.folder(self.DocumentingConceptFolderPathStr)
        self.DocumentedConceptModuleStr=self.FolderedModuleStr

        #debug
        '''
        self.debug(('self.',self,[
                                    'FolderedModuleStr',
                                    'FolderedDirKeyStrsList'
                                ]))
        '''

        #filter
        self.DocumentedSubNameStrsList=SYS._filter(
            lambda __FolderedDirKeyStr:
            os.path.isdir(
                self.FolderingPathVariable+__FolderedDirKeyStr
            ) and __FolderedDirKeyStr in Doer.DoerStrToDoStrOrderedDict.keys(),
            self.FolderedDirKeyStrsList
        )   

        #debug
        '''
        self.debug(('self.',self,['DocumentedSubNameStrsList','InstalledNameStrsList']))
        '''

        #sort
        self.DocumentedSubNameStrsList=SYS._filter(
                lambda __InstalledNameStr:
                __InstalledNameStr in self.DocumentedSubNameStrsList,
                self.InstalledNameStrsList
            )
        #map
        self.DocumentedSubModuleStrsList=map(
            lambda __DocumentedSubNameStr:
            self.DocumentedConceptModuleStr+'.'+__DocumentedSubNameStr,
            self.DocumentedSubNameStrsList
        )   

        #Check
        self.DocumentedConceptNameStr=self.FolderingPathVariable.split(
                    '/'
            )[-1] if self.FolderingPathVariable[-1]!='/' else self.FolderingPathVariable.split('/'
            )[-2]

        #debug
        '''
        self.debug(('self.',self,[
                                    'DocumentedSubNameStrsList',
                                    'DocumentedSubModuleStrsList',
                                    'DocumentedConceptNameStr'
                                ]))
        '''

        #check
        if self.DocumentedConceptNameStr in SYS.PluralStrToSingularStrOrderedDict.keys():

            #package
            self.DocumentedConceptModule=self.package(
                self.FolderedModuleStr
            ).PackagedModuleVariable

        #join
        self.DocumentedConceptModuleFolderPathStr='/'.join(
            self.DocumentedConceptModule.__file__.split(
            '/'
            )[:-1]
        )+'/'

        #debug
        '''
        self.debug(('self.',self,['DocumentedConceptModule']))
        '''

        #filter
        self.DocumentedSubModulesList=SYS._filter(
                lambda __AttributeValueVariable:
                type(__AttributeValueVariable).__name__=='module',
                self.DocumentedConceptModule.__dict__.values()
            )

        #debug
        '''
        self.debug((
                    'self.',self,[
                            'DocumentedSubModulesList'
                        ]
                    ))
        '''

        #Check
        if self.DocumentingSubReadmeIsBool:

            #debug
            '''
            self.debug(
                        [
                            'we build sub modules readmes here',
                            ('self.',self,['DocumentedSubModuleStrsList'])
                        ]
                    )
            '''

            #map
            map(
                    lambda __DocumentedSubModuleStr:
                    self.package(
                            __DocumentedSubModuleStr
                        ).scriptbook(
                        _GuideTuplesList=[
                                ('001','Document','Markdown'),
                            ],
                            **{
                                'GuidingBookStr':"Doc",
                            }
                        ).notebook(
                            "PreReadme.ipynb"
                        ).nbconvert(
                            "Readme.md"
                        ),
                    self.DocumentedSubModuleStrsList
                )

        #Check
        if self.DocumentingConceptSlideIsBool:

            #debug
            '''
            self.debug(
                        [
                            'we slide here',
                            ('self.',self,['DocumentedSubModuleStrsList'])
                        ]
                        )
            '''

            #map
            map(
                    lambda __DocumentedSubModuleStr:
                    self.package(
                            __DocumentedSubModuleStr
                        ).scriptbook(
                        _GuideTuplesList=[
                                ('001','Document','Markdown'),
                                ('002','Github','Markdown'),
                            ],
                            **{
                                'GuidingBookStr':"Doc",
                            }
                        ).notebook(
                            "Presentation.ipynb",
                            **{'WritingLoadBool':False}
                        ).nbconvert(
                            "Presentation.html",
                            'Slide'
                        ),
                    self.DocumentedSubModuleStrsList
                )

            #mv for Nbviewer ipython notebooks
            map(
                    lambda __DocumentedSubModuleStr:
                    os.popen(
                        'cp '+sys.modules[
                            __DocumentedSubModuleStr
                        ].LocalFolderPathStr+'Presentation.ipynb '+DocumentingNbviewerLocalFolderPathStr+__DocumentedSubModuleStr.split(
                                '.'
                            )[-1]+'.ipynb'
                    ),
                    self.DocumentedSubModuleStrsList
                )

            #mv for Ouvaton slide in html
            map(
                    lambda __DocumentedSubModuleStr:
                    os.popen(
                        'cp '+sys.modules[
                            __DocumentedSubModuleStr
                        ].LocalFolderPathStr+'Presentation.html '+DocumentingOntologyLocalFolderPathStr+__DocumentedSubModuleStr.split(
                                '.'
                            )[-1]+'.html'
                    ),
                    self.DocumentedSubModuleStrsList
                )

            #mv for Ouvaton slide in php
            map(
                    lambda __DocumentedSubModuleStr:
                    os.popen(
                        'cp '+sys.modules[
                            __DocumentedSubModuleStr
                        ].LocalFolderPathStr+'Presentation.html '+DocumentingOntologyLocalFolderPathStr+__DocumentedSubModuleStr.split(
                                '.'
                            )[-1]+'.php'
                    ),
                    self.DocumentedSubModuleStrsList
                )

            #map
            self.DocumentedSubModuleLocalFolderPathStrsList=map(
                    lambda __DocumentedSubModuleStr:
                    SYS.PythonlogyLocalFolderPathStr+__DocumentedSubModuleStr.replace(
                        '.','/'
                    ),
                    self.DocumentedSubModuleStrsList
                )

            #map
            self.DocumentedPresentationsDictsList=map(
                    lambda __DocumentedSubModuleFolderPathStr:
                    self.load(
                        **{
                            'FolderingPathVariable':__DocumentedSubModuleFolderPathStr,
                            'FilingKeyStr':'Presentation.ipynb',
                            'LoadingFormatStr':'json'
                        }
                    ).close(
                    ).LoadedReadVariable,
                    self.DocumentedSubModuleLocalFolderPathStrsList
                )                   

            #debug
            '''
            self.debug(
                        'self.DocumentedPresentationsDictsList is '+SYS._str(self.DocumentedPresentationsDictsList)
                    )
            '''

            #copy
            self.DocumentedConceptNotebookDict=copy.copy(Celler.CellingInitDict)

            #flat
            DocumentedFlatPresentationsDictsList=SYS.flat(
                    map(
                            lambda __DocumentedPresentationsDict:
                            copy.deepcopy(
                                __DocumentedPresentationsDict['worksheets'][0]['cells']
                                ),
                            self.DocumentedPresentationsDictsList
                        )
                    )

            #Flat all the presentations
            self.DocumentedConceptNotebookDict['worksheets']=[
                {
                    'cells':map(
                        lambda __DocumentedFlatPresentationsDict,__IndexInt:
                        dict(__DocumentedFlatPresentationsDict,**{
                            'prompt_number':__IndexInt}),
                        DocumentedFlatPresentationsDictsList,
                        xrange(len(DocumentedFlatPresentationsDictsList))
                    )
                }
            ]

            #debug
            '''
            self.debug(('self.',self,['DocumentedConceptNotebookDict']))
            '''

            #Write
            self.write(
                self.DocumentedConceptNotebookDict,
                **{
                    'FolderingPathVariable':self.DocumentingConceptFolderPathStr,
                    'FilingKeyStr':'Concept'+self.GuidingBookStr+'.ipynb',
                    'LoadingFormatStr':'json'
                }
            ).close()


            #nbconvert
            self.NotebookedCodeDict=self.DocumentedConceptNotebookDict
            self.nbconvert(
                _FormatStr='Slide',
                **{
                    'FolderingPathVariable':self.DocumentingConceptFolderPathStr,
                    'NotebookingFileKeyStr':'Concept'+self.GuidingBookStr+'.ipynb'
                }
            )

            #set
            self.DocumentedSlideLocalFilePathStr=DocumentingOntologyLocalFolderPathStr+self.DocumentedConceptModule.__name__.split('.')[-1]+'.html'

            #cp
            os.popen('cp '+self.FiledPathStr+' '+self.DocumentedSlideLocalFilePathStr+self.DocumentedConceptModule.__name__.split('.')[-1]+'.ipynb')

            #mv with .html extension
            os.popen(
                    'cp '+self.FiledPathStr.replace(
                    '.ipynb',
                    '.html'
                    )+' '+self.DocumentedSlideLocalFilePathStr
                )

            #mv with .php extension
            os.popen(
                    'mv '+self.FiledPathStr.replace(
                    '.ipynb',
                    '.html'
                    )+' '+self.DocumentedSlideLocalFilePathStr.replace('.html','.php')
                )

            #deploy
            try:
                self.deploy(
                    _ClientFilePathStrToServerFilePathStrOrderedDict=collections.OrderedDict(
                        [
                            (
                                self.DocumentedSlideLocalFilePathStr,
                                DocumentingOntologyOuvatonFolderPathStr+self.DocumentedConceptModule.__name__.split('.'
                                    )[-1]+'.php'
                            )
                        ]
                    )
                )
            except:
                print('There is NO Internet !')

        #Check
        if self.DocumentingConceptReadmeIsBool:

            #debug
            '''
            self.debug('we build the concept readme here')
            '''

            #import submodules
            '''
            map(
                    lambda __DocumentedSubModuleStr:
                    importlib.import_modules(__DocumentedSubModuleStr),
                    self.DocumentedSubModuleStrsList
                )
            '''

            #readme
            self.package(
                    self.DocumentedConceptModuleStr
                ).scriptbook(
                    _GuideTuplesList=[
                        ('001','Document','Markdown'),
                        ('002','Ouvaton','Markdown'),
                        ('1','Github','Markdown'),
                    ],
                    **{'GuidingBookStr':"Doc"}
                )

            #notebook
            self.scriptbook(
                    _GuideTuplesList=[]
                ).notebook(
                    "PreReadme.ipynb"
                ).nbconvert(
                    "Readme.md",
                    'Markdown',
            )

        #Check
        if self.DocumentingConceptDocumentIsBool:

            #debug
            '''
            self.debug(
                        [
                            'we document here',
                            ('self.',self,['DocumentedConceptModuleFolderPathStr'])
                        ]
                    )
            '''

            '''
            #document
            self.document(
                **{'PackagingModuleVariable':self.DocumentedConceptModuleStr}
            )   
            '''

            #package
            self.package(self.DocumentedConceptModuleStr)

            #mv with .php extension
            os.popen(
                    'cp '+self.PackagedLocalFolderPathStr+'Readme.md  '+DocumentingDocumentLocalFolderPathStr+self.DocumentedConceptModuleStr.split('.')[-1]+'.md'
                )

            #Return self
            #return self

        if self.DocumentingSiteDocumentIsBool:

            #open
            os.popen(
                        'mkdocs build --clean'
                )

            #deploy
            try:
                self.deploy(
                    _ClientFilePathStrToServerFilePathStrOrderedDict=collections.OrderedDict(
                        [
                            (
                                self.DocumentedSlideLocalFilePathStr,
                                DocumentingOntologyOuvatonFolderPathStr+self.DocumentedConceptModule.__name__.split('.'
                                    )[-1]+'.php'
                            )
                        ]
                    )
                )
            except:
                print('There is NO Internet !')

#</DefineClass>

View the Documenter sources on Github

Example

Let's create an empty class, which will automatically receive special attributes from the decorating ClassorClass, specially the NameStr, that should be the ClassStr without the TypeStr in the end.


In [27]:
#ImportModules
import ShareYourSystem as SYS
from ShareYourSystem.Guiders import Documenter

#Definition an Documenter instance
MyDocumenter=Documenter.DocumenterClass()

#Definition the AttestedStr
SYS._attest(
    [
        'MyDocumenter is '+SYS._str(
        MyDocumenter,
        **{
            'RepresentingBaseKeyStrsListBool':False,
            'RepresentingAlineaIsBool':False
        }
        )
    ]
)



*****Start of the Attest *****

MyDocumenter is < (DocumenterClass), 4540557008>
   /{ 
   /  '<New><Instance>IdInt' : 4540557008
   /  '<Spe><Class>DocumentedConceptModule' : None
   /  '<Spe><Class>DocumentedConceptModuleFolderPathStr' : 
   /  '<Spe><Class>DocumentedConceptModuleStr' : 
   /  '<Spe><Class>DocumentedSubModuleLocalFolderPathStrsList' : None
   /  '<Spe><Class>DocumentedSubModuleStrsList' : None
   /  '<Spe><Class>DocumentedSubModulesList' : None
   /  '<Spe><Class>DocumentedSubNameStrsList' : None
   /  '<Spe><Class>DocumentingConceptDocumentIsBool' : True
   /  '<Spe><Class>DocumentingConceptFolderPathStr' : 
   /  '<Spe><Class>DocumentingConceptReadmeIsBool' : True
   /  '<Spe><Class>DocumentingConceptSlideIsBool' : True
   /  '<Spe><Class>DocumentingSiteDocumentIsBool' : True
   /  '<Spe><Class>DocumentingSubReadmeIsBool' : True
   /}

*****End of the Attest *****


Documenter

Doc


The Documenter export in the mkdoc the readme of a Module


View the Documenter notebook on [NbViewer](http://nbviewer.ipython.org/url/shareyoursystem.ouvaton.org/Documenter.ipynb)

Code



# -*- coding: utf-8 -*-
"""


<DefineSource>
@Date : Fri Nov 14 13:20:38 2014 \n
@Author : Erwan Ledoux \n\n
</DefineSource>


The Documenter export in the mkdoc the readme of a Module 

"""

#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Guiders.Installer"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Classer"
SYS.setSubModule(globals())
#</DefineAugmentation>

#<ImportSpecificModules>
import os
import copy

from ShareYourSystem.Standards.Interfacers import Loader,Writer
#</ImportSpecificModules>

#<DefineLocals>
DocumentingSysFolderPathStr=SYS.ShareYourSystemLocalFolderPathStr
DocumentingLibraryFolderPathStr=DocumentingSysFolderPathStr+'/docs/LibraryReference/'
#</DefineLocals>

#<DefineClass>
@DecorationClass()
class DocumenterClass(BaseClass):

    #Definition
    RepresentingKeyStrsList=[
                                'DocumentedModulePathStr',
                                'DocumentedMkdocsList',
                                'DocumentedModulePathStr'
                            ]

    def default_init(self,
                        _DocumentingNewIsBool=False,
                        _DocumentingMkdocWriteIsBool=False,
                        _DocumentedMkdocsList=None,
                        _DocumentedMkdocsDict=None,
                        **_KwargVariablesDict
                    ):

        #Call the parent __init__ method
        BaseClass.__init__(self,**_KwargVariablesDict)


    def do_document(self):

        #first package
        self.package()

        #map
        self.DocumentedModulePathStr=self.PackagedModuleStr.replace('.','/')
        self.DocumentedNameStr=self.DocumentedModulePathStr.split('/')[-1]

        #debug
        '''
        self.debug(('self.',self,[
                            'DocumentedModulePathStr',
                            'DocumentedNameStr'
                            ]))
        '''

        #Load the readmes and write them into the docs Library reference folder
        self.load(
            **{
                'FolderingPathVariable':SYS.PythonlogyLocalFolderPathStr+'/'+self.DocumentedModulePathStr,
                'FilingKeyStr':'Readme.md',
                'LoadingFormatStr':'txt'
            }
        ).write(
            **{
                    'FolderingPathVariable':DocumentingLibraryFolderPathStr,
                    'FilingKeyStr':self.DocumentedNameStr+'.md',
                    'WritingLoadBool':True
                }
        ) 

        #Definition in the future yaml config mkdocs 
        self.DocumentedMkdocsList=[
                'docs'.join(
                    DocumentingLibraryFolderPathStr.split('docs/')[1:]
                )+self.DocumentedNameStr+'.md',
                'Library Reference',
                self.DocumentedNameStr
            ]

        #debug
        '''
        self.debug(('self.',self,[
                                    'DocumentedMkdocsList'
                                ]))
        '''


        #Definition
        self.load(
            **{
                'FolderingPathVariable':SYS.PythonlogyLocalFolderPathStr+self.__class__.__module__.replace(
                    '.','/')
                if self.DocumentingNewIsBool
                else DocumentingSysFolderPathStr,
                'FilingKeyStr':'mkdocs.yml',
                'LoadingFormatStr':'yaml'
            }
        )

        #Add to the pages
        self.LoadedReadVariable['pages'].append(self.DocumentedMkdocsList)

        #Copy
        self.DocumentedMkdocsDict=copy.copy(
            self.LoadedReadVariable
        )

        #debug
        '''
        self.debug(('self.',self,[
                                    'DocumentedMkdocsDict'
                                ]))
        '''

        if self.DocumentingMkdocWriteIsBool:

            #Close and write now in the top root folder
            self.write(
                self.DocumentedMkdocsDict,
                **{
                    'FolderingPathVariable':DocumentingSysFolderPathStr,
                }
            ).FiledHardVariable.close()

        #Return self
        #return self

#</DefineClass>

View the Documenter sources on Github

Example

Let's create an empty class, which will automatically receive special attributes from the decorating ClassorClass, specially the NameStr, that should be the ClassStr without the TypeStr in the end.


In [31]:
#ImportModules
import ShareYourSystem as SYS
from ShareYourSystem.Guiders import Documenter

#Definition a Documenter instance
MyDocumenter=Documenter.DocumenterClass().document(
    True,
    **{
        'PackagingModuleVariable':'ShareYourSystem.Standards.Objects'
    }
)
    
#Definition the AttestedStr
SYS._attest(
    [
        'MyDocumenter is '+SYS._str(
        MyDocumenter,
        **{
            'RepresentingBaseKeyStrsListBool':False
            }
        )
    ]
)  

#Print



*****Start of the Attest *****

MyDocumenter is < (DocumenterClass), 4540815184>
   /{ 
   /  '<New><Instance>DocumentedModulePathStr' : ShareYourSystem/Objects
   /  '<New><Instance>DocumentedNameStr' : Objects
   /  '<New><Instance>IdInt' : 4540815184
   /  '<Spe><Instance>DocumentedMkdocsList' : ['LibraryReference/Objects.md', 'Library Reference', 'Objects']
   /  '<Spe><Instance>DocumentedModulePathStr' : ShareYourSystem/Objects
   /}

*****End of the Attest *****