Welcome To Our Shell

Mister Spy & Souheyl Bypass Shell

Current Path : /home/ift/52_procpy/dataninja/95__misc/

Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
Upload File :
Current File : //home/ift/52_procpy/dataninja/95__misc/gpycode.py

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

import os
import re
import sys
import time
try:
    import xmltodict
except:
    import pip
    pip.main(["install","xmltodict"])
    import xmltodict


#*********************************************************************

class GraphML (object):

    def __init__ (self,text):

        self.nodes   = {}
        self.edges   = []
        self.targets = {}
        self.sources = {}
        self.parse(text)
        self.pycode  = ""
        
#*********************************************************************

    def parse_from_graphml (self,text):

        try:
            d = xmltodict.parse(text)
        except:
            d = text
    
        if type(d['graphml']['graph']['node']).__name__ == 'list':
            for node in d['graphml']['graph']['node']:
                obj = Node(node)
                self.nodes[obj.id] = obj
        else:
            obj = Node(d['graphml']['graph']['node'])
            self.nodes[obj.id] = obj
        
        self.allnodes = {}
        for k in self.nodes:
            self.allnodes[k] = self.nodes[k]
            for k1 in self.nodes[k].nodes:
                self.allnodes[k1] = self.nodes[k].nodes[k1]
            
        if type(d['graphml']['graph']['edge']).__name__ == 'list':
            for edge in d['graphml']['graph']['edge']:
                self.edges.append(Edge(edge,self.allnodes))
        else:
            self.edges.append(Edge(d['graphml']['graph']['edge'],self.allnodes))
        
        for edge in self.edges:
            try:
                self.sources[edge.source].append(edge)
            except:        
                self.sources[edge.source] = [edge]
            try:
                self.targets[edge.target].append(edge)
            except:        
                self.targets[edge.target] = [edge]


#*********************************************************************
#*********************************************************************
        

class Node (object):

    def __init__ (self,d):

        self.nodes = {}
        self.parse(d)

#*********************************************************************

    def parse (self,d):
    
        self.id = d['@id']

        try:
            d['graph']['node']
            bed = True
        except:
            bed = False
            
        if bed:
            if type(d['graph']['node']).__name__ == 'list':
                for node in d['graph']['node']:
                    obj = Node(node)
                    self.nodes[obj.id] = obj
            else:
                obj = Node(d['graph']['node'])
                self.nodes[obj.id] = obj
        
        nodedata = self.get_nodedata(d)

        if nodedata:
            self.w = float(nodedata['y:Geometry']['@width'])
            self.h = float(nodedata['y:Geometry']['@height'])
            self.x = float(nodedata['y:Geometry']['@x']) + 0.5*self.w
            self.y = float(nodedata['y:Geometry']['@y']) + 0.5*self.h
            try:
                self.color = nodedata['y:Fill']['@color']
            except:
                self.color = ""
            try:
                label = nodedata['y:NodeLabel']
            except:
                label = None
            if label:
                if type(label).__name__ != 'list':
                    try:
                        self.label = label['#text']
                    except:
                        pass
                else:
                    self.label    = []
                    sumrows       = 99999999
                    for l1 in label:
                        try:
                            self.label.append(l1['#text'])
                        except:
                            self.label.append("")
                    sumrows       = 1
                    self.rowlines = []
                    for row in nodedata['y:Table']['y:Rows']['y:Row']:
                        sumrows = sumrows + (float(row['@height'])             +
                                             float(row['y:Insets']['@bottom']) +
                                             float(row['y:Insets']['@top'])    ) + 1
                        self.rowlines.append(sumrows)
                    print str(self.rowlines)
                    
            

#*********************************************************************

    def get_nodedata (self,d):

        try:
            return(d['data'][1]['y:GenericNode'])
        except:
            pass
            
        try:
            return(d['data'][1]['y:ShapeNode'])
        except:
            pass
            
        try:
            return(d['data'][1]['y:TableNode'])
        except:
            pass
            
        try:
            return(d['data'][0]['y:GenericNode'])
        except:
            pass
            
        try:
            return(d['data'][0]['y:ShapeNode'])
        except:
            pass
            
        try:
            return(d['data'][0]['y:TableNode'])
        except:
            pass
            
        try:
            return(d['data']['y:GenericNode'])
        except:
            pass
            
        try:
            return(d['data']['y:ShapeNode'])
        except:
            pass
            
        try:
            return(d['data']['y:TableNode'])
        except:
            pass
            
        return(None)
    
#*********************************************************************
#*********************************************************************
        

class Edge (object):

    def __init__ (self,d,allnodes):

        self.source = None
        self.target = None
        self.allnodes = allnodes
        self.points = []
        self.parse(d)
        

#*********************************************************************

    def parse (self,d):
    
        self.source = d['@source']
        self.target = d['@target']

        self.points = [ [ self.allnodes[self.source].x,self.allnodes[self.source].y ] ]

        edgedata = self.get_edgedata(d)
        
        try:
            points = edgedata['y:Path']['y:Point']
        except:
            points = []
        for point in points:
            self.points.append( [ float(point['@x']), float(point['@y']) ] )

        self.points.append( [ self.allnodes[self.target].x,self.allnodes[self.target].y ] )

        for i in [0,-1]:   #  Korrektur auf rechtwinklige Anordnung der Edges zu den Bloecken
            p0   = self.points[1+3*i]  #  der Nachbarpunkt zum Anfangs- bzw Endpunkt
            x    = float(p0[0])
            y    = float(p0[1])
            node = [self.allnodes[self.source],self.allnodes[self.target]][i]
            x0   = node.x
            y0   = node.y
            x1   = x0 + 0.5*node.w
            y1   = y0 + 0.5*node.h
            x0   = x0 - 0.5*node.w
            y0   = y0 - 0.5*node.h
            if   x >= x1 and y1 >= y and y >= y0:
                x = x1
            elif x0 >= x and y1 >= y and y >= y0:
                x = x0
            if   y >= y1 and x1 >= x and x >= x0:
                y = y1
            elif y0 >= y and x1 >= x and x >= x0:
                y = y0
            self.points[i][0] = x
            self.points[i][1] = y
            
