Example #1
0
    def _recurse(pathname):
        if pathname in cdeps_cache:
            return cdeps_cache[pathname]
        
        if not os.path.exists(pathname):
            return set()

        set_union = set()
        set_union.add(pathname)
        for line in open(pathname):
            m = sre.match("# *include <([^>]+)>", line.strip())
            result_set = None
            if m:
                included_path = m.groups(0)[0]
                if included_path.startswith('colinux'):
                    combined_path = os.path.join('src', included_path)
                    result_set = _recurse(combined_path)
                    result_set.add(combined_path)
            else:
                m = sre.match("# *include \"([^>]+)\"", line.strip())
                if m:
                    included_path = m.groups(0)[0]
                    included_path = normal_path(os.path.join(os.path.dirname(pathname), included_path))
                    result_set = _recurse(included_path)
                    
            if result_set:
                set_union.union_update(result_set)
                    
        cdeps_cache[pathname] = set_union
        return set_union
Example #2
0
    def _recurse(pathname):
        if pathname in cdeps_cache:
            return cdeps_cache[pathname]

        if not os.path.exists(pathname):
            return set()

        set_union = set()
        set_union.add(pathname)
        for line in open(pathname):
            m = sre.match("# *include <([^>]+)>", line.strip())
            result_set = None
            if m:
                included_path = m.groups(0)[0]
                if included_path.startswith('colinux'):
                    combined_path = os.path.join('src', included_path)
                    result_set = _recurse(combined_path)
                    result_set.add(combined_path)
            else:
                m = sre.match("# *include \"([^>]+)\"", line.strip())
                if m:
                    included_path = m.groups(0)[0]
                    included_path = normal_path(
                        os.path.join(os.path.dirname(pathname), included_path))
                    result_set = _recurse(included_path)

            if result_set:
                set_union.union_update(result_set)

        cdeps_cache[pathname] = set_union
        return set_union
def createSIBQueue(scope, scopePath, adminObjectNode, sibDestinationNode):
    destinationparams = []
    for attribute in sibDestinationNode.attributes.values():
        if not (attribute.name in ("deliveryMode", "timeToLive", "priority", "readAhead")):
            destinationparams.append('-%s "%s"' % (attribute.name, attribute.value))
    if sre.match("/ServerCluster:(.*)/", scopePath) and not sibDestinationNode.attributes.has_key("cluster"):
        destinationparams.append('-cluster "%s"' % sre.match("/ServerCluster:(.*)/", scopePath).group(1))
    elif  sre.match("/Node:(.*)/Server:(.*)/", scopePath)  and not sibDestinationNode.attributes.has_key("server"):
        destinationparams.append(
            '-node "%s" -server "%s"' % sre.match("/Node:(.*)/Server:(.*)/", scopePath).group(1, 2))

    print "AdminTask.createSIBDestination " + " ".join(destinationparams)
    destination = AdminTask.createSIBDestination(" ".join(destinationparams))
    if getChild(sibDestinationNode, "Attributes"):
        modifyAttributes(sibDestinationNode, destination)

    queueparams = ['-queueName "%s"' % sibDestinationNode.attributes["name"].value]
    for attribute in adminObjectNode.attributes.values():
        queueparams.append('-%s "%s"' % (attribute.name, attribute.value))
    for attribute in sibDestinationNode.attributes.values():
        if attribute.name in ("deliveryMode", "timeToLive", "priority", "readAhead"):
            queueparams.append('-%s "%s"' % (attribute.name, attribute.value))

    print "AdminTask.createSIBJMSQueue " + " ".join(queueparams)
    cf = AdminTask.createSIBJMSQueue(scope, " ".join(queueparams))

    if getChild(adminObjectNode, "Attributes"):
        modifyAttributes(adminObjectNode, cf)
Example #4
0
def loadFile(fileName, width, height):
    """ 
    Loads skin xml file and resolves embedded #include directives.
    Returns completely loaded file as a string. 
    """
        
    log.debug("loadFile(%s, %d, %d)"%(fileName, width, height ) )
    s = ""
    f = file( fileName )
    for l in f.readlines():
        # log.debug(fileName + ":" + l) 
        m = sre.match( '^#include (.*)$', l )
        if m:
            incFile = m.group(1)
            incFile = incFile.strip()
            if sre.match( '^\w+\.xml$', incFile ):
                # need to find skin file
                incFile = findSkinFile( incFile, width, height )
            elif sre.match( '\%SKINDIR\%', incFile ):
                incFile = string.replace(incFile, "%SKINDIR%", getSkinDir())
            else:
                # convert path separators to proper path separator - just in case
                incFile = string.replace( incFile, "/", os.sep )
                incFile = string.replace( incFile, "\\", os.sep )

                # assume relative path provided
                path = os.path.dirname( fileName )
                path += os.sep + incFile
                incFile = path
            s += loadFile( incFile, width, height )
        else:
            s += l
    f.close()
    return s
Example #5
0
File: core.py Project: LLNL/WVL
def processStringURI(URI):
	# PYRONAME(SSL)://[hostname[:port]/]objectname
	x=sre.match(r'(?P<protocol>PYRONAME|PYRONAMESSL)://(((?P<hostname>[^\s:]+):(?P<port>\d+)/)|((?P<onlyhostname>[^\s:]+)/))?(?P<name>\S*)',URI)
	if x:
		import naming
		protocol=x.group('protocol')
		if protocol=="PYRONAMESSL":
			raise ProtocolError("NOT SUPPORTED YET: "+protocol) # XXX
		hostname=x.group('hostname') or x.group('onlyhostname')
		port=x.group('port')
		name=x.group('name')
		loc=naming.NameServerLocator()
		if port:
			port=int(port)
		NS=loc.getNS(host=hostname,port=port)
		return NS.resolve(name)
	# PYROLOC(SSL)://hostname[:port]/objectname
	x=sre.match(r'(?P<protocol>PYROLOC|PYROLOCSSL)://(?P<hostname>[^\s:]+):?(?P<port>\d+)?/(?P<name>\S*)',URI)
	if x:
		protocol=x.group('protocol')
		hostname=x.group('hostname')
		port=x.group('port')
		if port:
			port=int(port)
		else:
			port=0
		name=x.group('name')
		return PyroURI(hostname,name,port,protocol)
	if URI.startswith('PYROLOC') or URI.startswith('PYRONAME'):
		# hmm should have matched above. Likely invalid.
		raise URIError('invalid URI format')
	# It's not a meta-protocol such as PYROLOC or PYRONAME,
	# let the normal Pyro URI deal with it.
	# (it can deal with regular PYRO: and PYROSSL: protocols)
	return PyroURI(URI)
