TheySaySomethingInterrestingApparently: Someday, Code will speak by himself...


Iterpipes, Between Bash and Hash-bash

A library for running shell pipelines using shell-like syntax

Enables piping infinite streams through shell pipelines in Python

xhtml-css Bivalidator

Check your markup and style validity


Just type or paste an URL in the form above, and click on "check it" to see the magic. If you want to fine tune your validation, click on the "advanced" link. That's it!

Yet Another Comprehensive Content

Like, Young's modulus is a vibrating variation inside a solid... The times it take to respanw to an excess of energy is what molding apparence may look to not-so solid thing's... Like this Blog when adding content, the effor is like slapping it and the time it goes back, centered... we consider being more stable than usual...

lundi 16 août 2010

Someday, Code will speak by himself...

Some day, code will probably speak by himself, leaving coder have not choice to let himself, port himself to something else, like new cpu... It's ridiculous how 170 lines of code can easily be a Module creator for Wine...

They, may look for invalid idea left here to find-out motivation... I will recommand to inspect all C.V once again, instead spending time looking to «loisive» information possibly becoming important, it's a blog not a Code-Valley... By the way, We are so tiny here in this space, I may offer this porte-folio example for Nurun...

This example is using Wine, and parsing something that do not work as long yo read the comment and understant what is EBNF Syntax... Elsewhere, my other project, that create Python Module by inspecting AST result from module from pycparser and couples of test-module, I'm doing it over severals files inside the compilation Tree. Fixing my theory over Mozilla Firefox Generator Tree, Building it from scratch does not cost a full year of production... Maybe testing the design will, but one The AST parsing is acheived, altering string, for partability, translation or matter of category flavor, it's such information today Business are ready to pay... But major one, adaptation for top layer is the favorite one...

import os, sys, re
import iterpipes
from iterpipes import cmd, bincmd, linecmd, run, call, check_call, cmdformat, compose

import pybindgen
import ezpyinline
import pycparser 
from pycparser import c_parser as PyCParse

from classproperty import classproperty
from xml.dom import minidom
from lxml.html import parse

from lxml.cssselect import CSSSelector
from lxml import etree
from lxml.builder import E

from sets import Set
from html5lib import treebuilders

class BindGenStoreClass( ):

  def __init__( self , BindValue=False, **Kargs ):
    print "Creating Instantiation of Class: %s" % ( self.__class__.__name__ )
    if BindValue:
      for ItemName in Kargs:
        print "\tBinding Variable %s" % ( ItemName )
        setattr( self, ItemName, Kargs[ItemName] )

class CodeStorage( ):


  def __init__( self , BindValue=False, **Kargs ):
    print "Creating Instantiation of Class: %s" % ( self.__class__.__name__ )
    if BindValue:
      for ItemName in Kargs:
        print "\tBinding Variable %s" % ( ItemName )
        setattr( self, ItemName, Kargs[ItemName] )

class Config( ):
#  RegExpFileHeader={ 'h':(r'.h') }

  DictMsg={ 'error':{
    '__SearchPackageName__':("No Package %s%s installed, we strongly suggest to install a Wine package and It's development.") ,
    '__SearchPackageType__':("No Sub-Package %s%s installed, we strongly suggest to install a Wine package and It's development.") } }

  def __AptCacheLoad__( self ):
    for ItemPackege in self.AptCache:
      self.PackageNameList.append( ItemPackege )

  def __SearchPackageName__( self ):
    Regexp=re.compile( r'^%s' % self.PackageName )
    for ItemInspect in self.PackageNameList:
      if Regexp.match( ):
        self.PackageNameMatch.append( ItemInspect )
    if len( self.PackageNameMatch ) < 0 :
      raise StandardError, self.DictMsg['error'][DefName] % ( self.PackageName , self.PackageType )

  def __SearchPackageType__( self ):
    Regexp=re.compile( r'%s%s' % ( self.PackageName,self.PackageType ) )

    for Itempackage in self.PackageNameMatch:
      if Regexp.match( ):
    if self.PackageWine == None :
      raise StandardError, self.DictMsg['error'][DefName] % ( self.PackageName , self.PackageType )
      print "Found Package %s" % ( self.PackageWine )

  def __ChartFileLookup__( self ):
    for ItemRegChart in self.RegExpFileHeader.keys():
      for ItemFile in self.PackageFileList:
        if ItemFile.endswith( StrValueEnd ):
          self.PackageNameListSelected.append( ItemFile )
  def __init__( self, BindValue=True, **Kargs ):
    print "Creating Instantiation of Class: %s" % ( self.__class__.__name__ )
    if BindValue:
      for Item in Kargs:
        print "\tBinding Variable %s" % ( Item )
        setattr( self,  Item , Kargs[Item] )
    import apt