#*********************************************************************

    def get_edgedata (self,d):
    
        try:
            return(d['data'][1]['y:PolyLineEdge'])
        except:
            pass
            
        try:
            return(d['data'][0]['y:PolyLineEdge'])
        except:
            pass
            
        try:
            return(d['data']['y:PolyLineEdge'])
        except:
            pass
            
#*********************************************************************

"""

class PyCode (object):


    def __init__ (self):
        pass

#*********************************************************************

    def gp_to_py (gp):

        pytext = '''#  -*-  coding: utf-8 -*-
    
import procpy

class PROC (object):

    def __init__ (self,par):
        self.SUMTIME    = 0
        self.SUMEFFORT  = 0
        self.SUMCHECKTIMEEKF      = 0
        self.SUMCHECKTIMEMANAGER  = 0
        self.SUMPATH    = '.'
        self.SLEEP      = 0
        self.BLOCK      = ''
        self.JUMP       = 'run'        

'''

        nodes   = {}
        edges   = {}
    
        for k in gdata.keys():
    
            entry = gdata[k]

            if re.search(r"^node",k):
                nodes[("%06u" % int(entry['id']))] = entry
            if re.search(r"^edge",k):
                edges[("%06u" % int(entry['source']))+"-"+("%06u" % int(entry['target']))] = entry
        
    nodes_keys = nodes.keys()
    nodes_keys.sort()
    
    is_target = {}
    for edge in edges:    #  collect all blocks that occurs as targets
        is_target[ int(edges[edge]['target']) ] = 1

    print is_target
    for k in nodes_keys:    #  process all the blocks
    
        func  = "t" + ("%02u" % int(nodes[k]['id']) )
        if not int(nodes[k]['id']) in is_target:
            func = "run"
        text1 = "    def " + func + " (self):\n\n"
        try:
            text2 = str(nodes[k]['label'])
            text2 = text2.strip()
#            if str(nodes[k]['id']) == text2:
#                text2 = ""
        except:
            text2 = ""
        if not text2 == "":
            text2 = "        " + re.sub(r"\n","\n        ",text2,99999999,flags=re.DOTALL)
            text2 = re.sub("\$([A-Z][A-Z0-9]*)","self.\\1",text2,99999999)
#            m = re.search(r"(^.*\n|^)(        \-+ *\n)(.*)$",text2,flags=re.DOTALL)
#            if m:
#                text2 = ( m.group(1) + "\n        if self.DRYRUN == 1:\n    " +
#                          re.sub(r"\n","\n    ",m.group(3),99999999,flags=re.DOTALL) )
            text2 = text2 + "\n"
        if re.search("        [\:\[]([A-Z][A-Z0-9]*)[\:\]]",text2):
            text2 = re.sub("        [\:\[]([A-Z][A-Z0-9]*)[\:\]]","        self.BLOCK = '\\1'\n",text2,99999999)
        else:
            text2 = "        self.BLOCK = '" + str(nodes[k]['id']) + "'\n" + text2

        for edge in edges:    #  now look for all edges which will be started by the node
        
            branches = ""  #  the interpretation of an alternative branch
            forklist = []  #  the interpretation of calling (parallel) running childs
            
            if not edges[edge]['source'] == nodes[k]['id']:
                continue
            
            forklist.append(edges[edge]['target'])
            text3 = ""
            try:
                text3 = str(edges[edge]['label'])
            except:
                pass
            if not text3 == "":
                text3 = text3.strip()
                m = re.search(r"^([0-9\.]+) *\%",text3)
                if m:
                    func  = "t" + ("%02u" % int(edges[edge]['target']))
                    if not int(edges[edge]['target']) in is_target:
                        func = "run"
                    text3 = "___ABC___  '" + func + "' : " + m.group(1) + " ___DEF___"
                else:
                    text3 = re.sub("\$([A-Z][A-Z0-9]+)","self.\\1",text3,99999999)
                    text3 =          "\n        if " + text3 + ": "
                    text3 = text3 +  "self.JUMP  = 't" + ("%02u" % edges[edge]['target']) + "'\n"
            else:
                text3 = "        self.JUMP  = 't" + ("%02u" % edges[edge]['target']) + "'\n"
            text2 = text2 + text3
            del text3
        
        text2 = re.sub(r"___DEF______ABC___",",",text2,99999999)
        text2 = re.sub(r"___ABC___","        self.JUMP = {",text2)
        text2 = re.sub(r"___DEF___","}",text2)

        if not re.search(r"self\.JUMP",text2):
            text2 = text2 + "        self.JUMP  = ''\n"

        if text2 == "":
            text2 = "        pass\n"
        text1 = text1 + text2
        
        pytext = pytext + text1 + "\n\n"

#    print pytext
    return(pytext)

"""


bypass 1.0, Devloped By El Moujahidin (the source has been moved and devloped)
Email: contact@elmoujehidin.net bypass 1.0, Devloped By El Moujahidin (the source has been moved and devloped) Email: contact@elmoujehidin.net