Example #6
0
    def remotePath(self):
        log.debug( '> domain.ProgramFromQuery.remotePath()' )
        remoteFile = self.basename()
        remotePath = self.settings.get("paths_recordedprefix")
        shostIp = self.settings.get( "mythtv_host" )
        host = self.hostname()
        try:
            hostIp = socket.gethostbyname(host)
            snet = hostIp[:6]
            ssnet = shostIp[:6]
            log.debug(snet + " " + ssnet)
            
            # if the first 6 characters of both addresses don't match then
            # chances are the 'internet' address of the host has been
            # found so just use the setting IP
            if snet <> ssnet:
                hostIp = shostIp
        except:
            hostIp = shostIp
        
        log.debug ('Host: %s hostIp: %s'%(host, hostIp))
        # we should do this substitute anyway?!
        remotePath = sre.sub( '\%h', hostIp, remotePath )

        if sre.match( "^[Ss][Mm][Bb]:", remotePath ) and not sre.match( "^\d", host ):
            host = sre.sub( '\..*$', '', host )
            remotePath = string.replace( remotePath, '\\', '/' )

        if remotePath[len(remotePath)-1] != '/':
            remotePath += '/'
        remotePath += remoteFile   

        log.debug('< domain.ProgramFromQuery.remotePath() => [%s]'%remotePath)
        return str(remotePath)
Example #7
0
def loadFile(fileName, width, height):
    """ 
    Loads skin xml file and resolves embedded #include directives.
    Returns completely loaded file as a string. 
    """

    log.debug("loadFile(%s, %d, %d)" % (fileName, width, height))
    s = ""
    f = file(fileName)
    for l in f.readlines():
        # log.debug(fileName + ":" + l)
        m = sre.match('^#include (.*)$', l)
        if m:
            incFile = m.group(1)
            incFile = incFile.strip()
            if sre.match('^\w+\.xml$', incFile):
                # need to find skin file
                incFile = findSkinFile(incFile, width, height)
            elif sre.match('\%SKINDIR\%', incFile):
                incFile = string.replace(incFile, "%SKINDIR%", getSkinDir())
            else:
                # convert path separators to proper path separator - just in case
                incFile = string.replace(incFile, "/", os.sep)
                incFile = string.replace(incFile, "\\", os.sep)

                # assume relative path provided
                path = os.path.dirname(fileName)
                path += os.sep + incFile
                incFile = path
            s += loadFile(incFile, width, height)
        else:
            s += l
    f.close()
    return s
Example #8
0
def DupSymChain_Execute():

    # make sure we have a chain root selected #
    dupCol = win32com.client.Dispatch("XSI.Collection")
    for node in xsi.selection:
        if node.Type == "root":
            dupCol.Add(node)

    if not dupCol.Count:
        xsi.logmessage("Chain Root not selected", c.siError)
        return

        # step through each item in the dup collection #
    for sourceNode in dupCol:

        # duplicate the chain #
        dupRootStr = xsi.DuplicateSymmetry("B:%s" % sourceNode.FullName, 1, 1, 1, 0, 0, 0, 1)
        print dupRootStr

        # step through the resulting chain and switch the symmetrical name #
        col = win32com.client.Dispatch("XSI.Collection")
        col.SetAsText(dupRootStr)
        dupNodes = col(0).FindChildren("*")

        # step through the duplicated nodes and Rename #
        for node in dupNodes:
            import sre

            if sre.match(".*_Lft_.*", node.Name):
                node.Name = node.Name[:-1].replace("_Lft_", "_Rgt_")
            elif sre.match(".*_Rgt_.*", node.Name):
                node.Name = node.Name[:-1].replace("_Rgt_", "_Lft_")
Example #9
0
 def token(self, pattern, probe=False):
     # XXX this code should be shorter
     s = sre.match(r'\s+', self.str[self.i:])
     if s: 
         self.i += s.end()
     m = sre.match(pattern, self.str[self.i:])
     if not m: 
         return False
     if probe:
         return True
     start, end = self.i + m.start(), self.i + m.end()
     self.i += m.end()
     return self.str[start:end]
Example #10
0
 def fullTitle(self):
     """returns Title - subtitle if subtitle exists"""
     fullTitle = ""
     if self.title():
         fullTitle += self.title()
     if self.subtitle() and not sre.match( '^\s+$', self.subtitle() ):
         fullTitle += " - " + self.subtitle()
     return fullTitle
Example #11
0
 def buildListEntry(self, row):
     start = strptime(row.starttime(), "%Y%m%d%H%M%S")
     entry = strftime("%m/%d %I:%M %p", start) + "   "
     if row.title():
         entry += row.title()
     if row.subtitle() and not sre.match('^\s+$', row.subtitle()):
         entry += " - " + row.subtitle()
     log.debug('Window.buildListEntry(row = %s) => %s)' % (row, entry))
     return entry
Example #12
0
 def buildListEntry(self, row):
     start = strptime( row.starttime(), "%Y%m%d%H%M%S" )
     entry = strftime( "%m/%d %I:%M %p", start ) + "   "
     if row.title():
         entry += row.title()
     if row.subtitle() and not sre.match( '^\s+$', row.subtitle() ):
         entry += " - " + row.subtitle()
     log.debug('Window.buildListEntry(row = %s) => %s)'%(row, entry))            
     return entry
