prompt
large_stringlengths
72
9.34k
completion
large_stringlengths
0
7.61k
<|file_name|>slack.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 # # Copyright (c) 2017 Nick Douma # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including without limitation # the rights to use, copy, modify, merge, publish, distribute, sublicense, # and/or sell copies of the Software, and to permit persons to whom the # Software is furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. from argparse import ArgumentParser, ArgumentTypeError import datetime import json import re import urllib.error import urllib.parse import urllib.request import sys ISO8601 = r"^(\d{4})-?(\d{2})-?(\d{2})?[T ]?(\d{2}):?(\d{2}):?(\d{2})" def <|fim_middle|>(value): try: return int(value) except ValueError: pass matches = re.match(ISO8601, value) if not matches: raise ArgumentTypeError("Argument is not a valid UNIX or ISO8601 " "timestamp.") return int(datetime.datetime( *[int(m) for m in matches.groups()])).timestamp() def hex_value(value): value = value.replace("#", "") if not re.match(r"^[a-f0-9]{6}$", value): raise ArgumentTypeError("Argument is not a valid hex value.") return value parser = ArgumentParser(description="Send notifications using Slack") parser.add_argument("--webhook-url", help="Webhook URL.", required=True) parser.add_argument("--channel", help="Channel to post to (prefixed with #), " "or a specific user (prefixed with @).") parser.add_argument("--username", help="Username to post as") parser.add_argument("--title", help="Notification title.") parser.add_argument("--title_link", help="Notification title link.") parser.add_argument("--color", help="Sidebar color (as a hex value).", type=hex_value) parser.add_argument("--ts", help="Unix timestamp or ISO8601 timestamp " "(will be converted to Unix timestamp).", type=iso8601_to_unix_timestamp) parser.add_argument("message", help="Notification message.") args = parser.parse_args() message = {} for param in ["channel", "username"]: value = getattr(args, param) if value: message[param] = value attachment = {} for param in ["title", "title_link", "color", "ts", "message"]: value = getattr(args, param) if value: attachment[param] = value attachment['fallback'] = attachment['message'] attachment['text'] = attachment['message'] del attachment['message'] message['attachments'] = [attachment] payload = {"payload": json.dumps(message)} try: parameters = urllib.parse.urlencode(payload).encode('UTF-8') url = urllib.request.Request(args.webhook_url, parameters) responseData = urllib.request.urlopen(url).read() except urllib.error.HTTPError as he: print("Sending message to Slack failed: {}".format(he)) sys.exit(1) <|fim▁end|>
iso8601_to_unix_timestamp
<|file_name|>slack.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 # # Copyright (c) 2017 Nick Douma # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including without limitation # the rights to use, copy, modify, merge, publish, distribute, sublicense, # and/or sell copies of the Software, and to permit persons to whom the # Software is furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. from argparse import ArgumentParser, ArgumentTypeError import datetime import json import re import urllib.error import urllib.parse import urllib.request import sys ISO8601 = r"^(\d{4})-?(\d{2})-?(\d{2})?[T ]?(\d{2}):?(\d{2}):?(\d{2})" def iso8601_to_unix_timestamp(value): try: return int(value) except ValueError: pass matches = re.match(ISO8601, value) if not matches: raise ArgumentTypeError("Argument is not a valid UNIX or ISO8601 " "timestamp.") return int(datetime.datetime( *[int(m) for m in matches.groups()])).timestamp() def <|fim_middle|>(value): value = value.replace("#", "") if not re.match(r"^[a-f0-9]{6}$", value): raise ArgumentTypeError("Argument is not a valid hex value.") return value parser = ArgumentParser(description="Send notifications using Slack") parser.add_argument("--webhook-url", help="Webhook URL.", required=True) parser.add_argument("--channel", help="Channel to post to (prefixed with #), " "or a specific user (prefixed with @).") parser.add_argument("--username", help="Username to post as") parser.add_argument("--title", help="Notification title.") parser.add_argument("--title_link", help="Notification title link.") parser.add_argument("--color", help="Sidebar color (as a hex value).", type=hex_value) parser.add_argument("--ts", help="Unix timestamp or ISO8601 timestamp " "(will be converted to Unix timestamp).", type=iso8601_to_unix_timestamp) parser.add_argument("message", help="Notification message.") args = parser.parse_args() message = {} for param in ["channel", "username"]: value = getattr(args, param) if value: message[param] = value attachment = {} for param in ["title", "title_link", "color", "ts", "message"]: value = getattr(args, param) if value: attachment[param] = value attachment['fallback'] = attachment['message'] attachment['text'] = attachment['message'] del attachment['message'] message['attachments'] = [attachment] payload = {"payload": json.dumps(message)} try: parameters = urllib.parse.urlencode(payload).encode('UTF-8') url = urllib.request.Request(args.webhook_url, parameters) responseData = urllib.request.urlopen(url).read() except urllib.error.HTTPError as he: print("Sending message to Slack failed: {}".format(he)) sys.exit(1) <|fim▁end|>
hex_value
<|file_name|>test_utils.py<|end_file_name|><|fim▁begin|><|fim▁hole|>from django_nose.tools import assert_false, assert_true from pontoon.base.tests import TestCase from pontoon.base.utils import extension_in class UtilsTests(TestCase): def test_extension_in(self): assert_true(extension_in('filename.txt', ['bat', 'txt'])) assert_true(extension_in('filename.biff', ['biff'])) assert_true(extension_in('filename.tar.gz', ['gz'])) assert_false(extension_in('filename.txt', ['png', 'jpg'])) assert_false(extension_in('.dotfile', ['bat', 'txt'])) # Unintuitive, but that's how splitext works. assert_false(extension_in('filename.tar.gz', ['tar.gz']))<|fim▁end|>
<|file_name|>test_utils.py<|end_file_name|><|fim▁begin|>from django_nose.tools import assert_false, assert_true from pontoon.base.tests import TestCase from pontoon.base.utils import extension_in class UtilsTests(TestCase): <|fim_middle|> <|fim▁end|>
def test_extension_in(self): assert_true(extension_in('filename.txt', ['bat', 'txt'])) assert_true(extension_in('filename.biff', ['biff'])) assert_true(extension_in('filename.tar.gz', ['gz'])) assert_false(extension_in('filename.txt', ['png', 'jpg'])) assert_false(extension_in('.dotfile', ['bat', 'txt'])) # Unintuitive, but that's how splitext works. assert_false(extension_in('filename.tar.gz', ['tar.gz']))
<|file_name|>test_utils.py<|end_file_name|><|fim▁begin|>from django_nose.tools import assert_false, assert_true from pontoon.base.tests import TestCase from pontoon.base.utils import extension_in class UtilsTests(TestCase): def test_extension_in(self): <|fim_middle|> <|fim▁end|>
assert_true(extension_in('filename.txt', ['bat', 'txt'])) assert_true(extension_in('filename.biff', ['biff'])) assert_true(extension_in('filename.tar.gz', ['gz'])) assert_false(extension_in('filename.txt', ['png', 'jpg'])) assert_false(extension_in('.dotfile', ['bat', 'txt'])) # Unintuitive, but that's how splitext works. assert_false(extension_in('filename.tar.gz', ['tar.gz']))
<|file_name|>test_utils.py<|end_file_name|><|fim▁begin|>from django_nose.tools import assert_false, assert_true from pontoon.base.tests import TestCase from pontoon.base.utils import extension_in class UtilsTests(TestCase): def <|fim_middle|>(self): assert_true(extension_in('filename.txt', ['bat', 'txt'])) assert_true(extension_in('filename.biff', ['biff'])) assert_true(extension_in('filename.tar.gz', ['gz'])) assert_false(extension_in('filename.txt', ['png', 'jpg'])) assert_false(extension_in('.dotfile', ['bat', 'txt'])) # Unintuitive, but that's how splitext works. assert_false(extension_in('filename.tar.gz', ['tar.gz'])) <|fim▁end|>
test_extension_in
<|file_name|>call_invocation_tester.py<|end_file_name|><|fim▁begin|>#! /usr/bin/python # Copyright 2004-2008 Roman Yakovenko. # Distributed under the Boost Software License, Version 1.0. (See # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) import unittest import autoconfig import pygccxml from pygccxml.utils import * from pygccxml.parser import * from pygccxml import declarations class tester_t( unittest.TestCase ): def __init__(self, *args ): unittest.TestCase.__init__( self, *args ) def __test_split_impl(self, decl_string, name, args): self.failUnless( ( name, args ) == declarations.call_invocation.split( decl_string ) ) def __test_split_recursive_impl(self, decl_string, control_seq): self.failUnless( control_seq == declarations.call_invocation.split_recursive( decl_string ) ) def __test_is_call_invocation_impl( self, decl_string ): self.failUnless( declarations.call_invocation.is_call_invocation( decl_string ) ) def test_split_on_vector(self): self.__test_is_call_invocation_impl( "vector(int,std::allocator(int) )" ) self.__test_split_impl( "vector(int,std::allocator(int) )" , "vector" , [ "int", "std::allocator(int)" ] ) self.__test_split_recursive_impl( "vector(int,std::allocator(int) )" <|fim▁hole|> , [ ( "vector", [ "int", "std::allocator(int)" ] ) , ( "std::allocator", ["int"] ) ] ) def test_split_on_string(self): self.__test_is_call_invocation_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" ) self.__test_split_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" , "basic_string" , [ "char", "std::char_traits(char)", "std::allocator(char)" ] ) def test_split_on_map(self): self.__test_is_call_invocation_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" ) self.__test_split_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" , "map" , [ "long int" , "std::vector(int, std::allocator(int) )" , "std::less(long int)" , "std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) )" ] ) def test_join_on_vector(self): self.failUnless( "vector( int, std::allocator(int) )" == declarations.call_invocation.join("vector", ( "int", "std::allocator(int)" ) ) ) def test_find_args(self): temp = 'x()()' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,2) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (3, 4) == found ) temp = 'x(int,int)(1,2)' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,9) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (10, 14) == found ) def test_bug_unmatched_brace( self ): src = 'AlternativeName((&string("")), (&string("")), (&string("")))' self.__test_split_impl( src , 'AlternativeName' , ['(&string(""))', '(&string(""))', '(&string(""))'] ) def create_suite(): suite = unittest.TestSuite() suite.addTest( unittest.makeSuite(tester_t)) return suite def run_suite(): unittest.TextTestRunner(verbosity=2).run( create_suite() ) if __name__ == "__main__": run_suite()<|fim▁end|>
<|file_name|>call_invocation_tester.py<|end_file_name|><|fim▁begin|>#! /usr/bin/python # Copyright 2004-2008 Roman Yakovenko. # Distributed under the Boost Software License, Version 1.0. (See # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) import unittest import autoconfig import pygccxml from pygccxml.utils import * from pygccxml.parser import * from pygccxml import declarations class tester_t( unittest.TestCase ): <|fim_middle|> def create_suite(): suite = unittest.TestSuite() suite.addTest( unittest.makeSuite(tester_t)) return suite def run_suite(): unittest.TextTestRunner(verbosity=2).run( create_suite() ) if __name__ == "__main__": run_suite() <|fim▁end|>
def __init__(self, *args ): unittest.TestCase.__init__( self, *args ) def __test_split_impl(self, decl_string, name, args): self.failUnless( ( name, args ) == declarations.call_invocation.split( decl_string ) ) def __test_split_recursive_impl(self, decl_string, control_seq): self.failUnless( control_seq == declarations.call_invocation.split_recursive( decl_string ) ) def __test_is_call_invocation_impl( self, decl_string ): self.failUnless( declarations.call_invocation.is_call_invocation( decl_string ) ) def test_split_on_vector(self): self.__test_is_call_invocation_impl( "vector(int,std::allocator(int) )" ) self.__test_split_impl( "vector(int,std::allocator(int) )" , "vector" , [ "int", "std::allocator(int)" ] ) self.__test_split_recursive_impl( "vector(int,std::allocator(int) )" , [ ( "vector", [ "int", "std::allocator(int)" ] ) , ( "std::allocator", ["int"] ) ] ) def test_split_on_string(self): self.__test_is_call_invocation_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" ) self.__test_split_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" , "basic_string" , [ "char", "std::char_traits(char)", "std::allocator(char)" ] ) def test_split_on_map(self): self.__test_is_call_invocation_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" ) self.__test_split_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" , "map" , [ "long int" , "std::vector(int, std::allocator(int) )" , "std::less(long int)" , "std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) )" ] ) def test_join_on_vector(self): self.failUnless( "vector( int, std::allocator(int) )" == declarations.call_invocation.join("vector", ( "int", "std::allocator(int)" ) ) ) def test_find_args(self): temp = 'x()()' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,2) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (3, 4) == found ) temp = 'x(int,int)(1,2)' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,9) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (10, 14) == found ) def test_bug_unmatched_brace( self ): src = 'AlternativeName((&string("")), (&string("")), (&string("")))' self.__test_split_impl( src , 'AlternativeName' , ['(&string(""))', '(&string(""))', '(&string(""))'] )
<|file_name|>call_invocation_tester.py<|end_file_name|><|fim▁begin|>#! /usr/bin/python # Copyright 2004-2008 Roman Yakovenko. # Distributed under the Boost Software License, Version 1.0. (See # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) import unittest import autoconfig import pygccxml from pygccxml.utils import * from pygccxml.parser import * from pygccxml import declarations class tester_t( unittest.TestCase ): def __init__(self, *args ): <|fim_middle|> def __test_split_impl(self, decl_string, name, args): self.failUnless( ( name, args ) == declarations.call_invocation.split( decl_string ) ) def __test_split_recursive_impl(self, decl_string, control_seq): self.failUnless( control_seq == declarations.call_invocation.split_recursive( decl_string ) ) def __test_is_call_invocation_impl( self, decl_string ): self.failUnless( declarations.call_invocation.is_call_invocation( decl_string ) ) def test_split_on_vector(self): self.__test_is_call_invocation_impl( "vector(int,std::allocator(int) )" ) self.__test_split_impl( "vector(int,std::allocator(int) )" , "vector" , [ "int", "std::allocator(int)" ] ) self.__test_split_recursive_impl( "vector(int,std::allocator(int) )" , [ ( "vector", [ "int", "std::allocator(int)" ] ) , ( "std::allocator", ["int"] ) ] ) def test_split_on_string(self): self.__test_is_call_invocation_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" ) self.__test_split_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" , "basic_string" , [ "char", "std::char_traits(char)", "std::allocator(char)" ] ) def test_split_on_map(self): self.__test_is_call_invocation_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" ) self.__test_split_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" , "map" , [ "long int" , "std::vector(int, std::allocator(int) )" , "std::less(long int)" , "std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) )" ] ) def test_join_on_vector(self): self.failUnless( "vector( int, std::allocator(int) )" == declarations.call_invocation.join("vector", ( "int", "std::allocator(int)" ) ) ) def test_find_args(self): temp = 'x()()' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,2) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (3, 4) == found ) temp = 'x(int,int)(1,2)' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,9) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (10, 14) == found ) def test_bug_unmatched_brace( self ): src = 'AlternativeName((&string("")), (&string("")), (&string("")))' self.__test_split_impl( src , 'AlternativeName' , ['(&string(""))', '(&string(""))', '(&string(""))'] ) def create_suite(): suite = unittest.TestSuite() suite.addTest( unittest.makeSuite(tester_t)) return suite def run_suite(): unittest.TextTestRunner(verbosity=2).run( create_suite() ) if __name__ == "__main__": run_suite() <|fim▁end|>
unittest.TestCase.__init__( self, *args )
<|file_name|>call_invocation_tester.py<|end_file_name|><|fim▁begin|>#! /usr/bin/python # Copyright 2004-2008 Roman Yakovenko. # Distributed under the Boost Software License, Version 1.0. (See # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) import unittest import autoconfig import pygccxml from pygccxml.utils import * from pygccxml.parser import * from pygccxml import declarations class tester_t( unittest.TestCase ): def __init__(self, *args ): unittest.TestCase.__init__( self, *args ) def __test_split_impl(self, decl_string, name, args): <|fim_middle|> def __test_split_recursive_impl(self, decl_string, control_seq): self.failUnless( control_seq == declarations.call_invocation.split_recursive( decl_string ) ) def __test_is_call_invocation_impl( self, decl_string ): self.failUnless( declarations.call_invocation.is_call_invocation( decl_string ) ) def test_split_on_vector(self): self.__test_is_call_invocation_impl( "vector(int,std::allocator(int) )" ) self.__test_split_impl( "vector(int,std::allocator(int) )" , "vector" , [ "int", "std::allocator(int)" ] ) self.__test_split_recursive_impl( "vector(int,std::allocator(int) )" , [ ( "vector", [ "int", "std::allocator(int)" ] ) , ( "std::allocator", ["int"] ) ] ) def test_split_on_string(self): self.__test_is_call_invocation_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" ) self.__test_split_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" , "basic_string" , [ "char", "std::char_traits(char)", "std::allocator(char)" ] ) def test_split_on_map(self): self.__test_is_call_invocation_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" ) self.__test_split_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" , "map" , [ "long int" , "std::vector(int, std::allocator(int) )" , "std::less(long int)" , "std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) )" ] ) def test_join_on_vector(self): self.failUnless( "vector( int, std::allocator(int) )" == declarations.call_invocation.join("vector", ( "int", "std::allocator(int)" ) ) ) def test_find_args(self): temp = 'x()()' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,2) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (3, 4) == found ) temp = 'x(int,int)(1,2)' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,9) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (10, 14) == found ) def test_bug_unmatched_brace( self ): src = 'AlternativeName((&string("")), (&string("")), (&string("")))' self.__test_split_impl( src , 'AlternativeName' , ['(&string(""))', '(&string(""))', '(&string(""))'] ) def create_suite(): suite = unittest.TestSuite() suite.addTest( unittest.makeSuite(tester_t)) return suite def run_suite(): unittest.TextTestRunner(verbosity=2).run( create_suite() ) if __name__ == "__main__": run_suite() <|fim▁end|>
self.failUnless( ( name, args ) == declarations.call_invocation.split( decl_string ) )
<|file_name|>call_invocation_tester.py<|end_file_name|><|fim▁begin|>#! /usr/bin/python # Copyright 2004-2008 Roman Yakovenko. # Distributed under the Boost Software License, Version 1.0. (See # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) import unittest import autoconfig import pygccxml from pygccxml.utils import * from pygccxml.parser import * from pygccxml import declarations class tester_t( unittest.TestCase ): def __init__(self, *args ): unittest.TestCase.__init__( self, *args ) def __test_split_impl(self, decl_string, name, args): self.failUnless( ( name, args ) == declarations.call_invocation.split( decl_string ) ) def __test_split_recursive_impl(self, decl_string, control_seq): <|fim_middle|> def __test_is_call_invocation_impl( self, decl_string ): self.failUnless( declarations.call_invocation.is_call_invocation( decl_string ) ) def test_split_on_vector(self): self.__test_is_call_invocation_impl( "vector(int,std::allocator(int) )" ) self.__test_split_impl( "vector(int,std::allocator(int) )" , "vector" , [ "int", "std::allocator(int)" ] ) self.__test_split_recursive_impl( "vector(int,std::allocator(int) )" , [ ( "vector", [ "int", "std::allocator(int)" ] ) , ( "std::allocator", ["int"] ) ] ) def test_split_on_string(self): self.__test_is_call_invocation_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" ) self.__test_split_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" , "basic_string" , [ "char", "std::char_traits(char)", "std::allocator(char)" ] ) def test_split_on_map(self): self.__test_is_call_invocation_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" ) self.__test_split_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" , "map" , [ "long int" , "std::vector(int, std::allocator(int) )" , "std::less(long int)" , "std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) )" ] ) def test_join_on_vector(self): self.failUnless( "vector( int, std::allocator(int) )" == declarations.call_invocation.join("vector", ( "int", "std::allocator(int)" ) ) ) def test_find_args(self): temp = 'x()()' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,2) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (3, 4) == found ) temp = 'x(int,int)(1,2)' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,9) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (10, 14) == found ) def test_bug_unmatched_brace( self ): src = 'AlternativeName((&string("")), (&string("")), (&string("")))' self.__test_split_impl( src , 'AlternativeName' , ['(&string(""))', '(&string(""))', '(&string(""))'] ) def create_suite(): suite = unittest.TestSuite() suite.addTest( unittest.makeSuite(tester_t)) return suite def run_suite(): unittest.TextTestRunner(verbosity=2).run( create_suite() ) if __name__ == "__main__": run_suite() <|fim▁end|>
self.failUnless( control_seq == declarations.call_invocation.split_recursive( decl_string ) )
<|file_name|>call_invocation_tester.py<|end_file_name|><|fim▁begin|>#! /usr/bin/python # Copyright 2004-2008 Roman Yakovenko. # Distributed under the Boost Software License, Version 1.0. (See # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) import unittest import autoconfig import pygccxml from pygccxml.utils import * from pygccxml.parser import * from pygccxml import declarations class tester_t( unittest.TestCase ): def __init__(self, *args ): unittest.TestCase.__init__( self, *args ) def __test_split_impl(self, decl_string, name, args): self.failUnless( ( name, args ) == declarations.call_invocation.split( decl_string ) ) def __test_split_recursive_impl(self, decl_string, control_seq): self.failUnless( control_seq == declarations.call_invocation.split_recursive( decl_string ) ) def __test_is_call_invocation_impl( self, decl_string ): <|fim_middle|> def test_split_on_vector(self): self.__test_is_call_invocation_impl( "vector(int,std::allocator(int) )" ) self.__test_split_impl( "vector(int,std::allocator(int) )" , "vector" , [ "int", "std::allocator(int)" ] ) self.__test_split_recursive_impl( "vector(int,std::allocator(int) )" , [ ( "vector", [ "int", "std::allocator(int)" ] ) , ( "std::allocator", ["int"] ) ] ) def test_split_on_string(self): self.__test_is_call_invocation_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" ) self.__test_split_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" , "basic_string" , [ "char", "std::char_traits(char)", "std::allocator(char)" ] ) def test_split_on_map(self): self.__test_is_call_invocation_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" ) self.__test_split_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" , "map" , [ "long int" , "std::vector(int, std::allocator(int) )" , "std::less(long int)" , "std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) )" ] ) def test_join_on_vector(self): self.failUnless( "vector( int, std::allocator(int) )" == declarations.call_invocation.join("vector", ( "int", "std::allocator(int)" ) ) ) def test_find_args(self): temp = 'x()()' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,2) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (3, 4) == found ) temp = 'x(int,int)(1,2)' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,9) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (10, 14) == found ) def test_bug_unmatched_brace( self ): src = 'AlternativeName((&string("")), (&string("")), (&string("")))' self.__test_split_impl( src , 'AlternativeName' , ['(&string(""))', '(&string(""))', '(&string(""))'] ) def create_suite(): suite = unittest.TestSuite() suite.addTest( unittest.makeSuite(tester_t)) return suite def run_suite(): unittest.TextTestRunner(verbosity=2).run( create_suite() ) if __name__ == "__main__": run_suite() <|fim▁end|>
self.failUnless( declarations.call_invocation.is_call_invocation( decl_string ) )
<|file_name|>call_invocation_tester.py<|end_file_name|><|fim▁begin|>#! /usr/bin/python # Copyright 2004-2008 Roman Yakovenko. # Distributed under the Boost Software License, Version 1.0. (See # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) import unittest import autoconfig import pygccxml from pygccxml.utils import * from pygccxml.parser import * from pygccxml import declarations class tester_t( unittest.TestCase ): def __init__(self, *args ): unittest.TestCase.__init__( self, *args ) def __test_split_impl(self, decl_string, name, args): self.failUnless( ( name, args ) == declarations.call_invocation.split( decl_string ) ) def __test_split_recursive_impl(self, decl_string, control_seq): self.failUnless( control_seq == declarations.call_invocation.split_recursive( decl_string ) ) def __test_is_call_invocation_impl( self, decl_string ): self.failUnless( declarations.call_invocation.is_call_invocation( decl_string ) ) def test_split_on_vector(self): <|fim_middle|> def test_split_on_string(self): self.__test_is_call_invocation_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" ) self.__test_split_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" , "basic_string" , [ "char", "std::char_traits(char)", "std::allocator(char)" ] ) def test_split_on_map(self): self.__test_is_call_invocation_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" ) self.__test_split_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" , "map" , [ "long int" , "std::vector(int, std::allocator(int) )" , "std::less(long int)" , "std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) )" ] ) def test_join_on_vector(self): self.failUnless( "vector( int, std::allocator(int) )" == declarations.call_invocation.join("vector", ( "int", "std::allocator(int)" ) ) ) def test_find_args(self): temp = 'x()()' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,2) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (3, 4) == found ) temp = 'x(int,int)(1,2)' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,9) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (10, 14) == found ) def test_bug_unmatched_brace( self ): src = 'AlternativeName((&string("")), (&string("")), (&string("")))' self.__test_split_impl( src , 'AlternativeName' , ['(&string(""))', '(&string(""))', '(&string(""))'] ) def create_suite(): suite = unittest.TestSuite() suite.addTest( unittest.makeSuite(tester_t)) return suite def run_suite(): unittest.TextTestRunner(verbosity=2).run( create_suite() ) if __name__ == "__main__": run_suite() <|fim▁end|>
self.__test_is_call_invocation_impl( "vector(int,std::allocator(int) )" ) self.__test_split_impl( "vector(int,std::allocator(int) )" , "vector" , [ "int", "std::allocator(int)" ] ) self.__test_split_recursive_impl( "vector(int,std::allocator(int) )" , [ ( "vector", [ "int", "std::allocator(int)" ] ) , ( "std::allocator", ["int"] ) ] )
<|file_name|>call_invocation_tester.py<|end_file_name|><|fim▁begin|>#! /usr/bin/python # Copyright 2004-2008 Roman Yakovenko. # Distributed under the Boost Software License, Version 1.0. (See # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) import unittest import autoconfig import pygccxml from pygccxml.utils import * from pygccxml.parser import * from pygccxml import declarations class tester_t( unittest.TestCase ): def __init__(self, *args ): unittest.TestCase.__init__( self, *args ) def __test_split_impl(self, decl_string, name, args): self.failUnless( ( name, args ) == declarations.call_invocation.split( decl_string ) ) def __test_split_recursive_impl(self, decl_string, control_seq): self.failUnless( control_seq == declarations.call_invocation.split_recursive( decl_string ) ) def __test_is_call_invocation_impl( self, decl_string ): self.failUnless( declarations.call_invocation.is_call_invocation( decl_string ) ) def test_split_on_vector(self): self.__test_is_call_invocation_impl( "vector(int,std::allocator(int) )" ) self.__test_split_impl( "vector(int,std::allocator(int) )" , "vector" , [ "int", "std::allocator(int)" ] ) self.__test_split_recursive_impl( "vector(int,std::allocator(int) )" , [ ( "vector", [ "int", "std::allocator(int)" ] ) , ( "std::allocator", ["int"] ) ] ) def test_split_on_string(self): <|fim_middle|> def test_split_on_map(self): self.__test_is_call_invocation_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" ) self.__test_split_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" , "map" , [ "long int" , "std::vector(int, std::allocator(int) )" , "std::less(long int)" , "std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) )" ] ) def test_join_on_vector(self): self.failUnless( "vector( int, std::allocator(int) )" == declarations.call_invocation.join("vector", ( "int", "std::allocator(int)" ) ) ) def test_find_args(self): temp = 'x()()' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,2) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (3, 4) == found ) temp = 'x(int,int)(1,2)' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,9) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (10, 14) == found ) def test_bug_unmatched_brace( self ): src = 'AlternativeName((&string("")), (&string("")), (&string("")))' self.__test_split_impl( src , 'AlternativeName' , ['(&string(""))', '(&string(""))', '(&string(""))'] ) def create_suite(): suite = unittest.TestSuite() suite.addTest( unittest.makeSuite(tester_t)) return suite def run_suite(): unittest.TextTestRunner(verbosity=2).run( create_suite() ) if __name__ == "__main__": run_suite() <|fim▁end|>
self.__test_is_call_invocation_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" ) self.__test_split_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" , "basic_string" , [ "char", "std::char_traits(char)", "std::allocator(char)" ] )
<|file_name|>call_invocation_tester.py<|end_file_name|><|fim▁begin|>#! /usr/bin/python # Copyright 2004-2008 Roman Yakovenko. # Distributed under the Boost Software License, Version 1.0. (See # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) import unittest import autoconfig import pygccxml from pygccxml.utils import * from pygccxml.parser import * from pygccxml import declarations class tester_t( unittest.TestCase ): def __init__(self, *args ): unittest.TestCase.__init__( self, *args ) def __test_split_impl(self, decl_string, name, args): self.failUnless( ( name, args ) == declarations.call_invocation.split( decl_string ) ) def __test_split_recursive_impl(self, decl_string, control_seq): self.failUnless( control_seq == declarations.call_invocation.split_recursive( decl_string ) ) def __test_is_call_invocation_impl( self, decl_string ): self.failUnless( declarations.call_invocation.is_call_invocation( decl_string ) ) def test_split_on_vector(self): self.__test_is_call_invocation_impl( "vector(int,std::allocator(int) )" ) self.__test_split_impl( "vector(int,std::allocator(int) )" , "vector" , [ "int", "std::allocator(int)" ] ) self.__test_split_recursive_impl( "vector(int,std::allocator(int) )" , [ ( "vector", [ "int", "std::allocator(int)" ] ) , ( "std::allocator", ["int"] ) ] ) def test_split_on_string(self): self.__test_is_call_invocation_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" ) self.__test_split_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" , "basic_string" , [ "char", "std::char_traits(char)", "std::allocator(char)" ] ) def test_split_on_map(self): <|fim_middle|> def test_join_on_vector(self): self.failUnless( "vector( int, std::allocator(int) )" == declarations.call_invocation.join("vector", ( "int", "std::allocator(int)" ) ) ) def test_find_args(self): temp = 'x()()' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,2) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (3, 4) == found ) temp = 'x(int,int)(1,2)' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,9) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (10, 14) == found ) def test_bug_unmatched_brace( self ): src = 'AlternativeName((&string("")), (&string("")), (&string("")))' self.__test_split_impl( src , 'AlternativeName' , ['(&string(""))', '(&string(""))', '(&string(""))'] ) def create_suite(): suite = unittest.TestSuite() suite.addTest( unittest.makeSuite(tester_t)) return suite def run_suite(): unittest.TextTestRunner(verbosity=2).run( create_suite() ) if __name__ == "__main__": run_suite() <|fim▁end|>
self.__test_is_call_invocation_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" ) self.__test_split_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" , "map" , [ "long int" , "std::vector(int, std::allocator(int) )" , "std::less(long int)" , "std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) )" ] )
<|file_name|>call_invocation_tester.py<|end_file_name|><|fim▁begin|>#! /usr/bin/python # Copyright 2004-2008 Roman Yakovenko. # Distributed under the Boost Software License, Version 1.0. (See # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) import unittest import autoconfig import pygccxml from pygccxml.utils import * from pygccxml.parser import * from pygccxml import declarations class tester_t( unittest.TestCase ): def __init__(self, *args ): unittest.TestCase.__init__( self, *args ) def __test_split_impl(self, decl_string, name, args): self.failUnless( ( name, args ) == declarations.call_invocation.split( decl_string ) ) def __test_split_recursive_impl(self, decl_string, control_seq): self.failUnless( control_seq == declarations.call_invocation.split_recursive( decl_string ) ) def __test_is_call_invocation_impl( self, decl_string ): self.failUnless( declarations.call_invocation.is_call_invocation( decl_string ) ) def test_split_on_vector(self): self.__test_is_call_invocation_impl( "vector(int,std::allocator(int) )" ) self.__test_split_impl( "vector(int,std::allocator(int) )" , "vector" , [ "int", "std::allocator(int)" ] ) self.__test_split_recursive_impl( "vector(int,std::allocator(int) )" , [ ( "vector", [ "int", "std::allocator(int)" ] ) , ( "std::allocator", ["int"] ) ] ) def test_split_on_string(self): self.__test_is_call_invocation_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" ) self.__test_split_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" , "basic_string" , [ "char", "std::char_traits(char)", "std::allocator(char)" ] ) def test_split_on_map(self): self.__test_is_call_invocation_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" ) self.__test_split_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" , "map" , [ "long int" , "std::vector(int, std::allocator(int) )" , "std::less(long int)" , "std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) )" ] ) def test_join_on_vector(self): <|fim_middle|> def test_find_args(self): temp = 'x()()' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,2) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (3, 4) == found ) temp = 'x(int,int)(1,2)' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,9) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (10, 14) == found ) def test_bug_unmatched_brace( self ): src = 'AlternativeName((&string("")), (&string("")), (&string("")))' self.__test_split_impl( src , 'AlternativeName' , ['(&string(""))', '(&string(""))', '(&string(""))'] ) def create_suite(): suite = unittest.TestSuite() suite.addTest( unittest.makeSuite(tester_t)) return suite def run_suite(): unittest.TextTestRunner(verbosity=2).run( create_suite() ) if __name__ == "__main__": run_suite() <|fim▁end|>
self.failUnless( "vector( int, std::allocator(int) )" == declarations.call_invocation.join("vector", ( "int", "std::allocator(int)" ) ) )
<|file_name|>call_invocation_tester.py<|end_file_name|><|fim▁begin|>#! /usr/bin/python # Copyright 2004-2008 Roman Yakovenko. # Distributed under the Boost Software License, Version 1.0. (See # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) import unittest import autoconfig import pygccxml from pygccxml.utils import * from pygccxml.parser import * from pygccxml import declarations class tester_t( unittest.TestCase ): def __init__(self, *args ): unittest.TestCase.__init__( self, *args ) def __test_split_impl(self, decl_string, name, args): self.failUnless( ( name, args ) == declarations.call_invocation.split( decl_string ) ) def __test_split_recursive_impl(self, decl_string, control_seq): self.failUnless( control_seq == declarations.call_invocation.split_recursive( decl_string ) ) def __test_is_call_invocation_impl( self, decl_string ): self.failUnless( declarations.call_invocation.is_call_invocation( decl_string ) ) def test_split_on_vector(self): self.__test_is_call_invocation_impl( "vector(int,std::allocator(int) )" ) self.__test_split_impl( "vector(int,std::allocator(int) )" , "vector" , [ "int", "std::allocator(int)" ] ) self.__test_split_recursive_impl( "vector(int,std::allocator(int) )" , [ ( "vector", [ "int", "std::allocator(int)" ] ) , ( "std::allocator", ["int"] ) ] ) def test_split_on_string(self): self.__test_is_call_invocation_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" ) self.__test_split_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" , "basic_string" , [ "char", "std::char_traits(char)", "std::allocator(char)" ] ) def test_split_on_map(self): self.__test_is_call_invocation_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" ) self.__test_split_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" , "map" , [ "long int" , "std::vector(int, std::allocator(int) )" , "std::less(long int)" , "std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) )" ] ) def test_join_on_vector(self): self.failUnless( "vector( int, std::allocator(int) )" == declarations.call_invocation.join("vector", ( "int", "std::allocator(int)" ) ) ) def test_find_args(self): <|fim_middle|> def test_bug_unmatched_brace( self ): src = 'AlternativeName((&string("")), (&string("")), (&string("")))' self.__test_split_impl( src , 'AlternativeName' , ['(&string(""))', '(&string(""))', '(&string(""))'] ) def create_suite(): suite = unittest.TestSuite() suite.addTest( unittest.makeSuite(tester_t)) return suite def run_suite(): unittest.TextTestRunner(verbosity=2).run( create_suite() ) if __name__ == "__main__": run_suite() <|fim▁end|>
temp = 'x()()' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,2) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (3, 4) == found ) temp = 'x(int,int)(1,2)' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,9) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (10, 14) == found )
<|file_name|>call_invocation_tester.py<|end_file_name|><|fim▁begin|>#! /usr/bin/python # Copyright 2004-2008 Roman Yakovenko. # Distributed under the Boost Software License, Version 1.0. (See # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) import unittest import autoconfig import pygccxml from pygccxml.utils import * from pygccxml.parser import * from pygccxml import declarations class tester_t( unittest.TestCase ): def __init__(self, *args ): unittest.TestCase.__init__( self, *args ) def __test_split_impl(self, decl_string, name, args): self.failUnless( ( name, args ) == declarations.call_invocation.split( decl_string ) ) def __test_split_recursive_impl(self, decl_string, control_seq): self.failUnless( control_seq == declarations.call_invocation.split_recursive( decl_string ) ) def __test_is_call_invocation_impl( self, decl_string ): self.failUnless( declarations.call_invocation.is_call_invocation( decl_string ) ) def test_split_on_vector(self): self.__test_is_call_invocation_impl( "vector(int,std::allocator(int) )" ) self.__test_split_impl( "vector(int,std::allocator(int) )" , "vector" , [ "int", "std::allocator(int)" ] ) self.__test_split_recursive_impl( "vector(int,std::allocator(int) )" , [ ( "vector", [ "int", "std::allocator(int)" ] ) , ( "std::allocator", ["int"] ) ] ) def test_split_on_string(self): self.__test_is_call_invocation_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" ) self.__test_split_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" , "basic_string" , [ "char", "std::char_traits(char)", "std::allocator(char)" ] ) def test_split_on_map(self): self.__test_is_call_invocation_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" ) self.__test_split_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" , "map" , [ "long int" , "std::vector(int, std::allocator(int) )" , "std::less(long int)" , "std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) )" ] ) def test_join_on_vector(self): self.failUnless( "vector( int, std::allocator(int) )" == declarations.call_invocation.join("vector", ( "int", "std::allocator(int)" ) ) ) def test_find_args(self): temp = 'x()()' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,2) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (3, 4) == found ) temp = 'x(int,int)(1,2)' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,9) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (10, 14) == found ) def test_bug_unmatched_brace( self ): <|fim_middle|> def create_suite(): suite = unittest.TestSuite() suite.addTest( unittest.makeSuite(tester_t)) return suite def run_suite(): unittest.TextTestRunner(verbosity=2).run( create_suite() ) if __name__ == "__main__": run_suite() <|fim▁end|>
src = 'AlternativeName((&string("")), (&string("")), (&string("")))' self.__test_split_impl( src , 'AlternativeName' , ['(&string(""))', '(&string(""))', '(&string(""))'] )
<|file_name|>call_invocation_tester.py<|end_file_name|><|fim▁begin|>#! /usr/bin/python # Copyright 2004-2008 Roman Yakovenko. # Distributed under the Boost Software License, Version 1.0. (See # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) import unittest import autoconfig import pygccxml from pygccxml.utils import * from pygccxml.parser import * from pygccxml import declarations class tester_t( unittest.TestCase ): def __init__(self, *args ): unittest.TestCase.__init__( self, *args ) def __test_split_impl(self, decl_string, name, args): self.failUnless( ( name, args ) == declarations.call_invocation.split( decl_string ) ) def __test_split_recursive_impl(self, decl_string, control_seq): self.failUnless( control_seq == declarations.call_invocation.split_recursive( decl_string ) ) def __test_is_call_invocation_impl( self, decl_string ): self.failUnless( declarations.call_invocation.is_call_invocation( decl_string ) ) def test_split_on_vector(self): self.__test_is_call_invocation_impl( "vector(int,std::allocator(int) )" ) self.__test_split_impl( "vector(int,std::allocator(int) )" , "vector" , [ "int", "std::allocator(int)" ] ) self.__test_split_recursive_impl( "vector(int,std::allocator(int) )" , [ ( "vector", [ "int", "std::allocator(int)" ] ) , ( "std::allocator", ["int"] ) ] ) def test_split_on_string(self): self.__test_is_call_invocation_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" ) self.__test_split_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" , "basic_string" , [ "char", "std::char_traits(char)", "std::allocator(char)" ] ) def test_split_on_map(self): self.__test_is_call_invocation_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" ) self.__test_split_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" , "map" , [ "long int" , "std::vector(int, std::allocator(int) )" , "std::less(long int)" , "std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) )" ] ) def test_join_on_vector(self): self.failUnless( "vector( int, std::allocator(int) )" == declarations.call_invocation.join("vector", ( "int", "std::allocator(int)" ) ) ) def test_find_args(self): temp = 'x()()' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,2) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (3, 4) == found ) temp = 'x(int,int)(1,2)' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,9) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (10, 14) == found ) def test_bug_unmatched_brace( self ): src = 'AlternativeName((&string("")), (&string("")), (&string("")))' self.__test_split_impl( src , 'AlternativeName' , ['(&string(""))', '(&string(""))', '(&string(""))'] ) def create_suite(): <|fim_middle|> def run_suite(): unittest.TextTestRunner(verbosity=2).run( create_suite() ) if __name__ == "__main__": run_suite() <|fim▁end|>
suite = unittest.TestSuite() suite.addTest( unittest.makeSuite(tester_t)) return suite
<|file_name|>call_invocation_tester.py<|end_file_name|><|fim▁begin|>#! /usr/bin/python # Copyright 2004-2008 Roman Yakovenko. # Distributed under the Boost Software License, Version 1.0. (See # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) import unittest import autoconfig import pygccxml from pygccxml.utils import * from pygccxml.parser import * from pygccxml import declarations class tester_t( unittest.TestCase ): def __init__(self, *args ): unittest.TestCase.__init__( self, *args ) def __test_split_impl(self, decl_string, name, args): self.failUnless( ( name, args ) == declarations.call_invocation.split( decl_string ) ) def __test_split_recursive_impl(self, decl_string, control_seq): self.failUnless( control_seq == declarations.call_invocation.split_recursive( decl_string ) ) def __test_is_call_invocation_impl( self, decl_string ): self.failUnless( declarations.call_invocation.is_call_invocation( decl_string ) ) def test_split_on_vector(self): self.__test_is_call_invocation_impl( "vector(int,std::allocator(int) )" ) self.__test_split_impl( "vector(int,std::allocator(int) )" , "vector" , [ "int", "std::allocator(int)" ] ) self.__test_split_recursive_impl( "vector(int,std::allocator(int) )" , [ ( "vector", [ "int", "std::allocator(int)" ] ) , ( "std::allocator", ["int"] ) ] ) def test_split_on_string(self): self.__test_is_call_invocation_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" ) self.__test_split_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" , "basic_string" , [ "char", "std::char_traits(char)", "std::allocator(char)" ] ) def test_split_on_map(self): self.__test_is_call_invocation_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" ) self.__test_split_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" , "map" , [ "long int" , "std::vector(int, std::allocator(int) )" , "std::less(long int)" , "std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) )" ] ) def test_join_on_vector(self): self.failUnless( "vector( int, std::allocator(int) )" == declarations.call_invocation.join("vector", ( "int", "std::allocator(int)" ) ) ) def test_find_args(self): temp = 'x()()' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,2) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (3, 4) == found ) temp = 'x(int,int)(1,2)' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,9) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (10, 14) == found ) def test_bug_unmatched_brace( self ): src = 'AlternativeName((&string("")), (&string("")), (&string("")))' self.__test_split_impl( src , 'AlternativeName' , ['(&string(""))', '(&string(""))', '(&string(""))'] ) def create_suite(): suite = unittest.TestSuite() suite.addTest( unittest.makeSuite(tester_t)) return suite def run_suite(): <|fim_middle|> if __name__ == "__main__": run_suite() <|fim▁end|>
unittest.TextTestRunner(verbosity=2).run( create_suite() )
<|file_name|>call_invocation_tester.py<|end_file_name|><|fim▁begin|>#! /usr/bin/python # Copyright 2004-2008 Roman Yakovenko. # Distributed under the Boost Software License, Version 1.0. (See # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) import unittest import autoconfig import pygccxml from pygccxml.utils import * from pygccxml.parser import * from pygccxml import declarations class tester_t( unittest.TestCase ): def __init__(self, *args ): unittest.TestCase.__init__( self, *args ) def __test_split_impl(self, decl_string, name, args): self.failUnless( ( name, args ) == declarations.call_invocation.split( decl_string ) ) def __test_split_recursive_impl(self, decl_string, control_seq): self.failUnless( control_seq == declarations.call_invocation.split_recursive( decl_string ) ) def __test_is_call_invocation_impl( self, decl_string ): self.failUnless( declarations.call_invocation.is_call_invocation( decl_string ) ) def test_split_on_vector(self): self.__test_is_call_invocation_impl( "vector(int,std::allocator(int) )" ) self.__test_split_impl( "vector(int,std::allocator(int) )" , "vector" , [ "int", "std::allocator(int)" ] ) self.__test_split_recursive_impl( "vector(int,std::allocator(int) )" , [ ( "vector", [ "int", "std::allocator(int)" ] ) , ( "std::allocator", ["int"] ) ] ) def test_split_on_string(self): self.__test_is_call_invocation_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" ) self.__test_split_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" , "basic_string" , [ "char", "std::char_traits(char)", "std::allocator(char)" ] ) def test_split_on_map(self): self.__test_is_call_invocation_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" ) self.__test_split_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" , "map" , [ "long int" , "std::vector(int, std::allocator(int) )" , "std::less(long int)" , "std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) )" ] ) def test_join_on_vector(self): self.failUnless( "vector( int, std::allocator(int) )" == declarations.call_invocation.join("vector", ( "int", "std::allocator(int)" ) ) ) def test_find_args(self): temp = 'x()()' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,2) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (3, 4) == found ) temp = 'x(int,int)(1,2)' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,9) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (10, 14) == found ) def test_bug_unmatched_brace( self ): src = 'AlternativeName((&string("")), (&string("")), (&string("")))' self.__test_split_impl( src , 'AlternativeName' , ['(&string(""))', '(&string(""))', '(&string(""))'] ) def create_suite(): suite = unittest.TestSuite() suite.addTest( unittest.makeSuite(tester_t)) return suite def run_suite(): unittest.TextTestRunner(verbosity=2).run( create_suite() ) if __name__ == "__main__": <|fim_middle|> <|fim▁end|>
run_suite()
<|file_name|>call_invocation_tester.py<|end_file_name|><|fim▁begin|>#! /usr/bin/python # Copyright 2004-2008 Roman Yakovenko. # Distributed under the Boost Software License, Version 1.0. (See # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) import unittest import autoconfig import pygccxml from pygccxml.utils import * from pygccxml.parser import * from pygccxml import declarations class tester_t( unittest.TestCase ): def <|fim_middle|>(self, *args ): unittest.TestCase.__init__( self, *args ) def __test_split_impl(self, decl_string, name, args): self.failUnless( ( name, args ) == declarations.call_invocation.split( decl_string ) ) def __test_split_recursive_impl(self, decl_string, control_seq): self.failUnless( control_seq == declarations.call_invocation.split_recursive( decl_string ) ) def __test_is_call_invocation_impl( self, decl_string ): self.failUnless( declarations.call_invocation.is_call_invocation( decl_string ) ) def test_split_on_vector(self): self.__test_is_call_invocation_impl( "vector(int,std::allocator(int) )" ) self.__test_split_impl( "vector(int,std::allocator(int) )" , "vector" , [ "int", "std::allocator(int)" ] ) self.__test_split_recursive_impl( "vector(int,std::allocator(int) )" , [ ( "vector", [ "int", "std::allocator(int)" ] ) , ( "std::allocator", ["int"] ) ] ) def test_split_on_string(self): self.__test_is_call_invocation_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" ) self.__test_split_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" , "basic_string" , [ "char", "std::char_traits(char)", "std::allocator(char)" ] ) def test_split_on_map(self): self.__test_is_call_invocation_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" ) self.__test_split_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" , "map" , [ "long int" , "std::vector(int, std::allocator(int) )" , "std::less(long int)" , "std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) )" ] ) def test_join_on_vector(self): self.failUnless( "vector( int, std::allocator(int) )" == declarations.call_invocation.join("vector", ( "int", "std::allocator(int)" ) ) ) def test_find_args(self): temp = 'x()()' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,2) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (3, 4) == found ) temp = 'x(int,int)(1,2)' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,9) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (10, 14) == found ) def test_bug_unmatched_brace( self ): src = 'AlternativeName((&string("")), (&string("")), (&string("")))' self.__test_split_impl( src , 'AlternativeName' , ['(&string(""))', '(&string(""))', '(&string(""))'] ) def create_suite(): suite = unittest.TestSuite() suite.addTest( unittest.makeSuite(tester_t)) return suite def run_suite(): unittest.TextTestRunner(verbosity=2).run( create_suite() ) if __name__ == "__main__": run_suite() <|fim▁end|>
__init__
<|file_name|>call_invocation_tester.py<|end_file_name|><|fim▁begin|>#! /usr/bin/python # Copyright 2004-2008 Roman Yakovenko. # Distributed under the Boost Software License, Version 1.0. (See # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) import unittest import autoconfig import pygccxml from pygccxml.utils import * from pygccxml.parser import * from pygccxml import declarations class tester_t( unittest.TestCase ): def __init__(self, *args ): unittest.TestCase.__init__( self, *args ) def <|fim_middle|>(self, decl_string, name, args): self.failUnless( ( name, args ) == declarations.call_invocation.split( decl_string ) ) def __test_split_recursive_impl(self, decl_string, control_seq): self.failUnless( control_seq == declarations.call_invocation.split_recursive( decl_string ) ) def __test_is_call_invocation_impl( self, decl_string ): self.failUnless( declarations.call_invocation.is_call_invocation( decl_string ) ) def test_split_on_vector(self): self.__test_is_call_invocation_impl( "vector(int,std::allocator(int) )" ) self.__test_split_impl( "vector(int,std::allocator(int) )" , "vector" , [ "int", "std::allocator(int)" ] ) self.__test_split_recursive_impl( "vector(int,std::allocator(int) )" , [ ( "vector", [ "int", "std::allocator(int)" ] ) , ( "std::allocator", ["int"] ) ] ) def test_split_on_string(self): self.__test_is_call_invocation_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" ) self.__test_split_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" , "basic_string" , [ "char", "std::char_traits(char)", "std::allocator(char)" ] ) def test_split_on_map(self): self.__test_is_call_invocation_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" ) self.__test_split_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" , "map" , [ "long int" , "std::vector(int, std::allocator(int) )" , "std::less(long int)" , "std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) )" ] ) def test_join_on_vector(self): self.failUnless( "vector( int, std::allocator(int) )" == declarations.call_invocation.join("vector", ( "int", "std::allocator(int)" ) ) ) def test_find_args(self): temp = 'x()()' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,2) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (3, 4) == found ) temp = 'x(int,int)(1,2)' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,9) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (10, 14) == found ) def test_bug_unmatched_brace( self ): src = 'AlternativeName((&string("")), (&string("")), (&string("")))' self.__test_split_impl( src , 'AlternativeName' , ['(&string(""))', '(&string(""))', '(&string(""))'] ) def create_suite(): suite = unittest.TestSuite() suite.addTest( unittest.makeSuite(tester_t)) return suite def run_suite(): unittest.TextTestRunner(verbosity=2).run( create_suite() ) if __name__ == "__main__": run_suite() <|fim▁end|>
__test_split_impl
<|file_name|>call_invocation_tester.py<|end_file_name|><|fim▁begin|>#! /usr/bin/python # Copyright 2004-2008 Roman Yakovenko. # Distributed under the Boost Software License, Version 1.0. (See # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) import unittest import autoconfig import pygccxml from pygccxml.utils import * from pygccxml.parser import * from pygccxml import declarations class tester_t( unittest.TestCase ): def __init__(self, *args ): unittest.TestCase.__init__( self, *args ) def __test_split_impl(self, decl_string, name, args): self.failUnless( ( name, args ) == declarations.call_invocation.split( decl_string ) ) def <|fim_middle|>(self, decl_string, control_seq): self.failUnless( control_seq == declarations.call_invocation.split_recursive( decl_string ) ) def __test_is_call_invocation_impl( self, decl_string ): self.failUnless( declarations.call_invocation.is_call_invocation( decl_string ) ) def test_split_on_vector(self): self.__test_is_call_invocation_impl( "vector(int,std::allocator(int) )" ) self.__test_split_impl( "vector(int,std::allocator(int) )" , "vector" , [ "int", "std::allocator(int)" ] ) self.__test_split_recursive_impl( "vector(int,std::allocator(int) )" , [ ( "vector", [ "int", "std::allocator(int)" ] ) , ( "std::allocator", ["int"] ) ] ) def test_split_on_string(self): self.__test_is_call_invocation_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" ) self.__test_split_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" , "basic_string" , [ "char", "std::char_traits(char)", "std::allocator(char)" ] ) def test_split_on_map(self): self.__test_is_call_invocation_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" ) self.__test_split_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" , "map" , [ "long int" , "std::vector(int, std::allocator(int) )" , "std::less(long int)" , "std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) )" ] ) def test_join_on_vector(self): self.failUnless( "vector( int, std::allocator(int) )" == declarations.call_invocation.join("vector", ( "int", "std::allocator(int)" ) ) ) def test_find_args(self): temp = 'x()()' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,2) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (3, 4) == found ) temp = 'x(int,int)(1,2)' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,9) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (10, 14) == found ) def test_bug_unmatched_brace( self ): src = 'AlternativeName((&string("")), (&string("")), (&string("")))' self.__test_split_impl( src , 'AlternativeName' , ['(&string(""))', '(&string(""))', '(&string(""))'] ) def create_suite(): suite = unittest.TestSuite() suite.addTest( unittest.makeSuite(tester_t)) return suite def run_suite(): unittest.TextTestRunner(verbosity=2).run( create_suite() ) if __name__ == "__main__": run_suite() <|fim▁end|>
__test_split_recursive_impl
<|file_name|>call_invocation_tester.py<|end_file_name|><|fim▁begin|>#! /usr/bin/python # Copyright 2004-2008 Roman Yakovenko. # Distributed under the Boost Software License, Version 1.0. (See # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) import unittest import autoconfig import pygccxml from pygccxml.utils import * from pygccxml.parser import * from pygccxml import declarations class tester_t( unittest.TestCase ): def __init__(self, *args ): unittest.TestCase.__init__( self, *args ) def __test_split_impl(self, decl_string, name, args): self.failUnless( ( name, args ) == declarations.call_invocation.split( decl_string ) ) def __test_split_recursive_impl(self, decl_string, control_seq): self.failUnless( control_seq == declarations.call_invocation.split_recursive( decl_string ) ) def <|fim_middle|>( self, decl_string ): self.failUnless( declarations.call_invocation.is_call_invocation( decl_string ) ) def test_split_on_vector(self): self.__test_is_call_invocation_impl( "vector(int,std::allocator(int) )" ) self.__test_split_impl( "vector(int,std::allocator(int) )" , "vector" , [ "int", "std::allocator(int)" ] ) self.__test_split_recursive_impl( "vector(int,std::allocator(int) )" , [ ( "vector", [ "int", "std::allocator(int)" ] ) , ( "std::allocator", ["int"] ) ] ) def test_split_on_string(self): self.__test_is_call_invocation_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" ) self.__test_split_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" , "basic_string" , [ "char", "std::char_traits(char)", "std::allocator(char)" ] ) def test_split_on_map(self): self.__test_is_call_invocation_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" ) self.__test_split_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" , "map" , [ "long int" , "std::vector(int, std::allocator(int) )" , "std::less(long int)" , "std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) )" ] ) def test_join_on_vector(self): self.failUnless( "vector( int, std::allocator(int) )" == declarations.call_invocation.join("vector", ( "int", "std::allocator(int)" ) ) ) def test_find_args(self): temp = 'x()()' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,2) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (3, 4) == found ) temp = 'x(int,int)(1,2)' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,9) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (10, 14) == found ) def test_bug_unmatched_brace( self ): src = 'AlternativeName((&string("")), (&string("")), (&string("")))' self.__test_split_impl( src , 'AlternativeName' , ['(&string(""))', '(&string(""))', '(&string(""))'] ) def create_suite(): suite = unittest.TestSuite() suite.addTest( unittest.makeSuite(tester_t)) return suite def run_suite(): unittest.TextTestRunner(verbosity=2).run( create_suite() ) if __name__ == "__main__": run_suite() <|fim▁end|>
__test_is_call_invocation_impl
<|file_name|>call_invocation_tester.py<|end_file_name|><|fim▁begin|>#! /usr/bin/python # Copyright 2004-2008 Roman Yakovenko. # Distributed under the Boost Software License, Version 1.0. (See # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) import unittest import autoconfig import pygccxml from pygccxml.utils import * from pygccxml.parser import * from pygccxml import declarations class tester_t( unittest.TestCase ): def __init__(self, *args ): unittest.TestCase.__init__( self, *args ) def __test_split_impl(self, decl_string, name, args): self.failUnless( ( name, args ) == declarations.call_invocation.split( decl_string ) ) def __test_split_recursive_impl(self, decl_string, control_seq): self.failUnless( control_seq == declarations.call_invocation.split_recursive( decl_string ) ) def __test_is_call_invocation_impl( self, decl_string ): self.failUnless( declarations.call_invocation.is_call_invocation( decl_string ) ) def <|fim_middle|>(self): self.__test_is_call_invocation_impl( "vector(int,std::allocator(int) )" ) self.__test_split_impl( "vector(int,std::allocator(int) )" , "vector" , [ "int", "std::allocator(int)" ] ) self.__test_split_recursive_impl( "vector(int,std::allocator(int) )" , [ ( "vector", [ "int", "std::allocator(int)" ] ) , ( "std::allocator", ["int"] ) ] ) def test_split_on_string(self): self.__test_is_call_invocation_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" ) self.__test_split_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" , "basic_string" , [ "char", "std::char_traits(char)", "std::allocator(char)" ] ) def test_split_on_map(self): self.__test_is_call_invocation_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" ) self.__test_split_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" , "map" , [ "long int" , "std::vector(int, std::allocator(int) )" , "std::less(long int)" , "std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) )" ] ) def test_join_on_vector(self): self.failUnless( "vector( int, std::allocator(int) )" == declarations.call_invocation.join("vector", ( "int", "std::allocator(int)" ) ) ) def test_find_args(self): temp = 'x()()' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,2) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (3, 4) == found ) temp = 'x(int,int)(1,2)' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,9) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (10, 14) == found ) def test_bug_unmatched_brace( self ): src = 'AlternativeName((&string("")), (&string("")), (&string("")))' self.__test_split_impl( src , 'AlternativeName' , ['(&string(""))', '(&string(""))', '(&string(""))'] ) def create_suite(): suite = unittest.TestSuite() suite.addTest( unittest.makeSuite(tester_t)) return suite def run_suite(): unittest.TextTestRunner(verbosity=2).run( create_suite() ) if __name__ == "__main__": run_suite() <|fim▁end|>
test_split_on_vector
<|file_name|>call_invocation_tester.py<|end_file_name|><|fim▁begin|>#! /usr/bin/python # Copyright 2004-2008 Roman Yakovenko. # Distributed under the Boost Software License, Version 1.0. (See # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) import unittest import autoconfig import pygccxml from pygccxml.utils import * from pygccxml.parser import * from pygccxml import declarations class tester_t( unittest.TestCase ): def __init__(self, *args ): unittest.TestCase.__init__( self, *args ) def __test_split_impl(self, decl_string, name, args): self.failUnless( ( name, args ) == declarations.call_invocation.split( decl_string ) ) def __test_split_recursive_impl(self, decl_string, control_seq): self.failUnless( control_seq == declarations.call_invocation.split_recursive( decl_string ) ) def __test_is_call_invocation_impl( self, decl_string ): self.failUnless( declarations.call_invocation.is_call_invocation( decl_string ) ) def test_split_on_vector(self): self.__test_is_call_invocation_impl( "vector(int,std::allocator(int) )" ) self.__test_split_impl( "vector(int,std::allocator(int) )" , "vector" , [ "int", "std::allocator(int)" ] ) self.__test_split_recursive_impl( "vector(int,std::allocator(int) )" , [ ( "vector", [ "int", "std::allocator(int)" ] ) , ( "std::allocator", ["int"] ) ] ) def <|fim_middle|>(self): self.__test_is_call_invocation_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" ) self.__test_split_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" , "basic_string" , [ "char", "std::char_traits(char)", "std::allocator(char)" ] ) def test_split_on_map(self): self.__test_is_call_invocation_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" ) self.__test_split_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" , "map" , [ "long int" , "std::vector(int, std::allocator(int) )" , "std::less(long int)" , "std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) )" ] ) def test_join_on_vector(self): self.failUnless( "vector( int, std::allocator(int) )" == declarations.call_invocation.join("vector", ( "int", "std::allocator(int)" ) ) ) def test_find_args(self): temp = 'x()()' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,2) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (3, 4) == found ) temp = 'x(int,int)(1,2)' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,9) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (10, 14) == found ) def test_bug_unmatched_brace( self ): src = 'AlternativeName((&string("")), (&string("")), (&string("")))' self.__test_split_impl( src , 'AlternativeName' , ['(&string(""))', '(&string(""))', '(&string(""))'] ) def create_suite(): suite = unittest.TestSuite() suite.addTest( unittest.makeSuite(tester_t)) return suite def run_suite(): unittest.TextTestRunner(verbosity=2).run( create_suite() ) if __name__ == "__main__": run_suite() <|fim▁end|>
test_split_on_string
<|file_name|>call_invocation_tester.py<|end_file_name|><|fim▁begin|>#! /usr/bin/python # Copyright 2004-2008 Roman Yakovenko. # Distributed under the Boost Software License, Version 1.0. (See # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) import unittest import autoconfig import pygccxml from pygccxml.utils import * from pygccxml.parser import * from pygccxml import declarations class tester_t( unittest.TestCase ): def __init__(self, *args ): unittest.TestCase.__init__( self, *args ) def __test_split_impl(self, decl_string, name, args): self.failUnless( ( name, args ) == declarations.call_invocation.split( decl_string ) ) def __test_split_recursive_impl(self, decl_string, control_seq): self.failUnless( control_seq == declarations.call_invocation.split_recursive( decl_string ) ) def __test_is_call_invocation_impl( self, decl_string ): self.failUnless( declarations.call_invocation.is_call_invocation( decl_string ) ) def test_split_on_vector(self): self.__test_is_call_invocation_impl( "vector(int,std::allocator(int) )" ) self.__test_split_impl( "vector(int,std::allocator(int) )" , "vector" , [ "int", "std::allocator(int)" ] ) self.__test_split_recursive_impl( "vector(int,std::allocator(int) )" , [ ( "vector", [ "int", "std::allocator(int)" ] ) , ( "std::allocator", ["int"] ) ] ) def test_split_on_string(self): self.__test_is_call_invocation_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" ) self.__test_split_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" , "basic_string" , [ "char", "std::char_traits(char)", "std::allocator(char)" ] ) def <|fim_middle|>(self): self.__test_is_call_invocation_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" ) self.__test_split_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" , "map" , [ "long int" , "std::vector(int, std::allocator(int) )" , "std::less(long int)" , "std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) )" ] ) def test_join_on_vector(self): self.failUnless( "vector( int, std::allocator(int) )" == declarations.call_invocation.join("vector", ( "int", "std::allocator(int)" ) ) ) def test_find_args(self): temp = 'x()()' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,2) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (3, 4) == found ) temp = 'x(int,int)(1,2)' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,9) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (10, 14) == found ) def test_bug_unmatched_brace( self ): src = 'AlternativeName((&string("")), (&string("")), (&string("")))' self.__test_split_impl( src , 'AlternativeName' , ['(&string(""))', '(&string(""))', '(&string(""))'] ) def create_suite(): suite = unittest.TestSuite() suite.addTest( unittest.makeSuite(tester_t)) return suite def run_suite(): unittest.TextTestRunner(verbosity=2).run( create_suite() ) if __name__ == "__main__": run_suite() <|fim▁end|>
test_split_on_map
<|file_name|>call_invocation_tester.py<|end_file_name|><|fim▁begin|>#! /usr/bin/python # Copyright 2004-2008 Roman Yakovenko. # Distributed under the Boost Software License, Version 1.0. (See # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) import unittest import autoconfig import pygccxml from pygccxml.utils import * from pygccxml.parser import * from pygccxml import declarations class tester_t( unittest.TestCase ): def __init__(self, *args ): unittest.TestCase.__init__( self, *args ) def __test_split_impl(self, decl_string, name, args): self.failUnless( ( name, args ) == declarations.call_invocation.split( decl_string ) ) def __test_split_recursive_impl(self, decl_string, control_seq): self.failUnless( control_seq == declarations.call_invocation.split_recursive( decl_string ) ) def __test_is_call_invocation_impl( self, decl_string ): self.failUnless( declarations.call_invocation.is_call_invocation( decl_string ) ) def test_split_on_vector(self): self.__test_is_call_invocation_impl( "vector(int,std::allocator(int) )" ) self.__test_split_impl( "vector(int,std::allocator(int) )" , "vector" , [ "int", "std::allocator(int)" ] ) self.__test_split_recursive_impl( "vector(int,std::allocator(int) )" , [ ( "vector", [ "int", "std::allocator(int)" ] ) , ( "std::allocator", ["int"] ) ] ) def test_split_on_string(self): self.__test_is_call_invocation_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" ) self.__test_split_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" , "basic_string" , [ "char", "std::char_traits(char)", "std::allocator(char)" ] ) def test_split_on_map(self): self.__test_is_call_invocation_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" ) self.__test_split_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" , "map" , [ "long int" , "std::vector(int, std::allocator(int) )" , "std::less(long int)" , "std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) )" ] ) def <|fim_middle|>(self): self.failUnless( "vector( int, std::allocator(int) )" == declarations.call_invocation.join("vector", ( "int", "std::allocator(int)" ) ) ) def test_find_args(self): temp = 'x()()' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,2) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (3, 4) == found ) temp = 'x(int,int)(1,2)' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,9) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (10, 14) == found ) def test_bug_unmatched_brace( self ): src = 'AlternativeName((&string("")), (&string("")), (&string("")))' self.__test_split_impl( src , 'AlternativeName' , ['(&string(""))', '(&string(""))', '(&string(""))'] ) def create_suite(): suite = unittest.TestSuite() suite.addTest( unittest.makeSuite(tester_t)) return suite def run_suite(): unittest.TextTestRunner(verbosity=2).run( create_suite() ) if __name__ == "__main__": run_suite() <|fim▁end|>
test_join_on_vector
<|file_name|>call_invocation_tester.py<|end_file_name|><|fim▁begin|>#! /usr/bin/python # Copyright 2004-2008 Roman Yakovenko. # Distributed under the Boost Software License, Version 1.0. (See # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) import unittest import autoconfig import pygccxml from pygccxml.utils import * from pygccxml.parser import * from pygccxml import declarations class tester_t( unittest.TestCase ): def __init__(self, *args ): unittest.TestCase.__init__( self, *args ) def __test_split_impl(self, decl_string, name, args): self.failUnless( ( name, args ) == declarations.call_invocation.split( decl_string ) ) def __test_split_recursive_impl(self, decl_string, control_seq): self.failUnless( control_seq == declarations.call_invocation.split_recursive( decl_string ) ) def __test_is_call_invocation_impl( self, decl_string ): self.failUnless( declarations.call_invocation.is_call_invocation( decl_string ) ) def test_split_on_vector(self): self.__test_is_call_invocation_impl( "vector(int,std::allocator(int) )" ) self.__test_split_impl( "vector(int,std::allocator(int) )" , "vector" , [ "int", "std::allocator(int)" ] ) self.__test_split_recursive_impl( "vector(int,std::allocator(int) )" , [ ( "vector", [ "int", "std::allocator(int)" ] ) , ( "std::allocator", ["int"] ) ] ) def test_split_on_string(self): self.__test_is_call_invocation_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" ) self.__test_split_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" , "basic_string" , [ "char", "std::char_traits(char)", "std::allocator(char)" ] ) def test_split_on_map(self): self.__test_is_call_invocation_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" ) self.__test_split_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" , "map" , [ "long int" , "std::vector(int, std::allocator(int) )" , "std::less(long int)" , "std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) )" ] ) def test_join_on_vector(self): self.failUnless( "vector( int, std::allocator(int) )" == declarations.call_invocation.join("vector", ( "int", "std::allocator(int)" ) ) ) def <|fim_middle|>(self): temp = 'x()()' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,2) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (3, 4) == found ) temp = 'x(int,int)(1,2)' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,9) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (10, 14) == found ) def test_bug_unmatched_brace( self ): src = 'AlternativeName((&string("")), (&string("")), (&string("")))' self.__test_split_impl( src , 'AlternativeName' , ['(&string(""))', '(&string(""))', '(&string(""))'] ) def create_suite(): suite = unittest.TestSuite() suite.addTest( unittest.makeSuite(tester_t)) return suite def run_suite(): unittest.TextTestRunner(verbosity=2).run( create_suite() ) if __name__ == "__main__": run_suite() <|fim▁end|>
test_find_args
<|file_name|>call_invocation_tester.py<|end_file_name|><|fim▁begin|>#! /usr/bin/python # Copyright 2004-2008 Roman Yakovenko. # Distributed under the Boost Software License, Version 1.0. (See # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) import unittest import autoconfig import pygccxml from pygccxml.utils import * from pygccxml.parser import * from pygccxml import declarations class tester_t( unittest.TestCase ): def __init__(self, *args ): unittest.TestCase.__init__( self, *args ) def __test_split_impl(self, decl_string, name, args): self.failUnless( ( name, args ) == declarations.call_invocation.split( decl_string ) ) def __test_split_recursive_impl(self, decl_string, control_seq): self.failUnless( control_seq == declarations.call_invocation.split_recursive( decl_string ) ) def __test_is_call_invocation_impl( self, decl_string ): self.failUnless( declarations.call_invocation.is_call_invocation( decl_string ) ) def test_split_on_vector(self): self.__test_is_call_invocation_impl( "vector(int,std::allocator(int) )" ) self.__test_split_impl( "vector(int,std::allocator(int) )" , "vector" , [ "int", "std::allocator(int)" ] ) self.__test_split_recursive_impl( "vector(int,std::allocator(int) )" , [ ( "vector", [ "int", "std::allocator(int)" ] ) , ( "std::allocator", ["int"] ) ] ) def test_split_on_string(self): self.__test_is_call_invocation_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" ) self.__test_split_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" , "basic_string" , [ "char", "std::char_traits(char)", "std::allocator(char)" ] ) def test_split_on_map(self): self.__test_is_call_invocation_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" ) self.__test_split_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" , "map" , [ "long int" , "std::vector(int, std::allocator(int) )" , "std::less(long int)" , "std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) )" ] ) def test_join_on_vector(self): self.failUnless( "vector( int, std::allocator(int) )" == declarations.call_invocation.join("vector", ( "int", "std::allocator(int)" ) ) ) def test_find_args(self): temp = 'x()()' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,2) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (3, 4) == found ) temp = 'x(int,int)(1,2)' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,9) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (10, 14) == found ) def <|fim_middle|>( self ): src = 'AlternativeName((&string("")), (&string("")), (&string("")))' self.__test_split_impl( src , 'AlternativeName' , ['(&string(""))', '(&string(""))', '(&string(""))'] ) def create_suite(): suite = unittest.TestSuite() suite.addTest( unittest.makeSuite(tester_t)) return suite def run_suite(): unittest.TextTestRunner(verbosity=2).run( create_suite() ) if __name__ == "__main__": run_suite() <|fim▁end|>
test_bug_unmatched_brace
<|file_name|>call_invocation_tester.py<|end_file_name|><|fim▁begin|>#! /usr/bin/python # Copyright 2004-2008 Roman Yakovenko. # Distributed under the Boost Software License, Version 1.0. (See # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) import unittest import autoconfig import pygccxml from pygccxml.utils import * from pygccxml.parser import * from pygccxml import declarations class tester_t( unittest.TestCase ): def __init__(self, *args ): unittest.TestCase.__init__( self, *args ) def __test_split_impl(self, decl_string, name, args): self.failUnless( ( name, args ) == declarations.call_invocation.split( decl_string ) ) def __test_split_recursive_impl(self, decl_string, control_seq): self.failUnless( control_seq == declarations.call_invocation.split_recursive( decl_string ) ) def __test_is_call_invocation_impl( self, decl_string ): self.failUnless( declarations.call_invocation.is_call_invocation( decl_string ) ) def test_split_on_vector(self): self.__test_is_call_invocation_impl( "vector(int,std::allocator(int) )" ) self.__test_split_impl( "vector(int,std::allocator(int) )" , "vector" , [ "int", "std::allocator(int)" ] ) self.__test_split_recursive_impl( "vector(int,std::allocator(int) )" , [ ( "vector", [ "int", "std::allocator(int)" ] ) , ( "std::allocator", ["int"] ) ] ) def test_split_on_string(self): self.__test_is_call_invocation_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" ) self.__test_split_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" , "basic_string" , [ "char", "std::char_traits(char)", "std::allocator(char)" ] ) def test_split_on_map(self): self.__test_is_call_invocation_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" ) self.__test_split_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" , "map" , [ "long int" , "std::vector(int, std::allocator(int) )" , "std::less(long int)" , "std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) )" ] ) def test_join_on_vector(self): self.failUnless( "vector( int, std::allocator(int) )" == declarations.call_invocation.join("vector", ( "int", "std::allocator(int)" ) ) ) def test_find_args(self): temp = 'x()()' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,2) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (3, 4) == found ) temp = 'x(int,int)(1,2)' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,9) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (10, 14) == found ) def test_bug_unmatched_brace( self ): src = 'AlternativeName((&string("")), (&string("")), (&string("")))' self.__test_split_impl( src , 'AlternativeName' , ['(&string(""))', '(&string(""))', '(&string(""))'] ) def <|fim_middle|>(): suite = unittest.TestSuite() suite.addTest( unittest.makeSuite(tester_t)) return suite def run_suite(): unittest.TextTestRunner(verbosity=2).run( create_suite() ) if __name__ == "__main__": run_suite() <|fim▁end|>
create_suite
<|file_name|>call_invocation_tester.py<|end_file_name|><|fim▁begin|>#! /usr/bin/python # Copyright 2004-2008 Roman Yakovenko. # Distributed under the Boost Software License, Version 1.0. (See # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) import unittest import autoconfig import pygccxml from pygccxml.utils import * from pygccxml.parser import * from pygccxml import declarations class tester_t( unittest.TestCase ): def __init__(self, *args ): unittest.TestCase.__init__( self, *args ) def __test_split_impl(self, decl_string, name, args): self.failUnless( ( name, args ) == declarations.call_invocation.split( decl_string ) ) def __test_split_recursive_impl(self, decl_string, control_seq): self.failUnless( control_seq == declarations.call_invocation.split_recursive( decl_string ) ) def __test_is_call_invocation_impl( self, decl_string ): self.failUnless( declarations.call_invocation.is_call_invocation( decl_string ) ) def test_split_on_vector(self): self.__test_is_call_invocation_impl( "vector(int,std::allocator(int) )" ) self.__test_split_impl( "vector(int,std::allocator(int) )" , "vector" , [ "int", "std::allocator(int)" ] ) self.__test_split_recursive_impl( "vector(int,std::allocator(int) )" , [ ( "vector", [ "int", "std::allocator(int)" ] ) , ( "std::allocator", ["int"] ) ] ) def test_split_on_string(self): self.__test_is_call_invocation_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" ) self.__test_split_impl( "basic_string(char,std::char_traits(char),std::allocator(char) )" , "basic_string" , [ "char", "std::char_traits(char)", "std::allocator(char)" ] ) def test_split_on_map(self): self.__test_is_call_invocation_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" ) self.__test_split_impl( "map(long int,std::vector(int, std::allocator(int) ),std::less(long int),std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) ) )" , "map" , [ "long int" , "std::vector(int, std::allocator(int) )" , "std::less(long int)" , "std::allocator(std::pair(const long int, std::vector(int, std::allocator(int) ) ) )" ] ) def test_join_on_vector(self): self.failUnless( "vector( int, std::allocator(int) )" == declarations.call_invocation.join("vector", ( "int", "std::allocator(int)" ) ) ) def test_find_args(self): temp = 'x()()' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,2) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (3, 4) == found ) temp = 'x(int,int)(1,2)' found = declarations.call_invocation.find_args( temp ) self.failUnless( (1,9) == found ) found = declarations.call_invocation.find_args( temp, found[1]+1 ) self.failUnless( (10, 14) == found ) def test_bug_unmatched_brace( self ): src = 'AlternativeName((&string("")), (&string("")), (&string("")))' self.__test_split_impl( src , 'AlternativeName' , ['(&string(""))', '(&string(""))', '(&string(""))'] ) def create_suite(): suite = unittest.TestSuite() suite.addTest( unittest.makeSuite(tester_t)) return suite def <|fim_middle|>(): unittest.TextTestRunner(verbosity=2).run( create_suite() ) if __name__ == "__main__": run_suite() <|fim▁end|>
run_suite
<|file_name|>data_api.py<|end_file_name|><|fim▁begin|><|fim▁hole|>from colab.plugins.utils.proxy_data_api import ProxyDataAPI class JenkinsDataAPI(ProxyDataAPI): def fetch_data(self): pass<|fim▁end|>
<|file_name|>data_api.py<|end_file_name|><|fim▁begin|>from colab.plugins.utils.proxy_data_api import ProxyDataAPI class JenkinsDataAPI(ProxyDataAPI): <|fim_middle|> <|fim▁end|>
def fetch_data(self): pass
<|file_name|>data_api.py<|end_file_name|><|fim▁begin|>from colab.plugins.utils.proxy_data_api import ProxyDataAPI class JenkinsDataAPI(ProxyDataAPI): def fetch_data(self): <|fim_middle|> <|fim▁end|>
pass
<|file_name|>data_api.py<|end_file_name|><|fim▁begin|>from colab.plugins.utils.proxy_data_api import ProxyDataAPI class JenkinsDataAPI(ProxyDataAPI): def <|fim_middle|>(self): pass <|fim▁end|>
fetch_data
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|>import base64 try: from functools import wraps except ImportError: from django.utils.functional import wraps # Python 2.3, 2.4 fallback. from django import http, template from django.conf import settings from django.contrib.auth.models import User from django.contrib.auth import authenticate, login from django.shortcuts import render_to_response from django.utils.translation import ugettext_lazy, ugettext as _ ERROR_MESSAGE = ugettext_lazy("Please enter a correct username and password. Note that both fields are case-sensitive.") LOGIN_FORM_KEY = 'this_is_the_login_form' def _display_login_form(request, error_message=''): request.session.set_test_cookie() return render_to_response('admin/login.html', { 'title': _('Log in'), 'app_path': request.get_full_path(), 'error_message': error_message }, context_instance=template.RequestContext(request)) def staff_member_required(view_func): """ Decorator for views that checks that the user is logged in and is a staff member, displaying the login page if necessary. """ def _checklogin(request, *args, **kwargs): if request.user.is_authenticated() and request.user.is_staff: # The user is valid. Continue to the admin page. return view_func(request, *args, **kwargs) assert hasattr(request, 'session'), "The Django admin requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'." # If this isn't already the login page, display it. if LOGIN_FORM_KEY not in request.POST: if request.POST: message = _("Please log in again, because your session has expired.") else: message = "" return _display_login_form(request, message) # Check that the user accepts cookies. if not request.session.test_cookie_worked(): message = _("Looks like your browser isn't configured to accept cookies. Please enable cookies, reload this page, and try again.") return _display_login_form(request, message) else: request.session.delete_test_cookie() # Check the password. username = request.POST.get('username', None) password = request.POST.get('password', None) user = authenticate(username=username, password=password) if user is None: message = ERROR_MESSAGE<|fim▁hole|> users = list(User.all().filter('email =', username)) if len(users) == 1 and users[0].check_password(password): message = _("Your e-mail address is not your username. Try '%s' instead.") % users[0].username else: # Either we cannot find the user, or if more than 1 # we cannot guess which user is the correct one. message = _("Usernames cannot contain the '@' character.") return _display_login_form(request, message) # The user data is correct; log in the user in and continue. else: if user.is_active and user.is_staff: login(request, user) return http.HttpResponseRedirect(request.get_full_path()) else: return _display_login_form(request, ERROR_MESSAGE) return wraps(view_func)(_checklogin)<|fim▁end|>
if '@' in username: # Mistakenly entered e-mail address instead of username? Look it up.
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|>import base64 try: from functools import wraps except ImportError: from django.utils.functional import wraps # Python 2.3, 2.4 fallback. from django import http, template from django.conf import settings from django.contrib.auth.models import User from django.contrib.auth import authenticate, login from django.shortcuts import render_to_response from django.utils.translation import ugettext_lazy, ugettext as _ ERROR_MESSAGE = ugettext_lazy("Please enter a correct username and password. Note that both fields are case-sensitive.") LOGIN_FORM_KEY = 'this_is_the_login_form' def _display_login_form(request, error_message=''): <|fim_middle|> def staff_member_required(view_func): """ Decorator for views that checks that the user is logged in and is a staff member, displaying the login page if necessary. """ def _checklogin(request, *args, **kwargs): if request.user.is_authenticated() and request.user.is_staff: # The user is valid. Continue to the admin page. return view_func(request, *args, **kwargs) assert hasattr(request, 'session'), "The Django admin requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'." # If this isn't already the login page, display it. if LOGIN_FORM_KEY not in request.POST: if request.POST: message = _("Please log in again, because your session has expired.") else: message = "" return _display_login_form(request, message) # Check that the user accepts cookies. if not request.session.test_cookie_worked(): message = _("Looks like your browser isn't configured to accept cookies. Please enable cookies, reload this page, and try again.") return _display_login_form(request, message) else: request.session.delete_test_cookie() # Check the password. username = request.POST.get('username', None) password = request.POST.get('password', None) user = authenticate(username=username, password=password) if user is None: message = ERROR_MESSAGE if '@' in username: # Mistakenly entered e-mail address instead of username? Look it up. users = list(User.all().filter('email =', username)) if len(users) == 1 and users[0].check_password(password): message = _("Your e-mail address is not your username. Try '%s' instead.") % users[0].username else: # Either we cannot find the user, or if more than 1 # we cannot guess which user is the correct one. message = _("Usernames cannot contain the '@' character.") return _display_login_form(request, message) # The user data is correct; log in the user in and continue. else: if user.is_active and user.is_staff: login(request, user) return http.HttpResponseRedirect(request.get_full_path()) else: return _display_login_form(request, ERROR_MESSAGE) return wraps(view_func)(_checklogin) <|fim▁end|>
request.session.set_test_cookie() return render_to_response('admin/login.html', { 'title': _('Log in'), 'app_path': request.get_full_path(), 'error_message': error_message }, context_instance=template.RequestContext(request))
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|>import base64 try: from functools import wraps except ImportError: from django.utils.functional import wraps # Python 2.3, 2.4 fallback. from django import http, template from django.conf import settings from django.contrib.auth.models import User from django.contrib.auth import authenticate, login from django.shortcuts import render_to_response from django.utils.translation import ugettext_lazy, ugettext as _ ERROR_MESSAGE = ugettext_lazy("Please enter a correct username and password. Note that both fields are case-sensitive.") LOGIN_FORM_KEY = 'this_is_the_login_form' def _display_login_form(request, error_message=''): request.session.set_test_cookie() return render_to_response('admin/login.html', { 'title': _('Log in'), 'app_path': request.get_full_path(), 'error_message': error_message }, context_instance=template.RequestContext(request)) def staff_member_required(view_func): <|fim_middle|> <|fim▁end|>
""" Decorator for views that checks that the user is logged in and is a staff member, displaying the login page if necessary. """ def _checklogin(request, *args, **kwargs): if request.user.is_authenticated() and request.user.is_staff: # The user is valid. Continue to the admin page. return view_func(request, *args, **kwargs) assert hasattr(request, 'session'), "The Django admin requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'." # If this isn't already the login page, display it. if LOGIN_FORM_KEY not in request.POST: if request.POST: message = _("Please log in again, because your session has expired.") else: message = "" return _display_login_form(request, message) # Check that the user accepts cookies. if not request.session.test_cookie_worked(): message = _("Looks like your browser isn't configured to accept cookies. Please enable cookies, reload this page, and try again.") return _display_login_form(request, message) else: request.session.delete_test_cookie() # Check the password. username = request.POST.get('username', None) password = request.POST.get('password', None) user = authenticate(username=username, password=password) if user is None: message = ERROR_MESSAGE if '@' in username: # Mistakenly entered e-mail address instead of username? Look it up. users = list(User.all().filter('email =', username)) if len(users) == 1 and users[0].check_password(password): message = _("Your e-mail address is not your username. Try '%s' instead.") % users[0].username else: # Either we cannot find the user, or if more than 1 # we cannot guess which user is the correct one. message = _("Usernames cannot contain the '@' character.") return _display_login_form(request, message) # The user data is correct; log in the user in and continue. else: if user.is_active and user.is_staff: login(request, user) return http.HttpResponseRedirect(request.get_full_path()) else: return _display_login_form(request, ERROR_MESSAGE) return wraps(view_func)(_checklogin)
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|>import base64 try: from functools import wraps except ImportError: from django.utils.functional import wraps # Python 2.3, 2.4 fallback. from django import http, template from django.conf import settings from django.contrib.auth.models import User from django.contrib.auth import authenticate, login from django.shortcuts import render_to_response from django.utils.translation import ugettext_lazy, ugettext as _ ERROR_MESSAGE = ugettext_lazy("Please enter a correct username and password. Note that both fields are case-sensitive.") LOGIN_FORM_KEY = 'this_is_the_login_form' def _display_login_form(request, error_message=''): request.session.set_test_cookie() return render_to_response('admin/login.html', { 'title': _('Log in'), 'app_path': request.get_full_path(), 'error_message': error_message }, context_instance=template.RequestContext(request)) def staff_member_required(view_func): """ Decorator for views that checks that the user is logged in and is a staff member, displaying the login page if necessary. """ def _checklogin(request, *args, **kwargs): <|fim_middle|> return wraps(view_func)(_checklogin) <|fim▁end|>
if request.user.is_authenticated() and request.user.is_staff: # The user is valid. Continue to the admin page. return view_func(request, *args, **kwargs) assert hasattr(request, 'session'), "The Django admin requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'." # If this isn't already the login page, display it. if LOGIN_FORM_KEY not in request.POST: if request.POST: message = _("Please log in again, because your session has expired.") else: message = "" return _display_login_form(request, message) # Check that the user accepts cookies. if not request.session.test_cookie_worked(): message = _("Looks like your browser isn't configured to accept cookies. Please enable cookies, reload this page, and try again.") return _display_login_form(request, message) else: request.session.delete_test_cookie() # Check the password. username = request.POST.get('username', None) password = request.POST.get('password', None) user = authenticate(username=username, password=password) if user is None: message = ERROR_MESSAGE if '@' in username: # Mistakenly entered e-mail address instead of username? Look it up. users = list(User.all().filter('email =', username)) if len(users) == 1 and users[0].check_password(password): message = _("Your e-mail address is not your username. Try '%s' instead.") % users[0].username else: # Either we cannot find the user, or if more than 1 # we cannot guess which user is the correct one. message = _("Usernames cannot contain the '@' character.") return _display_login_form(request, message) # The user data is correct; log in the user in and continue. else: if user.is_active and user.is_staff: login(request, user) return http.HttpResponseRedirect(request.get_full_path()) else: return _display_login_form(request, ERROR_MESSAGE)
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|>import base64 try: from functools import wraps except ImportError: from django.utils.functional import wraps # Python 2.3, 2.4 fallback. from django import http, template from django.conf import settings from django.contrib.auth.models import User from django.contrib.auth import authenticate, login from django.shortcuts import render_to_response from django.utils.translation import ugettext_lazy, ugettext as _ ERROR_MESSAGE = ugettext_lazy("Please enter a correct username and password. Note that both fields are case-sensitive.") LOGIN_FORM_KEY = 'this_is_the_login_form' def _display_login_form(request, error_message=''): request.session.set_test_cookie() return render_to_response('admin/login.html', { 'title': _('Log in'), 'app_path': request.get_full_path(), 'error_message': error_message }, context_instance=template.RequestContext(request)) def staff_member_required(view_func): """ Decorator for views that checks that the user is logged in and is a staff member, displaying the login page if necessary. """ def _checklogin(request, *args, **kwargs): if request.user.is_authenticated() and request.user.is_staff: # The user is valid. Continue to the admin page. <|fim_middle|> assert hasattr(request, 'session'), "The Django admin requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'." # If this isn't already the login page, display it. if LOGIN_FORM_KEY not in request.POST: if request.POST: message = _("Please log in again, because your session has expired.") else: message = "" return _display_login_form(request, message) # Check that the user accepts cookies. if not request.session.test_cookie_worked(): message = _("Looks like your browser isn't configured to accept cookies. Please enable cookies, reload this page, and try again.") return _display_login_form(request, message) else: request.session.delete_test_cookie() # Check the password. username = request.POST.get('username', None) password = request.POST.get('password', None) user = authenticate(username=username, password=password) if user is None: message = ERROR_MESSAGE if '@' in username: # Mistakenly entered e-mail address instead of username? Look it up. users = list(User.all().filter('email =', username)) if len(users) == 1 and users[0].check_password(password): message = _("Your e-mail address is not your username. Try '%s' instead.") % users[0].username else: # Either we cannot find the user, or if more than 1 # we cannot guess which user is the correct one. message = _("Usernames cannot contain the '@' character.") return _display_login_form(request, message) # The user data is correct; log in the user in and continue. else: if user.is_active and user.is_staff: login(request, user) return http.HttpResponseRedirect(request.get_full_path()) else: return _display_login_form(request, ERROR_MESSAGE) return wraps(view_func)(_checklogin) <|fim▁end|>
return view_func(request, *args, **kwargs)
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|>import base64 try: from functools import wraps except ImportError: from django.utils.functional import wraps # Python 2.3, 2.4 fallback. from django import http, template from django.conf import settings from django.contrib.auth.models import User from django.contrib.auth import authenticate, login from django.shortcuts import render_to_response from django.utils.translation import ugettext_lazy, ugettext as _ ERROR_MESSAGE = ugettext_lazy("Please enter a correct username and password. Note that both fields are case-sensitive.") LOGIN_FORM_KEY = 'this_is_the_login_form' def _display_login_form(request, error_message=''): request.session.set_test_cookie() return render_to_response('admin/login.html', { 'title': _('Log in'), 'app_path': request.get_full_path(), 'error_message': error_message }, context_instance=template.RequestContext(request)) def staff_member_required(view_func): """ Decorator for views that checks that the user is logged in and is a staff member, displaying the login page if necessary. """ def _checklogin(request, *args, **kwargs): if request.user.is_authenticated() and request.user.is_staff: # The user is valid. Continue to the admin page. return view_func(request, *args, **kwargs) assert hasattr(request, 'session'), "The Django admin requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'." # If this isn't already the login page, display it. if LOGIN_FORM_KEY not in request.POST: <|fim_middle|> # Check that the user accepts cookies. if not request.session.test_cookie_worked(): message = _("Looks like your browser isn't configured to accept cookies. Please enable cookies, reload this page, and try again.") return _display_login_form(request, message) else: request.session.delete_test_cookie() # Check the password. username = request.POST.get('username', None) password = request.POST.get('password', None) user = authenticate(username=username, password=password) if user is None: message = ERROR_MESSAGE if '@' in username: # Mistakenly entered e-mail address instead of username? Look it up. users = list(User.all().filter('email =', username)) if len(users) == 1 and users[0].check_password(password): message = _("Your e-mail address is not your username. Try '%s' instead.") % users[0].username else: # Either we cannot find the user, or if more than 1 # we cannot guess which user is the correct one. message = _("Usernames cannot contain the '@' character.") return _display_login_form(request, message) # The user data is correct; log in the user in and continue. else: if user.is_active and user.is_staff: login(request, user) return http.HttpResponseRedirect(request.get_full_path()) else: return _display_login_form(request, ERROR_MESSAGE) return wraps(view_func)(_checklogin) <|fim▁end|>
if request.POST: message = _("Please log in again, because your session has expired.") else: message = "" return _display_login_form(request, message)
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|>import base64 try: from functools import wraps except ImportError: from django.utils.functional import wraps # Python 2.3, 2.4 fallback. from django import http, template from django.conf import settings from django.contrib.auth.models import User from django.contrib.auth import authenticate, login from django.shortcuts import render_to_response from django.utils.translation import ugettext_lazy, ugettext as _ ERROR_MESSAGE = ugettext_lazy("Please enter a correct username and password. Note that both fields are case-sensitive.") LOGIN_FORM_KEY = 'this_is_the_login_form' def _display_login_form(request, error_message=''): request.session.set_test_cookie() return render_to_response('admin/login.html', { 'title': _('Log in'), 'app_path': request.get_full_path(), 'error_message': error_message }, context_instance=template.RequestContext(request)) def staff_member_required(view_func): """ Decorator for views that checks that the user is logged in and is a staff member, displaying the login page if necessary. """ def _checklogin(request, *args, **kwargs): if request.user.is_authenticated() and request.user.is_staff: # The user is valid. Continue to the admin page. return view_func(request, *args, **kwargs) assert hasattr(request, 'session'), "The Django admin requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'." # If this isn't already the login page, display it. if LOGIN_FORM_KEY not in request.POST: if request.POST: <|fim_middle|> else: message = "" return _display_login_form(request, message) # Check that the user accepts cookies. if not request.session.test_cookie_worked(): message = _("Looks like your browser isn't configured to accept cookies. Please enable cookies, reload this page, and try again.") return _display_login_form(request, message) else: request.session.delete_test_cookie() # Check the password. username = request.POST.get('username', None) password = request.POST.get('password', None) user = authenticate(username=username, password=password) if user is None: message = ERROR_MESSAGE if '@' in username: # Mistakenly entered e-mail address instead of username? Look it up. users = list(User.all().filter('email =', username)) if len(users) == 1 and users[0].check_password(password): message = _("Your e-mail address is not your username. Try '%s' instead.") % users[0].username else: # Either we cannot find the user, or if more than 1 # we cannot guess which user is the correct one. message = _("Usernames cannot contain the '@' character.") return _display_login_form(request, message) # The user data is correct; log in the user in and continue. else: if user.is_active and user.is_staff: login(request, user) return http.HttpResponseRedirect(request.get_full_path()) else: return _display_login_form(request, ERROR_MESSAGE) return wraps(view_func)(_checklogin) <|fim▁end|>
message = _("Please log in again, because your session has expired.")
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|>import base64 try: from functools import wraps except ImportError: from django.utils.functional import wraps # Python 2.3, 2.4 fallback. from django import http, template from django.conf import settings from django.contrib.auth.models import User from django.contrib.auth import authenticate, login from django.shortcuts import render_to_response from django.utils.translation import ugettext_lazy, ugettext as _ ERROR_MESSAGE = ugettext_lazy("Please enter a correct username and password. Note that both fields are case-sensitive.") LOGIN_FORM_KEY = 'this_is_the_login_form' def _display_login_form(request, error_message=''): request.session.set_test_cookie() return render_to_response('admin/login.html', { 'title': _('Log in'), 'app_path': request.get_full_path(), 'error_message': error_message }, context_instance=template.RequestContext(request)) def staff_member_required(view_func): """ Decorator for views that checks that the user is logged in and is a staff member, displaying the login page if necessary. """ def _checklogin(request, *args, **kwargs): if request.user.is_authenticated() and request.user.is_staff: # The user is valid. Continue to the admin page. return view_func(request, *args, **kwargs) assert hasattr(request, 'session'), "The Django admin requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'." # If this isn't already the login page, display it. if LOGIN_FORM_KEY not in request.POST: if request.POST: message = _("Please log in again, because your session has expired.") else: <|fim_middle|> return _display_login_form(request, message) # Check that the user accepts cookies. if not request.session.test_cookie_worked(): message = _("Looks like your browser isn't configured to accept cookies. Please enable cookies, reload this page, and try again.") return _display_login_form(request, message) else: request.session.delete_test_cookie() # Check the password. username = request.POST.get('username', None) password = request.POST.get('password', None) user = authenticate(username=username, password=password) if user is None: message = ERROR_MESSAGE if '@' in username: # Mistakenly entered e-mail address instead of username? Look it up. users = list(User.all().filter('email =', username)) if len(users) == 1 and users[0].check_password(password): message = _("Your e-mail address is not your username. Try '%s' instead.") % users[0].username else: # Either we cannot find the user, or if more than 1 # we cannot guess which user is the correct one. message = _("Usernames cannot contain the '@' character.") return _display_login_form(request, message) # The user data is correct; log in the user in and continue. else: if user.is_active and user.is_staff: login(request, user) return http.HttpResponseRedirect(request.get_full_path()) else: return _display_login_form(request, ERROR_MESSAGE) return wraps(view_func)(_checklogin) <|fim▁end|>
message = ""
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|>import base64 try: from functools import wraps except ImportError: from django.utils.functional import wraps # Python 2.3, 2.4 fallback. from django import http, template from django.conf import settings from django.contrib.auth.models import User from django.contrib.auth import authenticate, login from django.shortcuts import render_to_response from django.utils.translation import ugettext_lazy, ugettext as _ ERROR_MESSAGE = ugettext_lazy("Please enter a correct username and password. Note that both fields are case-sensitive.") LOGIN_FORM_KEY = 'this_is_the_login_form' def _display_login_form(request, error_message=''): request.session.set_test_cookie() return render_to_response('admin/login.html', { 'title': _('Log in'), 'app_path': request.get_full_path(), 'error_message': error_message }, context_instance=template.RequestContext(request)) def staff_member_required(view_func): """ Decorator for views that checks that the user is logged in and is a staff member, displaying the login page if necessary. """ def _checklogin(request, *args, **kwargs): if request.user.is_authenticated() and request.user.is_staff: # The user is valid. Continue to the admin page. return view_func(request, *args, **kwargs) assert hasattr(request, 'session'), "The Django admin requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'." # If this isn't already the login page, display it. if LOGIN_FORM_KEY not in request.POST: if request.POST: message = _("Please log in again, because your session has expired.") else: message = "" return _display_login_form(request, message) # Check that the user accepts cookies. if not request.session.test_cookie_worked(): <|fim_middle|> else: request.session.delete_test_cookie() # Check the password. username = request.POST.get('username', None) password = request.POST.get('password', None) user = authenticate(username=username, password=password) if user is None: message = ERROR_MESSAGE if '@' in username: # Mistakenly entered e-mail address instead of username? Look it up. users = list(User.all().filter('email =', username)) if len(users) == 1 and users[0].check_password(password): message = _("Your e-mail address is not your username. Try '%s' instead.") % users[0].username else: # Either we cannot find the user, or if more than 1 # we cannot guess which user is the correct one. message = _("Usernames cannot contain the '@' character.") return _display_login_form(request, message) # The user data is correct; log in the user in and continue. else: if user.is_active and user.is_staff: login(request, user) return http.HttpResponseRedirect(request.get_full_path()) else: return _display_login_form(request, ERROR_MESSAGE) return wraps(view_func)(_checklogin) <|fim▁end|>
message = _("Looks like your browser isn't configured to accept cookies. Please enable cookies, reload this page, and try again.") return _display_login_form(request, message)
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|>import base64 try: from functools import wraps except ImportError: from django.utils.functional import wraps # Python 2.3, 2.4 fallback. from django import http, template from django.conf import settings from django.contrib.auth.models import User from django.contrib.auth import authenticate, login from django.shortcuts import render_to_response from django.utils.translation import ugettext_lazy, ugettext as _ ERROR_MESSAGE = ugettext_lazy("Please enter a correct username and password. Note that both fields are case-sensitive.") LOGIN_FORM_KEY = 'this_is_the_login_form' def _display_login_form(request, error_message=''): request.session.set_test_cookie() return render_to_response('admin/login.html', { 'title': _('Log in'), 'app_path': request.get_full_path(), 'error_message': error_message }, context_instance=template.RequestContext(request)) def staff_member_required(view_func): """ Decorator for views that checks that the user is logged in and is a staff member, displaying the login page if necessary. """ def _checklogin(request, *args, **kwargs): if request.user.is_authenticated() and request.user.is_staff: # The user is valid. Continue to the admin page. return view_func(request, *args, **kwargs) assert hasattr(request, 'session'), "The Django admin requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'." # If this isn't already the login page, display it. if LOGIN_FORM_KEY not in request.POST: if request.POST: message = _("Please log in again, because your session has expired.") else: message = "" return _display_login_form(request, message) # Check that the user accepts cookies. if not request.session.test_cookie_worked(): message = _("Looks like your browser isn't configured to accept cookies. Please enable cookies, reload this page, and try again.") return _display_login_form(request, message) else: <|fim_middle|> # Check the password. username = request.POST.get('username', None) password = request.POST.get('password', None) user = authenticate(username=username, password=password) if user is None: message = ERROR_MESSAGE if '@' in username: # Mistakenly entered e-mail address instead of username? Look it up. users = list(User.all().filter('email =', username)) if len(users) == 1 and users[0].check_password(password): message = _("Your e-mail address is not your username. Try '%s' instead.") % users[0].username else: # Either we cannot find the user, or if more than 1 # we cannot guess which user is the correct one. message = _("Usernames cannot contain the '@' character.") return _display_login_form(request, message) # The user data is correct; log in the user in and continue. else: if user.is_active and user.is_staff: login(request, user) return http.HttpResponseRedirect(request.get_full_path()) else: return _display_login_form(request, ERROR_MESSAGE) return wraps(view_func)(_checklogin) <|fim▁end|>
request.session.delete_test_cookie()
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|>import base64 try: from functools import wraps except ImportError: from django.utils.functional import wraps # Python 2.3, 2.4 fallback. from django import http, template from django.conf import settings from django.contrib.auth.models import User from django.contrib.auth import authenticate, login from django.shortcuts import render_to_response from django.utils.translation import ugettext_lazy, ugettext as _ ERROR_MESSAGE = ugettext_lazy("Please enter a correct username and password. Note that both fields are case-sensitive.") LOGIN_FORM_KEY = 'this_is_the_login_form' def _display_login_form(request, error_message=''): request.session.set_test_cookie() return render_to_response('admin/login.html', { 'title': _('Log in'), 'app_path': request.get_full_path(), 'error_message': error_message }, context_instance=template.RequestContext(request)) def staff_member_required(view_func): """ Decorator for views that checks that the user is logged in and is a staff member, displaying the login page if necessary. """ def _checklogin(request, *args, **kwargs): if request.user.is_authenticated() and request.user.is_staff: # The user is valid. Continue to the admin page. return view_func(request, *args, **kwargs) assert hasattr(request, 'session'), "The Django admin requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'." # If this isn't already the login page, display it. if LOGIN_FORM_KEY not in request.POST: if request.POST: message = _("Please log in again, because your session has expired.") else: message = "" return _display_login_form(request, message) # Check that the user accepts cookies. if not request.session.test_cookie_worked(): message = _("Looks like your browser isn't configured to accept cookies. Please enable cookies, reload this page, and try again.") return _display_login_form(request, message) else: request.session.delete_test_cookie() # Check the password. username = request.POST.get('username', None) password = request.POST.get('password', None) user = authenticate(username=username, password=password) if user is None: <|fim_middle|> # The user data is correct; log in the user in and continue. else: if user.is_active and user.is_staff: login(request, user) return http.HttpResponseRedirect(request.get_full_path()) else: return _display_login_form(request, ERROR_MESSAGE) return wraps(view_func)(_checklogin) <|fim▁end|>
message = ERROR_MESSAGE if '@' in username: # Mistakenly entered e-mail address instead of username? Look it up. users = list(User.all().filter('email =', username)) if len(users) == 1 and users[0].check_password(password): message = _("Your e-mail address is not your username. Try '%s' instead.") % users[0].username else: # Either we cannot find the user, or if more than 1 # we cannot guess which user is the correct one. message = _("Usernames cannot contain the '@' character.") return _display_login_form(request, message)
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|>import base64 try: from functools import wraps except ImportError: from django.utils.functional import wraps # Python 2.3, 2.4 fallback. from django import http, template from django.conf import settings from django.contrib.auth.models import User from django.contrib.auth import authenticate, login from django.shortcuts import render_to_response from django.utils.translation import ugettext_lazy, ugettext as _ ERROR_MESSAGE = ugettext_lazy("Please enter a correct username and password. Note that both fields are case-sensitive.") LOGIN_FORM_KEY = 'this_is_the_login_form' def _display_login_form(request, error_message=''): request.session.set_test_cookie() return render_to_response('admin/login.html', { 'title': _('Log in'), 'app_path': request.get_full_path(), 'error_message': error_message }, context_instance=template.RequestContext(request)) def staff_member_required(view_func): """ Decorator for views that checks that the user is logged in and is a staff member, displaying the login page if necessary. """ def _checklogin(request, *args, **kwargs): if request.user.is_authenticated() and request.user.is_staff: # The user is valid. Continue to the admin page. return view_func(request, *args, **kwargs) assert hasattr(request, 'session'), "The Django admin requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'." # If this isn't already the login page, display it. if LOGIN_FORM_KEY not in request.POST: if request.POST: message = _("Please log in again, because your session has expired.") else: message = "" return _display_login_form(request, message) # Check that the user accepts cookies. if not request.session.test_cookie_worked(): message = _("Looks like your browser isn't configured to accept cookies. Please enable cookies, reload this page, and try again.") return _display_login_form(request, message) else: request.session.delete_test_cookie() # Check the password. username = request.POST.get('username', None) password = request.POST.get('password', None) user = authenticate(username=username, password=password) if user is None: message = ERROR_MESSAGE if '@' in username: # Mistakenly entered e-mail address instead of username? Look it up. <|fim_middle|> return _display_login_form(request, message) # The user data is correct; log in the user in and continue. else: if user.is_active and user.is_staff: login(request, user) return http.HttpResponseRedirect(request.get_full_path()) else: return _display_login_form(request, ERROR_MESSAGE) return wraps(view_func)(_checklogin) <|fim▁end|>
users = list(User.all().filter('email =', username)) if len(users) == 1 and users[0].check_password(password): message = _("Your e-mail address is not your username. Try '%s' instead.") % users[0].username else: # Either we cannot find the user, or if more than 1 # we cannot guess which user is the correct one. message = _("Usernames cannot contain the '@' character.")
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|>import base64 try: from functools import wraps except ImportError: from django.utils.functional import wraps # Python 2.3, 2.4 fallback. from django import http, template from django.conf import settings from django.contrib.auth.models import User from django.contrib.auth import authenticate, login from django.shortcuts import render_to_response from django.utils.translation import ugettext_lazy, ugettext as _ ERROR_MESSAGE = ugettext_lazy("Please enter a correct username and password. Note that both fields are case-sensitive.") LOGIN_FORM_KEY = 'this_is_the_login_form' def _display_login_form(request, error_message=''): request.session.set_test_cookie() return render_to_response('admin/login.html', { 'title': _('Log in'), 'app_path': request.get_full_path(), 'error_message': error_message }, context_instance=template.RequestContext(request)) def staff_member_required(view_func): """ Decorator for views that checks that the user is logged in and is a staff member, displaying the login page if necessary. """ def _checklogin(request, *args, **kwargs): if request.user.is_authenticated() and request.user.is_staff: # The user is valid. Continue to the admin page. return view_func(request, *args, **kwargs) assert hasattr(request, 'session'), "The Django admin requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'." # If this isn't already the login page, display it. if LOGIN_FORM_KEY not in request.POST: if request.POST: message = _("Please log in again, because your session has expired.") else: message = "" return _display_login_form(request, message) # Check that the user accepts cookies. if not request.session.test_cookie_worked(): message = _("Looks like your browser isn't configured to accept cookies. Please enable cookies, reload this page, and try again.") return _display_login_form(request, message) else: request.session.delete_test_cookie() # Check the password. username = request.POST.get('username', None) password = request.POST.get('password', None) user = authenticate(username=username, password=password) if user is None: message = ERROR_MESSAGE if '@' in username: # Mistakenly entered e-mail address instead of username? Look it up. users = list(User.all().filter('email =', username)) if len(users) == 1 and users[0].check_password(password): <|fim_middle|> else: # Either we cannot find the user, or if more than 1 # we cannot guess which user is the correct one. message = _("Usernames cannot contain the '@' character.") return _display_login_form(request, message) # The user data is correct; log in the user in and continue. else: if user.is_active and user.is_staff: login(request, user) return http.HttpResponseRedirect(request.get_full_path()) else: return _display_login_form(request, ERROR_MESSAGE) return wraps(view_func)(_checklogin) <|fim▁end|>
message = _("Your e-mail address is not your username. Try '%s' instead.") % users[0].username
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|>import base64 try: from functools import wraps except ImportError: from django.utils.functional import wraps # Python 2.3, 2.4 fallback. from django import http, template from django.conf import settings from django.contrib.auth.models import User from django.contrib.auth import authenticate, login from django.shortcuts import render_to_response from django.utils.translation import ugettext_lazy, ugettext as _ ERROR_MESSAGE = ugettext_lazy("Please enter a correct username and password. Note that both fields are case-sensitive.") LOGIN_FORM_KEY = 'this_is_the_login_form' def _display_login_form(request, error_message=''): request.session.set_test_cookie() return render_to_response('admin/login.html', { 'title': _('Log in'), 'app_path': request.get_full_path(), 'error_message': error_message }, context_instance=template.RequestContext(request)) def staff_member_required(view_func): """ Decorator for views that checks that the user is logged in and is a staff member, displaying the login page if necessary. """ def _checklogin(request, *args, **kwargs): if request.user.is_authenticated() and request.user.is_staff: # The user is valid. Continue to the admin page. return view_func(request, *args, **kwargs) assert hasattr(request, 'session'), "The Django admin requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'." # If this isn't already the login page, display it. if LOGIN_FORM_KEY not in request.POST: if request.POST: message = _("Please log in again, because your session has expired.") else: message = "" return _display_login_form(request, message) # Check that the user accepts cookies. if not request.session.test_cookie_worked(): message = _("Looks like your browser isn't configured to accept cookies. Please enable cookies, reload this page, and try again.") return _display_login_form(request, message) else: request.session.delete_test_cookie() # Check the password. username = request.POST.get('username', None) password = request.POST.get('password', None) user = authenticate(username=username, password=password) if user is None: message = ERROR_MESSAGE if '@' in username: # Mistakenly entered e-mail address instead of username? Look it up. users = list(User.all().filter('email =', username)) if len(users) == 1 and users[0].check_password(password): message = _("Your e-mail address is not your username. Try '%s' instead.") % users[0].username else: # Either we cannot find the user, or if more than 1 # we cannot guess which user is the correct one. <|fim_middle|> return _display_login_form(request, message) # The user data is correct; log in the user in and continue. else: if user.is_active and user.is_staff: login(request, user) return http.HttpResponseRedirect(request.get_full_path()) else: return _display_login_form(request, ERROR_MESSAGE) return wraps(view_func)(_checklogin) <|fim▁end|>
message = _("Usernames cannot contain the '@' character.")
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|>import base64 try: from functools import wraps except ImportError: from django.utils.functional import wraps # Python 2.3, 2.4 fallback. from django import http, template from django.conf import settings from django.contrib.auth.models import User from django.contrib.auth import authenticate, login from django.shortcuts import render_to_response from django.utils.translation import ugettext_lazy, ugettext as _ ERROR_MESSAGE = ugettext_lazy("Please enter a correct username and password. Note that both fields are case-sensitive.") LOGIN_FORM_KEY = 'this_is_the_login_form' def _display_login_form(request, error_message=''): request.session.set_test_cookie() return render_to_response('admin/login.html', { 'title': _('Log in'), 'app_path': request.get_full_path(), 'error_message': error_message }, context_instance=template.RequestContext(request)) def staff_member_required(view_func): """ Decorator for views that checks that the user is logged in and is a staff member, displaying the login page if necessary. """ def _checklogin(request, *args, **kwargs): if request.user.is_authenticated() and request.user.is_staff: # The user is valid. Continue to the admin page. return view_func(request, *args, **kwargs) assert hasattr(request, 'session'), "The Django admin requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'." # If this isn't already the login page, display it. if LOGIN_FORM_KEY not in request.POST: if request.POST: message = _("Please log in again, because your session has expired.") else: message = "" return _display_login_form(request, message) # Check that the user accepts cookies. if not request.session.test_cookie_worked(): message = _("Looks like your browser isn't configured to accept cookies. Please enable cookies, reload this page, and try again.") return _display_login_form(request, message) else: request.session.delete_test_cookie() # Check the password. username = request.POST.get('username', None) password = request.POST.get('password', None) user = authenticate(username=username, password=password) if user is None: message = ERROR_MESSAGE if '@' in username: # Mistakenly entered e-mail address instead of username? Look it up. users = list(User.all().filter('email =', username)) if len(users) == 1 and users[0].check_password(password): message = _("Your e-mail address is not your username. Try '%s' instead.") % users[0].username else: # Either we cannot find the user, or if more than 1 # we cannot guess which user is the correct one. message = _("Usernames cannot contain the '@' character.") return _display_login_form(request, message) # The user data is correct; log in the user in and continue. else: <|fim_middle|> return wraps(view_func)(_checklogin) <|fim▁end|>
if user.is_active and user.is_staff: login(request, user) return http.HttpResponseRedirect(request.get_full_path()) else: return _display_login_form(request, ERROR_MESSAGE)
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|>import base64 try: from functools import wraps except ImportError: from django.utils.functional import wraps # Python 2.3, 2.4 fallback. from django import http, template from django.conf import settings from django.contrib.auth.models import User from django.contrib.auth import authenticate, login from django.shortcuts import render_to_response from django.utils.translation import ugettext_lazy, ugettext as _ ERROR_MESSAGE = ugettext_lazy("Please enter a correct username and password. Note that both fields are case-sensitive.") LOGIN_FORM_KEY = 'this_is_the_login_form' def _display_login_form(request, error_message=''): request.session.set_test_cookie() return render_to_response('admin/login.html', { 'title': _('Log in'), 'app_path': request.get_full_path(), 'error_message': error_message }, context_instance=template.RequestContext(request)) def staff_member_required(view_func): """ Decorator for views that checks that the user is logged in and is a staff member, displaying the login page if necessary. """ def _checklogin(request, *args, **kwargs): if request.user.is_authenticated() and request.user.is_staff: # The user is valid. Continue to the admin page. return view_func(request, *args, **kwargs) assert hasattr(request, 'session'), "The Django admin requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'." # If this isn't already the login page, display it. if LOGIN_FORM_KEY not in request.POST: if request.POST: message = _("Please log in again, because your session has expired.") else: message = "" return _display_login_form(request, message) # Check that the user accepts cookies. if not request.session.test_cookie_worked(): message = _("Looks like your browser isn't configured to accept cookies. Please enable cookies, reload this page, and try again.") return _display_login_form(request, message) else: request.session.delete_test_cookie() # Check the password. username = request.POST.get('username', None) password = request.POST.get('password', None) user = authenticate(username=username, password=password) if user is None: message = ERROR_MESSAGE if '@' in username: # Mistakenly entered e-mail address instead of username? Look it up. users = list(User.all().filter('email =', username)) if len(users) == 1 and users[0].check_password(password): message = _("Your e-mail address is not your username. Try '%s' instead.") % users[0].username else: # Either we cannot find the user, or if more than 1 # we cannot guess which user is the correct one. message = _("Usernames cannot contain the '@' character.") return _display_login_form(request, message) # The user data is correct; log in the user in and continue. else: if user.is_active and user.is_staff: <|fim_middle|> else: return _display_login_form(request, ERROR_MESSAGE) return wraps(view_func)(_checklogin) <|fim▁end|>
login(request, user) return http.HttpResponseRedirect(request.get_full_path())
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|>import base64 try: from functools import wraps except ImportError: from django.utils.functional import wraps # Python 2.3, 2.4 fallback. from django import http, template from django.conf import settings from django.contrib.auth.models import User from django.contrib.auth import authenticate, login from django.shortcuts import render_to_response from django.utils.translation import ugettext_lazy, ugettext as _ ERROR_MESSAGE = ugettext_lazy("Please enter a correct username and password. Note that both fields are case-sensitive.") LOGIN_FORM_KEY = 'this_is_the_login_form' def _display_login_form(request, error_message=''): request.session.set_test_cookie() return render_to_response('admin/login.html', { 'title': _('Log in'), 'app_path': request.get_full_path(), 'error_message': error_message }, context_instance=template.RequestContext(request)) def staff_member_required(view_func): """ Decorator for views that checks that the user is logged in and is a staff member, displaying the login page if necessary. """ def _checklogin(request, *args, **kwargs): if request.user.is_authenticated() and request.user.is_staff: # The user is valid. Continue to the admin page. return view_func(request, *args, **kwargs) assert hasattr(request, 'session'), "The Django admin requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'." # If this isn't already the login page, display it. if LOGIN_FORM_KEY not in request.POST: if request.POST: message = _("Please log in again, because your session has expired.") else: message = "" return _display_login_form(request, message) # Check that the user accepts cookies. if not request.session.test_cookie_worked(): message = _("Looks like your browser isn't configured to accept cookies. Please enable cookies, reload this page, and try again.") return _display_login_form(request, message) else: request.session.delete_test_cookie() # Check the password. username = request.POST.get('username', None) password = request.POST.get('password', None) user = authenticate(username=username, password=password) if user is None: message = ERROR_MESSAGE if '@' in username: # Mistakenly entered e-mail address instead of username? Look it up. users = list(User.all().filter('email =', username)) if len(users) == 1 and users[0].check_password(password): message = _("Your e-mail address is not your username. Try '%s' instead.") % users[0].username else: # Either we cannot find the user, or if more than 1 # we cannot guess which user is the correct one. message = _("Usernames cannot contain the '@' character.") return _display_login_form(request, message) # The user data is correct; log in the user in and continue. else: if user.is_active and user.is_staff: login(request, user) return http.HttpResponseRedirect(request.get_full_path()) else: <|fim_middle|> return wraps(view_func)(_checklogin) <|fim▁end|>
return _display_login_form(request, ERROR_MESSAGE)
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|>import base64 try: from functools import wraps except ImportError: from django.utils.functional import wraps # Python 2.3, 2.4 fallback. from django import http, template from django.conf import settings from django.contrib.auth.models import User from django.contrib.auth import authenticate, login from django.shortcuts import render_to_response from django.utils.translation import ugettext_lazy, ugettext as _ ERROR_MESSAGE = ugettext_lazy("Please enter a correct username and password. Note that both fields are case-sensitive.") LOGIN_FORM_KEY = 'this_is_the_login_form' def <|fim_middle|>(request, error_message=''): request.session.set_test_cookie() return render_to_response('admin/login.html', { 'title': _('Log in'), 'app_path': request.get_full_path(), 'error_message': error_message }, context_instance=template.RequestContext(request)) def staff_member_required(view_func): """ Decorator for views that checks that the user is logged in and is a staff member, displaying the login page if necessary. """ def _checklogin(request, *args, **kwargs): if request.user.is_authenticated() and request.user.is_staff: # The user is valid. Continue to the admin page. return view_func(request, *args, **kwargs) assert hasattr(request, 'session'), "The Django admin requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'." # If this isn't already the login page, display it. if LOGIN_FORM_KEY not in request.POST: if request.POST: message = _("Please log in again, because your session has expired.") else: message = "" return _display_login_form(request, message) # Check that the user accepts cookies. if not request.session.test_cookie_worked(): message = _("Looks like your browser isn't configured to accept cookies. Please enable cookies, reload this page, and try again.") return _display_login_form(request, message) else: request.session.delete_test_cookie() # Check the password. username = request.POST.get('username', None) password = request.POST.get('password', None) user = authenticate(username=username, password=password) if user is None: message = ERROR_MESSAGE if '@' in username: # Mistakenly entered e-mail address instead of username? Look it up. users = list(User.all().filter('email =', username)) if len(users) == 1 and users[0].check_password(password): message = _("Your e-mail address is not your username. Try '%s' instead.") % users[0].username else: # Either we cannot find the user, or if more than 1 # we cannot guess which user is the correct one. message = _("Usernames cannot contain the '@' character.") return _display_login_form(request, message) # The user data is correct; log in the user in and continue. else: if user.is_active and user.is_staff: login(request, user) return http.HttpResponseRedirect(request.get_full_path()) else: return _display_login_form(request, ERROR_MESSAGE) return wraps(view_func)(_checklogin) <|fim▁end|>
_display_login_form
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|>import base64 try: from functools import wraps except ImportError: from django.utils.functional import wraps # Python 2.3, 2.4 fallback. from django import http, template from django.conf import settings from django.contrib.auth.models import User from django.contrib.auth import authenticate, login from django.shortcuts import render_to_response from django.utils.translation import ugettext_lazy, ugettext as _ ERROR_MESSAGE = ugettext_lazy("Please enter a correct username and password. Note that both fields are case-sensitive.") LOGIN_FORM_KEY = 'this_is_the_login_form' def _display_login_form(request, error_message=''): request.session.set_test_cookie() return render_to_response('admin/login.html', { 'title': _('Log in'), 'app_path': request.get_full_path(), 'error_message': error_message }, context_instance=template.RequestContext(request)) def <|fim_middle|>(view_func): """ Decorator for views that checks that the user is logged in and is a staff member, displaying the login page if necessary. """ def _checklogin(request, *args, **kwargs): if request.user.is_authenticated() and request.user.is_staff: # The user is valid. Continue to the admin page. return view_func(request, *args, **kwargs) assert hasattr(request, 'session'), "The Django admin requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'." # If this isn't already the login page, display it. if LOGIN_FORM_KEY not in request.POST: if request.POST: message = _("Please log in again, because your session has expired.") else: message = "" return _display_login_form(request, message) # Check that the user accepts cookies. if not request.session.test_cookie_worked(): message = _("Looks like your browser isn't configured to accept cookies. Please enable cookies, reload this page, and try again.") return _display_login_form(request, message) else: request.session.delete_test_cookie() # Check the password. username = request.POST.get('username', None) password = request.POST.get('password', None) user = authenticate(username=username, password=password) if user is None: message = ERROR_MESSAGE if '@' in username: # Mistakenly entered e-mail address instead of username? Look it up. users = list(User.all().filter('email =', username)) if len(users) == 1 and users[0].check_password(password): message = _("Your e-mail address is not your username. Try '%s' instead.") % users[0].username else: # Either we cannot find the user, or if more than 1 # we cannot guess which user is the correct one. message = _("Usernames cannot contain the '@' character.") return _display_login_form(request, message) # The user data is correct; log in the user in and continue. else: if user.is_active and user.is_staff: login(request, user) return http.HttpResponseRedirect(request.get_full_path()) else: return _display_login_form(request, ERROR_MESSAGE) return wraps(view_func)(_checklogin) <|fim▁end|>
staff_member_required
<|file_name|>decorators.py<|end_file_name|><|fim▁begin|>import base64 try: from functools import wraps except ImportError: from django.utils.functional import wraps # Python 2.3, 2.4 fallback. from django import http, template from django.conf import settings from django.contrib.auth.models import User from django.contrib.auth import authenticate, login from django.shortcuts import render_to_response from django.utils.translation import ugettext_lazy, ugettext as _ ERROR_MESSAGE = ugettext_lazy("Please enter a correct username and password. Note that both fields are case-sensitive.") LOGIN_FORM_KEY = 'this_is_the_login_form' def _display_login_form(request, error_message=''): request.session.set_test_cookie() return render_to_response('admin/login.html', { 'title': _('Log in'), 'app_path': request.get_full_path(), 'error_message': error_message }, context_instance=template.RequestContext(request)) def staff_member_required(view_func): """ Decorator for views that checks that the user is logged in and is a staff member, displaying the login page if necessary. """ def <|fim_middle|>(request, *args, **kwargs): if request.user.is_authenticated() and request.user.is_staff: # The user is valid. Continue to the admin page. return view_func(request, *args, **kwargs) assert hasattr(request, 'session'), "The Django admin requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'." # If this isn't already the login page, display it. if LOGIN_FORM_KEY not in request.POST: if request.POST: message = _("Please log in again, because your session has expired.") else: message = "" return _display_login_form(request, message) # Check that the user accepts cookies. if not request.session.test_cookie_worked(): message = _("Looks like your browser isn't configured to accept cookies. Please enable cookies, reload this page, and try again.") return _display_login_form(request, message) else: request.session.delete_test_cookie() # Check the password. username = request.POST.get('username', None) password = request.POST.get('password', None) user = authenticate(username=username, password=password) if user is None: message = ERROR_MESSAGE if '@' in username: # Mistakenly entered e-mail address instead of username? Look it up. users = list(User.all().filter('email =', username)) if len(users) == 1 and users[0].check_password(password): message = _("Your e-mail address is not your username. Try '%s' instead.") % users[0].username else: # Either we cannot find the user, or if more than 1 # we cannot guess which user is the correct one. message = _("Usernames cannot contain the '@' character.") return _display_login_form(request, message) # The user data is correct; log in the user in and continue. else: if user.is_active and user.is_staff: login(request, user) return http.HttpResponseRedirect(request.get_full_path()) else: return _display_login_form(request, ERROR_MESSAGE) return wraps(view_func)(_checklogin) <|fim▁end|>
_checklogin
<|file_name|>run.py<|end_file_name|><|fim▁begin|>from mainapp import create_app app = create_app() if __name__ == '__main__':<|fim▁hole|> app.run(host='0.0.0.0')<|fim▁end|>
<|file_name|>run.py<|end_file_name|><|fim▁begin|>from mainapp import create_app app = create_app() if __name__ == '__main__': <|fim_middle|> <|fim▁end|>
app.run(host='0.0.0.0')
<|file_name|>Shendrones.py<|end_file_name|><|fim▁begin|>import scrapy from scrapy import log from scrapy.spiders import CrawlSpider, Rule from scrapy.linkextractors import LinkExtractor from rcbi.items import Part import copy import json import re VARIANT_JSON_REGEX = re.compile("product: ({.*}),") class ShendronesSpider(CrawlSpider): name = "shendrones" allowed_domains = ["shendrones.myshopify.com"] start_urls = ["http://shendrones.myshopify.com/collections/all"] <|fim▁hole|> def parse_item(self, response): item = Part() item["site"] = self.name variant = {} item["variants"] = [variant] base_url = response.url item["manufacturer"] = "Shendrones" # Find the json info for variants. body = response.body_as_unicode() m = VARIANT_JSON_REGEX.search(body) if m: shopify_info = json.loads(m.group(1)) global_title = shopify_info["title"] preorder = False if global_title.endswith("Pre Order"): global_title = global_title[:-len("Pre Order")].strip() variant["stock_state"] = "backordered" preorder = True for v in shopify_info["variants"]: if v["title"] != "Default Title": item["name"] = global_title + " " + v["title"] variant["url"] = base_url + "?variant=" + str(v["id"]) else: item["name"] = global_title variant["url"] = base_url variant["price"] = "${:.2f}".format(v["price"] / 100) if not preorder: if v["inventory_quantity"] <= 0: if v["inventory_policy"] == "deny": variant["stock_state"] = "out_of_stock" else: variant["stock_state"] = "backordered" elif v["inventory_quantity"] < 3: variant["stock_state"] = "low_stock" variant["stock_text"] = "Only " + str(v["inventory_quantity"]) + " left!" else: variant["stock_state"] = "in_stock" yield item item = copy.deepcopy(item) variant = item["variants"][0]<|fim▁end|>
rules = ( Rule(LinkExtractor(restrict_css=[".grid-item"]), callback='parse_item'), )
<|file_name|>Shendrones.py<|end_file_name|><|fim▁begin|>import scrapy from scrapy import log from scrapy.spiders import CrawlSpider, Rule from scrapy.linkextractors import LinkExtractor from rcbi.items import Part import copy import json import re VARIANT_JSON_REGEX = re.compile("product: ({.*}),") class ShendronesSpider(CrawlSpider): <|fim_middle|> <|fim▁end|>
name = "shendrones" allowed_domains = ["shendrones.myshopify.com"] start_urls = ["http://shendrones.myshopify.com/collections/all"] rules = ( Rule(LinkExtractor(restrict_css=[".grid-item"]), callback='parse_item'), ) def parse_item(self, response): item = Part() item["site"] = self.name variant = {} item["variants"] = [variant] base_url = response.url item["manufacturer"] = "Shendrones" # Find the json info for variants. body = response.body_as_unicode() m = VARIANT_JSON_REGEX.search(body) if m: shopify_info = json.loads(m.group(1)) global_title = shopify_info["title"] preorder = False if global_title.endswith("Pre Order"): global_title = global_title[:-len("Pre Order")].strip() variant["stock_state"] = "backordered" preorder = True for v in shopify_info["variants"]: if v["title"] != "Default Title": item["name"] = global_title + " " + v["title"] variant["url"] = base_url + "?variant=" + str(v["id"]) else: item["name"] = global_title variant["url"] = base_url variant["price"] = "${:.2f}".format(v["price"] / 100) if not preorder: if v["inventory_quantity"] <= 0: if v["inventory_policy"] == "deny": variant["stock_state"] = "out_of_stock" else: variant["stock_state"] = "backordered" elif v["inventory_quantity"] < 3: variant["stock_state"] = "low_stock" variant["stock_text"] = "Only " + str(v["inventory_quantity"]) + " left!" else: variant["stock_state"] = "in_stock" yield item item = copy.deepcopy(item) variant = item["variants"][0]
<|file_name|>Shendrones.py<|end_file_name|><|fim▁begin|>import scrapy from scrapy import log from scrapy.spiders import CrawlSpider, Rule from scrapy.linkextractors import LinkExtractor from rcbi.items import Part import copy import json import re VARIANT_JSON_REGEX = re.compile("product: ({.*}),") class ShendronesSpider(CrawlSpider): name = "shendrones" allowed_domains = ["shendrones.myshopify.com"] start_urls = ["http://shendrones.myshopify.com/collections/all"] rules = ( Rule(LinkExtractor(restrict_css=[".grid-item"]), callback='parse_item'), ) def parse_item(self, response): <|fim_middle|> <|fim▁end|>
item = Part() item["site"] = self.name variant = {} item["variants"] = [variant] base_url = response.url item["manufacturer"] = "Shendrones" # Find the json info for variants. body = response.body_as_unicode() m = VARIANT_JSON_REGEX.search(body) if m: shopify_info = json.loads(m.group(1)) global_title = shopify_info["title"] preorder = False if global_title.endswith("Pre Order"): global_title = global_title[:-len("Pre Order")].strip() variant["stock_state"] = "backordered" preorder = True for v in shopify_info["variants"]: if v["title"] != "Default Title": item["name"] = global_title + " " + v["title"] variant["url"] = base_url + "?variant=" + str(v["id"]) else: item["name"] = global_title variant["url"] = base_url variant["price"] = "${:.2f}".format(v["price"] / 100) if not preorder: if v["inventory_quantity"] <= 0: if v["inventory_policy"] == "deny": variant["stock_state"] = "out_of_stock" else: variant["stock_state"] = "backordered" elif v["inventory_quantity"] < 3: variant["stock_state"] = "low_stock" variant["stock_text"] = "Only " + str(v["inventory_quantity"]) + " left!" else: variant["stock_state"] = "in_stock" yield item item = copy.deepcopy(item) variant = item["variants"][0]
<|file_name|>Shendrones.py<|end_file_name|><|fim▁begin|>import scrapy from scrapy import log from scrapy.spiders import CrawlSpider, Rule from scrapy.linkextractors import LinkExtractor from rcbi.items import Part import copy import json import re VARIANT_JSON_REGEX = re.compile("product: ({.*}),") class ShendronesSpider(CrawlSpider): name = "shendrones" allowed_domains = ["shendrones.myshopify.com"] start_urls = ["http://shendrones.myshopify.com/collections/all"] rules = ( Rule(LinkExtractor(restrict_css=[".grid-item"]), callback='parse_item'), ) def parse_item(self, response): item = Part() item["site"] = self.name variant = {} item["variants"] = [variant] base_url = response.url item["manufacturer"] = "Shendrones" # Find the json info for variants. body = response.body_as_unicode() m = VARIANT_JSON_REGEX.search(body) if m: <|fim_middle|> <|fim▁end|>
shopify_info = json.loads(m.group(1)) global_title = shopify_info["title"] preorder = False if global_title.endswith("Pre Order"): global_title = global_title[:-len("Pre Order")].strip() variant["stock_state"] = "backordered" preorder = True for v in shopify_info["variants"]: if v["title"] != "Default Title": item["name"] = global_title + " " + v["title"] variant["url"] = base_url + "?variant=" + str(v["id"]) else: item["name"] = global_title variant["url"] = base_url variant["price"] = "${:.2f}".format(v["price"] / 100) if not preorder: if v["inventory_quantity"] <= 0: if v["inventory_policy"] == "deny": variant["stock_state"] = "out_of_stock" else: variant["stock_state"] = "backordered" elif v["inventory_quantity"] < 3: variant["stock_state"] = "low_stock" variant["stock_text"] = "Only " + str(v["inventory_quantity"]) + " left!" else: variant["stock_state"] = "in_stock" yield item item = copy.deepcopy(item) variant = item["variants"][0]
<|file_name|>Shendrones.py<|end_file_name|><|fim▁begin|>import scrapy from scrapy import log from scrapy.spiders import CrawlSpider, Rule from scrapy.linkextractors import LinkExtractor from rcbi.items import Part import copy import json import re VARIANT_JSON_REGEX = re.compile("product: ({.*}),") class ShendronesSpider(CrawlSpider): name = "shendrones" allowed_domains = ["shendrones.myshopify.com"] start_urls = ["http://shendrones.myshopify.com/collections/all"] rules = ( Rule(LinkExtractor(restrict_css=[".grid-item"]), callback='parse_item'), ) def parse_item(self, response): item = Part() item["site"] = self.name variant = {} item["variants"] = [variant] base_url = response.url item["manufacturer"] = "Shendrones" # Find the json info for variants. body = response.body_as_unicode() m = VARIANT_JSON_REGEX.search(body) if m: shopify_info = json.loads(m.group(1)) global_title = shopify_info["title"] preorder = False if global_title.endswith("Pre Order"): <|fim_middle|> for v in shopify_info["variants"]: if v["title"] != "Default Title": item["name"] = global_title + " " + v["title"] variant["url"] = base_url + "?variant=" + str(v["id"]) else: item["name"] = global_title variant["url"] = base_url variant["price"] = "${:.2f}".format(v["price"] / 100) if not preorder: if v["inventory_quantity"] <= 0: if v["inventory_policy"] == "deny": variant["stock_state"] = "out_of_stock" else: variant["stock_state"] = "backordered" elif v["inventory_quantity"] < 3: variant["stock_state"] = "low_stock" variant["stock_text"] = "Only " + str(v["inventory_quantity"]) + " left!" else: variant["stock_state"] = "in_stock" yield item item = copy.deepcopy(item) variant = item["variants"][0] <|fim▁end|>
global_title = global_title[:-len("Pre Order")].strip() variant["stock_state"] = "backordered" preorder = True
<|file_name|>Shendrones.py<|end_file_name|><|fim▁begin|>import scrapy from scrapy import log from scrapy.spiders import CrawlSpider, Rule from scrapy.linkextractors import LinkExtractor from rcbi.items import Part import copy import json import re VARIANT_JSON_REGEX = re.compile("product: ({.*}),") class ShendronesSpider(CrawlSpider): name = "shendrones" allowed_domains = ["shendrones.myshopify.com"] start_urls = ["http://shendrones.myshopify.com/collections/all"] rules = ( Rule(LinkExtractor(restrict_css=[".grid-item"]), callback='parse_item'), ) def parse_item(self, response): item = Part() item["site"] = self.name variant = {} item["variants"] = [variant] base_url = response.url item["manufacturer"] = "Shendrones" # Find the json info for variants. body = response.body_as_unicode() m = VARIANT_JSON_REGEX.search(body) if m: shopify_info = json.loads(m.group(1)) global_title = shopify_info["title"] preorder = False if global_title.endswith("Pre Order"): global_title = global_title[:-len("Pre Order")].strip() variant["stock_state"] = "backordered" preorder = True for v in shopify_info["variants"]: if v["title"] != "Default Title": <|fim_middle|> else: item["name"] = global_title variant["url"] = base_url variant["price"] = "${:.2f}".format(v["price"] / 100) if not preorder: if v["inventory_quantity"] <= 0: if v["inventory_policy"] == "deny": variant["stock_state"] = "out_of_stock" else: variant["stock_state"] = "backordered" elif v["inventory_quantity"] < 3: variant["stock_state"] = "low_stock" variant["stock_text"] = "Only " + str(v["inventory_quantity"]) + " left!" else: variant["stock_state"] = "in_stock" yield item item = copy.deepcopy(item) variant = item["variants"][0] <|fim▁end|>
item["name"] = global_title + " " + v["title"] variant["url"] = base_url + "?variant=" + str(v["id"])
<|file_name|>Shendrones.py<|end_file_name|><|fim▁begin|>import scrapy from scrapy import log from scrapy.spiders import CrawlSpider, Rule from scrapy.linkextractors import LinkExtractor from rcbi.items import Part import copy import json import re VARIANT_JSON_REGEX = re.compile("product: ({.*}),") class ShendronesSpider(CrawlSpider): name = "shendrones" allowed_domains = ["shendrones.myshopify.com"] start_urls = ["http://shendrones.myshopify.com/collections/all"] rules = ( Rule(LinkExtractor(restrict_css=[".grid-item"]), callback='parse_item'), ) def parse_item(self, response): item = Part() item["site"] = self.name variant = {} item["variants"] = [variant] base_url = response.url item["manufacturer"] = "Shendrones" # Find the json info for variants. body = response.body_as_unicode() m = VARIANT_JSON_REGEX.search(body) if m: shopify_info = json.loads(m.group(1)) global_title = shopify_info["title"] preorder = False if global_title.endswith("Pre Order"): global_title = global_title[:-len("Pre Order")].strip() variant["stock_state"] = "backordered" preorder = True for v in shopify_info["variants"]: if v["title"] != "Default Title": item["name"] = global_title + " " + v["title"] variant["url"] = base_url + "?variant=" + str(v["id"]) else: <|fim_middle|> variant["price"] = "${:.2f}".format(v["price"] / 100) if not preorder: if v["inventory_quantity"] <= 0: if v["inventory_policy"] == "deny": variant["stock_state"] = "out_of_stock" else: variant["stock_state"] = "backordered" elif v["inventory_quantity"] < 3: variant["stock_state"] = "low_stock" variant["stock_text"] = "Only " + str(v["inventory_quantity"]) + " left!" else: variant["stock_state"] = "in_stock" yield item item = copy.deepcopy(item) variant = item["variants"][0] <|fim▁end|>
item["name"] = global_title variant["url"] = base_url
<|file_name|>Shendrones.py<|end_file_name|><|fim▁begin|>import scrapy from scrapy import log from scrapy.spiders import CrawlSpider, Rule from scrapy.linkextractors import LinkExtractor from rcbi.items import Part import copy import json import re VARIANT_JSON_REGEX = re.compile("product: ({.*}),") class ShendronesSpider(CrawlSpider): name = "shendrones" allowed_domains = ["shendrones.myshopify.com"] start_urls = ["http://shendrones.myshopify.com/collections/all"] rules = ( Rule(LinkExtractor(restrict_css=[".grid-item"]), callback='parse_item'), ) def parse_item(self, response): item = Part() item["site"] = self.name variant = {} item["variants"] = [variant] base_url = response.url item["manufacturer"] = "Shendrones" # Find the json info for variants. body = response.body_as_unicode() m = VARIANT_JSON_REGEX.search(body) if m: shopify_info = json.loads(m.group(1)) global_title = shopify_info["title"] preorder = False if global_title.endswith("Pre Order"): global_title = global_title[:-len("Pre Order")].strip() variant["stock_state"] = "backordered" preorder = True for v in shopify_info["variants"]: if v["title"] != "Default Title": item["name"] = global_title + " " + v["title"] variant["url"] = base_url + "?variant=" + str(v["id"]) else: item["name"] = global_title variant["url"] = base_url variant["price"] = "${:.2f}".format(v["price"] / 100) if not preorder: <|fim_middle|> yield item item = copy.deepcopy(item) variant = item["variants"][0] <|fim▁end|>
if v["inventory_quantity"] <= 0: if v["inventory_policy"] == "deny": variant["stock_state"] = "out_of_stock" else: variant["stock_state"] = "backordered" elif v["inventory_quantity"] < 3: variant["stock_state"] = "low_stock" variant["stock_text"] = "Only " + str(v["inventory_quantity"]) + " left!" else: variant["stock_state"] = "in_stock"
<|file_name|>Shendrones.py<|end_file_name|><|fim▁begin|>import scrapy from scrapy import log from scrapy.spiders import CrawlSpider, Rule from scrapy.linkextractors import LinkExtractor from rcbi.items import Part import copy import json import re VARIANT_JSON_REGEX = re.compile("product: ({.*}),") class ShendronesSpider(CrawlSpider): name = "shendrones" allowed_domains = ["shendrones.myshopify.com"] start_urls = ["http://shendrones.myshopify.com/collections/all"] rules = ( Rule(LinkExtractor(restrict_css=[".grid-item"]), callback='parse_item'), ) def parse_item(self, response): item = Part() item["site"] = self.name variant = {} item["variants"] = [variant] base_url = response.url item["manufacturer"] = "Shendrones" # Find the json info for variants. body = response.body_as_unicode() m = VARIANT_JSON_REGEX.search(body) if m: shopify_info = json.loads(m.group(1)) global_title = shopify_info["title"] preorder = False if global_title.endswith("Pre Order"): global_title = global_title[:-len("Pre Order")].strip() variant["stock_state"] = "backordered" preorder = True for v in shopify_info["variants"]: if v["title"] != "Default Title": item["name"] = global_title + " " + v["title"] variant["url"] = base_url + "?variant=" + str(v["id"]) else: item["name"] = global_title variant["url"] = base_url variant["price"] = "${:.2f}".format(v["price"] / 100) if not preorder: if v["inventory_quantity"] <= 0: <|fim_middle|> elif v["inventory_quantity"] < 3: variant["stock_state"] = "low_stock" variant["stock_text"] = "Only " + str(v["inventory_quantity"]) + " left!" else: variant["stock_state"] = "in_stock" yield item item = copy.deepcopy(item) variant = item["variants"][0] <|fim▁end|>
if v["inventory_policy"] == "deny": variant["stock_state"] = "out_of_stock" else: variant["stock_state"] = "backordered"
<|file_name|>Shendrones.py<|end_file_name|><|fim▁begin|>import scrapy from scrapy import log from scrapy.spiders import CrawlSpider, Rule from scrapy.linkextractors import LinkExtractor from rcbi.items import Part import copy import json import re VARIANT_JSON_REGEX = re.compile("product: ({.*}),") class ShendronesSpider(CrawlSpider): name = "shendrones" allowed_domains = ["shendrones.myshopify.com"] start_urls = ["http://shendrones.myshopify.com/collections/all"] rules = ( Rule(LinkExtractor(restrict_css=[".grid-item"]), callback='parse_item'), ) def parse_item(self, response): item = Part() item["site"] = self.name variant = {} item["variants"] = [variant] base_url = response.url item["manufacturer"] = "Shendrones" # Find the json info for variants. body = response.body_as_unicode() m = VARIANT_JSON_REGEX.search(body) if m: shopify_info = json.loads(m.group(1)) global_title = shopify_info["title"] preorder = False if global_title.endswith("Pre Order"): global_title = global_title[:-len("Pre Order")].strip() variant["stock_state"] = "backordered" preorder = True for v in shopify_info["variants"]: if v["title"] != "Default Title": item["name"] = global_title + " " + v["title"] variant["url"] = base_url + "?variant=" + str(v["id"]) else: item["name"] = global_title variant["url"] = base_url variant["price"] = "${:.2f}".format(v["price"] / 100) if not preorder: if v["inventory_quantity"] <= 0: if v["inventory_policy"] == "deny": <|fim_middle|> else: variant["stock_state"] = "backordered" elif v["inventory_quantity"] < 3: variant["stock_state"] = "low_stock" variant["stock_text"] = "Only " + str(v["inventory_quantity"]) + " left!" else: variant["stock_state"] = "in_stock" yield item item = copy.deepcopy(item) variant = item["variants"][0] <|fim▁end|>
variant["stock_state"] = "out_of_stock"
<|file_name|>Shendrones.py<|end_file_name|><|fim▁begin|>import scrapy from scrapy import log from scrapy.spiders import CrawlSpider, Rule from scrapy.linkextractors import LinkExtractor from rcbi.items import Part import copy import json import re VARIANT_JSON_REGEX = re.compile("product: ({.*}),") class ShendronesSpider(CrawlSpider): name = "shendrones" allowed_domains = ["shendrones.myshopify.com"] start_urls = ["http://shendrones.myshopify.com/collections/all"] rules = ( Rule(LinkExtractor(restrict_css=[".grid-item"]), callback='parse_item'), ) def parse_item(self, response): item = Part() item["site"] = self.name variant = {} item["variants"] = [variant] base_url = response.url item["manufacturer"] = "Shendrones" # Find the json info for variants. body = response.body_as_unicode() m = VARIANT_JSON_REGEX.search(body) if m: shopify_info = json.loads(m.group(1)) global_title = shopify_info["title"] preorder = False if global_title.endswith("Pre Order"): global_title = global_title[:-len("Pre Order")].strip() variant["stock_state"] = "backordered" preorder = True for v in shopify_info["variants"]: if v["title"] != "Default Title": item["name"] = global_title + " " + v["title"] variant["url"] = base_url + "?variant=" + str(v["id"]) else: item["name"] = global_title variant["url"] = base_url variant["price"] = "${:.2f}".format(v["price"] / 100) if not preorder: if v["inventory_quantity"] <= 0: if v["inventory_policy"] == "deny": variant["stock_state"] = "out_of_stock" else: <|fim_middle|> elif v["inventory_quantity"] < 3: variant["stock_state"] = "low_stock" variant["stock_text"] = "Only " + str(v["inventory_quantity"]) + " left!" else: variant["stock_state"] = "in_stock" yield item item = copy.deepcopy(item) variant = item["variants"][0] <|fim▁end|>
variant["stock_state"] = "backordered"
<|file_name|>Shendrones.py<|end_file_name|><|fim▁begin|>import scrapy from scrapy import log from scrapy.spiders import CrawlSpider, Rule from scrapy.linkextractors import LinkExtractor from rcbi.items import Part import copy import json import re VARIANT_JSON_REGEX = re.compile("product: ({.*}),") class ShendronesSpider(CrawlSpider): name = "shendrones" allowed_domains = ["shendrones.myshopify.com"] start_urls = ["http://shendrones.myshopify.com/collections/all"] rules = ( Rule(LinkExtractor(restrict_css=[".grid-item"]), callback='parse_item'), ) def parse_item(self, response): item = Part() item["site"] = self.name variant = {} item["variants"] = [variant] base_url = response.url item["manufacturer"] = "Shendrones" # Find the json info for variants. body = response.body_as_unicode() m = VARIANT_JSON_REGEX.search(body) if m: shopify_info = json.loads(m.group(1)) global_title = shopify_info["title"] preorder = False if global_title.endswith("Pre Order"): global_title = global_title[:-len("Pre Order")].strip() variant["stock_state"] = "backordered" preorder = True for v in shopify_info["variants"]: if v["title"] != "Default Title": item["name"] = global_title + " " + v["title"] variant["url"] = base_url + "?variant=" + str(v["id"]) else: item["name"] = global_title variant["url"] = base_url variant["price"] = "${:.2f}".format(v["price"] / 100) if not preorder: if v["inventory_quantity"] <= 0: if v["inventory_policy"] == "deny": variant["stock_state"] = "out_of_stock" else: variant["stock_state"] = "backordered" elif v["inventory_quantity"] < 3: <|fim_middle|> else: variant["stock_state"] = "in_stock" yield item item = copy.deepcopy(item) variant = item["variants"][0] <|fim▁end|>
variant["stock_state"] = "low_stock" variant["stock_text"] = "Only " + str(v["inventory_quantity"]) + " left!"
<|file_name|>Shendrones.py<|end_file_name|><|fim▁begin|>import scrapy from scrapy import log from scrapy.spiders import CrawlSpider, Rule from scrapy.linkextractors import LinkExtractor from rcbi.items import Part import copy import json import re VARIANT_JSON_REGEX = re.compile("product: ({.*}),") class ShendronesSpider(CrawlSpider): name = "shendrones" allowed_domains = ["shendrones.myshopify.com"] start_urls = ["http://shendrones.myshopify.com/collections/all"] rules = ( Rule(LinkExtractor(restrict_css=[".grid-item"]), callback='parse_item'), ) def parse_item(self, response): item = Part() item["site"] = self.name variant = {} item["variants"] = [variant] base_url = response.url item["manufacturer"] = "Shendrones" # Find the json info for variants. body = response.body_as_unicode() m = VARIANT_JSON_REGEX.search(body) if m: shopify_info = json.loads(m.group(1)) global_title = shopify_info["title"] preorder = False if global_title.endswith("Pre Order"): global_title = global_title[:-len("Pre Order")].strip() variant["stock_state"] = "backordered" preorder = True for v in shopify_info["variants"]: if v["title"] != "Default Title": item["name"] = global_title + " " + v["title"] variant["url"] = base_url + "?variant=" + str(v["id"]) else: item["name"] = global_title variant["url"] = base_url variant["price"] = "${:.2f}".format(v["price"] / 100) if not preorder: if v["inventory_quantity"] <= 0: if v["inventory_policy"] == "deny": variant["stock_state"] = "out_of_stock" else: variant["stock_state"] = "backordered" elif v["inventory_quantity"] < 3: variant["stock_state"] = "low_stock" variant["stock_text"] = "Only " + str(v["inventory_quantity"]) + " left!" else: <|fim_middle|> yield item item = copy.deepcopy(item) variant = item["variants"][0] <|fim▁end|>
variant["stock_state"] = "in_stock"
<|file_name|>Shendrones.py<|end_file_name|><|fim▁begin|>import scrapy from scrapy import log from scrapy.spiders import CrawlSpider, Rule from scrapy.linkextractors import LinkExtractor from rcbi.items import Part import copy import json import re VARIANT_JSON_REGEX = re.compile("product: ({.*}),") class ShendronesSpider(CrawlSpider): name = "shendrones" allowed_domains = ["shendrones.myshopify.com"] start_urls = ["http://shendrones.myshopify.com/collections/all"] rules = ( Rule(LinkExtractor(restrict_css=[".grid-item"]), callback='parse_item'), ) def <|fim_middle|>(self, response): item = Part() item["site"] = self.name variant = {} item["variants"] = [variant] base_url = response.url item["manufacturer"] = "Shendrones" # Find the json info for variants. body = response.body_as_unicode() m = VARIANT_JSON_REGEX.search(body) if m: shopify_info = json.loads(m.group(1)) global_title = shopify_info["title"] preorder = False if global_title.endswith("Pre Order"): global_title = global_title[:-len("Pre Order")].strip() variant["stock_state"] = "backordered" preorder = True for v in shopify_info["variants"]: if v["title"] != "Default Title": item["name"] = global_title + " " + v["title"] variant["url"] = base_url + "?variant=" + str(v["id"]) else: item["name"] = global_title variant["url"] = base_url variant["price"] = "${:.2f}".format(v["price"] / 100) if not preorder: if v["inventory_quantity"] <= 0: if v["inventory_policy"] == "deny": variant["stock_state"] = "out_of_stock" else: variant["stock_state"] = "backordered" elif v["inventory_quantity"] < 3: variant["stock_state"] = "low_stock" variant["stock_text"] = "Only " + str(v["inventory_quantity"]) + " left!" else: variant["stock_state"] = "in_stock" yield item item = copy.deepcopy(item) variant = item["variants"][0] <|fim▁end|>
parse_item
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|># emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*- # vi: set ft=python sts=4 ts=4 sw=4 noet : # This file is part of Fail2Ban. # # Fail2Ban is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # Fail2Ban 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Fail2Ban; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Author: Cyril Jaquier # __author__ = "Cyril Jaquier" __copyright__ = "Copyright (c) 2004 Cyril Jaquier"<|fim▁hole|>__license__ = "GPL" import logging.handlers # Custom debug levels logging.MSG = logging.INFO - 2 logging.TRACEDEBUG = 7 logging.HEAVYDEBUG = 5 logging.addLevelName(logging.MSG, 'MSG') logging.addLevelName(logging.TRACEDEBUG, 'TRACE') logging.addLevelName(logging.HEAVYDEBUG, 'HEAVY') """ Below derived from: https://mail.python.org/pipermail/tutor/2007-August/056243.html """ logging.NOTICE = logging.INFO + 5 logging.addLevelName(logging.NOTICE, 'NOTICE') # define a new logger function for notice # this is exactly like existing info, critical, debug...etc def _Logger_notice(self, msg, *args, **kwargs): """ Log 'msg % args' with severity 'NOTICE'. To pass exception information, use the keyword argument exc_info with a true value, e.g. logger.notice("Houston, we have a %s", "major disaster", exc_info=1) """ if self.isEnabledFor(logging.NOTICE): self._log(logging.NOTICE, msg, args, **kwargs) logging.Logger.notice = _Logger_notice # define a new root level notice function # this is exactly like existing info, critical, debug...etc def _root_notice(msg, *args, **kwargs): """ Log a message with severity 'NOTICE' on the root logger. """ if len(logging.root.handlers) == 0: logging.basicConfig() logging.root.notice(msg, *args, **kwargs) # make the notice root level function known logging.notice = _root_notice # add NOTICE to the priority map of all the levels logging.handlers.SysLogHandler.priority_map['NOTICE'] = 'notice' from time import strptime # strptime thread safety hack-around - http://bugs.python.org/issue7980 strptime("2012", "%Y") # short names for pure numeric log-level ("Level 25" could be truncated by short formats): def _init(): for i in range(50): if logging.getLevelName(i).startswith('Level'): logging.addLevelName(i, '#%02d-Lev.' % i) _init()<|fim▁end|>
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|># emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*- # vi: set ft=python sts=4 ts=4 sw=4 noet : # This file is part of Fail2Ban. # # Fail2Ban is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # Fail2Ban 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Fail2Ban; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Author: Cyril Jaquier # __author__ = "Cyril Jaquier" __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL" import logging.handlers # Custom debug levels logging.MSG = logging.INFO - 2 logging.TRACEDEBUG = 7 logging.HEAVYDEBUG = 5 logging.addLevelName(logging.MSG, 'MSG') logging.addLevelName(logging.TRACEDEBUG, 'TRACE') logging.addLevelName(logging.HEAVYDEBUG, 'HEAVY') """ Below derived from: https://mail.python.org/pipermail/tutor/2007-August/056243.html """ logging.NOTICE = logging.INFO + 5 logging.addLevelName(logging.NOTICE, 'NOTICE') # define a new logger function for notice # this is exactly like existing info, critical, debug...etc def _Logger_notice(self, msg, *args, **kwargs): <|fim_middle|> logging.Logger.notice = _Logger_notice # define a new root level notice function # this is exactly like existing info, critical, debug...etc def _root_notice(msg, *args, **kwargs): """ Log a message with severity 'NOTICE' on the root logger. """ if len(logging.root.handlers) == 0: logging.basicConfig() logging.root.notice(msg, *args, **kwargs) # make the notice root level function known logging.notice = _root_notice # add NOTICE to the priority map of all the levels logging.handlers.SysLogHandler.priority_map['NOTICE'] = 'notice' from time import strptime # strptime thread safety hack-around - http://bugs.python.org/issue7980 strptime("2012", "%Y") # short names for pure numeric log-level ("Level 25" could be truncated by short formats): def _init(): for i in range(50): if logging.getLevelName(i).startswith('Level'): logging.addLevelName(i, '#%02d-Lev.' % i) _init() <|fim▁end|>
""" Log 'msg % args' with severity 'NOTICE'. To pass exception information, use the keyword argument exc_info with a true value, e.g. logger.notice("Houston, we have a %s", "major disaster", exc_info=1) """ if self.isEnabledFor(logging.NOTICE): self._log(logging.NOTICE, msg, args, **kwargs)
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|># emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*- # vi: set ft=python sts=4 ts=4 sw=4 noet : # This file is part of Fail2Ban. # # Fail2Ban is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # Fail2Ban 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Fail2Ban; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Author: Cyril Jaquier # __author__ = "Cyril Jaquier" __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL" import logging.handlers # Custom debug levels logging.MSG = logging.INFO - 2 logging.TRACEDEBUG = 7 logging.HEAVYDEBUG = 5 logging.addLevelName(logging.MSG, 'MSG') logging.addLevelName(logging.TRACEDEBUG, 'TRACE') logging.addLevelName(logging.HEAVYDEBUG, 'HEAVY') """ Below derived from: https://mail.python.org/pipermail/tutor/2007-August/056243.html """ logging.NOTICE = logging.INFO + 5 logging.addLevelName(logging.NOTICE, 'NOTICE') # define a new logger function for notice # this is exactly like existing info, critical, debug...etc def _Logger_notice(self, msg, *args, **kwargs): """ Log 'msg % args' with severity 'NOTICE'. To pass exception information, use the keyword argument exc_info with a true value, e.g. logger.notice("Houston, we have a %s", "major disaster", exc_info=1) """ if self.isEnabledFor(logging.NOTICE): self._log(logging.NOTICE, msg, args, **kwargs) logging.Logger.notice = _Logger_notice # define a new root level notice function # this is exactly like existing info, critical, debug...etc def _root_notice(msg, *args, **kwargs): <|fim_middle|> # make the notice root level function known logging.notice = _root_notice # add NOTICE to the priority map of all the levels logging.handlers.SysLogHandler.priority_map['NOTICE'] = 'notice' from time import strptime # strptime thread safety hack-around - http://bugs.python.org/issue7980 strptime("2012", "%Y") # short names for pure numeric log-level ("Level 25" could be truncated by short formats): def _init(): for i in range(50): if logging.getLevelName(i).startswith('Level'): logging.addLevelName(i, '#%02d-Lev.' % i) _init() <|fim▁end|>
""" Log a message with severity 'NOTICE' on the root logger. """ if len(logging.root.handlers) == 0: logging.basicConfig() logging.root.notice(msg, *args, **kwargs)
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|># emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*- # vi: set ft=python sts=4 ts=4 sw=4 noet : # This file is part of Fail2Ban. # # Fail2Ban is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # Fail2Ban 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Fail2Ban; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Author: Cyril Jaquier # __author__ = "Cyril Jaquier" __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL" import logging.handlers # Custom debug levels logging.MSG = logging.INFO - 2 logging.TRACEDEBUG = 7 logging.HEAVYDEBUG = 5 logging.addLevelName(logging.MSG, 'MSG') logging.addLevelName(logging.TRACEDEBUG, 'TRACE') logging.addLevelName(logging.HEAVYDEBUG, 'HEAVY') """ Below derived from: https://mail.python.org/pipermail/tutor/2007-August/056243.html """ logging.NOTICE = logging.INFO + 5 logging.addLevelName(logging.NOTICE, 'NOTICE') # define a new logger function for notice # this is exactly like existing info, critical, debug...etc def _Logger_notice(self, msg, *args, **kwargs): """ Log 'msg % args' with severity 'NOTICE'. To pass exception information, use the keyword argument exc_info with a true value, e.g. logger.notice("Houston, we have a %s", "major disaster", exc_info=1) """ if self.isEnabledFor(logging.NOTICE): self._log(logging.NOTICE, msg, args, **kwargs) logging.Logger.notice = _Logger_notice # define a new root level notice function # this is exactly like existing info, critical, debug...etc def _root_notice(msg, *args, **kwargs): """ Log a message with severity 'NOTICE' on the root logger. """ if len(logging.root.handlers) == 0: logging.basicConfig() logging.root.notice(msg, *args, **kwargs) # make the notice root level function known logging.notice = _root_notice # add NOTICE to the priority map of all the levels logging.handlers.SysLogHandler.priority_map['NOTICE'] = 'notice' from time import strptime # strptime thread safety hack-around - http://bugs.python.org/issue7980 strptime("2012", "%Y") # short names for pure numeric log-level ("Level 25" could be truncated by short formats): def _init(): <|fim_middle|> _init() <|fim▁end|>
for i in range(50): if logging.getLevelName(i).startswith('Level'): logging.addLevelName(i, '#%02d-Lev.' % i)
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|># emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*- # vi: set ft=python sts=4 ts=4 sw=4 noet : # This file is part of Fail2Ban. # # Fail2Ban is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # Fail2Ban 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Fail2Ban; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Author: Cyril Jaquier # __author__ = "Cyril Jaquier" __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL" import logging.handlers # Custom debug levels logging.MSG = logging.INFO - 2 logging.TRACEDEBUG = 7 logging.HEAVYDEBUG = 5 logging.addLevelName(logging.MSG, 'MSG') logging.addLevelName(logging.TRACEDEBUG, 'TRACE') logging.addLevelName(logging.HEAVYDEBUG, 'HEAVY') """ Below derived from: https://mail.python.org/pipermail/tutor/2007-August/056243.html """ logging.NOTICE = logging.INFO + 5 logging.addLevelName(logging.NOTICE, 'NOTICE') # define a new logger function for notice # this is exactly like existing info, critical, debug...etc def _Logger_notice(self, msg, *args, **kwargs): """ Log 'msg % args' with severity 'NOTICE'. To pass exception information, use the keyword argument exc_info with a true value, e.g. logger.notice("Houston, we have a %s", "major disaster", exc_info=1) """ if self.isEnabledFor(logging.NOTICE): <|fim_middle|> logging.Logger.notice = _Logger_notice # define a new root level notice function # this is exactly like existing info, critical, debug...etc def _root_notice(msg, *args, **kwargs): """ Log a message with severity 'NOTICE' on the root logger. """ if len(logging.root.handlers) == 0: logging.basicConfig() logging.root.notice(msg, *args, **kwargs) # make the notice root level function known logging.notice = _root_notice # add NOTICE to the priority map of all the levels logging.handlers.SysLogHandler.priority_map['NOTICE'] = 'notice' from time import strptime # strptime thread safety hack-around - http://bugs.python.org/issue7980 strptime("2012", "%Y") # short names for pure numeric log-level ("Level 25" could be truncated by short formats): def _init(): for i in range(50): if logging.getLevelName(i).startswith('Level'): logging.addLevelName(i, '#%02d-Lev.' % i) _init() <|fim▁end|>
self._log(logging.NOTICE, msg, args, **kwargs)
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|># emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*- # vi: set ft=python sts=4 ts=4 sw=4 noet : # This file is part of Fail2Ban. # # Fail2Ban is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # Fail2Ban 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Fail2Ban; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Author: Cyril Jaquier # __author__ = "Cyril Jaquier" __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL" import logging.handlers # Custom debug levels logging.MSG = logging.INFO - 2 logging.TRACEDEBUG = 7 logging.HEAVYDEBUG = 5 logging.addLevelName(logging.MSG, 'MSG') logging.addLevelName(logging.TRACEDEBUG, 'TRACE') logging.addLevelName(logging.HEAVYDEBUG, 'HEAVY') """ Below derived from: https://mail.python.org/pipermail/tutor/2007-August/056243.html """ logging.NOTICE = logging.INFO + 5 logging.addLevelName(logging.NOTICE, 'NOTICE') # define a new logger function for notice # this is exactly like existing info, critical, debug...etc def _Logger_notice(self, msg, *args, **kwargs): """ Log 'msg % args' with severity 'NOTICE'. To pass exception information, use the keyword argument exc_info with a true value, e.g. logger.notice("Houston, we have a %s", "major disaster", exc_info=1) """ if self.isEnabledFor(logging.NOTICE): self._log(logging.NOTICE, msg, args, **kwargs) logging.Logger.notice = _Logger_notice # define a new root level notice function # this is exactly like existing info, critical, debug...etc def _root_notice(msg, *args, **kwargs): """ Log a message with severity 'NOTICE' on the root logger. """ if len(logging.root.handlers) == 0: <|fim_middle|> logging.root.notice(msg, *args, **kwargs) # make the notice root level function known logging.notice = _root_notice # add NOTICE to the priority map of all the levels logging.handlers.SysLogHandler.priority_map['NOTICE'] = 'notice' from time import strptime # strptime thread safety hack-around - http://bugs.python.org/issue7980 strptime("2012", "%Y") # short names for pure numeric log-level ("Level 25" could be truncated by short formats): def _init(): for i in range(50): if logging.getLevelName(i).startswith('Level'): logging.addLevelName(i, '#%02d-Lev.' % i) _init() <|fim▁end|>
logging.basicConfig()
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|># emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*- # vi: set ft=python sts=4 ts=4 sw=4 noet : # This file is part of Fail2Ban. # # Fail2Ban is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # Fail2Ban 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Fail2Ban; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Author: Cyril Jaquier # __author__ = "Cyril Jaquier" __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL" import logging.handlers # Custom debug levels logging.MSG = logging.INFO - 2 logging.TRACEDEBUG = 7 logging.HEAVYDEBUG = 5 logging.addLevelName(logging.MSG, 'MSG') logging.addLevelName(logging.TRACEDEBUG, 'TRACE') logging.addLevelName(logging.HEAVYDEBUG, 'HEAVY') """ Below derived from: https://mail.python.org/pipermail/tutor/2007-August/056243.html """ logging.NOTICE = logging.INFO + 5 logging.addLevelName(logging.NOTICE, 'NOTICE') # define a new logger function for notice # this is exactly like existing info, critical, debug...etc def _Logger_notice(self, msg, *args, **kwargs): """ Log 'msg % args' with severity 'NOTICE'. To pass exception information, use the keyword argument exc_info with a true value, e.g. logger.notice("Houston, we have a %s", "major disaster", exc_info=1) """ if self.isEnabledFor(logging.NOTICE): self._log(logging.NOTICE, msg, args, **kwargs) logging.Logger.notice = _Logger_notice # define a new root level notice function # this is exactly like existing info, critical, debug...etc def _root_notice(msg, *args, **kwargs): """ Log a message with severity 'NOTICE' on the root logger. """ if len(logging.root.handlers) == 0: logging.basicConfig() logging.root.notice(msg, *args, **kwargs) # make the notice root level function known logging.notice = _root_notice # add NOTICE to the priority map of all the levels logging.handlers.SysLogHandler.priority_map['NOTICE'] = 'notice' from time import strptime # strptime thread safety hack-around - http://bugs.python.org/issue7980 strptime("2012", "%Y") # short names for pure numeric log-level ("Level 25" could be truncated by short formats): def _init(): for i in range(50): if logging.getLevelName(i).startswith('Level'): <|fim_middle|> _init() <|fim▁end|>
logging.addLevelName(i, '#%02d-Lev.' % i)
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|># emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*- # vi: set ft=python sts=4 ts=4 sw=4 noet : # This file is part of Fail2Ban. # # Fail2Ban is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # Fail2Ban 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Fail2Ban; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Author: Cyril Jaquier # __author__ = "Cyril Jaquier" __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL" import logging.handlers # Custom debug levels logging.MSG = logging.INFO - 2 logging.TRACEDEBUG = 7 logging.HEAVYDEBUG = 5 logging.addLevelName(logging.MSG, 'MSG') logging.addLevelName(logging.TRACEDEBUG, 'TRACE') logging.addLevelName(logging.HEAVYDEBUG, 'HEAVY') """ Below derived from: https://mail.python.org/pipermail/tutor/2007-August/056243.html """ logging.NOTICE = logging.INFO + 5 logging.addLevelName(logging.NOTICE, 'NOTICE') # define a new logger function for notice # this is exactly like existing info, critical, debug...etc def <|fim_middle|>(self, msg, *args, **kwargs): """ Log 'msg % args' with severity 'NOTICE'. To pass exception information, use the keyword argument exc_info with a true value, e.g. logger.notice("Houston, we have a %s", "major disaster", exc_info=1) """ if self.isEnabledFor(logging.NOTICE): self._log(logging.NOTICE, msg, args, **kwargs) logging.Logger.notice = _Logger_notice # define a new root level notice function # this is exactly like existing info, critical, debug...etc def _root_notice(msg, *args, **kwargs): """ Log a message with severity 'NOTICE' on the root logger. """ if len(logging.root.handlers) == 0: logging.basicConfig() logging.root.notice(msg, *args, **kwargs) # make the notice root level function known logging.notice = _root_notice # add NOTICE to the priority map of all the levels logging.handlers.SysLogHandler.priority_map['NOTICE'] = 'notice' from time import strptime # strptime thread safety hack-around - http://bugs.python.org/issue7980 strptime("2012", "%Y") # short names for pure numeric log-level ("Level 25" could be truncated by short formats): def _init(): for i in range(50): if logging.getLevelName(i).startswith('Level'): logging.addLevelName(i, '#%02d-Lev.' % i) _init() <|fim▁end|>
_Logger_notice
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|># emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*- # vi: set ft=python sts=4 ts=4 sw=4 noet : # This file is part of Fail2Ban. # # Fail2Ban is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # Fail2Ban 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Fail2Ban; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Author: Cyril Jaquier # __author__ = "Cyril Jaquier" __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL" import logging.handlers # Custom debug levels logging.MSG = logging.INFO - 2 logging.TRACEDEBUG = 7 logging.HEAVYDEBUG = 5 logging.addLevelName(logging.MSG, 'MSG') logging.addLevelName(logging.TRACEDEBUG, 'TRACE') logging.addLevelName(logging.HEAVYDEBUG, 'HEAVY') """ Below derived from: https://mail.python.org/pipermail/tutor/2007-August/056243.html """ logging.NOTICE = logging.INFO + 5 logging.addLevelName(logging.NOTICE, 'NOTICE') # define a new logger function for notice # this is exactly like existing info, critical, debug...etc def _Logger_notice(self, msg, *args, **kwargs): """ Log 'msg % args' with severity 'NOTICE'. To pass exception information, use the keyword argument exc_info with a true value, e.g. logger.notice("Houston, we have a %s", "major disaster", exc_info=1) """ if self.isEnabledFor(logging.NOTICE): self._log(logging.NOTICE, msg, args, **kwargs) logging.Logger.notice = _Logger_notice # define a new root level notice function # this is exactly like existing info, critical, debug...etc def <|fim_middle|>(msg, *args, **kwargs): """ Log a message with severity 'NOTICE' on the root logger. """ if len(logging.root.handlers) == 0: logging.basicConfig() logging.root.notice(msg, *args, **kwargs) # make the notice root level function known logging.notice = _root_notice # add NOTICE to the priority map of all the levels logging.handlers.SysLogHandler.priority_map['NOTICE'] = 'notice' from time import strptime # strptime thread safety hack-around - http://bugs.python.org/issue7980 strptime("2012", "%Y") # short names for pure numeric log-level ("Level 25" could be truncated by short formats): def _init(): for i in range(50): if logging.getLevelName(i).startswith('Level'): logging.addLevelName(i, '#%02d-Lev.' % i) _init() <|fim▁end|>
_root_notice
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|># emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*- # vi: set ft=python sts=4 ts=4 sw=4 noet : # This file is part of Fail2Ban. # # Fail2Ban is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # Fail2Ban 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Fail2Ban; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Author: Cyril Jaquier # __author__ = "Cyril Jaquier" __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL" import logging.handlers # Custom debug levels logging.MSG = logging.INFO - 2 logging.TRACEDEBUG = 7 logging.HEAVYDEBUG = 5 logging.addLevelName(logging.MSG, 'MSG') logging.addLevelName(logging.TRACEDEBUG, 'TRACE') logging.addLevelName(logging.HEAVYDEBUG, 'HEAVY') """ Below derived from: https://mail.python.org/pipermail/tutor/2007-August/056243.html """ logging.NOTICE = logging.INFO + 5 logging.addLevelName(logging.NOTICE, 'NOTICE') # define a new logger function for notice # this is exactly like existing info, critical, debug...etc def _Logger_notice(self, msg, *args, **kwargs): """ Log 'msg % args' with severity 'NOTICE'. To pass exception information, use the keyword argument exc_info with a true value, e.g. logger.notice("Houston, we have a %s", "major disaster", exc_info=1) """ if self.isEnabledFor(logging.NOTICE): self._log(logging.NOTICE, msg, args, **kwargs) logging.Logger.notice = _Logger_notice # define a new root level notice function # this is exactly like existing info, critical, debug...etc def _root_notice(msg, *args, **kwargs): """ Log a message with severity 'NOTICE' on the root logger. """ if len(logging.root.handlers) == 0: logging.basicConfig() logging.root.notice(msg, *args, **kwargs) # make the notice root level function known logging.notice = _root_notice # add NOTICE to the priority map of all the levels logging.handlers.SysLogHandler.priority_map['NOTICE'] = 'notice' from time import strptime # strptime thread safety hack-around - http://bugs.python.org/issue7980 strptime("2012", "%Y") # short names for pure numeric log-level ("Level 25" could be truncated by short formats): def <|fim_middle|>(): for i in range(50): if logging.getLevelName(i).startswith('Level'): logging.addLevelName(i, '#%02d-Lev.' % i) _init() <|fim▁end|>
_init
<|file_name|>gcccuda.py<|end_file_name|><|fim▁begin|>## # Copyright 2013-2020 Ghent University # # This file is part of EasyBuild, # originally created by the HPC team of Ghent University (http://ugent.be/hpc/en), # with support of Ghent University (http://ugent.be/hpc), # the Flemish Supercomputer Centre (VSC) (https://www.vscentrum.be), # Flemish Research Foundation (FWO) (http://www.fwo.be/en) # and the Department of Economy, Science and Innovation (EWI) (http://www.ewi-vlaanderen.be/en). # # https://github.com/easybuilders/easybuild # # EasyBuild is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation v2. # # EasyBuild is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of<|fim▁hole|># GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with EasyBuild. If not, see <http://www.gnu.org/licenses/>. ## """ EasyBuild support for a GCC+CUDA compiler toolchain. :author: Kenneth Hoste (Ghent University) """ from easybuild.toolchains.compiler.cuda import Cuda from easybuild.toolchains.gcc import GccToolchain class GccCUDA(GccToolchain, Cuda): """Compiler toolchain with GCC and CUDA.""" NAME = 'gcccuda' COMPILER_MODULE_NAME = ['GCC', 'CUDA'] SUBTOOLCHAIN = GccToolchain.NAME<|fim▁end|>
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
<|file_name|>gcccuda.py<|end_file_name|><|fim▁begin|>## # Copyright 2013-2020 Ghent University # # This file is part of EasyBuild, # originally created by the HPC team of Ghent University (http://ugent.be/hpc/en), # with support of Ghent University (http://ugent.be/hpc), # the Flemish Supercomputer Centre (VSC) (https://www.vscentrum.be), # Flemish Research Foundation (FWO) (http://www.fwo.be/en) # and the Department of Economy, Science and Innovation (EWI) (http://www.ewi-vlaanderen.be/en). # # https://github.com/easybuilders/easybuild # # EasyBuild is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation v2. # # EasyBuild 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with EasyBuild. If not, see <http://www.gnu.org/licenses/>. ## """ EasyBuild support for a GCC+CUDA compiler toolchain. :author: Kenneth Hoste (Ghent University) """ from easybuild.toolchains.compiler.cuda import Cuda from easybuild.toolchains.gcc import GccToolchain class GccCUDA(GccToolchain, Cuda): <|fim_middle|> <|fim▁end|>
"""Compiler toolchain with GCC and CUDA.""" NAME = 'gcccuda' COMPILER_MODULE_NAME = ['GCC', 'CUDA'] SUBTOOLCHAIN = GccToolchain.NAME
<|file_name|>add_rack_bunker.py<|end_file_name|><|fim▁begin|># -*- cpy-indent-level: 4; indent-tabs-mode: nil -*- # ex: set expandtab softtabstop=4 shiftwidth=4:<|fim▁hole|># Licensed 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. """Contains the logic for `aq add rack --bunker`.""" from aquilon.worker.broker import BrokerCommand # pylint: disable=W0611 from aquilon.worker.commands.add_rack import CommandAddRack class CommandAddRackBunker(CommandAddRack): required_parameters = ["bunker", "row", "column"]<|fim▁end|>
# # Copyright (C) 2008,2009,2010,2011,2012,2013,2014,2018 Contributor #
<|file_name|>add_rack_bunker.py<|end_file_name|><|fim▁begin|># -*- cpy-indent-level: 4; indent-tabs-mode: nil -*- # ex: set expandtab softtabstop=4 shiftwidth=4: # # Copyright (C) 2008,2009,2010,2011,2012,2013,2014,2018 Contributor # # Licensed 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. """Contains the logic for `aq add rack --bunker`.""" from aquilon.worker.broker import BrokerCommand # pylint: disable=W0611 from aquilon.worker.commands.add_rack import CommandAddRack class CommandAddRackBunker(CommandAddRack): <|fim_middle|> <|fim▁end|>
required_parameters = ["bunker", "row", "column"]
<|file_name|>divsum_analysis.py<|end_file_name|><|fim▁begin|>#!/usr/bin/python<|fim▁hole|>import sys print "divsum_analysis.py DivsumFile NumberOfNucleotides" try: file = sys.argv[1] except: file = raw_input("Introduce RepeatMasker's Divsum file: ") try: nucs = sys.argv[2] except: nucs = raw_input("Introduce number of analysed nucleotides: ") nucs = int(nucs) data = open(file).readlines() s_matrix = data.index("Coverage for each repeat class and divergence (Kimura)\n") matrix = [] elements = data[s_matrix+1] elements = elements.split() for element in elements[1:]: matrix.append([element,[]]) n_el = len(matrix) for line in data[s_matrix+2:]: # print line info = line.split() info = info[1:] for n in range(0,n_el): matrix[n][1].append(int(info[n])) abs = open(file+".abs", "w") rel = open(file+".rel", "w") for n in range(0,n_el): abs.write("%s\t%s\n" % (matrix[n][0], sum(matrix[n][1]))) rel.write("%s\t%s\n" % (matrix[n][0], round(1.0*sum(matrix[n][1])/nucs,100)))<|fim▁end|>
<|file_name|>test_nondet.py<|end_file_name|><|fim▁begin|>import numpy as np from numba import cuda, float32 from numba.cuda.testing import unittest, CUDATestCase def generate_input(n): A = np.array(np.arange(n * n).reshape(n, n), dtype=np.float32) B = np.array(np.arange(n) + 0, dtype=A.dtype) return A, B class TestCudaNonDet(CUDATestCase): def test_for_pre(self): """Test issue with loop not running due to bad sign-extension at the for loop precondition. """ @cuda.jit(argtypes=[float32[:, :], float32[:, :], float32[:]]) def diagproduct(c, a, b): startX, startY = cuda.grid(2) gridX = cuda.gridDim.x * cuda.blockDim.x gridY = cuda.gridDim.y * cuda.blockDim.y height = c.shape[0] width = c.shape[1] for x in range(startX, width, (gridX)): for y in range(startY, height, (gridY)):<|fim▁hole|> c[y, x] = a[y, x] * b[x] N = 8 A, B = generate_input(N) F = np.empty(A.shape, dtype=A.dtype) blockdim = (32, 8) griddim = (1, 1) dA = cuda.to_device(A) dB = cuda.to_device(B) dF = cuda.to_device(F, copy=False) diagproduct[griddim, blockdim](dF, dA, dB) E = np.dot(A, np.diag(B)) np.testing.assert_array_almost_equal(dF.copy_to_host(), E) if __name__ == '__main__': unittest.main()<|fim▁end|>
<|file_name|>test_nondet.py<|end_file_name|><|fim▁begin|>import numpy as np from numba import cuda, float32 from numba.cuda.testing import unittest, CUDATestCase def generate_input(n): <|fim_middle|> class TestCudaNonDet(CUDATestCase): def test_for_pre(self): """Test issue with loop not running due to bad sign-extension at the for loop precondition. """ @cuda.jit(argtypes=[float32[:, :], float32[:, :], float32[:]]) def diagproduct(c, a, b): startX, startY = cuda.grid(2) gridX = cuda.gridDim.x * cuda.blockDim.x gridY = cuda.gridDim.y * cuda.blockDim.y height = c.shape[0] width = c.shape[1] for x in range(startX, width, (gridX)): for y in range(startY, height, (gridY)): c[y, x] = a[y, x] * b[x] N = 8 A, B = generate_input(N) F = np.empty(A.shape, dtype=A.dtype) blockdim = (32, 8) griddim = (1, 1) dA = cuda.to_device(A) dB = cuda.to_device(B) dF = cuda.to_device(F, copy=False) diagproduct[griddim, blockdim](dF, dA, dB) E = np.dot(A, np.diag(B)) np.testing.assert_array_almost_equal(dF.copy_to_host(), E) if __name__ == '__main__': unittest.main() <|fim▁end|>
A = np.array(np.arange(n * n).reshape(n, n), dtype=np.float32) B = np.array(np.arange(n) + 0, dtype=A.dtype) return A, B
<|file_name|>test_nondet.py<|end_file_name|><|fim▁begin|>import numpy as np from numba import cuda, float32 from numba.cuda.testing import unittest, CUDATestCase def generate_input(n): A = np.array(np.arange(n * n).reshape(n, n), dtype=np.float32) B = np.array(np.arange(n) + 0, dtype=A.dtype) return A, B class TestCudaNonDet(CUDATestCase): <|fim_middle|> if __name__ == '__main__': unittest.main() <|fim▁end|>
def test_for_pre(self): """Test issue with loop not running due to bad sign-extension at the for loop precondition. """ @cuda.jit(argtypes=[float32[:, :], float32[:, :], float32[:]]) def diagproduct(c, a, b): startX, startY = cuda.grid(2) gridX = cuda.gridDim.x * cuda.blockDim.x gridY = cuda.gridDim.y * cuda.blockDim.y height = c.shape[0] width = c.shape[1] for x in range(startX, width, (gridX)): for y in range(startY, height, (gridY)): c[y, x] = a[y, x] * b[x] N = 8 A, B = generate_input(N) F = np.empty(A.shape, dtype=A.dtype) blockdim = (32, 8) griddim = (1, 1) dA = cuda.to_device(A) dB = cuda.to_device(B) dF = cuda.to_device(F, copy=False) diagproduct[griddim, blockdim](dF, dA, dB) E = np.dot(A, np.diag(B)) np.testing.assert_array_almost_equal(dF.copy_to_host(), E)
<|file_name|>test_nondet.py<|end_file_name|><|fim▁begin|>import numpy as np from numba import cuda, float32 from numba.cuda.testing import unittest, CUDATestCase def generate_input(n): A = np.array(np.arange(n * n).reshape(n, n), dtype=np.float32) B = np.array(np.arange(n) + 0, dtype=A.dtype) return A, B class TestCudaNonDet(CUDATestCase): def test_for_pre(self): <|fim_middle|> if __name__ == '__main__': unittest.main() <|fim▁end|>
"""Test issue with loop not running due to bad sign-extension at the for loop precondition. """ @cuda.jit(argtypes=[float32[:, :], float32[:, :], float32[:]]) def diagproduct(c, a, b): startX, startY = cuda.grid(2) gridX = cuda.gridDim.x * cuda.blockDim.x gridY = cuda.gridDim.y * cuda.blockDim.y height = c.shape[0] width = c.shape[1] for x in range(startX, width, (gridX)): for y in range(startY, height, (gridY)): c[y, x] = a[y, x] * b[x] N = 8 A, B = generate_input(N) F = np.empty(A.shape, dtype=A.dtype) blockdim = (32, 8) griddim = (1, 1) dA = cuda.to_device(A) dB = cuda.to_device(B) dF = cuda.to_device(F, copy=False) diagproduct[griddim, blockdim](dF, dA, dB) E = np.dot(A, np.diag(B)) np.testing.assert_array_almost_equal(dF.copy_to_host(), E)
<|file_name|>test_nondet.py<|end_file_name|><|fim▁begin|>import numpy as np from numba import cuda, float32 from numba.cuda.testing import unittest, CUDATestCase def generate_input(n): A = np.array(np.arange(n * n).reshape(n, n), dtype=np.float32) B = np.array(np.arange(n) + 0, dtype=A.dtype) return A, B class TestCudaNonDet(CUDATestCase): def test_for_pre(self): """Test issue with loop not running due to bad sign-extension at the for loop precondition. """ @cuda.jit(argtypes=[float32[:, :], float32[:, :], float32[:]]) def diagproduct(c, a, b): <|fim_middle|> N = 8 A, B = generate_input(N) F = np.empty(A.shape, dtype=A.dtype) blockdim = (32, 8) griddim = (1, 1) dA = cuda.to_device(A) dB = cuda.to_device(B) dF = cuda.to_device(F, copy=False) diagproduct[griddim, blockdim](dF, dA, dB) E = np.dot(A, np.diag(B)) np.testing.assert_array_almost_equal(dF.copy_to_host(), E) if __name__ == '__main__': unittest.main() <|fim▁end|>
startX, startY = cuda.grid(2) gridX = cuda.gridDim.x * cuda.blockDim.x gridY = cuda.gridDim.y * cuda.blockDim.y height = c.shape[0] width = c.shape[1] for x in range(startX, width, (gridX)): for y in range(startY, height, (gridY)): c[y, x] = a[y, x] * b[x]
<|file_name|>test_nondet.py<|end_file_name|><|fim▁begin|>import numpy as np from numba import cuda, float32 from numba.cuda.testing import unittest, CUDATestCase def generate_input(n): A = np.array(np.arange(n * n).reshape(n, n), dtype=np.float32) B = np.array(np.arange(n) + 0, dtype=A.dtype) return A, B class TestCudaNonDet(CUDATestCase): def test_for_pre(self): """Test issue with loop not running due to bad sign-extension at the for loop precondition. """ @cuda.jit(argtypes=[float32[:, :], float32[:, :], float32[:]]) def diagproduct(c, a, b): startX, startY = cuda.grid(2) gridX = cuda.gridDim.x * cuda.blockDim.x gridY = cuda.gridDim.y * cuda.blockDim.y height = c.shape[0] width = c.shape[1] for x in range(startX, width, (gridX)): for y in range(startY, height, (gridY)): c[y, x] = a[y, x] * b[x] N = 8 A, B = generate_input(N) F = np.empty(A.shape, dtype=A.dtype) blockdim = (32, 8) griddim = (1, 1) dA = cuda.to_device(A) dB = cuda.to_device(B) dF = cuda.to_device(F, copy=False) diagproduct[griddim, blockdim](dF, dA, dB) E = np.dot(A, np.diag(B)) np.testing.assert_array_almost_equal(dF.copy_to_host(), E) if __name__ == '__main__': <|fim_middle|> <|fim▁end|>
unittest.main()
<|file_name|>test_nondet.py<|end_file_name|><|fim▁begin|>import numpy as np from numba import cuda, float32 from numba.cuda.testing import unittest, CUDATestCase def <|fim_middle|>(n): A = np.array(np.arange(n * n).reshape(n, n), dtype=np.float32) B = np.array(np.arange(n) + 0, dtype=A.dtype) return A, B class TestCudaNonDet(CUDATestCase): def test_for_pre(self): """Test issue with loop not running due to bad sign-extension at the for loop precondition. """ @cuda.jit(argtypes=[float32[:, :], float32[:, :], float32[:]]) def diagproduct(c, a, b): startX, startY = cuda.grid(2) gridX = cuda.gridDim.x * cuda.blockDim.x gridY = cuda.gridDim.y * cuda.blockDim.y height = c.shape[0] width = c.shape[1] for x in range(startX, width, (gridX)): for y in range(startY, height, (gridY)): c[y, x] = a[y, x] * b[x] N = 8 A, B = generate_input(N) F = np.empty(A.shape, dtype=A.dtype) blockdim = (32, 8) griddim = (1, 1) dA = cuda.to_device(A) dB = cuda.to_device(B) dF = cuda.to_device(F, copy=False) diagproduct[griddim, blockdim](dF, dA, dB) E = np.dot(A, np.diag(B)) np.testing.assert_array_almost_equal(dF.copy_to_host(), E) if __name__ == '__main__': unittest.main() <|fim▁end|>
generate_input
<|file_name|>test_nondet.py<|end_file_name|><|fim▁begin|>import numpy as np from numba import cuda, float32 from numba.cuda.testing import unittest, CUDATestCase def generate_input(n): A = np.array(np.arange(n * n).reshape(n, n), dtype=np.float32) B = np.array(np.arange(n) + 0, dtype=A.dtype) return A, B class TestCudaNonDet(CUDATestCase): def <|fim_middle|>(self): """Test issue with loop not running due to bad sign-extension at the for loop precondition. """ @cuda.jit(argtypes=[float32[:, :], float32[:, :], float32[:]]) def diagproduct(c, a, b): startX, startY = cuda.grid(2) gridX = cuda.gridDim.x * cuda.blockDim.x gridY = cuda.gridDim.y * cuda.blockDim.y height = c.shape[0] width = c.shape[1] for x in range(startX, width, (gridX)): for y in range(startY, height, (gridY)): c[y, x] = a[y, x] * b[x] N = 8 A, B = generate_input(N) F = np.empty(A.shape, dtype=A.dtype) blockdim = (32, 8) griddim = (1, 1) dA = cuda.to_device(A) dB = cuda.to_device(B) dF = cuda.to_device(F, copy=False) diagproduct[griddim, blockdim](dF, dA, dB) E = np.dot(A, np.diag(B)) np.testing.assert_array_almost_equal(dF.copy_to_host(), E) if __name__ == '__main__': unittest.main() <|fim▁end|>
test_for_pre
<|file_name|>test_nondet.py<|end_file_name|><|fim▁begin|>import numpy as np from numba import cuda, float32 from numba.cuda.testing import unittest, CUDATestCase def generate_input(n): A = np.array(np.arange(n * n).reshape(n, n), dtype=np.float32) B = np.array(np.arange(n) + 0, dtype=A.dtype) return A, B class TestCudaNonDet(CUDATestCase): def test_for_pre(self): """Test issue with loop not running due to bad sign-extension at the for loop precondition. """ @cuda.jit(argtypes=[float32[:, :], float32[:, :], float32[:]]) def <|fim_middle|>(c, a, b): startX, startY = cuda.grid(2) gridX = cuda.gridDim.x * cuda.blockDim.x gridY = cuda.gridDim.y * cuda.blockDim.y height = c.shape[0] width = c.shape[1] for x in range(startX, width, (gridX)): for y in range(startY, height, (gridY)): c[y, x] = a[y, x] * b[x] N = 8 A, B = generate_input(N) F = np.empty(A.shape, dtype=A.dtype) blockdim = (32, 8) griddim = (1, 1) dA = cuda.to_device(A) dB = cuda.to_device(B) dF = cuda.to_device(F, copy=False) diagproduct[griddim, blockdim](dF, dA, dB) E = np.dot(A, np.diag(B)) np.testing.assert_array_almost_equal(dF.copy_to_host(), E) if __name__ == '__main__': unittest.main() <|fim▁end|>
diagproduct
<|file_name|>stack.py<|end_file_name|><|fim▁begin|># Stack implementation class Stack (object): def __init__ (self):<|fim▁hole|> self.stack.append(data) def peek (self): if self.isEmpty(): return None return self.stack[-1] def pop (self): if self.isEmpty(): return None return self.stack.pop() def isEmpty (self): return len(self.stack) == 0 def __str__ (self): return ' '.join(str(x) for x in self.stack)<|fim▁end|>
self.stack = [] def push (self, data):
<|file_name|>stack.py<|end_file_name|><|fim▁begin|># Stack implementation class Stack (object): <|fim_middle|> <|fim▁end|>
def __init__ (self): self.stack = [] def push (self, data): self.stack.append(data) def peek (self): if self.isEmpty(): return None return self.stack[-1] def pop (self): if self.isEmpty(): return None return self.stack.pop() def isEmpty (self): return len(self.stack) == 0 def __str__ (self): return ' '.join(str(x) for x in self.stack)
<|file_name|>stack.py<|end_file_name|><|fim▁begin|># Stack implementation class Stack (object): def __init__ (self): <|fim_middle|> def push (self, data): self.stack.append(data) def peek (self): if self.isEmpty(): return None return self.stack[-1] def pop (self): if self.isEmpty(): return None return self.stack.pop() def isEmpty (self): return len(self.stack) == 0 def __str__ (self): return ' '.join(str(x) for x in self.stack) <|fim▁end|>
self.stack = []