class WineDefAccessor( Config ):

  __all__=[ ]
  DictUserLevelProtection={ 'UserLevel':[ r'%suser'   % RegExpFilter ] ,
                            'Password':[ r'%spasword' % RegExpFilter ,
                                         r'%spasswd'  % RegExpFilter ,
                                         r'%spwd'     % RegExpFilter ,
                                         r'%spass'    % RegExpFilter ] }

  def __UserLevelRestriction__( self , StrArgKey , KeyNameInspections, DefaultDisplayOnConfidential='<<UserConfidential>>' ):

    for ItemRestriction in self.DictUserLevelProtection.keys():
      for ItemList in self.DictUserLevelProtection[ItemRestriction]:
        TestRegExp=re.compile( ItemList )
        if TestRegExp.match( KeyNameInspections ) :
          IntSetUserConfidential = True

      if not IntSetUserConfidential:
    return NamedItem

  def __KargsTransfert__( self, **kargs ):
    for ItemKey in kargs:
      setattr( self, ItemKey , kargs[ItemKey] )

  def __init__( self, BindModule=False, **kargs ):
    if BindModule :
        self.__KargsTransfert__( **kargs )

  def CodeParsing( self ):
    if self.Conf.PackageWine != None:
      print "Start Parsing Include Header in package %s" % ( self.Conf.PackageWine )
      for FileNameHeader in self.Conf.PackageNameListSelected:
        print "Parsing File: %s" % FileNameHeader

        FileHandler=open( FileNameHeader, 'r+' )
        ### There is some regulation, inside file we need to add,
        ### Assuming it's /usr/include/wine/windows/ddk/compstui.h with wine version 1.2
        ### There's some Yaml rule to define to let the AST work... Or, some may implement 
        ### PyBoost.Spirit, has AST-finite parser, using Plain EBNF syntax from 

        ###, and Using SimpleParser
        ### and you can acheive, fast, efficient AST-Rules stored in the CStore.CodeCompilePackage
        ### And Using next Step...

        StrNameModuleFromFile.replace( '.h', '' )
        StrQualifiedName='%s_%s' % ( self.Conf.PackageNameMain , StrNameModuleFromFile )
        self.CodeBinderClass.BindStorage['module'][StrQualifiedName]['Module']=pybindgen.Module( StrQualifiedName )
        self.CodeBinderClass.BindStorage['module'][StrQualifiedName]['Include']=self.CodeBinderClass.BindStorage['module'][StrQualifiedName]['Module'].add_include('"%s"' % FileNameHeader )

        #self.CStore.CodeCompilePackage.append( self.CCodeParser.parse( , FileNameHeader ) )

  def SearchWithRegExp( self, RegExpr, Buffer , MethodExtract='yield' , RegExpMeth='findall' ):
    StdGetattrList=[ 'print']
    StdGetattrListException=[ 'yield' ]
    if hasattr( RegExpr, RegExpMeth ):
      for IterFinder in getattr( RegExpr, RegExpMeth)( Buffer ) :
        if MethodExtract in StdGetattrList:
          getattr( __builtins__, MethodExtract )( str(IterFinder).replace( '\'', '' ) )
        if MethodExtract in StdGetattrListException:
          yield str(IterFinder).replace( '\'', '' )
      if MethodExtract == 'yield':
        raise GeneratorExit, 'Function Name %s had no other Generated Item' % ( self.SearchWithRegExp.func_name )

  def NodeLXml( self, StrType, *args):
    return { StrType:' '.join(args)}
  def StartNewTask( self, TypeFuncName, TupleData ):
    if hasattr( self, 'ThreadStart' ):
      self.ThreadStart.start_new( TypeFuncName, TupleData )
      import thread
      setattr( self, 'ThreadStart', 'None' )
      self.ThreadStart.start_new( TypeFuncName, TupleData )
      raise Warning, "Try to load the thread module from object %s instanciation like VarName=%s( ThreadStart=thread )" % ( self.__class__.__name__ , self.__class__.__name__ )

if __name__ == '__main__':
  del WineModParser
  WineModParser=WineDefAccessor( True,
                                 Conf=Config(True,PackageNameMain='wine' , PackageType=r'-dev', PackageName=r'wine1.2', RegExpFileHeader={ 'h':(r'.h') } ),
                                 CCodeParser=PyCParse.CParser() )

XCode under Essay, or simple example
XText may contains errors, syntax errors or lexical error...
  • 1No Interest
  • 2Somewhat good
  • 3Good
  • 4Special.