Skip to content
Extraits de code Groupes Projets
Sélectionner une révision Git
  • ae15c20e53976378046fcfa6b866f537b039ffad
  • master par défaut protégée
  • rust-playlist-sync
  • rust
  • fix-qt-deprecated-qvariant-type
  • fix-mpris-qtwindow-race-condition
  • rust-appimage-wayland
  • windows-build-rebased
  • v2.5 protégée
  • v2.4 protégée
  • v2.3-1 protégée
  • v2.3 protégée
  • v2.2 protégée
  • v2.1 protégée
  • v2.0 protégée
  • v1.8-3 protégée
  • v1.8-2 protégée
  • v1.8-1 protégée
  • v1.8 protégée
  • v1.7 protégée
  • v1.6 protégée
  • v1.5 protégée
  • v1.4 protégée
  • v1.3 protégée
  • v1.2 protégée
  • v1.1 protégée
  • v1.0 protégée
27 résultats

module_repo.c

Blame
    • Kubat's avatar
      ae15c20e
      MISC: Dependencies dl update · ae15c20e
      Kubat a rédigé
      - download and build dependencies with configure
      - add libcurl
      - add zlib
      - add iconv
      - sdl2 without touchscreen
      - compile using -fPIC
      - add openssl for libcurl
      MISC: Dependencies dl update
      Kubat a rédigé
      - download and build dependencies with configure
      - add libcurl
      - add zlib
      - add iconv
      - sdl2 without touchscreen
      - compile using -fPIC
      - add openssl for libcurl
    db.py 3,96 Kio
    from neo4j import GraphDatabase
    
    
    class Neo4j:
    
        def __init__(self, uri, user, password):
            self.driver = GraphDatabase.driver(uri, auth=(user, password))
    
        def close(self):
            self.driver.close()
    
        def print_greeting(self, message):
            with self.driver.session() as session:
                greeting = session.execute_write(self._create_and_return_greeting, message)
                print(greeting)
    
        @staticmethod
        def _create_and_return_greeting(tx, message):
            result = tx.run("CREATE (a:Greeting) "
                            "SET a.message = $message "
                            "RETURN a.message + ', from node ' + id(a)", message=message)
            return result.single()[0]
    
        def get_graph_data(self):
            with self.driver.session() as session:
                # results = session.run("MATCH (n)-[r]->(m) RETURN n,r,m")
                results = session.run("""CALL apoc.export.json.all(null,{useTypes:true, stream: true, jsonFormat: "JSON"})
                                            YIELD data
                                            RETURN data""")
                return results.data()
    
        def get_softwares(self):
            with self.driver.session() as session:
                results = session.run("MATCH (n:Software) RETURN n")
                return results.data()
    
        def get_softwares_shortest_path(self, search):
            with self.driver.session() as session:
                # results = session.run("""MATCH (n:Software)-[r:DEPENDS_ON*]-(m:Software)
                #                             WHERE n.name = $software1 AND m.name = $software2
                #                             RETURN n,r,m""", software1=SoftwareSearch.software1,
                #                       software2=SoftwareSearch.software2)
                results = session.run("""MATCH (S1:Software {name: $software1}), (S2:Software {name: $software2}),
                                          p = shortestPath((S1)-[:SIMILAR*]-(S2))
                                            RETURN p""",
                                      software1=search.software1,
                                      software2=search.software2)
                data = results.data()
                if data:
                    return [node for node in data[0]['p'] if type(node) is dict]
                    # [node._properties.get('name') for node in results.graph().nodes]
                else:
                    return []
    
        def get_relations(self):
            with self.driver.session() as session:
                results = session.run("MATCH p = (a)-[r]->(b) RETURN a.name as source,b.name as target, r as relation_type")
                return results.data()
    
        def get_nodes(self):
            with self.driver.session() as session:
                results = session.run("MATCH (a) return Id(a) as key, a.name as name")
                return results.data()
    
        def insert_software(self, insert_data):
            with self.driver.session() as session:
                # On check si le logiciel n'existe pas déjà
                results = session.run("match (a:Software) where a.name = '%s' return a" % insert_data.newNodeName)
                if results.data():
                    return {"Error": "%s already exist" % insert_data.newNodeName}
    
                session.run("CREATE (n:Software {name: '%s'})" % insert_data.newNodeName)
                return results.data()
    
        def relation_insert(self, insert_data):
            with self.driver.session() as session:
                # On check si la node avec laquelle on se relie existe
                results = session.run("match (a:Software) where (a.name = '%s' OR a.name = '%s') return a"
                                      % (insert_data.software1, insert_data.software2))
    
                if len(results.data()) != 2:
                    return {"Error": "%s/%s NOT FOUND" % (insert_data.software1, insert_data.software2)}
    
                results = session.run(
                    "MATCH (a:Software), (b:Software) WHERE a.name = '%s' AND b.name = '%s' CREATE (a)-[r:%s]->(b) "
                    "RETURN type(r)" % (insert_data.software1, insert_data.software2, insert_data.relationType))
                return results.data()