Example #13
0
def html_format(src):
    out = []
    while src != "":
        m = sre.search(pat_token, src)
        if m is None:
            break
        out.append(src[: m.start()])
        token = src[m.start() : m.end()]
        src = src[m.end() :]
        if sre.match(pat_paragraph, token):
            out.append(P())
        elif sre.match(pat_uri, token):
            out.append(link(token, token))
        elif sre.match(pat_tabulate, token):
            qtriples, src = parse_tabulate(src)
            tabulate(out, qtriples)
        elif sre.match(pat_slink, token):
            contents = token[1:-1].split()
            if 0 == len(contents):
                pass  # XXX error message?
            else:
                # XXX security screen target and caption
                # (caption should not look like a URL itself)
                # XXX url encoding
                # XXX nofollow
                if contents[0].startswith("http:"):
                    target = contents[0]
                    if 1 == len(contents):
                        caption = contents[0]
                    else:
                        caption = " ".join(contents[1:])
                else:
                    caption = " ".join(contents)
                    target = "/page/" + caption
            out.append(link(target, caption))
        elif sre.match(pat_escape, token):
            out.append(token[1])
        else:
            raise "Bug"
    out.append(src)
    return out
Example #14
0
def getpassword():
    nextrange = 2123456789
    while True:
        req = urllib2.Request(url)
        req.headers['Range'] = "bytes=%d-"%nextrange
        print req.headers['Range']
        c = opener.open(req)
        nextrange = int(sre.match(regex, c.headers['content-range']).groups()[0]) - 1
        print c.headers['content-range']
        f = open("level20.out","w")
        for data in c.read():
            f.write(data)
	def __extraireNomFeuilleStyle(self, fichierXML):
		"""A partir d'un fichier XML, extrait le nom de la feuille de style XSLT associée via l'instruction de traitement"""
		def extraire_instruction_trairement_dom(doc):
			ctxt = doc.xpathNewContext()
			res = ctxt.xpathEval("//self::processing-instruction()");
			return res
		doc = libxml2.parseFile(fichierXML)
		pis = extraire_instruction_trairement_dom(doc)
		if (len(pis) > 0 and pis[0] != None):
			match = sre.match("href=['\"](.+?)['\"]", pis[0].getContent())
			return match.group(1);
		else:
			return None
Example #16
0
def main():

    if len(sys.argv) < 2:
        print "Syntax: %s file.c" % (sys.argv[0])
        sys.exit(1)

    block = 0
    line_nb = 0
    log_func = 0

    file = open(sys.argv[1], "r")

    for line in file:
        line_nb += 1

        if block == 0:
            log_func = 0

        if sre.match(".*return.*", line):
            if block > 1 and log_func == 0:
                print "%s:%d:%s : return called but no log previously defined, this might confuse the user." % (
                    sys.argv[1],
                    line_nb,
                    line.strip(),
                )

        if sre.match(".*{.*", line):
            block += 1

        if sre.match(".*}.*", line):
            block -= 1
            log_func = 0

        for log in log_functions:
            expr = ".*%s.*" % (log)
            if sre.match(expr, line) and block > 0:
                log_func = 1

    file.close()
def createSIBMessagingEngine(scopeString, scope, sibMeNode):
    params = '-bus "%s"' % sibMeNode.attributes["busName"].value
    fileStore = getChild(sibMeNode, "fileStore")
    if fileStore:
        params = params + " -fileStore"
        for attribute in fileStore.attributes.values():
            params = params + ' -%s "%s"' % (attribute.name, attribute.value)
    dataStore = getChild(sibMeNode, "dataStore")
    if dataStore:
        params = params + " -dataStore"
        for attribute in dataStore.attributes.values():
            params = params + ' -%s "%s"' % (attribute.name, attribute.value)

    if sre.match("Cluster=(.*)", scopeString):
        params = params + ' -cluster "%s"' % sre.match("Cluster=(.*)", scopeString).group(1)
    elif  sre.match("Node=(.*),Server=(.*)", scopeString):
        params = params + ' -node "%s" -server "%s"' % sre.match("Node=(.*),Server=(.*)", scopeString).group(1, 2)
    print "AdminTask.addSIBusMember " + params
    AdminTask.addSIBusMember(params)
    if getChild(sibMeNode, "Attributes"):
        messagingEngine = wsadminToList(AdminConfig.list('SIBMessagingEngine', scope))[0]
        print 'me: ' + messagingEngine
        modifyAttributes(sibMeNode, messagingEngine)
Example #18
0
def zgGetAllPackFlats_Execute( flatModel ):
	'''find all the character models in the scene'''
	
	# create an out collection #
	outCol = xsi.zgNewCol()
	
	# find all the pack tags on the flat model #
	for prop in flatModel.Properties:
		# find the properties matching the pattern #
		if sre.match( '^zgPack_(.+)_Flat$', prop.Name ):
			# add them to the out col #
			outCol.Add( prop )
	# return the out col #
	return outCol
Example #19
0
	def is_valid(self, type, val):
		if not type:
			return None
		if type[0] == 'boolean':
			return self.is_valid_bool(val)
		elif type[0] == 'integer':
			return self.is_valid_int(val)
		elif type[0] == 'string':
			return self.is_valid_string(val)
		else:
			if sre.match(type[1], val):
				return val
			else:
				return None
Example #20
0
def zgListAllPacks_Execute():
	''' list all packs available to the system '''
	
	# create a output list #
	outList = []
	# step through the plugins #
	import sre
	for plugin in xsi.Plugins:
		if sre.match( '^zgPack_', plugin.Name ): 
#			xsi.logmessage( plugin )
			outList.append( plugin.Name )

	# return the outlist #	
	return outList
