prompt
large_stringlengths
72
9.34k
completion
large_stringlengths
0
7.61k
<|file_name|>tests.py<|end_file_name|><|fim▁begin|># coding: utf-8 import unittest from config_reader import ConfigReader class TestConfigReader(unittest.TestCase): def setUp(self): self.config = ConfigReader(""" <root> <person> <name>山田</name> <age>15</age> </person> <person> <name>佐藤</name> <age>43</age> </person> </root> """) def test_get_names(self): self.assertEqual(self.config.get_names(), ['山田', '佐藤'])<|fim▁hole|> def test_get_ages(self): self.assertEqual(self.config.get_ages(), ['15', '43'])<|fim▁end|>
<|file_name|>tests.py<|end_file_name|><|fim▁begin|># coding: utf-8 import unittest from config_reader import ConfigReader class TestConfigReader(unittest.TestCase): <|fim_middle|> <|fim▁end|>
def setUp(self): self.config = ConfigReader(""" <root> <person> <name>山田</name> <age>15</age> </person> <person> <name>佐藤</name> <age>43</age> </person> </root> """) def test_get_names(self): self.assertEqual(self.config.get_names(), ['山田', '佐藤']) def test_get_ages(self): self.assertEqual(self.config.get_ages(), ['15', '43'])
<|file_name|>tests.py<|end_file_name|><|fim▁begin|># coding: utf-8 import unittest from config_reader import ConfigReader class TestConfigReader(unittest.TestCase): def setUp(self): <|fim_middle|> ef test_get_names(self): self.assertEqual(self.config.get_names(), ['山田', '佐藤']) def test_get_ages(self): self.assertEqual(self.config.get_ages(), ['15', '43']) <|fim▁end|>
self.config = ConfigReader(""" <root> <person> <name>山田</name> <age>15</age> </person> <person> <name>佐藤</name> <age>43</age> </person> </root> """) d
<|file_name|>tests.py<|end_file_name|><|fim▁begin|># coding: utf-8 import unittest from config_reader import ConfigReader class TestConfigReader(unittest.TestCase): def setUp(self): self.config = ConfigReader(""" <root> <person> <name>山田</name> <age>15</age> </person> <person> <name>佐藤</name> <age>43</age> </person> </root> """) def test_get_names(self): self.ass<|fim_middle|> et_ages(self): self.assertEqual(self.config.get_ages(), ['15', '43']) <|fim▁end|>
ertEqual(self.config.get_names(), ['山田', '佐藤']) def test_g
<|file_name|>tests.py<|end_file_name|><|fim▁begin|># coding: utf-8 import unittest from config_reader import ConfigReader class TestConfigReader(unittest.TestCase): def setUp(self): self.config = ConfigReader(""" <root> <person> <name>山田</name> <age>15</age> </person> <person> <name>佐藤</name> <age>43</age> </person> </root> """) def test_get_names(self): self.assertEqual(self.config.get_names(), ['山田', '佐藤']) def test_get_ages(self): self.assertEqual<|fim_middle|> <|fim▁end|>
(self.config.get_ages(), ['15', '43'])
<|file_name|>tests.py<|end_file_name|><|fim▁begin|># coding: utf-8 import unittest from config_reader import ConfigReader class TestConfigReader(unittest.TestCase): def <|fim_middle|>(self): self.config = ConfigReader(""" <root> <person> <name>山田</name> <age>15</age> </person> <person> <name>佐藤</name> <age>43</age> </person> </root> """) def test_get_names(self): self.assertEqual(self.config.get_names(), ['山田', '佐藤']) def test_get_ages(self): self.assertEqual(self.config.get_ages(), ['15', '43']) <|fim▁end|>
setUp
<|file_name|>tests.py<|end_file_name|><|fim▁begin|># coding: utf-8 import unittest from config_reader import ConfigReader class TestConfigReader(unittest.TestCase): def setUp(self): self.config = ConfigReader(""" <root> <person> <name>山田</name> <age>15</age> </person> <person> <name>佐藤</name> <age>43</age> </person> </root> """) def test_get<|fim_middle|> self.assertEqual(self.config.get_names(), ['山田', '佐藤']) def test_get_ages(self): self.assertEqual(self.config.get_ages(), ['15', '43']) <|fim▁end|>
_names(self):
<|file_name|>tests.py<|end_file_name|><|fim▁begin|># coding: utf-8 import unittest from config_reader import ConfigReader class TestConfigReader(unittest.TestCase): def setUp(self): self.config = ConfigReader(""" <root> <person> <name>山田</name> <age>15</age> </person> <person> <name>佐藤</name> <age>43</age> </person> </root> """) def test_get_names(self): self.assertEqual(self.config.get_names(), ['山田', '佐藤']) def test_get_ages(se<|fim_middle|>self.assertEqual(self.config.get_ages(), ['15', '43']) <|fim▁end|>
lf):
<|file_name|>dimension.py<|end_file_name|><|fim▁begin|># coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- from msrest.serialization import Model class Dimension(Model):<|fim▁hole|> where instance name is dimension of the metric HTTP request. :param name: :type name: str :param display_name: :type display_name: str :param internal_name: :type internal_name: str :param to_be_exported_for_shoebox: :type to_be_exported_for_shoebox: bool """ _attribute_map = { 'name': {'key': 'name', 'type': 'str'}, 'display_name': {'key': 'displayName', 'type': 'str'}, 'internal_name': {'key': 'internalName', 'type': 'str'}, 'to_be_exported_for_shoebox': {'key': 'toBeExportedForShoebox', 'type': 'bool'}, } def __init__(self, name=None, display_name=None, internal_name=None, to_be_exported_for_shoebox=None): super(Dimension, self).__init__() self.name = name self.display_name = display_name self.internal_name = internal_name self.to_be_exported_for_shoebox = to_be_exported_for_shoebox<|fim▁end|>
"""Dimension of a resource metric. For e.g. instance specific HTTP requests for a web app,
<|file_name|>dimension.py<|end_file_name|><|fim▁begin|># coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- from msrest.serialization import Model class Dimension(Model): <|fim_middle|> <|fim▁end|>
"""Dimension of a resource metric. For e.g. instance specific HTTP requests for a web app, where instance name is dimension of the metric HTTP request. :param name: :type name: str :param display_name: :type display_name: str :param internal_name: :type internal_name: str :param to_be_exported_for_shoebox: :type to_be_exported_for_shoebox: bool """ _attribute_map = { 'name': {'key': 'name', 'type': 'str'}, 'display_name': {'key': 'displayName', 'type': 'str'}, 'internal_name': {'key': 'internalName', 'type': 'str'}, 'to_be_exported_for_shoebox': {'key': 'toBeExportedForShoebox', 'type': 'bool'}, } def __init__(self, name=None, display_name=None, internal_name=None, to_be_exported_for_shoebox=None): super(Dimension, self).__init__() self.name = name self.display_name = display_name self.internal_name = internal_name self.to_be_exported_for_shoebox = to_be_exported_for_shoebox
<|file_name|>dimension.py<|end_file_name|><|fim▁begin|># coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- from msrest.serialization import Model class Dimension(Model): """Dimension of a resource metric. For e.g. instance specific HTTP requests for a web app, where instance name is dimension of the metric HTTP request. :param name: :type name: str :param display_name: :type display_name: str :param internal_name: :type internal_name: str :param to_be_exported_for_shoebox: :type to_be_exported_for_shoebox: bool """ _attribute_map = { 'name': {'key': 'name', 'type': 'str'}, 'display_name': {'key': 'displayName', 'type': 'str'}, 'internal_name': {'key': 'internalName', 'type': 'str'}, 'to_be_exported_for_shoebox': {'key': 'toBeExportedForShoebox', 'type': 'bool'}, } def __init__(self, name=None, display_name=None, internal_name=None, to_be_exported_for_shoebox=None): <|fim_middle|> <|fim▁end|>
super(Dimension, self).__init__() self.name = name self.display_name = display_name self.internal_name = internal_name self.to_be_exported_for_shoebox = to_be_exported_for_shoebox
<|file_name|>dimension.py<|end_file_name|><|fim▁begin|># coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- from msrest.serialization import Model class Dimension(Model): """Dimension of a resource metric. For e.g. instance specific HTTP requests for a web app, where instance name is dimension of the metric HTTP request. :param name: :type name: str :param display_name: :type display_name: str :param internal_name: :type internal_name: str :param to_be_exported_for_shoebox: :type to_be_exported_for_shoebox: bool """ _attribute_map = { 'name': {'key': 'name', 'type': 'str'}, 'display_name': {'key': 'displayName', 'type': 'str'}, 'internal_name': {'key': 'internalName', 'type': 'str'}, 'to_be_exported_for_shoebox': {'key': 'toBeExportedForShoebox', 'type': 'bool'}, } def <|fim_middle|>(self, name=None, display_name=None, internal_name=None, to_be_exported_for_shoebox=None): super(Dimension, self).__init__() self.name = name self.display_name = display_name self.internal_name = internal_name self.to_be_exported_for_shoebox = to_be_exported_for_shoebox <|fim▁end|>
__init__
<|file_name|>artnet-server.py<|end_file_name|><|fim▁begin|>from artnet import * import SocketServer import time, os, random, datetime, sys import argparse import socket import struct from subprocess import Popen, PIPE, STDOUT import glob<|fim▁hole|>DEBUG = False UDP_IP = "2.0.0.61" UDP_PORT = 6454<|fim▁end|>
<|file_name|>liste.py<|end_file_name|><|fim▁begin|># -*-coding:Utf-8 -* # Copyright (c) 2013 LE GOFF Vincent # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this # list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # * Neither the name of the copyright holder nor the names of its contributors # may be used to endorse or promote products derived from this software # without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO Ematelot SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT # OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. """Fichier contenant le paramètre 'liste' de la commande 'matelot'.""" from primaires.format.fonctions import supprimer_accents from primaires.format.tableau import Tableau from primaires.interpreteur.masque.parametre import Parametre<|fim▁hole|>from secondaires.navigation.equipage.postes.hierarchie import ORDRE class PrmListe(Parametre): """Commande 'matelot liste'. """ def __init__(self): """Constructeur du paramètre""" Parametre.__init__(self, "liste", "list") self.tronquer = True self.aide_courte = "liste les matelots de l'équipage" self.aide_longue = \ "Cette commande liste les matelots de votre équipage. " \ "Elle permet d'obtenir rapidement des informations pratiques " \ "sur le nom du matelot ainsi que l'endroit où il se trouve." def interpreter(self, personnage, dic_masques): """Interprétation du paramètre""" salle = personnage.salle if not hasattr(salle, "navire"): personnage << "|err|Vous n'êtes pas sur un navire.|ff|" return navire = salle.navire equipage = navire.equipage if not navire.a_le_droit(personnage, "officier"): personnage << "|err|Vous ne pouvez donner d'ordre sur ce " \ "navire.|ff|" return matelots = tuple((m, m.nom_poste) for m in \ equipage.matelots.values()) matelots += tuple(equipage.joueurs.items()) matelots = sorted(matelots, \ key=lambda couple: ORDRE.index(couple[1]), reverse=True) if len(matelots) == 0: personnage << "|err|Votre équipage ne comprend aucun matelot.|ff|" return tableau = Tableau() tableau.ajouter_colonne("Nom") tableau.ajouter_colonne("Poste") tableau.ajouter_colonne("Affectation") for matelot, nom_poste in matelots: nom = matelot.nom nom_poste = nom_poste.capitalize() titre = "Aucune" if hasattr(matelot, "personnage"): titre = matelot.personnage.salle.titre_court.capitalize() tableau.ajouter_ligne(nom, nom_poste, titre) personnage << tableau.afficher()<|fim▁end|>
<|file_name|>liste.py<|end_file_name|><|fim▁begin|># -*-coding:Utf-8 -* # Copyright (c) 2013 LE GOFF Vincent # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this # list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # * Neither the name of the copyright holder nor the names of its contributors # may be used to endorse or promote products derived from this software # without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO Ematelot SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT # OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. """Fichier contenant le paramètre 'liste' de la commande 'matelot'.""" from primaires.format.fonctions import supprimer_accents from primaires.format.tableau import Tableau from primaires.interpreteur.masque.parametre import Parametre from secondaires.navigation.equipage.postes.hierarchie import ORDRE class PrmListe(Parametre): "<|fim_middle|> <|fim▁end|>
""Commande 'matelot liste'. """ def __init__(self): """Constructeur du paramètre""" Parametre.__init__(self, "liste", "list") self.tronquer = True self.aide_courte = "liste les matelots de l'équipage" self.aide_longue = \ "Cette commande liste les matelots de votre équipage. " \ "Elle permet d'obtenir rapidement des informations pratiques " \ "sur le nom du matelot ainsi que l'endroit où il se trouve." def interpreter(self, personnage, dic_masques): """Interprétation du paramètre""" salle = personnage.salle if not hasattr(salle, "navire"): personnage << "|err|Vous n'êtes pas sur un navire.|ff|" return navire = salle.navire equipage = navire.equipage if not navire.a_le_droit(personnage, "officier"): personnage << "|err|Vous ne pouvez donner d'ordre sur ce " \ "navire.|ff|" return matelots = tuple((m, m.nom_poste) for m in \ equipage.matelots.values()) matelots += tuple(equipage.joueurs.items()) matelots = sorted(matelots, \ key=lambda couple: ORDRE.index(couple[1]), reverse=True) if len(matelots) == 0: personnage << "|err|Votre équipage ne comprend aucun matelot.|ff|" return tableau = Tableau() tableau.ajouter_colonne("Nom") tableau.ajouter_colonne("Poste") tableau.ajouter_colonne("Affectation") for matelot, nom_poste in matelots: nom = matelot.nom nom_poste = nom_poste.capitalize() titre = "Aucune" if hasattr(matelot, "personnage"): titre = matelot.personnage.salle.titre_court.capitalize() tableau.ajouter_ligne(nom, nom_poste, titre) personnage << tableau.afficher()
<|file_name|>liste.py<|end_file_name|><|fim▁begin|># -*-coding:Utf-8 -* # Copyright (c) 2013 LE GOFF Vincent # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this # list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # * Neither the name of the copyright holder nor the names of its contributors # may be used to endorse or promote products derived from this software # without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO Ematelot SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT # OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. """Fichier contenant le paramètre 'liste' de la commande 'matelot'.""" from primaires.format.fonctions import supprimer_accents from primaires.format.tableau import Tableau from primaires.interpreteur.masque.parametre import Parametre from secondaires.navigation.equipage.postes.hierarchie import ORDRE class PrmListe(Parametre): """Commande 'matelot liste'. """ def __init__(self): "<|fim_middle|> def interpreter(self, personnage, dic_masques): """Interprétation du paramètre""" salle = personnage.salle if not hasattr(salle, "navire"): personnage << "|err|Vous n'êtes pas sur un navire.|ff|" return navire = salle.navire equipage = navire.equipage if not navire.a_le_droit(personnage, "officier"): personnage << "|err|Vous ne pouvez donner d'ordre sur ce " \ "navire.|ff|" return matelots = tuple((m, m.nom_poste) for m in \ equipage.matelots.values()) matelots += tuple(equipage.joueurs.items()) matelots = sorted(matelots, \ key=lambda couple: ORDRE.index(couple[1]), reverse=True) if len(matelots) == 0: personnage << "|err|Votre équipage ne comprend aucun matelot.|ff|" return tableau = Tableau() tableau.ajouter_colonne("Nom") tableau.ajouter_colonne("Poste") tableau.ajouter_colonne("Affectation") for matelot, nom_poste in matelots: nom = matelot.nom nom_poste = nom_poste.capitalize() titre = "Aucune" if hasattr(matelot, "personnage"): titre = matelot.personnage.salle.titre_court.capitalize() tableau.ajouter_ligne(nom, nom_poste, titre) personnage << tableau.afficher() <|fim▁end|>
""Constructeur du paramètre""" Parametre.__init__(self, "liste", "list") self.tronquer = True self.aide_courte = "liste les matelots de l'équipage" self.aide_longue = \ "Cette commande liste les matelots de votre équipage. " \ "Elle permet d'obtenir rapidement des informations pratiques " \ "sur le nom du matelot ainsi que l'endroit où il se trouve."
<|file_name|>liste.py<|end_file_name|><|fim▁begin|># -*-coding:Utf-8 -* # Copyright (c) 2013 LE GOFF Vincent # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this # list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # * Neither the name of the copyright holder nor the names of its contributors # may be used to endorse or promote products derived from this software # without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO Ematelot SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT # OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. """Fichier contenant le paramètre 'liste' de la commande 'matelot'.""" from primaires.format.fonctions import supprimer_accents from primaires.format.tableau import Tableau from primaires.interpreteur.masque.parametre import Parametre from secondaires.navigation.equipage.postes.hierarchie import ORDRE class PrmListe(Parametre): """Commande 'matelot liste'. """ def __init__(self): """Constructeur du paramètre""" Parametre.__init__(self, "liste", "list") self.tronquer = True self.aide_courte = "liste les matelots de l'équipage" self.aide_longue = \ "Cette commande liste les matelots de votre équipage. " \ "Elle permet d'obtenir rapidement des informations pratiques " \ "sur le nom du matelot ainsi que l'endroit où il se trouve." def interpreter(self, personnage, dic_masques): """In<|fim_middle|> <|fim▁end|>
terprétation du paramètre""" salle = personnage.salle if not hasattr(salle, "navire"): personnage << "|err|Vous n'êtes pas sur un navire.|ff|" return navire = salle.navire equipage = navire.equipage if not navire.a_le_droit(personnage, "officier"): personnage << "|err|Vous ne pouvez donner d'ordre sur ce " \ "navire.|ff|" return matelots = tuple((m, m.nom_poste) for m in \ equipage.matelots.values()) matelots += tuple(equipage.joueurs.items()) matelots = sorted(matelots, \ key=lambda couple: ORDRE.index(couple[1]), reverse=True) if len(matelots) == 0: personnage << "|err|Votre équipage ne comprend aucun matelot.|ff|" return tableau = Tableau() tableau.ajouter_colonne("Nom") tableau.ajouter_colonne("Poste") tableau.ajouter_colonne("Affectation") for matelot, nom_poste in matelots: nom = matelot.nom nom_poste = nom_poste.capitalize() titre = "Aucune" if hasattr(matelot, "personnage"): titre = matelot.personnage.salle.titre_court.capitalize() tableau.ajouter_ligne(nom, nom_poste, titre) personnage << tableau.afficher()
<|file_name|>liste.py<|end_file_name|><|fim▁begin|># -*-coding:Utf-8 -* # Copyright (c) 2013 LE GOFF Vincent # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this # list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # * Neither the name of the copyright holder nor the names of its contributors # may be used to endorse or promote products derived from this software # without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO Ematelot SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT # OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. """Fichier contenant le paramètre 'liste' de la commande 'matelot'.""" from primaires.format.fonctions import supprimer_accents from primaires.format.tableau import Tableau from primaires.interpreteur.masque.parametre import Parametre from secondaires.navigation.equipage.postes.hierarchie import ORDRE class PrmListe(Parametre): """Commande 'matelot liste'. """ def __init__(self): """Constructeur du paramètre""" Parametre.__init__(self, "liste", "list") self.tronquer = True self.aide_courte = "liste les matelots de l'équipage" self.aide_longue = \ "Cette commande liste les matelots de votre équipage. " \ "Elle permet d'obtenir rapidement des informations pratiques " \ "sur le nom du matelot ainsi que l'endroit où il se trouve." def interpreter(self, personnage, dic_masques): """Interprétation du paramètre""" salle = personnage.salle if not hasattr(salle, "navire"): personn <|fim_middle|> navire = salle.navire equipage = navire.equipage if not navire.a_le_droit(personnage, "officier"): personnage << "|err|Vous ne pouvez donner d'ordre sur ce " \ "navire.|ff|" return matelots = tuple((m, m.nom_poste) for m in \ equipage.matelots.values()) matelots += tuple(equipage.joueurs.items()) matelots = sorted(matelots, \ key=lambda couple: ORDRE.index(couple[1]), reverse=True) if len(matelots) == 0: personnage << "|err|Votre équipage ne comprend aucun matelot.|ff|" return tableau = Tableau() tableau.ajouter_colonne("Nom") tableau.ajouter_colonne("Poste") tableau.ajouter_colonne("Affectation") for matelot, nom_poste in matelots: nom = matelot.nom nom_poste = nom_poste.capitalize() titre = "Aucune" if hasattr(matelot, "personnage"): titre = matelot.personnage.salle.titre_court.capitalize() tableau.ajouter_ligne(nom, nom_poste, titre) personnage << tableau.afficher() <|fim▁end|>
age << "|err|Vous n'êtes pas sur un navire.|ff|" return
<|file_name|>liste.py<|end_file_name|><|fim▁begin|># -*-coding:Utf-8 -* # Copyright (c) 2013 LE GOFF Vincent # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this # list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # * Neither the name of the copyright holder nor the names of its contributors # may be used to endorse or promote products derived from this software # without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO Ematelot SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT # OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. """Fichier contenant le paramètre 'liste' de la commande 'matelot'.""" from primaires.format.fonctions import supprimer_accents from primaires.format.tableau import Tableau from primaires.interpreteur.masque.parametre import Parametre from secondaires.navigation.equipage.postes.hierarchie import ORDRE class PrmListe(Parametre): """Commande 'matelot liste'. """ def __init__(self): """Constructeur du paramètre""" Parametre.__init__(self, "liste", "list") self.tronquer = True self.aide_courte = "liste les matelots de l'équipage" self.aide_longue = \ "Cette commande liste les matelots de votre équipage. " \ "Elle permet d'obtenir rapidement des informations pratiques " \ "sur le nom du matelot ainsi que l'endroit où il se trouve." def interpreter(self, personnage, dic_masques): """Interprétation du paramètre""" salle = personnage.salle if not hasattr(salle, "navire"): personnage << "|err|Vous n'êtes pas sur un navire.|ff|" return navire = salle.navire equipage = navire.equipage if not navire.a_le_droit(personnage, "officier"): personna <|fim_middle|> matelots = tuple((m, m.nom_poste) for m in \ equipage.matelots.values()) matelots += tuple(equipage.joueurs.items()) matelots = sorted(matelots, \ key=lambda couple: ORDRE.index(couple[1]), reverse=True) if len(matelots) == 0: personnage << "|err|Votre équipage ne comprend aucun matelot.|ff|" return tableau = Tableau() tableau.ajouter_colonne("Nom") tableau.ajouter_colonne("Poste") tableau.ajouter_colonne("Affectation") for matelot, nom_poste in matelots: nom = matelot.nom nom_poste = nom_poste.capitalize() titre = "Aucune" if hasattr(matelot, "personnage"): titre = matelot.personnage.salle.titre_court.capitalize() tableau.ajouter_ligne(nom, nom_poste, titre) personnage << tableau.afficher() <|fim▁end|>
ge << "|err|Vous ne pouvez donner d'ordre sur ce " \ "navire.|ff|" return
<|file_name|>liste.py<|end_file_name|><|fim▁begin|># -*-coding:Utf-8 -* # Copyright (c) 2013 LE GOFF Vincent # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this # list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # * Neither the name of the copyright holder nor the names of its contributors # may be used to endorse or promote products derived from this software # without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO Ematelot SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT # OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. """Fichier contenant le paramètre 'liste' de la commande 'matelot'.""" from primaires.format.fonctions import supprimer_accents from primaires.format.tableau import Tableau from primaires.interpreteur.masque.parametre import Parametre from secondaires.navigation.equipage.postes.hierarchie import ORDRE class PrmListe(Parametre): """Commande 'matelot liste'. """ def __init__(self): """Constructeur du paramètre""" Parametre.__init__(self, "liste", "list") self.tronquer = True self.aide_courte = "liste les matelots de l'équipage" self.aide_longue = \ "Cette commande liste les matelots de votre équipage. " \ "Elle permet d'obtenir rapidement des informations pratiques " \ "sur le nom du matelot ainsi que l'endroit où il se trouve." def interpreter(self, personnage, dic_masques): """Interprétation du paramètre""" salle = personnage.salle if not hasattr(salle, "navire"): personnage << "|err|Vous n'êtes pas sur un navire.|ff|" return navire = salle.navire equipage = navire.equipage if not navire.a_le_droit(personnage, "officier"): personnage << "|err|Vous ne pouvez donner d'ordre sur ce " \ "navire.|ff|" return matelots = tuple((m, m.nom_poste) for m in \ equipage.matelots.values()) matelots += tuple(equipage.joueurs.items()) matelots = sorted(matelots, \ key=lambda couple: ORDRE.index(couple[1]), reverse=True) if len(matelots) == 0: personna <|fim_middle|> tableau = Tableau() tableau.ajouter_colonne("Nom") tableau.ajouter_colonne("Poste") tableau.ajouter_colonne("Affectation") for matelot, nom_poste in matelots: nom = matelot.nom nom_poste = nom_poste.capitalize() titre = "Aucune" if hasattr(matelot, "personnage"): titre = matelot.personnage.salle.titre_court.capitalize() tableau.ajouter_ligne(nom, nom_poste, titre) personnage << tableau.afficher() <|fim▁end|>
ge << "|err|Votre équipage ne comprend aucun matelot.|ff|" return
<|file_name|>liste.py<|end_file_name|><|fim▁begin|># -*-coding:Utf-8 -* # Copyright (c) 2013 LE GOFF Vincent # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this # list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # * Neither the name of the copyright holder nor the names of its contributors # may be used to endorse or promote products derived from this software # without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO Ematelot SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT # OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. """Fichier contenant le paramètre 'liste' de la commande 'matelot'.""" from primaires.format.fonctions import supprimer_accents from primaires.format.tableau import Tableau from primaires.interpreteur.masque.parametre import Parametre from secondaires.navigation.equipage.postes.hierarchie import ORDRE class PrmListe(Parametre): """Commande 'matelot liste'. """ def __init__(self): """Constructeur du paramètre""" Parametre.__init__(self, "liste", "list") self.tronquer = True self.aide_courte = "liste les matelots de l'équipage" self.aide_longue = \ "Cette commande liste les matelots de votre équipage. " \ "Elle permet d'obtenir rapidement des informations pratiques " \ "sur le nom du matelot ainsi que l'endroit où il se trouve." def interpreter(self, personnage, dic_masques): """Interprétation du paramètre""" salle = personnage.salle if not hasattr(salle, "navire"): personnage << "|err|Vous n'êtes pas sur un navire.|ff|" return navire = salle.navire equipage = navire.equipage if not navire.a_le_droit(personnage, "officier"): personnage << "|err|Vous ne pouvez donner d'ordre sur ce " \ "navire.|ff|" return matelots = tuple((m, m.nom_poste) for m in \ equipage.matelots.values()) matelots += tuple(equipage.joueurs.items()) matelots = sorted(matelots, \ key=lambda couple: ORDRE.index(couple[1]), reverse=True) if len(matelots) == 0: personnage << "|err|Votre équipage ne comprend aucun matelot.|ff|" return tableau = Tableau() tableau.ajouter_colonne("Nom") tableau.ajouter_colonne("Poste") tableau.ajouter_colonne("Affectation") for matelot, nom_poste in matelots: nom = matelot.nom nom_poste = nom_poste.capitalize() titre = "Aucune" if hasattr(matelot, "personnage"): titre = m <|fim_middle|> tableau.ajouter_ligne(nom, nom_poste, titre) personnage << tableau.afficher() <|fim▁end|>
atelot.personnage.salle.titre_court.capitalize()
<|file_name|>liste.py<|end_file_name|><|fim▁begin|># -*-coding:Utf-8 -* # Copyright (c) 2013 LE GOFF Vincent # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this # list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # * Neither the name of the copyright holder nor the names of its contributors # may be used to endorse or promote products derived from this software # without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO Ematelot SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT # OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. """Fichier contenant le paramètre 'liste' de la commande 'matelot'.""" from primaires.format.fonctions import supprimer_accents from primaires.format.tableau import Tableau from primaires.interpreteur.masque.parametre import Parametre from secondaires.navigation.equipage.postes.hierarchie import ORDRE class PrmListe(Parametre): """Commande 'matelot liste'. """ def _<|fim_middle|>self): """Constructeur du paramètre""" Parametre.__init__(self, "liste", "list") self.tronquer = True self.aide_courte = "liste les matelots de l'équipage" self.aide_longue = \ "Cette commande liste les matelots de votre équipage. " \ "Elle permet d'obtenir rapidement des informations pratiques " \ "sur le nom du matelot ainsi que l'endroit où il se trouve." def interpreter(self, personnage, dic_masques): """Interprétation du paramètre""" salle = personnage.salle if not hasattr(salle, "navire"): personnage << "|err|Vous n'êtes pas sur un navire.|ff|" return navire = salle.navire equipage = navire.equipage if not navire.a_le_droit(personnage, "officier"): personnage << "|err|Vous ne pouvez donner d'ordre sur ce " \ "navire.|ff|" return matelots = tuple((m, m.nom_poste) for m in \ equipage.matelots.values()) matelots += tuple(equipage.joueurs.items()) matelots = sorted(matelots, \ key=lambda couple: ORDRE.index(couple[1]), reverse=True) if len(matelots) == 0: personnage << "|err|Votre équipage ne comprend aucun matelot.|ff|" return tableau = Tableau() tableau.ajouter_colonne("Nom") tableau.ajouter_colonne("Poste") tableau.ajouter_colonne("Affectation") for matelot, nom_poste in matelots: nom = matelot.nom nom_poste = nom_poste.capitalize() titre = "Aucune" if hasattr(matelot, "personnage"): titre = matelot.personnage.salle.titre_court.capitalize() tableau.ajouter_ligne(nom, nom_poste, titre) personnage << tableau.afficher() <|fim▁end|>
_init__(
<|file_name|>liste.py<|end_file_name|><|fim▁begin|># -*-coding:Utf-8 -* # Copyright (c) 2013 LE GOFF Vincent # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this # list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # * Neither the name of the copyright holder nor the names of its contributors # may be used to endorse or promote products derived from this software # without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO Ematelot SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT # OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. """Fichier contenant le paramètre 'liste' de la commande 'matelot'.""" from primaires.format.fonctions import supprimer_accents from primaires.format.tableau import Tableau from primaires.interpreteur.masque.parametre import Parametre from secondaires.navigation.equipage.postes.hierarchie import ORDRE class PrmListe(Parametre): """Commande 'matelot liste'. """ def __init__(self): """Constructeur du paramètre""" Parametre.__init__(self, "liste", "list") self.tronquer = True self.aide_courte = "liste les matelots de l'équipage" self.aide_longue = \ "Cette commande liste les matelots de votre équipage. " \ "Elle permet d'obtenir rapidement des informations pratiques " \ "sur le nom du matelot ainsi que l'endroit où il se trouve." def inter<|fim_middle|>, personnage, dic_masques): """Interprétation du paramètre""" salle = personnage.salle if not hasattr(salle, "navire"): personnage << "|err|Vous n'êtes pas sur un navire.|ff|" return navire = salle.navire equipage = navire.equipage if not navire.a_le_droit(personnage, "officier"): personnage << "|err|Vous ne pouvez donner d'ordre sur ce " \ "navire.|ff|" return matelots = tuple((m, m.nom_poste) for m in \ equipage.matelots.values()) matelots += tuple(equipage.joueurs.items()) matelots = sorted(matelots, \ key=lambda couple: ORDRE.index(couple[1]), reverse=True) if len(matelots) == 0: personnage << "|err|Votre équipage ne comprend aucun matelot.|ff|" return tableau = Tableau() tableau.ajouter_colonne("Nom") tableau.ajouter_colonne("Poste") tableau.ajouter_colonne("Affectation") for matelot, nom_poste in matelots: nom = matelot.nom nom_poste = nom_poste.capitalize() titre = "Aucune" if hasattr(matelot, "personnage"): titre = matelot.personnage.salle.titre_court.capitalize() tableau.ajouter_ligne(nom, nom_poste, titre) personnage << tableau.afficher() <|fim▁end|>
preter(self
<|file_name|>fc_scan.py<|end_file_name|><|fim▁begin|>#! /usr/bin/env python # encoding: utf-8 # WARNING! Do not edit! https://waf.io/book/index.html#_obtaining_the_waf_file import re<|fim▁hole|>from waflib.TaskGen import feature,before_method,after_method,extension from waflib.Configure import conf INC_REGEX="""(?:^|['">]\s*;)\s*(?:|#\s*)INCLUDE\s+(?:\w+_)?[<"'](.+?)(?=["'>])""" USE_REGEX="""(?:^|;)\s*USE(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)""" MOD_REGEX="""(?:^|;)\s*MODULE(?!\s*PROCEDURE)(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)""" re_inc=re.compile(INC_REGEX,re.I) re_use=re.compile(USE_REGEX,re.I) re_mod=re.compile(MOD_REGEX,re.I) class fortran_parser(object): def __init__(self,incpaths): self.seen=[] self.nodes=[] self.names=[] self.incpaths=incpaths def find_deps(self,node): txt=node.read() incs=[] uses=[] mods=[] for line in txt.splitlines(): m=re_inc.search(line) if m: incs.append(m.group(1)) m=re_use.search(line) if m: uses.append(m.group(1)) m=re_mod.search(line) if m: mods.append(m.group(1)) return(incs,uses,mods) def start(self,node): self.waiting=[node] while self.waiting: nd=self.waiting.pop(0) self.iter(nd) def iter(self,node): path=node.abspath() incs,uses,mods=self.find_deps(node) for x in incs: if x in self.seen: continue self.seen.append(x) self.tryfind_header(x) for x in uses: name="USE@%s"%x if not name in self.names: self.names.append(name) for x in mods: name="MOD@%s"%x if not name in self.names: self.names.append(name) def tryfind_header(self,filename): found=None for n in self.incpaths: found=n.find_resource(filename) if found: self.nodes.append(found) self.waiting.append(found) break if not found: if not filename in self.names: self.names.append(filename)<|fim▁end|>
from waflib import Utils,Task,TaskGen,Logs
<|file_name|>fc_scan.py<|end_file_name|><|fim▁begin|>#! /usr/bin/env python # encoding: utf-8 # WARNING! Do not edit! https://waf.io/book/index.html#_obtaining_the_waf_file import re from waflib import Utils,Task,TaskGen,Logs from waflib.TaskGen import feature,before_method,after_method,extension from waflib.Configure import conf INC_REGEX="""(?:^|['">]\s*;)\s*(?:|#\s*)INCLUDE\s+(?:\w+_)?[<"'](.+?)(?=["'>])""" USE_REGEX="""(?:^|;)\s*USE(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)""" MOD_REGEX="""(?:^|;)\s*MODULE(?!\s*PROCEDURE)(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)""" re_inc=re.compile(INC_REGEX,re.I) re_use=re.compile(USE_REGEX,re.I) re_mod=re.compile(MOD_REGEX,re.I) class fortran_parser(object): <|fim_middle|> <|fim▁end|>
def __init__(self,incpaths): self.seen=[] self.nodes=[] self.names=[] self.incpaths=incpaths def find_deps(self,node): txt=node.read() incs=[] uses=[] mods=[] for line in txt.splitlines(): m=re_inc.search(line) if m: incs.append(m.group(1)) m=re_use.search(line) if m: uses.append(m.group(1)) m=re_mod.search(line) if m: mods.append(m.group(1)) return(incs,uses,mods) def start(self,node): self.waiting=[node] while self.waiting: nd=self.waiting.pop(0) self.iter(nd) def iter(self,node): path=node.abspath() incs,uses,mods=self.find_deps(node) for x in incs: if x in self.seen: continue self.seen.append(x) self.tryfind_header(x) for x in uses: name="USE@%s"%x if not name in self.names: self.names.append(name) for x in mods: name="MOD@%s"%x if not name in self.names: self.names.append(name) def tryfind_header(self,filename): found=None for n in self.incpaths: found=n.find_resource(filename) if found: self.nodes.append(found) self.waiting.append(found) break if not found: if not filename in self.names: self.names.append(filename)
<|file_name|>fc_scan.py<|end_file_name|><|fim▁begin|>#! /usr/bin/env python # encoding: utf-8 # WARNING! Do not edit! https://waf.io/book/index.html#_obtaining_the_waf_file import re from waflib import Utils,Task,TaskGen,Logs from waflib.TaskGen import feature,before_method,after_method,extension from waflib.Configure import conf INC_REGEX="""(?:^|['">]\s*;)\s*(?:|#\s*)INCLUDE\s+(?:\w+_)?[<"'](.+?)(?=["'>])""" USE_REGEX="""(?:^|;)\s*USE(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)""" MOD_REGEX="""(?:^|;)\s*MODULE(?!\s*PROCEDURE)(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)""" re_inc=re.compile(INC_REGEX,re.I) re_use=re.compile(USE_REGEX,re.I) re_mod=re.compile(MOD_REGEX,re.I) class fortran_parser(object): def __init__(self,incpaths): <|fim_middle|> def find_deps(self,node): txt=node.read() incs=[] uses=[] mods=[] for line in txt.splitlines(): m=re_inc.search(line) if m: incs.append(m.group(1)) m=re_use.search(line) if m: uses.append(m.group(1)) m=re_mod.search(line) if m: mods.append(m.group(1)) return(incs,uses,mods) def start(self,node): self.waiting=[node] while self.waiting: nd=self.waiting.pop(0) self.iter(nd) def iter(self,node): path=node.abspath() incs,uses,mods=self.find_deps(node) for x in incs: if x in self.seen: continue self.seen.append(x) self.tryfind_header(x) for x in uses: name="USE@%s"%x if not name in self.names: self.names.append(name) for x in mods: name="MOD@%s"%x if not name in self.names: self.names.append(name) def tryfind_header(self,filename): found=None for n in self.incpaths: found=n.find_resource(filename) if found: self.nodes.append(found) self.waiting.append(found) break if not found: if not filename in self.names: self.names.append(filename) <|fim▁end|>
self.seen=[] self.nodes=[] self.names=[] self.incpaths=incpaths
<|file_name|>fc_scan.py<|end_file_name|><|fim▁begin|>#! /usr/bin/env python # encoding: utf-8 # WARNING! Do not edit! https://waf.io/book/index.html#_obtaining_the_waf_file import re from waflib import Utils,Task,TaskGen,Logs from waflib.TaskGen import feature,before_method,after_method,extension from waflib.Configure import conf INC_REGEX="""(?:^|['">]\s*;)\s*(?:|#\s*)INCLUDE\s+(?:\w+_)?[<"'](.+?)(?=["'>])""" USE_REGEX="""(?:^|;)\s*USE(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)""" MOD_REGEX="""(?:^|;)\s*MODULE(?!\s*PROCEDURE)(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)""" re_inc=re.compile(INC_REGEX,re.I) re_use=re.compile(USE_REGEX,re.I) re_mod=re.compile(MOD_REGEX,re.I) class fortran_parser(object): def __init__(self,incpaths): self.seen=[] self.nodes=[] self.names=[] self.incpaths=incpaths def find_deps(self,node): <|fim_middle|> def start(self,node): self.waiting=[node] while self.waiting: nd=self.waiting.pop(0) self.iter(nd) def iter(self,node): path=node.abspath() incs,uses,mods=self.find_deps(node) for x in incs: if x in self.seen: continue self.seen.append(x) self.tryfind_header(x) for x in uses: name="USE@%s"%x if not name in self.names: self.names.append(name) for x in mods: name="MOD@%s"%x if not name in self.names: self.names.append(name) def tryfind_header(self,filename): found=None for n in self.incpaths: found=n.find_resource(filename) if found: self.nodes.append(found) self.waiting.append(found) break if not found: if not filename in self.names: self.names.append(filename) <|fim▁end|>
txt=node.read() incs=[] uses=[] mods=[] for line in txt.splitlines(): m=re_inc.search(line) if m: incs.append(m.group(1)) m=re_use.search(line) if m: uses.append(m.group(1)) m=re_mod.search(line) if m: mods.append(m.group(1)) return(incs,uses,mods)
<|file_name|>fc_scan.py<|end_file_name|><|fim▁begin|>#! /usr/bin/env python # encoding: utf-8 # WARNING! Do not edit! https://waf.io/book/index.html#_obtaining_the_waf_file import re from waflib import Utils,Task,TaskGen,Logs from waflib.TaskGen import feature,before_method,after_method,extension from waflib.Configure import conf INC_REGEX="""(?:^|['">]\s*;)\s*(?:|#\s*)INCLUDE\s+(?:\w+_)?[<"'](.+?)(?=["'>])""" USE_REGEX="""(?:^|;)\s*USE(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)""" MOD_REGEX="""(?:^|;)\s*MODULE(?!\s*PROCEDURE)(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)""" re_inc=re.compile(INC_REGEX,re.I) re_use=re.compile(USE_REGEX,re.I) re_mod=re.compile(MOD_REGEX,re.I) class fortran_parser(object): def __init__(self,incpaths): self.seen=[] self.nodes=[] self.names=[] self.incpaths=incpaths def find_deps(self,node): txt=node.read() incs=[] uses=[] mods=[] for line in txt.splitlines(): m=re_inc.search(line) if m: incs.append(m.group(1)) m=re_use.search(line) if m: uses.append(m.group(1)) m=re_mod.search(line) if m: mods.append(m.group(1)) return(incs,uses,mods) def start(self,node): <|fim_middle|> def iter(self,node): path=node.abspath() incs,uses,mods=self.find_deps(node) for x in incs: if x in self.seen: continue self.seen.append(x) self.tryfind_header(x) for x in uses: name="USE@%s"%x if not name in self.names: self.names.append(name) for x in mods: name="MOD@%s"%x if not name in self.names: self.names.append(name) def tryfind_header(self,filename): found=None for n in self.incpaths: found=n.find_resource(filename) if found: self.nodes.append(found) self.waiting.append(found) break if not found: if not filename in self.names: self.names.append(filename) <|fim▁end|>
self.waiting=[node] while self.waiting: nd=self.waiting.pop(0) self.iter(nd)
<|file_name|>fc_scan.py<|end_file_name|><|fim▁begin|>#! /usr/bin/env python # encoding: utf-8 # WARNING! Do not edit! https://waf.io/book/index.html#_obtaining_the_waf_file import re from waflib import Utils,Task,TaskGen,Logs from waflib.TaskGen import feature,before_method,after_method,extension from waflib.Configure import conf INC_REGEX="""(?:^|['">]\s*;)\s*(?:|#\s*)INCLUDE\s+(?:\w+_)?[<"'](.+?)(?=["'>])""" USE_REGEX="""(?:^|;)\s*USE(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)""" MOD_REGEX="""(?:^|;)\s*MODULE(?!\s*PROCEDURE)(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)""" re_inc=re.compile(INC_REGEX,re.I) re_use=re.compile(USE_REGEX,re.I) re_mod=re.compile(MOD_REGEX,re.I) class fortran_parser(object): def __init__(self,incpaths): self.seen=[] self.nodes=[] self.names=[] self.incpaths=incpaths def find_deps(self,node): txt=node.read() incs=[] uses=[] mods=[] for line in txt.splitlines(): m=re_inc.search(line) if m: incs.append(m.group(1)) m=re_use.search(line) if m: uses.append(m.group(1)) m=re_mod.search(line) if m: mods.append(m.group(1)) return(incs,uses,mods) def start(self,node): self.waiting=[node] while self.waiting: nd=self.waiting.pop(0) self.iter(nd) def iter(self,node): <|fim_middle|> def tryfind_header(self,filename): found=None for n in self.incpaths: found=n.find_resource(filename) if found: self.nodes.append(found) self.waiting.append(found) break if not found: if not filename in self.names: self.names.append(filename) <|fim▁end|>
path=node.abspath() incs,uses,mods=self.find_deps(node) for x in incs: if x in self.seen: continue self.seen.append(x) self.tryfind_header(x) for x in uses: name="USE@%s"%x if not name in self.names: self.names.append(name) for x in mods: name="MOD@%s"%x if not name in self.names: self.names.append(name)
<|file_name|>fc_scan.py<|end_file_name|><|fim▁begin|>#! /usr/bin/env python # encoding: utf-8 # WARNING! Do not edit! https://waf.io/book/index.html#_obtaining_the_waf_file import re from waflib import Utils,Task,TaskGen,Logs from waflib.TaskGen import feature,before_method,after_method,extension from waflib.Configure import conf INC_REGEX="""(?:^|['">]\s*;)\s*(?:|#\s*)INCLUDE\s+(?:\w+_)?[<"'](.+?)(?=["'>])""" USE_REGEX="""(?:^|;)\s*USE(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)""" MOD_REGEX="""(?:^|;)\s*MODULE(?!\s*PROCEDURE)(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)""" re_inc=re.compile(INC_REGEX,re.I) re_use=re.compile(USE_REGEX,re.I) re_mod=re.compile(MOD_REGEX,re.I) class fortran_parser(object): def __init__(self,incpaths): self.seen=[] self.nodes=[] self.names=[] self.incpaths=incpaths def find_deps(self,node): txt=node.read() incs=[] uses=[] mods=[] for line in txt.splitlines(): m=re_inc.search(line) if m: incs.append(m.group(1)) m=re_use.search(line) if m: uses.append(m.group(1)) m=re_mod.search(line) if m: mods.append(m.group(1)) return(incs,uses,mods) def start(self,node): self.waiting=[node] while self.waiting: nd=self.waiting.pop(0) self.iter(nd) def iter(self,node): path=node.abspath() incs,uses,mods=self.find_deps(node) for x in incs: if x in self.seen: continue self.seen.append(x) self.tryfind_header(x) for x in uses: name="USE@%s"%x if not name in self.names: self.names.append(name) for x in mods: name="MOD@%s"%x if not name in self.names: self.names.append(name) def tryfind_header(self,filename): <|fim_middle|> <|fim▁end|>
found=None for n in self.incpaths: found=n.find_resource(filename) if found: self.nodes.append(found) self.waiting.append(found) break if not found: if not filename in self.names: self.names.append(filename)
<|file_name|>fc_scan.py<|end_file_name|><|fim▁begin|>#! /usr/bin/env python # encoding: utf-8 # WARNING! Do not edit! https://waf.io/book/index.html#_obtaining_the_waf_file import re from waflib import Utils,Task,TaskGen,Logs from waflib.TaskGen import feature,before_method,after_method,extension from waflib.Configure import conf INC_REGEX="""(?:^|['">]\s*;)\s*(?:|#\s*)INCLUDE\s+(?:\w+_)?[<"'](.+?)(?=["'>])""" USE_REGEX="""(?:^|;)\s*USE(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)""" MOD_REGEX="""(?:^|;)\s*MODULE(?!\s*PROCEDURE)(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)""" re_inc=re.compile(INC_REGEX,re.I) re_use=re.compile(USE_REGEX,re.I) re_mod=re.compile(MOD_REGEX,re.I) class fortran_parser(object): def __init__(self,incpaths): self.seen=[] self.nodes=[] self.names=[] self.incpaths=incpaths def find_deps(self,node): txt=node.read() incs=[] uses=[] mods=[] for line in txt.splitlines(): m=re_inc.search(line) if m: <|fim_middle|> m=re_use.search(line) if m: uses.append(m.group(1)) m=re_mod.search(line) if m: mods.append(m.group(1)) return(incs,uses,mods) def start(self,node): self.waiting=[node] while self.waiting: nd=self.waiting.pop(0) self.iter(nd) def iter(self,node): path=node.abspath() incs,uses,mods=self.find_deps(node) for x in incs: if x in self.seen: continue self.seen.append(x) self.tryfind_header(x) for x in uses: name="USE@%s"%x if not name in self.names: self.names.append(name) for x in mods: name="MOD@%s"%x if not name in self.names: self.names.append(name) def tryfind_header(self,filename): found=None for n in self.incpaths: found=n.find_resource(filename) if found: self.nodes.append(found) self.waiting.append(found) break if not found: if not filename in self.names: self.names.append(filename) <|fim▁end|>
incs.append(m.group(1))
<|file_name|>fc_scan.py<|end_file_name|><|fim▁begin|>#! /usr/bin/env python # encoding: utf-8 # WARNING! Do not edit! https://waf.io/book/index.html#_obtaining_the_waf_file import re from waflib import Utils,Task,TaskGen,Logs from waflib.TaskGen import feature,before_method,after_method,extension from waflib.Configure import conf INC_REGEX="""(?:^|['">]\s*;)\s*(?:|#\s*)INCLUDE\s+(?:\w+_)?[<"'](.+?)(?=["'>])""" USE_REGEX="""(?:^|;)\s*USE(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)""" MOD_REGEX="""(?:^|;)\s*MODULE(?!\s*PROCEDURE)(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)""" re_inc=re.compile(INC_REGEX,re.I) re_use=re.compile(USE_REGEX,re.I) re_mod=re.compile(MOD_REGEX,re.I) class fortran_parser(object): def __init__(self,incpaths): self.seen=[] self.nodes=[] self.names=[] self.incpaths=incpaths def find_deps(self,node): txt=node.read() incs=[] uses=[] mods=[] for line in txt.splitlines(): m=re_inc.search(line) if m: incs.append(m.group(1)) m=re_use.search(line) if m: <|fim_middle|> m=re_mod.search(line) if m: mods.append(m.group(1)) return(incs,uses,mods) def start(self,node): self.waiting=[node] while self.waiting: nd=self.waiting.pop(0) self.iter(nd) def iter(self,node): path=node.abspath() incs,uses,mods=self.find_deps(node) for x in incs: if x in self.seen: continue self.seen.append(x) self.tryfind_header(x) for x in uses: name="USE@%s"%x if not name in self.names: self.names.append(name) for x in mods: name="MOD@%s"%x if not name in self.names: self.names.append(name) def tryfind_header(self,filename): found=None for n in self.incpaths: found=n.find_resource(filename) if found: self.nodes.append(found) self.waiting.append(found) break if not found: if not filename in self.names: self.names.append(filename) <|fim▁end|>
uses.append(m.group(1))
<|file_name|>fc_scan.py<|end_file_name|><|fim▁begin|>#! /usr/bin/env python # encoding: utf-8 # WARNING! Do not edit! https://waf.io/book/index.html#_obtaining_the_waf_file import re from waflib import Utils,Task,TaskGen,Logs from waflib.TaskGen import feature,before_method,after_method,extension from waflib.Configure import conf INC_REGEX="""(?:^|['">]\s*;)\s*(?:|#\s*)INCLUDE\s+(?:\w+_)?[<"'](.+?)(?=["'>])""" USE_REGEX="""(?:^|;)\s*USE(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)""" MOD_REGEX="""(?:^|;)\s*MODULE(?!\s*PROCEDURE)(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)""" re_inc=re.compile(INC_REGEX,re.I) re_use=re.compile(USE_REGEX,re.I) re_mod=re.compile(MOD_REGEX,re.I) class fortran_parser(object): def __init__(self,incpaths): self.seen=[] self.nodes=[] self.names=[] self.incpaths=incpaths def find_deps(self,node): txt=node.read() incs=[] uses=[] mods=[] for line in txt.splitlines(): m=re_inc.search(line) if m: incs.append(m.group(1)) m=re_use.search(line) if m: uses.append(m.group(1)) m=re_mod.search(line) if m: <|fim_middle|> return(incs,uses,mods) def start(self,node): self.waiting=[node] while self.waiting: nd=self.waiting.pop(0) self.iter(nd) def iter(self,node): path=node.abspath() incs,uses,mods=self.find_deps(node) for x in incs: if x in self.seen: continue self.seen.append(x) self.tryfind_header(x) for x in uses: name="USE@%s"%x if not name in self.names: self.names.append(name) for x in mods: name="MOD@%s"%x if not name in self.names: self.names.append(name) def tryfind_header(self,filename): found=None for n in self.incpaths: found=n.find_resource(filename) if found: self.nodes.append(found) self.waiting.append(found) break if not found: if not filename in self.names: self.names.append(filename) <|fim▁end|>
mods.append(m.group(1))
<|file_name|>fc_scan.py<|end_file_name|><|fim▁begin|>#! /usr/bin/env python # encoding: utf-8 # WARNING! Do not edit! https://waf.io/book/index.html#_obtaining_the_waf_file import re from waflib import Utils,Task,TaskGen,Logs from waflib.TaskGen import feature,before_method,after_method,extension from waflib.Configure import conf INC_REGEX="""(?:^|['">]\s*;)\s*(?:|#\s*)INCLUDE\s+(?:\w+_)?[<"'](.+?)(?=["'>])""" USE_REGEX="""(?:^|;)\s*USE(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)""" MOD_REGEX="""(?:^|;)\s*MODULE(?!\s*PROCEDURE)(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)""" re_inc=re.compile(INC_REGEX,re.I) re_use=re.compile(USE_REGEX,re.I) re_mod=re.compile(MOD_REGEX,re.I) class fortran_parser(object): def __init__(self,incpaths): self.seen=[] self.nodes=[] self.names=[] self.incpaths=incpaths def find_deps(self,node): txt=node.read() incs=[] uses=[] mods=[] for line in txt.splitlines(): m=re_inc.search(line) if m: incs.append(m.group(1)) m=re_use.search(line) if m: uses.append(m.group(1)) m=re_mod.search(line) if m: mods.append(m.group(1)) return(incs,uses,mods) def start(self,node): self.waiting=[node] while self.waiting: nd=self.waiting.pop(0) self.iter(nd) def iter(self,node): path=node.abspath() incs,uses,mods=self.find_deps(node) for x in incs: if x in self.seen: <|fim_middle|> self.seen.append(x) self.tryfind_header(x) for x in uses: name="USE@%s"%x if not name in self.names: self.names.append(name) for x in mods: name="MOD@%s"%x if not name in self.names: self.names.append(name) def tryfind_header(self,filename): found=None for n in self.incpaths: found=n.find_resource(filename) if found: self.nodes.append(found) self.waiting.append(found) break if not found: if not filename in self.names: self.names.append(filename) <|fim▁end|>
continue
<|file_name|>fc_scan.py<|end_file_name|><|fim▁begin|>#! /usr/bin/env python # encoding: utf-8 # WARNING! Do not edit! https://waf.io/book/index.html#_obtaining_the_waf_file import re from waflib import Utils,Task,TaskGen,Logs from waflib.TaskGen import feature,before_method,after_method,extension from waflib.Configure import conf INC_REGEX="""(?:^|['">]\s*;)\s*(?:|#\s*)INCLUDE\s+(?:\w+_)?[<"'](.+?)(?=["'>])""" USE_REGEX="""(?:^|;)\s*USE(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)""" MOD_REGEX="""(?:^|;)\s*MODULE(?!\s*PROCEDURE)(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)""" re_inc=re.compile(INC_REGEX,re.I) re_use=re.compile(USE_REGEX,re.I) re_mod=re.compile(MOD_REGEX,re.I) class fortran_parser(object): def __init__(self,incpaths): self.seen=[] self.nodes=[] self.names=[] self.incpaths=incpaths def find_deps(self,node): txt=node.read() incs=[] uses=[] mods=[] for line in txt.splitlines(): m=re_inc.search(line) if m: incs.append(m.group(1)) m=re_use.search(line) if m: uses.append(m.group(1)) m=re_mod.search(line) if m: mods.append(m.group(1)) return(incs,uses,mods) def start(self,node): self.waiting=[node] while self.waiting: nd=self.waiting.pop(0) self.iter(nd) def iter(self,node): path=node.abspath() incs,uses,mods=self.find_deps(node) for x in incs: if x in self.seen: continue self.seen.append(x) self.tryfind_header(x) for x in uses: name="USE@%s"%x if not name in self.names: <|fim_middle|> for x in mods: name="MOD@%s"%x if not name in self.names: self.names.append(name) def tryfind_header(self,filename): found=None for n in self.incpaths: found=n.find_resource(filename) if found: self.nodes.append(found) self.waiting.append(found) break if not found: if not filename in self.names: self.names.append(filename) <|fim▁end|>
self.names.append(name)
<|file_name|>fc_scan.py<|end_file_name|><|fim▁begin|>#! /usr/bin/env python # encoding: utf-8 # WARNING! Do not edit! https://waf.io/book/index.html#_obtaining_the_waf_file import re from waflib import Utils,Task,TaskGen,Logs from waflib.TaskGen import feature,before_method,after_method,extension from waflib.Configure import conf INC_REGEX="""(?:^|['">]\s*;)\s*(?:|#\s*)INCLUDE\s+(?:\w+_)?[<"'](.+?)(?=["'>])""" USE_REGEX="""(?:^|;)\s*USE(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)""" MOD_REGEX="""(?:^|;)\s*MODULE(?!\s*PROCEDURE)(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)""" re_inc=re.compile(INC_REGEX,re.I) re_use=re.compile(USE_REGEX,re.I) re_mod=re.compile(MOD_REGEX,re.I) class fortran_parser(object): def __init__(self,incpaths): self.seen=[] self.nodes=[] self.names=[] self.incpaths=incpaths def find_deps(self,node): txt=node.read() incs=[] uses=[] mods=[] for line in txt.splitlines(): m=re_inc.search(line) if m: incs.append(m.group(1)) m=re_use.search(line) if m: uses.append(m.group(1)) m=re_mod.search(line) if m: mods.append(m.group(1)) return(incs,uses,mods) def start(self,node): self.waiting=[node] while self.waiting: nd=self.waiting.pop(0) self.iter(nd) def iter(self,node): path=node.abspath() incs,uses,mods=self.find_deps(node) for x in incs: if x in self.seen: continue self.seen.append(x) self.tryfind_header(x) for x in uses: name="USE@%s"%x if not name in self.names: self.names.append(name) for x in mods: name="MOD@%s"%x if not name in self.names: <|fim_middle|> def tryfind_header(self,filename): found=None for n in self.incpaths: found=n.find_resource(filename) if found: self.nodes.append(found) self.waiting.append(found) break if not found: if not filename in self.names: self.names.append(filename) <|fim▁end|>
self.names.append(name)
<|file_name|>fc_scan.py<|end_file_name|><|fim▁begin|>#! /usr/bin/env python # encoding: utf-8 # WARNING! Do not edit! https://waf.io/book/index.html#_obtaining_the_waf_file import re from waflib import Utils,Task,TaskGen,Logs from waflib.TaskGen import feature,before_method,after_method,extension from waflib.Configure import conf INC_REGEX="""(?:^|['">]\s*;)\s*(?:|#\s*)INCLUDE\s+(?:\w+_)?[<"'](.+?)(?=["'>])""" USE_REGEX="""(?:^|;)\s*USE(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)""" MOD_REGEX="""(?:^|;)\s*MODULE(?!\s*PROCEDURE)(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)""" re_inc=re.compile(INC_REGEX,re.I) re_use=re.compile(USE_REGEX,re.I) re_mod=re.compile(MOD_REGEX,re.I) class fortran_parser(object): def __init__(self,incpaths): self.seen=[] self.nodes=[] self.names=[] self.incpaths=incpaths def find_deps(self,node): txt=node.read() incs=[] uses=[] mods=[] for line in txt.splitlines(): m=re_inc.search(line) if m: incs.append(m.group(1)) m=re_use.search(line) if m: uses.append(m.group(1)) m=re_mod.search(line) if m: mods.append(m.group(1)) return(incs,uses,mods) def start(self,node): self.waiting=[node] while self.waiting: nd=self.waiting.pop(0) self.iter(nd) def iter(self,node): path=node.abspath() incs,uses,mods=self.find_deps(node) for x in incs: if x in self.seen: continue self.seen.append(x) self.tryfind_header(x) for x in uses: name="USE@%s"%x if not name in self.names: self.names.append(name) for x in mods: name="MOD@%s"%x if not name in self.names: self.names.append(name) def tryfind_header(self,filename): found=None for n in self.incpaths: found=n.find_resource(filename) if found: <|fim_middle|> if not found: if not filename in self.names: self.names.append(filename) <|fim▁end|>
self.nodes.append(found) self.waiting.append(found) break
<|file_name|>fc_scan.py<|end_file_name|><|fim▁begin|>#! /usr/bin/env python # encoding: utf-8 # WARNING! Do not edit! https://waf.io/book/index.html#_obtaining_the_waf_file import re from waflib import Utils,Task,TaskGen,Logs from waflib.TaskGen import feature,before_method,after_method,extension from waflib.Configure import conf INC_REGEX="""(?:^|['">]\s*;)\s*(?:|#\s*)INCLUDE\s+(?:\w+_)?[<"'](.+?)(?=["'>])""" USE_REGEX="""(?:^|;)\s*USE(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)""" MOD_REGEX="""(?:^|;)\s*MODULE(?!\s*PROCEDURE)(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)""" re_inc=re.compile(INC_REGEX,re.I) re_use=re.compile(USE_REGEX,re.I) re_mod=re.compile(MOD_REGEX,re.I) class fortran_parser(object): def __init__(self,incpaths): self.seen=[] self.nodes=[] self.names=[] self.incpaths=incpaths def find_deps(self,node): txt=node.read() incs=[] uses=[] mods=[] for line in txt.splitlines(): m=re_inc.search(line) if m: incs.append(m.group(1)) m=re_use.search(line) if m: uses.append(m.group(1)) m=re_mod.search(line) if m: mods.append(m.group(1)) return(incs,uses,mods) def start(self,node): self.waiting=[node] while self.waiting: nd=self.waiting.pop(0) self.iter(nd) def iter(self,node): path=node.abspath() incs,uses,mods=self.find_deps(node) for x in incs: if x in self.seen: continue self.seen.append(x) self.tryfind_header(x) for x in uses: name="USE@%s"%x if not name in self.names: self.names.append(name) for x in mods: name="MOD@%s"%x if not name in self.names: self.names.append(name) def tryfind_header(self,filename): found=None for n in self.incpaths: found=n.find_resource(filename) if found: self.nodes.append(found) self.waiting.append(found) break if not found: <|fim_middle|> <|fim▁end|>
if not filename in self.names: self.names.append(filename)
<|file_name|>fc_scan.py<|end_file_name|><|fim▁begin|>#! /usr/bin/env python # encoding: utf-8 # WARNING! Do not edit! https://waf.io/book/index.html#_obtaining_the_waf_file import re from waflib import Utils,Task,TaskGen,Logs from waflib.TaskGen import feature,before_method,after_method,extension from waflib.Configure import conf INC_REGEX="""(?:^|['">]\s*;)\s*(?:|#\s*)INCLUDE\s+(?:\w+_)?[<"'](.+?)(?=["'>])""" USE_REGEX="""(?:^|;)\s*USE(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)""" MOD_REGEX="""(?:^|;)\s*MODULE(?!\s*PROCEDURE)(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)""" re_inc=re.compile(INC_REGEX,re.I) re_use=re.compile(USE_REGEX,re.I) re_mod=re.compile(MOD_REGEX,re.I) class fortran_parser(object): def __init__(self,incpaths): self.seen=[] self.nodes=[] self.names=[] self.incpaths=incpaths def find_deps(self,node): txt=node.read() incs=[] uses=[] mods=[] for line in txt.splitlines(): m=re_inc.search(line) if m: incs.append(m.group(1)) m=re_use.search(line) if m: uses.append(m.group(1)) m=re_mod.search(line) if m: mods.append(m.group(1)) return(incs,uses,mods) def start(self,node): self.waiting=[node] while self.waiting: nd=self.waiting.pop(0) self.iter(nd) def iter(self,node): path=node.abspath() incs,uses,mods=self.find_deps(node) for x in incs: if x in self.seen: continue self.seen.append(x) self.tryfind_header(x) for x in uses: name="USE@%s"%x if not name in self.names: self.names.append(name) for x in mods: name="MOD@%s"%x if not name in self.names: self.names.append(name) def tryfind_header(self,filename): found=None for n in self.incpaths: found=n.find_resource(filename) if found: self.nodes.append(found) self.waiting.append(found) break if not found: if not filename in self.names: <|fim_middle|> <|fim▁end|>
self.names.append(filename)
<|file_name|>fc_scan.py<|end_file_name|><|fim▁begin|>#! /usr/bin/env python # encoding: utf-8 # WARNING! Do not edit! https://waf.io/book/index.html#_obtaining_the_waf_file import re from waflib import Utils,Task,TaskGen,Logs from waflib.TaskGen import feature,before_method,after_method,extension from waflib.Configure import conf INC_REGEX="""(?:^|['">]\s*;)\s*(?:|#\s*)INCLUDE\s+(?:\w+_)?[<"'](.+?)(?=["'>])""" USE_REGEX="""(?:^|;)\s*USE(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)""" MOD_REGEX="""(?:^|;)\s*MODULE(?!\s*PROCEDURE)(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)""" re_inc=re.compile(INC_REGEX,re.I) re_use=re.compile(USE_REGEX,re.I) re_mod=re.compile(MOD_REGEX,re.I) class fortran_parser(object): def <|fim_middle|>(self,incpaths): self.seen=[] self.nodes=[] self.names=[] self.incpaths=incpaths def find_deps(self,node): txt=node.read() incs=[] uses=[] mods=[] for line in txt.splitlines(): m=re_inc.search(line) if m: incs.append(m.group(1)) m=re_use.search(line) if m: uses.append(m.group(1)) m=re_mod.search(line) if m: mods.append(m.group(1)) return(incs,uses,mods) def start(self,node): self.waiting=[node] while self.waiting: nd=self.waiting.pop(0) self.iter(nd) def iter(self,node): path=node.abspath() incs,uses,mods=self.find_deps(node) for x in incs: if x in self.seen: continue self.seen.append(x) self.tryfind_header(x) for x in uses: name="USE@%s"%x if not name in self.names: self.names.append(name) for x in mods: name="MOD@%s"%x if not name in self.names: self.names.append(name) def tryfind_header(self,filename): found=None for n in self.incpaths: found=n.find_resource(filename) if found: self.nodes.append(found) self.waiting.append(found) break if not found: if not filename in self.names: self.names.append(filename) <|fim▁end|>
__init__
<|file_name|>fc_scan.py<|end_file_name|><|fim▁begin|>#! /usr/bin/env python # encoding: utf-8 # WARNING! Do not edit! https://waf.io/book/index.html#_obtaining_the_waf_file import re from waflib import Utils,Task,TaskGen,Logs from waflib.TaskGen import feature,before_method,after_method,extension from waflib.Configure import conf INC_REGEX="""(?:^|['">]\s*;)\s*(?:|#\s*)INCLUDE\s+(?:\w+_)?[<"'](.+?)(?=["'>])""" USE_REGEX="""(?:^|;)\s*USE(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)""" MOD_REGEX="""(?:^|;)\s*MODULE(?!\s*PROCEDURE)(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)""" re_inc=re.compile(INC_REGEX,re.I) re_use=re.compile(USE_REGEX,re.I) re_mod=re.compile(MOD_REGEX,re.I) class fortran_parser(object): def __init__(self,incpaths): self.seen=[] self.nodes=[] self.names=[] self.incpaths=incpaths def <|fim_middle|>(self,node): txt=node.read() incs=[] uses=[] mods=[] for line in txt.splitlines(): m=re_inc.search(line) if m: incs.append(m.group(1)) m=re_use.search(line) if m: uses.append(m.group(1)) m=re_mod.search(line) if m: mods.append(m.group(1)) return(incs,uses,mods) def start(self,node): self.waiting=[node] while self.waiting: nd=self.waiting.pop(0) self.iter(nd) def iter(self,node): path=node.abspath() incs,uses,mods=self.find_deps(node) for x in incs: if x in self.seen: continue self.seen.append(x) self.tryfind_header(x) for x in uses: name="USE@%s"%x if not name in self.names: self.names.append(name) for x in mods: name="MOD@%s"%x if not name in self.names: self.names.append(name) def tryfind_header(self,filename): found=None for n in self.incpaths: found=n.find_resource(filename) if found: self.nodes.append(found) self.waiting.append(found) break if not found: if not filename in self.names: self.names.append(filename) <|fim▁end|>
find_deps
<|file_name|>fc_scan.py<|end_file_name|><|fim▁begin|>#! /usr/bin/env python # encoding: utf-8 # WARNING! Do not edit! https://waf.io/book/index.html#_obtaining_the_waf_file import re from waflib import Utils,Task,TaskGen,Logs from waflib.TaskGen import feature,before_method,after_method,extension from waflib.Configure import conf INC_REGEX="""(?:^|['">]\s*;)\s*(?:|#\s*)INCLUDE\s+(?:\w+_)?[<"'](.+?)(?=["'>])""" USE_REGEX="""(?:^|;)\s*USE(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)""" MOD_REGEX="""(?:^|;)\s*MODULE(?!\s*PROCEDURE)(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)""" re_inc=re.compile(INC_REGEX,re.I) re_use=re.compile(USE_REGEX,re.I) re_mod=re.compile(MOD_REGEX,re.I) class fortran_parser(object): def __init__(self,incpaths): self.seen=[] self.nodes=[] self.names=[] self.incpaths=incpaths def find_deps(self,node): txt=node.read() incs=[] uses=[] mods=[] for line in txt.splitlines(): m=re_inc.search(line) if m: incs.append(m.group(1)) m=re_use.search(line) if m: uses.append(m.group(1)) m=re_mod.search(line) if m: mods.append(m.group(1)) return(incs,uses,mods) def <|fim_middle|>(self,node): self.waiting=[node] while self.waiting: nd=self.waiting.pop(0) self.iter(nd) def iter(self,node): path=node.abspath() incs,uses,mods=self.find_deps(node) for x in incs: if x in self.seen: continue self.seen.append(x) self.tryfind_header(x) for x in uses: name="USE@%s"%x if not name in self.names: self.names.append(name) for x in mods: name="MOD@%s"%x if not name in self.names: self.names.append(name) def tryfind_header(self,filename): found=None for n in self.incpaths: found=n.find_resource(filename) if found: self.nodes.append(found) self.waiting.append(found) break if not found: if not filename in self.names: self.names.append(filename) <|fim▁end|>
start
<|file_name|>fc_scan.py<|end_file_name|><|fim▁begin|>#! /usr/bin/env python # encoding: utf-8 # WARNING! Do not edit! https://waf.io/book/index.html#_obtaining_the_waf_file import re from waflib import Utils,Task,TaskGen,Logs from waflib.TaskGen import feature,before_method,after_method,extension from waflib.Configure import conf INC_REGEX="""(?:^|['">]\s*;)\s*(?:|#\s*)INCLUDE\s+(?:\w+_)?[<"'](.+?)(?=["'>])""" USE_REGEX="""(?:^|;)\s*USE(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)""" MOD_REGEX="""(?:^|;)\s*MODULE(?!\s*PROCEDURE)(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)""" re_inc=re.compile(INC_REGEX,re.I) re_use=re.compile(USE_REGEX,re.I) re_mod=re.compile(MOD_REGEX,re.I) class fortran_parser(object): def __init__(self,incpaths): self.seen=[] self.nodes=[] self.names=[] self.incpaths=incpaths def find_deps(self,node): txt=node.read() incs=[] uses=[] mods=[] for line in txt.splitlines(): m=re_inc.search(line) if m: incs.append(m.group(1)) m=re_use.search(line) if m: uses.append(m.group(1)) m=re_mod.search(line) if m: mods.append(m.group(1)) return(incs,uses,mods) def start(self,node): self.waiting=[node] while self.waiting: nd=self.waiting.pop(0) self.iter(nd) def <|fim_middle|>(self,node): path=node.abspath() incs,uses,mods=self.find_deps(node) for x in incs: if x in self.seen: continue self.seen.append(x) self.tryfind_header(x) for x in uses: name="USE@%s"%x if not name in self.names: self.names.append(name) for x in mods: name="MOD@%s"%x if not name in self.names: self.names.append(name) def tryfind_header(self,filename): found=None for n in self.incpaths: found=n.find_resource(filename) if found: self.nodes.append(found) self.waiting.append(found) break if not found: if not filename in self.names: self.names.append(filename) <|fim▁end|>
iter
<|file_name|>fc_scan.py<|end_file_name|><|fim▁begin|>#! /usr/bin/env python # encoding: utf-8 # WARNING! Do not edit! https://waf.io/book/index.html#_obtaining_the_waf_file import re from waflib import Utils,Task,TaskGen,Logs from waflib.TaskGen import feature,before_method,after_method,extension from waflib.Configure import conf INC_REGEX="""(?:^|['">]\s*;)\s*(?:|#\s*)INCLUDE\s+(?:\w+_)?[<"'](.+?)(?=["'>])""" USE_REGEX="""(?:^|;)\s*USE(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)""" MOD_REGEX="""(?:^|;)\s*MODULE(?!\s*PROCEDURE)(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)""" re_inc=re.compile(INC_REGEX,re.I) re_use=re.compile(USE_REGEX,re.I) re_mod=re.compile(MOD_REGEX,re.I) class fortran_parser(object): def __init__(self,incpaths): self.seen=[] self.nodes=[] self.names=[] self.incpaths=incpaths def find_deps(self,node): txt=node.read() incs=[] uses=[] mods=[] for line in txt.splitlines(): m=re_inc.search(line) if m: incs.append(m.group(1)) m=re_use.search(line) if m: uses.append(m.group(1)) m=re_mod.search(line) if m: mods.append(m.group(1)) return(incs,uses,mods) def start(self,node): self.waiting=[node] while self.waiting: nd=self.waiting.pop(0) self.iter(nd) def iter(self,node): path=node.abspath() incs,uses,mods=self.find_deps(node) for x in incs: if x in self.seen: continue self.seen.append(x) self.tryfind_header(x) for x in uses: name="USE@%s"%x if not name in self.names: self.names.append(name) for x in mods: name="MOD@%s"%x if not name in self.names: self.names.append(name) def <|fim_middle|>(self,filename): found=None for n in self.incpaths: found=n.find_resource(filename) if found: self.nodes.append(found) self.waiting.append(found) break if not found: if not filename in self.names: self.names.append(filename) <|fim▁end|>
tryfind_header
<|file_name|>procurement_pull.py<|end_file_name|><|fim▁begin|>############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from openerp.osv import osv from openerp import netsvc from openerp.tools.translate import _ class procurement_order(osv.osv): _inherit = 'procurement.order' def check_buy(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return line.type_proc=='buy' return super(procurement_order, self).check_buy(cr, uid, ids) def check_produce(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return line.type_proc=='produce' return super(procurement_order, self).check_produce(cr, uid, ids) def check_move(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return (line.type_proc=='move') and (line.location_src_id) return False def action_move_create(self, cr, uid, ids, context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') picking_obj=self.pool.get('stock.picking') wf_service = netsvc.LocalService("workflow") for proc in proc_obj.browse(cr, uid, ids, context=context): line = None for line in proc.product_id.flow_pull_ids: if line.location_id == proc.location_id: break assert line, 'Line cannot be False if we are on this state of the workflow' origin = (proc.origin or proc.name or '').split(':')[0] +':'+line.name picking_id = picking_obj.create(cr, uid, { 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'type': line.picking_type, 'stock_journal_id': line.journal_id and line.journal_id.id or False, 'move_type': 'one', 'partner_id': line.partner_address_id.id, 'note': _('Picking for pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), 'invoice_state': line.invoice_state, }) move_id = move_obj.create(cr, uid, { 'name': line.name, 'picking_id': picking_id, 'company_id': line.company_id and line.company_id.id or False, 'product_id': proc.product_id.id, 'date': proc.date_planned, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'partner_id': line.partner_address_id.id, 'location_id': line.location_src_id.id, 'location_dest_id': line.location_id.id, 'move_dest_id': proc.move_id and proc.move_id.id or False, # to verif, about history ? 'tracking_id': False, 'cancel_cascade': line.cancel_cascade, 'state': 'confirmed', 'note': _('Move for pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), }) if proc.move_id and proc.move_id.state in ('confirmed'): move_obj.write(cr,uid, [proc.move_id.id], { 'state':'waiting' }, context=context) proc_id = proc_obj.create(cr, uid, { 'name': line.name, 'origin': origin, 'note': _('Pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), 'company_id': line.company_id and line.company_id.id or False, 'date_planned': proc.date_planned, 'product_id': proc.product_id.id, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id,<|fim▁hole|> 'location_id': line.location_src_id.id, 'procure_method': line.procure_method, 'move_id': move_id, }) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) if proc.move_id: move_obj.write(cr, uid, [proc.move_id.id], {'location_id':proc.location_id.id}) msg = _('Pulled from another location.') self.write(cr, uid, [proc.id], {'state':'running', 'message': msg}) self.message_post(cr, uid, [proc.id], body=msg, context=context) # trigger direct processing (the new procurement shares the same planned date as the original one, which is already being processed) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_check', cr) return False procurement_order() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:<|fim▁end|>
<|file_name|>procurement_pull.py<|end_file_name|><|fim▁begin|>############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from openerp.osv import osv from openerp import netsvc from openerp.tools.translate import _ class procurement_order(osv.osv): <|fim_middle|> procurement_order() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: <|fim▁end|>
_inherit = 'procurement.order' def check_buy(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return line.type_proc=='buy' return super(procurement_order, self).check_buy(cr, uid, ids) def check_produce(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return line.type_proc=='produce' return super(procurement_order, self).check_produce(cr, uid, ids) def check_move(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return (line.type_proc=='move') and (line.location_src_id) return False def action_move_create(self, cr, uid, ids, context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') picking_obj=self.pool.get('stock.picking') wf_service = netsvc.LocalService("workflow") for proc in proc_obj.browse(cr, uid, ids, context=context): line = None for line in proc.product_id.flow_pull_ids: if line.location_id == proc.location_id: break assert line, 'Line cannot be False if we are on this state of the workflow' origin = (proc.origin or proc.name or '').split(':')[0] +':'+line.name picking_id = picking_obj.create(cr, uid, { 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'type': line.picking_type, 'stock_journal_id': line.journal_id and line.journal_id.id or False, 'move_type': 'one', 'partner_id': line.partner_address_id.id, 'note': _('Picking for pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), 'invoice_state': line.invoice_state, }) move_id = move_obj.create(cr, uid, { 'name': line.name, 'picking_id': picking_id, 'company_id': line.company_id and line.company_id.id or False, 'product_id': proc.product_id.id, 'date': proc.date_planned, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'partner_id': line.partner_address_id.id, 'location_id': line.location_src_id.id, 'location_dest_id': line.location_id.id, 'move_dest_id': proc.move_id and proc.move_id.id or False, # to verif, about history ? 'tracking_id': False, 'cancel_cascade': line.cancel_cascade, 'state': 'confirmed', 'note': _('Move for pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), }) if proc.move_id and proc.move_id.state in ('confirmed'): move_obj.write(cr,uid, [proc.move_id.id], { 'state':'waiting' }, context=context) proc_id = proc_obj.create(cr, uid, { 'name': line.name, 'origin': origin, 'note': _('Pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), 'company_id': line.company_id and line.company_id.id or False, 'date_planned': proc.date_planned, 'product_id': proc.product_id.id, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'location_id': line.location_src_id.id, 'procure_method': line.procure_method, 'move_id': move_id, }) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) if proc.move_id: move_obj.write(cr, uid, [proc.move_id.id], {'location_id':proc.location_id.id}) msg = _('Pulled from another location.') self.write(cr, uid, [proc.id], {'state':'running', 'message': msg}) self.message_post(cr, uid, [proc.id], body=msg, context=context) # trigger direct processing (the new procurement shares the same planned date as the original one, which is already being processed) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_check', cr) return False
<|file_name|>procurement_pull.py<|end_file_name|><|fim▁begin|>############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from openerp.osv import osv from openerp import netsvc from openerp.tools.translate import _ class procurement_order(osv.osv): _inherit = 'procurement.order' def check_buy(self, cr, uid, ids, context=None): <|fim_middle|> def check_produce(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return line.type_proc=='produce' return super(procurement_order, self).check_produce(cr, uid, ids) def check_move(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return (line.type_proc=='move') and (line.location_src_id) return False def action_move_create(self, cr, uid, ids, context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') picking_obj=self.pool.get('stock.picking') wf_service = netsvc.LocalService("workflow") for proc in proc_obj.browse(cr, uid, ids, context=context): line = None for line in proc.product_id.flow_pull_ids: if line.location_id == proc.location_id: break assert line, 'Line cannot be False if we are on this state of the workflow' origin = (proc.origin or proc.name or '').split(':')[0] +':'+line.name picking_id = picking_obj.create(cr, uid, { 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'type': line.picking_type, 'stock_journal_id': line.journal_id and line.journal_id.id or False, 'move_type': 'one', 'partner_id': line.partner_address_id.id, 'note': _('Picking for pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), 'invoice_state': line.invoice_state, }) move_id = move_obj.create(cr, uid, { 'name': line.name, 'picking_id': picking_id, 'company_id': line.company_id and line.company_id.id or False, 'product_id': proc.product_id.id, 'date': proc.date_planned, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'partner_id': line.partner_address_id.id, 'location_id': line.location_src_id.id, 'location_dest_id': line.location_id.id, 'move_dest_id': proc.move_id and proc.move_id.id or False, # to verif, about history ? 'tracking_id': False, 'cancel_cascade': line.cancel_cascade, 'state': 'confirmed', 'note': _('Move for pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), }) if proc.move_id and proc.move_id.state in ('confirmed'): move_obj.write(cr,uid, [proc.move_id.id], { 'state':'waiting' }, context=context) proc_id = proc_obj.create(cr, uid, { 'name': line.name, 'origin': origin, 'note': _('Pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), 'company_id': line.company_id and line.company_id.id or False, 'date_planned': proc.date_planned, 'product_id': proc.product_id.id, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'location_id': line.location_src_id.id, 'procure_method': line.procure_method, 'move_id': move_id, }) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) if proc.move_id: move_obj.write(cr, uid, [proc.move_id.id], {'location_id':proc.location_id.id}) msg = _('Pulled from another location.') self.write(cr, uid, [proc.id], {'state':'running', 'message': msg}) self.message_post(cr, uid, [proc.id], body=msg, context=context) # trigger direct processing (the new procurement shares the same planned date as the original one, which is already being processed) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_check', cr) return False procurement_order() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: <|fim▁end|>
for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return line.type_proc=='buy' return super(procurement_order, self).check_buy(cr, uid, ids)
<|file_name|>procurement_pull.py<|end_file_name|><|fim▁begin|>############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from openerp.osv import osv from openerp import netsvc from openerp.tools.translate import _ class procurement_order(osv.osv): _inherit = 'procurement.order' def check_buy(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return line.type_proc=='buy' return super(procurement_order, self).check_buy(cr, uid, ids) def check_produce(self, cr, uid, ids, context=None): <|fim_middle|> def check_move(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return (line.type_proc=='move') and (line.location_src_id) return False def action_move_create(self, cr, uid, ids, context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') picking_obj=self.pool.get('stock.picking') wf_service = netsvc.LocalService("workflow") for proc in proc_obj.browse(cr, uid, ids, context=context): line = None for line in proc.product_id.flow_pull_ids: if line.location_id == proc.location_id: break assert line, 'Line cannot be False if we are on this state of the workflow' origin = (proc.origin or proc.name or '').split(':')[0] +':'+line.name picking_id = picking_obj.create(cr, uid, { 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'type': line.picking_type, 'stock_journal_id': line.journal_id and line.journal_id.id or False, 'move_type': 'one', 'partner_id': line.partner_address_id.id, 'note': _('Picking for pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), 'invoice_state': line.invoice_state, }) move_id = move_obj.create(cr, uid, { 'name': line.name, 'picking_id': picking_id, 'company_id': line.company_id and line.company_id.id or False, 'product_id': proc.product_id.id, 'date': proc.date_planned, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'partner_id': line.partner_address_id.id, 'location_id': line.location_src_id.id, 'location_dest_id': line.location_id.id, 'move_dest_id': proc.move_id and proc.move_id.id or False, # to verif, about history ? 'tracking_id': False, 'cancel_cascade': line.cancel_cascade, 'state': 'confirmed', 'note': _('Move for pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), }) if proc.move_id and proc.move_id.state in ('confirmed'): move_obj.write(cr,uid, [proc.move_id.id], { 'state':'waiting' }, context=context) proc_id = proc_obj.create(cr, uid, { 'name': line.name, 'origin': origin, 'note': _('Pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), 'company_id': line.company_id and line.company_id.id or False, 'date_planned': proc.date_planned, 'product_id': proc.product_id.id, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'location_id': line.location_src_id.id, 'procure_method': line.procure_method, 'move_id': move_id, }) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) if proc.move_id: move_obj.write(cr, uid, [proc.move_id.id], {'location_id':proc.location_id.id}) msg = _('Pulled from another location.') self.write(cr, uid, [proc.id], {'state':'running', 'message': msg}) self.message_post(cr, uid, [proc.id], body=msg, context=context) # trigger direct processing (the new procurement shares the same planned date as the original one, which is already being processed) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_check', cr) return False procurement_order() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: <|fim▁end|>
for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return line.type_proc=='produce' return super(procurement_order, self).check_produce(cr, uid, ids)
<|file_name|>procurement_pull.py<|end_file_name|><|fim▁begin|>############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from openerp.osv import osv from openerp import netsvc from openerp.tools.translate import _ class procurement_order(osv.osv): _inherit = 'procurement.order' def check_buy(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return line.type_proc=='buy' return super(procurement_order, self).check_buy(cr, uid, ids) def check_produce(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return line.type_proc=='produce' return super(procurement_order, self).check_produce(cr, uid, ids) def check_move(self, cr, uid, ids, context=None): <|fim_middle|> def action_move_create(self, cr, uid, ids, context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') picking_obj=self.pool.get('stock.picking') wf_service = netsvc.LocalService("workflow") for proc in proc_obj.browse(cr, uid, ids, context=context): line = None for line in proc.product_id.flow_pull_ids: if line.location_id == proc.location_id: break assert line, 'Line cannot be False if we are on this state of the workflow' origin = (proc.origin or proc.name or '').split(':')[0] +':'+line.name picking_id = picking_obj.create(cr, uid, { 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'type': line.picking_type, 'stock_journal_id': line.journal_id and line.journal_id.id or False, 'move_type': 'one', 'partner_id': line.partner_address_id.id, 'note': _('Picking for pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), 'invoice_state': line.invoice_state, }) move_id = move_obj.create(cr, uid, { 'name': line.name, 'picking_id': picking_id, 'company_id': line.company_id and line.company_id.id or False, 'product_id': proc.product_id.id, 'date': proc.date_planned, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'partner_id': line.partner_address_id.id, 'location_id': line.location_src_id.id, 'location_dest_id': line.location_id.id, 'move_dest_id': proc.move_id and proc.move_id.id or False, # to verif, about history ? 'tracking_id': False, 'cancel_cascade': line.cancel_cascade, 'state': 'confirmed', 'note': _('Move for pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), }) if proc.move_id and proc.move_id.state in ('confirmed'): move_obj.write(cr,uid, [proc.move_id.id], { 'state':'waiting' }, context=context) proc_id = proc_obj.create(cr, uid, { 'name': line.name, 'origin': origin, 'note': _('Pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), 'company_id': line.company_id and line.company_id.id or False, 'date_planned': proc.date_planned, 'product_id': proc.product_id.id, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'location_id': line.location_src_id.id, 'procure_method': line.procure_method, 'move_id': move_id, }) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) if proc.move_id: move_obj.write(cr, uid, [proc.move_id.id], {'location_id':proc.location_id.id}) msg = _('Pulled from another location.') self.write(cr, uid, [proc.id], {'state':'running', 'message': msg}) self.message_post(cr, uid, [proc.id], body=msg, context=context) # trigger direct processing (the new procurement shares the same planned date as the original one, which is already being processed) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_check', cr) return False procurement_order() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: <|fim▁end|>
for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return (line.type_proc=='move') and (line.location_src_id) return False
<|file_name|>procurement_pull.py<|end_file_name|><|fim▁begin|>############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from openerp.osv import osv from openerp import netsvc from openerp.tools.translate import _ class procurement_order(osv.osv): _inherit = 'procurement.order' def check_buy(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return line.type_proc=='buy' return super(procurement_order, self).check_buy(cr, uid, ids) def check_produce(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return line.type_proc=='produce' return super(procurement_order, self).check_produce(cr, uid, ids) def check_move(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return (line.type_proc=='move') and (line.location_src_id) return False def action_move_create(self, cr, uid, ids, context=None): <|fim_middle|> procurement_order() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: <|fim▁end|>
proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') picking_obj=self.pool.get('stock.picking') wf_service = netsvc.LocalService("workflow") for proc in proc_obj.browse(cr, uid, ids, context=context): line = None for line in proc.product_id.flow_pull_ids: if line.location_id == proc.location_id: break assert line, 'Line cannot be False if we are on this state of the workflow' origin = (proc.origin or proc.name or '').split(':')[0] +':'+line.name picking_id = picking_obj.create(cr, uid, { 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'type': line.picking_type, 'stock_journal_id': line.journal_id and line.journal_id.id or False, 'move_type': 'one', 'partner_id': line.partner_address_id.id, 'note': _('Picking for pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), 'invoice_state': line.invoice_state, }) move_id = move_obj.create(cr, uid, { 'name': line.name, 'picking_id': picking_id, 'company_id': line.company_id and line.company_id.id or False, 'product_id': proc.product_id.id, 'date': proc.date_planned, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'partner_id': line.partner_address_id.id, 'location_id': line.location_src_id.id, 'location_dest_id': line.location_id.id, 'move_dest_id': proc.move_id and proc.move_id.id or False, # to verif, about history ? 'tracking_id': False, 'cancel_cascade': line.cancel_cascade, 'state': 'confirmed', 'note': _('Move for pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), }) if proc.move_id and proc.move_id.state in ('confirmed'): move_obj.write(cr,uid, [proc.move_id.id], { 'state':'waiting' }, context=context) proc_id = proc_obj.create(cr, uid, { 'name': line.name, 'origin': origin, 'note': _('Pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), 'company_id': line.company_id and line.company_id.id or False, 'date_planned': proc.date_planned, 'product_id': proc.product_id.id, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'location_id': line.location_src_id.id, 'procure_method': line.procure_method, 'move_id': move_id, }) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) if proc.move_id: move_obj.write(cr, uid, [proc.move_id.id], {'location_id':proc.location_id.id}) msg = _('Pulled from another location.') self.write(cr, uid, [proc.id], {'state':'running', 'message': msg}) self.message_post(cr, uid, [proc.id], body=msg, context=context) # trigger direct processing (the new procurement shares the same planned date as the original one, which is already being processed) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_check', cr) return False
<|file_name|>procurement_pull.py<|end_file_name|><|fim▁begin|>############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from openerp.osv import osv from openerp import netsvc from openerp.tools.translate import _ class procurement_order(osv.osv): _inherit = 'procurement.order' def check_buy(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: <|fim_middle|> return super(procurement_order, self).check_buy(cr, uid, ids) def check_produce(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return line.type_proc=='produce' return super(procurement_order, self).check_produce(cr, uid, ids) def check_move(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return (line.type_proc=='move') and (line.location_src_id) return False def action_move_create(self, cr, uid, ids, context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') picking_obj=self.pool.get('stock.picking') wf_service = netsvc.LocalService("workflow") for proc in proc_obj.browse(cr, uid, ids, context=context): line = None for line in proc.product_id.flow_pull_ids: if line.location_id == proc.location_id: break assert line, 'Line cannot be False if we are on this state of the workflow' origin = (proc.origin or proc.name or '').split(':')[0] +':'+line.name picking_id = picking_obj.create(cr, uid, { 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'type': line.picking_type, 'stock_journal_id': line.journal_id and line.journal_id.id or False, 'move_type': 'one', 'partner_id': line.partner_address_id.id, 'note': _('Picking for pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), 'invoice_state': line.invoice_state, }) move_id = move_obj.create(cr, uid, { 'name': line.name, 'picking_id': picking_id, 'company_id': line.company_id and line.company_id.id or False, 'product_id': proc.product_id.id, 'date': proc.date_planned, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'partner_id': line.partner_address_id.id, 'location_id': line.location_src_id.id, 'location_dest_id': line.location_id.id, 'move_dest_id': proc.move_id and proc.move_id.id or False, # to verif, about history ? 'tracking_id': False, 'cancel_cascade': line.cancel_cascade, 'state': 'confirmed', 'note': _('Move for pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), }) if proc.move_id and proc.move_id.state in ('confirmed'): move_obj.write(cr,uid, [proc.move_id.id], { 'state':'waiting' }, context=context) proc_id = proc_obj.create(cr, uid, { 'name': line.name, 'origin': origin, 'note': _('Pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), 'company_id': line.company_id and line.company_id.id or False, 'date_planned': proc.date_planned, 'product_id': proc.product_id.id, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'location_id': line.location_src_id.id, 'procure_method': line.procure_method, 'move_id': move_id, }) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) if proc.move_id: move_obj.write(cr, uid, [proc.move_id.id], {'location_id':proc.location_id.id}) msg = _('Pulled from another location.') self.write(cr, uid, [proc.id], {'state':'running', 'message': msg}) self.message_post(cr, uid, [proc.id], body=msg, context=context) # trigger direct processing (the new procurement shares the same planned date as the original one, which is already being processed) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_check', cr) return False procurement_order() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: <|fim▁end|>
return line.type_proc=='buy'
<|file_name|>procurement_pull.py<|end_file_name|><|fim▁begin|>############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from openerp.osv import osv from openerp import netsvc from openerp.tools.translate import _ class procurement_order(osv.osv): _inherit = 'procurement.order' def check_buy(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return line.type_proc=='buy' return super(procurement_order, self).check_buy(cr, uid, ids) def check_produce(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: <|fim_middle|> return super(procurement_order, self).check_produce(cr, uid, ids) def check_move(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return (line.type_proc=='move') and (line.location_src_id) return False def action_move_create(self, cr, uid, ids, context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') picking_obj=self.pool.get('stock.picking') wf_service = netsvc.LocalService("workflow") for proc in proc_obj.browse(cr, uid, ids, context=context): line = None for line in proc.product_id.flow_pull_ids: if line.location_id == proc.location_id: break assert line, 'Line cannot be False if we are on this state of the workflow' origin = (proc.origin or proc.name or '').split(':')[0] +':'+line.name picking_id = picking_obj.create(cr, uid, { 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'type': line.picking_type, 'stock_journal_id': line.journal_id and line.journal_id.id or False, 'move_type': 'one', 'partner_id': line.partner_address_id.id, 'note': _('Picking for pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), 'invoice_state': line.invoice_state, }) move_id = move_obj.create(cr, uid, { 'name': line.name, 'picking_id': picking_id, 'company_id': line.company_id and line.company_id.id or False, 'product_id': proc.product_id.id, 'date': proc.date_planned, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'partner_id': line.partner_address_id.id, 'location_id': line.location_src_id.id, 'location_dest_id': line.location_id.id, 'move_dest_id': proc.move_id and proc.move_id.id or False, # to verif, about history ? 'tracking_id': False, 'cancel_cascade': line.cancel_cascade, 'state': 'confirmed', 'note': _('Move for pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), }) if proc.move_id and proc.move_id.state in ('confirmed'): move_obj.write(cr,uid, [proc.move_id.id], { 'state':'waiting' }, context=context) proc_id = proc_obj.create(cr, uid, { 'name': line.name, 'origin': origin, 'note': _('Pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), 'company_id': line.company_id and line.company_id.id or False, 'date_planned': proc.date_planned, 'product_id': proc.product_id.id, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'location_id': line.location_src_id.id, 'procure_method': line.procure_method, 'move_id': move_id, }) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) if proc.move_id: move_obj.write(cr, uid, [proc.move_id.id], {'location_id':proc.location_id.id}) msg = _('Pulled from another location.') self.write(cr, uid, [proc.id], {'state':'running', 'message': msg}) self.message_post(cr, uid, [proc.id], body=msg, context=context) # trigger direct processing (the new procurement shares the same planned date as the original one, which is already being processed) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_check', cr) return False procurement_order() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: <|fim▁end|>
return line.type_proc=='produce'
<|file_name|>procurement_pull.py<|end_file_name|><|fim▁begin|>############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from openerp.osv import osv from openerp import netsvc from openerp.tools.translate import _ class procurement_order(osv.osv): _inherit = 'procurement.order' def check_buy(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return line.type_proc=='buy' return super(procurement_order, self).check_buy(cr, uid, ids) def check_produce(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return line.type_proc=='produce' return super(procurement_order, self).check_produce(cr, uid, ids) def check_move(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: <|fim_middle|> return False def action_move_create(self, cr, uid, ids, context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') picking_obj=self.pool.get('stock.picking') wf_service = netsvc.LocalService("workflow") for proc in proc_obj.browse(cr, uid, ids, context=context): line = None for line in proc.product_id.flow_pull_ids: if line.location_id == proc.location_id: break assert line, 'Line cannot be False if we are on this state of the workflow' origin = (proc.origin or proc.name or '').split(':')[0] +':'+line.name picking_id = picking_obj.create(cr, uid, { 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'type': line.picking_type, 'stock_journal_id': line.journal_id and line.journal_id.id or False, 'move_type': 'one', 'partner_id': line.partner_address_id.id, 'note': _('Picking for pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), 'invoice_state': line.invoice_state, }) move_id = move_obj.create(cr, uid, { 'name': line.name, 'picking_id': picking_id, 'company_id': line.company_id and line.company_id.id or False, 'product_id': proc.product_id.id, 'date': proc.date_planned, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'partner_id': line.partner_address_id.id, 'location_id': line.location_src_id.id, 'location_dest_id': line.location_id.id, 'move_dest_id': proc.move_id and proc.move_id.id or False, # to verif, about history ? 'tracking_id': False, 'cancel_cascade': line.cancel_cascade, 'state': 'confirmed', 'note': _('Move for pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), }) if proc.move_id and proc.move_id.state in ('confirmed'): move_obj.write(cr,uid, [proc.move_id.id], { 'state':'waiting' }, context=context) proc_id = proc_obj.create(cr, uid, { 'name': line.name, 'origin': origin, 'note': _('Pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), 'company_id': line.company_id and line.company_id.id or False, 'date_planned': proc.date_planned, 'product_id': proc.product_id.id, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'location_id': line.location_src_id.id, 'procure_method': line.procure_method, 'move_id': move_id, }) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) if proc.move_id: move_obj.write(cr, uid, [proc.move_id.id], {'location_id':proc.location_id.id}) msg = _('Pulled from another location.') self.write(cr, uid, [proc.id], {'state':'running', 'message': msg}) self.message_post(cr, uid, [proc.id], body=msg, context=context) # trigger direct processing (the new procurement shares the same planned date as the original one, which is already being processed) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_check', cr) return False procurement_order() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: <|fim▁end|>
return (line.type_proc=='move') and (line.location_src_id)
<|file_name|>procurement_pull.py<|end_file_name|><|fim▁begin|>############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from openerp.osv import osv from openerp import netsvc from openerp.tools.translate import _ class procurement_order(osv.osv): _inherit = 'procurement.order' def check_buy(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return line.type_proc=='buy' return super(procurement_order, self).check_buy(cr, uid, ids) def check_produce(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return line.type_proc=='produce' return super(procurement_order, self).check_produce(cr, uid, ids) def check_move(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return (line.type_proc=='move') and (line.location_src_id) return False def action_move_create(self, cr, uid, ids, context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') picking_obj=self.pool.get('stock.picking') wf_service = netsvc.LocalService("workflow") for proc in proc_obj.browse(cr, uid, ids, context=context): line = None for line in proc.product_id.flow_pull_ids: if line.location_id == proc.location_id: <|fim_middle|> assert line, 'Line cannot be False if we are on this state of the workflow' origin = (proc.origin or proc.name or '').split(':')[0] +':'+line.name picking_id = picking_obj.create(cr, uid, { 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'type': line.picking_type, 'stock_journal_id': line.journal_id and line.journal_id.id or False, 'move_type': 'one', 'partner_id': line.partner_address_id.id, 'note': _('Picking for pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), 'invoice_state': line.invoice_state, }) move_id = move_obj.create(cr, uid, { 'name': line.name, 'picking_id': picking_id, 'company_id': line.company_id and line.company_id.id or False, 'product_id': proc.product_id.id, 'date': proc.date_planned, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'partner_id': line.partner_address_id.id, 'location_id': line.location_src_id.id, 'location_dest_id': line.location_id.id, 'move_dest_id': proc.move_id and proc.move_id.id or False, # to verif, about history ? 'tracking_id': False, 'cancel_cascade': line.cancel_cascade, 'state': 'confirmed', 'note': _('Move for pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), }) if proc.move_id and proc.move_id.state in ('confirmed'): move_obj.write(cr,uid, [proc.move_id.id], { 'state':'waiting' }, context=context) proc_id = proc_obj.create(cr, uid, { 'name': line.name, 'origin': origin, 'note': _('Pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), 'company_id': line.company_id and line.company_id.id or False, 'date_planned': proc.date_planned, 'product_id': proc.product_id.id, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'location_id': line.location_src_id.id, 'procure_method': line.procure_method, 'move_id': move_id, }) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) if proc.move_id: move_obj.write(cr, uid, [proc.move_id.id], {'location_id':proc.location_id.id}) msg = _('Pulled from another location.') self.write(cr, uid, [proc.id], {'state':'running', 'message': msg}) self.message_post(cr, uid, [proc.id], body=msg, context=context) # trigger direct processing (the new procurement shares the same planned date as the original one, which is already being processed) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_check', cr) return False procurement_order() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: <|fim▁end|>
break
<|file_name|>procurement_pull.py<|end_file_name|><|fim▁begin|>############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from openerp.osv import osv from openerp import netsvc from openerp.tools.translate import _ class procurement_order(osv.osv): _inherit = 'procurement.order' def check_buy(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return line.type_proc=='buy' return super(procurement_order, self).check_buy(cr, uid, ids) def check_produce(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return line.type_proc=='produce' return super(procurement_order, self).check_produce(cr, uid, ids) def check_move(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return (line.type_proc=='move') and (line.location_src_id) return False def action_move_create(self, cr, uid, ids, context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') picking_obj=self.pool.get('stock.picking') wf_service = netsvc.LocalService("workflow") for proc in proc_obj.browse(cr, uid, ids, context=context): line = None for line in proc.product_id.flow_pull_ids: if line.location_id == proc.location_id: break assert line, 'Line cannot be False if we are on this state of the workflow' origin = (proc.origin or proc.name or '').split(':')[0] +':'+line.name picking_id = picking_obj.create(cr, uid, { 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'type': line.picking_type, 'stock_journal_id': line.journal_id and line.journal_id.id or False, 'move_type': 'one', 'partner_id': line.partner_address_id.id, 'note': _('Picking for pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), 'invoice_state': line.invoice_state, }) move_id = move_obj.create(cr, uid, { 'name': line.name, 'picking_id': picking_id, 'company_id': line.company_id and line.company_id.id or False, 'product_id': proc.product_id.id, 'date': proc.date_planned, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'partner_id': line.partner_address_id.id, 'location_id': line.location_src_id.id, 'location_dest_id': line.location_id.id, 'move_dest_id': proc.move_id and proc.move_id.id or False, # to verif, about history ? 'tracking_id': False, 'cancel_cascade': line.cancel_cascade, 'state': 'confirmed', 'note': _('Move for pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), }) if proc.move_id and proc.move_id.state in ('confirmed'): <|fim_middle|> proc_id = proc_obj.create(cr, uid, { 'name': line.name, 'origin': origin, 'note': _('Pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), 'company_id': line.company_id and line.company_id.id or False, 'date_planned': proc.date_planned, 'product_id': proc.product_id.id, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'location_id': line.location_src_id.id, 'procure_method': line.procure_method, 'move_id': move_id, }) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) if proc.move_id: move_obj.write(cr, uid, [proc.move_id.id], {'location_id':proc.location_id.id}) msg = _('Pulled from another location.') self.write(cr, uid, [proc.id], {'state':'running', 'message': msg}) self.message_post(cr, uid, [proc.id], body=msg, context=context) # trigger direct processing (the new procurement shares the same planned date as the original one, which is already being processed) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_check', cr) return False procurement_order() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: <|fim▁end|>
move_obj.write(cr,uid, [proc.move_id.id], { 'state':'waiting' }, context=context)
<|file_name|>procurement_pull.py<|end_file_name|><|fim▁begin|>############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from openerp.osv import osv from openerp import netsvc from openerp.tools.translate import _ class procurement_order(osv.osv): _inherit = 'procurement.order' def check_buy(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return line.type_proc=='buy' return super(procurement_order, self).check_buy(cr, uid, ids) def check_produce(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return line.type_proc=='produce' return super(procurement_order, self).check_produce(cr, uid, ids) def check_move(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return (line.type_proc=='move') and (line.location_src_id) return False def action_move_create(self, cr, uid, ids, context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') picking_obj=self.pool.get('stock.picking') wf_service = netsvc.LocalService("workflow") for proc in proc_obj.browse(cr, uid, ids, context=context): line = None for line in proc.product_id.flow_pull_ids: if line.location_id == proc.location_id: break assert line, 'Line cannot be False if we are on this state of the workflow' origin = (proc.origin or proc.name or '').split(':')[0] +':'+line.name picking_id = picking_obj.create(cr, uid, { 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'type': line.picking_type, 'stock_journal_id': line.journal_id and line.journal_id.id or False, 'move_type': 'one', 'partner_id': line.partner_address_id.id, 'note': _('Picking for pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), 'invoice_state': line.invoice_state, }) move_id = move_obj.create(cr, uid, { 'name': line.name, 'picking_id': picking_id, 'company_id': line.company_id and line.company_id.id or False, 'product_id': proc.product_id.id, 'date': proc.date_planned, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'partner_id': line.partner_address_id.id, 'location_id': line.location_src_id.id, 'location_dest_id': line.location_id.id, 'move_dest_id': proc.move_id and proc.move_id.id or False, # to verif, about history ? 'tracking_id': False, 'cancel_cascade': line.cancel_cascade, 'state': 'confirmed', 'note': _('Move for pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), }) if proc.move_id and proc.move_id.state in ('confirmed'): move_obj.write(cr,uid, [proc.move_id.id], { 'state':'waiting' }, context=context) proc_id = proc_obj.create(cr, uid, { 'name': line.name, 'origin': origin, 'note': _('Pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), 'company_id': line.company_id and line.company_id.id or False, 'date_planned': proc.date_planned, 'product_id': proc.product_id.id, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'location_id': line.location_src_id.id, 'procure_method': line.procure_method, 'move_id': move_id, }) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) if proc.move_id: <|fim_middle|> msg = _('Pulled from another location.') self.write(cr, uid, [proc.id], {'state':'running', 'message': msg}) self.message_post(cr, uid, [proc.id], body=msg, context=context) # trigger direct processing (the new procurement shares the same planned date as the original one, which is already being processed) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_check', cr) return False procurement_order() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: <|fim▁end|>
move_obj.write(cr, uid, [proc.move_id.id], {'location_id':proc.location_id.id})
<|file_name|>procurement_pull.py<|end_file_name|><|fim▁begin|>############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from openerp.osv import osv from openerp import netsvc from openerp.tools.translate import _ class procurement_order(osv.osv): _inherit = 'procurement.order' def <|fim_middle|>(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return line.type_proc=='buy' return super(procurement_order, self).check_buy(cr, uid, ids) def check_produce(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return line.type_proc=='produce' return super(procurement_order, self).check_produce(cr, uid, ids) def check_move(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return (line.type_proc=='move') and (line.location_src_id) return False def action_move_create(self, cr, uid, ids, context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') picking_obj=self.pool.get('stock.picking') wf_service = netsvc.LocalService("workflow") for proc in proc_obj.browse(cr, uid, ids, context=context): line = None for line in proc.product_id.flow_pull_ids: if line.location_id == proc.location_id: break assert line, 'Line cannot be False if we are on this state of the workflow' origin = (proc.origin or proc.name or '').split(':')[0] +':'+line.name picking_id = picking_obj.create(cr, uid, { 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'type': line.picking_type, 'stock_journal_id': line.journal_id and line.journal_id.id or False, 'move_type': 'one', 'partner_id': line.partner_address_id.id, 'note': _('Picking for pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), 'invoice_state': line.invoice_state, }) move_id = move_obj.create(cr, uid, { 'name': line.name, 'picking_id': picking_id, 'company_id': line.company_id and line.company_id.id or False, 'product_id': proc.product_id.id, 'date': proc.date_planned, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'partner_id': line.partner_address_id.id, 'location_id': line.location_src_id.id, 'location_dest_id': line.location_id.id, 'move_dest_id': proc.move_id and proc.move_id.id or False, # to verif, about history ? 'tracking_id': False, 'cancel_cascade': line.cancel_cascade, 'state': 'confirmed', 'note': _('Move for pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), }) if proc.move_id and proc.move_id.state in ('confirmed'): move_obj.write(cr,uid, [proc.move_id.id], { 'state':'waiting' }, context=context) proc_id = proc_obj.create(cr, uid, { 'name': line.name, 'origin': origin, 'note': _('Pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), 'company_id': line.company_id and line.company_id.id or False, 'date_planned': proc.date_planned, 'product_id': proc.product_id.id, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'location_id': line.location_src_id.id, 'procure_method': line.procure_method, 'move_id': move_id, }) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) if proc.move_id: move_obj.write(cr, uid, [proc.move_id.id], {'location_id':proc.location_id.id}) msg = _('Pulled from another location.') self.write(cr, uid, [proc.id], {'state':'running', 'message': msg}) self.message_post(cr, uid, [proc.id], body=msg, context=context) # trigger direct processing (the new procurement shares the same planned date as the original one, which is already being processed) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_check', cr) return False procurement_order() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: <|fim▁end|>
check_buy
<|file_name|>procurement_pull.py<|end_file_name|><|fim▁begin|>############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from openerp.osv import osv from openerp import netsvc from openerp.tools.translate import _ class procurement_order(osv.osv): _inherit = 'procurement.order' def check_buy(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return line.type_proc=='buy' return super(procurement_order, self).check_buy(cr, uid, ids) def <|fim_middle|>(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return line.type_proc=='produce' return super(procurement_order, self).check_produce(cr, uid, ids) def check_move(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return (line.type_proc=='move') and (line.location_src_id) return False def action_move_create(self, cr, uid, ids, context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') picking_obj=self.pool.get('stock.picking') wf_service = netsvc.LocalService("workflow") for proc in proc_obj.browse(cr, uid, ids, context=context): line = None for line in proc.product_id.flow_pull_ids: if line.location_id == proc.location_id: break assert line, 'Line cannot be False if we are on this state of the workflow' origin = (proc.origin or proc.name or '').split(':')[0] +':'+line.name picking_id = picking_obj.create(cr, uid, { 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'type': line.picking_type, 'stock_journal_id': line.journal_id and line.journal_id.id or False, 'move_type': 'one', 'partner_id': line.partner_address_id.id, 'note': _('Picking for pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), 'invoice_state': line.invoice_state, }) move_id = move_obj.create(cr, uid, { 'name': line.name, 'picking_id': picking_id, 'company_id': line.company_id and line.company_id.id or False, 'product_id': proc.product_id.id, 'date': proc.date_planned, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'partner_id': line.partner_address_id.id, 'location_id': line.location_src_id.id, 'location_dest_id': line.location_id.id, 'move_dest_id': proc.move_id and proc.move_id.id or False, # to verif, about history ? 'tracking_id': False, 'cancel_cascade': line.cancel_cascade, 'state': 'confirmed', 'note': _('Move for pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), }) if proc.move_id and proc.move_id.state in ('confirmed'): move_obj.write(cr,uid, [proc.move_id.id], { 'state':'waiting' }, context=context) proc_id = proc_obj.create(cr, uid, { 'name': line.name, 'origin': origin, 'note': _('Pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), 'company_id': line.company_id and line.company_id.id or False, 'date_planned': proc.date_planned, 'product_id': proc.product_id.id, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'location_id': line.location_src_id.id, 'procure_method': line.procure_method, 'move_id': move_id, }) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) if proc.move_id: move_obj.write(cr, uid, [proc.move_id.id], {'location_id':proc.location_id.id}) msg = _('Pulled from another location.') self.write(cr, uid, [proc.id], {'state':'running', 'message': msg}) self.message_post(cr, uid, [proc.id], body=msg, context=context) # trigger direct processing (the new procurement shares the same planned date as the original one, which is already being processed) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_check', cr) return False procurement_order() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: <|fim▁end|>
check_produce
<|file_name|>procurement_pull.py<|end_file_name|><|fim▁begin|>############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from openerp.osv import osv from openerp import netsvc from openerp.tools.translate import _ class procurement_order(osv.osv): _inherit = 'procurement.order' def check_buy(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return line.type_proc=='buy' return super(procurement_order, self).check_buy(cr, uid, ids) def check_produce(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return line.type_proc=='produce' return super(procurement_order, self).check_produce(cr, uid, ids) def <|fim_middle|>(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return (line.type_proc=='move') and (line.location_src_id) return False def action_move_create(self, cr, uid, ids, context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') picking_obj=self.pool.get('stock.picking') wf_service = netsvc.LocalService("workflow") for proc in proc_obj.browse(cr, uid, ids, context=context): line = None for line in proc.product_id.flow_pull_ids: if line.location_id == proc.location_id: break assert line, 'Line cannot be False if we are on this state of the workflow' origin = (proc.origin or proc.name or '').split(':')[0] +':'+line.name picking_id = picking_obj.create(cr, uid, { 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'type': line.picking_type, 'stock_journal_id': line.journal_id and line.journal_id.id or False, 'move_type': 'one', 'partner_id': line.partner_address_id.id, 'note': _('Picking for pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), 'invoice_state': line.invoice_state, }) move_id = move_obj.create(cr, uid, { 'name': line.name, 'picking_id': picking_id, 'company_id': line.company_id and line.company_id.id or False, 'product_id': proc.product_id.id, 'date': proc.date_planned, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'partner_id': line.partner_address_id.id, 'location_id': line.location_src_id.id, 'location_dest_id': line.location_id.id, 'move_dest_id': proc.move_id and proc.move_id.id or False, # to verif, about history ? 'tracking_id': False, 'cancel_cascade': line.cancel_cascade, 'state': 'confirmed', 'note': _('Move for pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), }) if proc.move_id and proc.move_id.state in ('confirmed'): move_obj.write(cr,uid, [proc.move_id.id], { 'state':'waiting' }, context=context) proc_id = proc_obj.create(cr, uid, { 'name': line.name, 'origin': origin, 'note': _('Pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), 'company_id': line.company_id and line.company_id.id or False, 'date_planned': proc.date_planned, 'product_id': proc.product_id.id, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'location_id': line.location_src_id.id, 'procure_method': line.procure_method, 'move_id': move_id, }) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) if proc.move_id: move_obj.write(cr, uid, [proc.move_id.id], {'location_id':proc.location_id.id}) msg = _('Pulled from another location.') self.write(cr, uid, [proc.id], {'state':'running', 'message': msg}) self.message_post(cr, uid, [proc.id], body=msg, context=context) # trigger direct processing (the new procurement shares the same planned date as the original one, which is already being processed) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_check', cr) return False procurement_order() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: <|fim▁end|>
check_move
<|file_name|>procurement_pull.py<|end_file_name|><|fim▁begin|>############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from openerp.osv import osv from openerp import netsvc from openerp.tools.translate import _ class procurement_order(osv.osv): _inherit = 'procurement.order' def check_buy(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return line.type_proc=='buy' return super(procurement_order, self).check_buy(cr, uid, ids) def check_produce(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return line.type_proc=='produce' return super(procurement_order, self).check_produce(cr, uid, ids) def check_move(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): for line in procurement.product_id.flow_pull_ids: if line.location_id==procurement.location_id: return (line.type_proc=='move') and (line.location_src_id) return False def <|fim_middle|>(self, cr, uid, ids, context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') picking_obj=self.pool.get('stock.picking') wf_service = netsvc.LocalService("workflow") for proc in proc_obj.browse(cr, uid, ids, context=context): line = None for line in proc.product_id.flow_pull_ids: if line.location_id == proc.location_id: break assert line, 'Line cannot be False if we are on this state of the workflow' origin = (proc.origin or proc.name or '').split(':')[0] +':'+line.name picking_id = picking_obj.create(cr, uid, { 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'type': line.picking_type, 'stock_journal_id': line.journal_id and line.journal_id.id or False, 'move_type': 'one', 'partner_id': line.partner_address_id.id, 'note': _('Picking for pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), 'invoice_state': line.invoice_state, }) move_id = move_obj.create(cr, uid, { 'name': line.name, 'picking_id': picking_id, 'company_id': line.company_id and line.company_id.id or False, 'product_id': proc.product_id.id, 'date': proc.date_planned, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'partner_id': line.partner_address_id.id, 'location_id': line.location_src_id.id, 'location_dest_id': line.location_id.id, 'move_dest_id': proc.move_id and proc.move_id.id or False, # to verif, about history ? 'tracking_id': False, 'cancel_cascade': line.cancel_cascade, 'state': 'confirmed', 'note': _('Move for pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), }) if proc.move_id and proc.move_id.state in ('confirmed'): move_obj.write(cr,uid, [proc.move_id.id], { 'state':'waiting' }, context=context) proc_id = proc_obj.create(cr, uid, { 'name': line.name, 'origin': origin, 'note': _('Pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), 'company_id': line.company_id and line.company_id.id or False, 'date_planned': proc.date_planned, 'product_id': proc.product_id.id, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'location_id': line.location_src_id.id, 'procure_method': line.procure_method, 'move_id': move_id, }) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) if proc.move_id: move_obj.write(cr, uid, [proc.move_id.id], {'location_id':proc.location_id.id}) msg = _('Pulled from another location.') self.write(cr, uid, [proc.id], {'state':'running', 'message': msg}) self.message_post(cr, uid, [proc.id], body=msg, context=context) # trigger direct processing (the new procurement shares the same planned date as the original one, which is already being processed) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_check', cr) return False procurement_order() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: <|fim▁end|>
action_move_create
<|file_name|>test_Cursor.py<|end_file_name|><|fim▁begin|>import pytest from py4jdbc.dbapi2 import connect, Connection from py4jdbc.resultset import ResultSet from py4jdbc.exceptions.dbapi2 import Error def test_connect(gateway): url = "jdbc:derby:memory:testdb;create=true" conn = connect(url, gateway=gateway) cur = conn.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute_with_params(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") # Verify table is empty. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 0 # Insert one with parameter binding.. sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" cur.execute(sql, (12, "m")) # Verify there's 1 row. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 1 # Insert a bunch. params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == len("thecowsaremooing") + 1 derby.rollback() derby.autocommit = True def test_fetchone(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs.fetchone(), rs.Row) def test_fetchmany(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor()<|fim▁hole|>def test_fetchManyCount(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rs = cur.execute("select a from x_with_params.cowtest") ress = [] while True: x = rs.fetchmany(3) ress.append(x) if len(x) < 3: break derby.rollback() derby.autocommit = True assert sum(map(len, ress)) == len("thecowsaremooing") def test_fetchall(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchall()}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") # Exhaust all rows. list(rs) assert rs.fetchone() == None def test_close_and_execute(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.execute("select * from SYS.SYSTABLES") def test_close_and_fetchone(derby): cur = derby.cursor() cur.execute("select * from SYS.SYSTABLES") cur.close() with pytest.raises(Error): cur.fetchone() def test_close_twice(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.close()<|fim▁end|>
rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchmany(5)})
<|file_name|>test_Cursor.py<|end_file_name|><|fim▁begin|>import pytest from py4jdbc.dbapi2 import connect, Connection from py4jdbc.resultset import ResultSet from py4jdbc.exceptions.dbapi2 import Error def test_connect(gateway): <|fim_middle|> def test_execute(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute_with_params(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") # Verify table is empty. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 0 # Insert one with parameter binding.. sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" cur.execute(sql, (12, "m")) # Verify there's 1 row. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 1 # Insert a bunch. params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == len("thecowsaremooing") + 1 derby.rollback() derby.autocommit = True def test_fetchone(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs.fetchone(), rs.Row) def test_fetchmany(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchmany(5)}) def test_fetchManyCount(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rs = cur.execute("select a from x_with_params.cowtest") ress = [] while True: x = rs.fetchmany(3) ress.append(x) if len(x) < 3: break derby.rollback() derby.autocommit = True assert sum(map(len, ress)) == len("thecowsaremooing") def test_fetchall(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchall()}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") # Exhaust all rows. list(rs) assert rs.fetchone() == None def test_close_and_execute(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.execute("select * from SYS.SYSTABLES") def test_close_and_fetchone(derby): cur = derby.cursor() cur.execute("select * from SYS.SYSTABLES") cur.close() with pytest.raises(Error): cur.fetchone() def test_close_twice(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.close() <|fim▁end|>
url = "jdbc:derby:memory:testdb;create=true" conn = connect(url, gateway=gateway) cur = conn.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet)
<|file_name|>test_Cursor.py<|end_file_name|><|fim▁begin|>import pytest from py4jdbc.dbapi2 import connect, Connection from py4jdbc.resultset import ResultSet from py4jdbc.exceptions.dbapi2 import Error def test_connect(gateway): url = "jdbc:derby:memory:testdb;create=true" conn = connect(url, gateway=gateway) cur = conn.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute(derby): <|fim_middle|> def test_execute_with_params(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") # Verify table is empty. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 0 # Insert one with parameter binding.. sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" cur.execute(sql, (12, "m")) # Verify there's 1 row. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 1 # Insert a bunch. params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == len("thecowsaremooing") + 1 derby.rollback() derby.autocommit = True def test_fetchone(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs.fetchone(), rs.Row) def test_fetchmany(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchmany(5)}) def test_fetchManyCount(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rs = cur.execute("select a from x_with_params.cowtest") ress = [] while True: x = rs.fetchmany(3) ress.append(x) if len(x) < 3: break derby.rollback() derby.autocommit = True assert sum(map(len, ress)) == len("thecowsaremooing") def test_fetchall(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchall()}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") # Exhaust all rows. list(rs) assert rs.fetchone() == None def test_close_and_execute(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.execute("select * from SYS.SYSTABLES") def test_close_and_fetchone(derby): cur = derby.cursor() cur.execute("select * from SYS.SYSTABLES") cur.close() with pytest.raises(Error): cur.fetchone() def test_close_twice(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.close() <|fim▁end|>
cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet)
<|file_name|>test_Cursor.py<|end_file_name|><|fim▁begin|>import pytest from py4jdbc.dbapi2 import connect, Connection from py4jdbc.resultset import ResultSet from py4jdbc.exceptions.dbapi2 import Error def test_connect(gateway): url = "jdbc:derby:memory:testdb;create=true" conn = connect(url, gateway=gateway) cur = conn.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute_with_params(derby): <|fim_middle|> def test_fetchone(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs.fetchone(), rs.Row) def test_fetchmany(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchmany(5)}) def test_fetchManyCount(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rs = cur.execute("select a from x_with_params.cowtest") ress = [] while True: x = rs.fetchmany(3) ress.append(x) if len(x) < 3: break derby.rollback() derby.autocommit = True assert sum(map(len, ress)) == len("thecowsaremooing") def test_fetchall(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchall()}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") # Exhaust all rows. list(rs) assert rs.fetchone() == None def test_close_and_execute(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.execute("select * from SYS.SYSTABLES") def test_close_and_fetchone(derby): cur = derby.cursor() cur.execute("select * from SYS.SYSTABLES") cur.close() with pytest.raises(Error): cur.fetchone() def test_close_twice(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.close() <|fim▁end|>
derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") # Verify table is empty. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 0 # Insert one with parameter binding.. sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" cur.execute(sql, (12, "m")) # Verify there's 1 row. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 1 # Insert a bunch. params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == len("thecowsaremooing") + 1 derby.rollback() derby.autocommit = True
<|file_name|>test_Cursor.py<|end_file_name|><|fim▁begin|>import pytest from py4jdbc.dbapi2 import connect, Connection from py4jdbc.resultset import ResultSet from py4jdbc.exceptions.dbapi2 import Error def test_connect(gateway): url = "jdbc:derby:memory:testdb;create=true" conn = connect(url, gateway=gateway) cur = conn.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute_with_params(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") # Verify table is empty. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 0 # Insert one with parameter binding.. sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" cur.execute(sql, (12, "m")) # Verify there's 1 row. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 1 # Insert a bunch. params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == len("thecowsaremooing") + 1 derby.rollback() derby.autocommit = True def test_fetchone(derby): <|fim_middle|> def test_fetchmany(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchmany(5)}) def test_fetchManyCount(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rs = cur.execute("select a from x_with_params.cowtest") ress = [] while True: x = rs.fetchmany(3) ress.append(x) if len(x) < 3: break derby.rollback() derby.autocommit = True assert sum(map(len, ress)) == len("thecowsaremooing") def test_fetchall(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchall()}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") # Exhaust all rows. list(rs) assert rs.fetchone() == None def test_close_and_execute(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.execute("select * from SYS.SYSTABLES") def test_close_and_fetchone(derby): cur = derby.cursor() cur.execute("select * from SYS.SYSTABLES") cur.close() with pytest.raises(Error): cur.fetchone() def test_close_twice(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.close() <|fim▁end|>
cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs.fetchone(), rs.Row)
<|file_name|>test_Cursor.py<|end_file_name|><|fim▁begin|>import pytest from py4jdbc.dbapi2 import connect, Connection from py4jdbc.resultset import ResultSet from py4jdbc.exceptions.dbapi2 import Error def test_connect(gateway): url = "jdbc:derby:memory:testdb;create=true" conn = connect(url, gateway=gateway) cur = conn.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute_with_params(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") # Verify table is empty. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 0 # Insert one with parameter binding.. sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" cur.execute(sql, (12, "m")) # Verify there's 1 row. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 1 # Insert a bunch. params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == len("thecowsaremooing") + 1 derby.rollback() derby.autocommit = True def test_fetchone(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs.fetchone(), rs.Row) def test_fetchmany(derby): <|fim_middle|> def test_fetchManyCount(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rs = cur.execute("select a from x_with_params.cowtest") ress = [] while True: x = rs.fetchmany(3) ress.append(x) if len(x) < 3: break derby.rollback() derby.autocommit = True assert sum(map(len, ress)) == len("thecowsaremooing") def test_fetchall(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchall()}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") # Exhaust all rows. list(rs) assert rs.fetchone() == None def test_close_and_execute(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.execute("select * from SYS.SYSTABLES") def test_close_and_fetchone(derby): cur = derby.cursor() cur.execute("select * from SYS.SYSTABLES") cur.close() with pytest.raises(Error): cur.fetchone() def test_close_twice(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.close() <|fim▁end|>
'''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchmany(5)})
<|file_name|>test_Cursor.py<|end_file_name|><|fim▁begin|>import pytest from py4jdbc.dbapi2 import connect, Connection from py4jdbc.resultset import ResultSet from py4jdbc.exceptions.dbapi2 import Error def test_connect(gateway): url = "jdbc:derby:memory:testdb;create=true" conn = connect(url, gateway=gateway) cur = conn.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute_with_params(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") # Verify table is empty. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 0 # Insert one with parameter binding.. sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" cur.execute(sql, (12, "m")) # Verify there's 1 row. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 1 # Insert a bunch. params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == len("thecowsaremooing") + 1 derby.rollback() derby.autocommit = True def test_fetchone(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs.fetchone(), rs.Row) def test_fetchmany(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchmany(5)}) def test_fetchManyCount(derby): <|fim_middle|> def test_fetchall(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchall()}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") # Exhaust all rows. list(rs) assert rs.fetchone() == None def test_close_and_execute(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.execute("select * from SYS.SYSTABLES") def test_close_and_fetchone(derby): cur = derby.cursor() cur.execute("select * from SYS.SYSTABLES") cur.close() with pytest.raises(Error): cur.fetchone() def test_close_twice(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.close() <|fim▁end|>
derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rs = cur.execute("select a from x_with_params.cowtest") ress = [] while True: x = rs.fetchmany(3) ress.append(x) if len(x) < 3: break derby.rollback() derby.autocommit = True assert sum(map(len, ress)) == len("thecowsaremooing")
<|file_name|>test_Cursor.py<|end_file_name|><|fim▁begin|>import pytest from py4jdbc.dbapi2 import connect, Connection from py4jdbc.resultset import ResultSet from py4jdbc.exceptions.dbapi2 import Error def test_connect(gateway): url = "jdbc:derby:memory:testdb;create=true" conn = connect(url, gateway=gateway) cur = conn.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute_with_params(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") # Verify table is empty. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 0 # Insert one with parameter binding.. sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" cur.execute(sql, (12, "m")) # Verify there's 1 row. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 1 # Insert a bunch. params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == len("thecowsaremooing") + 1 derby.rollback() derby.autocommit = True def test_fetchone(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs.fetchone(), rs.Row) def test_fetchmany(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchmany(5)}) def test_fetchManyCount(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rs = cur.execute("select a from x_with_params.cowtest") ress = [] while True: x = rs.fetchmany(3) ress.append(x) if len(x) < 3: break derby.rollback() derby.autocommit = True assert sum(map(len, ress)) == len("thecowsaremooing") def test_fetchall(derby): <|fim_middle|> def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") # Exhaust all rows. list(rs) assert rs.fetchone() == None def test_close_and_execute(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.execute("select * from SYS.SYSTABLES") def test_close_and_fetchone(derby): cur = derby.cursor() cur.execute("select * from SYS.SYSTABLES") cur.close() with pytest.raises(Error): cur.fetchone() def test_close_twice(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.close() <|fim▁end|>
'''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchall()})
<|file_name|>test_Cursor.py<|end_file_name|><|fim▁begin|>import pytest from py4jdbc.dbapi2 import connect, Connection from py4jdbc.resultset import ResultSet from py4jdbc.exceptions.dbapi2 import Error def test_connect(gateway): url = "jdbc:derby:memory:testdb;create=true" conn = connect(url, gateway=gateway) cur = conn.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute_with_params(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") # Verify table is empty. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 0 # Insert one with parameter binding.. sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" cur.execute(sql, (12, "m")) # Verify there's 1 row. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 1 # Insert a bunch. params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == len("thecowsaremooing") + 1 derby.rollback() derby.autocommit = True def test_fetchone(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs.fetchone(), rs.Row) def test_fetchmany(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchmany(5)}) def test_fetchManyCount(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rs = cur.execute("select a from x_with_params.cowtest") ress = [] while True: x = rs.fetchmany(3) ress.append(x) if len(x) < 3: break derby.rollback() derby.autocommit = True assert sum(map(len, ress)) == len("thecowsaremooing") def test_fetchall(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchall()}) def test_Cursor__iter__(derby): <|fim_middle|> def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") # Exhaust all rows. list(rs) assert rs.fetchone() == None def test_close_and_execute(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.execute("select * from SYS.SYSTABLES") def test_close_and_fetchone(derby): cur = derby.cursor() cur.execute("select * from SYS.SYSTABLES") cur.close() with pytest.raises(Error): cur.fetchone() def test_close_twice(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.close() <|fim▁end|>
cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs})
<|file_name|>test_Cursor.py<|end_file_name|><|fim▁begin|>import pytest from py4jdbc.dbapi2 import connect, Connection from py4jdbc.resultset import ResultSet from py4jdbc.exceptions.dbapi2 import Error def test_connect(gateway): url = "jdbc:derby:memory:testdb;create=true" conn = connect(url, gateway=gateway) cur = conn.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute_with_params(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") # Verify table is empty. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 0 # Insert one with parameter binding.. sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" cur.execute(sql, (12, "m")) # Verify there's 1 row. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 1 # Insert a bunch. params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == len("thecowsaremooing") + 1 derby.rollback() derby.autocommit = True def test_fetchone(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs.fetchone(), rs.Row) def test_fetchmany(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchmany(5)}) def test_fetchManyCount(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rs = cur.execute("select a from x_with_params.cowtest") ress = [] while True: x = rs.fetchmany(3) ress.append(x) if len(x) < 3: break derby.rollback() derby.autocommit = True assert sum(map(len, ress)) == len("thecowsaremooing") def test_fetchall(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchall()}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs}) def test_Cursor__iter__(derby): <|fim_middle|> def test_close_and_execute(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.execute("select * from SYS.SYSTABLES") def test_close_and_fetchone(derby): cur = derby.cursor() cur.execute("select * from SYS.SYSTABLES") cur.close() with pytest.raises(Error): cur.fetchone() def test_close_twice(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.close() <|fim▁end|>
cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") # Exhaust all rows. list(rs) assert rs.fetchone() == None
<|file_name|>test_Cursor.py<|end_file_name|><|fim▁begin|>import pytest from py4jdbc.dbapi2 import connect, Connection from py4jdbc.resultset import ResultSet from py4jdbc.exceptions.dbapi2 import Error def test_connect(gateway): url = "jdbc:derby:memory:testdb;create=true" conn = connect(url, gateway=gateway) cur = conn.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute_with_params(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") # Verify table is empty. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 0 # Insert one with parameter binding.. sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" cur.execute(sql, (12, "m")) # Verify there's 1 row. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 1 # Insert a bunch. params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == len("thecowsaremooing") + 1 derby.rollback() derby.autocommit = True def test_fetchone(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs.fetchone(), rs.Row) def test_fetchmany(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchmany(5)}) def test_fetchManyCount(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rs = cur.execute("select a from x_with_params.cowtest") ress = [] while True: x = rs.fetchmany(3) ress.append(x) if len(x) < 3: break derby.rollback() derby.autocommit = True assert sum(map(len, ress)) == len("thecowsaremooing") def test_fetchall(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchall()}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") # Exhaust all rows. list(rs) assert rs.fetchone() == None def test_close_and_execute(derby): <|fim_middle|> def test_close_and_fetchone(derby): cur = derby.cursor() cur.execute("select * from SYS.SYSTABLES") cur.close() with pytest.raises(Error): cur.fetchone() def test_close_twice(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.close() <|fim▁end|>
cur = derby.cursor() cur.close() with pytest.raises(Error): cur.execute("select * from SYS.SYSTABLES")
<|file_name|>test_Cursor.py<|end_file_name|><|fim▁begin|>import pytest from py4jdbc.dbapi2 import connect, Connection from py4jdbc.resultset import ResultSet from py4jdbc.exceptions.dbapi2 import Error def test_connect(gateway): url = "jdbc:derby:memory:testdb;create=true" conn = connect(url, gateway=gateway) cur = conn.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute_with_params(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") # Verify table is empty. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 0 # Insert one with parameter binding.. sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" cur.execute(sql, (12, "m")) # Verify there's 1 row. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 1 # Insert a bunch. params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == len("thecowsaremooing") + 1 derby.rollback() derby.autocommit = True def test_fetchone(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs.fetchone(), rs.Row) def test_fetchmany(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchmany(5)}) def test_fetchManyCount(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rs = cur.execute("select a from x_with_params.cowtest") ress = [] while True: x = rs.fetchmany(3) ress.append(x) if len(x) < 3: break derby.rollback() derby.autocommit = True assert sum(map(len, ress)) == len("thecowsaremooing") def test_fetchall(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchall()}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") # Exhaust all rows. list(rs) assert rs.fetchone() == None def test_close_and_execute(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.execute("select * from SYS.SYSTABLES") def test_close_and_fetchone(derby): <|fim_middle|> def test_close_twice(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.close() <|fim▁end|>
cur = derby.cursor() cur.execute("select * from SYS.SYSTABLES") cur.close() with pytest.raises(Error): cur.fetchone()
<|file_name|>test_Cursor.py<|end_file_name|><|fim▁begin|>import pytest from py4jdbc.dbapi2 import connect, Connection from py4jdbc.resultset import ResultSet from py4jdbc.exceptions.dbapi2 import Error def test_connect(gateway): url = "jdbc:derby:memory:testdb;create=true" conn = connect(url, gateway=gateway) cur = conn.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute_with_params(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") # Verify table is empty. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 0 # Insert one with parameter binding.. sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" cur.execute(sql, (12, "m")) # Verify there's 1 row. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 1 # Insert a bunch. params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == len("thecowsaremooing") + 1 derby.rollback() derby.autocommit = True def test_fetchone(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs.fetchone(), rs.Row) def test_fetchmany(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchmany(5)}) def test_fetchManyCount(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rs = cur.execute("select a from x_with_params.cowtest") ress = [] while True: x = rs.fetchmany(3) ress.append(x) if len(x) < 3: break derby.rollback() derby.autocommit = True assert sum(map(len, ress)) == len("thecowsaremooing") def test_fetchall(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchall()}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") # Exhaust all rows. list(rs) assert rs.fetchone() == None def test_close_and_execute(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.execute("select * from SYS.SYSTABLES") def test_close_and_fetchone(derby): cur = derby.cursor() cur.execute("select * from SYS.SYSTABLES") cur.close() with pytest.raises(Error): cur.fetchone() def test_close_twice(derby): <|fim_middle|> <|fim▁end|>
cur = derby.cursor() cur.close() with pytest.raises(Error): cur.close()
<|file_name|>test_Cursor.py<|end_file_name|><|fim▁begin|>import pytest from py4jdbc.dbapi2 import connect, Connection from py4jdbc.resultset import ResultSet from py4jdbc.exceptions.dbapi2 import Error def test_connect(gateway): url = "jdbc:derby:memory:testdb;create=true" conn = connect(url, gateway=gateway) cur = conn.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute_with_params(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") # Verify table is empty. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 0 # Insert one with parameter binding.. sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" cur.execute(sql, (12, "m")) # Verify there's 1 row. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 1 # Insert a bunch. params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == len("thecowsaremooing") + 1 derby.rollback() derby.autocommit = True def test_fetchone(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs.fetchone(), rs.Row) def test_fetchmany(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchmany(5)}) def test_fetchManyCount(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rs = cur.execute("select a from x_with_params.cowtest") ress = [] while True: x = rs.fetchmany(3) ress.append(x) if len(x) < 3: <|fim_middle|> derby.rollback() derby.autocommit = True assert sum(map(len, ress)) == len("thecowsaremooing") def test_fetchall(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchall()}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") # Exhaust all rows. list(rs) assert rs.fetchone() == None def test_close_and_execute(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.execute("select * from SYS.SYSTABLES") def test_close_and_fetchone(derby): cur = derby.cursor() cur.execute("select * from SYS.SYSTABLES") cur.close() with pytest.raises(Error): cur.fetchone() def test_close_twice(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.close() <|fim▁end|>
break
<|file_name|>test_Cursor.py<|end_file_name|><|fim▁begin|>import pytest from py4jdbc.dbapi2 import connect, Connection from py4jdbc.resultset import ResultSet from py4jdbc.exceptions.dbapi2 import Error def <|fim_middle|>(gateway): url = "jdbc:derby:memory:testdb;create=true" conn = connect(url, gateway=gateway) cur = conn.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute_with_params(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") # Verify table is empty. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 0 # Insert one with parameter binding.. sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" cur.execute(sql, (12, "m")) # Verify there's 1 row. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 1 # Insert a bunch. params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == len("thecowsaremooing") + 1 derby.rollback() derby.autocommit = True def test_fetchone(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs.fetchone(), rs.Row) def test_fetchmany(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchmany(5)}) def test_fetchManyCount(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rs = cur.execute("select a from x_with_params.cowtest") ress = [] while True: x = rs.fetchmany(3) ress.append(x) if len(x) < 3: break derby.rollback() derby.autocommit = True assert sum(map(len, ress)) == len("thecowsaremooing") def test_fetchall(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchall()}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") # Exhaust all rows. list(rs) assert rs.fetchone() == None def test_close_and_execute(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.execute("select * from SYS.SYSTABLES") def test_close_and_fetchone(derby): cur = derby.cursor() cur.execute("select * from SYS.SYSTABLES") cur.close() with pytest.raises(Error): cur.fetchone() def test_close_twice(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.close() <|fim▁end|>
test_connect
<|file_name|>test_Cursor.py<|end_file_name|><|fim▁begin|>import pytest from py4jdbc.dbapi2 import connect, Connection from py4jdbc.resultset import ResultSet from py4jdbc.exceptions.dbapi2 import Error def test_connect(gateway): url = "jdbc:derby:memory:testdb;create=true" conn = connect(url, gateway=gateway) cur = conn.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def <|fim_middle|>(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute_with_params(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") # Verify table is empty. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 0 # Insert one with parameter binding.. sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" cur.execute(sql, (12, "m")) # Verify there's 1 row. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 1 # Insert a bunch. params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == len("thecowsaremooing") + 1 derby.rollback() derby.autocommit = True def test_fetchone(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs.fetchone(), rs.Row) def test_fetchmany(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchmany(5)}) def test_fetchManyCount(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rs = cur.execute("select a from x_with_params.cowtest") ress = [] while True: x = rs.fetchmany(3) ress.append(x) if len(x) < 3: break derby.rollback() derby.autocommit = True assert sum(map(len, ress)) == len("thecowsaremooing") def test_fetchall(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchall()}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") # Exhaust all rows. list(rs) assert rs.fetchone() == None def test_close_and_execute(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.execute("select * from SYS.SYSTABLES") def test_close_and_fetchone(derby): cur = derby.cursor() cur.execute("select * from SYS.SYSTABLES") cur.close() with pytest.raises(Error): cur.fetchone() def test_close_twice(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.close() <|fim▁end|>
test_execute
<|file_name|>test_Cursor.py<|end_file_name|><|fim▁begin|>import pytest from py4jdbc.dbapi2 import connect, Connection from py4jdbc.resultset import ResultSet from py4jdbc.exceptions.dbapi2 import Error def test_connect(gateway): url = "jdbc:derby:memory:testdb;create=true" conn = connect(url, gateway=gateway) cur = conn.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def <|fim_middle|>(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") # Verify table is empty. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 0 # Insert one with parameter binding.. sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" cur.execute(sql, (12, "m")) # Verify there's 1 row. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 1 # Insert a bunch. params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == len("thecowsaremooing") + 1 derby.rollback() derby.autocommit = True def test_fetchone(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs.fetchone(), rs.Row) def test_fetchmany(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchmany(5)}) def test_fetchManyCount(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rs = cur.execute("select a from x_with_params.cowtest") ress = [] while True: x = rs.fetchmany(3) ress.append(x) if len(x) < 3: break derby.rollback() derby.autocommit = True assert sum(map(len, ress)) == len("thecowsaremooing") def test_fetchall(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchall()}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") # Exhaust all rows. list(rs) assert rs.fetchone() == None def test_close_and_execute(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.execute("select * from SYS.SYSTABLES") def test_close_and_fetchone(derby): cur = derby.cursor() cur.execute("select * from SYS.SYSTABLES") cur.close() with pytest.raises(Error): cur.fetchone() def test_close_twice(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.close() <|fim▁end|>
test_execute_with_params
<|file_name|>test_Cursor.py<|end_file_name|><|fim▁begin|>import pytest from py4jdbc.dbapi2 import connect, Connection from py4jdbc.resultset import ResultSet from py4jdbc.exceptions.dbapi2 import Error def test_connect(gateway): url = "jdbc:derby:memory:testdb;create=true" conn = connect(url, gateway=gateway) cur = conn.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute_with_params(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") # Verify table is empty. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 0 # Insert one with parameter binding.. sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" cur.execute(sql, (12, "m")) # Verify there's 1 row. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 1 # Insert a bunch. params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == len("thecowsaremooing") + 1 derby.rollback() derby.autocommit = True def <|fim_middle|>(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs.fetchone(), rs.Row) def test_fetchmany(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchmany(5)}) def test_fetchManyCount(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rs = cur.execute("select a from x_with_params.cowtest") ress = [] while True: x = rs.fetchmany(3) ress.append(x) if len(x) < 3: break derby.rollback() derby.autocommit = True assert sum(map(len, ress)) == len("thecowsaremooing") def test_fetchall(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchall()}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") # Exhaust all rows. list(rs) assert rs.fetchone() == None def test_close_and_execute(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.execute("select * from SYS.SYSTABLES") def test_close_and_fetchone(derby): cur = derby.cursor() cur.execute("select * from SYS.SYSTABLES") cur.close() with pytest.raises(Error): cur.fetchone() def test_close_twice(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.close() <|fim▁end|>
test_fetchone
<|file_name|>test_Cursor.py<|end_file_name|><|fim▁begin|>import pytest from py4jdbc.dbapi2 import connect, Connection from py4jdbc.resultset import ResultSet from py4jdbc.exceptions.dbapi2 import Error def test_connect(gateway): url = "jdbc:derby:memory:testdb;create=true" conn = connect(url, gateway=gateway) cur = conn.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute_with_params(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") # Verify table is empty. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 0 # Insert one with parameter binding.. sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" cur.execute(sql, (12, "m")) # Verify there's 1 row. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 1 # Insert a bunch. params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == len("thecowsaremooing") + 1 derby.rollback() derby.autocommit = True def test_fetchone(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs.fetchone(), rs.Row) def <|fim_middle|>(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchmany(5)}) def test_fetchManyCount(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rs = cur.execute("select a from x_with_params.cowtest") ress = [] while True: x = rs.fetchmany(3) ress.append(x) if len(x) < 3: break derby.rollback() derby.autocommit = True assert sum(map(len, ress)) == len("thecowsaremooing") def test_fetchall(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchall()}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") # Exhaust all rows. list(rs) assert rs.fetchone() == None def test_close_and_execute(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.execute("select * from SYS.SYSTABLES") def test_close_and_fetchone(derby): cur = derby.cursor() cur.execute("select * from SYS.SYSTABLES") cur.close() with pytest.raises(Error): cur.fetchone() def test_close_twice(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.close() <|fim▁end|>
test_fetchmany
<|file_name|>test_Cursor.py<|end_file_name|><|fim▁begin|>import pytest from py4jdbc.dbapi2 import connect, Connection from py4jdbc.resultset import ResultSet from py4jdbc.exceptions.dbapi2 import Error def test_connect(gateway): url = "jdbc:derby:memory:testdb;create=true" conn = connect(url, gateway=gateway) cur = conn.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute_with_params(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") # Verify table is empty. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 0 # Insert one with parameter binding.. sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" cur.execute(sql, (12, "m")) # Verify there's 1 row. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 1 # Insert a bunch. params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == len("thecowsaremooing") + 1 derby.rollback() derby.autocommit = True def test_fetchone(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs.fetchone(), rs.Row) def test_fetchmany(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchmany(5)}) def <|fim_middle|>(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rs = cur.execute("select a from x_with_params.cowtest") ress = [] while True: x = rs.fetchmany(3) ress.append(x) if len(x) < 3: break derby.rollback() derby.autocommit = True assert sum(map(len, ress)) == len("thecowsaremooing") def test_fetchall(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchall()}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") # Exhaust all rows. list(rs) assert rs.fetchone() == None def test_close_and_execute(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.execute("select * from SYS.SYSTABLES") def test_close_and_fetchone(derby): cur = derby.cursor() cur.execute("select * from SYS.SYSTABLES") cur.close() with pytest.raises(Error): cur.fetchone() def test_close_twice(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.close() <|fim▁end|>
test_fetchManyCount
<|file_name|>test_Cursor.py<|end_file_name|><|fim▁begin|>import pytest from py4jdbc.dbapi2 import connect, Connection from py4jdbc.resultset import ResultSet from py4jdbc.exceptions.dbapi2 import Error def test_connect(gateway): url = "jdbc:derby:memory:testdb;create=true" conn = connect(url, gateway=gateway) cur = conn.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute_with_params(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") # Verify table is empty. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 0 # Insert one with parameter binding.. sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" cur.execute(sql, (12, "m")) # Verify there's 1 row. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 1 # Insert a bunch. params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == len("thecowsaremooing") + 1 derby.rollback() derby.autocommit = True def test_fetchone(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs.fetchone(), rs.Row) def test_fetchmany(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchmany(5)}) def test_fetchManyCount(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rs = cur.execute("select a from x_with_params.cowtest") ress = [] while True: x = rs.fetchmany(3) ress.append(x) if len(x) < 3: break derby.rollback() derby.autocommit = True assert sum(map(len, ress)) == len("thecowsaremooing") def <|fim_middle|>(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchall()}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") # Exhaust all rows. list(rs) assert rs.fetchone() == None def test_close_and_execute(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.execute("select * from SYS.SYSTABLES") def test_close_and_fetchone(derby): cur = derby.cursor() cur.execute("select * from SYS.SYSTABLES") cur.close() with pytest.raises(Error): cur.fetchone() def test_close_twice(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.close() <|fim▁end|>
test_fetchall
<|file_name|>test_Cursor.py<|end_file_name|><|fim▁begin|>import pytest from py4jdbc.dbapi2 import connect, Connection from py4jdbc.resultset import ResultSet from py4jdbc.exceptions.dbapi2 import Error def test_connect(gateway): url = "jdbc:derby:memory:testdb;create=true" conn = connect(url, gateway=gateway) cur = conn.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute_with_params(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") # Verify table is empty. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 0 # Insert one with parameter binding.. sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" cur.execute(sql, (12, "m")) # Verify there's 1 row. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 1 # Insert a bunch. params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == len("thecowsaremooing") + 1 derby.rollback() derby.autocommit = True def test_fetchone(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs.fetchone(), rs.Row) def test_fetchmany(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchmany(5)}) def test_fetchManyCount(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rs = cur.execute("select a from x_with_params.cowtest") ress = [] while True: x = rs.fetchmany(3) ress.append(x) if len(x) < 3: break derby.rollback() derby.autocommit = True assert sum(map(len, ress)) == len("thecowsaremooing") def test_fetchall(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchall()}) def <|fim_middle|>(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") # Exhaust all rows. list(rs) assert rs.fetchone() == None def test_close_and_execute(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.execute("select * from SYS.SYSTABLES") def test_close_and_fetchone(derby): cur = derby.cursor() cur.execute("select * from SYS.SYSTABLES") cur.close() with pytest.raises(Error): cur.fetchone() def test_close_twice(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.close() <|fim▁end|>
test_Cursor__iter__
<|file_name|>test_Cursor.py<|end_file_name|><|fim▁begin|>import pytest from py4jdbc.dbapi2 import connect, Connection from py4jdbc.resultset import ResultSet from py4jdbc.exceptions.dbapi2 import Error def test_connect(gateway): url = "jdbc:derby:memory:testdb;create=true" conn = connect(url, gateway=gateway) cur = conn.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute_with_params(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") # Verify table is empty. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 0 # Insert one with parameter binding.. sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" cur.execute(sql, (12, "m")) # Verify there's 1 row. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 1 # Insert a bunch. params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == len("thecowsaremooing") + 1 derby.rollback() derby.autocommit = True def test_fetchone(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs.fetchone(), rs.Row) def test_fetchmany(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchmany(5)}) def test_fetchManyCount(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rs = cur.execute("select a from x_with_params.cowtest") ress = [] while True: x = rs.fetchmany(3) ress.append(x) if len(x) < 3: break derby.rollback() derby.autocommit = True assert sum(map(len, ress)) == len("thecowsaremooing") def test_fetchall(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchall()}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs}) def <|fim_middle|>(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") # Exhaust all rows. list(rs) assert rs.fetchone() == None def test_close_and_execute(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.execute("select * from SYS.SYSTABLES") def test_close_and_fetchone(derby): cur = derby.cursor() cur.execute("select * from SYS.SYSTABLES") cur.close() with pytest.raises(Error): cur.fetchone() def test_close_twice(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.close() <|fim▁end|>
test_Cursor__iter__
<|file_name|>test_Cursor.py<|end_file_name|><|fim▁begin|>import pytest from py4jdbc.dbapi2 import connect, Connection from py4jdbc.resultset import ResultSet from py4jdbc.exceptions.dbapi2 import Error def test_connect(gateway): url = "jdbc:derby:memory:testdb;create=true" conn = connect(url, gateway=gateway) cur = conn.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute_with_params(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") # Verify table is empty. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 0 # Insert one with parameter binding.. sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" cur.execute(sql, (12, "m")) # Verify there's 1 row. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 1 # Insert a bunch. params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == len("thecowsaremooing") + 1 derby.rollback() derby.autocommit = True def test_fetchone(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs.fetchone(), rs.Row) def test_fetchmany(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchmany(5)}) def test_fetchManyCount(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rs = cur.execute("select a from x_with_params.cowtest") ress = [] while True: x = rs.fetchmany(3) ress.append(x) if len(x) < 3: break derby.rollback() derby.autocommit = True assert sum(map(len, ress)) == len("thecowsaremooing") def test_fetchall(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchall()}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") # Exhaust all rows. list(rs) assert rs.fetchone() == None def <|fim_middle|>(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.execute("select * from SYS.SYSTABLES") def test_close_and_fetchone(derby): cur = derby.cursor() cur.execute("select * from SYS.SYSTABLES") cur.close() with pytest.raises(Error): cur.fetchone() def test_close_twice(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.close() <|fim▁end|>
test_close_and_execute
<|file_name|>test_Cursor.py<|end_file_name|><|fim▁begin|>import pytest from py4jdbc.dbapi2 import connect, Connection from py4jdbc.resultset import ResultSet from py4jdbc.exceptions.dbapi2 import Error def test_connect(gateway): url = "jdbc:derby:memory:testdb;create=true" conn = connect(url, gateway=gateway) cur = conn.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute_with_params(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") # Verify table is empty. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 0 # Insert one with parameter binding.. sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" cur.execute(sql, (12, "m")) # Verify there's 1 row. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 1 # Insert a bunch. params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == len("thecowsaremooing") + 1 derby.rollback() derby.autocommit = True def test_fetchone(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs.fetchone(), rs.Row) def test_fetchmany(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchmany(5)}) def test_fetchManyCount(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rs = cur.execute("select a from x_with_params.cowtest") ress = [] while True: x = rs.fetchmany(3) ress.append(x) if len(x) < 3: break derby.rollback() derby.autocommit = True assert sum(map(len, ress)) == len("thecowsaremooing") def test_fetchall(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchall()}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") # Exhaust all rows. list(rs) assert rs.fetchone() == None def test_close_and_execute(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.execute("select * from SYS.SYSTABLES") def <|fim_middle|>(derby): cur = derby.cursor() cur.execute("select * from SYS.SYSTABLES") cur.close() with pytest.raises(Error): cur.fetchone() def test_close_twice(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.close() <|fim▁end|>
test_close_and_fetchone
<|file_name|>test_Cursor.py<|end_file_name|><|fim▁begin|>import pytest from py4jdbc.dbapi2 import connect, Connection from py4jdbc.resultset import ResultSet from py4jdbc.exceptions.dbapi2 import Error def test_connect(gateway): url = "jdbc:derby:memory:testdb;create=true" conn = connect(url, gateway=gateway) cur = conn.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs, ResultSet) def test_execute_with_params(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") # Verify table is empty. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 0 # Insert one with parameter binding.. sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" cur.execute(sql, (12, "m")) # Verify there's 1 row. rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == 1 # Insert a bunch. params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rows = cur.execute("select * from x_with_params.cowtest as r").fetchall() assert len(rows) == len("thecowsaremooing") + 1 derby.rollback() derby.autocommit = True def test_fetchone(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert isinstance(rs.fetchone(), rs.Row) def test_fetchmany(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchmany(5)}) def test_fetchManyCount(derby): derby.autocommit = False cur = derby.cursor() cur.execute("create schema x_with_params") cur.execute("create table x_with_params.cowtest(a int, b char(1))") sql = "insert into x_with_params.cowtest (a, b) values (?, ?)" params = list(enumerate("thecowsaremooing")) cur.executemany(sql, params) rs = cur.execute("select a from x_with_params.cowtest") ress = [] while True: x = rs.fetchmany(3) ress.append(x) if len(x) < 3: break derby.rollback() derby.autocommit = True assert sum(map(len, ress)) == len("thecowsaremooing") def test_fetchall(derby): '''Assert all rows of result set have the correct class. ''' cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs.fetchall()}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") assert all({isinstance(row, rs.Row) for row in rs}) def test_Cursor__iter__(derby): cur = derby.cursor() rs = cur.execute("select * from SYS.SYSTABLES") # Exhaust all rows. list(rs) assert rs.fetchone() == None def test_close_and_execute(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.execute("select * from SYS.SYSTABLES") def test_close_and_fetchone(derby): cur = derby.cursor() cur.execute("select * from SYS.SYSTABLES") cur.close() with pytest.raises(Error): cur.fetchone() def <|fim_middle|>(derby): cur = derby.cursor() cur.close() with pytest.raises(Error): cur.close() <|fim▁end|>
test_close_twice
<|file_name|>scan.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # @Author: yancz1989 # @Date: 2017-01-17 23:43:18 # @Last Modified by: yancz1989 # @Last Modified time: 2017-02-22 20:33:29 import utilities as util from utilities import parse_image_file, filterBoxes, voxel_2_world, mkdir import numpy as np import os import json import sys from PIL import Image, ImageDraw import SimpleITK as sitk from env import * def generate_scan_image(subset): list_dirs = os.walk(TRUNK_DIR + subset) jsobjs = [] output_dir = SAMPLE_DIR + subset mkdir(output_dir) for root, dirs, files in list_dirs: for f in files: if f.lower().endswith('mhd'): key = os.path.splitext(f)[0] numpyImage, numpyOrigin, numpySpacing = ( util.load_itk_image( os.path.join(root, f))) for z in range(numpyImage.shape[0]): patch = numpyImage[z, 0:512, 0:512] patch = util.normalizePlanes(patch) im = Image.fromarray(patch * 255).convert('L') output_filename = ( subset + "-" + key + "-" + str(z) + "-scan.bmp") print(subset + '/' + output_filename) im.save(os.path.join( output_dir, output_filename)) jsobjs.append({ "image_path": subset + '/' + output_filename, "rects":[] } ) with open(META_DIR + subset + '-scan.json', 'w') as f: json.dump(jsobjs, f) def get_image_map(data_root, input_file, threshold): result_map = {} with open(input_file) as f: result_list = json.load(f) for it in result_list: key, subset, z = parse_image_file(it['file']) src_file = os.path.join( data_root, subset, key + ".mhd") boxes = filterBoxes(it['box'], threshold) if not result_map.get(src_file): result_map[src_file] = [] result_map[src_file].append((key, z, boxes)) return result_map def generate_result(result_map, output_file): with open(output_file) as fout: fout.write("seriesuid,coordX,coordY,coordZ,probability\n") for fkey, val in result_map.items(): itkimage = sitk.ReadImage(fkey) for it in val: key, z, boxes = val for box in boxes: world_box = voxel_2_world( [z, box[1], box[0]], itkimage) csv_line = key + "," + str(world_box[2]) + "," + str(world_box[1]) + "," + str(world_box[0]) + "," + str(box[4]) fout.write(csv_line + "\n") if __name__ == '__main__': if sys.argv[1] == 'gen':<|fim▁hole|> else: result_map = get_image_map(TRUNK_DIR, sys.argv[2], 0.01) generate_result(result_map, OUTPUT_FILE)<|fim▁end|>
generate_scan_image(sys.argv[2])
<|file_name|>scan.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # @Author: yancz1989 # @Date: 2017-01-17 23:43:18 # @Last Modified by: yancz1989 # @Last Modified time: 2017-02-22 20:33:29 import utilities as util from utilities import parse_image_file, filterBoxes, voxel_2_world, mkdir import numpy as np import os import json import sys from PIL import Image, ImageDraw import SimpleITK as sitk from env import * def generate_scan_image(subset): <|fim_middle|> def get_image_map(data_root, input_file, threshold): result_map = {} with open(input_file) as f: result_list = json.load(f) for it in result_list: key, subset, z = parse_image_file(it['file']) src_file = os.path.join( data_root, subset, key + ".mhd") boxes = filterBoxes(it['box'], threshold) if not result_map.get(src_file): result_map[src_file] = [] result_map[src_file].append((key, z, boxes)) return result_map def generate_result(result_map, output_file): with open(output_file) as fout: fout.write("seriesuid,coordX,coordY,coordZ,probability\n") for fkey, val in result_map.items(): itkimage = sitk.ReadImage(fkey) for it in val: key, z, boxes = val for box in boxes: world_box = voxel_2_world( [z, box[1], box[0]], itkimage) csv_line = key + "," + str(world_box[2]) + "," + str(world_box[1]) + "," + str(world_box[0]) + "," + str(box[4]) fout.write(csv_line + "\n") if __name__ == '__main__': if sys.argv[1] == 'gen': generate_scan_image(sys.argv[2]) else: result_map = get_image_map(TRUNK_DIR, sys.argv[2], 0.01) generate_result(result_map, OUTPUT_FILE)<|fim▁end|>
list_dirs = os.walk(TRUNK_DIR + subset) jsobjs = [] output_dir = SAMPLE_DIR + subset mkdir(output_dir) for root, dirs, files in list_dirs: for f in files: if f.lower().endswith('mhd'): key = os.path.splitext(f)[0] numpyImage, numpyOrigin, numpySpacing = ( util.load_itk_image( os.path.join(root, f))) for z in range(numpyImage.shape[0]): patch = numpyImage[z, 0:512, 0:512] patch = util.normalizePlanes(patch) im = Image.fromarray(patch * 255).convert('L') output_filename = ( subset + "-" + key + "-" + str(z) + "-scan.bmp") print(subset + '/' + output_filename) im.save(os.path.join( output_dir, output_filename)) jsobjs.append({ "image_path": subset + '/' + output_filename, "rects":[] } ) with open(META_DIR + subset + '-scan.json', 'w') as f: json.dump(jsobjs, f)
<|file_name|>scan.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # @Author: yancz1989 # @Date: 2017-01-17 23:43:18 # @Last Modified by: yancz1989 # @Last Modified time: 2017-02-22 20:33:29 import utilities as util from utilities import parse_image_file, filterBoxes, voxel_2_world, mkdir import numpy as np import os import json import sys from PIL import Image, ImageDraw import SimpleITK as sitk from env import * def generate_scan_image(subset): list_dirs = os.walk(TRUNK_DIR + subset) jsobjs = [] output_dir = SAMPLE_DIR + subset mkdir(output_dir) for root, dirs, files in list_dirs: for f in files: if f.lower().endswith('mhd'): key = os.path.splitext(f)[0] numpyImage, numpyOrigin, numpySpacing = ( util.load_itk_image( os.path.join(root, f))) for z in range(numpyImage.shape[0]): patch = numpyImage[z, 0:512, 0:512] patch = util.normalizePlanes(patch) im = Image.fromarray(patch * 255).convert('L') output_filename = ( subset + "-" + key + "-" + str(z) + "-scan.bmp") print(subset + '/' + output_filename) im.save(os.path.join( output_dir, output_filename)) jsobjs.append({ "image_path": subset + '/' + output_filename, "rects":[] } ) with open(META_DIR + subset + '-scan.json', 'w') as f: json.dump(jsobjs, f) def get_image_map(data_root, input_file, threshold): <|fim_middle|> def generate_result(result_map, output_file): with open(output_file) as fout: fout.write("seriesuid,coordX,coordY,coordZ,probability\n") for fkey, val in result_map.items(): itkimage = sitk.ReadImage(fkey) for it in val: key, z, boxes = val for box in boxes: world_box = voxel_2_world( [z, box[1], box[0]], itkimage) csv_line = key + "," + str(world_box[2]) + "," + str(world_box[1]) + "," + str(world_box[0]) + "," + str(box[4]) fout.write(csv_line + "\n") if __name__ == '__main__': if sys.argv[1] == 'gen': generate_scan_image(sys.argv[2]) else: result_map = get_image_map(TRUNK_DIR, sys.argv[2], 0.01) generate_result(result_map, OUTPUT_FILE)<|fim▁end|>
result_map = {} with open(input_file) as f: result_list = json.load(f) for it in result_list: key, subset, z = parse_image_file(it['file']) src_file = os.path.join( data_root, subset, key + ".mhd") boxes = filterBoxes(it['box'], threshold) if not result_map.get(src_file): result_map[src_file] = [] result_map[src_file].append((key, z, boxes)) return result_map
<|file_name|>scan.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # @Author: yancz1989 # @Date: 2017-01-17 23:43:18 # @Last Modified by: yancz1989 # @Last Modified time: 2017-02-22 20:33:29 import utilities as util from utilities import parse_image_file, filterBoxes, voxel_2_world, mkdir import numpy as np import os import json import sys from PIL import Image, ImageDraw import SimpleITK as sitk from env import * def generate_scan_image(subset): list_dirs = os.walk(TRUNK_DIR + subset) jsobjs = [] output_dir = SAMPLE_DIR + subset mkdir(output_dir) for root, dirs, files in list_dirs: for f in files: if f.lower().endswith('mhd'): key = os.path.splitext(f)[0] numpyImage, numpyOrigin, numpySpacing = ( util.load_itk_image( os.path.join(root, f))) for z in range(numpyImage.shape[0]): patch = numpyImage[z, 0:512, 0:512] patch = util.normalizePlanes(patch) im = Image.fromarray(patch * 255).convert('L') output_filename = ( subset + "-" + key + "-" + str(z) + "-scan.bmp") print(subset + '/' + output_filename) im.save(os.path.join( output_dir, output_filename)) jsobjs.append({ "image_path": subset + '/' + output_filename, "rects":[] } ) with open(META_DIR + subset + '-scan.json', 'w') as f: json.dump(jsobjs, f) def get_image_map(data_root, input_file, threshold): result_map = {} with open(input_file) as f: result_list = json.load(f) for it in result_list: key, subset, z = parse_image_file(it['file']) src_file = os.path.join( data_root, subset, key + ".mhd") boxes = filterBoxes(it['box'], threshold) if not result_map.get(src_file): result_map[src_file] = [] result_map[src_file].append((key, z, boxes)) return result_map def generate_result(result_map, output_file): <|fim_middle|> if __name__ == '__main__': if sys.argv[1] == 'gen': generate_scan_image(sys.argv[2]) else: result_map = get_image_map(TRUNK_DIR, sys.argv[2], 0.01) generate_result(result_map, OUTPUT_FILE)<|fim▁end|>
with open(output_file) as fout: fout.write("seriesuid,coordX,coordY,coordZ,probability\n") for fkey, val in result_map.items(): itkimage = sitk.ReadImage(fkey) for it in val: key, z, boxes = val for box in boxes: world_box = voxel_2_world( [z, box[1], box[0]], itkimage) csv_line = key + "," + str(world_box[2]) + "," + str(world_box[1]) + "," + str(world_box[0]) + "," + str(box[4]) fout.write(csv_line + "\n")
<|file_name|>scan.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # @Author: yancz1989 # @Date: 2017-01-17 23:43:18 # @Last Modified by: yancz1989 # @Last Modified time: 2017-02-22 20:33:29 import utilities as util from utilities import parse_image_file, filterBoxes, voxel_2_world, mkdir import numpy as np import os import json import sys from PIL import Image, ImageDraw import SimpleITK as sitk from env import * def generate_scan_image(subset): list_dirs = os.walk(TRUNK_DIR + subset) jsobjs = [] output_dir = SAMPLE_DIR + subset mkdir(output_dir) for root, dirs, files in list_dirs: for f in files: if f.lower().endswith('mhd'): <|fim_middle|> with open(META_DIR + subset + '-scan.json', 'w') as f: json.dump(jsobjs, f) def get_image_map(data_root, input_file, threshold): result_map = {} with open(input_file) as f: result_list = json.load(f) for it in result_list: key, subset, z = parse_image_file(it['file']) src_file = os.path.join( data_root, subset, key + ".mhd") boxes = filterBoxes(it['box'], threshold) if not result_map.get(src_file): result_map[src_file] = [] result_map[src_file].append((key, z, boxes)) return result_map def generate_result(result_map, output_file): with open(output_file) as fout: fout.write("seriesuid,coordX,coordY,coordZ,probability\n") for fkey, val in result_map.items(): itkimage = sitk.ReadImage(fkey) for it in val: key, z, boxes = val for box in boxes: world_box = voxel_2_world( [z, box[1], box[0]], itkimage) csv_line = key + "," + str(world_box[2]) + "," + str(world_box[1]) + "," + str(world_box[0]) + "," + str(box[4]) fout.write(csv_line + "\n") if __name__ == '__main__': if sys.argv[1] == 'gen': generate_scan_image(sys.argv[2]) else: result_map = get_image_map(TRUNK_DIR, sys.argv[2], 0.01) generate_result(result_map, OUTPUT_FILE)<|fim▁end|>
key = os.path.splitext(f)[0] numpyImage, numpyOrigin, numpySpacing = ( util.load_itk_image( os.path.join(root, f))) for z in range(numpyImage.shape[0]): patch = numpyImage[z, 0:512, 0:512] patch = util.normalizePlanes(patch) im = Image.fromarray(patch * 255).convert('L') output_filename = ( subset + "-" + key + "-" + str(z) + "-scan.bmp") print(subset + '/' + output_filename) im.save(os.path.join( output_dir, output_filename)) jsobjs.append({ "image_path": subset + '/' + output_filename, "rects":[] } )
<|file_name|>scan.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # @Author: yancz1989 # @Date: 2017-01-17 23:43:18 # @Last Modified by: yancz1989 # @Last Modified time: 2017-02-22 20:33:29 import utilities as util from utilities import parse_image_file, filterBoxes, voxel_2_world, mkdir import numpy as np import os import json import sys from PIL import Image, ImageDraw import SimpleITK as sitk from env import * def generate_scan_image(subset): list_dirs = os.walk(TRUNK_DIR + subset) jsobjs = [] output_dir = SAMPLE_DIR + subset mkdir(output_dir) for root, dirs, files in list_dirs: for f in files: if f.lower().endswith('mhd'): key = os.path.splitext(f)[0] numpyImage, numpyOrigin, numpySpacing = ( util.load_itk_image( os.path.join(root, f))) for z in range(numpyImage.shape[0]): patch = numpyImage[z, 0:512, 0:512] patch = util.normalizePlanes(patch) im = Image.fromarray(patch * 255).convert('L') output_filename = ( subset + "-" + key + "-" + str(z) + "-scan.bmp") print(subset + '/' + output_filename) im.save(os.path.join( output_dir, output_filename)) jsobjs.append({ "image_path": subset + '/' + output_filename, "rects":[] } ) with open(META_DIR + subset + '-scan.json', 'w') as f: json.dump(jsobjs, f) def get_image_map(data_root, input_file, threshold): result_map = {} with open(input_file) as f: result_list = json.load(f) for it in result_list: key, subset, z = parse_image_file(it['file']) src_file = os.path.join( data_root, subset, key + ".mhd") boxes = filterBoxes(it['box'], threshold) if not result_map.get(src_file): <|fim_middle|> result_map[src_file].append((key, z, boxes)) return result_map def generate_result(result_map, output_file): with open(output_file) as fout: fout.write("seriesuid,coordX,coordY,coordZ,probability\n") for fkey, val in result_map.items(): itkimage = sitk.ReadImage(fkey) for it in val: key, z, boxes = val for box in boxes: world_box = voxel_2_world( [z, box[1], box[0]], itkimage) csv_line = key + "," + str(world_box[2]) + "," + str(world_box[1]) + "," + str(world_box[0]) + "," + str(box[4]) fout.write(csv_line + "\n") if __name__ == '__main__': if sys.argv[1] == 'gen': generate_scan_image(sys.argv[2]) else: result_map = get_image_map(TRUNK_DIR, sys.argv[2], 0.01) generate_result(result_map, OUTPUT_FILE)<|fim▁end|>
result_map[src_file] = []
<|file_name|>scan.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # @Author: yancz1989 # @Date: 2017-01-17 23:43:18 # @Last Modified by: yancz1989 # @Last Modified time: 2017-02-22 20:33:29 import utilities as util from utilities import parse_image_file, filterBoxes, voxel_2_world, mkdir import numpy as np import os import json import sys from PIL import Image, ImageDraw import SimpleITK as sitk from env import * def generate_scan_image(subset): list_dirs = os.walk(TRUNK_DIR + subset) jsobjs = [] output_dir = SAMPLE_DIR + subset mkdir(output_dir) for root, dirs, files in list_dirs: for f in files: if f.lower().endswith('mhd'): key = os.path.splitext(f)[0] numpyImage, numpyOrigin, numpySpacing = ( util.load_itk_image( os.path.join(root, f))) for z in range(numpyImage.shape[0]): patch = numpyImage[z, 0:512, 0:512] patch = util.normalizePlanes(patch) im = Image.fromarray(patch * 255).convert('L') output_filename = ( subset + "-" + key + "-" + str(z) + "-scan.bmp") print(subset + '/' + output_filename) im.save(os.path.join( output_dir, output_filename)) jsobjs.append({ "image_path": subset + '/' + output_filename, "rects":[] } ) with open(META_DIR + subset + '-scan.json', 'w') as f: json.dump(jsobjs, f) def get_image_map(data_root, input_file, threshold): result_map = {} with open(input_file) as f: result_list = json.load(f) for it in result_list: key, subset, z = parse_image_file(it['file']) src_file = os.path.join( data_root, subset, key + ".mhd") boxes = filterBoxes(it['box'], threshold) if not result_map.get(src_file): result_map[src_file] = [] result_map[src_file].append((key, z, boxes)) return result_map def generate_result(result_map, output_file): with open(output_file) as fout: fout.write("seriesuid,coordX,coordY,coordZ,probability\n") for fkey, val in result_map.items(): itkimage = sitk.ReadImage(fkey) for it in val: key, z, boxes = val for box in boxes: world_box = voxel_2_world( [z, box[1], box[0]], itkimage) csv_line = key + "," + str(world_box[2]) + "," + str(world_box[1]) + "," + str(world_box[0]) + "," + str(box[4]) fout.write(csv_line + "\n") if __name__ == '__main__': <|fim_middle|> <|fim▁end|>
if sys.argv[1] == 'gen': generate_scan_image(sys.argv[2]) else: result_map = get_image_map(TRUNK_DIR, sys.argv[2], 0.01) generate_result(result_map, OUTPUT_FILE)
<|file_name|>scan.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # @Author: yancz1989 # @Date: 2017-01-17 23:43:18 # @Last Modified by: yancz1989 # @Last Modified time: 2017-02-22 20:33:29 import utilities as util from utilities import parse_image_file, filterBoxes, voxel_2_world, mkdir import numpy as np import os import json import sys from PIL import Image, ImageDraw import SimpleITK as sitk from env import * def generate_scan_image(subset): list_dirs = os.walk(TRUNK_DIR + subset) jsobjs = [] output_dir = SAMPLE_DIR + subset mkdir(output_dir) for root, dirs, files in list_dirs: for f in files: if f.lower().endswith('mhd'): key = os.path.splitext(f)[0] numpyImage, numpyOrigin, numpySpacing = ( util.load_itk_image( os.path.join(root, f))) for z in range(numpyImage.shape[0]): patch = numpyImage[z, 0:512, 0:512] patch = util.normalizePlanes(patch) im = Image.fromarray(patch * 255).convert('L') output_filename = ( subset + "-" + key + "-" + str(z) + "-scan.bmp") print(subset + '/' + output_filename) im.save(os.path.join( output_dir, output_filename)) jsobjs.append({ "image_path": subset + '/' + output_filename, "rects":[] } ) with open(META_DIR + subset + '-scan.json', 'w') as f: json.dump(jsobjs, f) def get_image_map(data_root, input_file, threshold): result_map = {} with open(input_file) as f: result_list = json.load(f) for it in result_list: key, subset, z = parse_image_file(it['file']) src_file = os.path.join( data_root, subset, key + ".mhd") boxes = filterBoxes(it['box'], threshold) if not result_map.get(src_file): result_map[src_file] = [] result_map[src_file].append((key, z, boxes)) return result_map def generate_result(result_map, output_file): with open(output_file) as fout: fout.write("seriesuid,coordX,coordY,coordZ,probability\n") for fkey, val in result_map.items(): itkimage = sitk.ReadImage(fkey) for it in val: key, z, boxes = val for box in boxes: world_box = voxel_2_world( [z, box[1], box[0]], itkimage) csv_line = key + "," + str(world_box[2]) + "," + str(world_box[1]) + "," + str(world_box[0]) + "," + str(box[4]) fout.write(csv_line + "\n") if __name__ == '__main__': if sys.argv[1] == 'gen': <|fim_middle|> else: result_map = get_image_map(TRUNK_DIR, sys.argv[2], 0.01) generate_result(result_map, OUTPUT_FILE)<|fim▁end|>
generate_scan_image(sys.argv[2])
<|file_name|>scan.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # @Author: yancz1989 # @Date: 2017-01-17 23:43:18 # @Last Modified by: yancz1989 # @Last Modified time: 2017-02-22 20:33:29 import utilities as util from utilities import parse_image_file, filterBoxes, voxel_2_world, mkdir import numpy as np import os import json import sys from PIL import Image, ImageDraw import SimpleITK as sitk from env import * def generate_scan_image(subset): list_dirs = os.walk(TRUNK_DIR + subset) jsobjs = [] output_dir = SAMPLE_DIR + subset mkdir(output_dir) for root, dirs, files in list_dirs: for f in files: if f.lower().endswith('mhd'): key = os.path.splitext(f)[0] numpyImage, numpyOrigin, numpySpacing = ( util.load_itk_image( os.path.join(root, f))) for z in range(numpyImage.shape[0]): patch = numpyImage[z, 0:512, 0:512] patch = util.normalizePlanes(patch) im = Image.fromarray(patch * 255).convert('L') output_filename = ( subset + "-" + key + "-" + str(z) + "-scan.bmp") print(subset + '/' + output_filename) im.save(os.path.join( output_dir, output_filename)) jsobjs.append({ "image_path": subset + '/' + output_filename, "rects":[] } ) with open(META_DIR + subset + '-scan.json', 'w') as f: json.dump(jsobjs, f) def get_image_map(data_root, input_file, threshold): result_map = {} with open(input_file) as f: result_list = json.load(f) for it in result_list: key, subset, z = parse_image_file(it['file']) src_file = os.path.join( data_root, subset, key + ".mhd") boxes = filterBoxes(it['box'], threshold) if not result_map.get(src_file): result_map[src_file] = [] result_map[src_file].append((key, z, boxes)) return result_map def generate_result(result_map, output_file): with open(output_file) as fout: fout.write("seriesuid,coordX,coordY,coordZ,probability\n") for fkey, val in result_map.items(): itkimage = sitk.ReadImage(fkey) for it in val: key, z, boxes = val for box in boxes: world_box = voxel_2_world( [z, box[1], box[0]], itkimage) csv_line = key + "," + str(world_box[2]) + "," + str(world_box[1]) + "," + str(world_box[0]) + "," + str(box[4]) fout.write(csv_line + "\n") if __name__ == '__main__': if sys.argv[1] == 'gen': generate_scan_image(sys.argv[2]) else: <|fim_middle|> <|fim▁end|>
result_map = get_image_map(TRUNK_DIR, sys.argv[2], 0.01) generate_result(result_map, OUTPUT_FILE)
<|file_name|>scan.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # @Author: yancz1989 # @Date: 2017-01-17 23:43:18 # @Last Modified by: yancz1989 # @Last Modified time: 2017-02-22 20:33:29 import utilities as util from utilities import parse_image_file, filterBoxes, voxel_2_world, mkdir import numpy as np import os import json import sys from PIL import Image, ImageDraw import SimpleITK as sitk from env import * def <|fim_middle|>(subset): list_dirs = os.walk(TRUNK_DIR + subset) jsobjs = [] output_dir = SAMPLE_DIR + subset mkdir(output_dir) for root, dirs, files in list_dirs: for f in files: if f.lower().endswith('mhd'): key = os.path.splitext(f)[0] numpyImage, numpyOrigin, numpySpacing = ( util.load_itk_image( os.path.join(root, f))) for z in range(numpyImage.shape[0]): patch = numpyImage[z, 0:512, 0:512] patch = util.normalizePlanes(patch) im = Image.fromarray(patch * 255).convert('L') output_filename = ( subset + "-" + key + "-" + str(z) + "-scan.bmp") print(subset + '/' + output_filename) im.save(os.path.join( output_dir, output_filename)) jsobjs.append({ "image_path": subset + '/' + output_filename, "rects":[] } ) with open(META_DIR + subset + '-scan.json', 'w') as f: json.dump(jsobjs, f) def get_image_map(data_root, input_file, threshold): result_map = {} with open(input_file) as f: result_list = json.load(f) for it in result_list: key, subset, z = parse_image_file(it['file']) src_file = os.path.join( data_root, subset, key + ".mhd") boxes = filterBoxes(it['box'], threshold) if not result_map.get(src_file): result_map[src_file] = [] result_map[src_file].append((key, z, boxes)) return result_map def generate_result(result_map, output_file): with open(output_file) as fout: fout.write("seriesuid,coordX,coordY,coordZ,probability\n") for fkey, val in result_map.items(): itkimage = sitk.ReadImage(fkey) for it in val: key, z, boxes = val for box in boxes: world_box = voxel_2_world( [z, box[1], box[0]], itkimage) csv_line = key + "," + str(world_box[2]) + "," + str(world_box[1]) + "," + str(world_box[0]) + "," + str(box[4]) fout.write(csv_line + "\n") if __name__ == '__main__': if sys.argv[1] == 'gen': generate_scan_image(sys.argv[2]) else: result_map = get_image_map(TRUNK_DIR, sys.argv[2], 0.01) generate_result(result_map, OUTPUT_FILE)<|fim▁end|>
generate_scan_image
<|file_name|>scan.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # @Author: yancz1989 # @Date: 2017-01-17 23:43:18 # @Last Modified by: yancz1989 # @Last Modified time: 2017-02-22 20:33:29 import utilities as util from utilities import parse_image_file, filterBoxes, voxel_2_world, mkdir import numpy as np import os import json import sys from PIL import Image, ImageDraw import SimpleITK as sitk from env import * def generate_scan_image(subset): list_dirs = os.walk(TRUNK_DIR + subset) jsobjs = [] output_dir = SAMPLE_DIR + subset mkdir(output_dir) for root, dirs, files in list_dirs: for f in files: if f.lower().endswith('mhd'): key = os.path.splitext(f)[0] numpyImage, numpyOrigin, numpySpacing = ( util.load_itk_image( os.path.join(root, f))) for z in range(numpyImage.shape[0]): patch = numpyImage[z, 0:512, 0:512] patch = util.normalizePlanes(patch) im = Image.fromarray(patch * 255).convert('L') output_filename = ( subset + "-" + key + "-" + str(z) + "-scan.bmp") print(subset + '/' + output_filename) im.save(os.path.join( output_dir, output_filename)) jsobjs.append({ "image_path": subset + '/' + output_filename, "rects":[] } ) with open(META_DIR + subset + '-scan.json', 'w') as f: json.dump(jsobjs, f) def <|fim_middle|>(data_root, input_file, threshold): result_map = {} with open(input_file) as f: result_list = json.load(f) for it in result_list: key, subset, z = parse_image_file(it['file']) src_file = os.path.join( data_root, subset, key + ".mhd") boxes = filterBoxes(it['box'], threshold) if not result_map.get(src_file): result_map[src_file] = [] result_map[src_file].append((key, z, boxes)) return result_map def generate_result(result_map, output_file): with open(output_file) as fout: fout.write("seriesuid,coordX,coordY,coordZ,probability\n") for fkey, val in result_map.items(): itkimage = sitk.ReadImage(fkey) for it in val: key, z, boxes = val for box in boxes: world_box = voxel_2_world( [z, box[1], box[0]], itkimage) csv_line = key + "," + str(world_box[2]) + "," + str(world_box[1]) + "," + str(world_box[0]) + "," + str(box[4]) fout.write(csv_line + "\n") if __name__ == '__main__': if sys.argv[1] == 'gen': generate_scan_image(sys.argv[2]) else: result_map = get_image_map(TRUNK_DIR, sys.argv[2], 0.01) generate_result(result_map, OUTPUT_FILE)<|fim▁end|>
get_image_map
<|file_name|>scan.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # @Author: yancz1989 # @Date: 2017-01-17 23:43:18 # @Last Modified by: yancz1989 # @Last Modified time: 2017-02-22 20:33:29 import utilities as util from utilities import parse_image_file, filterBoxes, voxel_2_world, mkdir import numpy as np import os import json import sys from PIL import Image, ImageDraw import SimpleITK as sitk from env import * def generate_scan_image(subset): list_dirs = os.walk(TRUNK_DIR + subset) jsobjs = [] output_dir = SAMPLE_DIR + subset mkdir(output_dir) for root, dirs, files in list_dirs: for f in files: if f.lower().endswith('mhd'): key = os.path.splitext(f)[0] numpyImage, numpyOrigin, numpySpacing = ( util.load_itk_image( os.path.join(root, f))) for z in range(numpyImage.shape[0]): patch = numpyImage[z, 0:512, 0:512] patch = util.normalizePlanes(patch) im = Image.fromarray(patch * 255).convert('L') output_filename = ( subset + "-" + key + "-" + str(z) + "-scan.bmp") print(subset + '/' + output_filename) im.save(os.path.join( output_dir, output_filename)) jsobjs.append({ "image_path": subset + '/' + output_filename, "rects":[] } ) with open(META_DIR + subset + '-scan.json', 'w') as f: json.dump(jsobjs, f) def get_image_map(data_root, input_file, threshold): result_map = {} with open(input_file) as f: result_list = json.load(f) for it in result_list: key, subset, z = parse_image_file(it['file']) src_file = os.path.join( data_root, subset, key + ".mhd") boxes = filterBoxes(it['box'], threshold) if not result_map.get(src_file): result_map[src_file] = [] result_map[src_file].append((key, z, boxes)) return result_map def <|fim_middle|>(result_map, output_file): with open(output_file) as fout: fout.write("seriesuid,coordX,coordY,coordZ,probability\n") for fkey, val in result_map.items(): itkimage = sitk.ReadImage(fkey) for it in val: key, z, boxes = val for box in boxes: world_box = voxel_2_world( [z, box[1], box[0]], itkimage) csv_line = key + "," + str(world_box[2]) + "," + str(world_box[1]) + "," + str(world_box[0]) + "," + str(box[4]) fout.write(csv_line + "\n") if __name__ == '__main__': if sys.argv[1] == 'gen': generate_scan_image(sys.argv[2]) else: result_map = get_image_map(TRUNK_DIR, sys.argv[2], 0.01) generate_result(result_map, OUTPUT_FILE)<|fim▁end|>
generate_result
<|file_name|>conf.py<|end_file_name|><|fim▁begin|># Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.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. # -*- coding: utf-8 -*- import sys import os from datetime import date # eventlet/gevent should not monkey patch anything. os.environ["GEVENT_NOPATCH"] = "yes" os.environ["EVENTLET_NOPATCH"] = "yes" #os.environ["CELERY_LOADER"] = "default" this = os.path.dirname(os.path.abspath(__file__)) # If your extensions are in another directory, add it here. If the directory # is relative to the documentation root, use os.path.abspath to make it # absolute, like shown here. sys.path.append(os.path.join(os.pardir, "tests")) sys.path.append(os.path.join(this, "_ext")) #import celery # General configuration # --------------------- extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.coverage', 'sphinx.ext.pngmath', 'sphinx.ext.intersphinx', ] html_show_sphinx = False # Add any paths that contain templates here, relative to this directory. templates_path = ['.templates'] # The suffix of source filenames. source_suffix = '.rst' # The master toctree document. master_doc = 'index' # General information about the project. project = 'Apache Flume' copyright = '2009-%s The Apache Software Foundation' % date.today().year keep_warnings = True # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. #version = ".".join(map(str, celery.VERSION[0:2])) # The full version, including alpha/beta/rc tags. #release = celery.__version__ exclude_trees = ['.build'] # If true, '()' will be appended to :func: etc. cross-reference text. add_function_parentheses = True #intersphinx_mapping = { # "http://docs.python.org/dev": None, # "http://kombu.readthedocs.org/en/latest/": None, # "http://django-celery.readthedocs.org/en/latest": None, #} # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'trac' highlight_language = 'none' # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". #html_static_path = ['../resources/images'] html_logo = 'images/flume-logo.png' <|fim▁hole|># If false, no module index is generated. html_use_modindex = True # If false, no index is generated. html_use_index = True #html_theme = 'default' html_sidebars = { '**': ['localtoc.html', 'relations.html', 'sourcelink.html'], }<|fim▁end|>
html_use_smartypants = True
<|file_name|>app.py<|end_file_name|><|fim▁begin|><|fim▁hole|> urls = ( '/hello','Index' ) app = web.application(urls,globals()) render = web.template.render('/usr/local/LPTHW/ex51/gothonweb/templates/',base="layout") class Index(object): def GET(self): return render.hello_form() def POST(self): form = web.input(name="Nobody",greet="Hello") greeting = "%s,%s" % (form.greet,form.name) return render.index(greeting = greeting) if __name__ == '__main__': app.run()<|fim▁end|>
import web