Example #21
0
 def process_dir(self, root, revnum, dir_path, pattern=None):
     "Recursively process children of DIR_PATH."
     dirents = svn.fs.dir_entries(root, dir_path)
     for name in dirents.keys():
         if not dirents[name].kind == svn.core.svn_node_dir:
             continue
         if pattern is None or sre.match(pattern, name):
             if dir_path == "":
                 child_path = name
             else:
                 child_path = "%s/%s" % (dir_path, name)
             self.log("Examining path '%s' for conversion" % (child_path))
             if not self.convert_path_history(root, revnum, child_path):
                 self.process_dir(root, revnum, child_path)
 def process_dir(self, root, revnum, dir_path, pattern=None):
   "Recursively process children of DIR_PATH."
   dirents = svn.fs.dir_entries(root, dir_path)
   for name in dirents.keys():
     if not dirents[name].kind == svn.core.svn_node_dir:
       continue
     if pattern is None or sre.match(pattern, name):
       if dir_path == "":
         child_path = name
       else:
         child_path = "%s/%s" % (dir_path, name)
       self.log("Examining path '%s' for conversion" % (child_path))
       if not self.convert_path_history(root, revnum, child_path):
         self.process_dir(root, revnum, child_path)
Example #23
0
def main():

    if len(sys.argv) < 2:
        print "Syntax: %s file.c" % (sys.argv[0])
        sys.exit(1)

    block = 0
    line_nb = 0
    log_func = 0

    file = open(sys.argv[1], "r")

    for line in file:
        line_nb += 1

        if block == 0:
            log_func = 0

        if sre.match(".*return.*", line):
            if block > 1 and log_func == 0:
                print "%s:%d:%s : return called but no log previously defined, this might confuse the user." % (
                    sys.argv[1], line_nb, line.strip())

        if sre.match(".*{.*", line):
            block += 1

        if sre.match(".*}.*", line):
            block -= 1
            log_func = 0

        for log in log_functions:
            expr = ".*%s.*" % (log)
            if sre.match(expr, line) and block > 0:
                log_func = 1

    file.close()
Example #24
0
def loadurl(urlname,context={}):
    """resolves a url and returns the results
    if the url starts with file:// then it will try to find a static file
    if it starts with python:// then it will try to find a python object"""
    parameter_re = "\s*(\w+\s*=|)\s*\w+\s*"
    namedparameter_re = "\s*((?P<key>\w+)\s*=|)\s*(?P<value>\w+)\s*"
    identifier_re = "(\w+[.])+\w+"
    module_re = "(?P<module>(%s))" % identifier_re
    parameters_re = "(?P<params>(%s,)*%s)" % (parameter_re, parameter_re)
    innerid_re = "[.]\w+"
    import_re = "\s*%s\s*(\(%s\)\s*|)" % (module_re, parameters_re)
    import_matcher = sre.compile(import_re)
    import_match = import_matcher.match(urlname)
    if not import_match:
        raise ValueError("Invalid overlay definition: %s" % urlname)
    module = import_match.group("module")
    moduleparts = module.split(".")
    
    #load the first part as that should be a module
    modulename = moduleparts.pop(0)
    includeobject = imp.load_module(modulename,*imp.find_module(modulename))

    #cycle through the rest of the url parts gathering objects as we go
    for part in moduleparts:
        if hasattr(includeobject,part):
            includeobject = getattr(includeobject,part)

    if callable(includeobject):
        parameters = import_match.group("params")
        includeargs = []
        includekwargs = {}
        if parameters:
            for parameterdef in parameters.split(","):
                namedparameter_match = sre.match(namedparameter_re, parameterdef)
                key = namedparameter_match.group("key")
                value = namedparameter_match.group("value")
                value = context.get(value)
                if key:
                    if isinstance(key, unicode):
                        key = key.encode("utf-8")
                    includekwargs[key] = context.get(value,value)
                else:
                    includeargs.append(context.get(value,value))
        includeobject = includeobject(*includeargs, **includekwargs)
    return str(includeobject)

    includesource = open(os.path.join(namespacedir, filename), "r").read()
    return includesource
Example #25
0
def checkGeneration(flock):
	"""This checks to see what generation we are one and returns the next generation"""
	current = 0
	for count in flock:
		#print `flock[count].file`
		prjm_file = flock[count].file.split('/')
		if sre.match('GeneticM', prjm_file[-1]):
			parts = prjm_file[-1].split('-')
			try: 
				new = int(parts[1])
			except:
				continue
			if current <= new: 
				current = new
	current += 1
	return current
Example #26
0
 def deleteRecording(self, program):
     """
     @type program: RecordedProgram
     @return: 1 on success, 0 on failure
     """
     msg = program.data()[:]
     msg.insert(0, 'DELETE_RECORDING')
     msg.append('0')
     reply = self._sendRequest(self.cmdSock, msg)
     if sre.match('^-?\d+$', reply[0]):
         rc = int(reply[0])
         self.bus.publish({'id':Event.RECORDING_DELETED, 'source': self, 'program':program})
     else:
         raise ServerException, reply[0]
     log.debug('Deleted recording %s with response %s' % (safe_str(program.title()), rc))
     return rc
Example #27
0
def checkGeneration(flock):
    """This checks to see what generation we are one and returns the next generation"""
    current = 0
    for count in flock:
        #print `flock[count].file`
        prjm_file = flock[count].file.split('/')
        if sre.match('GeneticM', prjm_file[-1]):
            parts = prjm_file[-1].split('-')
            try:
                new = int(parts[1])
            except:
                continue
            if current <= new:
                current = new
    current += 1
    return current
Example #28
0
File: core.py Project: LLNL/WVL
	def reinitFromString(self,arg):
		if arg.startswith('PYROLOC') or arg.startswith('PYRONAME'):
			uri=processStringURI(arg)
			self.init(uri.address,uri.objectID,uri.port,uri.protocol)
			return
		x=sre.match(r'(?P<protocol>[^\s:/]+)://(?P<hostname>[^\s:]+):?(?P<port>\d+)?/(?P<id>\S*)',arg)
		if x:
			self.protocol=x.group('protocol')
			self.address=x.group('hostname')
			self.port=x.group('port')
			if self.port:
				self.port=int(self.port)
			else:
				self.port=Pyro.config.PYRO_PORT
			self.objectID=x.group('id')
			return
		Log.error('PyroURI','illegal URI format passed: '+arg)
		raise URIError('illegal URI format')
Example #29
0
 def rerecordRecording(self, program):
     """
     Deletes a program and allows it to be recorded again. 
     
     @type program: RecordedProgram
     @return: 1 on success, 0 on failure
     """
     rc1 = self.deleteRecording(program)
     
     msg = program.data()[:]
     msg.insert(0, 'FORGET_RECORDING')
     msg.append('0')
     reply = self._sendRequest(self.cmdSock, msg)
     if sre.match('^-?\d+$', reply[0]):
         rc2 = int(reply[0])
     else:
         raise ServerException, reply[0]
     log.debug('Allowed re-record of %s with response %s' %(safe_str(program.title()), rc2))
     return rc1
	def __init__(self, req):
		#f = open("/tmp/falstelo.log","w")

		self.requeteApache = req
		self.typeMime = configuration.typeMime
		#le fichier demandé est forcement un .html
		#on lui ote donc ce ".html" final
		self.fichierDemande = self.requeteApache.filename[0:len(self.requeteApache.filename)-5]
		#on extrait du fichier demandé le repertoire dans lequel on travaille (le lien vers la feuille de style XSLT sera en fonction de ce repertoire
		#f.write("URI="+req.uri+"\nUnparsed URI="+req.unparsed_uri+"\nFilename="+req.filename+"\nrepertoireTravail="+sre.match("(/.*/)", req.filename).group(0)+"\n")
		#f.close()
		self.repertoireTravail = sre.match("(/.*/)", req.filename).group(0)
		
		self.fichiersXML = []
		self.noeudsXML = []
		self.requetesSQL = []
		self.fichierXSLT = None
		self.resultat = ""
		return
Example #31
0
 def literal(self, probe=False):
     if probe:
         return self.token(self.numeric_lit, probe) or \
             self.token(self.string_lit, probe) or \
             self.token(self.http_lit, probe)
     src_pos = self.i
     if self.token(self.numeric_lit, True):
         lit = self.token(self.numeric_lit)
         return NumericLitExpr((src_pos, self.i), cook_number(lit))
     elif self.token(self.string_lit, True):
         lit = self.token(self.string_lit)
         return StringLitExpr((src_pos, self.i), cook_string(lit))
     elif self.token(self.http_lit, True):
         lit = self.token(self.http_lit)
         m = sre.match(self.http_lit, lit)
         range = (src_pos, self.i)
         self.decorate(range, format_http_link)
         return HttpLitExpr(range, m.group(2))
     else:
         raise ParseError(self, 'Bad literal: ' + self.str[src_pos:])
Example #32
0
    def buildListEntry(self, row):
        mlog.debug('> upcoming.Window.buildListEntry()')
        entry = strftime("%a %d/%m %I:%M%p",
                         time.localtime(float(row.recstarttime())))
        if row.cardid():
            entry += " - Encoder %s" % row.cardid()
        if row.channame():
            entry += " - %s" % row.channame()
        if row.title():
            entry += " - %s" % row.title()
        if row.subtitle() and not sre.match('^\s+$', row.subtitle()):
            entry += "-%s" % row.subtitle()
#        start = strptime( row.starttime(), "%Y%m%d%H%M%S" )
#        entry = strftime( "%m/%d %I:%M %p", start ) + "   "
#        if row.title():
#            entry += row.title()
#        if row.subtitle() and not sre.match( '^\s+$', row.subtitle() ):
#            entry += " - " + row.subtitle()
#
        mlog.debug('< upcoming.Window.buildListEntry()')
        return entry
Example #33
0
        #			child2,
        #			child3...  ]
        breeders = selectBreeders(count, children, possible_parents, too_old,
                                  flock)

        #print breeders
        #for file in flock:

        breedParents(breeders, flock, count, generation, mutation_chances,
                     possible_parents, main_dir, False, False)

        print "a-ok"
    return


if not sre.match(".*pydoc$", sys.argv[0]):
    # option parsing with optparse
    opts_parser = optparse.OptionParser("usage: %prog [options]")
    opts_parser.add_option("-l",
                           "--playlist",
                           dest="playlist_file",
                           default=False,
                           help="Specify the playlist file to use")
    opts_parser.add_option(
        "-o",
        "--outputpath",
        dest="output_path",
        default=False,
        help="Specify the output path, where new presets will be written")
    opts_parser.add_option("-i",
                           "--images",
Example #34
0
def main():
    """non-playlist based breeding no longer allowed
	Legacy code that will hopefully go away someday soon"""

    if not options.playlist_file:
        print "Playlist now required"
        sys.exit(1)

    if not options.output_path:
        print "Output path required"
        sys.exit(1)

    presets_directory = options.output_path

    if options.playlist_file:
        playlist = ProjectMPlaylist(options.playlist_file, options.milkdrop)
        playlist.readFile()

        # Return "This" Generation's number
        generation = checkGeneration(playlist.flock)

        # find the last surviving generation
        too_old = generation - lifespan

        # select the breeders from the pool and return them in a dictionary of lists:
        #  { primary_parent: [ child1,
        #			child2,
        #			child3...  ]
        breeders = selectBreeders2(playlist.total_presets, children,
                                   possible_parents, too_old, playlist.flock)

        #print breeders
        #for file in flock:

        breedParents(breeders, playlist.flock, playlist.total_presets,
                     generation, mutation_chances, possible_parents,
                     presets_directory, options.milkdrop, False, False)

        print "new ok"

    else:
        # old shit code
        flock = {}
        full_list = []
        split_dirs = presets_directory.split(':')
        main_dir = split_dirs[0]
        for dir in split_dirs:
            list = os.listdir(dir)
            #	list = list.split('\n')
            #	full_list.extend(list)
            # ewwww, gross, this is *way* slower than extend
            # fix this later, it sucks, especially when you have thousands and thousands of presets
            for file in list:
                if sre.match('GeneticM', file):
                    full_list.append(dir + file)
        print "list generated"

        # find the current number of presets to give our secondary count starting number.
        count = 0
        for file in full_list:
            flock[count] = GeneticMlib.Evolver(file, False)
            count += 1

        # Return "This" Generation's number
        generation = checkGeneration(flock)

        # find the last surviving generation
        too_old = generation - lifespan

        # select the breeders from the pool and return them in a dictionary of lists:
        #  { primary_parent: [ child1,
        #			child2,
        #			child3...  ]
        breeders = selectBreeders(count, children, possible_parents, too_old,
                                  flock)

        #print breeders
        #for file in flock:

        breedParents(breeders, flock, count, generation, mutation_chances,
                     possible_parents, main_dir, False, False)

        print "a-ok"
    return
Example #35
0
		generation = checkGeneration(flock)

		# find the last surviving generation
		too_old = generation - lifespan

		# select the breeders from the pool and return them in a dictionary of lists:
		#  { primary_parent: [ child1,
		#			child2,
		#			child3...  ]
		breeders = selectBreeders(count, children, possible_parents, too_old, flock)

		#print breeders
		#for file in flock:

		breedParents(breeders, flock, count, generation, mutation_chances, possible_parents, main_dir, False, False)

		print "a-ok"
	return

if not sre.match(".*pydoc$", sys.argv[0]):
	# option parsing with optparse
	opts_parser = optparse.OptionParser("usage: %prog [options]")
	opts_parser.add_option("-l", "--playlist", dest="playlist_file", default=False, help="Specify the playlist file to use")
	opts_parser.add_option("-o", "--outputpath", dest="output_path", default=False, help="Specify the output path, where new presets will be written")
	opts_parser.add_option("-i", "--images", action="store_true", dest="images", default=False, help="Use images mode to mutate in images")
	opts_parser.add_option("-m", "--milkdrop", action="store_true", dest="milkdrop", default=False, help="Milkdrop suport (?) - use .milk suffix instead of .prjm")
	options, args = opts_parser.parse_args()
	# run the main loop
	main()

Example #36
0
def main():
    finished = False

    gaia = wikipedia.getSite(code=u'en', fam=u'gaia')
    wikipedia.setAction(wikipedia.translate(gaia, msg))
    wikipedia.output(u'Welcome to the Gaiabot Item Creatior.')

    blank = sre.compile(u'^$', sre.UNICODE)

    while not finished:
        wikipedia.output(u'Begining Process...')
        choice = wikipedia.inputChoice(u'Do you wish to create a item?',
                                       ['Yes', 'No'], ['y', 'N'], 'N')
        if choice in ['n', 'N']:
            finished = True
        else:
            wikipedia.output(
                u'Please enter the asked values to create a Item partial.')
            name = u''
            image = u''
            thumb = False
            price = u''
            store = u''
            gender = u''
            description = u''
            month = u''
            year = u''
            isDonation = False
            alt = u''
            otheritem = u''

            intro = u''

            trivia = []
            external = []
            groups = []
            animalHats = False
            animalMasks = False
            masks = False
            headgear = False

            while name.isspace() or sre.match(blank, name) != None:
                name = wikipedia.input(u'Please enter the item name: ').strip(
                    u' ').strip(u'	')
            choice = wikipedia.inputChoice(u'Is this a donation Item?',
                                           ['Yes', 'No'], ['y', 'N'], 'N')
            if choice in ['y', 'Y']:
                isDonation = True
                alt = wikipedia.input(
                    u'(Optional)Please enter the item\'s alternate name if it has one: '
                ).strip(u' ').strip(u'	')
                otheritem = wikipedia.input(
                    u'(Optional)Please enter the name of other item released this month: '
                ).strip(u' ').strip(u'	')
            else:
                intro = wikipedia.input(
                    u'Please enter the intro statement for the item: ').strip(
                        u' ').strip(u'	')
            image = wikipedia.input(
                u'If it has one, please enter the name of the image for the Item. No Item: Prefix: '
            ).strip(u' ').strip(u'	')
            if not image.isspace() and sre.match(blank, image) == None:
                choice = wikipedia.inputChoice(
                    u'Does this image need to become a thumbnail for space (Large Images only.)?',
                    ['Yes', 'No'], ['y', 'N'], 'N')
                if choice in ['y', 'Y']:
                    thumb = True
            price = wikipedia.input(
                u'Please enter the item\'s price, if it is not sold in stores leave blank: '
            ).strip(u' ').strip(u'	')
            store = wikipedia.input(
                u'Please enter the name of the store that the item is sold at: '
            ).strip(u' ').strip(u'	')
            gender = wikipedia.input(
                u'Please enter the gender that the item can be equiped to, leave blank for Any: '
            ).strip(u' ').strip(u'	')
            description = wikipedia.input(
                u'Please enter the item description: ').strip(u' ').strip(u'	')
            choice = wikipedia.inputChoice(
                u'What Month was this item released in?', [
                    'January', 'Fenuary', 'March', 'April', 'May', 'June',
                    'July', 'August', 'September', 'October', 'November',
                    'December', 'Unknown'
                ], [
                    'jan', 'feb', 'mar', 'apr', 'may', 'june', 'july', 'aug',
                    'sept', 'oct', 'nov', 'dec', 'u'
                ], 'u')
            if choice in ['jan', 'Jan', 'january', 'January']:
                month = u'January'
            elif choice in ['feb', 'Feb', 'feburary', 'Febuary']:
                month = u'Febuary'
            elif choice in ['mar', 'Mar', 'march', 'March']:
                month = u'March'
            elif choice in ['apr', 'Apr', 'april', 'April']:
                month = u'April'
            elif choice in ['may', 'May']:
                month = u'May'
            elif choice in ['june', 'June']:
                month = u'June'
            elif choice in ['july', 'July']:
                month = u'July'
            elif choice in ['aug', 'Aug', 'august', 'August']:
                month = u'August'
            elif choice in [
                    'sep', 'Sep', 'sept', 'Sept', 'september', 'September'
            ]:
                month = u'September'
            elif choice in ['oct', 'Oct', 'october', 'October']:
                month = u'October'
            elif choice in ['nov', 'Nov', 'november', 'November']:
                month = u'November'
            elif choice in ['dec', 'Dec', 'december', 'December']:
                month = u'December'
            year = wikipedia.input(u'What year was this item released in?'
                                   ).strip(u' ').strip(u'	')
            incomplete = True
            while incomplete:
                t = wikipedia.input(
                    u'You may enter multiple entrys for the trivia section here. Leave the box blank when you are finished: '
                ).strip(u' ').strip(u'	')
                if not t.isspace() and sre.match(blank, t) == None:
                    trivia.append(t)
                else:
                    incomplete = False
            incomplete = True
            while incomplete:
                e = wikipedia.input(
                    u'Please enter a URL for the External links section. Use Blank when finished: '
                ).strip(u' ').strip(u'	')
                if not e.isspace() and sre.match(blank, e) == None:
                    c = wikipedia.input(
                        u'Please enter a caption for this URL if you wish: '
                    ).strip(u' ').strip(u'	')
                    external.append((e, c))
                else:
                    incomplete = False
            incomplete = True
            while incomplete:
                g = wikipedia.input(
                    u'Please enter the names of the normal Item Groups this Item is in. Leave the box blank when you are finished(Do not use special groups): '
                ).strip(u' ').strip(u'	')
                if not g.isspace() and sre.match(blank, g) == None:
                    groups.append(g)
                else:
                    incomplete = False
            incomplete = True
            choice = wikipedia.inputChoice(
                u'Is this a in the Special group "Animal Hats"?',
                ['Yes', 'No'], ['y', 'N'], 'N')
            if choice in ['y', 'Y']:
                animalHats = True
            choice = wikipedia.inputChoice(
                u'Is this a in the Special group "Animal Masks"?',
                ['Yes', 'No'], ['y', 'N'], 'N')
            if choice in ['y', 'Y']:
                animalMasks = True
            choice = wikipedia.inputChoice(
                u'Is this a in the Special group "Masks"?', ['Yes', 'No'],
                ['y', 'N'], 'N')
            if choice in ['y', 'Y']:
                masks = True
            choice = wikipedia.inputChoice(
                u'Is this a in the Special group "Headgear"?', ['Yes', 'No'],
                ['y', 'N'], 'N')
            if choice in ['y', 'Y']:
                headgear = True
            outputTo = wikipedia.input(
                u'(Required)Please enter the article name you wish to output the Item Partial to: '
            ).strip(u' ').strip(u'	')

            if not outputTo.isspace() and sre.match(blank, outputTo) == None:
                pageData = u''
                if isDonation:
                    pageData += u'{{donationIntro|name=%s|' % name
                    if not alt.isspace() and sre.match(blank, alt) == None:
                        pageData += u'alt=%s|' % alt
                    pageData += u'month=%s|year=%s|other=%s}}\n' % (
                        month, year, other)
                else:
                    pageData += u'%s\n' % intro
                pageData += u'{{item|name=%s' % name
                if not image.isspace() and sre.match(blank, image) == None:
                    pageData += u'|image=%s' % image
                    if thumb:
                        pageData += u'|thumb=true'
                if not price.isspace() and sre.match(blank, price) == None:
                    pageData += u'|price=%s' % price
                if not store.isspace() and sre.match(blank, store) == None:
                    pageData += u'|store=%s' % store
                if not gender.isspace() and sre.match(blank, gender) == None:
                    pageData += u'|gender=%s' % gender
                pageData += u'|description=%s' % description
                if not month.isspace() and sre.match(blank, month) == None:
                    pageData += u'|month=%s' % month
                if not year.isspace() and sre.match(blank, year) == None:
                    pageData += u'|year=%s' % year
                pageData += u'}}\n'
                pageData += u'==Trivia==\n'
                if len(trivia) > 0:
                    for t in trivia:
                        pageData += u'%s\n\n' % t
                else:
                    pageData += u'???\n\n'
                pageData += u'==External Links==\n'
                for url, comment in external:
                    pageData += u'* %s' % url
                    if not comment.isspace() and sre.match(blank,
                                                           comment) == None:
                        pageData += u' - %s' % comment
                    pageData += u'\n'
                pageData += u'\n'
                pageData += u'{{itemGroups'
                for g in groups:
                    pageData += u'|%s' % g
                if animalHats:
                    pageData += u'|Animal Hats'
                if animalMasks:
                    pageData += u'|Animal Masks'
                if masks:
                    pageData += u'|Masks'
                if headgear:
                    pageData += u'|Headgear'
                pageData += u'}}'

                page = wikipedia.Page(gaia, u'%s' % outputTo)
                old = u''
                try:
                    old = page.get()
                except wikipedia.NoPage:
                    old = u''
                page.put(old + pageData)
Example #37
0
import sre

text = "The Bookshop Sketch"

# a single character
m = sre.match(".", text)
if m: print(repr("."), "=>", repr(m.group(0)))

# and so on, for all 're' examples...

## '.' => 'T'



Example #38
0
# Misc tests from Tim Peters' re.doc

if verbose:
    print 'Running tests on sre.search and sre.match'

try:
    assert sre.search('x*', 'axx').span(0) == (0, 0)
    assert sre.search('x*', 'axx').span() == (0, 0)
    assert sre.search('x+', 'axx').span(0) == (1, 3)
    assert sre.search('x+', 'axx').span() == (1, 3)
    assert sre.search('x', 'aaa') == None
except:
    raise TestFailed, "sre.search"

try:
    assert sre.match('a*', 'xxx').span(0) == (0, 0)
    assert sre.match('a*', 'xxx').span() == (0, 0)
    assert sre.match('x*', 'xxxa').span(0) == (0, 3)
    assert sre.match('x*', 'xxxa').span() == (0, 3)
    assert sre.match('a+', 'xxx') == None
except:
    raise TestFailed, "sre.search"

if verbose:
    print 'Running tests on sre.sub'

try:
    assert sre.sub("(?i)b+", "x", "bbbb BBBB") == 'x x'

    def bump_num(matchobj):
        int_value = int(matchobj.group(0))
Example #39
0
def main():
	"""non-playlist based breeding no longer allowed
	Legacy code that will hopefully go away someday soon"""

	if not options.playlist_file:
		print "Playlist now required"
		sys.exit(1)

	if not options.output_path:
		print "Output path required"
		sys.exit(1)
	
	presets_directory = options.output_path

	if options.playlist_file:
		playlist = ProjectMPlaylist(options.playlist_file, options.milkdrop)
		playlist.readFile()
		
		# Return "This" Generation's number
		generation = checkGeneration(playlist.flock)

		# find the last surviving generation
		too_old = generation - lifespan

		# select the breeders from the pool and return them in a dictionary of lists:
		#  { primary_parent: [ child1,
		#			child2,
		#			child3...  ]
		breeders = selectBreeders2(playlist.total_presets, children, possible_parents, too_old, playlist.flock)

		#print breeders
		#for file in flock:

		breedParents(breeders, playlist.flock, playlist.total_presets, generation, mutation_chances, possible_parents, presets_directory, options.milkdrop, False, False)

		print "new ok"

	else:
		# old shit code
		flock = {}
		full_list = []
		split_dirs = presets_directory.split(':')
		main_dir = split_dirs[0]
		for dir in split_dirs:
			list = os.listdir(dir)
		#	list = list.split('\n')
		#	full_list.extend(list)
			# ewwww, gross, this is *way* slower than extend
			# fix this later, it sucks, especially when you have thousands and thousands of presets
			for file in list:
				if sre.match('GeneticM', file):
					full_list.append(dir + file)
		print "list generated"

		# find the current number of presets to give our secondary count starting number.
		count = 0
		for file in full_list:
			flock[count] = GeneticMlib.Evolver(file, False)
			count += 1

		# Return "This" Generation's number
		generation = checkGeneration(flock)

		# find the last surviving generation
		too_old = generation - lifespan

		# select the breeders from the pool and return them in a dictionary of lists:
		#  { primary_parent: [ child1,
		#			child2,
		#			child3...  ]
		breeders = selectBreeders(count, children, possible_parents, too_old, flock)

		#print breeders
		#for file in flock:

		breedParents(breeders, flock, count, generation, mutation_chances, possible_parents, main_dir, False, False)

		print "a-ok"
	return
Example #40
0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# -------------------------------------------------------------------------
#
# parsetestResults.pl
#
# Transliteration of the perl version
#
import sys,sre
docStrings = {}

for line in sys.stdin:
   if not sre.match("^-",line):
      x=sre.match("^([^-]+)-(.*)... ok$",line)
      if x:
         method,description = x.groups()
         try:
            docStrings[method].append(description)
         except KeyError:
            docStrings[method]=[description]

methods = [method for method in docStrings]
methods.sort()
for method in methods:
   methPrint = sre.sub("(^ *| *$)", "", method)
   print "\t$ ==%s== : " % methPrint,;
   descriptions = docStrings[method]
   descriptions.sort()
Example #41
0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# -------------------------------------------------------------------------
#
# parsetestResults.pl
#
# Transliteration of the perl version
#
import sys, sre
docStrings = {}

for line in sys.stdin:
    if not sre.match("^-", line):
        x = sre.match("^([^-]+)-(.*)... ok$", line)
        if x:
            method, description = x.groups()
            try:
                docStrings[method].append(description)
            except KeyError:
                docStrings[method] = [description]

methods = [method for method in docStrings]
methods.sort()
for method in methods:
    methPrint = sre.sub("(^ *| *$)", "", method)
    print "\t$ ==%s== : " % methPrint,
    descriptions = docStrings[method]
    descriptions.sort()
Example #42
0
import sre

text = "The Bookshop Sketch"

# a single character
m = sre.match(".", text)
if m: print repr("."), "=>", repr(m.group(0))

# and so on, for all 're' examples...

## '.' => 'T'



Example #43
0
mobj = sre.search(sre.compile("\.bz2$"), args[0])
if mobj:
    infile.close()
    infile = bz2.BZ2File(args[0])


if not infile:
    print "error opening ",args[0]
    sys.exit(0)

buffer = infile.readline()
if not buffer:
    print "error reading from ",args[0]
    usage(sys.argv[0])

mobj = sre.match(sre.compile('first-record ([\d\.]+)'), buffer)
if mobj:
    startsecs = float(mobj.group(1))
    print "got starting time from file header: ",startsecs
else:
    print "no starting time - bailing."
    sys.exit(0)
    
    
lines = long(0)
print >>sys.stderr,"progress (10k lines): ",
while 1:
    buffer = infile.readline()
    if not buffer:
        break
Example #44
0
idMap = IdentifierMap()

globalReplace = str()
if len(sys.argv) > 2:
    globalReplace = sys.argv[2]
globalReplace = globalReplace.split()
print globalReplace

kernel = psci.Kernel.CreateKernelInCurrentThread()
agent = kernel.CreateAgent('obfuscator')
kernel.ExecuteCommandLine('source "%s"' % sys.argv[1], 'obfuscator')
original = kernel.ExecuteCommandLine('print -f', 'obfuscator')
original = original.split('\n')
for line in original:
    match = sre.match(r'^\s*sp\s*\{(.+)\s*$', line)
    if match is not None:
        line = line.replace(match.group(1),
                            idMap.getIdentifier(match.group(1)))
    else:
        vars = sre.findall(r'<(\S+)>', line)
        for var in vars:
            line = line.replace('<' + var + '>',
                                '<' + idMap.getIdentifier(var) + '>')

        match = sre.match(r'.*\^name ([\w-]+)', line)
        if match is not None:
            line = line.replace(
                '^name %s' % match.group(1),
                '^name %s' % idMap.getIdentifier(match.group(1)))