commit
stringlengths
40
40
old_file
stringlengths
4
118
new_file
stringlengths
4
118
old_contents
stringlengths
0
2.94k
new_contents
stringlengths
1
4.43k
subject
stringlengths
15
444
message
stringlengths
16
3.45k
lang
stringclasses
1 value
license
stringclasses
13 values
repos
stringlengths
5
43.2k
prompt
stringlengths
17
4.58k
response
stringlengths
1
4.43k
prompt_tagged
stringlengths
58
4.62k
response_tagged
stringlengths
1
4.43k
text
stringlengths
132
7.29k
text_tagged
stringlengths
173
7.33k
3c5e708961e336f71805d79465944e6503b83538
tests/test_screen19.py
tests/test_screen19.py
from __future__ import absolute_import, division, print_function import pytest from screen19.screen import Screen19 def test_screen19_command_line_help_does_not_crash(): Screen19().run([]) def test_screen19(dials_data, tmpdir): data_dir = dials_data("x4wide").strpath with tmpdir.as_cwd(): Screen19().run([data_dir]) logfile = tmpdir.join("screen19.log").read() assert "screen19 successfully completed" in logfile assert "photon incidence rate is outside the linear response region" in logfile @pytest.mark.xfail(raises=ValueError, reason="LAPACK bug?") def test_screen19_single_frame(dials_data, tmpdir): # TODO Use a single frame with fewer than 80 reflections image = dials_data("x4wide").join("X4_wide_M1S4_2_0001.cbf").strpath with tmpdir.as_cwd(): Screen19().run([image]) logfile = tmpdir.join("screen19.log").read() assert "screen19 successfully completed" in logfile
from __future__ import absolute_import, division, print_function import pytest from screen19.screen import Screen19 def test_screen19_command_line_help_does_not_crash(): Screen19().run([]) def test_screen19(dials_data, tmpdir): data_dir = dials_data("x4wide").strpath with tmpdir.as_cwd(): Screen19().run([data_dir], set_up_logging=True) logfile = tmpdir.join("screen19.log").read() assert "screen19 successfully completed" in logfile assert "photon incidence rate is outside the linear response region" in logfile @pytest.mark.xfail(raises=ValueError, reason="LAPACK bug?") def test_screen19_single_frame(dials_data, tmpdir): # TODO Use a single frame with fewer than 80 reflections image = dials_data("x4wide").join("X4_wide_M1S4_2_0001.cbf").strpath with tmpdir.as_cwd(): Screen19().run([image], set_up_logging=True) logfile = tmpdir.join("screen19.log").read() assert "screen19 successfully completed" in logfile
Fix tests broken by new log configuration option
Fix tests broken by new log configuration option
Python
bsd-3-clause
xia2/i19
from __future__ import absolute_import, division, print_function import pytest from screen19.screen import Screen19 def test_screen19_command_line_help_does_not_crash(): Screen19().run([]) def test_screen19(dials_data, tmpdir): data_dir = dials_data("x4wide").strpath with tmpdir.as_cwd(): Screen19().run([data_dir]) logfile = tmpdir.join("screen19.log").read() assert "screen19 successfully completed" in logfile assert "photon incidence rate is outside the linear response region" in logfile @pytest.mark.xfail(raises=ValueError, reason="LAPACK bug?") def test_screen19_single_frame(dials_data, tmpdir): # TODO Use a single frame with fewer than 80 reflections image = dials_data("x4wide").join("X4_wide_M1S4_2_0001.cbf").strpath with tmpdir.as_cwd(): Screen19().run([image]) logfile = tmpdir.join("screen19.log").read() assert "screen19 successfully completed" in logfile Fix tests broken by new log configuration option
from __future__ import absolute_import, division, print_function import pytest from screen19.screen import Screen19 def test_screen19_command_line_help_does_not_crash(): Screen19().run([]) def test_screen19(dials_data, tmpdir): data_dir = dials_data("x4wide").strpath with tmpdir.as_cwd(): Screen19().run([data_dir], set_up_logging=True) logfile = tmpdir.join("screen19.log").read() assert "screen19 successfully completed" in logfile assert "photon incidence rate is outside the linear response region" in logfile @pytest.mark.xfail(raises=ValueError, reason="LAPACK bug?") def test_screen19_single_frame(dials_data, tmpdir): # TODO Use a single frame with fewer than 80 reflections image = dials_data("x4wide").join("X4_wide_M1S4_2_0001.cbf").strpath with tmpdir.as_cwd(): Screen19().run([image], set_up_logging=True) logfile = tmpdir.join("screen19.log").read() assert "screen19 successfully completed" in logfile
<commit_before>from __future__ import absolute_import, division, print_function import pytest from screen19.screen import Screen19 def test_screen19_command_line_help_does_not_crash(): Screen19().run([]) def test_screen19(dials_data, tmpdir): data_dir = dials_data("x4wide").strpath with tmpdir.as_cwd(): Screen19().run([data_dir]) logfile = tmpdir.join("screen19.log").read() assert "screen19 successfully completed" in logfile assert "photon incidence rate is outside the linear response region" in logfile @pytest.mark.xfail(raises=ValueError, reason="LAPACK bug?") def test_screen19_single_frame(dials_data, tmpdir): # TODO Use a single frame with fewer than 80 reflections image = dials_data("x4wide").join("X4_wide_M1S4_2_0001.cbf").strpath with tmpdir.as_cwd(): Screen19().run([image]) logfile = tmpdir.join("screen19.log").read() assert "screen19 successfully completed" in logfile <commit_msg>Fix tests broken by new log configuration option<commit_after>
from __future__ import absolute_import, division, print_function import pytest from screen19.screen import Screen19 def test_screen19_command_line_help_does_not_crash(): Screen19().run([]) def test_screen19(dials_data, tmpdir): data_dir = dials_data("x4wide").strpath with tmpdir.as_cwd(): Screen19().run([data_dir], set_up_logging=True) logfile = tmpdir.join("screen19.log").read() assert "screen19 successfully completed" in logfile assert "photon incidence rate is outside the linear response region" in logfile @pytest.mark.xfail(raises=ValueError, reason="LAPACK bug?") def test_screen19_single_frame(dials_data, tmpdir): # TODO Use a single frame with fewer than 80 reflections image = dials_data("x4wide").join("X4_wide_M1S4_2_0001.cbf").strpath with tmpdir.as_cwd(): Screen19().run([image], set_up_logging=True) logfile = tmpdir.join("screen19.log").read() assert "screen19 successfully completed" in logfile
from __future__ import absolute_import, division, print_function import pytest from screen19.screen import Screen19 def test_screen19_command_line_help_does_not_crash(): Screen19().run([]) def test_screen19(dials_data, tmpdir): data_dir = dials_data("x4wide").strpath with tmpdir.as_cwd(): Screen19().run([data_dir]) logfile = tmpdir.join("screen19.log").read() assert "screen19 successfully completed" in logfile assert "photon incidence rate is outside the linear response region" in logfile @pytest.mark.xfail(raises=ValueError, reason="LAPACK bug?") def test_screen19_single_frame(dials_data, tmpdir): # TODO Use a single frame with fewer than 80 reflections image = dials_data("x4wide").join("X4_wide_M1S4_2_0001.cbf").strpath with tmpdir.as_cwd(): Screen19().run([image]) logfile = tmpdir.join("screen19.log").read() assert "screen19 successfully completed" in logfile Fix tests broken by new log configuration optionfrom __future__ import absolute_import, division, print_function import pytest from screen19.screen import Screen19 def test_screen19_command_line_help_does_not_crash(): Screen19().run([]) def test_screen19(dials_data, tmpdir): data_dir = dials_data("x4wide").strpath with tmpdir.as_cwd(): Screen19().run([data_dir], set_up_logging=True) logfile = tmpdir.join("screen19.log").read() assert "screen19 successfully completed" in logfile assert "photon incidence rate is outside the linear response region" in logfile @pytest.mark.xfail(raises=ValueError, reason="LAPACK bug?") def test_screen19_single_frame(dials_data, tmpdir): # TODO Use a single frame with fewer than 80 reflections image = dials_data("x4wide").join("X4_wide_M1S4_2_0001.cbf").strpath with tmpdir.as_cwd(): Screen19().run([image], set_up_logging=True) logfile = tmpdir.join("screen19.log").read() assert "screen19 successfully completed" in logfile
<commit_before>from __future__ import absolute_import, division, print_function import pytest from screen19.screen import Screen19 def test_screen19_command_line_help_does_not_crash(): Screen19().run([]) def test_screen19(dials_data, tmpdir): data_dir = dials_data("x4wide").strpath with tmpdir.as_cwd(): Screen19().run([data_dir]) logfile = tmpdir.join("screen19.log").read() assert "screen19 successfully completed" in logfile assert "photon incidence rate is outside the linear response region" in logfile @pytest.mark.xfail(raises=ValueError, reason="LAPACK bug?") def test_screen19_single_frame(dials_data, tmpdir): # TODO Use a single frame with fewer than 80 reflections image = dials_data("x4wide").join("X4_wide_M1S4_2_0001.cbf").strpath with tmpdir.as_cwd(): Screen19().run([image]) logfile = tmpdir.join("screen19.log").read() assert "screen19 successfully completed" in logfile <commit_msg>Fix tests broken by new log configuration option<commit_after>from __future__ import absolute_import, division, print_function import pytest from screen19.screen import Screen19 def test_screen19_command_line_help_does_not_crash(): Screen19().run([]) def test_screen19(dials_data, tmpdir): data_dir = dials_data("x4wide").strpath with tmpdir.as_cwd(): Screen19().run([data_dir], set_up_logging=True) logfile = tmpdir.join("screen19.log").read() assert "screen19 successfully completed" in logfile assert "photon incidence rate is outside the linear response region" in logfile @pytest.mark.xfail(raises=ValueError, reason="LAPACK bug?") def test_screen19_single_frame(dials_data, tmpdir): # TODO Use a single frame with fewer than 80 reflections image = dials_data("x4wide").join("X4_wide_M1S4_2_0001.cbf").strpath with tmpdir.as_cwd(): Screen19().run([image], set_up_logging=True) logfile = tmpdir.join("screen19.log").read() assert "screen19 successfully completed" in logfile
a21b02b93b8b92693be6dbdfe9c8d454ee233cc1
fabdefs.py
fabdefs.py
from fabric.api import * """ Define the server environments that this app will be deployed to. Ensure that you have SSH access to the servers for the scripts in 'fabfile.py' to work. """ def production(): """ Env parameters for the production environment. """ env.host_string = 'ubuntu@xxx' env.key_filename = '~/.ssh/xxx.pem' env.project_dir = '/var/www/pmg-cms' env.config_dir = 'config/production' env.git_branch = 'master' env.activate = 'source %s/env/bin/activate' % env.project_dir print("PRODUCTION ENVIRONMENT\n") return
from fabric.api import * """ Define the server environments that this app will be deployed to. Ensure that you have SSH access to the servers for the scripts in 'fabfile.py' to work. """ def production(): """ Env parameters for the production environment. """ env.host_string = 'ubuntu@54.76.117.251' env.key_filename = '~/.ssh/petrus.pem' env.project_dir = '/var/www/pmg-cms' env.config_dir = 'config/production' env.git_branch = 'master' env.activate = 'source %s/env/bin/activate' % env.project_dir print("PRODUCTION ENVIRONMENT\n") return
Add details of demo EC2 server.
Add details of demo EC2 server.
Python
apache-2.0
Code4SA/pmg-cms-2,Code4SA/pmg-cms-2,Code4SA/pmg-cms-2
from fabric.api import * """ Define the server environments that this app will be deployed to. Ensure that you have SSH access to the servers for the scripts in 'fabfile.py' to work. """ def production(): """ Env parameters for the production environment. """ env.host_string = 'ubuntu@xxx' env.key_filename = '~/.ssh/xxx.pem' env.project_dir = '/var/www/pmg-cms' env.config_dir = 'config/production' env.git_branch = 'master' env.activate = 'source %s/env/bin/activate' % env.project_dir print("PRODUCTION ENVIRONMENT\n") returnAdd details of demo EC2 server.
from fabric.api import * """ Define the server environments that this app will be deployed to. Ensure that you have SSH access to the servers for the scripts in 'fabfile.py' to work. """ def production(): """ Env parameters for the production environment. """ env.host_string = 'ubuntu@54.76.117.251' env.key_filename = '~/.ssh/petrus.pem' env.project_dir = '/var/www/pmg-cms' env.config_dir = 'config/production' env.git_branch = 'master' env.activate = 'source %s/env/bin/activate' % env.project_dir print("PRODUCTION ENVIRONMENT\n") return
<commit_before>from fabric.api import * """ Define the server environments that this app will be deployed to. Ensure that you have SSH access to the servers for the scripts in 'fabfile.py' to work. """ def production(): """ Env parameters for the production environment. """ env.host_string = 'ubuntu@xxx' env.key_filename = '~/.ssh/xxx.pem' env.project_dir = '/var/www/pmg-cms' env.config_dir = 'config/production' env.git_branch = 'master' env.activate = 'source %s/env/bin/activate' % env.project_dir print("PRODUCTION ENVIRONMENT\n") return<commit_msg>Add details of demo EC2 server.<commit_after>
from fabric.api import * """ Define the server environments that this app will be deployed to. Ensure that you have SSH access to the servers for the scripts in 'fabfile.py' to work. """ def production(): """ Env parameters for the production environment. """ env.host_string = 'ubuntu@54.76.117.251' env.key_filename = '~/.ssh/petrus.pem' env.project_dir = '/var/www/pmg-cms' env.config_dir = 'config/production' env.git_branch = 'master' env.activate = 'source %s/env/bin/activate' % env.project_dir print("PRODUCTION ENVIRONMENT\n") return
from fabric.api import * """ Define the server environments that this app will be deployed to. Ensure that you have SSH access to the servers for the scripts in 'fabfile.py' to work. """ def production(): """ Env parameters for the production environment. """ env.host_string = 'ubuntu@xxx' env.key_filename = '~/.ssh/xxx.pem' env.project_dir = '/var/www/pmg-cms' env.config_dir = 'config/production' env.git_branch = 'master' env.activate = 'source %s/env/bin/activate' % env.project_dir print("PRODUCTION ENVIRONMENT\n") returnAdd details of demo EC2 server.from fabric.api import * """ Define the server environments that this app will be deployed to. Ensure that you have SSH access to the servers for the scripts in 'fabfile.py' to work. """ def production(): """ Env parameters for the production environment. """ env.host_string = 'ubuntu@54.76.117.251' env.key_filename = '~/.ssh/petrus.pem' env.project_dir = '/var/www/pmg-cms' env.config_dir = 'config/production' env.git_branch = 'master' env.activate = 'source %s/env/bin/activate' % env.project_dir print("PRODUCTION ENVIRONMENT\n") return
<commit_before>from fabric.api import * """ Define the server environments that this app will be deployed to. Ensure that you have SSH access to the servers for the scripts in 'fabfile.py' to work. """ def production(): """ Env parameters for the production environment. """ env.host_string = 'ubuntu@xxx' env.key_filename = '~/.ssh/xxx.pem' env.project_dir = '/var/www/pmg-cms' env.config_dir = 'config/production' env.git_branch = 'master' env.activate = 'source %s/env/bin/activate' % env.project_dir print("PRODUCTION ENVIRONMENT\n") return<commit_msg>Add details of demo EC2 server.<commit_after>from fabric.api import * """ Define the server environments that this app will be deployed to. Ensure that you have SSH access to the servers for the scripts in 'fabfile.py' to work. """ def production(): """ Env parameters for the production environment. """ env.host_string = 'ubuntu@54.76.117.251' env.key_filename = '~/.ssh/petrus.pem' env.project_dir = '/var/www/pmg-cms' env.config_dir = 'config/production' env.git_branch = 'master' env.activate = 'source %s/env/bin/activate' % env.project_dir print("PRODUCTION ENVIRONMENT\n") return
1606445e137ecae5a1f5c50edcc5e851d399b313
project_euler/025.1000_digit_fibonacci_number.py
project_euler/025.1000_digit_fibonacci_number.py
''' Problem 025 The Fibonacci sequence is defined by the recurrence relation: Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1. Hence the first 12 terms will be: F1 = 1 F2 = 1 F3 = 2 F4 = 3 F5 = 5 F6 = 8 F7 = 13 F8 = 21 F9 = 34 F10 = 55 F11 = 89 F12 = 144 The 12th term, F12, is the first term to contain three digits. What is the index of the first term in the Fibonacci sequence to contain 1000 digits? Solution: Copyright 2017 Dave Cuthbert, MIT License ''' def gen_fibonacci(): term_1 = 1 term_2 = 1 while True: next_term = term_1 + term_2 yield next term_2 = term_1 term_1 = next_term def solve_problem(): get_fibonacci = gen_fibonacci for i in range(10): print(next(get_fibonacci)) return("DONE") if __name__ == "__main__": print(solve_problem())
''' Problem 025 The Fibonacci sequence is defined by the recurrence relation: Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1. Hence the first 12 terms will be: F1 = 1 F2 = 1 F3 = 2 F4 = 3 F5 = 5 F6 = 8 F7 = 13 F8 = 21 F9 = 34 F10 = 55 F11 = 89 F12 = 144 The 12th term, F12, is the first term to contain three digits. What is the index of the first term in the Fibonacci sequence to contain 1000 digits? Solution: Copyright 2017 Dave Cuthbert, MIT License ''' def gen_fibonacci(): term_1 = 1 term_2 = 1 while True: next_term = term_1 + term_2 yield next_term term_2 = term_1 term_1 = next_term def solve_problem(): get_fibonacci = gen_fibonacci() count = 3 # Not starting with first term in sequence while True: current_fib = next(get_fibonacci) if len(str(current_fib)) >= 1000: return(count) count +=1 if __name__ == "__main__": print(solve_problem())
Solve 1000 digit fib number
Solve 1000 digit fib number
Python
mit
daveinnyc/various,daveinnyc/various,daveinnyc/various,daveinnyc/various,daveinnyc/various,daveinnyc/various,daveinnyc/various
''' Problem 025 The Fibonacci sequence is defined by the recurrence relation: Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1. Hence the first 12 terms will be: F1 = 1 F2 = 1 F3 = 2 F4 = 3 F5 = 5 F6 = 8 F7 = 13 F8 = 21 F9 = 34 F10 = 55 F11 = 89 F12 = 144 The 12th term, F12, is the first term to contain three digits. What is the index of the first term in the Fibonacci sequence to contain 1000 digits? Solution: Copyright 2017 Dave Cuthbert, MIT License ''' def gen_fibonacci(): term_1 = 1 term_2 = 1 while True: next_term = term_1 + term_2 yield next term_2 = term_1 term_1 = next_term def solve_problem(): get_fibonacci = gen_fibonacci for i in range(10): print(next(get_fibonacci)) return("DONE") if __name__ == "__main__": print(solve_problem()) Solve 1000 digit fib number
''' Problem 025 The Fibonacci sequence is defined by the recurrence relation: Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1. Hence the first 12 terms will be: F1 = 1 F2 = 1 F3 = 2 F4 = 3 F5 = 5 F6 = 8 F7 = 13 F8 = 21 F9 = 34 F10 = 55 F11 = 89 F12 = 144 The 12th term, F12, is the first term to contain three digits. What is the index of the first term in the Fibonacci sequence to contain 1000 digits? Solution: Copyright 2017 Dave Cuthbert, MIT License ''' def gen_fibonacci(): term_1 = 1 term_2 = 1 while True: next_term = term_1 + term_2 yield next_term term_2 = term_1 term_1 = next_term def solve_problem(): get_fibonacci = gen_fibonacci() count = 3 # Not starting with first term in sequence while True: current_fib = next(get_fibonacci) if len(str(current_fib)) >= 1000: return(count) count +=1 if __name__ == "__main__": print(solve_problem())
<commit_before>''' Problem 025 The Fibonacci sequence is defined by the recurrence relation: Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1. Hence the first 12 terms will be: F1 = 1 F2 = 1 F3 = 2 F4 = 3 F5 = 5 F6 = 8 F7 = 13 F8 = 21 F9 = 34 F10 = 55 F11 = 89 F12 = 144 The 12th term, F12, is the first term to contain three digits. What is the index of the first term in the Fibonacci sequence to contain 1000 digits? Solution: Copyright 2017 Dave Cuthbert, MIT License ''' def gen_fibonacci(): term_1 = 1 term_2 = 1 while True: next_term = term_1 + term_2 yield next term_2 = term_1 term_1 = next_term def solve_problem(): get_fibonacci = gen_fibonacci for i in range(10): print(next(get_fibonacci)) return("DONE") if __name__ == "__main__": print(solve_problem()) <commit_msg>Solve 1000 digit fib number<commit_after>
''' Problem 025 The Fibonacci sequence is defined by the recurrence relation: Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1. Hence the first 12 terms will be: F1 = 1 F2 = 1 F3 = 2 F4 = 3 F5 = 5 F6 = 8 F7 = 13 F8 = 21 F9 = 34 F10 = 55 F11 = 89 F12 = 144 The 12th term, F12, is the first term to contain three digits. What is the index of the first term in the Fibonacci sequence to contain 1000 digits? Solution: Copyright 2017 Dave Cuthbert, MIT License ''' def gen_fibonacci(): term_1 = 1 term_2 = 1 while True: next_term = term_1 + term_2 yield next_term term_2 = term_1 term_1 = next_term def solve_problem(): get_fibonacci = gen_fibonacci() count = 3 # Not starting with first term in sequence while True: current_fib = next(get_fibonacci) if len(str(current_fib)) >= 1000: return(count) count +=1 if __name__ == "__main__": print(solve_problem())
''' Problem 025 The Fibonacci sequence is defined by the recurrence relation: Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1. Hence the first 12 terms will be: F1 = 1 F2 = 1 F3 = 2 F4 = 3 F5 = 5 F6 = 8 F7 = 13 F8 = 21 F9 = 34 F10 = 55 F11 = 89 F12 = 144 The 12th term, F12, is the first term to contain three digits. What is the index of the first term in the Fibonacci sequence to contain 1000 digits? Solution: Copyright 2017 Dave Cuthbert, MIT License ''' def gen_fibonacci(): term_1 = 1 term_2 = 1 while True: next_term = term_1 + term_2 yield next term_2 = term_1 term_1 = next_term def solve_problem(): get_fibonacci = gen_fibonacci for i in range(10): print(next(get_fibonacci)) return("DONE") if __name__ == "__main__": print(solve_problem()) Solve 1000 digit fib number''' Problem 025 The Fibonacci sequence is defined by the recurrence relation: Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1. Hence the first 12 terms will be: F1 = 1 F2 = 1 F3 = 2 F4 = 3 F5 = 5 F6 = 8 F7 = 13 F8 = 21 F9 = 34 F10 = 55 F11 = 89 F12 = 144 The 12th term, F12, is the first term to contain three digits. What is the index of the first term in the Fibonacci sequence to contain 1000 digits? Solution: Copyright 2017 Dave Cuthbert, MIT License ''' def gen_fibonacci(): term_1 = 1 term_2 = 1 while True: next_term = term_1 + term_2 yield next_term term_2 = term_1 term_1 = next_term def solve_problem(): get_fibonacci = gen_fibonacci() count = 3 # Not starting with first term in sequence while True: current_fib = next(get_fibonacci) if len(str(current_fib)) >= 1000: return(count) count +=1 if __name__ == "__main__": print(solve_problem())
<commit_before>''' Problem 025 The Fibonacci sequence is defined by the recurrence relation: Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1. Hence the first 12 terms will be: F1 = 1 F2 = 1 F3 = 2 F4 = 3 F5 = 5 F6 = 8 F7 = 13 F8 = 21 F9 = 34 F10 = 55 F11 = 89 F12 = 144 The 12th term, F12, is the first term to contain three digits. What is the index of the first term in the Fibonacci sequence to contain 1000 digits? Solution: Copyright 2017 Dave Cuthbert, MIT License ''' def gen_fibonacci(): term_1 = 1 term_2 = 1 while True: next_term = term_1 + term_2 yield next term_2 = term_1 term_1 = next_term def solve_problem(): get_fibonacci = gen_fibonacci for i in range(10): print(next(get_fibonacci)) return("DONE") if __name__ == "__main__": print(solve_problem()) <commit_msg>Solve 1000 digit fib number<commit_after>''' Problem 025 The Fibonacci sequence is defined by the recurrence relation: Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1. Hence the first 12 terms will be: F1 = 1 F2 = 1 F3 = 2 F4 = 3 F5 = 5 F6 = 8 F7 = 13 F8 = 21 F9 = 34 F10 = 55 F11 = 89 F12 = 144 The 12th term, F12, is the first term to contain three digits. What is the index of the first term in the Fibonacci sequence to contain 1000 digits? Solution: Copyright 2017 Dave Cuthbert, MIT License ''' def gen_fibonacci(): term_1 = 1 term_2 = 1 while True: next_term = term_1 + term_2 yield next_term term_2 = term_1 term_1 = next_term def solve_problem(): get_fibonacci = gen_fibonacci() count = 3 # Not starting with first term in sequence while True: current_fib = next(get_fibonacci) if len(str(current_fib)) >= 1000: return(count) count +=1 if __name__ == "__main__": print(solve_problem())
accd91b9b180f88facd5a61bddbb073b5a35af63
ratechecker/migrations/0002_remove_fee_loader.py
ratechecker/migrations/0002_remove_fee_loader.py
# -*- coding: utf-8 -*- # Generated by Django 1.11.22 on 2019-10-31 16:33 from __future__ import unicode_literals from django.db import migrations, OperationalError, ProgrammingError def fix_fee_product_index(apps, schema_editor): try: schema_editor.execute( 'DROP INDEX IF EXISTS idx_16977_product_id;' ) except (ProgrammingError, OperationalError): pass try: schema_editor.execute( 'ALTER TABLE IF EXISTS cfpb.ratechecker_fee ' 'DROP CONSTRAINT IF EXISTS idx_16977_product_id;' ) except (ProgrammingError, OperationalError): pass try: schema_editor.execute( 'ALTER TABLE IF EXISTS cfpb.ratechecker_fee ' 'ADD CONSTRAINT idx_16977_product_id ' 'UNIQUE (product_id, state_id, lender, single_family, condo, coop);' ) except (ProgrammingError, OperationalError): pass class Migration(migrations.Migration): dependencies = [ ('ratechecker', '0001_initial'), ] operations = [ migrations.AlterUniqueTogether( name='fee', unique_together=set([]), ), migrations.RemoveField( model_name='fee', name='plan', ), migrations.RunPython(fix_fee_product_index), migrations.DeleteModel( name='Fee', ), ]
# -*- coding: utf-8 -*- # Generated by Django 1.11.22 on 2019-10-31 16:33 from __future__ import unicode_literals from django.db import migrations, OperationalError, ProgrammingError def fix_fee_product_index(apps, schema_editor): try: schema_editor.execute( 'DROP INDEX IF EXISTS idx_16977_product_id;' ) except (ProgrammingError, OperationalError): pass try: schema_editor.execute( 'ALTER TABLE IF EXISTS cfpb.ratechecker_fee ' 'DROP CONSTRAINT IF EXISTS idx_16977_product_id;' ) except (ProgrammingError, OperationalError): pass try: schema_editor.execute( 'ALTER TABLE IF EXISTS cfpb.ratechecker_fee ' 'ADD CONSTRAINT idx_16977_product_id ' 'UNIQUE (product_id, state_id, lender, single_family, condo, coop);' ) except (ProgrammingError, OperationalError): pass class Migration(migrations.Migration): dependencies = [ ('ratechecker', '0001_initial'), ] operations = [ migrations.RunPython(fix_fee_product_index), migrations.AlterUniqueTogether( name='fee', unique_together=set([]), ), migrations.RemoveField( model_name='fee', name='plan', ), migrations.DeleteModel( name='Fee', ), ]
Fix order of migration in operations
Fix order of migration in operations
Python
cc0-1.0
cfpb/owning-a-home-api
# -*- coding: utf-8 -*- # Generated by Django 1.11.22 on 2019-10-31 16:33 from __future__ import unicode_literals from django.db import migrations, OperationalError, ProgrammingError def fix_fee_product_index(apps, schema_editor): try: schema_editor.execute( 'DROP INDEX IF EXISTS idx_16977_product_id;' ) except (ProgrammingError, OperationalError): pass try: schema_editor.execute( 'ALTER TABLE IF EXISTS cfpb.ratechecker_fee ' 'DROP CONSTRAINT IF EXISTS idx_16977_product_id;' ) except (ProgrammingError, OperationalError): pass try: schema_editor.execute( 'ALTER TABLE IF EXISTS cfpb.ratechecker_fee ' 'ADD CONSTRAINT idx_16977_product_id ' 'UNIQUE (product_id, state_id, lender, single_family, condo, coop);' ) except (ProgrammingError, OperationalError): pass class Migration(migrations.Migration): dependencies = [ ('ratechecker', '0001_initial'), ] operations = [ migrations.AlterUniqueTogether( name='fee', unique_together=set([]), ), migrations.RemoveField( model_name='fee', name='plan', ), migrations.RunPython(fix_fee_product_index), migrations.DeleteModel( name='Fee', ), ] Fix order of migration in operations
# -*- coding: utf-8 -*- # Generated by Django 1.11.22 on 2019-10-31 16:33 from __future__ import unicode_literals from django.db import migrations, OperationalError, ProgrammingError def fix_fee_product_index(apps, schema_editor): try: schema_editor.execute( 'DROP INDEX IF EXISTS idx_16977_product_id;' ) except (ProgrammingError, OperationalError): pass try: schema_editor.execute( 'ALTER TABLE IF EXISTS cfpb.ratechecker_fee ' 'DROP CONSTRAINT IF EXISTS idx_16977_product_id;' ) except (ProgrammingError, OperationalError): pass try: schema_editor.execute( 'ALTER TABLE IF EXISTS cfpb.ratechecker_fee ' 'ADD CONSTRAINT idx_16977_product_id ' 'UNIQUE (product_id, state_id, lender, single_family, condo, coop);' ) except (ProgrammingError, OperationalError): pass class Migration(migrations.Migration): dependencies = [ ('ratechecker', '0001_initial'), ] operations = [ migrations.RunPython(fix_fee_product_index), migrations.AlterUniqueTogether( name='fee', unique_together=set([]), ), migrations.RemoveField( model_name='fee', name='plan', ), migrations.DeleteModel( name='Fee', ), ]
<commit_before># -*- coding: utf-8 -*- # Generated by Django 1.11.22 on 2019-10-31 16:33 from __future__ import unicode_literals from django.db import migrations, OperationalError, ProgrammingError def fix_fee_product_index(apps, schema_editor): try: schema_editor.execute( 'DROP INDEX IF EXISTS idx_16977_product_id;' ) except (ProgrammingError, OperationalError): pass try: schema_editor.execute( 'ALTER TABLE IF EXISTS cfpb.ratechecker_fee ' 'DROP CONSTRAINT IF EXISTS idx_16977_product_id;' ) except (ProgrammingError, OperationalError): pass try: schema_editor.execute( 'ALTER TABLE IF EXISTS cfpb.ratechecker_fee ' 'ADD CONSTRAINT idx_16977_product_id ' 'UNIQUE (product_id, state_id, lender, single_family, condo, coop);' ) except (ProgrammingError, OperationalError): pass class Migration(migrations.Migration): dependencies = [ ('ratechecker', '0001_initial'), ] operations = [ migrations.AlterUniqueTogether( name='fee', unique_together=set([]), ), migrations.RemoveField( model_name='fee', name='plan', ), migrations.RunPython(fix_fee_product_index), migrations.DeleteModel( name='Fee', ), ] <commit_msg>Fix order of migration in operations<commit_after>
# -*- coding: utf-8 -*- # Generated by Django 1.11.22 on 2019-10-31 16:33 from __future__ import unicode_literals from django.db import migrations, OperationalError, ProgrammingError def fix_fee_product_index(apps, schema_editor): try: schema_editor.execute( 'DROP INDEX IF EXISTS idx_16977_product_id;' ) except (ProgrammingError, OperationalError): pass try: schema_editor.execute( 'ALTER TABLE IF EXISTS cfpb.ratechecker_fee ' 'DROP CONSTRAINT IF EXISTS idx_16977_product_id;' ) except (ProgrammingError, OperationalError): pass try: schema_editor.execute( 'ALTER TABLE IF EXISTS cfpb.ratechecker_fee ' 'ADD CONSTRAINT idx_16977_product_id ' 'UNIQUE (product_id, state_id, lender, single_family, condo, coop);' ) except (ProgrammingError, OperationalError): pass class Migration(migrations.Migration): dependencies = [ ('ratechecker', '0001_initial'), ] operations = [ migrations.RunPython(fix_fee_product_index), migrations.AlterUniqueTogether( name='fee', unique_together=set([]), ), migrations.RemoveField( model_name='fee', name='plan', ), migrations.DeleteModel( name='Fee', ), ]
# -*- coding: utf-8 -*- # Generated by Django 1.11.22 on 2019-10-31 16:33 from __future__ import unicode_literals from django.db import migrations, OperationalError, ProgrammingError def fix_fee_product_index(apps, schema_editor): try: schema_editor.execute( 'DROP INDEX IF EXISTS idx_16977_product_id;' ) except (ProgrammingError, OperationalError): pass try: schema_editor.execute( 'ALTER TABLE IF EXISTS cfpb.ratechecker_fee ' 'DROP CONSTRAINT IF EXISTS idx_16977_product_id;' ) except (ProgrammingError, OperationalError): pass try: schema_editor.execute( 'ALTER TABLE IF EXISTS cfpb.ratechecker_fee ' 'ADD CONSTRAINT idx_16977_product_id ' 'UNIQUE (product_id, state_id, lender, single_family, condo, coop);' ) except (ProgrammingError, OperationalError): pass class Migration(migrations.Migration): dependencies = [ ('ratechecker', '0001_initial'), ] operations = [ migrations.AlterUniqueTogether( name='fee', unique_together=set([]), ), migrations.RemoveField( model_name='fee', name='plan', ), migrations.RunPython(fix_fee_product_index), migrations.DeleteModel( name='Fee', ), ] Fix order of migration in operations# -*- coding: utf-8 -*- # Generated by Django 1.11.22 on 2019-10-31 16:33 from __future__ import unicode_literals from django.db import migrations, OperationalError, ProgrammingError def fix_fee_product_index(apps, schema_editor): try: schema_editor.execute( 'DROP INDEX IF EXISTS idx_16977_product_id;' ) except (ProgrammingError, OperationalError): pass try: schema_editor.execute( 'ALTER TABLE IF EXISTS cfpb.ratechecker_fee ' 'DROP CONSTRAINT IF EXISTS idx_16977_product_id;' ) except (ProgrammingError, OperationalError): pass try: schema_editor.execute( 'ALTER TABLE IF EXISTS cfpb.ratechecker_fee ' 'ADD CONSTRAINT idx_16977_product_id ' 'UNIQUE (product_id, state_id, lender, single_family, condo, coop);' ) except (ProgrammingError, OperationalError): pass class Migration(migrations.Migration): dependencies = [ ('ratechecker', '0001_initial'), ] operations = [ migrations.RunPython(fix_fee_product_index), migrations.AlterUniqueTogether( name='fee', unique_together=set([]), ), migrations.RemoveField( model_name='fee', name='plan', ), migrations.DeleteModel( name='Fee', ), ]
<commit_before># -*- coding: utf-8 -*- # Generated by Django 1.11.22 on 2019-10-31 16:33 from __future__ import unicode_literals from django.db import migrations, OperationalError, ProgrammingError def fix_fee_product_index(apps, schema_editor): try: schema_editor.execute( 'DROP INDEX IF EXISTS idx_16977_product_id;' ) except (ProgrammingError, OperationalError): pass try: schema_editor.execute( 'ALTER TABLE IF EXISTS cfpb.ratechecker_fee ' 'DROP CONSTRAINT IF EXISTS idx_16977_product_id;' ) except (ProgrammingError, OperationalError): pass try: schema_editor.execute( 'ALTER TABLE IF EXISTS cfpb.ratechecker_fee ' 'ADD CONSTRAINT idx_16977_product_id ' 'UNIQUE (product_id, state_id, lender, single_family, condo, coop);' ) except (ProgrammingError, OperationalError): pass class Migration(migrations.Migration): dependencies = [ ('ratechecker', '0001_initial'), ] operations = [ migrations.AlterUniqueTogether( name='fee', unique_together=set([]), ), migrations.RemoveField( model_name='fee', name='plan', ), migrations.RunPython(fix_fee_product_index), migrations.DeleteModel( name='Fee', ), ] <commit_msg>Fix order of migration in operations<commit_after># -*- coding: utf-8 -*- # Generated by Django 1.11.22 on 2019-10-31 16:33 from __future__ import unicode_literals from django.db import migrations, OperationalError, ProgrammingError def fix_fee_product_index(apps, schema_editor): try: schema_editor.execute( 'DROP INDEX IF EXISTS idx_16977_product_id;' ) except (ProgrammingError, OperationalError): pass try: schema_editor.execute( 'ALTER TABLE IF EXISTS cfpb.ratechecker_fee ' 'DROP CONSTRAINT IF EXISTS idx_16977_product_id;' ) except (ProgrammingError, OperationalError): pass try: schema_editor.execute( 'ALTER TABLE IF EXISTS cfpb.ratechecker_fee ' 'ADD CONSTRAINT idx_16977_product_id ' 'UNIQUE (product_id, state_id, lender, single_family, condo, coop);' ) except (ProgrammingError, OperationalError): pass class Migration(migrations.Migration): dependencies = [ ('ratechecker', '0001_initial'), ] operations = [ migrations.RunPython(fix_fee_product_index), migrations.AlterUniqueTogether( name='fee', unique_together=set([]), ), migrations.RemoveField( model_name='fee', name='plan', ), migrations.DeleteModel( name='Fee', ), ]
9ed7649d98bc4b1d3412047d0d5c50c1a5c8116c
tests/system/conftest.py
tests/system/conftest.py
# This file contains pytest fixtures as well as some config API_BASE = "http://localhost:5555/n/" TEST_MAX_DURATION_SECS = 240 TEST_GRANULARITY_CHECK_SECS = 0.1 # we don't want to commit passwords to the repo. # load them from an external json file. try: from accounts import credentials passwords = [] for account in credentials: passwords.append((account['user'], account['password'])) except IOError as e: print ("Error: test accounts file not found." "You need to create accounts.py\n" "File format: credentials = [{'user': 'bill@example.com', " "'password': 'VerySecret'}]") raise
# This file contains pytest fixtures as well as some config API_BASE = "http://localhost:5555/n/" TEST_MAX_DURATION_SECS = 240 TEST_GRANULARITY_CHECK_SECS = 0.1 # we don't want to commit passwords to the repo. # load them from an external json file. try: from accounts import credentials passwords = [] for account in credentials: passwords.append((account['user'], account['password'])) except ImportError: print ("Error: test accounts file not found. " "You need to create accounts.py\n" "File format: credentials = [{'user': 'bill@example.com', " "'password': 'VerySecret'}]") raise
Fix check for accounts.py file in system tests.
Fix check for accounts.py file in system tests.
Python
agpl-3.0
Eagles2F/sync-engine,ErinCall/sync-engine,closeio/nylas,gale320/sync-engine,nylas/sync-engine,EthanBlackburn/sync-engine,wakermahmud/sync-engine,Eagles2F/sync-engine,jobscore/sync-engine,wakermahmud/sync-engine,gale320/sync-engine,ErinCall/sync-engine,gale320/sync-engine,PriviPK/privipk-sync-engine,nylas/sync-engine,nylas/sync-engine,PriviPK/privipk-sync-engine,ErinCall/sync-engine,Eagles2F/sync-engine,jobscore/sync-engine,EthanBlackburn/sync-engine,Eagles2F/sync-engine,closeio/nylas,PriviPK/privipk-sync-engine,jobscore/sync-engine,PriviPK/privipk-sync-engine,gale320/sync-engine,wakermahmud/sync-engine,ErinCall/sync-engine,wakermahmud/sync-engine,ErinCall/sync-engine,EthanBlackburn/sync-engine,jobscore/sync-engine,EthanBlackburn/sync-engine,closeio/nylas,PriviPK/privipk-sync-engine,closeio/nylas,nylas/sync-engine,gale320/sync-engine,Eagles2F/sync-engine,EthanBlackburn/sync-engine,wakermahmud/sync-engine
# This file contains pytest fixtures as well as some config API_BASE = "http://localhost:5555/n/" TEST_MAX_DURATION_SECS = 240 TEST_GRANULARITY_CHECK_SECS = 0.1 # we don't want to commit passwords to the repo. # load them from an external json file. try: from accounts import credentials passwords = [] for account in credentials: passwords.append((account['user'], account['password'])) except IOError as e: print ("Error: test accounts file not found." "You need to create accounts.py\n" "File format: credentials = [{'user': 'bill@example.com', " "'password': 'VerySecret'}]") raise Fix check for accounts.py file in system tests.
# This file contains pytest fixtures as well as some config API_BASE = "http://localhost:5555/n/" TEST_MAX_DURATION_SECS = 240 TEST_GRANULARITY_CHECK_SECS = 0.1 # we don't want to commit passwords to the repo. # load them from an external json file. try: from accounts import credentials passwords = [] for account in credentials: passwords.append((account['user'], account['password'])) except ImportError: print ("Error: test accounts file not found. " "You need to create accounts.py\n" "File format: credentials = [{'user': 'bill@example.com', " "'password': 'VerySecret'}]") raise
<commit_before># This file contains pytest fixtures as well as some config API_BASE = "http://localhost:5555/n/" TEST_MAX_DURATION_SECS = 240 TEST_GRANULARITY_CHECK_SECS = 0.1 # we don't want to commit passwords to the repo. # load them from an external json file. try: from accounts import credentials passwords = [] for account in credentials: passwords.append((account['user'], account['password'])) except IOError as e: print ("Error: test accounts file not found." "You need to create accounts.py\n" "File format: credentials = [{'user': 'bill@example.com', " "'password': 'VerySecret'}]") raise <commit_msg>Fix check for accounts.py file in system tests.<commit_after>
# This file contains pytest fixtures as well as some config API_BASE = "http://localhost:5555/n/" TEST_MAX_DURATION_SECS = 240 TEST_GRANULARITY_CHECK_SECS = 0.1 # we don't want to commit passwords to the repo. # load them from an external json file. try: from accounts import credentials passwords = [] for account in credentials: passwords.append((account['user'], account['password'])) except ImportError: print ("Error: test accounts file not found. " "You need to create accounts.py\n" "File format: credentials = [{'user': 'bill@example.com', " "'password': 'VerySecret'}]") raise
# This file contains pytest fixtures as well as some config API_BASE = "http://localhost:5555/n/" TEST_MAX_DURATION_SECS = 240 TEST_GRANULARITY_CHECK_SECS = 0.1 # we don't want to commit passwords to the repo. # load them from an external json file. try: from accounts import credentials passwords = [] for account in credentials: passwords.append((account['user'], account['password'])) except IOError as e: print ("Error: test accounts file not found." "You need to create accounts.py\n" "File format: credentials = [{'user': 'bill@example.com', " "'password': 'VerySecret'}]") raise Fix check for accounts.py file in system tests.# This file contains pytest fixtures as well as some config API_BASE = "http://localhost:5555/n/" TEST_MAX_DURATION_SECS = 240 TEST_GRANULARITY_CHECK_SECS = 0.1 # we don't want to commit passwords to the repo. # load them from an external json file. try: from accounts import credentials passwords = [] for account in credentials: passwords.append((account['user'], account['password'])) except ImportError: print ("Error: test accounts file not found. " "You need to create accounts.py\n" "File format: credentials = [{'user': 'bill@example.com', " "'password': 'VerySecret'}]") raise
<commit_before># This file contains pytest fixtures as well as some config API_BASE = "http://localhost:5555/n/" TEST_MAX_DURATION_SECS = 240 TEST_GRANULARITY_CHECK_SECS = 0.1 # we don't want to commit passwords to the repo. # load them from an external json file. try: from accounts import credentials passwords = [] for account in credentials: passwords.append((account['user'], account['password'])) except IOError as e: print ("Error: test accounts file not found." "You need to create accounts.py\n" "File format: credentials = [{'user': 'bill@example.com', " "'password': 'VerySecret'}]") raise <commit_msg>Fix check for accounts.py file in system tests.<commit_after># This file contains pytest fixtures as well as some config API_BASE = "http://localhost:5555/n/" TEST_MAX_DURATION_SECS = 240 TEST_GRANULARITY_CHECK_SECS = 0.1 # we don't want to commit passwords to the repo. # load them from an external json file. try: from accounts import credentials passwords = [] for account in credentials: passwords.append((account['user'], account['password'])) except ImportError: print ("Error: test accounts file not found. " "You need to create accounts.py\n" "File format: credentials = [{'user': 'bill@example.com', " "'password': 'VerySecret'}]") raise
0912f6910ac436f8f09848b4485e39e5c308f70e
indra/tools/live_curation/dump_index.py
indra/tools/live_curation/dump_index.py
"""This is a script to dump all the corpora on S3 into an index file.""" import boto3 res = s3.list_objects(Bucket='world-modelers', Prefix='indra_models') s3 = boto3.session.Session(profile_name='wm').client('s3') corpora = [] for entry in res['Content']: if entry['Key'].endswith('/statements.json'): corpus_id = entry['Key'].split('/')[1] mod = entry['LastModified'] corpora.append((corpus_id, mod.strftime('%Y-%m-%d-%H-%M-%S'))) with open('index.csv', 'w') as fh: for corpus_id, mod in sorted(corpora, key=lambda x: x[1]): fh.write('%s,%s\n' % (corpus_id, mod))
"""This is a script to dump all the corpora on S3 into an index file.""" import boto3 if __name__ == '__main__': s3 = boto3.session.Session(profile_name='wm').client('s3') res = s3.list_objects(Bucket='world-modelers', Prefix='indra_models') corpora = [] for entry in res['Content']: if entry['Key'].endswith('/statements.json'): corpus_id = entry['Key'].split('/')[1] mod = entry['LastModified'] corpora.append((corpus_id, mod.strftime('%Y-%m-%d-%H-%M-%S'))) with open('index.csv', 'w') as fh: for corpus_id, mod in sorted(corpora, key=lambda x: x[1]): fh.write('%s,%s\n' % (corpus_id, mod))
Fix the index dumper code
Fix the index dumper code
Python
bsd-2-clause
sorgerlab/indra,bgyori/indra,bgyori/indra,johnbachman/belpy,johnbachman/indra,sorgerlab/belpy,sorgerlab/belpy,johnbachman/belpy,sorgerlab/indra,johnbachman/indra,sorgerlab/belpy,johnbachman/indra,sorgerlab/indra,johnbachman/belpy,bgyori/indra
"""This is a script to dump all the corpora on S3 into an index file.""" import boto3 res = s3.list_objects(Bucket='world-modelers', Prefix='indra_models') s3 = boto3.session.Session(profile_name='wm').client('s3') corpora = [] for entry in res['Content']: if entry['Key'].endswith('/statements.json'): corpus_id = entry['Key'].split('/')[1] mod = entry['LastModified'] corpora.append((corpus_id, mod.strftime('%Y-%m-%d-%H-%M-%S'))) with open('index.csv', 'w') as fh: for corpus_id, mod in sorted(corpora, key=lambda x: x[1]): fh.write('%s,%s\n' % (corpus_id, mod)) Fix the index dumper code
"""This is a script to dump all the corpora on S3 into an index file.""" import boto3 if __name__ == '__main__': s3 = boto3.session.Session(profile_name='wm').client('s3') res = s3.list_objects(Bucket='world-modelers', Prefix='indra_models') corpora = [] for entry in res['Content']: if entry['Key'].endswith('/statements.json'): corpus_id = entry['Key'].split('/')[1] mod = entry['LastModified'] corpora.append((corpus_id, mod.strftime('%Y-%m-%d-%H-%M-%S'))) with open('index.csv', 'w') as fh: for corpus_id, mod in sorted(corpora, key=lambda x: x[1]): fh.write('%s,%s\n' % (corpus_id, mod))
<commit_before>"""This is a script to dump all the corpora on S3 into an index file.""" import boto3 res = s3.list_objects(Bucket='world-modelers', Prefix='indra_models') s3 = boto3.session.Session(profile_name='wm').client('s3') corpora = [] for entry in res['Content']: if entry['Key'].endswith('/statements.json'): corpus_id = entry['Key'].split('/')[1] mod = entry['LastModified'] corpora.append((corpus_id, mod.strftime('%Y-%m-%d-%H-%M-%S'))) with open('index.csv', 'w') as fh: for corpus_id, mod in sorted(corpora, key=lambda x: x[1]): fh.write('%s,%s\n' % (corpus_id, mod)) <commit_msg>Fix the index dumper code<commit_after>
"""This is a script to dump all the corpora on S3 into an index file.""" import boto3 if __name__ == '__main__': s3 = boto3.session.Session(profile_name='wm').client('s3') res = s3.list_objects(Bucket='world-modelers', Prefix='indra_models') corpora = [] for entry in res['Content']: if entry['Key'].endswith('/statements.json'): corpus_id = entry['Key'].split('/')[1] mod = entry['LastModified'] corpora.append((corpus_id, mod.strftime('%Y-%m-%d-%H-%M-%S'))) with open('index.csv', 'w') as fh: for corpus_id, mod in sorted(corpora, key=lambda x: x[1]): fh.write('%s,%s\n' % (corpus_id, mod))
"""This is a script to dump all the corpora on S3 into an index file.""" import boto3 res = s3.list_objects(Bucket='world-modelers', Prefix='indra_models') s3 = boto3.session.Session(profile_name='wm').client('s3') corpora = [] for entry in res['Content']: if entry['Key'].endswith('/statements.json'): corpus_id = entry['Key'].split('/')[1] mod = entry['LastModified'] corpora.append((corpus_id, mod.strftime('%Y-%m-%d-%H-%M-%S'))) with open('index.csv', 'w') as fh: for corpus_id, mod in sorted(corpora, key=lambda x: x[1]): fh.write('%s,%s\n' % (corpus_id, mod)) Fix the index dumper code"""This is a script to dump all the corpora on S3 into an index file.""" import boto3 if __name__ == '__main__': s3 = boto3.session.Session(profile_name='wm').client('s3') res = s3.list_objects(Bucket='world-modelers', Prefix='indra_models') corpora = [] for entry in res['Content']: if entry['Key'].endswith('/statements.json'): corpus_id = entry['Key'].split('/')[1] mod = entry['LastModified'] corpora.append((corpus_id, mod.strftime('%Y-%m-%d-%H-%M-%S'))) with open('index.csv', 'w') as fh: for corpus_id, mod in sorted(corpora, key=lambda x: x[1]): fh.write('%s,%s\n' % (corpus_id, mod))
<commit_before>"""This is a script to dump all the corpora on S3 into an index file.""" import boto3 res = s3.list_objects(Bucket='world-modelers', Prefix='indra_models') s3 = boto3.session.Session(profile_name='wm').client('s3') corpora = [] for entry in res['Content']: if entry['Key'].endswith('/statements.json'): corpus_id = entry['Key'].split('/')[1] mod = entry['LastModified'] corpora.append((corpus_id, mod.strftime('%Y-%m-%d-%H-%M-%S'))) with open('index.csv', 'w') as fh: for corpus_id, mod in sorted(corpora, key=lambda x: x[1]): fh.write('%s,%s\n' % (corpus_id, mod)) <commit_msg>Fix the index dumper code<commit_after>"""This is a script to dump all the corpora on S3 into an index file.""" import boto3 if __name__ == '__main__': s3 = boto3.session.Session(profile_name='wm').client('s3') res = s3.list_objects(Bucket='world-modelers', Prefix='indra_models') corpora = [] for entry in res['Content']: if entry['Key'].endswith('/statements.json'): corpus_id = entry['Key'].split('/')[1] mod = entry['LastModified'] corpora.append((corpus_id, mod.strftime('%Y-%m-%d-%H-%M-%S'))) with open('index.csv', 'w') as fh: for corpus_id, mod in sorted(corpora, key=lambda x: x[1]): fh.write('%s,%s\n' % (corpus_id, mod))
81c401daf5d418a917d6bda4b5cbf0eb3870ce15
vip_hci/__init__.py
vip_hci/__init__.py
__version__ = "1.1.3" from . import preproc from . import config from . import fits from . import invprob from . import psfsub from . import fm from . import metrics from . import stats from . import var from .hci_dataset import * from .hci_postproc import * from .vip_ds9 import *
__version__ = "1.2.0" from . import preproc from . import config from . import fits from . import invprob from . import psfsub from . import fm from . import metrics from . import stats from . import var from .hci_dataset import * from .hci_postproc import * from .vip_ds9 import *
Update to version 1.2.0 - version needed for exoplanet data challenge
Update to version 1.2.0 - version needed for exoplanet data challenge
Python
mit
henry-ngo/VIP,vortex-exoplanet/VIP
__version__ = "1.1.3" from . import preproc from . import config from . import fits from . import invprob from . import psfsub from . import fm from . import metrics from . import stats from . import var from .hci_dataset import * from .hci_postproc import * from .vip_ds9 import *Update to version 1.2.0 - version needed for exoplanet data challenge
__version__ = "1.2.0" from . import preproc from . import config from . import fits from . import invprob from . import psfsub from . import fm from . import metrics from . import stats from . import var from .hci_dataset import * from .hci_postproc import * from .vip_ds9 import *
<commit_before>__version__ = "1.1.3" from . import preproc from . import config from . import fits from . import invprob from . import psfsub from . import fm from . import metrics from . import stats from . import var from .hci_dataset import * from .hci_postproc import * from .vip_ds9 import *<commit_msg>Update to version 1.2.0 - version needed for exoplanet data challenge<commit_after>
__version__ = "1.2.0" from . import preproc from . import config from . import fits from . import invprob from . import psfsub from . import fm from . import metrics from . import stats from . import var from .hci_dataset import * from .hci_postproc import * from .vip_ds9 import *
__version__ = "1.1.3" from . import preproc from . import config from . import fits from . import invprob from . import psfsub from . import fm from . import metrics from . import stats from . import var from .hci_dataset import * from .hci_postproc import * from .vip_ds9 import *Update to version 1.2.0 - version needed for exoplanet data challenge__version__ = "1.2.0" from . import preproc from . import config from . import fits from . import invprob from . import psfsub from . import fm from . import metrics from . import stats from . import var from .hci_dataset import * from .hci_postproc import * from .vip_ds9 import *
<commit_before>__version__ = "1.1.3" from . import preproc from . import config from . import fits from . import invprob from . import psfsub from . import fm from . import metrics from . import stats from . import var from .hci_dataset import * from .hci_postproc import * from .vip_ds9 import *<commit_msg>Update to version 1.2.0 - version needed for exoplanet data challenge<commit_after>__version__ = "1.2.0" from . import preproc from . import config from . import fits from . import invprob from . import psfsub from . import fm from . import metrics from . import stats from . import var from .hci_dataset import * from .hci_postproc import * from .vip_ds9 import *
7d0691eae614da96f8fe14a5f5338659ef9638df
ml/pytorch/image_classification/architectures.py
ml/pytorch/image_classification/architectures.py
import torch from torch.autograd import Variable import torch.nn as nn import torch.nn.functional as F ################################################################################ # SUPPORT ################################################################################ class Flatten(nn.Module): """ Module to Flatten a layer """ def forward(self, input): return input.view(input.size(0), -1) def flatten(x): return x.view(x.size(0), -1)
import torch from torch.autograd import Variable import torch.nn as nn import torch.nn.functional as F ################################################################################ # SUPPORT ################################################################################ class Flatten(nn.Module): """ Module to Flatten a layer """ def forward(self, input): return input.view(input.size(0), -1) def flatten(x): return x.view(x.size(0), -1) ################################################################################ # LAYERS ################################################################################ def conv(fin, out, k=3, s=1, d=1, bn=True, bias=False, dropout=None, activation=nn.ReLU): """ Convolutional module By default uses same padding CONV > BatchNorm > Activation > Dropout """ # naive calculation of padding p = (k-1)//2 # Conv sq = nn.Sequential() sq.add_module("conv", nn.Conv2d(fin, out, k, stride=s, padding=p, dilation=d, bias=bias)) # Optional components if bn: sq.add_module("bn", nn.BatchNorm2d(out)) if activation is not None: sq.add_module("activation", activation()) if dropout is not None: sq.add_module("dropout", nn.Dropout2d(p=dropout)) return sq
Add custom conv layer module
FEAT: Add custom conv layer module
Python
apache-2.0
ronrest/convenience_py,ronrest/convenience_py
import torch from torch.autograd import Variable import torch.nn as nn import torch.nn.functional as F ################################################################################ # SUPPORT ################################################################################ class Flatten(nn.Module): """ Module to Flatten a layer """ def forward(self, input): return input.view(input.size(0), -1) def flatten(x): return x.view(x.size(0), -1) FEAT: Add custom conv layer module
import torch from torch.autograd import Variable import torch.nn as nn import torch.nn.functional as F ################################################################################ # SUPPORT ################################################################################ class Flatten(nn.Module): """ Module to Flatten a layer """ def forward(self, input): return input.view(input.size(0), -1) def flatten(x): return x.view(x.size(0), -1) ################################################################################ # LAYERS ################################################################################ def conv(fin, out, k=3, s=1, d=1, bn=True, bias=False, dropout=None, activation=nn.ReLU): """ Convolutional module By default uses same padding CONV > BatchNorm > Activation > Dropout """ # naive calculation of padding p = (k-1)//2 # Conv sq = nn.Sequential() sq.add_module("conv", nn.Conv2d(fin, out, k, stride=s, padding=p, dilation=d, bias=bias)) # Optional components if bn: sq.add_module("bn", nn.BatchNorm2d(out)) if activation is not None: sq.add_module("activation", activation()) if dropout is not None: sq.add_module("dropout", nn.Dropout2d(p=dropout)) return sq
<commit_before>import torch from torch.autograd import Variable import torch.nn as nn import torch.nn.functional as F ################################################################################ # SUPPORT ################################################################################ class Flatten(nn.Module): """ Module to Flatten a layer """ def forward(self, input): return input.view(input.size(0), -1) def flatten(x): return x.view(x.size(0), -1) <commit_msg>FEAT: Add custom conv layer module<commit_after>
import torch from torch.autograd import Variable import torch.nn as nn import torch.nn.functional as F ################################################################################ # SUPPORT ################################################################################ class Flatten(nn.Module): """ Module to Flatten a layer """ def forward(self, input): return input.view(input.size(0), -1) def flatten(x): return x.view(x.size(0), -1) ################################################################################ # LAYERS ################################################################################ def conv(fin, out, k=3, s=1, d=1, bn=True, bias=False, dropout=None, activation=nn.ReLU): """ Convolutional module By default uses same padding CONV > BatchNorm > Activation > Dropout """ # naive calculation of padding p = (k-1)//2 # Conv sq = nn.Sequential() sq.add_module("conv", nn.Conv2d(fin, out, k, stride=s, padding=p, dilation=d, bias=bias)) # Optional components if bn: sq.add_module("bn", nn.BatchNorm2d(out)) if activation is not None: sq.add_module("activation", activation()) if dropout is not None: sq.add_module("dropout", nn.Dropout2d(p=dropout)) return sq
import torch from torch.autograd import Variable import torch.nn as nn import torch.nn.functional as F ################################################################################ # SUPPORT ################################################################################ class Flatten(nn.Module): """ Module to Flatten a layer """ def forward(self, input): return input.view(input.size(0), -1) def flatten(x): return x.view(x.size(0), -1) FEAT: Add custom conv layer moduleimport torch from torch.autograd import Variable import torch.nn as nn import torch.nn.functional as F ################################################################################ # SUPPORT ################################################################################ class Flatten(nn.Module): """ Module to Flatten a layer """ def forward(self, input): return input.view(input.size(0), -1) def flatten(x): return x.view(x.size(0), -1) ################################################################################ # LAYERS ################################################################################ def conv(fin, out, k=3, s=1, d=1, bn=True, bias=False, dropout=None, activation=nn.ReLU): """ Convolutional module By default uses same padding CONV > BatchNorm > Activation > Dropout """ # naive calculation of padding p = (k-1)//2 # Conv sq = nn.Sequential() sq.add_module("conv", nn.Conv2d(fin, out, k, stride=s, padding=p, dilation=d, bias=bias)) # Optional components if bn: sq.add_module("bn", nn.BatchNorm2d(out)) if activation is not None: sq.add_module("activation", activation()) if dropout is not None: sq.add_module("dropout", nn.Dropout2d(p=dropout)) return sq
<commit_before>import torch from torch.autograd import Variable import torch.nn as nn import torch.nn.functional as F ################################################################################ # SUPPORT ################################################################################ class Flatten(nn.Module): """ Module to Flatten a layer """ def forward(self, input): return input.view(input.size(0), -1) def flatten(x): return x.view(x.size(0), -1) <commit_msg>FEAT: Add custom conv layer module<commit_after>import torch from torch.autograd import Variable import torch.nn as nn import torch.nn.functional as F ################################################################################ # SUPPORT ################################################################################ class Flatten(nn.Module): """ Module to Flatten a layer """ def forward(self, input): return input.view(input.size(0), -1) def flatten(x): return x.view(x.size(0), -1) ################################################################################ # LAYERS ################################################################################ def conv(fin, out, k=3, s=1, d=1, bn=True, bias=False, dropout=None, activation=nn.ReLU): """ Convolutional module By default uses same padding CONV > BatchNorm > Activation > Dropout """ # naive calculation of padding p = (k-1)//2 # Conv sq = nn.Sequential() sq.add_module("conv", nn.Conv2d(fin, out, k, stride=s, padding=p, dilation=d, bias=bias)) # Optional components if bn: sq.add_module("bn", nn.BatchNorm2d(out)) if activation is not None: sq.add_module("activation", activation()) if dropout is not None: sq.add_module("dropout", nn.Dropout2d(p=dropout)) return sq
93870152b4afb04f1547378184e2cee0bd0dd45f
kobo/apps/languages/serializers/base.py
kobo/apps/languages/serializers/base.py
# coding: utf-8 from collections import defaultdict, OrderedDict from django.db import models from rest_framework import serializers class BaseServiceSerializer(serializers.ModelSerializer): class Meta: fields = [ 'name', 'code', ] class BaseServiceLanguageM2MSerializer(serializers.ModelSerializer): region = serializers.SerializerMethodField() service = serializers.SerializerMethodField() language = serializers.SerializerMethodField() class Meta: fields = '__all__' def get_list_serializer_class(self): pass def get_region(self, through_instance): if through_instance.region: return through_instance.region.code return None def get_service(self, through_instance): return through_instance.service.code def get_language(self, through_instance): return through_instance.language.code class BaseServiceLanguageM2MListSerializer(serializers.ListSerializer): def to_representation(self, data): """ Override `ListSerializer` behaviour to display services as a dictionary instead of a list """ iterable = data.all() if isinstance(data, models.Manager) else data formatted_data = self._get_formatted_data(iterable) representation = [] for service_code, service in formatted_data.items(): representation.append({service_code: service}) return representation
# coding: utf-8 from collections import defaultdict, OrderedDict from django.db import models from rest_framework import serializers class BaseServiceSerializer(serializers.ModelSerializer): class Meta: fields = [ 'name', 'code', ] class BaseServiceLanguageM2MSerializer(serializers.ModelSerializer): region = serializers.SerializerMethodField() service = serializers.SerializerMethodField() language = serializers.SerializerMethodField() class Meta: fields = '__all__' def get_list_serializer_class(self): pass def get_region(self, through_instance): if through_instance.region: return through_instance.region.code return None def get_service(self, through_instance): return through_instance.service.code def get_language(self, through_instance): return through_instance.language.code class BaseServiceLanguageM2MListSerializer(serializers.ListSerializer): # Force `ListSerializer` to return a dict, not a list @property def data(self): ret = serializers.BaseSerializer.data.fget(self) return serializers.ReturnDict(ret, serializer=self) def to_representation(self, data): """ Override `ListSerializer` behaviour to display services as a dictionary instead of a list """ iterable = data.all() if isinstance(data, models.Manager) else data formatted_data = self._get_formatted_data(iterable) return formatted_data
Return a dictionary for transcription/translation services (instead of list)
Return a dictionary for transcription/translation services (instead of list)
Python
agpl-3.0
kobotoolbox/kpi,kobotoolbox/kpi,kobotoolbox/kpi,kobotoolbox/kpi,kobotoolbox/kpi
# coding: utf-8 from collections import defaultdict, OrderedDict from django.db import models from rest_framework import serializers class BaseServiceSerializer(serializers.ModelSerializer): class Meta: fields = [ 'name', 'code', ] class BaseServiceLanguageM2MSerializer(serializers.ModelSerializer): region = serializers.SerializerMethodField() service = serializers.SerializerMethodField() language = serializers.SerializerMethodField() class Meta: fields = '__all__' def get_list_serializer_class(self): pass def get_region(self, through_instance): if through_instance.region: return through_instance.region.code return None def get_service(self, through_instance): return through_instance.service.code def get_language(self, through_instance): return through_instance.language.code class BaseServiceLanguageM2MListSerializer(serializers.ListSerializer): def to_representation(self, data): """ Override `ListSerializer` behaviour to display services as a dictionary instead of a list """ iterable = data.all() if isinstance(data, models.Manager) else data formatted_data = self._get_formatted_data(iterable) representation = [] for service_code, service in formatted_data.items(): representation.append({service_code: service}) return representation Return a dictionary for transcription/translation services (instead of list)
# coding: utf-8 from collections import defaultdict, OrderedDict from django.db import models from rest_framework import serializers class BaseServiceSerializer(serializers.ModelSerializer): class Meta: fields = [ 'name', 'code', ] class BaseServiceLanguageM2MSerializer(serializers.ModelSerializer): region = serializers.SerializerMethodField() service = serializers.SerializerMethodField() language = serializers.SerializerMethodField() class Meta: fields = '__all__' def get_list_serializer_class(self): pass def get_region(self, through_instance): if through_instance.region: return through_instance.region.code return None def get_service(self, through_instance): return through_instance.service.code def get_language(self, through_instance): return through_instance.language.code class BaseServiceLanguageM2MListSerializer(serializers.ListSerializer): # Force `ListSerializer` to return a dict, not a list @property def data(self): ret = serializers.BaseSerializer.data.fget(self) return serializers.ReturnDict(ret, serializer=self) def to_representation(self, data): """ Override `ListSerializer` behaviour to display services as a dictionary instead of a list """ iterable = data.all() if isinstance(data, models.Manager) else data formatted_data = self._get_formatted_data(iterable) return formatted_data
<commit_before># coding: utf-8 from collections import defaultdict, OrderedDict from django.db import models from rest_framework import serializers class BaseServiceSerializer(serializers.ModelSerializer): class Meta: fields = [ 'name', 'code', ] class BaseServiceLanguageM2MSerializer(serializers.ModelSerializer): region = serializers.SerializerMethodField() service = serializers.SerializerMethodField() language = serializers.SerializerMethodField() class Meta: fields = '__all__' def get_list_serializer_class(self): pass def get_region(self, through_instance): if through_instance.region: return through_instance.region.code return None def get_service(self, through_instance): return through_instance.service.code def get_language(self, through_instance): return through_instance.language.code class BaseServiceLanguageM2MListSerializer(serializers.ListSerializer): def to_representation(self, data): """ Override `ListSerializer` behaviour to display services as a dictionary instead of a list """ iterable = data.all() if isinstance(data, models.Manager) else data formatted_data = self._get_formatted_data(iterable) representation = [] for service_code, service in formatted_data.items(): representation.append({service_code: service}) return representation <commit_msg>Return a dictionary for transcription/translation services (instead of list)<commit_after>
# coding: utf-8 from collections import defaultdict, OrderedDict from django.db import models from rest_framework import serializers class BaseServiceSerializer(serializers.ModelSerializer): class Meta: fields = [ 'name', 'code', ] class BaseServiceLanguageM2MSerializer(serializers.ModelSerializer): region = serializers.SerializerMethodField() service = serializers.SerializerMethodField() language = serializers.SerializerMethodField() class Meta: fields = '__all__' def get_list_serializer_class(self): pass def get_region(self, through_instance): if through_instance.region: return through_instance.region.code return None def get_service(self, through_instance): return through_instance.service.code def get_language(self, through_instance): return through_instance.language.code class BaseServiceLanguageM2MListSerializer(serializers.ListSerializer): # Force `ListSerializer` to return a dict, not a list @property def data(self): ret = serializers.BaseSerializer.data.fget(self) return serializers.ReturnDict(ret, serializer=self) def to_representation(self, data): """ Override `ListSerializer` behaviour to display services as a dictionary instead of a list """ iterable = data.all() if isinstance(data, models.Manager) else data formatted_data = self._get_formatted_data(iterable) return formatted_data
# coding: utf-8 from collections import defaultdict, OrderedDict from django.db import models from rest_framework import serializers class BaseServiceSerializer(serializers.ModelSerializer): class Meta: fields = [ 'name', 'code', ] class BaseServiceLanguageM2MSerializer(serializers.ModelSerializer): region = serializers.SerializerMethodField() service = serializers.SerializerMethodField() language = serializers.SerializerMethodField() class Meta: fields = '__all__' def get_list_serializer_class(self): pass def get_region(self, through_instance): if through_instance.region: return through_instance.region.code return None def get_service(self, through_instance): return through_instance.service.code def get_language(self, through_instance): return through_instance.language.code class BaseServiceLanguageM2MListSerializer(serializers.ListSerializer): def to_representation(self, data): """ Override `ListSerializer` behaviour to display services as a dictionary instead of a list """ iterable = data.all() if isinstance(data, models.Manager) else data formatted_data = self._get_formatted_data(iterable) representation = [] for service_code, service in formatted_data.items(): representation.append({service_code: service}) return representation Return a dictionary for transcription/translation services (instead of list)# coding: utf-8 from collections import defaultdict, OrderedDict from django.db import models from rest_framework import serializers class BaseServiceSerializer(serializers.ModelSerializer): class Meta: fields = [ 'name', 'code', ] class BaseServiceLanguageM2MSerializer(serializers.ModelSerializer): region = serializers.SerializerMethodField() service = serializers.SerializerMethodField() language = serializers.SerializerMethodField() class Meta: fields = '__all__' def get_list_serializer_class(self): pass def get_region(self, through_instance): if through_instance.region: return through_instance.region.code return None def get_service(self, through_instance): return through_instance.service.code def get_language(self, through_instance): return through_instance.language.code class BaseServiceLanguageM2MListSerializer(serializers.ListSerializer): # Force `ListSerializer` to return a dict, not a list @property def data(self): ret = serializers.BaseSerializer.data.fget(self) return serializers.ReturnDict(ret, serializer=self) def to_representation(self, data): """ Override `ListSerializer` behaviour to display services as a dictionary instead of a list """ iterable = data.all() if isinstance(data, models.Manager) else data formatted_data = self._get_formatted_data(iterable) return formatted_data
<commit_before># coding: utf-8 from collections import defaultdict, OrderedDict from django.db import models from rest_framework import serializers class BaseServiceSerializer(serializers.ModelSerializer): class Meta: fields = [ 'name', 'code', ] class BaseServiceLanguageM2MSerializer(serializers.ModelSerializer): region = serializers.SerializerMethodField() service = serializers.SerializerMethodField() language = serializers.SerializerMethodField() class Meta: fields = '__all__' def get_list_serializer_class(self): pass def get_region(self, through_instance): if through_instance.region: return through_instance.region.code return None def get_service(self, through_instance): return through_instance.service.code def get_language(self, through_instance): return through_instance.language.code class BaseServiceLanguageM2MListSerializer(serializers.ListSerializer): def to_representation(self, data): """ Override `ListSerializer` behaviour to display services as a dictionary instead of a list """ iterable = data.all() if isinstance(data, models.Manager) else data formatted_data = self._get_formatted_data(iterable) representation = [] for service_code, service in formatted_data.items(): representation.append({service_code: service}) return representation <commit_msg>Return a dictionary for transcription/translation services (instead of list)<commit_after># coding: utf-8 from collections import defaultdict, OrderedDict from django.db import models from rest_framework import serializers class BaseServiceSerializer(serializers.ModelSerializer): class Meta: fields = [ 'name', 'code', ] class BaseServiceLanguageM2MSerializer(serializers.ModelSerializer): region = serializers.SerializerMethodField() service = serializers.SerializerMethodField() language = serializers.SerializerMethodField() class Meta: fields = '__all__' def get_list_serializer_class(self): pass def get_region(self, through_instance): if through_instance.region: return through_instance.region.code return None def get_service(self, through_instance): return through_instance.service.code def get_language(self, through_instance): return through_instance.language.code class BaseServiceLanguageM2MListSerializer(serializers.ListSerializer): # Force `ListSerializer` to return a dict, not a list @property def data(self): ret = serializers.BaseSerializer.data.fget(self) return serializers.ReturnDict(ret, serializer=self) def to_representation(self, data): """ Override `ListSerializer` behaviour to display services as a dictionary instead of a list """ iterable = data.all() if isinstance(data, models.Manager) else data formatted_data = self._get_formatted_data(iterable) return formatted_data
bab9d6b28ca37ff5a34bf535d366ef81f10a5f90
pyinfra/modules/virtualenv.py
pyinfra/modules/virtualenv.py
# pyinfra # File: pyinfra/modules/pip.py # Desc: manage virtualenvs ''' Manage Python virtual environments ''' from __future__ import unicode_literals from pyinfra.api import operation from pyinfra.modules import files @operation def virtualenv( state, host, path, python=None, site_packages=False, always_copy=False, present=True, ): ''' Manage virtualenv. + python: python interpreter to use + site_packages: give access to the global site-packages + always_copy: always copy files rather than symlinking + present: whether the virtualenv should be installed ''' if present is False and host.fact.directory(path): # Ensure deletion of unwanted virtualenv # no 'yield from' in python 2.7 yield files.directory(state, host, path, present=False) elif present and not host.fact.directory(path): # Create missing virtualenv command = '/usr/bin/virtualenv' if python: command += ' -p {}'.format(python) if site_packages: command += ' --system-site-packages' if always_copy: command += ' --always-copy' command += ' ' + path yield command
# pyinfra # File: pyinfra/modules/pip.py # Desc: manage virtualenvs ''' Manage Python virtual environments ''' from __future__ import unicode_literals from pyinfra.api import operation from pyinfra.modules import files @operation def virtualenv( state, host, path, python=None, site_packages=False, always_copy=False, present=True, ): ''' Manage virtualenv. + python: python interpreter to use + site_packages: give access to the global site-packages + always_copy: always copy files rather than symlinking + present: whether the virtualenv should be installed ''' if present is False and host.fact.directory(path): # Ensure deletion of unwanted virtualenv # no 'yield from' in python 2.7 yield files.directory(state, host, path, present=False) elif present and not host.fact.directory(path): # Create missing virtualenv command = ['/usr/bin/virtualenv'] if python: command.append('-p {}'.format(python)) if site_packages: command.append('--system-site-packages') if always_copy: command.append('--always-copy') command.append(path) yield ' '.join(command)
Refactor building command using join()
Refactor building command using join()
Python
mit
Fizzadar/pyinfra,Fizzadar/pyinfra
# pyinfra # File: pyinfra/modules/pip.py # Desc: manage virtualenvs ''' Manage Python virtual environments ''' from __future__ import unicode_literals from pyinfra.api import operation from pyinfra.modules import files @operation def virtualenv( state, host, path, python=None, site_packages=False, always_copy=False, present=True, ): ''' Manage virtualenv. + python: python interpreter to use + site_packages: give access to the global site-packages + always_copy: always copy files rather than symlinking + present: whether the virtualenv should be installed ''' if present is False and host.fact.directory(path): # Ensure deletion of unwanted virtualenv # no 'yield from' in python 2.7 yield files.directory(state, host, path, present=False) elif present and not host.fact.directory(path): # Create missing virtualenv command = '/usr/bin/virtualenv' if python: command += ' -p {}'.format(python) if site_packages: command += ' --system-site-packages' if always_copy: command += ' --always-copy' command += ' ' + path yield command Refactor building command using join()
# pyinfra # File: pyinfra/modules/pip.py # Desc: manage virtualenvs ''' Manage Python virtual environments ''' from __future__ import unicode_literals from pyinfra.api import operation from pyinfra.modules import files @operation def virtualenv( state, host, path, python=None, site_packages=False, always_copy=False, present=True, ): ''' Manage virtualenv. + python: python interpreter to use + site_packages: give access to the global site-packages + always_copy: always copy files rather than symlinking + present: whether the virtualenv should be installed ''' if present is False and host.fact.directory(path): # Ensure deletion of unwanted virtualenv # no 'yield from' in python 2.7 yield files.directory(state, host, path, present=False) elif present and not host.fact.directory(path): # Create missing virtualenv command = ['/usr/bin/virtualenv'] if python: command.append('-p {}'.format(python)) if site_packages: command.append('--system-site-packages') if always_copy: command.append('--always-copy') command.append(path) yield ' '.join(command)
<commit_before># pyinfra # File: pyinfra/modules/pip.py # Desc: manage virtualenvs ''' Manage Python virtual environments ''' from __future__ import unicode_literals from pyinfra.api import operation from pyinfra.modules import files @operation def virtualenv( state, host, path, python=None, site_packages=False, always_copy=False, present=True, ): ''' Manage virtualenv. + python: python interpreter to use + site_packages: give access to the global site-packages + always_copy: always copy files rather than symlinking + present: whether the virtualenv should be installed ''' if present is False and host.fact.directory(path): # Ensure deletion of unwanted virtualenv # no 'yield from' in python 2.7 yield files.directory(state, host, path, present=False) elif present and not host.fact.directory(path): # Create missing virtualenv command = '/usr/bin/virtualenv' if python: command += ' -p {}'.format(python) if site_packages: command += ' --system-site-packages' if always_copy: command += ' --always-copy' command += ' ' + path yield command <commit_msg>Refactor building command using join()<commit_after>
# pyinfra # File: pyinfra/modules/pip.py # Desc: manage virtualenvs ''' Manage Python virtual environments ''' from __future__ import unicode_literals from pyinfra.api import operation from pyinfra.modules import files @operation def virtualenv( state, host, path, python=None, site_packages=False, always_copy=False, present=True, ): ''' Manage virtualenv. + python: python interpreter to use + site_packages: give access to the global site-packages + always_copy: always copy files rather than symlinking + present: whether the virtualenv should be installed ''' if present is False and host.fact.directory(path): # Ensure deletion of unwanted virtualenv # no 'yield from' in python 2.7 yield files.directory(state, host, path, present=False) elif present and not host.fact.directory(path): # Create missing virtualenv command = ['/usr/bin/virtualenv'] if python: command.append('-p {}'.format(python)) if site_packages: command.append('--system-site-packages') if always_copy: command.append('--always-copy') command.append(path) yield ' '.join(command)
# pyinfra # File: pyinfra/modules/pip.py # Desc: manage virtualenvs ''' Manage Python virtual environments ''' from __future__ import unicode_literals from pyinfra.api import operation from pyinfra.modules import files @operation def virtualenv( state, host, path, python=None, site_packages=False, always_copy=False, present=True, ): ''' Manage virtualenv. + python: python interpreter to use + site_packages: give access to the global site-packages + always_copy: always copy files rather than symlinking + present: whether the virtualenv should be installed ''' if present is False and host.fact.directory(path): # Ensure deletion of unwanted virtualenv # no 'yield from' in python 2.7 yield files.directory(state, host, path, present=False) elif present and not host.fact.directory(path): # Create missing virtualenv command = '/usr/bin/virtualenv' if python: command += ' -p {}'.format(python) if site_packages: command += ' --system-site-packages' if always_copy: command += ' --always-copy' command += ' ' + path yield command Refactor building command using join()# pyinfra # File: pyinfra/modules/pip.py # Desc: manage virtualenvs ''' Manage Python virtual environments ''' from __future__ import unicode_literals from pyinfra.api import operation from pyinfra.modules import files @operation def virtualenv( state, host, path, python=None, site_packages=False, always_copy=False, present=True, ): ''' Manage virtualenv. + python: python interpreter to use + site_packages: give access to the global site-packages + always_copy: always copy files rather than symlinking + present: whether the virtualenv should be installed ''' if present is False and host.fact.directory(path): # Ensure deletion of unwanted virtualenv # no 'yield from' in python 2.7 yield files.directory(state, host, path, present=False) elif present and not host.fact.directory(path): # Create missing virtualenv command = ['/usr/bin/virtualenv'] if python: command.append('-p {}'.format(python)) if site_packages: command.append('--system-site-packages') if always_copy: command.append('--always-copy') command.append(path) yield ' '.join(command)
<commit_before># pyinfra # File: pyinfra/modules/pip.py # Desc: manage virtualenvs ''' Manage Python virtual environments ''' from __future__ import unicode_literals from pyinfra.api import operation from pyinfra.modules import files @operation def virtualenv( state, host, path, python=None, site_packages=False, always_copy=False, present=True, ): ''' Manage virtualenv. + python: python interpreter to use + site_packages: give access to the global site-packages + always_copy: always copy files rather than symlinking + present: whether the virtualenv should be installed ''' if present is False and host.fact.directory(path): # Ensure deletion of unwanted virtualenv # no 'yield from' in python 2.7 yield files.directory(state, host, path, present=False) elif present and not host.fact.directory(path): # Create missing virtualenv command = '/usr/bin/virtualenv' if python: command += ' -p {}'.format(python) if site_packages: command += ' --system-site-packages' if always_copy: command += ' --always-copy' command += ' ' + path yield command <commit_msg>Refactor building command using join()<commit_after># pyinfra # File: pyinfra/modules/pip.py # Desc: manage virtualenvs ''' Manage Python virtual environments ''' from __future__ import unicode_literals from pyinfra.api import operation from pyinfra.modules import files @operation def virtualenv( state, host, path, python=None, site_packages=False, always_copy=False, present=True, ): ''' Manage virtualenv. + python: python interpreter to use + site_packages: give access to the global site-packages + always_copy: always copy files rather than symlinking + present: whether the virtualenv should be installed ''' if present is False and host.fact.directory(path): # Ensure deletion of unwanted virtualenv # no 'yield from' in python 2.7 yield files.directory(state, host, path, present=False) elif present and not host.fact.directory(path): # Create missing virtualenv command = ['/usr/bin/virtualenv'] if python: command.append('-p {}'.format(python)) if site_packages: command.append('--system-site-packages') if always_copy: command.append('--always-copy') command.append(path) yield ' '.join(command)
0b1cdfac668b15ab9d48b1eb8a4ac4bff7b8c98e
pylinks/main/templatetags/menu_li.py
pylinks/main/templatetags/menu_li.py
from django.template import Library from django.template.defaulttags import URLNode, url from django.utils.html import escape, mark_safe register = Library() class MenuLINode(URLNode): def render(self, context): # Pull out the match and hijack asvar # to be used for the link title request = context.get('request') if self.asvar: title = escape(self.asvar.strip('"\'')) elif request: title = request.resolver_match.url_name # Reset asvar and render to get the URL self.asvar = None menu_url = super(MenuLINode, self).render(context) # Check if we're on the defined page if request and str(self.view_name).strip('"\'') == \ request.resolver_match.url_name: active_class = ' class="active"' else: active_class = '' return mark_safe('<li%s><a href="%s">%s</a></li>' % \ (active_class, menu_url, title)) @register.tag def menu_li(parser, token, node_cls=MenuLINode): """ Add a menu <li> for Twitter Bootstrap, checking adding the "active" class as needed. """ node_instance = url(parser, token) return node_cls(view_name=node_instance.view_name, args=node_instance.args, kwargs=node_instance.kwargs, asvar=node_instance.asvar)
from django.template import Library from django.template.defaulttags import URLNode, url from django.utils.html import escape, mark_safe register = Library() class MenuLINode(URLNode): def render(self, context): # Pull out the match and hijack asvar # to be used for the link title match = getattr(context.get('request'), 'resolver_match', None) if self.asvar: title = escape(self.asvar.strip('"\'')) elif match: title = match.url_name # Reset asvar and render to get the URL self.asvar = None menu_url = super(MenuLINode, self).render(context) # Check if we're on the defined page if match and str(self.view_name).strip('"\'') == match.url_name: active_class = ' class="active"' else: active_class = '' return mark_safe('<li%s><a href="%s">%s</a></li>' % \ (active_class, menu_url, title)) @register.tag def menu_li(parser, token, node_cls=MenuLINode): """ Add a menu <li> for Twitter Bootstrap, checking adding the "active" class as needed. """ node_instance = url(parser, token) return node_cls(view_name=node_instance.view_name, args=node_instance.args, kwargs=node_instance.kwargs, asvar=node_instance.asvar)
Fix check for valid resolver_match
Fix check for valid resolver_match
Python
mit
michaelmior/pylinks,michaelmior/pylinks,michaelmior/pylinks
from django.template import Library from django.template.defaulttags import URLNode, url from django.utils.html import escape, mark_safe register = Library() class MenuLINode(URLNode): def render(self, context): # Pull out the match and hijack asvar # to be used for the link title request = context.get('request') if self.asvar: title = escape(self.asvar.strip('"\'')) elif request: title = request.resolver_match.url_name # Reset asvar and render to get the URL self.asvar = None menu_url = super(MenuLINode, self).render(context) # Check if we're on the defined page if request and str(self.view_name).strip('"\'') == \ request.resolver_match.url_name: active_class = ' class="active"' else: active_class = '' return mark_safe('<li%s><a href="%s">%s</a></li>' % \ (active_class, menu_url, title)) @register.tag def menu_li(parser, token, node_cls=MenuLINode): """ Add a menu <li> for Twitter Bootstrap, checking adding the "active" class as needed. """ node_instance = url(parser, token) return node_cls(view_name=node_instance.view_name, args=node_instance.args, kwargs=node_instance.kwargs, asvar=node_instance.asvar) Fix check for valid resolver_match
from django.template import Library from django.template.defaulttags import URLNode, url from django.utils.html import escape, mark_safe register = Library() class MenuLINode(URLNode): def render(self, context): # Pull out the match and hijack asvar # to be used for the link title match = getattr(context.get('request'), 'resolver_match', None) if self.asvar: title = escape(self.asvar.strip('"\'')) elif match: title = match.url_name # Reset asvar and render to get the URL self.asvar = None menu_url = super(MenuLINode, self).render(context) # Check if we're on the defined page if match and str(self.view_name).strip('"\'') == match.url_name: active_class = ' class="active"' else: active_class = '' return mark_safe('<li%s><a href="%s">%s</a></li>' % \ (active_class, menu_url, title)) @register.tag def menu_li(parser, token, node_cls=MenuLINode): """ Add a menu <li> for Twitter Bootstrap, checking adding the "active" class as needed. """ node_instance = url(parser, token) return node_cls(view_name=node_instance.view_name, args=node_instance.args, kwargs=node_instance.kwargs, asvar=node_instance.asvar)
<commit_before>from django.template import Library from django.template.defaulttags import URLNode, url from django.utils.html import escape, mark_safe register = Library() class MenuLINode(URLNode): def render(self, context): # Pull out the match and hijack asvar # to be used for the link title request = context.get('request') if self.asvar: title = escape(self.asvar.strip('"\'')) elif request: title = request.resolver_match.url_name # Reset asvar and render to get the URL self.asvar = None menu_url = super(MenuLINode, self).render(context) # Check if we're on the defined page if request and str(self.view_name).strip('"\'') == \ request.resolver_match.url_name: active_class = ' class="active"' else: active_class = '' return mark_safe('<li%s><a href="%s">%s</a></li>' % \ (active_class, menu_url, title)) @register.tag def menu_li(parser, token, node_cls=MenuLINode): """ Add a menu <li> for Twitter Bootstrap, checking adding the "active" class as needed. """ node_instance = url(parser, token) return node_cls(view_name=node_instance.view_name, args=node_instance.args, kwargs=node_instance.kwargs, asvar=node_instance.asvar) <commit_msg>Fix check for valid resolver_match<commit_after>
from django.template import Library from django.template.defaulttags import URLNode, url from django.utils.html import escape, mark_safe register = Library() class MenuLINode(URLNode): def render(self, context): # Pull out the match and hijack asvar # to be used for the link title match = getattr(context.get('request'), 'resolver_match', None) if self.asvar: title = escape(self.asvar.strip('"\'')) elif match: title = match.url_name # Reset asvar and render to get the URL self.asvar = None menu_url = super(MenuLINode, self).render(context) # Check if we're on the defined page if match and str(self.view_name).strip('"\'') == match.url_name: active_class = ' class="active"' else: active_class = '' return mark_safe('<li%s><a href="%s">%s</a></li>' % \ (active_class, menu_url, title)) @register.tag def menu_li(parser, token, node_cls=MenuLINode): """ Add a menu <li> for Twitter Bootstrap, checking adding the "active" class as needed. """ node_instance = url(parser, token) return node_cls(view_name=node_instance.view_name, args=node_instance.args, kwargs=node_instance.kwargs, asvar=node_instance.asvar)
from django.template import Library from django.template.defaulttags import URLNode, url from django.utils.html import escape, mark_safe register = Library() class MenuLINode(URLNode): def render(self, context): # Pull out the match and hijack asvar # to be used for the link title request = context.get('request') if self.asvar: title = escape(self.asvar.strip('"\'')) elif request: title = request.resolver_match.url_name # Reset asvar and render to get the URL self.asvar = None menu_url = super(MenuLINode, self).render(context) # Check if we're on the defined page if request and str(self.view_name).strip('"\'') == \ request.resolver_match.url_name: active_class = ' class="active"' else: active_class = '' return mark_safe('<li%s><a href="%s">%s</a></li>' % \ (active_class, menu_url, title)) @register.tag def menu_li(parser, token, node_cls=MenuLINode): """ Add a menu <li> for Twitter Bootstrap, checking adding the "active" class as needed. """ node_instance = url(parser, token) return node_cls(view_name=node_instance.view_name, args=node_instance.args, kwargs=node_instance.kwargs, asvar=node_instance.asvar) Fix check for valid resolver_matchfrom django.template import Library from django.template.defaulttags import URLNode, url from django.utils.html import escape, mark_safe register = Library() class MenuLINode(URLNode): def render(self, context): # Pull out the match and hijack asvar # to be used for the link title match = getattr(context.get('request'), 'resolver_match', None) if self.asvar: title = escape(self.asvar.strip('"\'')) elif match: title = match.url_name # Reset asvar and render to get the URL self.asvar = None menu_url = super(MenuLINode, self).render(context) # Check if we're on the defined page if match and str(self.view_name).strip('"\'') == match.url_name: active_class = ' class="active"' else: active_class = '' return mark_safe('<li%s><a href="%s">%s</a></li>' % \ (active_class, menu_url, title)) @register.tag def menu_li(parser, token, node_cls=MenuLINode): """ Add a menu <li> for Twitter Bootstrap, checking adding the "active" class as needed. """ node_instance = url(parser, token) return node_cls(view_name=node_instance.view_name, args=node_instance.args, kwargs=node_instance.kwargs, asvar=node_instance.asvar)
<commit_before>from django.template import Library from django.template.defaulttags import URLNode, url from django.utils.html import escape, mark_safe register = Library() class MenuLINode(URLNode): def render(self, context): # Pull out the match and hijack asvar # to be used for the link title request = context.get('request') if self.asvar: title = escape(self.asvar.strip('"\'')) elif request: title = request.resolver_match.url_name # Reset asvar and render to get the URL self.asvar = None menu_url = super(MenuLINode, self).render(context) # Check if we're on the defined page if request and str(self.view_name).strip('"\'') == \ request.resolver_match.url_name: active_class = ' class="active"' else: active_class = '' return mark_safe('<li%s><a href="%s">%s</a></li>' % \ (active_class, menu_url, title)) @register.tag def menu_li(parser, token, node_cls=MenuLINode): """ Add a menu <li> for Twitter Bootstrap, checking adding the "active" class as needed. """ node_instance = url(parser, token) return node_cls(view_name=node_instance.view_name, args=node_instance.args, kwargs=node_instance.kwargs, asvar=node_instance.asvar) <commit_msg>Fix check for valid resolver_match<commit_after>from django.template import Library from django.template.defaulttags import URLNode, url from django.utils.html import escape, mark_safe register = Library() class MenuLINode(URLNode): def render(self, context): # Pull out the match and hijack asvar # to be used for the link title match = getattr(context.get('request'), 'resolver_match', None) if self.asvar: title = escape(self.asvar.strip('"\'')) elif match: title = match.url_name # Reset asvar and render to get the URL self.asvar = None menu_url = super(MenuLINode, self).render(context) # Check if we're on the defined page if match and str(self.view_name).strip('"\'') == match.url_name: active_class = ' class="active"' else: active_class = '' return mark_safe('<li%s><a href="%s">%s</a></li>' % \ (active_class, menu_url, title)) @register.tag def menu_li(parser, token, node_cls=MenuLINode): """ Add a menu <li> for Twitter Bootstrap, checking adding the "active" class as needed. """ node_instance = url(parser, token) return node_cls(view_name=node_instance.view_name, args=node_instance.args, kwargs=node_instance.kwargs, asvar=node_instance.asvar)
36f9faf31bf7002d95aaa43b1427367a3a781ffa
plugins/httptitle.py
plugins/httptitle.py
import plugin import urllib2 import logging import re from httplib import HTTPException from htmllib import HTMLParser class Plugin(plugin.baseplugin): def __init__(self, bot): self._regex = re.compile("(https?://.+)\s?") self._ua = "Mozilla/5.0 (X11; Linux x86_64; rv:2.0b8) Gecko/20100101 Firefox/4.0b8" bot.register_regex(self._regex, self.title) def unescape(self, s): p = HTMLParser(None) p.save_bgn() p.feed(s) return p.save_end() def title(self, bot, user, channel, text, match_obj): url = match_obj.groups()[0] req = urllib2.Request(url) req.add_header("User-Agent", self._ua) try: content = urllib2.urlopen(req).read() except (urllib2.URLError, HTTPException), e: logging.debug("%s - %s" % (e, url)) return beg = content.find("<title>") if beg != -1: title = content[beg+7:content.find("</title>")].replace("\n","") title = self.unescape(title) bot.privmsg(channel, "Title: %s" % unicode(title, "utf-8"))
import plugin import urllib2 import logging import re from httplib import HTTPException import HTMLParser class Plugin(plugin.baseplugin): def __init__(self, bot): self._regex = re.compile("(https?://.+)\s?") self._ua = "Mozilla/5.0 (X11; Linux x86_64; rv:2.0b8) Gecko/20100101 Firefox/4.0b8" bot.register_regex(self._regex, self.title) def unescape(self, s): p = HTMLParser.HTMLParser(None) p.save_bgn() p.feed(s) return p.save_end() def title(self, bot, user, channel, text, match_obj): url = match_obj.groups()[0] req = urllib2.Request(url) req.add_header("User-Agent", self._ua) try: content = urllib2.urlopen(req).read() except (urllib2.URLError, HTTPException), e: logging.debug("%s - %s" % (e, url)) return beg = content.find("<title>") if beg != -1: title = content[beg+7:content.find("</title>")].replace("\n","") try: title = self.unescape(title) except HTMLParser.HTMLParseError, e: logging.info("%s - %s" % (e.msg, url)) bot.privmsg(channel, "Title: %s" % unicode(title, "utf-8"))
Use the HTMLParser module instead of htmllib
Use the HTMLParser module instead of htmllib
Python
mit
mineo/lala,mineo/lala
import plugin import urllib2 import logging import re from httplib import HTTPException from htmllib import HTMLParser class Plugin(plugin.baseplugin): def __init__(self, bot): self._regex = re.compile("(https?://.+)\s?") self._ua = "Mozilla/5.0 (X11; Linux x86_64; rv:2.0b8) Gecko/20100101 Firefox/4.0b8" bot.register_regex(self._regex, self.title) def unescape(self, s): p = HTMLParser(None) p.save_bgn() p.feed(s) return p.save_end() def title(self, bot, user, channel, text, match_obj): url = match_obj.groups()[0] req = urllib2.Request(url) req.add_header("User-Agent", self._ua) try: content = urllib2.urlopen(req).read() except (urllib2.URLError, HTTPException), e: logging.debug("%s - %s" % (e, url)) return beg = content.find("<title>") if beg != -1: title = content[beg+7:content.find("</title>")].replace("\n","") title = self.unescape(title) bot.privmsg(channel, "Title: %s" % unicode(title, "utf-8")) Use the HTMLParser module instead of htmllib
import plugin import urllib2 import logging import re from httplib import HTTPException import HTMLParser class Plugin(plugin.baseplugin): def __init__(self, bot): self._regex = re.compile("(https?://.+)\s?") self._ua = "Mozilla/5.0 (X11; Linux x86_64; rv:2.0b8) Gecko/20100101 Firefox/4.0b8" bot.register_regex(self._regex, self.title) def unescape(self, s): p = HTMLParser.HTMLParser(None) p.save_bgn() p.feed(s) return p.save_end() def title(self, bot, user, channel, text, match_obj): url = match_obj.groups()[0] req = urllib2.Request(url) req.add_header("User-Agent", self._ua) try: content = urllib2.urlopen(req).read() except (urllib2.URLError, HTTPException), e: logging.debug("%s - %s" % (e, url)) return beg = content.find("<title>") if beg != -1: title = content[beg+7:content.find("</title>")].replace("\n","") try: title = self.unescape(title) except HTMLParser.HTMLParseError, e: logging.info("%s - %s" % (e.msg, url)) bot.privmsg(channel, "Title: %s" % unicode(title, "utf-8"))
<commit_before>import plugin import urllib2 import logging import re from httplib import HTTPException from htmllib import HTMLParser class Plugin(plugin.baseplugin): def __init__(self, bot): self._regex = re.compile("(https?://.+)\s?") self._ua = "Mozilla/5.0 (X11; Linux x86_64; rv:2.0b8) Gecko/20100101 Firefox/4.0b8" bot.register_regex(self._regex, self.title) def unescape(self, s): p = HTMLParser(None) p.save_bgn() p.feed(s) return p.save_end() def title(self, bot, user, channel, text, match_obj): url = match_obj.groups()[0] req = urllib2.Request(url) req.add_header("User-Agent", self._ua) try: content = urllib2.urlopen(req).read() except (urllib2.URLError, HTTPException), e: logging.debug("%s - %s" % (e, url)) return beg = content.find("<title>") if beg != -1: title = content[beg+7:content.find("</title>")].replace("\n","") title = self.unescape(title) bot.privmsg(channel, "Title: %s" % unicode(title, "utf-8")) <commit_msg>Use the HTMLParser module instead of htmllib<commit_after>
import plugin import urllib2 import logging import re from httplib import HTTPException import HTMLParser class Plugin(plugin.baseplugin): def __init__(self, bot): self._regex = re.compile("(https?://.+)\s?") self._ua = "Mozilla/5.0 (X11; Linux x86_64; rv:2.0b8) Gecko/20100101 Firefox/4.0b8" bot.register_regex(self._regex, self.title) def unescape(self, s): p = HTMLParser.HTMLParser(None) p.save_bgn() p.feed(s) return p.save_end() def title(self, bot, user, channel, text, match_obj): url = match_obj.groups()[0] req = urllib2.Request(url) req.add_header("User-Agent", self._ua) try: content = urllib2.urlopen(req).read() except (urllib2.URLError, HTTPException), e: logging.debug("%s - %s" % (e, url)) return beg = content.find("<title>") if beg != -1: title = content[beg+7:content.find("</title>")].replace("\n","") try: title = self.unescape(title) except HTMLParser.HTMLParseError, e: logging.info("%s - %s" % (e.msg, url)) bot.privmsg(channel, "Title: %s" % unicode(title, "utf-8"))
import plugin import urllib2 import logging import re from httplib import HTTPException from htmllib import HTMLParser class Plugin(plugin.baseplugin): def __init__(self, bot): self._regex = re.compile("(https?://.+)\s?") self._ua = "Mozilla/5.0 (X11; Linux x86_64; rv:2.0b8) Gecko/20100101 Firefox/4.0b8" bot.register_regex(self._regex, self.title) def unescape(self, s): p = HTMLParser(None) p.save_bgn() p.feed(s) return p.save_end() def title(self, bot, user, channel, text, match_obj): url = match_obj.groups()[0] req = urllib2.Request(url) req.add_header("User-Agent", self._ua) try: content = urllib2.urlopen(req).read() except (urllib2.URLError, HTTPException), e: logging.debug("%s - %s" % (e, url)) return beg = content.find("<title>") if beg != -1: title = content[beg+7:content.find("</title>")].replace("\n","") title = self.unescape(title) bot.privmsg(channel, "Title: %s" % unicode(title, "utf-8")) Use the HTMLParser module instead of htmllibimport plugin import urllib2 import logging import re from httplib import HTTPException import HTMLParser class Plugin(plugin.baseplugin): def __init__(self, bot): self._regex = re.compile("(https?://.+)\s?") self._ua = "Mozilla/5.0 (X11; Linux x86_64; rv:2.0b8) Gecko/20100101 Firefox/4.0b8" bot.register_regex(self._regex, self.title) def unescape(self, s): p = HTMLParser.HTMLParser(None) p.save_bgn() p.feed(s) return p.save_end() def title(self, bot, user, channel, text, match_obj): url = match_obj.groups()[0] req = urllib2.Request(url) req.add_header("User-Agent", self._ua) try: content = urllib2.urlopen(req).read() except (urllib2.URLError, HTTPException), e: logging.debug("%s - %s" % (e, url)) return beg = content.find("<title>") if beg != -1: title = content[beg+7:content.find("</title>")].replace("\n","") try: title = self.unescape(title) except HTMLParser.HTMLParseError, e: logging.info("%s - %s" % (e.msg, url)) bot.privmsg(channel, "Title: %s" % unicode(title, "utf-8"))
<commit_before>import plugin import urllib2 import logging import re from httplib import HTTPException from htmllib import HTMLParser class Plugin(plugin.baseplugin): def __init__(self, bot): self._regex = re.compile("(https?://.+)\s?") self._ua = "Mozilla/5.0 (X11; Linux x86_64; rv:2.0b8) Gecko/20100101 Firefox/4.0b8" bot.register_regex(self._regex, self.title) def unescape(self, s): p = HTMLParser(None) p.save_bgn() p.feed(s) return p.save_end() def title(self, bot, user, channel, text, match_obj): url = match_obj.groups()[0] req = urllib2.Request(url) req.add_header("User-Agent", self._ua) try: content = urllib2.urlopen(req).read() except (urllib2.URLError, HTTPException), e: logging.debug("%s - %s" % (e, url)) return beg = content.find("<title>") if beg != -1: title = content[beg+7:content.find("</title>")].replace("\n","") title = self.unescape(title) bot.privmsg(channel, "Title: %s" % unicode(title, "utf-8")) <commit_msg>Use the HTMLParser module instead of htmllib<commit_after>import plugin import urllib2 import logging import re from httplib import HTTPException import HTMLParser class Plugin(plugin.baseplugin): def __init__(self, bot): self._regex = re.compile("(https?://.+)\s?") self._ua = "Mozilla/5.0 (X11; Linux x86_64; rv:2.0b8) Gecko/20100101 Firefox/4.0b8" bot.register_regex(self._regex, self.title) def unescape(self, s): p = HTMLParser.HTMLParser(None) p.save_bgn() p.feed(s) return p.save_end() def title(self, bot, user, channel, text, match_obj): url = match_obj.groups()[0] req = urllib2.Request(url) req.add_header("User-Agent", self._ua) try: content = urllib2.urlopen(req).read() except (urllib2.URLError, HTTPException), e: logging.debug("%s - %s" % (e, url)) return beg = content.find("<title>") if beg != -1: title = content[beg+7:content.find("</title>")].replace("\n","") try: title = self.unescape(title) except HTMLParser.HTMLParseError, e: logging.info("%s - %s" % (e.msg, url)) bot.privmsg(channel, "Title: %s" % unicode(title, "utf-8"))
3d6cc53a3fa5f272086612fa487589acc9b13737
federez_ldap/wsgi.py
federez_ldap/wsgi.py
""" WSGI config for federez_ldap project. This module contains the WSGI application used by Django's development server and any production WSGI deployments. It should expose a module-level variable named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover this application via the ``WSGI_APPLICATION`` setting. Usually you will have the standard Django WSGI application here, but it also might make sense to replace the whole Django WSGI application with a custom one that later delegates to the Django one. For example, you could introduce WSGI middleware here, or combine a Django application with an application of another framework. """ import os os.environ.setdefault("DJANGO_SETTINGS_MODULE", "federez_ldap.settings") # This application object is used by any WSGI server configured to use this # file. This includes Django's development server, if the WSGI_APPLICATION # setting points here. from django.core.wsgi import get_wsgi_application application = get_wsgi_application() # Apply WSGI middleware here. # from helloworld.wsgi import HelloWorldApplication # application = HelloWorldApplication(application)
""" WSGI config for federez_ldap project. This module contains the WSGI application used by Django's development server and any production WSGI deployments. It should expose a module-level variable named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover this application via the ``WSGI_APPLICATION`` setting. Usually you will have the standard Django WSGI application here, but it also might make sense to replace the whole Django WSGI application with a custom one that later delegates to the Django one. For example, you could introduce WSGI middleware here, or combine a Django application with an application of another framework. """ import sys import os from os.path import dirname sys.path.append(dirname(dirname(__file__))) os.environ.setdefault("DJANGO_SETTINGS_MODULE", "federez_ldap.settings") # This application object is used by any WSGI server configured to use this # file. This includes Django's development server, if the WSGI_APPLICATION # setting points here. from django.core.wsgi import get_wsgi_application application = get_wsgi_application() # Apply WSGI middleware here. # from helloworld.wsgi import HelloWorldApplication # application = HelloWorldApplication(application)
Append app path to Python path in WSGI
Append app path to Python path in WSGI
Python
mit
FedeRez/webldap,FedeRez/webldap,FedeRez/webldap
""" WSGI config for federez_ldap project. This module contains the WSGI application used by Django's development server and any production WSGI deployments. It should expose a module-level variable named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover this application via the ``WSGI_APPLICATION`` setting. Usually you will have the standard Django WSGI application here, but it also might make sense to replace the whole Django WSGI application with a custom one that later delegates to the Django one. For example, you could introduce WSGI middleware here, or combine a Django application with an application of another framework. """ import os os.environ.setdefault("DJANGO_SETTINGS_MODULE", "federez_ldap.settings") # This application object is used by any WSGI server configured to use this # file. This includes Django's development server, if the WSGI_APPLICATION # setting points here. from django.core.wsgi import get_wsgi_application application = get_wsgi_application() # Apply WSGI middleware here. # from helloworld.wsgi import HelloWorldApplication # application = HelloWorldApplication(application) Append app path to Python path in WSGI
""" WSGI config for federez_ldap project. This module contains the WSGI application used by Django's development server and any production WSGI deployments. It should expose a module-level variable named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover this application via the ``WSGI_APPLICATION`` setting. Usually you will have the standard Django WSGI application here, but it also might make sense to replace the whole Django WSGI application with a custom one that later delegates to the Django one. For example, you could introduce WSGI middleware here, or combine a Django application with an application of another framework. """ import sys import os from os.path import dirname sys.path.append(dirname(dirname(__file__))) os.environ.setdefault("DJANGO_SETTINGS_MODULE", "federez_ldap.settings") # This application object is used by any WSGI server configured to use this # file. This includes Django's development server, if the WSGI_APPLICATION # setting points here. from django.core.wsgi import get_wsgi_application application = get_wsgi_application() # Apply WSGI middleware here. # from helloworld.wsgi import HelloWorldApplication # application = HelloWorldApplication(application)
<commit_before>""" WSGI config for federez_ldap project. This module contains the WSGI application used by Django's development server and any production WSGI deployments. It should expose a module-level variable named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover this application via the ``WSGI_APPLICATION`` setting. Usually you will have the standard Django WSGI application here, but it also might make sense to replace the whole Django WSGI application with a custom one that later delegates to the Django one. For example, you could introduce WSGI middleware here, or combine a Django application with an application of another framework. """ import os os.environ.setdefault("DJANGO_SETTINGS_MODULE", "federez_ldap.settings") # This application object is used by any WSGI server configured to use this # file. This includes Django's development server, if the WSGI_APPLICATION # setting points here. from django.core.wsgi import get_wsgi_application application = get_wsgi_application() # Apply WSGI middleware here. # from helloworld.wsgi import HelloWorldApplication # application = HelloWorldApplication(application) <commit_msg>Append app path to Python path in WSGI<commit_after>
""" WSGI config for federez_ldap project. This module contains the WSGI application used by Django's development server and any production WSGI deployments. It should expose a module-level variable named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover this application via the ``WSGI_APPLICATION`` setting. Usually you will have the standard Django WSGI application here, but it also might make sense to replace the whole Django WSGI application with a custom one that later delegates to the Django one. For example, you could introduce WSGI middleware here, or combine a Django application with an application of another framework. """ import sys import os from os.path import dirname sys.path.append(dirname(dirname(__file__))) os.environ.setdefault("DJANGO_SETTINGS_MODULE", "federez_ldap.settings") # This application object is used by any WSGI server configured to use this # file. This includes Django's development server, if the WSGI_APPLICATION # setting points here. from django.core.wsgi import get_wsgi_application application = get_wsgi_application() # Apply WSGI middleware here. # from helloworld.wsgi import HelloWorldApplication # application = HelloWorldApplication(application)
""" WSGI config for federez_ldap project. This module contains the WSGI application used by Django's development server and any production WSGI deployments. It should expose a module-level variable named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover this application via the ``WSGI_APPLICATION`` setting. Usually you will have the standard Django WSGI application here, but it also might make sense to replace the whole Django WSGI application with a custom one that later delegates to the Django one. For example, you could introduce WSGI middleware here, or combine a Django application with an application of another framework. """ import os os.environ.setdefault("DJANGO_SETTINGS_MODULE", "federez_ldap.settings") # This application object is used by any WSGI server configured to use this # file. This includes Django's development server, if the WSGI_APPLICATION # setting points here. from django.core.wsgi import get_wsgi_application application = get_wsgi_application() # Apply WSGI middleware here. # from helloworld.wsgi import HelloWorldApplication # application = HelloWorldApplication(application) Append app path to Python path in WSGI""" WSGI config for federez_ldap project. This module contains the WSGI application used by Django's development server and any production WSGI deployments. It should expose a module-level variable named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover this application via the ``WSGI_APPLICATION`` setting. Usually you will have the standard Django WSGI application here, but it also might make sense to replace the whole Django WSGI application with a custom one that later delegates to the Django one. For example, you could introduce WSGI middleware here, or combine a Django application with an application of another framework. """ import sys import os from os.path import dirname sys.path.append(dirname(dirname(__file__))) os.environ.setdefault("DJANGO_SETTINGS_MODULE", "federez_ldap.settings") # This application object is used by any WSGI server configured to use this # file. This includes Django's development server, if the WSGI_APPLICATION # setting points here. from django.core.wsgi import get_wsgi_application application = get_wsgi_application() # Apply WSGI middleware here. # from helloworld.wsgi import HelloWorldApplication # application = HelloWorldApplication(application)
<commit_before>""" WSGI config for federez_ldap project. This module contains the WSGI application used by Django's development server and any production WSGI deployments. It should expose a module-level variable named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover this application via the ``WSGI_APPLICATION`` setting. Usually you will have the standard Django WSGI application here, but it also might make sense to replace the whole Django WSGI application with a custom one that later delegates to the Django one. For example, you could introduce WSGI middleware here, or combine a Django application with an application of another framework. """ import os os.environ.setdefault("DJANGO_SETTINGS_MODULE", "federez_ldap.settings") # This application object is used by any WSGI server configured to use this # file. This includes Django's development server, if the WSGI_APPLICATION # setting points here. from django.core.wsgi import get_wsgi_application application = get_wsgi_application() # Apply WSGI middleware here. # from helloworld.wsgi import HelloWorldApplication # application = HelloWorldApplication(application) <commit_msg>Append app path to Python path in WSGI<commit_after>""" WSGI config for federez_ldap project. This module contains the WSGI application used by Django's development server and any production WSGI deployments. It should expose a module-level variable named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover this application via the ``WSGI_APPLICATION`` setting. Usually you will have the standard Django WSGI application here, but it also might make sense to replace the whole Django WSGI application with a custom one that later delegates to the Django one. For example, you could introduce WSGI middleware here, or combine a Django application with an application of another framework. """ import sys import os from os.path import dirname sys.path.append(dirname(dirname(__file__))) os.environ.setdefault("DJANGO_SETTINGS_MODULE", "federez_ldap.settings") # This application object is used by any WSGI server configured to use this # file. This includes Django's development server, if the WSGI_APPLICATION # setting points here. from django.core.wsgi import get_wsgi_application application = get_wsgi_application() # Apply WSGI middleware here. # from helloworld.wsgi import HelloWorldApplication # application = HelloWorldApplication(application)
daaeb002d7a4a2845052dd3078512e66189c5a88
linguist/tests/base.py
linguist/tests/base.py
# -*- coding: utf-8 -*- from django.test import TestCase from ..registry import LinguistRegistry as Registry from ..models import Translation from . import settings from .translations import FooModel, FooTranslation class BaseTestCase(TestCase): """ Base test class mixin. """ @property def languages(self): return [language[0] for language in settings.LANGUAGES] @property def translation_en(self): obj, created = Translation.objects.get_or_create( identifier='foo', object_id=self.instance.pk, language='en', field_name='title', field_value='Hello') return obj @property def translation_fr(self): obj, created = Translation.objects.get_or_create( identifier='foo', object_id=self.instance.pk, language='fr', field_name='title', field_value='bonjour') return obj def create_registry(self): self.registry = Registry() self.registry.register(FooTranslation) self.instance = FooModel()
# -*- coding: utf-8 -*- from django.test import TestCase from ..models import Translation from . import settings from .translations import FooModel class BaseTestCase(TestCase): """ Base test class mixin. """ @property def languages(self): return [language[0] for language in settings.LANGUAGES] @property def translation_en(self): obj, created = Translation.objects.get_or_create( identifier='foo', object_id=self.instance.pk, language='en', field_name='title', field_value='Hello') return obj @property def translation_fr(self): obj, created = Translation.objects.get_or_create( identifier='foo', object_id=self.instance.pk, language='fr', field_name='title', field_value='bonjour') return obj def setup_models(self): self.instance = FooModel()
Update BaseTest class (removing registry).
Update BaseTest class (removing registry).
Python
mit
ulule/django-linguist
# -*- coding: utf-8 -*- from django.test import TestCase from ..registry import LinguistRegistry as Registry from ..models import Translation from . import settings from .translations import FooModel, FooTranslation class BaseTestCase(TestCase): """ Base test class mixin. """ @property def languages(self): return [language[0] for language in settings.LANGUAGES] @property def translation_en(self): obj, created = Translation.objects.get_or_create( identifier='foo', object_id=self.instance.pk, language='en', field_name='title', field_value='Hello') return obj @property def translation_fr(self): obj, created = Translation.objects.get_or_create( identifier='foo', object_id=self.instance.pk, language='fr', field_name='title', field_value='bonjour') return obj def create_registry(self): self.registry = Registry() self.registry.register(FooTranslation) self.instance = FooModel() Update BaseTest class (removing registry).
# -*- coding: utf-8 -*- from django.test import TestCase from ..models import Translation from . import settings from .translations import FooModel class BaseTestCase(TestCase): """ Base test class mixin. """ @property def languages(self): return [language[0] for language in settings.LANGUAGES] @property def translation_en(self): obj, created = Translation.objects.get_or_create( identifier='foo', object_id=self.instance.pk, language='en', field_name='title', field_value='Hello') return obj @property def translation_fr(self): obj, created = Translation.objects.get_or_create( identifier='foo', object_id=self.instance.pk, language='fr', field_name='title', field_value='bonjour') return obj def setup_models(self): self.instance = FooModel()
<commit_before># -*- coding: utf-8 -*- from django.test import TestCase from ..registry import LinguistRegistry as Registry from ..models import Translation from . import settings from .translations import FooModel, FooTranslation class BaseTestCase(TestCase): """ Base test class mixin. """ @property def languages(self): return [language[0] for language in settings.LANGUAGES] @property def translation_en(self): obj, created = Translation.objects.get_or_create( identifier='foo', object_id=self.instance.pk, language='en', field_name='title', field_value='Hello') return obj @property def translation_fr(self): obj, created = Translation.objects.get_or_create( identifier='foo', object_id=self.instance.pk, language='fr', field_name='title', field_value='bonjour') return obj def create_registry(self): self.registry = Registry() self.registry.register(FooTranslation) self.instance = FooModel() <commit_msg>Update BaseTest class (removing registry).<commit_after>
# -*- coding: utf-8 -*- from django.test import TestCase from ..models import Translation from . import settings from .translations import FooModel class BaseTestCase(TestCase): """ Base test class mixin. """ @property def languages(self): return [language[0] for language in settings.LANGUAGES] @property def translation_en(self): obj, created = Translation.objects.get_or_create( identifier='foo', object_id=self.instance.pk, language='en', field_name='title', field_value='Hello') return obj @property def translation_fr(self): obj, created = Translation.objects.get_or_create( identifier='foo', object_id=self.instance.pk, language='fr', field_name='title', field_value='bonjour') return obj def setup_models(self): self.instance = FooModel()
# -*- coding: utf-8 -*- from django.test import TestCase from ..registry import LinguistRegistry as Registry from ..models import Translation from . import settings from .translations import FooModel, FooTranslation class BaseTestCase(TestCase): """ Base test class mixin. """ @property def languages(self): return [language[0] for language in settings.LANGUAGES] @property def translation_en(self): obj, created = Translation.objects.get_or_create( identifier='foo', object_id=self.instance.pk, language='en', field_name='title', field_value='Hello') return obj @property def translation_fr(self): obj, created = Translation.objects.get_or_create( identifier='foo', object_id=self.instance.pk, language='fr', field_name='title', field_value='bonjour') return obj def create_registry(self): self.registry = Registry() self.registry.register(FooTranslation) self.instance = FooModel() Update BaseTest class (removing registry).# -*- coding: utf-8 -*- from django.test import TestCase from ..models import Translation from . import settings from .translations import FooModel class BaseTestCase(TestCase): """ Base test class mixin. """ @property def languages(self): return [language[0] for language in settings.LANGUAGES] @property def translation_en(self): obj, created = Translation.objects.get_or_create( identifier='foo', object_id=self.instance.pk, language='en', field_name='title', field_value='Hello') return obj @property def translation_fr(self): obj, created = Translation.objects.get_or_create( identifier='foo', object_id=self.instance.pk, language='fr', field_name='title', field_value='bonjour') return obj def setup_models(self): self.instance = FooModel()
<commit_before># -*- coding: utf-8 -*- from django.test import TestCase from ..registry import LinguistRegistry as Registry from ..models import Translation from . import settings from .translations import FooModel, FooTranslation class BaseTestCase(TestCase): """ Base test class mixin. """ @property def languages(self): return [language[0] for language in settings.LANGUAGES] @property def translation_en(self): obj, created = Translation.objects.get_or_create( identifier='foo', object_id=self.instance.pk, language='en', field_name='title', field_value='Hello') return obj @property def translation_fr(self): obj, created = Translation.objects.get_or_create( identifier='foo', object_id=self.instance.pk, language='fr', field_name='title', field_value='bonjour') return obj def create_registry(self): self.registry = Registry() self.registry.register(FooTranslation) self.instance = FooModel() <commit_msg>Update BaseTest class (removing registry).<commit_after># -*- coding: utf-8 -*- from django.test import TestCase from ..models import Translation from . import settings from .translations import FooModel class BaseTestCase(TestCase): """ Base test class mixin. """ @property def languages(self): return [language[0] for language in settings.LANGUAGES] @property def translation_en(self): obj, created = Translation.objects.get_or_create( identifier='foo', object_id=self.instance.pk, language='en', field_name='title', field_value='Hello') return obj @property def translation_fr(self): obj, created = Translation.objects.get_or_create( identifier='foo', object_id=self.instance.pk, language='fr', field_name='title', field_value='bonjour') return obj def setup_models(self): self.instance = FooModel()
213a7a36bd599279d060edc053a86b602c9731b1
python/turbodbc_test/test_has_numpy_support.py
python/turbodbc_test/test_has_numpy_support.py
from mock import patch from turbodbc.cursor import _has_numpy_support def test_has_numpy_support_fails(): with patch('__builtin__.__import__', side_effect=ImportError): assert _has_numpy_support() == False def test_has_numpy_support_succeeds(): assert _has_numpy_support() == True
import six from mock import patch from turbodbc.cursor import _has_numpy_support # Python 2/3 compatibility _IMPORT_FUNCTION_NAME = "{}.__import__".format(six.moves.builtins.__name__) def test_has_numpy_support_fails(): with patch(_IMPORT_FUNCTION_NAME, side_effect=ImportError): assert _has_numpy_support() == False def test_has_numpy_support_succeeds(): assert _has_numpy_support() == True
Fix test issue with mocking import for Python 3
Fix test issue with mocking import for Python 3
Python
mit
blue-yonder/turbodbc,blue-yonder/turbodbc,blue-yonder/turbodbc,blue-yonder/turbodbc
from mock import patch from turbodbc.cursor import _has_numpy_support def test_has_numpy_support_fails(): with patch('__builtin__.__import__', side_effect=ImportError): assert _has_numpy_support() == False def test_has_numpy_support_succeeds(): assert _has_numpy_support() == TrueFix test issue with mocking import for Python 3
import six from mock import patch from turbodbc.cursor import _has_numpy_support # Python 2/3 compatibility _IMPORT_FUNCTION_NAME = "{}.__import__".format(six.moves.builtins.__name__) def test_has_numpy_support_fails(): with patch(_IMPORT_FUNCTION_NAME, side_effect=ImportError): assert _has_numpy_support() == False def test_has_numpy_support_succeeds(): assert _has_numpy_support() == True
<commit_before>from mock import patch from turbodbc.cursor import _has_numpy_support def test_has_numpy_support_fails(): with patch('__builtin__.__import__', side_effect=ImportError): assert _has_numpy_support() == False def test_has_numpy_support_succeeds(): assert _has_numpy_support() == True<commit_msg>Fix test issue with mocking import for Python 3<commit_after>
import six from mock import patch from turbodbc.cursor import _has_numpy_support # Python 2/3 compatibility _IMPORT_FUNCTION_NAME = "{}.__import__".format(six.moves.builtins.__name__) def test_has_numpy_support_fails(): with patch(_IMPORT_FUNCTION_NAME, side_effect=ImportError): assert _has_numpy_support() == False def test_has_numpy_support_succeeds(): assert _has_numpy_support() == True
from mock import patch from turbodbc.cursor import _has_numpy_support def test_has_numpy_support_fails(): with patch('__builtin__.__import__', side_effect=ImportError): assert _has_numpy_support() == False def test_has_numpy_support_succeeds(): assert _has_numpy_support() == TrueFix test issue with mocking import for Python 3import six from mock import patch from turbodbc.cursor import _has_numpy_support # Python 2/3 compatibility _IMPORT_FUNCTION_NAME = "{}.__import__".format(six.moves.builtins.__name__) def test_has_numpy_support_fails(): with patch(_IMPORT_FUNCTION_NAME, side_effect=ImportError): assert _has_numpy_support() == False def test_has_numpy_support_succeeds(): assert _has_numpy_support() == True
<commit_before>from mock import patch from turbodbc.cursor import _has_numpy_support def test_has_numpy_support_fails(): with patch('__builtin__.__import__', side_effect=ImportError): assert _has_numpy_support() == False def test_has_numpy_support_succeeds(): assert _has_numpy_support() == True<commit_msg>Fix test issue with mocking import for Python 3<commit_after>import six from mock import patch from turbodbc.cursor import _has_numpy_support # Python 2/3 compatibility _IMPORT_FUNCTION_NAME = "{}.__import__".format(six.moves.builtins.__name__) def test_has_numpy_support_fails(): with patch(_IMPORT_FUNCTION_NAME, side_effect=ImportError): assert _has_numpy_support() == False def test_has_numpy_support_succeeds(): assert _has_numpy_support() == True
254702c1b5a76701a1437d6dc3d732ec27ebaa81
backslash/api_object.py
backslash/api_object.py
class APIObject(object): def __init__(self, client, json_data): super(APIObject, self).__init__() self.client = client self._data = json_data def __eq__(self, other): if not isinstance(other, APIObject): return NotImplemented return self.client is other.client and self._data == other._data def __ne__(self, other): return not (self == other) def __getattr__(self, name): try: return self.__dict__['_data'][name] except KeyError: raise AttributeError(name) def refresh(self): self._data = self._fetch() def _fetch(self): return self.client.api.get(self.api_path, raw=True)[self._data['type']] def __repr__(self): return '<API:{data[type]}:{data[id]}>'.format(data=self._data)
class APIObject(object): def __init__(self, client, json_data): super(APIObject, self).__init__() self.client = client self._data = json_data def __eq__(self, other): if not isinstance(other, APIObject): return NotImplemented return self.client is other.client and self._data == other._data def __ne__(self, other): return not (self == other) def __getattr__(self, name): try: return self.__dict__['_data'][name] except KeyError: raise AttributeError(name) def refresh(self): self._data = self._fetch() return self def _fetch(self): return self.client.api.get(self.api_path, raw=True)[self._data['type']] def __repr__(self): return '<API:{data[type]}:{data[id]}>'.format(data=self._data)
Make `refresh` return self for chaining actions
Make `refresh` return self for chaining actions
Python
bsd-3-clause
slash-testing/backslash-python,vmalloc/backslash-python
class APIObject(object): def __init__(self, client, json_data): super(APIObject, self).__init__() self.client = client self._data = json_data def __eq__(self, other): if not isinstance(other, APIObject): return NotImplemented return self.client is other.client and self._data == other._data def __ne__(self, other): return not (self == other) def __getattr__(self, name): try: return self.__dict__['_data'][name] except KeyError: raise AttributeError(name) def refresh(self): self._data = self._fetch() def _fetch(self): return self.client.api.get(self.api_path, raw=True)[self._data['type']] def __repr__(self): return '<API:{data[type]}:{data[id]}>'.format(data=self._data) Make `refresh` return self for chaining actions
class APIObject(object): def __init__(self, client, json_data): super(APIObject, self).__init__() self.client = client self._data = json_data def __eq__(self, other): if not isinstance(other, APIObject): return NotImplemented return self.client is other.client and self._data == other._data def __ne__(self, other): return not (self == other) def __getattr__(self, name): try: return self.__dict__['_data'][name] except KeyError: raise AttributeError(name) def refresh(self): self._data = self._fetch() return self def _fetch(self): return self.client.api.get(self.api_path, raw=True)[self._data['type']] def __repr__(self): return '<API:{data[type]}:{data[id]}>'.format(data=self._data)
<commit_before> class APIObject(object): def __init__(self, client, json_data): super(APIObject, self).__init__() self.client = client self._data = json_data def __eq__(self, other): if not isinstance(other, APIObject): return NotImplemented return self.client is other.client and self._data == other._data def __ne__(self, other): return not (self == other) def __getattr__(self, name): try: return self.__dict__['_data'][name] except KeyError: raise AttributeError(name) def refresh(self): self._data = self._fetch() def _fetch(self): return self.client.api.get(self.api_path, raw=True)[self._data['type']] def __repr__(self): return '<API:{data[type]}:{data[id]}>'.format(data=self._data) <commit_msg>Make `refresh` return self for chaining actions<commit_after>
class APIObject(object): def __init__(self, client, json_data): super(APIObject, self).__init__() self.client = client self._data = json_data def __eq__(self, other): if not isinstance(other, APIObject): return NotImplemented return self.client is other.client and self._data == other._data def __ne__(self, other): return not (self == other) def __getattr__(self, name): try: return self.__dict__['_data'][name] except KeyError: raise AttributeError(name) def refresh(self): self._data = self._fetch() return self def _fetch(self): return self.client.api.get(self.api_path, raw=True)[self._data['type']] def __repr__(self): return '<API:{data[type]}:{data[id]}>'.format(data=self._data)
class APIObject(object): def __init__(self, client, json_data): super(APIObject, self).__init__() self.client = client self._data = json_data def __eq__(self, other): if not isinstance(other, APIObject): return NotImplemented return self.client is other.client and self._data == other._data def __ne__(self, other): return not (self == other) def __getattr__(self, name): try: return self.__dict__['_data'][name] except KeyError: raise AttributeError(name) def refresh(self): self._data = self._fetch() def _fetch(self): return self.client.api.get(self.api_path, raw=True)[self._data['type']] def __repr__(self): return '<API:{data[type]}:{data[id]}>'.format(data=self._data) Make `refresh` return self for chaining actions class APIObject(object): def __init__(self, client, json_data): super(APIObject, self).__init__() self.client = client self._data = json_data def __eq__(self, other): if not isinstance(other, APIObject): return NotImplemented return self.client is other.client and self._data == other._data def __ne__(self, other): return not (self == other) def __getattr__(self, name): try: return self.__dict__['_data'][name] except KeyError: raise AttributeError(name) def refresh(self): self._data = self._fetch() return self def _fetch(self): return self.client.api.get(self.api_path, raw=True)[self._data['type']] def __repr__(self): return '<API:{data[type]}:{data[id]}>'.format(data=self._data)
<commit_before> class APIObject(object): def __init__(self, client, json_data): super(APIObject, self).__init__() self.client = client self._data = json_data def __eq__(self, other): if not isinstance(other, APIObject): return NotImplemented return self.client is other.client and self._data == other._data def __ne__(self, other): return not (self == other) def __getattr__(self, name): try: return self.__dict__['_data'][name] except KeyError: raise AttributeError(name) def refresh(self): self._data = self._fetch() def _fetch(self): return self.client.api.get(self.api_path, raw=True)[self._data['type']] def __repr__(self): return '<API:{data[type]}:{data[id]}>'.format(data=self._data) <commit_msg>Make `refresh` return self for chaining actions<commit_after> class APIObject(object): def __init__(self, client, json_data): super(APIObject, self).__init__() self.client = client self._data = json_data def __eq__(self, other): if not isinstance(other, APIObject): return NotImplemented return self.client is other.client and self._data == other._data def __ne__(self, other): return not (self == other) def __getattr__(self, name): try: return self.__dict__['_data'][name] except KeyError: raise AttributeError(name) def refresh(self): self._data = self._fetch() return self def _fetch(self): return self.client.api.get(self.api_path, raw=True)[self._data['type']] def __repr__(self): return '<API:{data[type]}:{data[id]}>'.format(data=self._data)
8ee40b1cd12f5c39a239b911a2a04b293553f1f6
flasgger/__init__.py
flasgger/__init__.py
__version__ = '0.9.1.dev0' __author__ = 'Bruno Rocha' __email__ = 'rochacbruno@gmail.com' from jsonschema import ValidationError # noqa from .base import Swagger, Flasgger, NO_SANITIZER, BR_SANITIZER, MK_SANITIZER, LazyJSONEncoder # noqa from .utils import swag_from, validate, apispec_to_template, LazyString # noqa from .marshmallow_apispec import APISpec, SwaggerView, Schema, fields # noqa from .constants import OPTIONAL_FIELDS # noqa
__version__ = '0.9.1' __author__ = 'Bruno Rocha' __email__ = 'rochacbruno@gmail.com' from jsonschema import ValidationError # noqa from .base import Swagger, Flasgger, NO_SANITIZER, BR_SANITIZER, MK_SANITIZER, LazyJSONEncoder # noqa from .utils import swag_from, validate, apispec_to_template, LazyString # noqa from .marshmallow_apispec import APISpec, SwaggerView, Schema, fields # noqa from .constants import OPTIONAL_FIELDS # noqa
Set __version__ to 0.9.1 for release.
Set __version__ to 0.9.1 for release.
Python
mit
rochacbruno/flasgger,flasgger/flasgger,flasgger/flasgger,rochacbruno/flasgger,rochacbruno/flasgger,flasgger/flasgger,flasgger/flasgger
__version__ = '0.9.1.dev0' __author__ = 'Bruno Rocha' __email__ = 'rochacbruno@gmail.com' from jsonschema import ValidationError # noqa from .base import Swagger, Flasgger, NO_SANITIZER, BR_SANITIZER, MK_SANITIZER, LazyJSONEncoder # noqa from .utils import swag_from, validate, apispec_to_template, LazyString # noqa from .marshmallow_apispec import APISpec, SwaggerView, Schema, fields # noqa from .constants import OPTIONAL_FIELDS # noqa Set __version__ to 0.9.1 for release.
__version__ = '0.9.1' __author__ = 'Bruno Rocha' __email__ = 'rochacbruno@gmail.com' from jsonschema import ValidationError # noqa from .base import Swagger, Flasgger, NO_SANITIZER, BR_SANITIZER, MK_SANITIZER, LazyJSONEncoder # noqa from .utils import swag_from, validate, apispec_to_template, LazyString # noqa from .marshmallow_apispec import APISpec, SwaggerView, Schema, fields # noqa from .constants import OPTIONAL_FIELDS # noqa
<commit_before> __version__ = '0.9.1.dev0' __author__ = 'Bruno Rocha' __email__ = 'rochacbruno@gmail.com' from jsonschema import ValidationError # noqa from .base import Swagger, Flasgger, NO_SANITIZER, BR_SANITIZER, MK_SANITIZER, LazyJSONEncoder # noqa from .utils import swag_from, validate, apispec_to_template, LazyString # noqa from .marshmallow_apispec import APISpec, SwaggerView, Schema, fields # noqa from .constants import OPTIONAL_FIELDS # noqa <commit_msg>Set __version__ to 0.9.1 for release.<commit_after>
__version__ = '0.9.1' __author__ = 'Bruno Rocha' __email__ = 'rochacbruno@gmail.com' from jsonschema import ValidationError # noqa from .base import Swagger, Flasgger, NO_SANITIZER, BR_SANITIZER, MK_SANITIZER, LazyJSONEncoder # noqa from .utils import swag_from, validate, apispec_to_template, LazyString # noqa from .marshmallow_apispec import APISpec, SwaggerView, Schema, fields # noqa from .constants import OPTIONAL_FIELDS # noqa
__version__ = '0.9.1.dev0' __author__ = 'Bruno Rocha' __email__ = 'rochacbruno@gmail.com' from jsonschema import ValidationError # noqa from .base import Swagger, Flasgger, NO_SANITIZER, BR_SANITIZER, MK_SANITIZER, LazyJSONEncoder # noqa from .utils import swag_from, validate, apispec_to_template, LazyString # noqa from .marshmallow_apispec import APISpec, SwaggerView, Schema, fields # noqa from .constants import OPTIONAL_FIELDS # noqa Set __version__ to 0.9.1 for release. __version__ = '0.9.1' __author__ = 'Bruno Rocha' __email__ = 'rochacbruno@gmail.com' from jsonschema import ValidationError # noqa from .base import Swagger, Flasgger, NO_SANITIZER, BR_SANITIZER, MK_SANITIZER, LazyJSONEncoder # noqa from .utils import swag_from, validate, apispec_to_template, LazyString # noqa from .marshmallow_apispec import APISpec, SwaggerView, Schema, fields # noqa from .constants import OPTIONAL_FIELDS # noqa
<commit_before> __version__ = '0.9.1.dev0' __author__ = 'Bruno Rocha' __email__ = 'rochacbruno@gmail.com' from jsonschema import ValidationError # noqa from .base import Swagger, Flasgger, NO_SANITIZER, BR_SANITIZER, MK_SANITIZER, LazyJSONEncoder # noqa from .utils import swag_from, validate, apispec_to_template, LazyString # noqa from .marshmallow_apispec import APISpec, SwaggerView, Schema, fields # noqa from .constants import OPTIONAL_FIELDS # noqa <commit_msg>Set __version__ to 0.9.1 for release.<commit_after> __version__ = '0.9.1' __author__ = 'Bruno Rocha' __email__ = 'rochacbruno@gmail.com' from jsonschema import ValidationError # noqa from .base import Swagger, Flasgger, NO_SANITIZER, BR_SANITIZER, MK_SANITIZER, LazyJSONEncoder # noqa from .utils import swag_from, validate, apispec_to_template, LazyString # noqa from .marshmallow_apispec import APISpec, SwaggerView, Schema, fields # noqa from .constants import OPTIONAL_FIELDS # noqa
35e0d3e5f275c79a80aa843700f621da59fefd6b
scripts/environment.py
scripts/environment.py
import json import logging import os log_format = "[{levelname}][{name}] {message}" def configure_logging(log_level): logging.basicConfig(level = log_level, format = log_format, style = "{") logging.addLevelName(logging.DEBUG, "Debug") logging.addLevelName(logging.INFO, "Info") logging.addLevelName(logging.WARNING, "Warning") logging.addLevelName(logging.ERROR, "Error") logging.addLevelName(logging.CRITICAL, "Critical") logging.getLogger("werkzeug").setLevel(logging.WARNING) def create_default_environment(): return { "git_executable": "git", "python3_executable": "python3", "scp_executable": "scp", "ssh_executable": "ssh", } def load_environment(): env = create_default_environment() env.update(_load_environment_transform(os.path.join(os.path.expanduser("~"), "environment.json"))) env.update(_load_environment_transform("environment.json")) return env def _load_environment_transform(transform_file_path): if not os.path.exists(transform_file_path): return {} with open(transform_file_path) as transform_file: return json.load(transform_file)
import json import logging import os import sys log_format = "[{levelname}][{name}] {message}" def configure_logging(log_level): logging.basicConfig(level = log_level, format = log_format, style = "{") logging.addLevelName(logging.DEBUG, "Debug") logging.addLevelName(logging.INFO, "Info") logging.addLevelName(logging.WARNING, "Warning") logging.addLevelName(logging.ERROR, "Error") logging.addLevelName(logging.CRITICAL, "Critical") logging.getLogger("werkzeug").setLevel(logging.WARNING) def create_default_environment(): return { "git_executable": "git", "python3_executable": sys.executable, "scp_executable": "scp", "ssh_executable": "ssh", } def load_environment(): env = create_default_environment() env.update(_load_environment_transform(os.path.join(os.path.expanduser("~"), "environment.json"))) env.update(_load_environment_transform("environment.json")) return env def _load_environment_transform(transform_file_path): if not os.path.exists(transform_file_path): return {} with open(transform_file_path) as transform_file: return json.load(transform_file)
Use sys.executable as the default python executable
Use sys.executable as the default python executable
Python
mit
BenjaminHamon/MyWebsite,BenjaminHamon/MyWebsite
import json import logging import os log_format = "[{levelname}][{name}] {message}" def configure_logging(log_level): logging.basicConfig(level = log_level, format = log_format, style = "{") logging.addLevelName(logging.DEBUG, "Debug") logging.addLevelName(logging.INFO, "Info") logging.addLevelName(logging.WARNING, "Warning") logging.addLevelName(logging.ERROR, "Error") logging.addLevelName(logging.CRITICAL, "Critical") logging.getLogger("werkzeug").setLevel(logging.WARNING) def create_default_environment(): return { "git_executable": "git", "python3_executable": "python3", "scp_executable": "scp", "ssh_executable": "ssh", } def load_environment(): env = create_default_environment() env.update(_load_environment_transform(os.path.join(os.path.expanduser("~"), "environment.json"))) env.update(_load_environment_transform("environment.json")) return env def _load_environment_transform(transform_file_path): if not os.path.exists(transform_file_path): return {} with open(transform_file_path) as transform_file: return json.load(transform_file) Use sys.executable as the default python executable
import json import logging import os import sys log_format = "[{levelname}][{name}] {message}" def configure_logging(log_level): logging.basicConfig(level = log_level, format = log_format, style = "{") logging.addLevelName(logging.DEBUG, "Debug") logging.addLevelName(logging.INFO, "Info") logging.addLevelName(logging.WARNING, "Warning") logging.addLevelName(logging.ERROR, "Error") logging.addLevelName(logging.CRITICAL, "Critical") logging.getLogger("werkzeug").setLevel(logging.WARNING) def create_default_environment(): return { "git_executable": "git", "python3_executable": sys.executable, "scp_executable": "scp", "ssh_executable": "ssh", } def load_environment(): env = create_default_environment() env.update(_load_environment_transform(os.path.join(os.path.expanduser("~"), "environment.json"))) env.update(_load_environment_transform("environment.json")) return env def _load_environment_transform(transform_file_path): if not os.path.exists(transform_file_path): return {} with open(transform_file_path) as transform_file: return json.load(transform_file)
<commit_before>import json import logging import os log_format = "[{levelname}][{name}] {message}" def configure_logging(log_level): logging.basicConfig(level = log_level, format = log_format, style = "{") logging.addLevelName(logging.DEBUG, "Debug") logging.addLevelName(logging.INFO, "Info") logging.addLevelName(logging.WARNING, "Warning") logging.addLevelName(logging.ERROR, "Error") logging.addLevelName(logging.CRITICAL, "Critical") logging.getLogger("werkzeug").setLevel(logging.WARNING) def create_default_environment(): return { "git_executable": "git", "python3_executable": "python3", "scp_executable": "scp", "ssh_executable": "ssh", } def load_environment(): env = create_default_environment() env.update(_load_environment_transform(os.path.join(os.path.expanduser("~"), "environment.json"))) env.update(_load_environment_transform("environment.json")) return env def _load_environment_transform(transform_file_path): if not os.path.exists(transform_file_path): return {} with open(transform_file_path) as transform_file: return json.load(transform_file) <commit_msg>Use sys.executable as the default python executable<commit_after>
import json import logging import os import sys log_format = "[{levelname}][{name}] {message}" def configure_logging(log_level): logging.basicConfig(level = log_level, format = log_format, style = "{") logging.addLevelName(logging.DEBUG, "Debug") logging.addLevelName(logging.INFO, "Info") logging.addLevelName(logging.WARNING, "Warning") logging.addLevelName(logging.ERROR, "Error") logging.addLevelName(logging.CRITICAL, "Critical") logging.getLogger("werkzeug").setLevel(logging.WARNING) def create_default_environment(): return { "git_executable": "git", "python3_executable": sys.executable, "scp_executable": "scp", "ssh_executable": "ssh", } def load_environment(): env = create_default_environment() env.update(_load_environment_transform(os.path.join(os.path.expanduser("~"), "environment.json"))) env.update(_load_environment_transform("environment.json")) return env def _load_environment_transform(transform_file_path): if not os.path.exists(transform_file_path): return {} with open(transform_file_path) as transform_file: return json.load(transform_file)
import json import logging import os log_format = "[{levelname}][{name}] {message}" def configure_logging(log_level): logging.basicConfig(level = log_level, format = log_format, style = "{") logging.addLevelName(logging.DEBUG, "Debug") logging.addLevelName(logging.INFO, "Info") logging.addLevelName(logging.WARNING, "Warning") logging.addLevelName(logging.ERROR, "Error") logging.addLevelName(logging.CRITICAL, "Critical") logging.getLogger("werkzeug").setLevel(logging.WARNING) def create_default_environment(): return { "git_executable": "git", "python3_executable": "python3", "scp_executable": "scp", "ssh_executable": "ssh", } def load_environment(): env = create_default_environment() env.update(_load_environment_transform(os.path.join(os.path.expanduser("~"), "environment.json"))) env.update(_load_environment_transform("environment.json")) return env def _load_environment_transform(transform_file_path): if not os.path.exists(transform_file_path): return {} with open(transform_file_path) as transform_file: return json.load(transform_file) Use sys.executable as the default python executableimport json import logging import os import sys log_format = "[{levelname}][{name}] {message}" def configure_logging(log_level): logging.basicConfig(level = log_level, format = log_format, style = "{") logging.addLevelName(logging.DEBUG, "Debug") logging.addLevelName(logging.INFO, "Info") logging.addLevelName(logging.WARNING, "Warning") logging.addLevelName(logging.ERROR, "Error") logging.addLevelName(logging.CRITICAL, "Critical") logging.getLogger("werkzeug").setLevel(logging.WARNING) def create_default_environment(): return { "git_executable": "git", "python3_executable": sys.executable, "scp_executable": "scp", "ssh_executable": "ssh", } def load_environment(): env = create_default_environment() env.update(_load_environment_transform(os.path.join(os.path.expanduser("~"), "environment.json"))) env.update(_load_environment_transform("environment.json")) return env def _load_environment_transform(transform_file_path): if not os.path.exists(transform_file_path): return {} with open(transform_file_path) as transform_file: return json.load(transform_file)
<commit_before>import json import logging import os log_format = "[{levelname}][{name}] {message}" def configure_logging(log_level): logging.basicConfig(level = log_level, format = log_format, style = "{") logging.addLevelName(logging.DEBUG, "Debug") logging.addLevelName(logging.INFO, "Info") logging.addLevelName(logging.WARNING, "Warning") logging.addLevelName(logging.ERROR, "Error") logging.addLevelName(logging.CRITICAL, "Critical") logging.getLogger("werkzeug").setLevel(logging.WARNING) def create_default_environment(): return { "git_executable": "git", "python3_executable": "python3", "scp_executable": "scp", "ssh_executable": "ssh", } def load_environment(): env = create_default_environment() env.update(_load_environment_transform(os.path.join(os.path.expanduser("~"), "environment.json"))) env.update(_load_environment_transform("environment.json")) return env def _load_environment_transform(transform_file_path): if not os.path.exists(transform_file_path): return {} with open(transform_file_path) as transform_file: return json.load(transform_file) <commit_msg>Use sys.executable as the default python executable<commit_after>import json import logging import os import sys log_format = "[{levelname}][{name}] {message}" def configure_logging(log_level): logging.basicConfig(level = log_level, format = log_format, style = "{") logging.addLevelName(logging.DEBUG, "Debug") logging.addLevelName(logging.INFO, "Info") logging.addLevelName(logging.WARNING, "Warning") logging.addLevelName(logging.ERROR, "Error") logging.addLevelName(logging.CRITICAL, "Critical") logging.getLogger("werkzeug").setLevel(logging.WARNING) def create_default_environment(): return { "git_executable": "git", "python3_executable": sys.executable, "scp_executable": "scp", "ssh_executable": "ssh", } def load_environment(): env = create_default_environment() env.update(_load_environment_transform(os.path.join(os.path.expanduser("~"), "environment.json"))) env.update(_load_environment_transform("environment.json")) return env def _load_environment_transform(transform_file_path): if not os.path.exists(transform_file_path): return {} with open(transform_file_path) as transform_file: return json.load(transform_file)
01aa219b0058cbfbdb96e890f510fa275f3ef790
python/Completion.py
python/Completion.py
import vim, syncrequest, types class Completion: def get_completions(self, column, partialWord): parameters = {} parameters['column'] = vim.eval(column) parameters['wordToComplete'] = vim.eval(partialWord) parameters['WantDocumentationForEveryCompletionResult'] = \ bool(int(vim.eval('g:omnicomplete_fetch_full_documentation'))) want_snippet = \ bool(int(vim.eval('g:OmniSharp_want_snippet'))) parameters['WantSnippet'] = want_snippet parameters['WantMethodHeader'] = want_snippet parameters['WantReturnType'] = want_snippet parameters['buffer'] = '\r\n'.join(vim.eval('s:textBuffer')[:]) response = syncrequest.get_response('/autocomplete', parameters) enc = vim.eval('&encoding') vim_completions = [] if response is not None: for completion in response: complete = { 'snip': completion['Snippet'] if completion['Snippet'] is not None else '', 'word': completion['MethodHeader'] if completion['MethodHeader'] is not None else completion['CompletionText'], 'menu': completion['ReturnType'] if completion['ReturnType'] is not None else completion['DisplayText'], 'info': completion['Description'].replace('\r\n', '\n') if completion['Description'] is not None else '', 'icase': 1, 'dup':1 } vim_completions.append(complete) return vim_completions
import vim, syncrequest, types class Completion: def get_completions(self, column, partialWord): parameters = {} parameters['column'] = vim.eval(column) parameters['wordToComplete'] = vim.eval(partialWord) parameters['WantDocumentationForEveryCompletionResult'] = \ bool(int(vim.eval('g:omnicomplete_fetch_full_documentation'))) want_snippet = \ bool(int(vim.eval('g:OmniSharp_want_snippet'))) parameters['WantSnippet'] = want_snippet parameters['WantMethodHeader'] = want_snippet parameters['WantReturnType'] = want_snippet parameters['buffer'] = '\r\n'.join(vim.eval('s:textBuffer')[:]) response = syncrequest.get_response('/autocomplete', parameters) enc = vim.eval('&encoding') vim_completions = [] if response is not None: for completion in response: complete = { 'snip': completion['Snippet'] or '', 'word': completion['MethodHeader'] or completion['CompletionText'], 'menu': completion['ReturnType'] or completion['DisplayText'], 'info': completion['Description'].replace('\r\n', '\n') or '', 'icase': 1, 'dup':1 } vim_completions.append(complete) return vim_completions
Use or operator in python to tidy up completion building.
Use or operator in python to tidy up completion building.
Python
mit
OmniSharp/omnisharp-vim,OmniSharp/omnisharp-vim,OmniSharp/omnisharp-vim
import vim, syncrequest, types class Completion: def get_completions(self, column, partialWord): parameters = {} parameters['column'] = vim.eval(column) parameters['wordToComplete'] = vim.eval(partialWord) parameters['WantDocumentationForEveryCompletionResult'] = \ bool(int(vim.eval('g:omnicomplete_fetch_full_documentation'))) want_snippet = \ bool(int(vim.eval('g:OmniSharp_want_snippet'))) parameters['WantSnippet'] = want_snippet parameters['WantMethodHeader'] = want_snippet parameters['WantReturnType'] = want_snippet parameters['buffer'] = '\r\n'.join(vim.eval('s:textBuffer')[:]) response = syncrequest.get_response('/autocomplete', parameters) enc = vim.eval('&encoding') vim_completions = [] if response is not None: for completion in response: complete = { 'snip': completion['Snippet'] if completion['Snippet'] is not None else '', 'word': completion['MethodHeader'] if completion['MethodHeader'] is not None else completion['CompletionText'], 'menu': completion['ReturnType'] if completion['ReturnType'] is not None else completion['DisplayText'], 'info': completion['Description'].replace('\r\n', '\n') if completion['Description'] is not None else '', 'icase': 1, 'dup':1 } vim_completions.append(complete) return vim_completions Use or operator in python to tidy up completion building.
import vim, syncrequest, types class Completion: def get_completions(self, column, partialWord): parameters = {} parameters['column'] = vim.eval(column) parameters['wordToComplete'] = vim.eval(partialWord) parameters['WantDocumentationForEveryCompletionResult'] = \ bool(int(vim.eval('g:omnicomplete_fetch_full_documentation'))) want_snippet = \ bool(int(vim.eval('g:OmniSharp_want_snippet'))) parameters['WantSnippet'] = want_snippet parameters['WantMethodHeader'] = want_snippet parameters['WantReturnType'] = want_snippet parameters['buffer'] = '\r\n'.join(vim.eval('s:textBuffer')[:]) response = syncrequest.get_response('/autocomplete', parameters) enc = vim.eval('&encoding') vim_completions = [] if response is not None: for completion in response: complete = { 'snip': completion['Snippet'] or '', 'word': completion['MethodHeader'] or completion['CompletionText'], 'menu': completion['ReturnType'] or completion['DisplayText'], 'info': completion['Description'].replace('\r\n', '\n') or '', 'icase': 1, 'dup':1 } vim_completions.append(complete) return vim_completions
<commit_before>import vim, syncrequest, types class Completion: def get_completions(self, column, partialWord): parameters = {} parameters['column'] = vim.eval(column) parameters['wordToComplete'] = vim.eval(partialWord) parameters['WantDocumentationForEveryCompletionResult'] = \ bool(int(vim.eval('g:omnicomplete_fetch_full_documentation'))) want_snippet = \ bool(int(vim.eval('g:OmniSharp_want_snippet'))) parameters['WantSnippet'] = want_snippet parameters['WantMethodHeader'] = want_snippet parameters['WantReturnType'] = want_snippet parameters['buffer'] = '\r\n'.join(vim.eval('s:textBuffer')[:]) response = syncrequest.get_response('/autocomplete', parameters) enc = vim.eval('&encoding') vim_completions = [] if response is not None: for completion in response: complete = { 'snip': completion['Snippet'] if completion['Snippet'] is not None else '', 'word': completion['MethodHeader'] if completion['MethodHeader'] is not None else completion['CompletionText'], 'menu': completion['ReturnType'] if completion['ReturnType'] is not None else completion['DisplayText'], 'info': completion['Description'].replace('\r\n', '\n') if completion['Description'] is not None else '', 'icase': 1, 'dup':1 } vim_completions.append(complete) return vim_completions <commit_msg>Use or operator in python to tidy up completion building.<commit_after>
import vim, syncrequest, types class Completion: def get_completions(self, column, partialWord): parameters = {} parameters['column'] = vim.eval(column) parameters['wordToComplete'] = vim.eval(partialWord) parameters['WantDocumentationForEveryCompletionResult'] = \ bool(int(vim.eval('g:omnicomplete_fetch_full_documentation'))) want_snippet = \ bool(int(vim.eval('g:OmniSharp_want_snippet'))) parameters['WantSnippet'] = want_snippet parameters['WantMethodHeader'] = want_snippet parameters['WantReturnType'] = want_snippet parameters['buffer'] = '\r\n'.join(vim.eval('s:textBuffer')[:]) response = syncrequest.get_response('/autocomplete', parameters) enc = vim.eval('&encoding') vim_completions = [] if response is not None: for completion in response: complete = { 'snip': completion['Snippet'] or '', 'word': completion['MethodHeader'] or completion['CompletionText'], 'menu': completion['ReturnType'] or completion['DisplayText'], 'info': completion['Description'].replace('\r\n', '\n') or '', 'icase': 1, 'dup':1 } vim_completions.append(complete) return vim_completions
import vim, syncrequest, types class Completion: def get_completions(self, column, partialWord): parameters = {} parameters['column'] = vim.eval(column) parameters['wordToComplete'] = vim.eval(partialWord) parameters['WantDocumentationForEveryCompletionResult'] = \ bool(int(vim.eval('g:omnicomplete_fetch_full_documentation'))) want_snippet = \ bool(int(vim.eval('g:OmniSharp_want_snippet'))) parameters['WantSnippet'] = want_snippet parameters['WantMethodHeader'] = want_snippet parameters['WantReturnType'] = want_snippet parameters['buffer'] = '\r\n'.join(vim.eval('s:textBuffer')[:]) response = syncrequest.get_response('/autocomplete', parameters) enc = vim.eval('&encoding') vim_completions = [] if response is not None: for completion in response: complete = { 'snip': completion['Snippet'] if completion['Snippet'] is not None else '', 'word': completion['MethodHeader'] if completion['MethodHeader'] is not None else completion['CompletionText'], 'menu': completion['ReturnType'] if completion['ReturnType'] is not None else completion['DisplayText'], 'info': completion['Description'].replace('\r\n', '\n') if completion['Description'] is not None else '', 'icase': 1, 'dup':1 } vim_completions.append(complete) return vim_completions Use or operator in python to tidy up completion building.import vim, syncrequest, types class Completion: def get_completions(self, column, partialWord): parameters = {} parameters['column'] = vim.eval(column) parameters['wordToComplete'] = vim.eval(partialWord) parameters['WantDocumentationForEveryCompletionResult'] = \ bool(int(vim.eval('g:omnicomplete_fetch_full_documentation'))) want_snippet = \ bool(int(vim.eval('g:OmniSharp_want_snippet'))) parameters['WantSnippet'] = want_snippet parameters['WantMethodHeader'] = want_snippet parameters['WantReturnType'] = want_snippet parameters['buffer'] = '\r\n'.join(vim.eval('s:textBuffer')[:]) response = syncrequest.get_response('/autocomplete', parameters) enc = vim.eval('&encoding') vim_completions = [] if response is not None: for completion in response: complete = { 'snip': completion['Snippet'] or '', 'word': completion['MethodHeader'] or completion['CompletionText'], 'menu': completion['ReturnType'] or completion['DisplayText'], 'info': completion['Description'].replace('\r\n', '\n') or '', 'icase': 1, 'dup':1 } vim_completions.append(complete) return vim_completions
<commit_before>import vim, syncrequest, types class Completion: def get_completions(self, column, partialWord): parameters = {} parameters['column'] = vim.eval(column) parameters['wordToComplete'] = vim.eval(partialWord) parameters['WantDocumentationForEveryCompletionResult'] = \ bool(int(vim.eval('g:omnicomplete_fetch_full_documentation'))) want_snippet = \ bool(int(vim.eval('g:OmniSharp_want_snippet'))) parameters['WantSnippet'] = want_snippet parameters['WantMethodHeader'] = want_snippet parameters['WantReturnType'] = want_snippet parameters['buffer'] = '\r\n'.join(vim.eval('s:textBuffer')[:]) response = syncrequest.get_response('/autocomplete', parameters) enc = vim.eval('&encoding') vim_completions = [] if response is not None: for completion in response: complete = { 'snip': completion['Snippet'] if completion['Snippet'] is not None else '', 'word': completion['MethodHeader'] if completion['MethodHeader'] is not None else completion['CompletionText'], 'menu': completion['ReturnType'] if completion['ReturnType'] is not None else completion['DisplayText'], 'info': completion['Description'].replace('\r\n', '\n') if completion['Description'] is not None else '', 'icase': 1, 'dup':1 } vim_completions.append(complete) return vim_completions <commit_msg>Use or operator in python to tidy up completion building.<commit_after>import vim, syncrequest, types class Completion: def get_completions(self, column, partialWord): parameters = {} parameters['column'] = vim.eval(column) parameters['wordToComplete'] = vim.eval(partialWord) parameters['WantDocumentationForEveryCompletionResult'] = \ bool(int(vim.eval('g:omnicomplete_fetch_full_documentation'))) want_snippet = \ bool(int(vim.eval('g:OmniSharp_want_snippet'))) parameters['WantSnippet'] = want_snippet parameters['WantMethodHeader'] = want_snippet parameters['WantReturnType'] = want_snippet parameters['buffer'] = '\r\n'.join(vim.eval('s:textBuffer')[:]) response = syncrequest.get_response('/autocomplete', parameters) enc = vim.eval('&encoding') vim_completions = [] if response is not None: for completion in response: complete = { 'snip': completion['Snippet'] or '', 'word': completion['MethodHeader'] or completion['CompletionText'], 'menu': completion['ReturnType'] or completion['DisplayText'], 'info': completion['Description'].replace('\r\n', '\n') or '', 'icase': 1, 'dup':1 } vim_completions.append(complete) return vim_completions
76dd8c7b000a97b4c6b808d69294e5f1d3eee3e4
rdmo/core/exports.py
rdmo/core/exports.py
from xml.dom.minidom import parseString from django.http import HttpResponse class XMLResponse(HttpResponse): def __init__(self, xml, name=None): super().__init__(prettify_xml(xml), content_type='application/xml') if name: self['Content-Disposition'] = 'filename="{}.xml"'.format(name) def prettify_xml(xmlstring): xmlobj = parseString(xmlstring) return xmlobj.toprettyxml()
from xml.dom.minidom import parseString from django.http import HttpResponse class XMLResponse(HttpResponse): def __init__(self, xml, name=None): super().__init__(prettify_xml(xml), content_type='application/xml') if name: self['Content-Disposition'] = 'filename="{}.xml"'.format(name) def prettify_xml(xmlstring): xmlobj = parseString(xmlstring) return xmlobj.toprettyxml( indent='\t', newl='\n', encoding='UTF-8' )
Add explicit xml export options (indent, new line and encoding)
Add explicit xml export options (indent, new line and encoding)
Python
apache-2.0
rdmorganiser/rdmo,rdmorganiser/rdmo,rdmorganiser/rdmo
from xml.dom.minidom import parseString from django.http import HttpResponse class XMLResponse(HttpResponse): def __init__(self, xml, name=None): super().__init__(prettify_xml(xml), content_type='application/xml') if name: self['Content-Disposition'] = 'filename="{}.xml"'.format(name) def prettify_xml(xmlstring): xmlobj = parseString(xmlstring) return xmlobj.toprettyxml() Add explicit xml export options (indent, new line and encoding)
from xml.dom.minidom import parseString from django.http import HttpResponse class XMLResponse(HttpResponse): def __init__(self, xml, name=None): super().__init__(prettify_xml(xml), content_type='application/xml') if name: self['Content-Disposition'] = 'filename="{}.xml"'.format(name) def prettify_xml(xmlstring): xmlobj = parseString(xmlstring) return xmlobj.toprettyxml( indent='\t', newl='\n', encoding='UTF-8' )
<commit_before>from xml.dom.minidom import parseString from django.http import HttpResponse class XMLResponse(HttpResponse): def __init__(self, xml, name=None): super().__init__(prettify_xml(xml), content_type='application/xml') if name: self['Content-Disposition'] = 'filename="{}.xml"'.format(name) def prettify_xml(xmlstring): xmlobj = parseString(xmlstring) return xmlobj.toprettyxml() <commit_msg>Add explicit xml export options (indent, new line and encoding)<commit_after>
from xml.dom.minidom import parseString from django.http import HttpResponse class XMLResponse(HttpResponse): def __init__(self, xml, name=None): super().__init__(prettify_xml(xml), content_type='application/xml') if name: self['Content-Disposition'] = 'filename="{}.xml"'.format(name) def prettify_xml(xmlstring): xmlobj = parseString(xmlstring) return xmlobj.toprettyxml( indent='\t', newl='\n', encoding='UTF-8' )
from xml.dom.minidom import parseString from django.http import HttpResponse class XMLResponse(HttpResponse): def __init__(self, xml, name=None): super().__init__(prettify_xml(xml), content_type='application/xml') if name: self['Content-Disposition'] = 'filename="{}.xml"'.format(name) def prettify_xml(xmlstring): xmlobj = parseString(xmlstring) return xmlobj.toprettyxml() Add explicit xml export options (indent, new line and encoding)from xml.dom.minidom import parseString from django.http import HttpResponse class XMLResponse(HttpResponse): def __init__(self, xml, name=None): super().__init__(prettify_xml(xml), content_type='application/xml') if name: self['Content-Disposition'] = 'filename="{}.xml"'.format(name) def prettify_xml(xmlstring): xmlobj = parseString(xmlstring) return xmlobj.toprettyxml( indent='\t', newl='\n', encoding='UTF-8' )
<commit_before>from xml.dom.minidom import parseString from django.http import HttpResponse class XMLResponse(HttpResponse): def __init__(self, xml, name=None): super().__init__(prettify_xml(xml), content_type='application/xml') if name: self['Content-Disposition'] = 'filename="{}.xml"'.format(name) def prettify_xml(xmlstring): xmlobj = parseString(xmlstring) return xmlobj.toprettyxml() <commit_msg>Add explicit xml export options (indent, new line and encoding)<commit_after>from xml.dom.minidom import parseString from django.http import HttpResponse class XMLResponse(HttpResponse): def __init__(self, xml, name=None): super().__init__(prettify_xml(xml), content_type='application/xml') if name: self['Content-Disposition'] = 'filename="{}.xml"'.format(name) def prettify_xml(xmlstring): xmlobj = parseString(xmlstring) return xmlobj.toprettyxml( indent='\t', newl='\n', encoding='UTF-8' )
aef60d17607a0819e24a2a61304bd5ca38289d50
scripts/slave/dart/dart_util.py
scripts/slave/dart/dart_util.py
#!/usr/bin/python # Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """Utils for the dart project. """ import optparse import os import sys from common import chromium_utils def clobber(): print('Clobbereing platform: %s' % sys.platform) if sys.platform in ('win32'): release_dir = os.path.abspath('ReleaseIA32') print('Removing directory %s' % release_dir) chromium_utils.RemoveDirectory(release_dir) debug_dir = os.path.abspath('DebugIA32') print('Removing directory %s' % debug_dir) chromium_utils.RemoveDirectory(debug_dir) elif sys.platform in ('linux2'): out_dir = os.path.abspath('out') print('Removing directory %s' % out_dir) chromium_utils.RemoveDirectory(out_dir) elif sys.platform.startswith('darwin'): xcode_dir = os.path.abspath('xcodebuild') print('Removing directory %s' % xcode_dir) chromium_utils.RemoveDirectory(xcode_dir) else: print("Platform not recognized") return 0 def main(): parser = optparse.OptionParser() parser.add_option('', '--clobber', default=False, action='store_true', help='Clobber the builder') options, args = parser.parse_args() # args unused, use. args.append('') # Determine what to do based on options passed in. if options.clobber: return clobber() else: print("Nothing to do") if '__main__' == __name__ : sys.exit(main())
#!/usr/bin/python # Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """Utils for the dart project. """ import optparse import subprocess import sys def clobber(): cmd = [sys.executable, './tools/clean_output_directory.py', '--mode=all'] print 'Clobbering %s' % (' '.join(cmd)) return subprocess.call(cmd) def main(): parser = optparse.OptionParser() parser.add_option('', '--clobber', default=False, action='store_true', help='Clobber the builder') options, args = parser.parse_args() # args unused, use. args.append('') # Determine what to do based on options passed in. if options.clobber: return clobber() else: print("Nothing to do") if '__main__' == __name__ : sys.exit(main())
Use the new tools/clean_output_directory.py script for clobbering builders.
Use the new tools/clean_output_directory.py script for clobbering builders. This will unify our clobbering functionality across builders that use annotated steps and builders with test setup in the buildbot source. TBR=foo Review URL: https://chromiumcodereview.appspot.com/10834305 git-svn-id: 239fca9b83025a0b6f823aeeca02ba5be3d9fd76@151464 0039d316-1c4b-4281-b951-d872f2087c98
Python
bsd-3-clause
eunchong/build,eunchong/build,eunchong/build,eunchong/build
#!/usr/bin/python # Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """Utils for the dart project. """ import optparse import os import sys from common import chromium_utils def clobber(): print('Clobbereing platform: %s' % sys.platform) if sys.platform in ('win32'): release_dir = os.path.abspath('ReleaseIA32') print('Removing directory %s' % release_dir) chromium_utils.RemoveDirectory(release_dir) debug_dir = os.path.abspath('DebugIA32') print('Removing directory %s' % debug_dir) chromium_utils.RemoveDirectory(debug_dir) elif sys.platform in ('linux2'): out_dir = os.path.abspath('out') print('Removing directory %s' % out_dir) chromium_utils.RemoveDirectory(out_dir) elif sys.platform.startswith('darwin'): xcode_dir = os.path.abspath('xcodebuild') print('Removing directory %s' % xcode_dir) chromium_utils.RemoveDirectory(xcode_dir) else: print("Platform not recognized") return 0 def main(): parser = optparse.OptionParser() parser.add_option('', '--clobber', default=False, action='store_true', help='Clobber the builder') options, args = parser.parse_args() # args unused, use. args.append('') # Determine what to do based on options passed in. if options.clobber: return clobber() else: print("Nothing to do") if '__main__' == __name__ : sys.exit(main()) Use the new tools/clean_output_directory.py script for clobbering builders. This will unify our clobbering functionality across builders that use annotated steps and builders with test setup in the buildbot source. TBR=foo Review URL: https://chromiumcodereview.appspot.com/10834305 git-svn-id: 239fca9b83025a0b6f823aeeca02ba5be3d9fd76@151464 0039d316-1c4b-4281-b951-d872f2087c98
#!/usr/bin/python # Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """Utils for the dart project. """ import optparse import subprocess import sys def clobber(): cmd = [sys.executable, './tools/clean_output_directory.py', '--mode=all'] print 'Clobbering %s' % (' '.join(cmd)) return subprocess.call(cmd) def main(): parser = optparse.OptionParser() parser.add_option('', '--clobber', default=False, action='store_true', help='Clobber the builder') options, args = parser.parse_args() # args unused, use. args.append('') # Determine what to do based on options passed in. if options.clobber: return clobber() else: print("Nothing to do") if '__main__' == __name__ : sys.exit(main())
<commit_before>#!/usr/bin/python # Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """Utils for the dart project. """ import optparse import os import sys from common import chromium_utils def clobber(): print('Clobbereing platform: %s' % sys.platform) if sys.platform in ('win32'): release_dir = os.path.abspath('ReleaseIA32') print('Removing directory %s' % release_dir) chromium_utils.RemoveDirectory(release_dir) debug_dir = os.path.abspath('DebugIA32') print('Removing directory %s' % debug_dir) chromium_utils.RemoveDirectory(debug_dir) elif sys.platform in ('linux2'): out_dir = os.path.abspath('out') print('Removing directory %s' % out_dir) chromium_utils.RemoveDirectory(out_dir) elif sys.platform.startswith('darwin'): xcode_dir = os.path.abspath('xcodebuild') print('Removing directory %s' % xcode_dir) chromium_utils.RemoveDirectory(xcode_dir) else: print("Platform not recognized") return 0 def main(): parser = optparse.OptionParser() parser.add_option('', '--clobber', default=False, action='store_true', help='Clobber the builder') options, args = parser.parse_args() # args unused, use. args.append('') # Determine what to do based on options passed in. if options.clobber: return clobber() else: print("Nothing to do") if '__main__' == __name__ : sys.exit(main()) <commit_msg>Use the new tools/clean_output_directory.py script for clobbering builders. This will unify our clobbering functionality across builders that use annotated steps and builders with test setup in the buildbot source. TBR=foo Review URL: https://chromiumcodereview.appspot.com/10834305 git-svn-id: 239fca9b83025a0b6f823aeeca02ba5be3d9fd76@151464 0039d316-1c4b-4281-b951-d872f2087c98<commit_after>
#!/usr/bin/python # Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """Utils for the dart project. """ import optparse import subprocess import sys def clobber(): cmd = [sys.executable, './tools/clean_output_directory.py', '--mode=all'] print 'Clobbering %s' % (' '.join(cmd)) return subprocess.call(cmd) def main(): parser = optparse.OptionParser() parser.add_option('', '--clobber', default=False, action='store_true', help='Clobber the builder') options, args = parser.parse_args() # args unused, use. args.append('') # Determine what to do based on options passed in. if options.clobber: return clobber() else: print("Nothing to do") if '__main__' == __name__ : sys.exit(main())
#!/usr/bin/python # Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """Utils for the dart project. """ import optparse import os import sys from common import chromium_utils def clobber(): print('Clobbereing platform: %s' % sys.platform) if sys.platform in ('win32'): release_dir = os.path.abspath('ReleaseIA32') print('Removing directory %s' % release_dir) chromium_utils.RemoveDirectory(release_dir) debug_dir = os.path.abspath('DebugIA32') print('Removing directory %s' % debug_dir) chromium_utils.RemoveDirectory(debug_dir) elif sys.platform in ('linux2'): out_dir = os.path.abspath('out') print('Removing directory %s' % out_dir) chromium_utils.RemoveDirectory(out_dir) elif sys.platform.startswith('darwin'): xcode_dir = os.path.abspath('xcodebuild') print('Removing directory %s' % xcode_dir) chromium_utils.RemoveDirectory(xcode_dir) else: print("Platform not recognized") return 0 def main(): parser = optparse.OptionParser() parser.add_option('', '--clobber', default=False, action='store_true', help='Clobber the builder') options, args = parser.parse_args() # args unused, use. args.append('') # Determine what to do based on options passed in. if options.clobber: return clobber() else: print("Nothing to do") if '__main__' == __name__ : sys.exit(main()) Use the new tools/clean_output_directory.py script for clobbering builders. This will unify our clobbering functionality across builders that use annotated steps and builders with test setup in the buildbot source. TBR=foo Review URL: https://chromiumcodereview.appspot.com/10834305 git-svn-id: 239fca9b83025a0b6f823aeeca02ba5be3d9fd76@151464 0039d316-1c4b-4281-b951-d872f2087c98#!/usr/bin/python # Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """Utils for the dart project. """ import optparse import subprocess import sys def clobber(): cmd = [sys.executable, './tools/clean_output_directory.py', '--mode=all'] print 'Clobbering %s' % (' '.join(cmd)) return subprocess.call(cmd) def main(): parser = optparse.OptionParser() parser.add_option('', '--clobber', default=False, action='store_true', help='Clobber the builder') options, args = parser.parse_args() # args unused, use. args.append('') # Determine what to do based on options passed in. if options.clobber: return clobber() else: print("Nothing to do") if '__main__' == __name__ : sys.exit(main())
<commit_before>#!/usr/bin/python # Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """Utils for the dart project. """ import optparse import os import sys from common import chromium_utils def clobber(): print('Clobbereing platform: %s' % sys.platform) if sys.platform in ('win32'): release_dir = os.path.abspath('ReleaseIA32') print('Removing directory %s' % release_dir) chromium_utils.RemoveDirectory(release_dir) debug_dir = os.path.abspath('DebugIA32') print('Removing directory %s' % debug_dir) chromium_utils.RemoveDirectory(debug_dir) elif sys.platform in ('linux2'): out_dir = os.path.abspath('out') print('Removing directory %s' % out_dir) chromium_utils.RemoveDirectory(out_dir) elif sys.platform.startswith('darwin'): xcode_dir = os.path.abspath('xcodebuild') print('Removing directory %s' % xcode_dir) chromium_utils.RemoveDirectory(xcode_dir) else: print("Platform not recognized") return 0 def main(): parser = optparse.OptionParser() parser.add_option('', '--clobber', default=False, action='store_true', help='Clobber the builder') options, args = parser.parse_args() # args unused, use. args.append('') # Determine what to do based on options passed in. if options.clobber: return clobber() else: print("Nothing to do") if '__main__' == __name__ : sys.exit(main()) <commit_msg>Use the new tools/clean_output_directory.py script for clobbering builders. This will unify our clobbering functionality across builders that use annotated steps and builders with test setup in the buildbot source. TBR=foo Review URL: https://chromiumcodereview.appspot.com/10834305 git-svn-id: 239fca9b83025a0b6f823aeeca02ba5be3d9fd76@151464 0039d316-1c4b-4281-b951-d872f2087c98<commit_after>#!/usr/bin/python # Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """Utils for the dart project. """ import optparse import subprocess import sys def clobber(): cmd = [sys.executable, './tools/clean_output_directory.py', '--mode=all'] print 'Clobbering %s' % (' '.join(cmd)) return subprocess.call(cmd) def main(): parser = optparse.OptionParser() parser.add_option('', '--clobber', default=False, action='store_true', help='Clobber the builder') options, args = parser.parse_args() # args unused, use. args.append('') # Determine what to do based on options passed in. if options.clobber: return clobber() else: print("Nothing to do") if '__main__' == __name__ : sys.exit(main())
a6ce85fa26235769b84003cf3cd73999b343bee6
tests/environment.py
tests/environment.py
import os import shutil import tempfile def before_all(context): context.starting_dir = os.getcwd() context.temp_dir = tempfile.mkdtemp() os.chdir(context.temp_dir) def after_all(context): os.chdir(context.starting_dir) shutil.rmtree(context.temp_dir)
import os import shutil import tempfile def before_scenario(context, *args, **kwargs): context.starting_dir = os.getcwd() context.temp_dir = tempfile.mkdtemp() os.chdir(context.temp_dir) def after_scenario(context, *args, **kwargs): os.chdir(context.starting_dir) shutil.rmtree(context.temp_dir)
Make temp dirs for each scenario.
Make temp dirs for each scenario.
Python
mit
coddingtonbear/jirafs,coddingtonbear/jirafs
import os import shutil import tempfile def before_all(context): context.starting_dir = os.getcwd() context.temp_dir = tempfile.mkdtemp() os.chdir(context.temp_dir) def after_all(context): os.chdir(context.starting_dir) shutil.rmtree(context.temp_dir) Make temp dirs for each scenario.
import os import shutil import tempfile def before_scenario(context, *args, **kwargs): context.starting_dir = os.getcwd() context.temp_dir = tempfile.mkdtemp() os.chdir(context.temp_dir) def after_scenario(context, *args, **kwargs): os.chdir(context.starting_dir) shutil.rmtree(context.temp_dir)
<commit_before>import os import shutil import tempfile def before_all(context): context.starting_dir = os.getcwd() context.temp_dir = tempfile.mkdtemp() os.chdir(context.temp_dir) def after_all(context): os.chdir(context.starting_dir) shutil.rmtree(context.temp_dir) <commit_msg>Make temp dirs for each scenario.<commit_after>
import os import shutil import tempfile def before_scenario(context, *args, **kwargs): context.starting_dir = os.getcwd() context.temp_dir = tempfile.mkdtemp() os.chdir(context.temp_dir) def after_scenario(context, *args, **kwargs): os.chdir(context.starting_dir) shutil.rmtree(context.temp_dir)
import os import shutil import tempfile def before_all(context): context.starting_dir = os.getcwd() context.temp_dir = tempfile.mkdtemp() os.chdir(context.temp_dir) def after_all(context): os.chdir(context.starting_dir) shutil.rmtree(context.temp_dir) Make temp dirs for each scenario.import os import shutil import tempfile def before_scenario(context, *args, **kwargs): context.starting_dir = os.getcwd() context.temp_dir = tempfile.mkdtemp() os.chdir(context.temp_dir) def after_scenario(context, *args, **kwargs): os.chdir(context.starting_dir) shutil.rmtree(context.temp_dir)
<commit_before>import os import shutil import tempfile def before_all(context): context.starting_dir = os.getcwd() context.temp_dir = tempfile.mkdtemp() os.chdir(context.temp_dir) def after_all(context): os.chdir(context.starting_dir) shutil.rmtree(context.temp_dir) <commit_msg>Make temp dirs for each scenario.<commit_after>import os import shutil import tempfile def before_scenario(context, *args, **kwargs): context.starting_dir = os.getcwd() context.temp_dir = tempfile.mkdtemp() os.chdir(context.temp_dir) def after_scenario(context, *args, **kwargs): os.chdir(context.starting_dir) shutil.rmtree(context.temp_dir)
d91b9fe330f61b2790d3c4a84190caa2b798d80e
bitmath/integrations/__init__.py
bitmath/integrations/__init__.py
# -*- coding: utf-8 -*- # The MIT License (MIT) # # Copyright © 2014-2016 Tim Bielawa <timbielawa@gmail.com> # See GitHub Contributors Graph for more information # # 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, sub-license, 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. # Kept for backward compatibilty from .argparse import BitmathType try: from .progressbar import BitmathFileTransferSpeed except ModuleNotFoundError: # Ignore missing dependency as argparse integration will fail if # progressbar is not installed (#86). pass
# -*- coding: utf-8 -*- # The MIT License (MIT) # # Copyright © 2014-2016 Tim Bielawa <timbielawa@gmail.com> # See GitHub Contributors Graph for more information # # 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, sub-license, 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. # Kept for backward compatibilty from .argparse import BitmathType try: from .progressbar import BitmathFileTransferSpeed except ImportError: # Ignore missing dependency as argparse integration will fail if # progressbar is not installed (#86). pass
Fix build errors with Python <3.6
Fix build errors with Python <3.6 The `ModuleNotFoundError` was introduced in Python 3.6.
Python
mit
tbielawa/bitmath,tbielawa/bitmath
# -*- coding: utf-8 -*- # The MIT License (MIT) # # Copyright © 2014-2016 Tim Bielawa <timbielawa@gmail.com> # See GitHub Contributors Graph for more information # # 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, sub-license, 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. # Kept for backward compatibilty from .argparse import BitmathType try: from .progressbar import BitmathFileTransferSpeed except ModuleNotFoundError: # Ignore missing dependency as argparse integration will fail if # progressbar is not installed (#86). pass Fix build errors with Python <3.6 The `ModuleNotFoundError` was introduced in Python 3.6.
# -*- coding: utf-8 -*- # The MIT License (MIT) # # Copyright © 2014-2016 Tim Bielawa <timbielawa@gmail.com> # See GitHub Contributors Graph for more information # # 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, sub-license, 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. # Kept for backward compatibilty from .argparse import BitmathType try: from .progressbar import BitmathFileTransferSpeed except ImportError: # Ignore missing dependency as argparse integration will fail if # progressbar is not installed (#86). pass
<commit_before># -*- coding: utf-8 -*- # The MIT License (MIT) # # Copyright © 2014-2016 Tim Bielawa <timbielawa@gmail.com> # See GitHub Contributors Graph for more information # # 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, sub-license, 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. # Kept for backward compatibilty from .argparse import BitmathType try: from .progressbar import BitmathFileTransferSpeed except ModuleNotFoundError: # Ignore missing dependency as argparse integration will fail if # progressbar is not installed (#86). pass <commit_msg>Fix build errors with Python <3.6 The `ModuleNotFoundError` was introduced in Python 3.6.<commit_after>
# -*- coding: utf-8 -*- # The MIT License (MIT) # # Copyright © 2014-2016 Tim Bielawa <timbielawa@gmail.com> # See GitHub Contributors Graph for more information # # 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, sub-license, 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. # Kept for backward compatibilty from .argparse import BitmathType try: from .progressbar import BitmathFileTransferSpeed except ImportError: # Ignore missing dependency as argparse integration will fail if # progressbar is not installed (#86). pass
# -*- coding: utf-8 -*- # The MIT License (MIT) # # Copyright © 2014-2016 Tim Bielawa <timbielawa@gmail.com> # See GitHub Contributors Graph for more information # # 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, sub-license, 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. # Kept for backward compatibilty from .argparse import BitmathType try: from .progressbar import BitmathFileTransferSpeed except ModuleNotFoundError: # Ignore missing dependency as argparse integration will fail if # progressbar is not installed (#86). pass Fix build errors with Python <3.6 The `ModuleNotFoundError` was introduced in Python 3.6.# -*- coding: utf-8 -*- # The MIT License (MIT) # # Copyright © 2014-2016 Tim Bielawa <timbielawa@gmail.com> # See GitHub Contributors Graph for more information # # 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, sub-license, 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. # Kept for backward compatibilty from .argparse import BitmathType try: from .progressbar import BitmathFileTransferSpeed except ImportError: # Ignore missing dependency as argparse integration will fail if # progressbar is not installed (#86). pass
<commit_before># -*- coding: utf-8 -*- # The MIT License (MIT) # # Copyright © 2014-2016 Tim Bielawa <timbielawa@gmail.com> # See GitHub Contributors Graph for more information # # 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, sub-license, 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. # Kept for backward compatibilty from .argparse import BitmathType try: from .progressbar import BitmathFileTransferSpeed except ModuleNotFoundError: # Ignore missing dependency as argparse integration will fail if # progressbar is not installed (#86). pass <commit_msg>Fix build errors with Python <3.6 The `ModuleNotFoundError` was introduced in Python 3.6.<commit_after># -*- coding: utf-8 -*- # The MIT License (MIT) # # Copyright © 2014-2016 Tim Bielawa <timbielawa@gmail.com> # See GitHub Contributors Graph for more information # # 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, sub-license, 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. # Kept for backward compatibilty from .argparse import BitmathType try: from .progressbar import BitmathFileTransferSpeed except ImportError: # Ignore missing dependency as argparse integration will fail if # progressbar is not installed (#86). pass
b65f44f1f4d5b5fea061c0d75391c4e771563d12
plugins/configuration/preferences/preferences.py
plugins/configuration/preferences/preferences.py
#!/usr/bin/env python #-*- coding: utf-8 -*- #This software is distributed under the Creative Commons license (CC0) version 1.0. A copy of this license should have been distributed with this software. #The license can also be read online: <https://creativecommons.org/publicdomain/zero/1.0/>. If this online license differs from the license provided with this software, the license provided with this software should be applied. """ Provides a class that allows for creating global application preferences. """ import luna.listen #To prepare the preferences for use when plug-ins are loaded. import luna.plugins #To get the configuration data type to extend from. class Preferences: """ Offers a system to create global application preferences. """ def __init__(self): luna.listen.listen(self.check_prepare, luna.plugins, "state") def check_prepare(self, _, new_state): if new_state == luna.plugins.PluginsState.LOADED: self.prepare() def prepare(self): """ Finalizes the class initialisation using data that is only available at run time. """ original_class = self.__class__ parent_class = luna.plugins.api("configuration").Configuration self.__class__ = original_class.__class__(original_class.__name__ + "Configuration", (original_class, parent_class), {}) #Add the configuration class mixin. super().__init__() #Execute the Configuration class' initialisation method to create the data structures.
#!/usr/bin/env python #-*- coding: utf-8 -*- #This software is distributed under the Creative Commons license (CC0) version 1.0. A copy of this license should have been distributed with this software. #The license can also be read online: <https://creativecommons.org/publicdomain/zero/1.0/>. If this online license differs from the license provided with this software, the license provided with this software should be applied. """ Provides a class that allows for creating global application preferences. """ import luna.listen #To prepare the preferences for use when plug-ins are loaded. import luna.plugins #To get the configuration data type to extend from. class Preferences: """ Offers a system to create global application preferences. """ def __init__(self): luna.listen.listen(self.check_prepare, luna.plugins.instance, "state") def check_prepare(self, _, new_state): if new_state == luna.plugins.PluginsState.LOADED: self.prepare() def prepare(self): """ Finalizes the class initialisation using data that is only available at run time. """ original_class = self.__class__ parent_class = luna.plugins.api("configuration").Configuration self.__class__ = original_class.__class__(original_class.__name__ + "Configuration", (original_class, parent_class), {}) #Add the configuration class mixin. super().__init__() #Execute the Configuration class' initialisation method to create the data structures.
Fix instantiating the preparation when plug-ins are done loading
Fix instantiating the preparation when plug-ins are done loading The new position of the state variable.
Python
cc0-1.0
Ghostkeeper/Luna
#!/usr/bin/env python #-*- coding: utf-8 -*- #This software is distributed under the Creative Commons license (CC0) version 1.0. A copy of this license should have been distributed with this software. #The license can also be read online: <https://creativecommons.org/publicdomain/zero/1.0/>. If this online license differs from the license provided with this software, the license provided with this software should be applied. """ Provides a class that allows for creating global application preferences. """ import luna.listen #To prepare the preferences for use when plug-ins are loaded. import luna.plugins #To get the configuration data type to extend from. class Preferences: """ Offers a system to create global application preferences. """ def __init__(self): luna.listen.listen(self.check_prepare, luna.plugins, "state") def check_prepare(self, _, new_state): if new_state == luna.plugins.PluginsState.LOADED: self.prepare() def prepare(self): """ Finalizes the class initialisation using data that is only available at run time. """ original_class = self.__class__ parent_class = luna.plugins.api("configuration").Configuration self.__class__ = original_class.__class__(original_class.__name__ + "Configuration", (original_class, parent_class), {}) #Add the configuration class mixin. super().__init__() #Execute the Configuration class' initialisation method to create the data structures.Fix instantiating the preparation when plug-ins are done loading The new position of the state variable.
#!/usr/bin/env python #-*- coding: utf-8 -*- #This software is distributed under the Creative Commons license (CC0) version 1.0. A copy of this license should have been distributed with this software. #The license can also be read online: <https://creativecommons.org/publicdomain/zero/1.0/>. If this online license differs from the license provided with this software, the license provided with this software should be applied. """ Provides a class that allows for creating global application preferences. """ import luna.listen #To prepare the preferences for use when plug-ins are loaded. import luna.plugins #To get the configuration data type to extend from. class Preferences: """ Offers a system to create global application preferences. """ def __init__(self): luna.listen.listen(self.check_prepare, luna.plugins.instance, "state") def check_prepare(self, _, new_state): if new_state == luna.plugins.PluginsState.LOADED: self.prepare() def prepare(self): """ Finalizes the class initialisation using data that is only available at run time. """ original_class = self.__class__ parent_class = luna.plugins.api("configuration").Configuration self.__class__ = original_class.__class__(original_class.__name__ + "Configuration", (original_class, parent_class), {}) #Add the configuration class mixin. super().__init__() #Execute the Configuration class' initialisation method to create the data structures.
<commit_before>#!/usr/bin/env python #-*- coding: utf-8 -*- #This software is distributed under the Creative Commons license (CC0) version 1.0. A copy of this license should have been distributed with this software. #The license can also be read online: <https://creativecommons.org/publicdomain/zero/1.0/>. If this online license differs from the license provided with this software, the license provided with this software should be applied. """ Provides a class that allows for creating global application preferences. """ import luna.listen #To prepare the preferences for use when plug-ins are loaded. import luna.plugins #To get the configuration data type to extend from. class Preferences: """ Offers a system to create global application preferences. """ def __init__(self): luna.listen.listen(self.check_prepare, luna.plugins, "state") def check_prepare(self, _, new_state): if new_state == luna.plugins.PluginsState.LOADED: self.prepare() def prepare(self): """ Finalizes the class initialisation using data that is only available at run time. """ original_class = self.__class__ parent_class = luna.plugins.api("configuration").Configuration self.__class__ = original_class.__class__(original_class.__name__ + "Configuration", (original_class, parent_class), {}) #Add the configuration class mixin. super().__init__() #Execute the Configuration class' initialisation method to create the data structures.<commit_msg>Fix instantiating the preparation when plug-ins are done loading The new position of the state variable.<commit_after>
#!/usr/bin/env python #-*- coding: utf-8 -*- #This software is distributed under the Creative Commons license (CC0) version 1.0. A copy of this license should have been distributed with this software. #The license can also be read online: <https://creativecommons.org/publicdomain/zero/1.0/>. If this online license differs from the license provided with this software, the license provided with this software should be applied. """ Provides a class that allows for creating global application preferences. """ import luna.listen #To prepare the preferences for use when plug-ins are loaded. import luna.plugins #To get the configuration data type to extend from. class Preferences: """ Offers a system to create global application preferences. """ def __init__(self): luna.listen.listen(self.check_prepare, luna.plugins.instance, "state") def check_prepare(self, _, new_state): if new_state == luna.plugins.PluginsState.LOADED: self.prepare() def prepare(self): """ Finalizes the class initialisation using data that is only available at run time. """ original_class = self.__class__ parent_class = luna.plugins.api("configuration").Configuration self.__class__ = original_class.__class__(original_class.__name__ + "Configuration", (original_class, parent_class), {}) #Add the configuration class mixin. super().__init__() #Execute the Configuration class' initialisation method to create the data structures.
#!/usr/bin/env python #-*- coding: utf-8 -*- #This software is distributed under the Creative Commons license (CC0) version 1.0. A copy of this license should have been distributed with this software. #The license can also be read online: <https://creativecommons.org/publicdomain/zero/1.0/>. If this online license differs from the license provided with this software, the license provided with this software should be applied. """ Provides a class that allows for creating global application preferences. """ import luna.listen #To prepare the preferences for use when plug-ins are loaded. import luna.plugins #To get the configuration data type to extend from. class Preferences: """ Offers a system to create global application preferences. """ def __init__(self): luna.listen.listen(self.check_prepare, luna.plugins, "state") def check_prepare(self, _, new_state): if new_state == luna.plugins.PluginsState.LOADED: self.prepare() def prepare(self): """ Finalizes the class initialisation using data that is only available at run time. """ original_class = self.__class__ parent_class = luna.plugins.api("configuration").Configuration self.__class__ = original_class.__class__(original_class.__name__ + "Configuration", (original_class, parent_class), {}) #Add the configuration class mixin. super().__init__() #Execute the Configuration class' initialisation method to create the data structures.Fix instantiating the preparation when plug-ins are done loading The new position of the state variable.#!/usr/bin/env python #-*- coding: utf-8 -*- #This software is distributed under the Creative Commons license (CC0) version 1.0. A copy of this license should have been distributed with this software. #The license can also be read online: <https://creativecommons.org/publicdomain/zero/1.0/>. If this online license differs from the license provided with this software, the license provided with this software should be applied. """ Provides a class that allows for creating global application preferences. """ import luna.listen #To prepare the preferences for use when plug-ins are loaded. import luna.plugins #To get the configuration data type to extend from. class Preferences: """ Offers a system to create global application preferences. """ def __init__(self): luna.listen.listen(self.check_prepare, luna.plugins.instance, "state") def check_prepare(self, _, new_state): if new_state == luna.plugins.PluginsState.LOADED: self.prepare() def prepare(self): """ Finalizes the class initialisation using data that is only available at run time. """ original_class = self.__class__ parent_class = luna.plugins.api("configuration").Configuration self.__class__ = original_class.__class__(original_class.__name__ + "Configuration", (original_class, parent_class), {}) #Add the configuration class mixin. super().__init__() #Execute the Configuration class' initialisation method to create the data structures.
<commit_before>#!/usr/bin/env python #-*- coding: utf-8 -*- #This software is distributed under the Creative Commons license (CC0) version 1.0. A copy of this license should have been distributed with this software. #The license can also be read online: <https://creativecommons.org/publicdomain/zero/1.0/>. If this online license differs from the license provided with this software, the license provided with this software should be applied. """ Provides a class that allows for creating global application preferences. """ import luna.listen #To prepare the preferences for use when plug-ins are loaded. import luna.plugins #To get the configuration data type to extend from. class Preferences: """ Offers a system to create global application preferences. """ def __init__(self): luna.listen.listen(self.check_prepare, luna.plugins, "state") def check_prepare(self, _, new_state): if new_state == luna.plugins.PluginsState.LOADED: self.prepare() def prepare(self): """ Finalizes the class initialisation using data that is only available at run time. """ original_class = self.__class__ parent_class = luna.plugins.api("configuration").Configuration self.__class__ = original_class.__class__(original_class.__name__ + "Configuration", (original_class, parent_class), {}) #Add the configuration class mixin. super().__init__() #Execute the Configuration class' initialisation method to create the data structures.<commit_msg>Fix instantiating the preparation when plug-ins are done loading The new position of the state variable.<commit_after>#!/usr/bin/env python #-*- coding: utf-8 -*- #This software is distributed under the Creative Commons license (CC0) version 1.0. A copy of this license should have been distributed with this software. #The license can also be read online: <https://creativecommons.org/publicdomain/zero/1.0/>. If this online license differs from the license provided with this software, the license provided with this software should be applied. """ Provides a class that allows for creating global application preferences. """ import luna.listen #To prepare the preferences for use when plug-ins are loaded. import luna.plugins #To get the configuration data type to extend from. class Preferences: """ Offers a system to create global application preferences. """ def __init__(self): luna.listen.listen(self.check_prepare, luna.plugins.instance, "state") def check_prepare(self, _, new_state): if new_state == luna.plugins.PluginsState.LOADED: self.prepare() def prepare(self): """ Finalizes the class initialisation using data that is only available at run time. """ original_class = self.__class__ parent_class = luna.plugins.api("configuration").Configuration self.__class__ = original_class.__class__(original_class.__name__ + "Configuration", (original_class, parent_class), {}) #Add the configuration class mixin. super().__init__() #Execute the Configuration class' initialisation method to create the data structures.
58f31424ccb2eda5ee94514bd1305f1b814ab1de
estmator_project/est_client/urls.py
estmator_project/est_client/urls.py
from django.conf.urls import url import views urlpatterns = [ # urls begin with /client/ url(r'^$', views.client_view, name='api_client'), # not sure what the api urls are doing currently url( r'^form$', views.client_form_view, name='client_form' ), url( r'^form/edit$', views.client_edit_form_view, name='client_edit_form' ), url( r'^listform$', views.client_list_form_view, name='client_list_form' ) ]
from django.conf.urls import url import views urlpatterns = [ # urls begin with /client/ url(r'^$', views.client_view, name='api_client'), # not sure what the api urls are doing currently url( r'^form$', views.client_form_view, name='client_form' ), url( r'^form/edit$', views.client_edit_form_view, name='client_edit_form' ), url( r'^listform$', views.client_list_form_view, name='client_list_form' ), url( r'^company/form$', views.company_form_view, name='company_form' ), url( r'^company/form/edit$', views.company_edit_form_view, name='company_edit_form' ), url( r'^company/listform$', views.company_list_form_view, name='company_list_form' ) ]
Add simple company form routes
Add simple company form routes
Python
mit
Estmator/EstmatorApp,Estmator/EstmatorApp,Estmator/EstmatorApp
from django.conf.urls import url import views urlpatterns = [ # urls begin with /client/ url(r'^$', views.client_view, name='api_client'), # not sure what the api urls are doing currently url( r'^form$', views.client_form_view, name='client_form' ), url( r'^form/edit$', views.client_edit_form_view, name='client_edit_form' ), url( r'^listform$', views.client_list_form_view, name='client_list_form' ) ] Add simple company form routes
from django.conf.urls import url import views urlpatterns = [ # urls begin with /client/ url(r'^$', views.client_view, name='api_client'), # not sure what the api urls are doing currently url( r'^form$', views.client_form_view, name='client_form' ), url( r'^form/edit$', views.client_edit_form_view, name='client_edit_form' ), url( r'^listform$', views.client_list_form_view, name='client_list_form' ), url( r'^company/form$', views.company_form_view, name='company_form' ), url( r'^company/form/edit$', views.company_edit_form_view, name='company_edit_form' ), url( r'^company/listform$', views.company_list_form_view, name='company_list_form' ) ]
<commit_before>from django.conf.urls import url import views urlpatterns = [ # urls begin with /client/ url(r'^$', views.client_view, name='api_client'), # not sure what the api urls are doing currently url( r'^form$', views.client_form_view, name='client_form' ), url( r'^form/edit$', views.client_edit_form_view, name='client_edit_form' ), url( r'^listform$', views.client_list_form_view, name='client_list_form' ) ] <commit_msg>Add simple company form routes<commit_after>
from django.conf.urls import url import views urlpatterns = [ # urls begin with /client/ url(r'^$', views.client_view, name='api_client'), # not sure what the api urls are doing currently url( r'^form$', views.client_form_view, name='client_form' ), url( r'^form/edit$', views.client_edit_form_view, name='client_edit_form' ), url( r'^listform$', views.client_list_form_view, name='client_list_form' ), url( r'^company/form$', views.company_form_view, name='company_form' ), url( r'^company/form/edit$', views.company_edit_form_view, name='company_edit_form' ), url( r'^company/listform$', views.company_list_form_view, name='company_list_form' ) ]
from django.conf.urls import url import views urlpatterns = [ # urls begin with /client/ url(r'^$', views.client_view, name='api_client'), # not sure what the api urls are doing currently url( r'^form$', views.client_form_view, name='client_form' ), url( r'^form/edit$', views.client_edit_form_view, name='client_edit_form' ), url( r'^listform$', views.client_list_form_view, name='client_list_form' ) ] Add simple company form routesfrom django.conf.urls import url import views urlpatterns = [ # urls begin with /client/ url(r'^$', views.client_view, name='api_client'), # not sure what the api urls are doing currently url( r'^form$', views.client_form_view, name='client_form' ), url( r'^form/edit$', views.client_edit_form_view, name='client_edit_form' ), url( r'^listform$', views.client_list_form_view, name='client_list_form' ), url( r'^company/form$', views.company_form_view, name='company_form' ), url( r'^company/form/edit$', views.company_edit_form_view, name='company_edit_form' ), url( r'^company/listform$', views.company_list_form_view, name='company_list_form' ) ]
<commit_before>from django.conf.urls import url import views urlpatterns = [ # urls begin with /client/ url(r'^$', views.client_view, name='api_client'), # not sure what the api urls are doing currently url( r'^form$', views.client_form_view, name='client_form' ), url( r'^form/edit$', views.client_edit_form_view, name='client_edit_form' ), url( r'^listform$', views.client_list_form_view, name='client_list_form' ) ] <commit_msg>Add simple company form routes<commit_after>from django.conf.urls import url import views urlpatterns = [ # urls begin with /client/ url(r'^$', views.client_view, name='api_client'), # not sure what the api urls are doing currently url( r'^form$', views.client_form_view, name='client_form' ), url( r'^form/edit$', views.client_edit_form_view, name='client_edit_form' ), url( r'^listform$', views.client_list_form_view, name='client_list_form' ), url( r'^company/form$', views.company_form_view, name='company_form' ), url( r'^company/form/edit$', views.company_edit_form_view, name='company_edit_form' ), url( r'^company/listform$', views.company_list_form_view, name='company_list_form' ) ]
de8b35e5c0a3c5f1427bbdcf3b60bd3e915cf0ad
xorcise/__init__.py
xorcise/__init__.py
import curses from .character import Character from .console import Console from .line import Line from .attribute import RenditionAttribute, ColorAttribute from .misc import ESCAPE_CHARS, DELETE_CHARS, BACKSPACE_CHARS, \ is_printable_char, char_with_control_key __console = None def turn_on_console(asciize=False, spaces_per_tab=4): Line.ASCIIZE = asciize Line.SPACES_PER_TAB = spaces_per_tab window = curses.initscr() curses.noecho() curses.cbreak() curses.start_color() curses.use_default_colors() ColorAttribute.initialize() global __console __console = Console(window) return __console def turn_off_console(): curses.nocbreak() curses.echo() curses.endwin()
import curses from .character import Character from .console import Console from .line import Line from .attribute import RenditionAttribute, ColorAttribute from .misc import ESCAPE_CHARS, DELETE_CHARS, BACKSPACE_CHARS, \ is_printable_char, char_with_control_key def turn_on_console(asciize=False, spaces_per_tab=4): Line.ASCIIZE = asciize Line.SPACES_PER_TAB = spaces_per_tab window = curses.initscr() curses.noecho() curses.cbreak() curses.start_color() curses.use_default_colors() ColorAttribute.initialize() return Console(window) def turn_off_console(): curses.nocbreak() curses.echo() curses.endwin()
Remove an extra global variable in xorcise package
Remove an extra global variable in xorcise package
Python
unlicense
raviqqe/shakyo
import curses from .character import Character from .console import Console from .line import Line from .attribute import RenditionAttribute, ColorAttribute from .misc import ESCAPE_CHARS, DELETE_CHARS, BACKSPACE_CHARS, \ is_printable_char, char_with_control_key __console = None def turn_on_console(asciize=False, spaces_per_tab=4): Line.ASCIIZE = asciize Line.SPACES_PER_TAB = spaces_per_tab window = curses.initscr() curses.noecho() curses.cbreak() curses.start_color() curses.use_default_colors() ColorAttribute.initialize() global __console __console = Console(window) return __console def turn_off_console(): curses.nocbreak() curses.echo() curses.endwin() Remove an extra global variable in xorcise package
import curses from .character import Character from .console import Console from .line import Line from .attribute import RenditionAttribute, ColorAttribute from .misc import ESCAPE_CHARS, DELETE_CHARS, BACKSPACE_CHARS, \ is_printable_char, char_with_control_key def turn_on_console(asciize=False, spaces_per_tab=4): Line.ASCIIZE = asciize Line.SPACES_PER_TAB = spaces_per_tab window = curses.initscr() curses.noecho() curses.cbreak() curses.start_color() curses.use_default_colors() ColorAttribute.initialize() return Console(window) def turn_off_console(): curses.nocbreak() curses.echo() curses.endwin()
<commit_before>import curses from .character import Character from .console import Console from .line import Line from .attribute import RenditionAttribute, ColorAttribute from .misc import ESCAPE_CHARS, DELETE_CHARS, BACKSPACE_CHARS, \ is_printable_char, char_with_control_key __console = None def turn_on_console(asciize=False, spaces_per_tab=4): Line.ASCIIZE = asciize Line.SPACES_PER_TAB = spaces_per_tab window = curses.initscr() curses.noecho() curses.cbreak() curses.start_color() curses.use_default_colors() ColorAttribute.initialize() global __console __console = Console(window) return __console def turn_off_console(): curses.nocbreak() curses.echo() curses.endwin() <commit_msg>Remove an extra global variable in xorcise package<commit_after>
import curses from .character import Character from .console import Console from .line import Line from .attribute import RenditionAttribute, ColorAttribute from .misc import ESCAPE_CHARS, DELETE_CHARS, BACKSPACE_CHARS, \ is_printable_char, char_with_control_key def turn_on_console(asciize=False, spaces_per_tab=4): Line.ASCIIZE = asciize Line.SPACES_PER_TAB = spaces_per_tab window = curses.initscr() curses.noecho() curses.cbreak() curses.start_color() curses.use_default_colors() ColorAttribute.initialize() return Console(window) def turn_off_console(): curses.nocbreak() curses.echo() curses.endwin()
import curses from .character import Character from .console import Console from .line import Line from .attribute import RenditionAttribute, ColorAttribute from .misc import ESCAPE_CHARS, DELETE_CHARS, BACKSPACE_CHARS, \ is_printable_char, char_with_control_key __console = None def turn_on_console(asciize=False, spaces_per_tab=4): Line.ASCIIZE = asciize Line.SPACES_PER_TAB = spaces_per_tab window = curses.initscr() curses.noecho() curses.cbreak() curses.start_color() curses.use_default_colors() ColorAttribute.initialize() global __console __console = Console(window) return __console def turn_off_console(): curses.nocbreak() curses.echo() curses.endwin() Remove an extra global variable in xorcise packageimport curses from .character import Character from .console import Console from .line import Line from .attribute import RenditionAttribute, ColorAttribute from .misc import ESCAPE_CHARS, DELETE_CHARS, BACKSPACE_CHARS, \ is_printable_char, char_with_control_key def turn_on_console(asciize=False, spaces_per_tab=4): Line.ASCIIZE = asciize Line.SPACES_PER_TAB = spaces_per_tab window = curses.initscr() curses.noecho() curses.cbreak() curses.start_color() curses.use_default_colors() ColorAttribute.initialize() return Console(window) def turn_off_console(): curses.nocbreak() curses.echo() curses.endwin()
<commit_before>import curses from .character import Character from .console import Console from .line import Line from .attribute import RenditionAttribute, ColorAttribute from .misc import ESCAPE_CHARS, DELETE_CHARS, BACKSPACE_CHARS, \ is_printable_char, char_with_control_key __console = None def turn_on_console(asciize=False, spaces_per_tab=4): Line.ASCIIZE = asciize Line.SPACES_PER_TAB = spaces_per_tab window = curses.initscr() curses.noecho() curses.cbreak() curses.start_color() curses.use_default_colors() ColorAttribute.initialize() global __console __console = Console(window) return __console def turn_off_console(): curses.nocbreak() curses.echo() curses.endwin() <commit_msg>Remove an extra global variable in xorcise package<commit_after>import curses from .character import Character from .console import Console from .line import Line from .attribute import RenditionAttribute, ColorAttribute from .misc import ESCAPE_CHARS, DELETE_CHARS, BACKSPACE_CHARS, \ is_printable_char, char_with_control_key def turn_on_console(asciize=False, spaces_per_tab=4): Line.ASCIIZE = asciize Line.SPACES_PER_TAB = spaces_per_tab window = curses.initscr() curses.noecho() curses.cbreak() curses.start_color() curses.use_default_colors() ColorAttribute.initialize() return Console(window) def turn_off_console(): curses.nocbreak() curses.echo() curses.endwin()
9e8fd0f092c35b81abaf83c0099c6c8eccbbea25
src/dicomweb_client/__init__.py
src/dicomweb_client/__init__.py
__version__ = '0.14.0' from dicomweb_client.api import DICOMwebClient
__version__ = '0.20.0rc' from dicomweb_client.api import DICOMwebClient
Increase version for release candidate
Increase version for release candidate
Python
mit
MGHComputationalPathology/dicomweb-client
__version__ = '0.14.0' from dicomweb_client.api import DICOMwebClient Increase version for release candidate
__version__ = '0.20.0rc' from dicomweb_client.api import DICOMwebClient
<commit_before>__version__ = '0.14.0' from dicomweb_client.api import DICOMwebClient <commit_msg>Increase version for release candidate<commit_after>
__version__ = '0.20.0rc' from dicomweb_client.api import DICOMwebClient
__version__ = '0.14.0' from dicomweb_client.api import DICOMwebClient Increase version for release candidate__version__ = '0.20.0rc' from dicomweb_client.api import DICOMwebClient
<commit_before>__version__ = '0.14.0' from dicomweb_client.api import DICOMwebClient <commit_msg>Increase version for release candidate<commit_after>__version__ = '0.20.0rc' from dicomweb_client.api import DICOMwebClient
7a93f8c3b65409460322dd90ba9011637c4c1c4a
ycml/transformers/base.py
ycml/transformers/base.py
import logging import numpy as np from sklearn.base import BaseEstimator, TransformerMixin from ..utils import Timer __all__ = ['PureTransformer', 'identity'] logger = logging.getLogger(__name__) # Helper class. A transformer that only does transformation and does not need to fit any internal parameters. class PureTransformer(BaseEstimator, TransformerMixin): FORCE_NP_1D_ARRAY = False def __init__(self, nparray=True, **kwargs): super(PureTransformer, self).__init__(**kwargs) self.nparray = nparray #end def def fit(self, X, y=None, **fit_params): return self def transform(self, X, **kwargs): timer = Timer() transformed = self._transform(X, **kwargs) if self.nparray: if self.FORCE_NP_1D_ARRAY: transformed = np.array(transformed, dtype=np.object) else: transformed = np.array(transformed) if transformed.ndim == 1: transformed = transformed.reshape(transformed.shape[0], 1) #end if logger.debug('Done <{}> transformation{}.'.format(type(self).__name__, timer)) return transformed #end def def _transform(self, X, y=None): return [self.transform_one(row) for row in X] #end def def transform_one(self, x): raise NotImplementedError('transform_one method needs to be implemented.') #end class def identity(x): return x
import logging import numpy as np from sklearn.base import BaseEstimator, TransformerMixin from ..utils import Timer __all__ = ['PureTransformer', 'identity'] logger = logging.getLogger(__name__) # Helper class. A transformer that only does transformation and does not need to fit any internal parameters. class PureTransformer(BaseEstimator, TransformerMixin): def __init__(self, nparray=True, nparray_dtype=None, **kwargs): super(PureTransformer, self).__init__(**kwargs) self.nparray = nparray self.nparray_dtype = nparray_dtype #end def def fit(self, X, y=None, **fit_params): return self def transform(self, X, **kwargs): timer = Timer() transformed = self._transform(X, **kwargs) if self.nparray: nparray_dtype = getattr(self, 'nparray_dtype', None) if nparray_dtype: transformed = np.array(transformed, dtype=nparray_dtype) else: transformed = np.array(transformed) if transformed.ndim == 1: transformed = transformed.reshape(transformed.shape[0], 1) #end if #end if logger.debug('Done <{}> transformation{}.'.format(type(self).__name__, timer)) return transformed #end def def _transform(self, X, y=None): return [self.transform_one(row) for row in X] #end def def transform_one(self, x): raise NotImplementedError('transform_one method needs to be implemented.') #end class def identity(x): return x
Fix np array issues again
Fix np array issues again
Python
apache-2.0
skylander86/ycml
import logging import numpy as np from sklearn.base import BaseEstimator, TransformerMixin from ..utils import Timer __all__ = ['PureTransformer', 'identity'] logger = logging.getLogger(__name__) # Helper class. A transformer that only does transformation and does not need to fit any internal parameters. class PureTransformer(BaseEstimator, TransformerMixin): FORCE_NP_1D_ARRAY = False def __init__(self, nparray=True, **kwargs): super(PureTransformer, self).__init__(**kwargs) self.nparray = nparray #end def def fit(self, X, y=None, **fit_params): return self def transform(self, X, **kwargs): timer = Timer() transformed = self._transform(X, **kwargs) if self.nparray: if self.FORCE_NP_1D_ARRAY: transformed = np.array(transformed, dtype=np.object) else: transformed = np.array(transformed) if transformed.ndim == 1: transformed = transformed.reshape(transformed.shape[0], 1) #end if logger.debug('Done <{}> transformation{}.'.format(type(self).__name__, timer)) return transformed #end def def _transform(self, X, y=None): return [self.transform_one(row) for row in X] #end def def transform_one(self, x): raise NotImplementedError('transform_one method needs to be implemented.') #end class def identity(x): return x Fix np array issues again
import logging import numpy as np from sklearn.base import BaseEstimator, TransformerMixin from ..utils import Timer __all__ = ['PureTransformer', 'identity'] logger = logging.getLogger(__name__) # Helper class. A transformer that only does transformation and does not need to fit any internal parameters. class PureTransformer(BaseEstimator, TransformerMixin): def __init__(self, nparray=True, nparray_dtype=None, **kwargs): super(PureTransformer, self).__init__(**kwargs) self.nparray = nparray self.nparray_dtype = nparray_dtype #end def def fit(self, X, y=None, **fit_params): return self def transform(self, X, **kwargs): timer = Timer() transformed = self._transform(X, **kwargs) if self.nparray: nparray_dtype = getattr(self, 'nparray_dtype', None) if nparray_dtype: transformed = np.array(transformed, dtype=nparray_dtype) else: transformed = np.array(transformed) if transformed.ndim == 1: transformed = transformed.reshape(transformed.shape[0], 1) #end if #end if logger.debug('Done <{}> transformation{}.'.format(type(self).__name__, timer)) return transformed #end def def _transform(self, X, y=None): return [self.transform_one(row) for row in X] #end def def transform_one(self, x): raise NotImplementedError('transform_one method needs to be implemented.') #end class def identity(x): return x
<commit_before>import logging import numpy as np from sklearn.base import BaseEstimator, TransformerMixin from ..utils import Timer __all__ = ['PureTransformer', 'identity'] logger = logging.getLogger(__name__) # Helper class. A transformer that only does transformation and does not need to fit any internal parameters. class PureTransformer(BaseEstimator, TransformerMixin): FORCE_NP_1D_ARRAY = False def __init__(self, nparray=True, **kwargs): super(PureTransformer, self).__init__(**kwargs) self.nparray = nparray #end def def fit(self, X, y=None, **fit_params): return self def transform(self, X, **kwargs): timer = Timer() transformed = self._transform(X, **kwargs) if self.nparray: if self.FORCE_NP_1D_ARRAY: transformed = np.array(transformed, dtype=np.object) else: transformed = np.array(transformed) if transformed.ndim == 1: transformed = transformed.reshape(transformed.shape[0], 1) #end if logger.debug('Done <{}> transformation{}.'.format(type(self).__name__, timer)) return transformed #end def def _transform(self, X, y=None): return [self.transform_one(row) for row in X] #end def def transform_one(self, x): raise NotImplementedError('transform_one method needs to be implemented.') #end class def identity(x): return x <commit_msg>Fix np array issues again<commit_after>
import logging import numpy as np from sklearn.base import BaseEstimator, TransformerMixin from ..utils import Timer __all__ = ['PureTransformer', 'identity'] logger = logging.getLogger(__name__) # Helper class. A transformer that only does transformation and does not need to fit any internal parameters. class PureTransformer(BaseEstimator, TransformerMixin): def __init__(self, nparray=True, nparray_dtype=None, **kwargs): super(PureTransformer, self).__init__(**kwargs) self.nparray = nparray self.nparray_dtype = nparray_dtype #end def def fit(self, X, y=None, **fit_params): return self def transform(self, X, **kwargs): timer = Timer() transformed = self._transform(X, **kwargs) if self.nparray: nparray_dtype = getattr(self, 'nparray_dtype', None) if nparray_dtype: transformed = np.array(transformed, dtype=nparray_dtype) else: transformed = np.array(transformed) if transformed.ndim == 1: transformed = transformed.reshape(transformed.shape[0], 1) #end if #end if logger.debug('Done <{}> transformation{}.'.format(type(self).__name__, timer)) return transformed #end def def _transform(self, X, y=None): return [self.transform_one(row) for row in X] #end def def transform_one(self, x): raise NotImplementedError('transform_one method needs to be implemented.') #end class def identity(x): return x
import logging import numpy as np from sklearn.base import BaseEstimator, TransformerMixin from ..utils import Timer __all__ = ['PureTransformer', 'identity'] logger = logging.getLogger(__name__) # Helper class. A transformer that only does transformation and does not need to fit any internal parameters. class PureTransformer(BaseEstimator, TransformerMixin): FORCE_NP_1D_ARRAY = False def __init__(self, nparray=True, **kwargs): super(PureTransformer, self).__init__(**kwargs) self.nparray = nparray #end def def fit(self, X, y=None, **fit_params): return self def transform(self, X, **kwargs): timer = Timer() transformed = self._transform(X, **kwargs) if self.nparray: if self.FORCE_NP_1D_ARRAY: transformed = np.array(transformed, dtype=np.object) else: transformed = np.array(transformed) if transformed.ndim == 1: transformed = transformed.reshape(transformed.shape[0], 1) #end if logger.debug('Done <{}> transformation{}.'.format(type(self).__name__, timer)) return transformed #end def def _transform(self, X, y=None): return [self.transform_one(row) for row in X] #end def def transform_one(self, x): raise NotImplementedError('transform_one method needs to be implemented.') #end class def identity(x): return x Fix np array issues againimport logging import numpy as np from sklearn.base import BaseEstimator, TransformerMixin from ..utils import Timer __all__ = ['PureTransformer', 'identity'] logger = logging.getLogger(__name__) # Helper class. A transformer that only does transformation and does not need to fit any internal parameters. class PureTransformer(BaseEstimator, TransformerMixin): def __init__(self, nparray=True, nparray_dtype=None, **kwargs): super(PureTransformer, self).__init__(**kwargs) self.nparray = nparray self.nparray_dtype = nparray_dtype #end def def fit(self, X, y=None, **fit_params): return self def transform(self, X, **kwargs): timer = Timer() transformed = self._transform(X, **kwargs) if self.nparray: nparray_dtype = getattr(self, 'nparray_dtype', None) if nparray_dtype: transformed = np.array(transformed, dtype=nparray_dtype) else: transformed = np.array(transformed) if transformed.ndim == 1: transformed = transformed.reshape(transformed.shape[0], 1) #end if #end if logger.debug('Done <{}> transformation{}.'.format(type(self).__name__, timer)) return transformed #end def def _transform(self, X, y=None): return [self.transform_one(row) for row in X] #end def def transform_one(self, x): raise NotImplementedError('transform_one method needs to be implemented.') #end class def identity(x): return x
<commit_before>import logging import numpy as np from sklearn.base import BaseEstimator, TransformerMixin from ..utils import Timer __all__ = ['PureTransformer', 'identity'] logger = logging.getLogger(__name__) # Helper class. A transformer that only does transformation and does not need to fit any internal parameters. class PureTransformer(BaseEstimator, TransformerMixin): FORCE_NP_1D_ARRAY = False def __init__(self, nparray=True, **kwargs): super(PureTransformer, self).__init__(**kwargs) self.nparray = nparray #end def def fit(self, X, y=None, **fit_params): return self def transform(self, X, **kwargs): timer = Timer() transformed = self._transform(X, **kwargs) if self.nparray: if self.FORCE_NP_1D_ARRAY: transformed = np.array(transformed, dtype=np.object) else: transformed = np.array(transformed) if transformed.ndim == 1: transformed = transformed.reshape(transformed.shape[0], 1) #end if logger.debug('Done <{}> transformation{}.'.format(type(self).__name__, timer)) return transformed #end def def _transform(self, X, y=None): return [self.transform_one(row) for row in X] #end def def transform_one(self, x): raise NotImplementedError('transform_one method needs to be implemented.') #end class def identity(x): return x <commit_msg>Fix np array issues again<commit_after>import logging import numpy as np from sklearn.base import BaseEstimator, TransformerMixin from ..utils import Timer __all__ = ['PureTransformer', 'identity'] logger = logging.getLogger(__name__) # Helper class. A transformer that only does transformation and does not need to fit any internal parameters. class PureTransformer(BaseEstimator, TransformerMixin): def __init__(self, nparray=True, nparray_dtype=None, **kwargs): super(PureTransformer, self).__init__(**kwargs) self.nparray = nparray self.nparray_dtype = nparray_dtype #end def def fit(self, X, y=None, **fit_params): return self def transform(self, X, **kwargs): timer = Timer() transformed = self._transform(X, **kwargs) if self.nparray: nparray_dtype = getattr(self, 'nparray_dtype', None) if nparray_dtype: transformed = np.array(transformed, dtype=nparray_dtype) else: transformed = np.array(transformed) if transformed.ndim == 1: transformed = transformed.reshape(transformed.shape[0], 1) #end if #end if logger.debug('Done <{}> transformation{}.'.format(type(self).__name__, timer)) return transformed #end def def _transform(self, X, y=None): return [self.transform_one(row) for row in X] #end def def transform_one(self, x): raise NotImplementedError('transform_one method needs to be implemented.') #end class def identity(x): return x
ec1cbf654d8c280e3094a5917a696c84f1e1264f
setup.py
setup.py
#!/usr/bin/env python from distutils.core import setup VERSION = "2.00" setup( name = "SocksipyChain", version = VERSION, description = "A Python SOCKS/HTTP Proxy module", long_description = """\ This Python module allows you to create TCP connections through a chain of SOCKS or HTTP proxies without any special effort. It also supports TLS/SSL encryption if the OpenSSL modules are installed..", """, url = "http://github.com/PageKite/SocksiPyChain", author = "Bjarni R. Einarsson", author_email="bre@pagekite.net", license = "BSD", py_modules=["sockschain"] )
#!/usr/bin/env python from distutils.core import setup VERSION = "2.00" setup( name = "SocksipyChain", version = VERSION, description = "A Python SOCKS/HTTP Proxy module", long_description = """\ This Python module allows you to create TCP connections through a chain of SOCKS or HTTP proxies without any special effort. It also supports TLS/SSL encryption if the OpenSSL modules are installed..", """, url = "http://github.com/PageKite/SocksiPyChain", author = "Bjarni R. Einarsson", author_email="bre@pagekite.net", license = "BSD", py_modules=["sockschain"], scripts=["sockschain.py"] )
Install as a script as well
Install as a script as well
Python
bsd-3-clause
locusf/PySocksipyChain,locusf/PySocksipyChain
#!/usr/bin/env python from distutils.core import setup VERSION = "2.00" setup( name = "SocksipyChain", version = VERSION, description = "A Python SOCKS/HTTP Proxy module", long_description = """\ This Python module allows you to create TCP connections through a chain of SOCKS or HTTP proxies without any special effort. It also supports TLS/SSL encryption if the OpenSSL modules are installed..", """, url = "http://github.com/PageKite/SocksiPyChain", author = "Bjarni R. Einarsson", author_email="bre@pagekite.net", license = "BSD", py_modules=["sockschain"] ) Install as a script as well
#!/usr/bin/env python from distutils.core import setup VERSION = "2.00" setup( name = "SocksipyChain", version = VERSION, description = "A Python SOCKS/HTTP Proxy module", long_description = """\ This Python module allows you to create TCP connections through a chain of SOCKS or HTTP proxies without any special effort. It also supports TLS/SSL encryption if the OpenSSL modules are installed..", """, url = "http://github.com/PageKite/SocksiPyChain", author = "Bjarni R. Einarsson", author_email="bre@pagekite.net", license = "BSD", py_modules=["sockschain"], scripts=["sockschain.py"] )
<commit_before>#!/usr/bin/env python from distutils.core import setup VERSION = "2.00" setup( name = "SocksipyChain", version = VERSION, description = "A Python SOCKS/HTTP Proxy module", long_description = """\ This Python module allows you to create TCP connections through a chain of SOCKS or HTTP proxies without any special effort. It also supports TLS/SSL encryption if the OpenSSL modules are installed..", """, url = "http://github.com/PageKite/SocksiPyChain", author = "Bjarni R. Einarsson", author_email="bre@pagekite.net", license = "BSD", py_modules=["sockschain"] ) <commit_msg>Install as a script as well<commit_after>
#!/usr/bin/env python from distutils.core import setup VERSION = "2.00" setup( name = "SocksipyChain", version = VERSION, description = "A Python SOCKS/HTTP Proxy module", long_description = """\ This Python module allows you to create TCP connections through a chain of SOCKS or HTTP proxies without any special effort. It also supports TLS/SSL encryption if the OpenSSL modules are installed..", """, url = "http://github.com/PageKite/SocksiPyChain", author = "Bjarni R. Einarsson", author_email="bre@pagekite.net", license = "BSD", py_modules=["sockschain"], scripts=["sockschain.py"] )
#!/usr/bin/env python from distutils.core import setup VERSION = "2.00" setup( name = "SocksipyChain", version = VERSION, description = "A Python SOCKS/HTTP Proxy module", long_description = """\ This Python module allows you to create TCP connections through a chain of SOCKS or HTTP proxies without any special effort. It also supports TLS/SSL encryption if the OpenSSL modules are installed..", """, url = "http://github.com/PageKite/SocksiPyChain", author = "Bjarni R. Einarsson", author_email="bre@pagekite.net", license = "BSD", py_modules=["sockschain"] ) Install as a script as well#!/usr/bin/env python from distutils.core import setup VERSION = "2.00" setup( name = "SocksipyChain", version = VERSION, description = "A Python SOCKS/HTTP Proxy module", long_description = """\ This Python module allows you to create TCP connections through a chain of SOCKS or HTTP proxies without any special effort. It also supports TLS/SSL encryption if the OpenSSL modules are installed..", """, url = "http://github.com/PageKite/SocksiPyChain", author = "Bjarni R. Einarsson", author_email="bre@pagekite.net", license = "BSD", py_modules=["sockschain"], scripts=["sockschain.py"] )
<commit_before>#!/usr/bin/env python from distutils.core import setup VERSION = "2.00" setup( name = "SocksipyChain", version = VERSION, description = "A Python SOCKS/HTTP Proxy module", long_description = """\ This Python module allows you to create TCP connections through a chain of SOCKS or HTTP proxies without any special effort. It also supports TLS/SSL encryption if the OpenSSL modules are installed..", """, url = "http://github.com/PageKite/SocksiPyChain", author = "Bjarni R. Einarsson", author_email="bre@pagekite.net", license = "BSD", py_modules=["sockschain"] ) <commit_msg>Install as a script as well<commit_after>#!/usr/bin/env python from distutils.core import setup VERSION = "2.00" setup( name = "SocksipyChain", version = VERSION, description = "A Python SOCKS/HTTP Proxy module", long_description = """\ This Python module allows you to create TCP connections through a chain of SOCKS or HTTP proxies without any special effort. It also supports TLS/SSL encryption if the OpenSSL modules are installed..", """, url = "http://github.com/PageKite/SocksiPyChain", author = "Bjarni R. Einarsson", author_email="bre@pagekite.net", license = "BSD", py_modules=["sockschain"], scripts=["sockschain.py"] )
33922c93c66d236b238863bffd08a520456846b6
tests/integration/modules/test_win_dns_client.py
tests/integration/modules/test_win_dns_client.py
# -*- coding: utf-8 -*- # Import Python libs from __future__ import absolute_import # Import Salt Testing libs from tests.support.case import ModuleCase from tests.support.unit import skipIf from tests.support.helpers import destructiveTest # Import Salt libs import salt.utils.platform @skipIf(not salt.utils.platform.is_windows(), 'windows test only') class WinDNSTest(ModuleCase): ''' Test for salt.modules.win_dns_client ''' @destructiveTest def test_add_remove_dns(self): ''' Test add and removing a dns server ''' dns = '8.8.8.8' interface = 'Ethernet' # add dns server self.assertTrue(self.run_function('win_dns_client.add_dns', [dns, interface], index=42)) srvs = self.run_function('win_dns_client.get_dns_servers', interface=interface) self.assertIn(dns, srvs) # remove dns server self.assertTrue(self.run_function('win_dns_client.rm_dns', [dns], interface=interface)) srvs = self.run_function('win_dns_client.get_dns_servers', interface=interface) self.assertNotIn(dns, srvs)
# -*- coding: utf-8 -*- # Import Python libs from __future__ import absolute_import # Import Salt Testing libs from tests.support.case import ModuleCase from tests.support.unit import skipIf from tests.support.helpers import destructiveTest # Import Salt libs import salt.utils.platform @skipIf(not salt.utils.platform.is_windows(), 'windows test only') class WinDNSTest(ModuleCase): ''' Test for salt.modules.win_dns_client ''' @destructiveTest def test_add_remove_dns(self): ''' Test add and removing a dns server ''' # Get a list of interfaces on the system interfaces = self.run_function('network.interfaces_names') skipIf(interfaces.count == 0, 'This test requires a network interface') interface = interfaces[0] dns = '8.8.8.8' # add dns server self.assertTrue(self.run_function('win_dns_client.add_dns', [dns, interface], index=42)) srvs = self.run_function('win_dns_client.get_dns_servers', interface=interface) self.assertIn(dns, srvs) # remove dns server self.assertTrue(self.run_function('win_dns_client.rm_dns', [dns], interface=interface)) srvs = self.run_function('win_dns_client.get_dns_servers', interface=interface) self.assertNotIn(dns, srvs)
Fix the failing dns test on Windows
Fix the failing dns test on Windows Gets the name of the first interface on the system. Windows network interfaces don't have the same name across Window systems. YOu can even go as far as naming them whatever you want. The test was failing because the interface name was hard-coded as 'Ethernet'.
Python
apache-2.0
saltstack/salt,saltstack/salt,saltstack/salt,saltstack/salt,saltstack/salt
# -*- coding: utf-8 -*- # Import Python libs from __future__ import absolute_import # Import Salt Testing libs from tests.support.case import ModuleCase from tests.support.unit import skipIf from tests.support.helpers import destructiveTest # Import Salt libs import salt.utils.platform @skipIf(not salt.utils.platform.is_windows(), 'windows test only') class WinDNSTest(ModuleCase): ''' Test for salt.modules.win_dns_client ''' @destructiveTest def test_add_remove_dns(self): ''' Test add and removing a dns server ''' dns = '8.8.8.8' interface = 'Ethernet' # add dns server self.assertTrue(self.run_function('win_dns_client.add_dns', [dns, interface], index=42)) srvs = self.run_function('win_dns_client.get_dns_servers', interface=interface) self.assertIn(dns, srvs) # remove dns server self.assertTrue(self.run_function('win_dns_client.rm_dns', [dns], interface=interface)) srvs = self.run_function('win_dns_client.get_dns_servers', interface=interface) self.assertNotIn(dns, srvs) Fix the failing dns test on Windows Gets the name of the first interface on the system. Windows network interfaces don't have the same name across Window systems. YOu can even go as far as naming them whatever you want. The test was failing because the interface name was hard-coded as 'Ethernet'.
# -*- coding: utf-8 -*- # Import Python libs from __future__ import absolute_import # Import Salt Testing libs from tests.support.case import ModuleCase from tests.support.unit import skipIf from tests.support.helpers import destructiveTest # Import Salt libs import salt.utils.platform @skipIf(not salt.utils.platform.is_windows(), 'windows test only') class WinDNSTest(ModuleCase): ''' Test for salt.modules.win_dns_client ''' @destructiveTest def test_add_remove_dns(self): ''' Test add and removing a dns server ''' # Get a list of interfaces on the system interfaces = self.run_function('network.interfaces_names') skipIf(interfaces.count == 0, 'This test requires a network interface') interface = interfaces[0] dns = '8.8.8.8' # add dns server self.assertTrue(self.run_function('win_dns_client.add_dns', [dns, interface], index=42)) srvs = self.run_function('win_dns_client.get_dns_servers', interface=interface) self.assertIn(dns, srvs) # remove dns server self.assertTrue(self.run_function('win_dns_client.rm_dns', [dns], interface=interface)) srvs = self.run_function('win_dns_client.get_dns_servers', interface=interface) self.assertNotIn(dns, srvs)
<commit_before># -*- coding: utf-8 -*- # Import Python libs from __future__ import absolute_import # Import Salt Testing libs from tests.support.case import ModuleCase from tests.support.unit import skipIf from tests.support.helpers import destructiveTest # Import Salt libs import salt.utils.platform @skipIf(not salt.utils.platform.is_windows(), 'windows test only') class WinDNSTest(ModuleCase): ''' Test for salt.modules.win_dns_client ''' @destructiveTest def test_add_remove_dns(self): ''' Test add and removing a dns server ''' dns = '8.8.8.8' interface = 'Ethernet' # add dns server self.assertTrue(self.run_function('win_dns_client.add_dns', [dns, interface], index=42)) srvs = self.run_function('win_dns_client.get_dns_servers', interface=interface) self.assertIn(dns, srvs) # remove dns server self.assertTrue(self.run_function('win_dns_client.rm_dns', [dns], interface=interface)) srvs = self.run_function('win_dns_client.get_dns_servers', interface=interface) self.assertNotIn(dns, srvs) <commit_msg>Fix the failing dns test on Windows Gets the name of the first interface on the system. Windows network interfaces don't have the same name across Window systems. YOu can even go as far as naming them whatever you want. The test was failing because the interface name was hard-coded as 'Ethernet'.<commit_after>
# -*- coding: utf-8 -*- # Import Python libs from __future__ import absolute_import # Import Salt Testing libs from tests.support.case import ModuleCase from tests.support.unit import skipIf from tests.support.helpers import destructiveTest # Import Salt libs import salt.utils.platform @skipIf(not salt.utils.platform.is_windows(), 'windows test only') class WinDNSTest(ModuleCase): ''' Test for salt.modules.win_dns_client ''' @destructiveTest def test_add_remove_dns(self): ''' Test add and removing a dns server ''' # Get a list of interfaces on the system interfaces = self.run_function('network.interfaces_names') skipIf(interfaces.count == 0, 'This test requires a network interface') interface = interfaces[0] dns = '8.8.8.8' # add dns server self.assertTrue(self.run_function('win_dns_client.add_dns', [dns, interface], index=42)) srvs = self.run_function('win_dns_client.get_dns_servers', interface=interface) self.assertIn(dns, srvs) # remove dns server self.assertTrue(self.run_function('win_dns_client.rm_dns', [dns], interface=interface)) srvs = self.run_function('win_dns_client.get_dns_servers', interface=interface) self.assertNotIn(dns, srvs)
# -*- coding: utf-8 -*- # Import Python libs from __future__ import absolute_import # Import Salt Testing libs from tests.support.case import ModuleCase from tests.support.unit import skipIf from tests.support.helpers import destructiveTest # Import Salt libs import salt.utils.platform @skipIf(not salt.utils.platform.is_windows(), 'windows test only') class WinDNSTest(ModuleCase): ''' Test for salt.modules.win_dns_client ''' @destructiveTest def test_add_remove_dns(self): ''' Test add and removing a dns server ''' dns = '8.8.8.8' interface = 'Ethernet' # add dns server self.assertTrue(self.run_function('win_dns_client.add_dns', [dns, interface], index=42)) srvs = self.run_function('win_dns_client.get_dns_servers', interface=interface) self.assertIn(dns, srvs) # remove dns server self.assertTrue(self.run_function('win_dns_client.rm_dns', [dns], interface=interface)) srvs = self.run_function('win_dns_client.get_dns_servers', interface=interface) self.assertNotIn(dns, srvs) Fix the failing dns test on Windows Gets the name of the first interface on the system. Windows network interfaces don't have the same name across Window systems. YOu can even go as far as naming them whatever you want. The test was failing because the interface name was hard-coded as 'Ethernet'.# -*- coding: utf-8 -*- # Import Python libs from __future__ import absolute_import # Import Salt Testing libs from tests.support.case import ModuleCase from tests.support.unit import skipIf from tests.support.helpers import destructiveTest # Import Salt libs import salt.utils.platform @skipIf(not salt.utils.platform.is_windows(), 'windows test only') class WinDNSTest(ModuleCase): ''' Test for salt.modules.win_dns_client ''' @destructiveTest def test_add_remove_dns(self): ''' Test add and removing a dns server ''' # Get a list of interfaces on the system interfaces = self.run_function('network.interfaces_names') skipIf(interfaces.count == 0, 'This test requires a network interface') interface = interfaces[0] dns = '8.8.8.8' # add dns server self.assertTrue(self.run_function('win_dns_client.add_dns', [dns, interface], index=42)) srvs = self.run_function('win_dns_client.get_dns_servers', interface=interface) self.assertIn(dns, srvs) # remove dns server self.assertTrue(self.run_function('win_dns_client.rm_dns', [dns], interface=interface)) srvs = self.run_function('win_dns_client.get_dns_servers', interface=interface) self.assertNotIn(dns, srvs)
<commit_before># -*- coding: utf-8 -*- # Import Python libs from __future__ import absolute_import # Import Salt Testing libs from tests.support.case import ModuleCase from tests.support.unit import skipIf from tests.support.helpers import destructiveTest # Import Salt libs import salt.utils.platform @skipIf(not salt.utils.platform.is_windows(), 'windows test only') class WinDNSTest(ModuleCase): ''' Test for salt.modules.win_dns_client ''' @destructiveTest def test_add_remove_dns(self): ''' Test add and removing a dns server ''' dns = '8.8.8.8' interface = 'Ethernet' # add dns server self.assertTrue(self.run_function('win_dns_client.add_dns', [dns, interface], index=42)) srvs = self.run_function('win_dns_client.get_dns_servers', interface=interface) self.assertIn(dns, srvs) # remove dns server self.assertTrue(self.run_function('win_dns_client.rm_dns', [dns], interface=interface)) srvs = self.run_function('win_dns_client.get_dns_servers', interface=interface) self.assertNotIn(dns, srvs) <commit_msg>Fix the failing dns test on Windows Gets the name of the first interface on the system. Windows network interfaces don't have the same name across Window systems. YOu can even go as far as naming them whatever you want. The test was failing because the interface name was hard-coded as 'Ethernet'.<commit_after># -*- coding: utf-8 -*- # Import Python libs from __future__ import absolute_import # Import Salt Testing libs from tests.support.case import ModuleCase from tests.support.unit import skipIf from tests.support.helpers import destructiveTest # Import Salt libs import salt.utils.platform @skipIf(not salt.utils.platform.is_windows(), 'windows test only') class WinDNSTest(ModuleCase): ''' Test for salt.modules.win_dns_client ''' @destructiveTest def test_add_remove_dns(self): ''' Test add and removing a dns server ''' # Get a list of interfaces on the system interfaces = self.run_function('network.interfaces_names') skipIf(interfaces.count == 0, 'This test requires a network interface') interface = interfaces[0] dns = '8.8.8.8' # add dns server self.assertTrue(self.run_function('win_dns_client.add_dns', [dns, interface], index=42)) srvs = self.run_function('win_dns_client.get_dns_servers', interface=interface) self.assertIn(dns, srvs) # remove dns server self.assertTrue(self.run_function('win_dns_client.rm_dns', [dns], interface=interface)) srvs = self.run_function('win_dns_client.get_dns_servers', interface=interface) self.assertNotIn(dns, srvs)
3da286b934dcb9da5f06a8e19342f74079e432ef
fabtastic/management/commands/ft_backup_db_to_s3.py
fabtastic/management/commands/ft_backup_db_to_s3.py
import os from django.core.management.base import BaseCommand from django.conf import settings from fabtastic import db from fabtastic.util.aws import get_s3_connection class Command(BaseCommand): help = 'Backs the DB up to S3. Make sure to run s3cmd --configure.' def handle(self, *args, **options): db_alias = getattr(settings, 'FABTASTIC_DUMP_DB_ALIAS', 'default') # Get DB settings from settings.py. database = db.util.get_db_setting_dict(db_alias=db_alias) # Generate a temporary DB dump filename. dump_filename = db.util.get_db_dump_filename(db_alias=db_alias) # Carry out the DB dump. dump_file_path = db.dump_db_to_file(dump_filename, database) print "Uploading to S3." conn = get_s3_connection() bucket = conn.create_bucket(settings.S3_DB_BACKUP['BUCKET']) key = bucket.new_key(dump_filename) key.set_contents_from_filename(dump_file_path) print "S3 DB backup complete." # Clean up the temporary download file. os.remove(dump_filename)
import os import datetime from django.core.management.base import BaseCommand from django.conf import settings from fabtastic import db from fabtastic.util.aws import get_s3_connection class Command(BaseCommand): help = 'Backs the DB up to S3. Make sure to run s3cmd --configure.' def handle(self, *args, **options): db_alias = getattr(settings, 'FABTASTIC_DUMP_DB_ALIAS', 'default') # Get DB settings from settings.py. database = db.util.get_db_setting_dict(db_alias=db_alias) # Generate a temporary DB dump filename. dump_filename = db.util.get_db_dump_filename(db_alias=db_alias) # Carry out the DB dump. dump_file_path = db.dump_db_to_file(dump_filename, database) print "Uploading to S3." conn = get_s3_connection() bucket = conn.create_bucket(settings.S3_DB_BACKUP['BUCKET']) now = datetime.datetime.now() s3_path = '%d/%d/%d/%s' % ( now.year, now.month, now.day, dump_filename, ) key = bucket.new_key(s3_path) key.set_contents_from_filename(dump_file_path) bucket.copy_key( 'latest_db.sql.tar.bz2', settings.S3_DB_BACKUP['BUCKET'], s3_path, ) print "S3 DB backup complete." # Clean up the temporary download file. os.remove(dump_filename)
Make backing up to S3 use a year/month/date structure for backups, for S3 clients that 'fake' directory structures.
Make backing up to S3 use a year/month/date structure for backups, for S3 clients that 'fake' directory structures.
Python
bsd-3-clause
duointeractive/django-fabtastic
import os from django.core.management.base import BaseCommand from django.conf import settings from fabtastic import db from fabtastic.util.aws import get_s3_connection class Command(BaseCommand): help = 'Backs the DB up to S3. Make sure to run s3cmd --configure.' def handle(self, *args, **options): db_alias = getattr(settings, 'FABTASTIC_DUMP_DB_ALIAS', 'default') # Get DB settings from settings.py. database = db.util.get_db_setting_dict(db_alias=db_alias) # Generate a temporary DB dump filename. dump_filename = db.util.get_db_dump_filename(db_alias=db_alias) # Carry out the DB dump. dump_file_path = db.dump_db_to_file(dump_filename, database) print "Uploading to S3." conn = get_s3_connection() bucket = conn.create_bucket(settings.S3_DB_BACKUP['BUCKET']) key = bucket.new_key(dump_filename) key.set_contents_from_filename(dump_file_path) print "S3 DB backup complete." # Clean up the temporary download file. os.remove(dump_filename) Make backing up to S3 use a year/month/date structure for backups, for S3 clients that 'fake' directory structures.
import os import datetime from django.core.management.base import BaseCommand from django.conf import settings from fabtastic import db from fabtastic.util.aws import get_s3_connection class Command(BaseCommand): help = 'Backs the DB up to S3. Make sure to run s3cmd --configure.' def handle(self, *args, **options): db_alias = getattr(settings, 'FABTASTIC_DUMP_DB_ALIAS', 'default') # Get DB settings from settings.py. database = db.util.get_db_setting_dict(db_alias=db_alias) # Generate a temporary DB dump filename. dump_filename = db.util.get_db_dump_filename(db_alias=db_alias) # Carry out the DB dump. dump_file_path = db.dump_db_to_file(dump_filename, database) print "Uploading to S3." conn = get_s3_connection() bucket = conn.create_bucket(settings.S3_DB_BACKUP['BUCKET']) now = datetime.datetime.now() s3_path = '%d/%d/%d/%s' % ( now.year, now.month, now.day, dump_filename, ) key = bucket.new_key(s3_path) key.set_contents_from_filename(dump_file_path) bucket.copy_key( 'latest_db.sql.tar.bz2', settings.S3_DB_BACKUP['BUCKET'], s3_path, ) print "S3 DB backup complete." # Clean up the temporary download file. os.remove(dump_filename)
<commit_before>import os from django.core.management.base import BaseCommand from django.conf import settings from fabtastic import db from fabtastic.util.aws import get_s3_connection class Command(BaseCommand): help = 'Backs the DB up to S3. Make sure to run s3cmd --configure.' def handle(self, *args, **options): db_alias = getattr(settings, 'FABTASTIC_DUMP_DB_ALIAS', 'default') # Get DB settings from settings.py. database = db.util.get_db_setting_dict(db_alias=db_alias) # Generate a temporary DB dump filename. dump_filename = db.util.get_db_dump_filename(db_alias=db_alias) # Carry out the DB dump. dump_file_path = db.dump_db_to_file(dump_filename, database) print "Uploading to S3." conn = get_s3_connection() bucket = conn.create_bucket(settings.S3_DB_BACKUP['BUCKET']) key = bucket.new_key(dump_filename) key.set_contents_from_filename(dump_file_path) print "S3 DB backup complete." # Clean up the temporary download file. os.remove(dump_filename) <commit_msg>Make backing up to S3 use a year/month/date structure for backups, for S3 clients that 'fake' directory structures.<commit_after>
import os import datetime from django.core.management.base import BaseCommand from django.conf import settings from fabtastic import db from fabtastic.util.aws import get_s3_connection class Command(BaseCommand): help = 'Backs the DB up to S3. Make sure to run s3cmd --configure.' def handle(self, *args, **options): db_alias = getattr(settings, 'FABTASTIC_DUMP_DB_ALIAS', 'default') # Get DB settings from settings.py. database = db.util.get_db_setting_dict(db_alias=db_alias) # Generate a temporary DB dump filename. dump_filename = db.util.get_db_dump_filename(db_alias=db_alias) # Carry out the DB dump. dump_file_path = db.dump_db_to_file(dump_filename, database) print "Uploading to S3." conn = get_s3_connection() bucket = conn.create_bucket(settings.S3_DB_BACKUP['BUCKET']) now = datetime.datetime.now() s3_path = '%d/%d/%d/%s' % ( now.year, now.month, now.day, dump_filename, ) key = bucket.new_key(s3_path) key.set_contents_from_filename(dump_file_path) bucket.copy_key( 'latest_db.sql.tar.bz2', settings.S3_DB_BACKUP['BUCKET'], s3_path, ) print "S3 DB backup complete." # Clean up the temporary download file. os.remove(dump_filename)
import os from django.core.management.base import BaseCommand from django.conf import settings from fabtastic import db from fabtastic.util.aws import get_s3_connection class Command(BaseCommand): help = 'Backs the DB up to S3. Make sure to run s3cmd --configure.' def handle(self, *args, **options): db_alias = getattr(settings, 'FABTASTIC_DUMP_DB_ALIAS', 'default') # Get DB settings from settings.py. database = db.util.get_db_setting_dict(db_alias=db_alias) # Generate a temporary DB dump filename. dump_filename = db.util.get_db_dump_filename(db_alias=db_alias) # Carry out the DB dump. dump_file_path = db.dump_db_to_file(dump_filename, database) print "Uploading to S3." conn = get_s3_connection() bucket = conn.create_bucket(settings.S3_DB_BACKUP['BUCKET']) key = bucket.new_key(dump_filename) key.set_contents_from_filename(dump_file_path) print "S3 DB backup complete." # Clean up the temporary download file. os.remove(dump_filename) Make backing up to S3 use a year/month/date structure for backups, for S3 clients that 'fake' directory structures.import os import datetime from django.core.management.base import BaseCommand from django.conf import settings from fabtastic import db from fabtastic.util.aws import get_s3_connection class Command(BaseCommand): help = 'Backs the DB up to S3. Make sure to run s3cmd --configure.' def handle(self, *args, **options): db_alias = getattr(settings, 'FABTASTIC_DUMP_DB_ALIAS', 'default') # Get DB settings from settings.py. database = db.util.get_db_setting_dict(db_alias=db_alias) # Generate a temporary DB dump filename. dump_filename = db.util.get_db_dump_filename(db_alias=db_alias) # Carry out the DB dump. dump_file_path = db.dump_db_to_file(dump_filename, database) print "Uploading to S3." conn = get_s3_connection() bucket = conn.create_bucket(settings.S3_DB_BACKUP['BUCKET']) now = datetime.datetime.now() s3_path = '%d/%d/%d/%s' % ( now.year, now.month, now.day, dump_filename, ) key = bucket.new_key(s3_path) key.set_contents_from_filename(dump_file_path) bucket.copy_key( 'latest_db.sql.tar.bz2', settings.S3_DB_BACKUP['BUCKET'], s3_path, ) print "S3 DB backup complete." # Clean up the temporary download file. os.remove(dump_filename)
<commit_before>import os from django.core.management.base import BaseCommand from django.conf import settings from fabtastic import db from fabtastic.util.aws import get_s3_connection class Command(BaseCommand): help = 'Backs the DB up to S3. Make sure to run s3cmd --configure.' def handle(self, *args, **options): db_alias = getattr(settings, 'FABTASTIC_DUMP_DB_ALIAS', 'default') # Get DB settings from settings.py. database = db.util.get_db_setting_dict(db_alias=db_alias) # Generate a temporary DB dump filename. dump_filename = db.util.get_db_dump_filename(db_alias=db_alias) # Carry out the DB dump. dump_file_path = db.dump_db_to_file(dump_filename, database) print "Uploading to S3." conn = get_s3_connection() bucket = conn.create_bucket(settings.S3_DB_BACKUP['BUCKET']) key = bucket.new_key(dump_filename) key.set_contents_from_filename(dump_file_path) print "S3 DB backup complete." # Clean up the temporary download file. os.remove(dump_filename) <commit_msg>Make backing up to S3 use a year/month/date structure for backups, for S3 clients that 'fake' directory structures.<commit_after>import os import datetime from django.core.management.base import BaseCommand from django.conf import settings from fabtastic import db from fabtastic.util.aws import get_s3_connection class Command(BaseCommand): help = 'Backs the DB up to S3. Make sure to run s3cmd --configure.' def handle(self, *args, **options): db_alias = getattr(settings, 'FABTASTIC_DUMP_DB_ALIAS', 'default') # Get DB settings from settings.py. database = db.util.get_db_setting_dict(db_alias=db_alias) # Generate a temporary DB dump filename. dump_filename = db.util.get_db_dump_filename(db_alias=db_alias) # Carry out the DB dump. dump_file_path = db.dump_db_to_file(dump_filename, database) print "Uploading to S3." conn = get_s3_connection() bucket = conn.create_bucket(settings.S3_DB_BACKUP['BUCKET']) now = datetime.datetime.now() s3_path = '%d/%d/%d/%s' % ( now.year, now.month, now.day, dump_filename, ) key = bucket.new_key(s3_path) key.set_contents_from_filename(dump_file_path) bucket.copy_key( 'latest_db.sql.tar.bz2', settings.S3_DB_BACKUP['BUCKET'], s3_path, ) print "S3 DB backup complete." # Clean up the temporary download file. os.remove(dump_filename)
d35bd019d99c8ef19012642339ddab1f4a631b8d
fixtureless/tests/test_django_project/test_django_project/test_app/tests/__init__.py
fixtureless/tests/test_django_project/test_django_project/test_app/tests/__init__.py
from test_app.tests.generator import * from test_app.tests.factory import * from test_app.tests.utils import *
from test_app.tests.test_generator import * from test_app.tests.test_factory import * from test_app.tests.test_utils import *
Fix broken imports after file namechange
Fix broken imports after file namechange
Python
mit
ricomoss/django-fixtureless
from test_app.tests.generator import * from test_app.tests.factory import * from test_app.tests.utils import * Fix broken imports after file namechange
from test_app.tests.test_generator import * from test_app.tests.test_factory import * from test_app.tests.test_utils import *
<commit_before>from test_app.tests.generator import * from test_app.tests.factory import * from test_app.tests.utils import * <commit_msg>Fix broken imports after file namechange<commit_after>
from test_app.tests.test_generator import * from test_app.tests.test_factory import * from test_app.tests.test_utils import *
from test_app.tests.generator import * from test_app.tests.factory import * from test_app.tests.utils import * Fix broken imports after file namechangefrom test_app.tests.test_generator import * from test_app.tests.test_factory import * from test_app.tests.test_utils import *
<commit_before>from test_app.tests.generator import * from test_app.tests.factory import * from test_app.tests.utils import * <commit_msg>Fix broken imports after file namechange<commit_after>from test_app.tests.test_generator import * from test_app.tests.test_factory import * from test_app.tests.test_utils import *
29339e5098be783746a17306be78467e37c6a54d
centerline/__init__.py
centerline/__init__.py
# -*- coding: utf-8 -*- from __future__ import unicode_literals from . import utils from .main import Centerline __all__ = ['utils', 'Centerline']
# -*- coding: utf-8 -*- from __future__ import unicode_literals from . import utils from .main import Centerline __all__ = ('utils', 'Centerline')
Convert the list to a tuple
Convert the list to a tuple
Python
mit
fitodic/centerline,fitodic/polygon-centerline,fitodic/centerline
# -*- coding: utf-8 -*- from __future__ import unicode_literals from . import utils from .main import Centerline __all__ = ['utils', 'Centerline'] Convert the list to a tuple
# -*- coding: utf-8 -*- from __future__ import unicode_literals from . import utils from .main import Centerline __all__ = ('utils', 'Centerline')
<commit_before># -*- coding: utf-8 -*- from __future__ import unicode_literals from . import utils from .main import Centerline __all__ = ['utils', 'Centerline'] <commit_msg>Convert the list to a tuple<commit_after>
# -*- coding: utf-8 -*- from __future__ import unicode_literals from . import utils from .main import Centerline __all__ = ('utils', 'Centerline')
# -*- coding: utf-8 -*- from __future__ import unicode_literals from . import utils from .main import Centerline __all__ = ['utils', 'Centerline'] Convert the list to a tuple# -*- coding: utf-8 -*- from __future__ import unicode_literals from . import utils from .main import Centerline __all__ = ('utils', 'Centerline')
<commit_before># -*- coding: utf-8 -*- from __future__ import unicode_literals from . import utils from .main import Centerline __all__ = ['utils', 'Centerline'] <commit_msg>Convert the list to a tuple<commit_after># -*- coding: utf-8 -*- from __future__ import unicode_literals from . import utils from .main import Centerline __all__ = ('utils', 'Centerline')
2b0453595ab10a41a5068fc78e1c84f500973dc3
mooch/app.py
mooch/app.py
import sqlite3 from flask import Flask, jsonify app = Flask(__name__) def get_db(): return sqlite3.connect(":memory:") @app.route("/status") def status(): return jsonify({"okay": True, "GitHub": {"lastCommitTime": "2013-03-12T08:14:29-07:00"}}) @app.route("/hooks/github", methods=["POST"]) def github_hook(): pass if __name__ == '__main__': app.run(debug=True, host='0.0.0.0', port=5000)
import sqlite3 from flask import Flask, jsonify, request app = Flask(__name__) def init_db(db): db.execute(""" CREATE TABLE if not exists events ( id INTEGER PRIMARY KEY, eventType TEXT, eventTime datetime, data BLOB, insertTime datetime default current_timestamp); """) # FIXME: not exists def get_db(): return sqlite3.connect("/tmp/mooch.sqlite", isolation_level=None) @app.route("/status") def status(): status = {} c = get_db().cursor() # GitHub c.execute(""" select max(eventTime) from events where eventType = 'github' """) last_github_ts = c.fetchone()[0] if last_github_ts is not None: status['GitHub'] = {"lastCommitTime": last_github_ts} return jsonify(status) @app.route("/hooks/github", methods=["POST"]) def github_hook(): #import pdb; pdb.set_trace() last_ts = max(commit['timestamp'] for commit in request.json['commits']) get_db().execute("INSERT INTO events (eventType, eventTime) VALUES (?, ?)", ("github", last_ts)) if __name__ == '__main__': init_db(get_db()) app.run(debug=True, host='0.0.0.0', port=5000)
Store last github commit in `events` table
Store last github commit in `events` table
Python
mit
asivokon/mooch-sentinel,asivokon/mooch-sentinel,asivokon/mooch-sentinel,asivokon/mooch-sentinel
import sqlite3 from flask import Flask, jsonify app = Flask(__name__) def get_db(): return sqlite3.connect(":memory:") @app.route("/status") def status(): return jsonify({"okay": True, "GitHub": {"lastCommitTime": "2013-03-12T08:14:29-07:00"}}) @app.route("/hooks/github", methods=["POST"]) def github_hook(): pass if __name__ == '__main__': app.run(debug=True, host='0.0.0.0', port=5000) Store last github commit in `events` table
import sqlite3 from flask import Flask, jsonify, request app = Flask(__name__) def init_db(db): db.execute(""" CREATE TABLE if not exists events ( id INTEGER PRIMARY KEY, eventType TEXT, eventTime datetime, data BLOB, insertTime datetime default current_timestamp); """) # FIXME: not exists def get_db(): return sqlite3.connect("/tmp/mooch.sqlite", isolation_level=None) @app.route("/status") def status(): status = {} c = get_db().cursor() # GitHub c.execute(""" select max(eventTime) from events where eventType = 'github' """) last_github_ts = c.fetchone()[0] if last_github_ts is not None: status['GitHub'] = {"lastCommitTime": last_github_ts} return jsonify(status) @app.route("/hooks/github", methods=["POST"]) def github_hook(): #import pdb; pdb.set_trace() last_ts = max(commit['timestamp'] for commit in request.json['commits']) get_db().execute("INSERT INTO events (eventType, eventTime) VALUES (?, ?)", ("github", last_ts)) if __name__ == '__main__': init_db(get_db()) app.run(debug=True, host='0.0.0.0', port=5000)
<commit_before>import sqlite3 from flask import Flask, jsonify app = Flask(__name__) def get_db(): return sqlite3.connect(":memory:") @app.route("/status") def status(): return jsonify({"okay": True, "GitHub": {"lastCommitTime": "2013-03-12T08:14:29-07:00"}}) @app.route("/hooks/github", methods=["POST"]) def github_hook(): pass if __name__ == '__main__': app.run(debug=True, host='0.0.0.0', port=5000) <commit_msg>Store last github commit in `events` table<commit_after>
import sqlite3 from flask import Flask, jsonify, request app = Flask(__name__) def init_db(db): db.execute(""" CREATE TABLE if not exists events ( id INTEGER PRIMARY KEY, eventType TEXT, eventTime datetime, data BLOB, insertTime datetime default current_timestamp); """) # FIXME: not exists def get_db(): return sqlite3.connect("/tmp/mooch.sqlite", isolation_level=None) @app.route("/status") def status(): status = {} c = get_db().cursor() # GitHub c.execute(""" select max(eventTime) from events where eventType = 'github' """) last_github_ts = c.fetchone()[0] if last_github_ts is not None: status['GitHub'] = {"lastCommitTime": last_github_ts} return jsonify(status) @app.route("/hooks/github", methods=["POST"]) def github_hook(): #import pdb; pdb.set_trace() last_ts = max(commit['timestamp'] for commit in request.json['commits']) get_db().execute("INSERT INTO events (eventType, eventTime) VALUES (?, ?)", ("github", last_ts)) if __name__ == '__main__': init_db(get_db()) app.run(debug=True, host='0.0.0.0', port=5000)
import sqlite3 from flask import Flask, jsonify app = Flask(__name__) def get_db(): return sqlite3.connect(":memory:") @app.route("/status") def status(): return jsonify({"okay": True, "GitHub": {"lastCommitTime": "2013-03-12T08:14:29-07:00"}}) @app.route("/hooks/github", methods=["POST"]) def github_hook(): pass if __name__ == '__main__': app.run(debug=True, host='0.0.0.0', port=5000) Store last github commit in `events` tableimport sqlite3 from flask import Flask, jsonify, request app = Flask(__name__) def init_db(db): db.execute(""" CREATE TABLE if not exists events ( id INTEGER PRIMARY KEY, eventType TEXT, eventTime datetime, data BLOB, insertTime datetime default current_timestamp); """) # FIXME: not exists def get_db(): return sqlite3.connect("/tmp/mooch.sqlite", isolation_level=None) @app.route("/status") def status(): status = {} c = get_db().cursor() # GitHub c.execute(""" select max(eventTime) from events where eventType = 'github' """) last_github_ts = c.fetchone()[0] if last_github_ts is not None: status['GitHub'] = {"lastCommitTime": last_github_ts} return jsonify(status) @app.route("/hooks/github", methods=["POST"]) def github_hook(): #import pdb; pdb.set_trace() last_ts = max(commit['timestamp'] for commit in request.json['commits']) get_db().execute("INSERT INTO events (eventType, eventTime) VALUES (?, ?)", ("github", last_ts)) if __name__ == '__main__': init_db(get_db()) app.run(debug=True, host='0.0.0.0', port=5000)
<commit_before>import sqlite3 from flask import Flask, jsonify app = Flask(__name__) def get_db(): return sqlite3.connect(":memory:") @app.route("/status") def status(): return jsonify({"okay": True, "GitHub": {"lastCommitTime": "2013-03-12T08:14:29-07:00"}}) @app.route("/hooks/github", methods=["POST"]) def github_hook(): pass if __name__ == '__main__': app.run(debug=True, host='0.0.0.0', port=5000) <commit_msg>Store last github commit in `events` table<commit_after>import sqlite3 from flask import Flask, jsonify, request app = Flask(__name__) def init_db(db): db.execute(""" CREATE TABLE if not exists events ( id INTEGER PRIMARY KEY, eventType TEXT, eventTime datetime, data BLOB, insertTime datetime default current_timestamp); """) # FIXME: not exists def get_db(): return sqlite3.connect("/tmp/mooch.sqlite", isolation_level=None) @app.route("/status") def status(): status = {} c = get_db().cursor() # GitHub c.execute(""" select max(eventTime) from events where eventType = 'github' """) last_github_ts = c.fetchone()[0] if last_github_ts is not None: status['GitHub'] = {"lastCommitTime": last_github_ts} return jsonify(status) @app.route("/hooks/github", methods=["POST"]) def github_hook(): #import pdb; pdb.set_trace() last_ts = max(commit['timestamp'] for commit in request.json['commits']) get_db().execute("INSERT INTO events (eventType, eventTime) VALUES (?, ?)", ("github", last_ts)) if __name__ == '__main__': init_db(get_db()) app.run(debug=True, host='0.0.0.0', port=5000)
63c1382f80250ca5df4c438e31a71ddae519a44a
clowder_server/admin.py
clowder_server/admin.py
from django.contrib import admin from clowder_account.models import ClowderUser, ClowderUserAdmin from clowder_server.models import Alert, Ping admin.site.register(Alert) admin.site.register(ClowderUser, ClowderUserAdmin) admin.site.register(Ping)
from django.contrib import admin from clowder_account.models import ClowderUser, ClowderUserAdmin from clowder_server.models import Alert, Ping admin.site.register(Alert) admin.site.register(ClowderUser, ClowderUserAdmin) @admin.register(Ping) class PingAdmin(admin.ModelAdmin): list_filter = ('user',)
Add list filter for searching
ADMIN: Add list filter for searching
Python
agpl-3.0
keithhackbarth/clowder_server,keithhackbarth/clowder_server,framewr/clowder_server,framewr/clowder_server,framewr/clowder_server,keithhackbarth/clowder_server,framewr/clowder_server,keithhackbarth/clowder_server
from django.contrib import admin from clowder_account.models import ClowderUser, ClowderUserAdmin from clowder_server.models import Alert, Ping admin.site.register(Alert) admin.site.register(ClowderUser, ClowderUserAdmin) admin.site.register(Ping) ADMIN: Add list filter for searching
from django.contrib import admin from clowder_account.models import ClowderUser, ClowderUserAdmin from clowder_server.models import Alert, Ping admin.site.register(Alert) admin.site.register(ClowderUser, ClowderUserAdmin) @admin.register(Ping) class PingAdmin(admin.ModelAdmin): list_filter = ('user',)
<commit_before>from django.contrib import admin from clowder_account.models import ClowderUser, ClowderUserAdmin from clowder_server.models import Alert, Ping admin.site.register(Alert) admin.site.register(ClowderUser, ClowderUserAdmin) admin.site.register(Ping) <commit_msg>ADMIN: Add list filter for searching<commit_after>
from django.contrib import admin from clowder_account.models import ClowderUser, ClowderUserAdmin from clowder_server.models import Alert, Ping admin.site.register(Alert) admin.site.register(ClowderUser, ClowderUserAdmin) @admin.register(Ping) class PingAdmin(admin.ModelAdmin): list_filter = ('user',)
from django.contrib import admin from clowder_account.models import ClowderUser, ClowderUserAdmin from clowder_server.models import Alert, Ping admin.site.register(Alert) admin.site.register(ClowderUser, ClowderUserAdmin) admin.site.register(Ping) ADMIN: Add list filter for searchingfrom django.contrib import admin from clowder_account.models import ClowderUser, ClowderUserAdmin from clowder_server.models import Alert, Ping admin.site.register(Alert) admin.site.register(ClowderUser, ClowderUserAdmin) @admin.register(Ping) class PingAdmin(admin.ModelAdmin): list_filter = ('user',)
<commit_before>from django.contrib import admin from clowder_account.models import ClowderUser, ClowderUserAdmin from clowder_server.models import Alert, Ping admin.site.register(Alert) admin.site.register(ClowderUser, ClowderUserAdmin) admin.site.register(Ping) <commit_msg>ADMIN: Add list filter for searching<commit_after>from django.contrib import admin from clowder_account.models import ClowderUser, ClowderUserAdmin from clowder_server.models import Alert, Ping admin.site.register(Alert) admin.site.register(ClowderUser, ClowderUserAdmin) @admin.register(Ping) class PingAdmin(admin.ModelAdmin): list_filter = ('user',)
effb5d796e55dbf28de2ec8d6711fcf2724bc62f
src/core/migrations/0059_auto_20211013_1657.py
src/core/migrations/0059_auto_20211013_1657.py
# -*- coding: utf-8 -*- # Generated by Django 1.11.29 on 2021-10-13 15:57 from __future__ import unicode_literals from django.db import migrations def set_about_plugin_to_hpe(apps, schema_editor): Plugin = apps.get_model('utils', 'Plugin') Plugin.objects.filter( name='About', ).update( homepage_element=True, ) class Migration(migrations.Migration): dependencies = [ ('core', '0058_merge_20211005_0909'), ] operations = [ migrations.RunPython(set_about_plugin_to_hpe, reverse_code=migrations.RunPython.noop) ]
# -*- coding: utf-8 -*- # Generated by Django 1.11.29 on 2021-10-13 15:57 from __future__ import unicode_literals from django.db import migrations def set_about_plugin_to_hpe(apps, schema_editor): Plugin = apps.get_model('utils', 'Plugin') Plugin.objects.filter( name='About', ).update( homepage_element=True, ) class Migration(migrations.Migration): dependencies = [ ('core', '0058_merge_20211005_0909'), ('utils', '0023_upgrade_1_4_0'), ] operations = [ migrations.RunPython(set_about_plugin_to_hpe, reverse_code=migrations.RunPython.noop) ]
Fix missing dependency on core.0059 migration
Fix missing dependency on core.0059 migration
Python
agpl-3.0
BirkbeckCTP/janeway,BirkbeckCTP/janeway,BirkbeckCTP/janeway,BirkbeckCTP/janeway
# -*- coding: utf-8 -*- # Generated by Django 1.11.29 on 2021-10-13 15:57 from __future__ import unicode_literals from django.db import migrations def set_about_plugin_to_hpe(apps, schema_editor): Plugin = apps.get_model('utils', 'Plugin') Plugin.objects.filter( name='About', ).update( homepage_element=True, ) class Migration(migrations.Migration): dependencies = [ ('core', '0058_merge_20211005_0909'), ] operations = [ migrations.RunPython(set_about_plugin_to_hpe, reverse_code=migrations.RunPython.noop) ] Fix missing dependency on core.0059 migration
# -*- coding: utf-8 -*- # Generated by Django 1.11.29 on 2021-10-13 15:57 from __future__ import unicode_literals from django.db import migrations def set_about_plugin_to_hpe(apps, schema_editor): Plugin = apps.get_model('utils', 'Plugin') Plugin.objects.filter( name='About', ).update( homepage_element=True, ) class Migration(migrations.Migration): dependencies = [ ('core', '0058_merge_20211005_0909'), ('utils', '0023_upgrade_1_4_0'), ] operations = [ migrations.RunPython(set_about_plugin_to_hpe, reverse_code=migrations.RunPython.noop) ]
<commit_before># -*- coding: utf-8 -*- # Generated by Django 1.11.29 on 2021-10-13 15:57 from __future__ import unicode_literals from django.db import migrations def set_about_plugin_to_hpe(apps, schema_editor): Plugin = apps.get_model('utils', 'Plugin') Plugin.objects.filter( name='About', ).update( homepage_element=True, ) class Migration(migrations.Migration): dependencies = [ ('core', '0058_merge_20211005_0909'), ] operations = [ migrations.RunPython(set_about_plugin_to_hpe, reverse_code=migrations.RunPython.noop) ] <commit_msg>Fix missing dependency on core.0059 migration<commit_after>
# -*- coding: utf-8 -*- # Generated by Django 1.11.29 on 2021-10-13 15:57 from __future__ import unicode_literals from django.db import migrations def set_about_plugin_to_hpe(apps, schema_editor): Plugin = apps.get_model('utils', 'Plugin') Plugin.objects.filter( name='About', ).update( homepage_element=True, ) class Migration(migrations.Migration): dependencies = [ ('core', '0058_merge_20211005_0909'), ('utils', '0023_upgrade_1_4_0'), ] operations = [ migrations.RunPython(set_about_plugin_to_hpe, reverse_code=migrations.RunPython.noop) ]
# -*- coding: utf-8 -*- # Generated by Django 1.11.29 on 2021-10-13 15:57 from __future__ import unicode_literals from django.db import migrations def set_about_plugin_to_hpe(apps, schema_editor): Plugin = apps.get_model('utils', 'Plugin') Plugin.objects.filter( name='About', ).update( homepage_element=True, ) class Migration(migrations.Migration): dependencies = [ ('core', '0058_merge_20211005_0909'), ] operations = [ migrations.RunPython(set_about_plugin_to_hpe, reverse_code=migrations.RunPython.noop) ] Fix missing dependency on core.0059 migration# -*- coding: utf-8 -*- # Generated by Django 1.11.29 on 2021-10-13 15:57 from __future__ import unicode_literals from django.db import migrations def set_about_plugin_to_hpe(apps, schema_editor): Plugin = apps.get_model('utils', 'Plugin') Plugin.objects.filter( name='About', ).update( homepage_element=True, ) class Migration(migrations.Migration): dependencies = [ ('core', '0058_merge_20211005_0909'), ('utils', '0023_upgrade_1_4_0'), ] operations = [ migrations.RunPython(set_about_plugin_to_hpe, reverse_code=migrations.RunPython.noop) ]
<commit_before># -*- coding: utf-8 -*- # Generated by Django 1.11.29 on 2021-10-13 15:57 from __future__ import unicode_literals from django.db import migrations def set_about_plugin_to_hpe(apps, schema_editor): Plugin = apps.get_model('utils', 'Plugin') Plugin.objects.filter( name='About', ).update( homepage_element=True, ) class Migration(migrations.Migration): dependencies = [ ('core', '0058_merge_20211005_0909'), ] operations = [ migrations.RunPython(set_about_plugin_to_hpe, reverse_code=migrations.RunPython.noop) ] <commit_msg>Fix missing dependency on core.0059 migration<commit_after># -*- coding: utf-8 -*- # Generated by Django 1.11.29 on 2021-10-13 15:57 from __future__ import unicode_literals from django.db import migrations def set_about_plugin_to_hpe(apps, schema_editor): Plugin = apps.get_model('utils', 'Plugin') Plugin.objects.filter( name='About', ).update( homepage_element=True, ) class Migration(migrations.Migration): dependencies = [ ('core', '0058_merge_20211005_0909'), ('utils', '0023_upgrade_1_4_0'), ] operations = [ migrations.RunPython(set_about_plugin_to_hpe, reverse_code=migrations.RunPython.noop) ]
c72764fde63e14f378a9e31dd89ea4180655d379
nightreads/emails/management/commands/send_email.py
nightreads/emails/management/commands/send_email.py
from django.core.management.base import BaseCommand from nightreads.emails.models import Email from nightreads.emails.email_service import send_email_obj from nightreads.emails.views import get_subscriber_emails class Command(BaseCommand): help = 'Send the email to susbcribers' def handle(self, *args, **options): email_obj = Email.objects.filter(is_sent=False).first() if not email_obj: return email_obj.recipients = get_subscriber_emails(email_obj=email_obj) send_email_obj(email_obj=email_obj) email_obj.is_sent = True email_obj.targetted_users = len(email_obj.recipients) email_obj.save() self.stdout.write( self.style.SUCCESS('Successfully sent email {}'.format(email_obj)))
from django.core.management.base import BaseCommand from nightreads.emails.models import Email from nightreads.emails.email_service import send_email_obj from nightreads.emails.views import get_subscriber_emails class Command(BaseCommand): help = 'Send the email to susbcribers' def handle(self, *args, **options): email_obj = Email.objects.filter(is_sent=False).first() if not email_obj: self.stdout.write( self.style.SUCCESS('No emails available to send')) return email_obj.recipients = get_subscriber_emails(email_obj=email_obj) send_email_obj(email_obj=email_obj) email_obj.is_sent = True email_obj.targetted_users = len(email_obj.recipients) email_obj.save() self.stdout.write( self.style.SUCCESS('Successfully sent email {}'.format(email_obj)))
Add a note if no emails are available to send
Add a note if no emails are available to send
Python
mit
avinassh/nightreads,avinassh/nightreads
from django.core.management.base import BaseCommand from nightreads.emails.models import Email from nightreads.emails.email_service import send_email_obj from nightreads.emails.views import get_subscriber_emails class Command(BaseCommand): help = 'Send the email to susbcribers' def handle(self, *args, **options): email_obj = Email.objects.filter(is_sent=False).first() if not email_obj: return email_obj.recipients = get_subscriber_emails(email_obj=email_obj) send_email_obj(email_obj=email_obj) email_obj.is_sent = True email_obj.targetted_users = len(email_obj.recipients) email_obj.save() self.stdout.write( self.style.SUCCESS('Successfully sent email {}'.format(email_obj))) Add a note if no emails are available to send
from django.core.management.base import BaseCommand from nightreads.emails.models import Email from nightreads.emails.email_service import send_email_obj from nightreads.emails.views import get_subscriber_emails class Command(BaseCommand): help = 'Send the email to susbcribers' def handle(self, *args, **options): email_obj = Email.objects.filter(is_sent=False).first() if not email_obj: self.stdout.write( self.style.SUCCESS('No emails available to send')) return email_obj.recipients = get_subscriber_emails(email_obj=email_obj) send_email_obj(email_obj=email_obj) email_obj.is_sent = True email_obj.targetted_users = len(email_obj.recipients) email_obj.save() self.stdout.write( self.style.SUCCESS('Successfully sent email {}'.format(email_obj)))
<commit_before>from django.core.management.base import BaseCommand from nightreads.emails.models import Email from nightreads.emails.email_service import send_email_obj from nightreads.emails.views import get_subscriber_emails class Command(BaseCommand): help = 'Send the email to susbcribers' def handle(self, *args, **options): email_obj = Email.objects.filter(is_sent=False).first() if not email_obj: return email_obj.recipients = get_subscriber_emails(email_obj=email_obj) send_email_obj(email_obj=email_obj) email_obj.is_sent = True email_obj.targetted_users = len(email_obj.recipients) email_obj.save() self.stdout.write( self.style.SUCCESS('Successfully sent email {}'.format(email_obj))) <commit_msg>Add a note if no emails are available to send<commit_after>
from django.core.management.base import BaseCommand from nightreads.emails.models import Email from nightreads.emails.email_service import send_email_obj from nightreads.emails.views import get_subscriber_emails class Command(BaseCommand): help = 'Send the email to susbcribers' def handle(self, *args, **options): email_obj = Email.objects.filter(is_sent=False).first() if not email_obj: self.stdout.write( self.style.SUCCESS('No emails available to send')) return email_obj.recipients = get_subscriber_emails(email_obj=email_obj) send_email_obj(email_obj=email_obj) email_obj.is_sent = True email_obj.targetted_users = len(email_obj.recipients) email_obj.save() self.stdout.write( self.style.SUCCESS('Successfully sent email {}'.format(email_obj)))
from django.core.management.base import BaseCommand from nightreads.emails.models import Email from nightreads.emails.email_service import send_email_obj from nightreads.emails.views import get_subscriber_emails class Command(BaseCommand): help = 'Send the email to susbcribers' def handle(self, *args, **options): email_obj = Email.objects.filter(is_sent=False).first() if not email_obj: return email_obj.recipients = get_subscriber_emails(email_obj=email_obj) send_email_obj(email_obj=email_obj) email_obj.is_sent = True email_obj.targetted_users = len(email_obj.recipients) email_obj.save() self.stdout.write( self.style.SUCCESS('Successfully sent email {}'.format(email_obj))) Add a note if no emails are available to sendfrom django.core.management.base import BaseCommand from nightreads.emails.models import Email from nightreads.emails.email_service import send_email_obj from nightreads.emails.views import get_subscriber_emails class Command(BaseCommand): help = 'Send the email to susbcribers' def handle(self, *args, **options): email_obj = Email.objects.filter(is_sent=False).first() if not email_obj: self.stdout.write( self.style.SUCCESS('No emails available to send')) return email_obj.recipients = get_subscriber_emails(email_obj=email_obj) send_email_obj(email_obj=email_obj) email_obj.is_sent = True email_obj.targetted_users = len(email_obj.recipients) email_obj.save() self.stdout.write( self.style.SUCCESS('Successfully sent email {}'.format(email_obj)))
<commit_before>from django.core.management.base import BaseCommand from nightreads.emails.models import Email from nightreads.emails.email_service import send_email_obj from nightreads.emails.views import get_subscriber_emails class Command(BaseCommand): help = 'Send the email to susbcribers' def handle(self, *args, **options): email_obj = Email.objects.filter(is_sent=False).first() if not email_obj: return email_obj.recipients = get_subscriber_emails(email_obj=email_obj) send_email_obj(email_obj=email_obj) email_obj.is_sent = True email_obj.targetted_users = len(email_obj.recipients) email_obj.save() self.stdout.write( self.style.SUCCESS('Successfully sent email {}'.format(email_obj))) <commit_msg>Add a note if no emails are available to send<commit_after>from django.core.management.base import BaseCommand from nightreads.emails.models import Email from nightreads.emails.email_service import send_email_obj from nightreads.emails.views import get_subscriber_emails class Command(BaseCommand): help = 'Send the email to susbcribers' def handle(self, *args, **options): email_obj = Email.objects.filter(is_sent=False).first() if not email_obj: self.stdout.write( self.style.SUCCESS('No emails available to send')) return email_obj.recipients = get_subscriber_emails(email_obj=email_obj) send_email_obj(email_obj=email_obj) email_obj.is_sent = True email_obj.targetted_users = len(email_obj.recipients) email_obj.save() self.stdout.write( self.style.SUCCESS('Successfully sent email {}'.format(email_obj)))
014e4fe380cddcdcc5ca12a32ab6af35e87ee56e
common/postgresqlfix.py
common/postgresqlfix.py
# This file is part of e-Giełda. # Copyright (C) 2014 Mateusz Maćkowski and Tomasz Zieliński # # e-Giełda is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # You should have received a copy of the GNU Affero General Public License # along with e-Giełda. If not, see <http://www.gnu.org/licenses/>. from django.db.models import QuerySet def new_exclude(self, *args, **kwargs): new_kwargs = dict() for key, value in kwargs.items(): if not ((isinstance(value, list) and not value) or (isinstance(value, QuerySet) and not value)): new_kwargs[key] = value if len(new_kwargs): return old_exclude(self, *args, **new_kwargs) else: return self def new_filter(self, *args, **kwargs): new_kwargs = dict() for key, value in kwargs.items(): if not ((isinstance(value, list) and not value) or (isinstance(value, QuerySet) and not value)): new_kwargs[key] = value if len(new_kwargs): return old_filter(self, *args, **new_kwargs) else: return self old_exclude = QuerySet.exclude QuerySet.exclude = new_exclude old_filter = QuerySet.filter QuerySet.filter = new_filter
# This file is part of e-Giełda. # Copyright (C) 2014 Mateusz Maćkowski and Tomasz Zieliński # # e-Giełda is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # You should have received a copy of the GNU Affero General Public License # along with e-Giełda. If not, see <http://www.gnu.org/licenses/>. from django.db.models import QuerySet def new_exclude(self, *args, **kwargs): new_kwargs = dict() for key, value in kwargs.items(): if not ((isinstance(value, list) and not value) or (isinstance(value, QuerySet) and not value)): new_kwargs[key] = value return old_exclude(self, *args, **new_kwargs) def new_filter(self, *args, **kwargs): new_kwargs = dict() for key, value in kwargs.items(): if not ((isinstance(value, list) and not value) or (isinstance(value, QuerySet) and not value)): new_kwargs[key] = value return old_filter(self, *args, **new_kwargs) old_exclude = QuerySet.exclude QuerySet.exclude = new_exclude old_filter = QuerySet.filter QuerySet.filter = new_filter
Fix buggy patched QuerySet methods
Fix buggy patched QuerySet methods
Python
agpl-3.0
m4tx/egielda,m4tx/egielda,m4tx/egielda
# This file is part of e-Giełda. # Copyright (C) 2014 Mateusz Maćkowski and Tomasz Zieliński # # e-Giełda is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # You should have received a copy of the GNU Affero General Public License # along with e-Giełda. If not, see <http://www.gnu.org/licenses/>. from django.db.models import QuerySet def new_exclude(self, *args, **kwargs): new_kwargs = dict() for key, value in kwargs.items(): if not ((isinstance(value, list) and not value) or (isinstance(value, QuerySet) and not value)): new_kwargs[key] = value if len(new_kwargs): return old_exclude(self, *args, **new_kwargs) else: return self def new_filter(self, *args, **kwargs): new_kwargs = dict() for key, value in kwargs.items(): if not ((isinstance(value, list) and not value) or (isinstance(value, QuerySet) and not value)): new_kwargs[key] = value if len(new_kwargs): return old_filter(self, *args, **new_kwargs) else: return self old_exclude = QuerySet.exclude QuerySet.exclude = new_exclude old_filter = QuerySet.filter QuerySet.filter = new_filterFix buggy patched QuerySet methods
# This file is part of e-Giełda. # Copyright (C) 2014 Mateusz Maćkowski and Tomasz Zieliński # # e-Giełda is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # You should have received a copy of the GNU Affero General Public License # along with e-Giełda. If not, see <http://www.gnu.org/licenses/>. from django.db.models import QuerySet def new_exclude(self, *args, **kwargs): new_kwargs = dict() for key, value in kwargs.items(): if not ((isinstance(value, list) and not value) or (isinstance(value, QuerySet) and not value)): new_kwargs[key] = value return old_exclude(self, *args, **new_kwargs) def new_filter(self, *args, **kwargs): new_kwargs = dict() for key, value in kwargs.items(): if not ((isinstance(value, list) and not value) or (isinstance(value, QuerySet) and not value)): new_kwargs[key] = value return old_filter(self, *args, **new_kwargs) old_exclude = QuerySet.exclude QuerySet.exclude = new_exclude old_filter = QuerySet.filter QuerySet.filter = new_filter
<commit_before># This file is part of e-Giełda. # Copyright (C) 2014 Mateusz Maćkowski and Tomasz Zieliński # # e-Giełda is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # You should have received a copy of the GNU Affero General Public License # along with e-Giełda. If not, see <http://www.gnu.org/licenses/>. from django.db.models import QuerySet def new_exclude(self, *args, **kwargs): new_kwargs = dict() for key, value in kwargs.items(): if not ((isinstance(value, list) and not value) or (isinstance(value, QuerySet) and not value)): new_kwargs[key] = value if len(new_kwargs): return old_exclude(self, *args, **new_kwargs) else: return self def new_filter(self, *args, **kwargs): new_kwargs = dict() for key, value in kwargs.items(): if not ((isinstance(value, list) and not value) or (isinstance(value, QuerySet) and not value)): new_kwargs[key] = value if len(new_kwargs): return old_filter(self, *args, **new_kwargs) else: return self old_exclude = QuerySet.exclude QuerySet.exclude = new_exclude old_filter = QuerySet.filter QuerySet.filter = new_filter<commit_msg>Fix buggy patched QuerySet methods<commit_after>
# This file is part of e-Giełda. # Copyright (C) 2014 Mateusz Maćkowski and Tomasz Zieliński # # e-Giełda is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # You should have received a copy of the GNU Affero General Public License # along with e-Giełda. If not, see <http://www.gnu.org/licenses/>. from django.db.models import QuerySet def new_exclude(self, *args, **kwargs): new_kwargs = dict() for key, value in kwargs.items(): if not ((isinstance(value, list) and not value) or (isinstance(value, QuerySet) and not value)): new_kwargs[key] = value return old_exclude(self, *args, **new_kwargs) def new_filter(self, *args, **kwargs): new_kwargs = dict() for key, value in kwargs.items(): if not ((isinstance(value, list) and not value) or (isinstance(value, QuerySet) and not value)): new_kwargs[key] = value return old_filter(self, *args, **new_kwargs) old_exclude = QuerySet.exclude QuerySet.exclude = new_exclude old_filter = QuerySet.filter QuerySet.filter = new_filter
# This file is part of e-Giełda. # Copyright (C) 2014 Mateusz Maćkowski and Tomasz Zieliński # # e-Giełda is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # You should have received a copy of the GNU Affero General Public License # along with e-Giełda. If not, see <http://www.gnu.org/licenses/>. from django.db.models import QuerySet def new_exclude(self, *args, **kwargs): new_kwargs = dict() for key, value in kwargs.items(): if not ((isinstance(value, list) and not value) or (isinstance(value, QuerySet) and not value)): new_kwargs[key] = value if len(new_kwargs): return old_exclude(self, *args, **new_kwargs) else: return self def new_filter(self, *args, **kwargs): new_kwargs = dict() for key, value in kwargs.items(): if not ((isinstance(value, list) and not value) or (isinstance(value, QuerySet) and not value)): new_kwargs[key] = value if len(new_kwargs): return old_filter(self, *args, **new_kwargs) else: return self old_exclude = QuerySet.exclude QuerySet.exclude = new_exclude old_filter = QuerySet.filter QuerySet.filter = new_filterFix buggy patched QuerySet methods# This file is part of e-Giełda. # Copyright (C) 2014 Mateusz Maćkowski and Tomasz Zieliński # # e-Giełda is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # You should have received a copy of the GNU Affero General Public License # along with e-Giełda. If not, see <http://www.gnu.org/licenses/>. from django.db.models import QuerySet def new_exclude(self, *args, **kwargs): new_kwargs = dict() for key, value in kwargs.items(): if not ((isinstance(value, list) and not value) or (isinstance(value, QuerySet) and not value)): new_kwargs[key] = value return old_exclude(self, *args, **new_kwargs) def new_filter(self, *args, **kwargs): new_kwargs = dict() for key, value in kwargs.items(): if not ((isinstance(value, list) and not value) or (isinstance(value, QuerySet) and not value)): new_kwargs[key] = value return old_filter(self, *args, **new_kwargs) old_exclude = QuerySet.exclude QuerySet.exclude = new_exclude old_filter = QuerySet.filter QuerySet.filter = new_filter
<commit_before># This file is part of e-Giełda. # Copyright (C) 2014 Mateusz Maćkowski and Tomasz Zieliński # # e-Giełda is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # You should have received a copy of the GNU Affero General Public License # along with e-Giełda. If not, see <http://www.gnu.org/licenses/>. from django.db.models import QuerySet def new_exclude(self, *args, **kwargs): new_kwargs = dict() for key, value in kwargs.items(): if not ((isinstance(value, list) and not value) or (isinstance(value, QuerySet) and not value)): new_kwargs[key] = value if len(new_kwargs): return old_exclude(self, *args, **new_kwargs) else: return self def new_filter(self, *args, **kwargs): new_kwargs = dict() for key, value in kwargs.items(): if not ((isinstance(value, list) and not value) or (isinstance(value, QuerySet) and not value)): new_kwargs[key] = value if len(new_kwargs): return old_filter(self, *args, **new_kwargs) else: return self old_exclude = QuerySet.exclude QuerySet.exclude = new_exclude old_filter = QuerySet.filter QuerySet.filter = new_filter<commit_msg>Fix buggy patched QuerySet methods<commit_after># This file is part of e-Giełda. # Copyright (C) 2014 Mateusz Maćkowski and Tomasz Zieliński # # e-Giełda is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # You should have received a copy of the GNU Affero General Public License # along with e-Giełda. If not, see <http://www.gnu.org/licenses/>. from django.db.models import QuerySet def new_exclude(self, *args, **kwargs): new_kwargs = dict() for key, value in kwargs.items(): if not ((isinstance(value, list) and not value) or (isinstance(value, QuerySet) and not value)): new_kwargs[key] = value return old_exclude(self, *args, **new_kwargs) def new_filter(self, *args, **kwargs): new_kwargs = dict() for key, value in kwargs.items(): if not ((isinstance(value, list) and not value) or (isinstance(value, QuerySet) and not value)): new_kwargs[key] = value return old_filter(self, *args, **new_kwargs) old_exclude = QuerySet.exclude QuerySet.exclude = new_exclude old_filter = QuerySet.filter QuerySet.filter = new_filter
ce6e69c26b6d820b4f835cd56e72244faf0a6636
api/caching/listeners.py
api/caching/listeners.py
from api.caching.tasks import ban_url, logger from framework.guid.model import Guid from framework.tasks.handlers import enqueue_task from modularodm import signals @signals.save.connect def log_object_saved(sender, instance, fields_changed, cached_data): abs_url = None if hasattr(instance, 'absolute_api_v2_url'): abs_url = instance.absolute_api_v2_url else: # I don't think this should ever happen, but ... just in case. guid_obj = Guid.load(instance._id) if guid_obj is not None: typedModel = guid_obj.referent if hasattr(typedModel, 'absolute_api_v2_url'): abs_url = typedModel.absolute_api_v2_url if abs_url is not None: enqueue_task(ban_url.s(abs_url)) else: logger.error('Cannot ban None url for {} with id {}'.format(instance._name, instance._id))
from api.caching.tasks import ban_url, logger from framework.guid.model import Guid from framework.tasks.handlers import enqueue_task from modularodm import signals @signals.save.connect def log_object_saved(sender, instance, fields_changed, cached_data): abs_url = None if hasattr(instance, 'absolute_api_v2_url'): abs_url = instance.absolute_api_v2_url else: # I don't think this should ever happen, but ... just in case. guid_obj = Guid.load(instance._id) if guid_obj is not None: typedModel = guid_obj.referent if hasattr(typedModel, 'absolute_api_v2_url'): abs_url = typedModel.absolute_api_v2_url if abs_url is not None: enqueue_task(ban_url.s(abs_url))
Remove logging. It will just break travis.
Remove logging. It will just break travis.
Python
apache-2.0
RomanZWang/osf.io,billyhunt/osf.io,billyhunt/osf.io,DanielSBrown/osf.io,monikagrabowska/osf.io,pattisdr/osf.io,pattisdr/osf.io,brandonPurvis/osf.io,amyshi188/osf.io,icereval/osf.io,KAsante95/osf.io,cslzchen/osf.io,cwisecarver/osf.io,saradbowman/osf.io,RomanZWang/osf.io,mluo613/osf.io,caneruguz/osf.io,GageGaskins/osf.io,samchrisinger/osf.io,GageGaskins/osf.io,saradbowman/osf.io,laurenrevere/osf.io,erinspace/osf.io,chennan47/osf.io,zamattiac/osf.io,KAsante95/osf.io,RomanZWang/osf.io,TomHeatwole/osf.io,acshi/osf.io,alexschiller/osf.io,aaxelb/osf.io,abought/osf.io,TomBaxter/osf.io,aaxelb/osf.io,binoculars/osf.io,cslzchen/osf.io,mluke93/osf.io,hmoco/osf.io,rdhyee/osf.io,binoculars/osf.io,Johnetordoff/osf.io,caseyrollins/osf.io,mattclark/osf.io,adlius/osf.io,Nesiehr/osf.io,GageGaskins/osf.io,DanielSBrown/osf.io,TomBaxter/osf.io,asanfilippo7/osf.io,abought/osf.io,leb2dg/osf.io,kwierman/osf.io,zamattiac/osf.io,chennan47/osf.io,GageGaskins/osf.io,acshi/osf.io,Nesiehr/osf.io,monikagrabowska/osf.io,monikagrabowska/osf.io,asanfilippo7/osf.io,mattclark/osf.io,kch8qx/osf.io,TomHeatwole/osf.io,caneruguz/osf.io,erinspace/osf.io,caneruguz/osf.io,doublebits/osf.io,alexschiller/osf.io,KAsante95/osf.io,chrisseto/osf.io,KAsante95/osf.io,jnayak1/osf.io,crcresearch/osf.io,cslzchen/osf.io,samchrisinger/osf.io,felliott/osf.io,acshi/osf.io,binoculars/osf.io,brianjgeiger/osf.io,jnayak1/osf.io,TomHeatwole/osf.io,cwisecarver/osf.io,SSJohns/osf.io,RomanZWang/osf.io,Johnetordoff/osf.io,kwierman/osf.io,adlius/osf.io,adlius/osf.io,emetsger/osf.io,aaxelb/osf.io,emetsger/osf.io,RomanZWang/osf.io,sloria/osf.io,leb2dg/osf.io,mluo613/osf.io,felliott/osf.io,baylee-d/osf.io,icereval/osf.io,caseyrollins/osf.io,erinspace/osf.io,mfraezz/osf.io,rdhyee/osf.io,asanfilippo7/osf.io,rdhyee/osf.io,baylee-d/osf.io,zachjanicki/osf.io,DanielSBrown/osf.io,mattclark/osf.io,laurenrevere/osf.io,DanielSBrown/osf.io,leb2dg/osf.io,rdhyee/osf.io,abought/osf.io,kch8qx/osf.io,zachjanicki/osf.io,HalcyonChimera/osf.io,alexschiller/osf.io,monikagrabowska/osf.io,zamattiac/osf.io,kch8qx/osf.io,abought/osf.io,Johnetordoff/osf.io,felliott/osf.io,mfraezz/osf.io,kwierman/osf.io,CenterForOpenScience/osf.io,chennan47/osf.io,cslzchen/osf.io,mluo613/osf.io,HalcyonChimera/osf.io,mluke93/osf.io,emetsger/osf.io,samchrisinger/osf.io,aaxelb/osf.io,caseyrollins/osf.io,emetsger/osf.io,doublebits/osf.io,brandonPurvis/osf.io,brandonPurvis/osf.io,cwisecarver/osf.io,hmoco/osf.io,jnayak1/osf.io,Nesiehr/osf.io,zachjanicki/osf.io,crcresearch/osf.io,alexschiller/osf.io,cwisecarver/osf.io,doublebits/osf.io,baylee-d/osf.io,sloria/osf.io,icereval/osf.io,monikagrabowska/osf.io,Johnetordoff/osf.io,zachjanicki/osf.io,GageGaskins/osf.io,brandonPurvis/osf.io,mluke93/osf.io,mfraezz/osf.io,billyhunt/osf.io,pattisdr/osf.io,asanfilippo7/osf.io,TomHeatwole/osf.io,samchrisinger/osf.io,chrisseto/osf.io,acshi/osf.io,SSJohns/osf.io,doublebits/osf.io,billyhunt/osf.io,jnayak1/osf.io,SSJohns/osf.io,alexschiller/osf.io,SSJohns/osf.io,kch8qx/osf.io,felliott/osf.io,kch8qx/osf.io,mluke93/osf.io,brianjgeiger/osf.io,CenterForOpenScience/osf.io,chrisseto/osf.io,mfraezz/osf.io,laurenrevere/osf.io,doublebits/osf.io,Nesiehr/osf.io,leb2dg/osf.io,caneruguz/osf.io,chrisseto/osf.io,adlius/osf.io,CenterForOpenScience/osf.io,HalcyonChimera/osf.io,brianjgeiger/osf.io,kwierman/osf.io,mluo613/osf.io,wearpants/osf.io,brandonPurvis/osf.io,billyhunt/osf.io,HalcyonChimera/osf.io,brianjgeiger/osf.io,amyshi188/osf.io,zamattiac/osf.io,CenterForOpenScience/osf.io,wearpants/osf.io,acshi/osf.io,hmoco/osf.io,amyshi188/osf.io,sloria/osf.io,amyshi188/osf.io,mluo613/osf.io,hmoco/osf.io,TomBaxter/osf.io,wearpants/osf.io,crcresearch/osf.io,KAsante95/osf.io,wearpants/osf.io
from api.caching.tasks import ban_url, logger from framework.guid.model import Guid from framework.tasks.handlers import enqueue_task from modularodm import signals @signals.save.connect def log_object_saved(sender, instance, fields_changed, cached_data): abs_url = None if hasattr(instance, 'absolute_api_v2_url'): abs_url = instance.absolute_api_v2_url else: # I don't think this should ever happen, but ... just in case. guid_obj = Guid.load(instance._id) if guid_obj is not None: typedModel = guid_obj.referent if hasattr(typedModel, 'absolute_api_v2_url'): abs_url = typedModel.absolute_api_v2_url if abs_url is not None: enqueue_task(ban_url.s(abs_url)) else: logger.error('Cannot ban None url for {} with id {}'.format(instance._name, instance._id)) Remove logging. It will just break travis.
from api.caching.tasks import ban_url, logger from framework.guid.model import Guid from framework.tasks.handlers import enqueue_task from modularodm import signals @signals.save.connect def log_object_saved(sender, instance, fields_changed, cached_data): abs_url = None if hasattr(instance, 'absolute_api_v2_url'): abs_url = instance.absolute_api_v2_url else: # I don't think this should ever happen, but ... just in case. guid_obj = Guid.load(instance._id) if guid_obj is not None: typedModel = guid_obj.referent if hasattr(typedModel, 'absolute_api_v2_url'): abs_url = typedModel.absolute_api_v2_url if abs_url is not None: enqueue_task(ban_url.s(abs_url))
<commit_before>from api.caching.tasks import ban_url, logger from framework.guid.model import Guid from framework.tasks.handlers import enqueue_task from modularodm import signals @signals.save.connect def log_object_saved(sender, instance, fields_changed, cached_data): abs_url = None if hasattr(instance, 'absolute_api_v2_url'): abs_url = instance.absolute_api_v2_url else: # I don't think this should ever happen, but ... just in case. guid_obj = Guid.load(instance._id) if guid_obj is not None: typedModel = guid_obj.referent if hasattr(typedModel, 'absolute_api_v2_url'): abs_url = typedModel.absolute_api_v2_url if abs_url is not None: enqueue_task(ban_url.s(abs_url)) else: logger.error('Cannot ban None url for {} with id {}'.format(instance._name, instance._id)) <commit_msg>Remove logging. It will just break travis.<commit_after>
from api.caching.tasks import ban_url, logger from framework.guid.model import Guid from framework.tasks.handlers import enqueue_task from modularodm import signals @signals.save.connect def log_object_saved(sender, instance, fields_changed, cached_data): abs_url = None if hasattr(instance, 'absolute_api_v2_url'): abs_url = instance.absolute_api_v2_url else: # I don't think this should ever happen, but ... just in case. guid_obj = Guid.load(instance._id) if guid_obj is not None: typedModel = guid_obj.referent if hasattr(typedModel, 'absolute_api_v2_url'): abs_url = typedModel.absolute_api_v2_url if abs_url is not None: enqueue_task(ban_url.s(abs_url))
from api.caching.tasks import ban_url, logger from framework.guid.model import Guid from framework.tasks.handlers import enqueue_task from modularodm import signals @signals.save.connect def log_object_saved(sender, instance, fields_changed, cached_data): abs_url = None if hasattr(instance, 'absolute_api_v2_url'): abs_url = instance.absolute_api_v2_url else: # I don't think this should ever happen, but ... just in case. guid_obj = Guid.load(instance._id) if guid_obj is not None: typedModel = guid_obj.referent if hasattr(typedModel, 'absolute_api_v2_url'): abs_url = typedModel.absolute_api_v2_url if abs_url is not None: enqueue_task(ban_url.s(abs_url)) else: logger.error('Cannot ban None url for {} with id {}'.format(instance._name, instance._id)) Remove logging. It will just break travis.from api.caching.tasks import ban_url, logger from framework.guid.model import Guid from framework.tasks.handlers import enqueue_task from modularodm import signals @signals.save.connect def log_object_saved(sender, instance, fields_changed, cached_data): abs_url = None if hasattr(instance, 'absolute_api_v2_url'): abs_url = instance.absolute_api_v2_url else: # I don't think this should ever happen, but ... just in case. guid_obj = Guid.load(instance._id) if guid_obj is not None: typedModel = guid_obj.referent if hasattr(typedModel, 'absolute_api_v2_url'): abs_url = typedModel.absolute_api_v2_url if abs_url is not None: enqueue_task(ban_url.s(abs_url))
<commit_before>from api.caching.tasks import ban_url, logger from framework.guid.model import Guid from framework.tasks.handlers import enqueue_task from modularodm import signals @signals.save.connect def log_object_saved(sender, instance, fields_changed, cached_data): abs_url = None if hasattr(instance, 'absolute_api_v2_url'): abs_url = instance.absolute_api_v2_url else: # I don't think this should ever happen, but ... just in case. guid_obj = Guid.load(instance._id) if guid_obj is not None: typedModel = guid_obj.referent if hasattr(typedModel, 'absolute_api_v2_url'): abs_url = typedModel.absolute_api_v2_url if abs_url is not None: enqueue_task(ban_url.s(abs_url)) else: logger.error('Cannot ban None url for {} with id {}'.format(instance._name, instance._id)) <commit_msg>Remove logging. It will just break travis.<commit_after>from api.caching.tasks import ban_url, logger from framework.guid.model import Guid from framework.tasks.handlers import enqueue_task from modularodm import signals @signals.save.connect def log_object_saved(sender, instance, fields_changed, cached_data): abs_url = None if hasattr(instance, 'absolute_api_v2_url'): abs_url = instance.absolute_api_v2_url else: # I don't think this should ever happen, but ... just in case. guid_obj = Guid.load(instance._id) if guid_obj is not None: typedModel = guid_obj.referent if hasattr(typedModel, 'absolute_api_v2_url'): abs_url = typedModel.absolute_api_v2_url if abs_url is not None: enqueue_task(ban_url.s(abs_url))
3429a1b543208adf95e60c89477a4219a5a366a3
makesty.py
makesty.py
import re # Input file created from http://astronautweb.co/snippet/font-awesome/ INPUT_FILE = 'htmlfontawesome.txt' OUTPUT_FILE = 'fontawesome.sty' with open(INPUT_FILE) as r, open(OUTPUT_FILE, 'w') as w: for line in r: # Expects to find 'fa-NAME' ending with " name = re.findall(r'fa-[^""]*', line)[0] # Expects to find '\fSYMBOL' ending with " symbol = re.findall(r'\\f[^"]*', line)[0][1:].upper() camel_case = [w.capitalize() for w in name.split('-')] camel_case[0] = camel_case[0].lower() camel_name = ''.join(camel_case) name = name.lstrip('fa-') print('\expandafter\def\csname faicon@{name}\endcsname ' '{{\symbol{{"{symbol}}}}} \def\{camel_name} ' '{{{{\FA\csname faicon@{name}\endcsname}}}}'.format(name=name, camel_name=camel_name, symbol=symbol), file=w)
import re # Input file created from http://astronautweb.co/snippet/font-awesome/ INPUT_FILE = 'htmlfontawesome.txt' OUTPUT_FILE = 'fontawesome.sty' OUTPUT_HEADER = r''' % Identify this package. \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{fontawesome}[2014/04/24 v4.0.3 font awesome icons] % Requirements to use. \usepackage{fontspec} % Define shortcut to load the Font Awesome font. \newfontfamily{\FA}{FontAwesome} % Generic command displaying an icon by its name. \newcommand*{\faicon}[1]{{ \FA\csname faicon@#1\endcsname }} ''' with open(INPUT_FILE) as r, open(OUTPUT_FILE, 'w') as w: print(OUTPUT_HEADER, file=w) for line in r: # Expects to find 'fa-NAME' ending with " name = re.findall(r'fa-[^""]*', line)[0] # Expects to find '\fSYMBOL' ending with " symbol = re.findall(r'\\f[^"]*', line)[0][1:].upper() camel_case = [w.capitalize() for w in name.split('-')] camel_case[0] = camel_case[0].lower() camel_name = ''.join(camel_case) name = name.lstrip('fa-') print('\expandafter\def\csname faicon@{name}\endcsname ' '{{\symbol{{"{symbol}}}}} \def\{camel_name} ' '{{{{\FA\csname faicon@{name}\endcsname}}}}'.format(name=name, camel_name=camel_name, symbol=symbol), file=w) print(r'\endinput', file=w)
Add header and footer sections to the .sty.
Add header and footer sections to the .sty.
Python
mit
posquit0/latex-fontawesome
import re # Input file created from http://astronautweb.co/snippet/font-awesome/ INPUT_FILE = 'htmlfontawesome.txt' OUTPUT_FILE = 'fontawesome.sty' with open(INPUT_FILE) as r, open(OUTPUT_FILE, 'w') as w: for line in r: # Expects to find 'fa-NAME' ending with " name = re.findall(r'fa-[^""]*', line)[0] # Expects to find '\fSYMBOL' ending with " symbol = re.findall(r'\\f[^"]*', line)[0][1:].upper() camel_case = [w.capitalize() for w in name.split('-')] camel_case[0] = camel_case[0].lower() camel_name = ''.join(camel_case) name = name.lstrip('fa-') print('\expandafter\def\csname faicon@{name}\endcsname ' '{{\symbol{{"{symbol}}}}} \def\{camel_name} ' '{{{{\FA\csname faicon@{name}\endcsname}}}}'.format(name=name, camel_name=camel_name, symbol=symbol), file=w) Add header and footer sections to the .sty.
import re # Input file created from http://astronautweb.co/snippet/font-awesome/ INPUT_FILE = 'htmlfontawesome.txt' OUTPUT_FILE = 'fontawesome.sty' OUTPUT_HEADER = r''' % Identify this package. \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{fontawesome}[2014/04/24 v4.0.3 font awesome icons] % Requirements to use. \usepackage{fontspec} % Define shortcut to load the Font Awesome font. \newfontfamily{\FA}{FontAwesome} % Generic command displaying an icon by its name. \newcommand*{\faicon}[1]{{ \FA\csname faicon@#1\endcsname }} ''' with open(INPUT_FILE) as r, open(OUTPUT_FILE, 'w') as w: print(OUTPUT_HEADER, file=w) for line in r: # Expects to find 'fa-NAME' ending with " name = re.findall(r'fa-[^""]*', line)[0] # Expects to find '\fSYMBOL' ending with " symbol = re.findall(r'\\f[^"]*', line)[0][1:].upper() camel_case = [w.capitalize() for w in name.split('-')] camel_case[0] = camel_case[0].lower() camel_name = ''.join(camel_case) name = name.lstrip('fa-') print('\expandafter\def\csname faicon@{name}\endcsname ' '{{\symbol{{"{symbol}}}}} \def\{camel_name} ' '{{{{\FA\csname faicon@{name}\endcsname}}}}'.format(name=name, camel_name=camel_name, symbol=symbol), file=w) print(r'\endinput', file=w)
<commit_before>import re # Input file created from http://astronautweb.co/snippet/font-awesome/ INPUT_FILE = 'htmlfontawesome.txt' OUTPUT_FILE = 'fontawesome.sty' with open(INPUT_FILE) as r, open(OUTPUT_FILE, 'w') as w: for line in r: # Expects to find 'fa-NAME' ending with " name = re.findall(r'fa-[^""]*', line)[0] # Expects to find '\fSYMBOL' ending with " symbol = re.findall(r'\\f[^"]*', line)[0][1:].upper() camel_case = [w.capitalize() for w in name.split('-')] camel_case[0] = camel_case[0].lower() camel_name = ''.join(camel_case) name = name.lstrip('fa-') print('\expandafter\def\csname faicon@{name}\endcsname ' '{{\symbol{{"{symbol}}}}} \def\{camel_name} ' '{{{{\FA\csname faicon@{name}\endcsname}}}}'.format(name=name, camel_name=camel_name, symbol=symbol), file=w) <commit_msg>Add header and footer sections to the .sty.<commit_after>
import re # Input file created from http://astronautweb.co/snippet/font-awesome/ INPUT_FILE = 'htmlfontawesome.txt' OUTPUT_FILE = 'fontawesome.sty' OUTPUT_HEADER = r''' % Identify this package. \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{fontawesome}[2014/04/24 v4.0.3 font awesome icons] % Requirements to use. \usepackage{fontspec} % Define shortcut to load the Font Awesome font. \newfontfamily{\FA}{FontAwesome} % Generic command displaying an icon by its name. \newcommand*{\faicon}[1]{{ \FA\csname faicon@#1\endcsname }} ''' with open(INPUT_FILE) as r, open(OUTPUT_FILE, 'w') as w: print(OUTPUT_HEADER, file=w) for line in r: # Expects to find 'fa-NAME' ending with " name = re.findall(r'fa-[^""]*', line)[0] # Expects to find '\fSYMBOL' ending with " symbol = re.findall(r'\\f[^"]*', line)[0][1:].upper() camel_case = [w.capitalize() for w in name.split('-')] camel_case[0] = camel_case[0].lower() camel_name = ''.join(camel_case) name = name.lstrip('fa-') print('\expandafter\def\csname faicon@{name}\endcsname ' '{{\symbol{{"{symbol}}}}} \def\{camel_name} ' '{{{{\FA\csname faicon@{name}\endcsname}}}}'.format(name=name, camel_name=camel_name, symbol=symbol), file=w) print(r'\endinput', file=w)
import re # Input file created from http://astronautweb.co/snippet/font-awesome/ INPUT_FILE = 'htmlfontawesome.txt' OUTPUT_FILE = 'fontawesome.sty' with open(INPUT_FILE) as r, open(OUTPUT_FILE, 'w') as w: for line in r: # Expects to find 'fa-NAME' ending with " name = re.findall(r'fa-[^""]*', line)[0] # Expects to find '\fSYMBOL' ending with " symbol = re.findall(r'\\f[^"]*', line)[0][1:].upper() camel_case = [w.capitalize() for w in name.split('-')] camel_case[0] = camel_case[0].lower() camel_name = ''.join(camel_case) name = name.lstrip('fa-') print('\expandafter\def\csname faicon@{name}\endcsname ' '{{\symbol{{"{symbol}}}}} \def\{camel_name} ' '{{{{\FA\csname faicon@{name}\endcsname}}}}'.format(name=name, camel_name=camel_name, symbol=symbol), file=w) Add header and footer sections to the .sty.import re # Input file created from http://astronautweb.co/snippet/font-awesome/ INPUT_FILE = 'htmlfontawesome.txt' OUTPUT_FILE = 'fontawesome.sty' OUTPUT_HEADER = r''' % Identify this package. \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{fontawesome}[2014/04/24 v4.0.3 font awesome icons] % Requirements to use. \usepackage{fontspec} % Define shortcut to load the Font Awesome font. \newfontfamily{\FA}{FontAwesome} % Generic command displaying an icon by its name. \newcommand*{\faicon}[1]{{ \FA\csname faicon@#1\endcsname }} ''' with open(INPUT_FILE) as r, open(OUTPUT_FILE, 'w') as w: print(OUTPUT_HEADER, file=w) for line in r: # Expects to find 'fa-NAME' ending with " name = re.findall(r'fa-[^""]*', line)[0] # Expects to find '\fSYMBOL' ending with " symbol = re.findall(r'\\f[^"]*', line)[0][1:].upper() camel_case = [w.capitalize() for w in name.split('-')] camel_case[0] = camel_case[0].lower() camel_name = ''.join(camel_case) name = name.lstrip('fa-') print('\expandafter\def\csname faicon@{name}\endcsname ' '{{\symbol{{"{symbol}}}}} \def\{camel_name} ' '{{{{\FA\csname faicon@{name}\endcsname}}}}'.format(name=name, camel_name=camel_name, symbol=symbol), file=w) print(r'\endinput', file=w)
<commit_before>import re # Input file created from http://astronautweb.co/snippet/font-awesome/ INPUT_FILE = 'htmlfontawesome.txt' OUTPUT_FILE = 'fontawesome.sty' with open(INPUT_FILE) as r, open(OUTPUT_FILE, 'w') as w: for line in r: # Expects to find 'fa-NAME' ending with " name = re.findall(r'fa-[^""]*', line)[0] # Expects to find '\fSYMBOL' ending with " symbol = re.findall(r'\\f[^"]*', line)[0][1:].upper() camel_case = [w.capitalize() for w in name.split('-')] camel_case[0] = camel_case[0].lower() camel_name = ''.join(camel_case) name = name.lstrip('fa-') print('\expandafter\def\csname faicon@{name}\endcsname ' '{{\symbol{{"{symbol}}}}} \def\{camel_name} ' '{{{{\FA\csname faicon@{name}\endcsname}}}}'.format(name=name, camel_name=camel_name, symbol=symbol), file=w) <commit_msg>Add header and footer sections to the .sty.<commit_after>import re # Input file created from http://astronautweb.co/snippet/font-awesome/ INPUT_FILE = 'htmlfontawesome.txt' OUTPUT_FILE = 'fontawesome.sty' OUTPUT_HEADER = r''' % Identify this package. \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{fontawesome}[2014/04/24 v4.0.3 font awesome icons] % Requirements to use. \usepackage{fontspec} % Define shortcut to load the Font Awesome font. \newfontfamily{\FA}{FontAwesome} % Generic command displaying an icon by its name. \newcommand*{\faicon}[1]{{ \FA\csname faicon@#1\endcsname }} ''' with open(INPUT_FILE) as r, open(OUTPUT_FILE, 'w') as w: print(OUTPUT_HEADER, file=w) for line in r: # Expects to find 'fa-NAME' ending with " name = re.findall(r'fa-[^""]*', line)[0] # Expects to find '\fSYMBOL' ending with " symbol = re.findall(r'\\f[^"]*', line)[0][1:].upper() camel_case = [w.capitalize() for w in name.split('-')] camel_case[0] = camel_case[0].lower() camel_name = ''.join(camel_case) name = name.lstrip('fa-') print('\expandafter\def\csname faicon@{name}\endcsname ' '{{\symbol{{"{symbol}}}}} \def\{camel_name} ' '{{{{\FA\csname faicon@{name}\endcsname}}}}'.format(name=name, camel_name=camel_name, symbol=symbol), file=w) print(r'\endinput', file=w)
f87f2ec4707bcf851e00ff58bbfe43f4d7523606
scripts/dnz-fetch.py
scripts/dnz-fetch.py
import os import math import json from pprint import pprint from pydnz import Dnz dnz = Dnz(os.environ.get('DNZ_KEY')) results = [] def dnz_request(page=1): filters = { 'category': ['Images'], 'year': ['2005+TO+2006'] } fields = ['id', 'date'] return dnz.search('', _and=filters, per_page=100, page=page, fields=fields) # First request. first_result = dnz_request() results = first_result.records iterations = math.ceil(first_result.result_count / 100) # iterations = 5 # Subsequent requests. for i in range(2, iterations + 1): records = dnz_request(i).records for record in records: results.append({ 'id': record['id'], 'date': record['date'] }) pprint(len(results)) with open('dnz-2015.json', 'w') as outfile: json.dump(results, outfile)
import os # import math import json from pprint import pprint from datetime import date from pydnz import Dnz dnz_api = Dnz(os.environ.get('DNZ_KEY')) YEAR_INTERVAL = 10 def request_dnz_records(timespan, page): parameters = { '_and': { 'category': ['Images'], 'year': [timespan] }, 'per_page': 100, 'page': page, 'fields': [ 'id', 'date' ] } return dnz_api.search('', **parameters) def format_timespan(year1, year2): return '{y1}+TO+{y2}'.format(y1=year1, y2=year2) def fetch_timespan(timespan): pprint('Fetching ' + timespan) first_result = request_dnz_records(timespan, 1) store_results(first_result.records) pprint(first_result.result_count) # iterations = math.ceil(first_result.result_count / 100) iterations = 1 # Subsequent requests. for i in range(2, iterations + 1): records = request_dnz_records(i).records store_results(records) pprint(len(results)) def store_results(records): for record in records: results.append({ 'id': record['id'], 'date': record['date'] }) if __name__ == '__main__': results = [] present = date.today().year past = present - YEAR_INTERVAL years = [y for y in range(2005, 2006)] timespans = [format_timespan(y, y + 1) for y in years] for timespan in timespans: fetch_timespan(timespan) with open('dnz-records.json', 'w') as outfile: json.dump(results, outfile)
Refactor DNZ fetch script before overhaul
Refactor DNZ fetch script before overhaul
Python
mit
judsonsam/tekautoday,judsonsam/tekautoday,judsonsam/tekautoday,judsonsam/tekautoday
import os import math import json from pprint import pprint from pydnz import Dnz dnz = Dnz(os.environ.get('DNZ_KEY')) results = [] def dnz_request(page=1): filters = { 'category': ['Images'], 'year': ['2005+TO+2006'] } fields = ['id', 'date'] return dnz.search('', _and=filters, per_page=100, page=page, fields=fields) # First request. first_result = dnz_request() results = first_result.records iterations = math.ceil(first_result.result_count / 100) # iterations = 5 # Subsequent requests. for i in range(2, iterations + 1): records = dnz_request(i).records for record in records: results.append({ 'id': record['id'], 'date': record['date'] }) pprint(len(results)) with open('dnz-2015.json', 'w') as outfile: json.dump(results, outfile) Refactor DNZ fetch script before overhaul
import os # import math import json from pprint import pprint from datetime import date from pydnz import Dnz dnz_api = Dnz(os.environ.get('DNZ_KEY')) YEAR_INTERVAL = 10 def request_dnz_records(timespan, page): parameters = { '_and': { 'category': ['Images'], 'year': [timespan] }, 'per_page': 100, 'page': page, 'fields': [ 'id', 'date' ] } return dnz_api.search('', **parameters) def format_timespan(year1, year2): return '{y1}+TO+{y2}'.format(y1=year1, y2=year2) def fetch_timespan(timespan): pprint('Fetching ' + timespan) first_result = request_dnz_records(timespan, 1) store_results(first_result.records) pprint(first_result.result_count) # iterations = math.ceil(first_result.result_count / 100) iterations = 1 # Subsequent requests. for i in range(2, iterations + 1): records = request_dnz_records(i).records store_results(records) pprint(len(results)) def store_results(records): for record in records: results.append({ 'id': record['id'], 'date': record['date'] }) if __name__ == '__main__': results = [] present = date.today().year past = present - YEAR_INTERVAL years = [y for y in range(2005, 2006)] timespans = [format_timespan(y, y + 1) for y in years] for timespan in timespans: fetch_timespan(timespan) with open('dnz-records.json', 'w') as outfile: json.dump(results, outfile)
<commit_before>import os import math import json from pprint import pprint from pydnz import Dnz dnz = Dnz(os.environ.get('DNZ_KEY')) results = [] def dnz_request(page=1): filters = { 'category': ['Images'], 'year': ['2005+TO+2006'] } fields = ['id', 'date'] return dnz.search('', _and=filters, per_page=100, page=page, fields=fields) # First request. first_result = dnz_request() results = first_result.records iterations = math.ceil(first_result.result_count / 100) # iterations = 5 # Subsequent requests. for i in range(2, iterations + 1): records = dnz_request(i).records for record in records: results.append({ 'id': record['id'], 'date': record['date'] }) pprint(len(results)) with open('dnz-2015.json', 'w') as outfile: json.dump(results, outfile) <commit_msg>Refactor DNZ fetch script before overhaul<commit_after>
import os # import math import json from pprint import pprint from datetime import date from pydnz import Dnz dnz_api = Dnz(os.environ.get('DNZ_KEY')) YEAR_INTERVAL = 10 def request_dnz_records(timespan, page): parameters = { '_and': { 'category': ['Images'], 'year': [timespan] }, 'per_page': 100, 'page': page, 'fields': [ 'id', 'date' ] } return dnz_api.search('', **parameters) def format_timespan(year1, year2): return '{y1}+TO+{y2}'.format(y1=year1, y2=year2) def fetch_timespan(timespan): pprint('Fetching ' + timespan) first_result = request_dnz_records(timespan, 1) store_results(first_result.records) pprint(first_result.result_count) # iterations = math.ceil(first_result.result_count / 100) iterations = 1 # Subsequent requests. for i in range(2, iterations + 1): records = request_dnz_records(i).records store_results(records) pprint(len(results)) def store_results(records): for record in records: results.append({ 'id': record['id'], 'date': record['date'] }) if __name__ == '__main__': results = [] present = date.today().year past = present - YEAR_INTERVAL years = [y for y in range(2005, 2006)] timespans = [format_timespan(y, y + 1) for y in years] for timespan in timespans: fetch_timespan(timespan) with open('dnz-records.json', 'w') as outfile: json.dump(results, outfile)
import os import math import json from pprint import pprint from pydnz import Dnz dnz = Dnz(os.environ.get('DNZ_KEY')) results = [] def dnz_request(page=1): filters = { 'category': ['Images'], 'year': ['2005+TO+2006'] } fields = ['id', 'date'] return dnz.search('', _and=filters, per_page=100, page=page, fields=fields) # First request. first_result = dnz_request() results = first_result.records iterations = math.ceil(first_result.result_count / 100) # iterations = 5 # Subsequent requests. for i in range(2, iterations + 1): records = dnz_request(i).records for record in records: results.append({ 'id': record['id'], 'date': record['date'] }) pprint(len(results)) with open('dnz-2015.json', 'w') as outfile: json.dump(results, outfile) Refactor DNZ fetch script before overhaulimport os # import math import json from pprint import pprint from datetime import date from pydnz import Dnz dnz_api = Dnz(os.environ.get('DNZ_KEY')) YEAR_INTERVAL = 10 def request_dnz_records(timespan, page): parameters = { '_and': { 'category': ['Images'], 'year': [timespan] }, 'per_page': 100, 'page': page, 'fields': [ 'id', 'date' ] } return dnz_api.search('', **parameters) def format_timespan(year1, year2): return '{y1}+TO+{y2}'.format(y1=year1, y2=year2) def fetch_timespan(timespan): pprint('Fetching ' + timespan) first_result = request_dnz_records(timespan, 1) store_results(first_result.records) pprint(first_result.result_count) # iterations = math.ceil(first_result.result_count / 100) iterations = 1 # Subsequent requests. for i in range(2, iterations + 1): records = request_dnz_records(i).records store_results(records) pprint(len(results)) def store_results(records): for record in records: results.append({ 'id': record['id'], 'date': record['date'] }) if __name__ == '__main__': results = [] present = date.today().year past = present - YEAR_INTERVAL years = [y for y in range(2005, 2006)] timespans = [format_timespan(y, y + 1) for y in years] for timespan in timespans: fetch_timespan(timespan) with open('dnz-records.json', 'w') as outfile: json.dump(results, outfile)
<commit_before>import os import math import json from pprint import pprint from pydnz import Dnz dnz = Dnz(os.environ.get('DNZ_KEY')) results = [] def dnz_request(page=1): filters = { 'category': ['Images'], 'year': ['2005+TO+2006'] } fields = ['id', 'date'] return dnz.search('', _and=filters, per_page=100, page=page, fields=fields) # First request. first_result = dnz_request() results = first_result.records iterations = math.ceil(first_result.result_count / 100) # iterations = 5 # Subsequent requests. for i in range(2, iterations + 1): records = dnz_request(i).records for record in records: results.append({ 'id': record['id'], 'date': record['date'] }) pprint(len(results)) with open('dnz-2015.json', 'w') as outfile: json.dump(results, outfile) <commit_msg>Refactor DNZ fetch script before overhaul<commit_after>import os # import math import json from pprint import pprint from datetime import date from pydnz import Dnz dnz_api = Dnz(os.environ.get('DNZ_KEY')) YEAR_INTERVAL = 10 def request_dnz_records(timespan, page): parameters = { '_and': { 'category': ['Images'], 'year': [timespan] }, 'per_page': 100, 'page': page, 'fields': [ 'id', 'date' ] } return dnz_api.search('', **parameters) def format_timespan(year1, year2): return '{y1}+TO+{y2}'.format(y1=year1, y2=year2) def fetch_timespan(timespan): pprint('Fetching ' + timespan) first_result = request_dnz_records(timespan, 1) store_results(first_result.records) pprint(first_result.result_count) # iterations = math.ceil(first_result.result_count / 100) iterations = 1 # Subsequent requests. for i in range(2, iterations + 1): records = request_dnz_records(i).records store_results(records) pprint(len(results)) def store_results(records): for record in records: results.append({ 'id': record['id'], 'date': record['date'] }) if __name__ == '__main__': results = [] present = date.today().year past = present - YEAR_INTERVAL years = [y for y in range(2005, 2006)] timespans = [format_timespan(y, y + 1) for y in years] for timespan in timespans: fetch_timespan(timespan) with open('dnz-records.json', 'w') as outfile: json.dump(results, outfile)
be5541bd16a84c37b973cf77cb0f4d5c5e83e39a
spacy/tests/regression/test_issue768.py
spacy/tests/regression/test_issue768.py
# coding: utf-8 from __future__ import unicode_literals from ...language import Language from ...attrs import LANG from ...fr.language_data import get_tokenizer_exceptions, STOP_WORDS from ...language_data.punctuation import TOKENIZER_INFIXES, ALPHA import pytest @pytest.fixture def fr_tokenizer_w_infix(): SPLIT_INFIX = r'(?<=[{a}]\')(?=[{a}])'.format(a=ALPHA) # create new Language subclass to add to default infixes class French(Language): lang = 'fr' class Defaults(Language.Defaults): lex_attr_getters = dict(Language.Defaults.lex_attr_getters) lex_attr_getters[LANG] = lambda text: 'fr' tokenizer_exceptions = get_tokenizer_exceptions() stop_words = STOP_WORDS infixes = TOKENIZER_INFIXES + [SPLIT_INFIX] return French.Defaults.create_tokenizer() @pytest.mark.parametrize('text,expected_tokens', [("l'avion", ["l'", "avion"]), ("j'ai", ["j'", "ai"])]) def test_issue768(fr_tokenizer_w_infix, text, expected_tokens): """Allow zero-width 'infix' token during the tokenization process.""" tokens = fr_tokenizer_w_infix(text) assert len(tokens) == 2 assert [t.text for t in tokens] == expected_tokens
# coding: utf-8 from __future__ import unicode_literals from ...language import Language from ...attrs import LANG from ...fr.stop_words import STOP_WORDS from ...fr.tokenizer_exceptions import TOKENIZER_EXCEPTIONS from ...language_data.punctuation import TOKENIZER_INFIXES, ALPHA from ...util import update_exc import pytest @pytest.fixture def fr_tokenizer_w_infix(): SPLIT_INFIX = r'(?<=[{a}]\')(?=[{a}])'.format(a=ALPHA) # create new Language subclass to add to default infixes class French(Language): lang = 'fr' class Defaults(Language.Defaults): lex_attr_getters = dict(Language.Defaults.lex_attr_getters) lex_attr_getters[LANG] = lambda text: 'fr' tokenizer_exceptions = update_exc(TOKENIZER_EXCEPTIONS) stop_words = STOP_WORDS infixes = TOKENIZER_INFIXES + [SPLIT_INFIX] return French.Defaults.create_tokenizer() @pytest.mark.parametrize('text,expected_tokens', [("l'avion", ["l'", "avion"]), ("j'ai", ["j'", "ai"])]) def test_issue768(fr_tokenizer_w_infix, text, expected_tokens): """Allow zero-width 'infix' token during the tokenization process.""" tokens = fr_tokenizer_w_infix(text) assert len(tokens) == 2 assert [t.text for t in tokens] == expected_tokens
Fix import and tokenizer exceptions
Fix import and tokenizer exceptions
Python
mit
explosion/spaCy,honnibal/spaCy,recognai/spaCy,explosion/spaCy,explosion/spaCy,aikramer2/spaCy,aikramer2/spaCy,recognai/spaCy,explosion/spaCy,spacy-io/spaCy,aikramer2/spaCy,aikramer2/spaCy,recognai/spaCy,recognai/spaCy,spacy-io/spaCy,honnibal/spaCy,spacy-io/spaCy,spacy-io/spaCy,aikramer2/spaCy,spacy-io/spaCy,explosion/spaCy,recognai/spaCy,recognai/spaCy,explosion/spaCy,aikramer2/spaCy,honnibal/spaCy,honnibal/spaCy,spacy-io/spaCy
# coding: utf-8 from __future__ import unicode_literals from ...language import Language from ...attrs import LANG from ...fr.language_data import get_tokenizer_exceptions, STOP_WORDS from ...language_data.punctuation import TOKENIZER_INFIXES, ALPHA import pytest @pytest.fixture def fr_tokenizer_w_infix(): SPLIT_INFIX = r'(?<=[{a}]\')(?=[{a}])'.format(a=ALPHA) # create new Language subclass to add to default infixes class French(Language): lang = 'fr' class Defaults(Language.Defaults): lex_attr_getters = dict(Language.Defaults.lex_attr_getters) lex_attr_getters[LANG] = lambda text: 'fr' tokenizer_exceptions = get_tokenizer_exceptions() stop_words = STOP_WORDS infixes = TOKENIZER_INFIXES + [SPLIT_INFIX] return French.Defaults.create_tokenizer() @pytest.mark.parametrize('text,expected_tokens', [("l'avion", ["l'", "avion"]), ("j'ai", ["j'", "ai"])]) def test_issue768(fr_tokenizer_w_infix, text, expected_tokens): """Allow zero-width 'infix' token during the tokenization process.""" tokens = fr_tokenizer_w_infix(text) assert len(tokens) == 2 assert [t.text for t in tokens] == expected_tokens Fix import and tokenizer exceptions
# coding: utf-8 from __future__ import unicode_literals from ...language import Language from ...attrs import LANG from ...fr.stop_words import STOP_WORDS from ...fr.tokenizer_exceptions import TOKENIZER_EXCEPTIONS from ...language_data.punctuation import TOKENIZER_INFIXES, ALPHA from ...util import update_exc import pytest @pytest.fixture def fr_tokenizer_w_infix(): SPLIT_INFIX = r'(?<=[{a}]\')(?=[{a}])'.format(a=ALPHA) # create new Language subclass to add to default infixes class French(Language): lang = 'fr' class Defaults(Language.Defaults): lex_attr_getters = dict(Language.Defaults.lex_attr_getters) lex_attr_getters[LANG] = lambda text: 'fr' tokenizer_exceptions = update_exc(TOKENIZER_EXCEPTIONS) stop_words = STOP_WORDS infixes = TOKENIZER_INFIXES + [SPLIT_INFIX] return French.Defaults.create_tokenizer() @pytest.mark.parametrize('text,expected_tokens', [("l'avion", ["l'", "avion"]), ("j'ai", ["j'", "ai"])]) def test_issue768(fr_tokenizer_w_infix, text, expected_tokens): """Allow zero-width 'infix' token during the tokenization process.""" tokens = fr_tokenizer_w_infix(text) assert len(tokens) == 2 assert [t.text for t in tokens] == expected_tokens
<commit_before># coding: utf-8 from __future__ import unicode_literals from ...language import Language from ...attrs import LANG from ...fr.language_data import get_tokenizer_exceptions, STOP_WORDS from ...language_data.punctuation import TOKENIZER_INFIXES, ALPHA import pytest @pytest.fixture def fr_tokenizer_w_infix(): SPLIT_INFIX = r'(?<=[{a}]\')(?=[{a}])'.format(a=ALPHA) # create new Language subclass to add to default infixes class French(Language): lang = 'fr' class Defaults(Language.Defaults): lex_attr_getters = dict(Language.Defaults.lex_attr_getters) lex_attr_getters[LANG] = lambda text: 'fr' tokenizer_exceptions = get_tokenizer_exceptions() stop_words = STOP_WORDS infixes = TOKENIZER_INFIXES + [SPLIT_INFIX] return French.Defaults.create_tokenizer() @pytest.mark.parametrize('text,expected_tokens', [("l'avion", ["l'", "avion"]), ("j'ai", ["j'", "ai"])]) def test_issue768(fr_tokenizer_w_infix, text, expected_tokens): """Allow zero-width 'infix' token during the tokenization process.""" tokens = fr_tokenizer_w_infix(text) assert len(tokens) == 2 assert [t.text for t in tokens] == expected_tokens <commit_msg>Fix import and tokenizer exceptions<commit_after>
# coding: utf-8 from __future__ import unicode_literals from ...language import Language from ...attrs import LANG from ...fr.stop_words import STOP_WORDS from ...fr.tokenizer_exceptions import TOKENIZER_EXCEPTIONS from ...language_data.punctuation import TOKENIZER_INFIXES, ALPHA from ...util import update_exc import pytest @pytest.fixture def fr_tokenizer_w_infix(): SPLIT_INFIX = r'(?<=[{a}]\')(?=[{a}])'.format(a=ALPHA) # create new Language subclass to add to default infixes class French(Language): lang = 'fr' class Defaults(Language.Defaults): lex_attr_getters = dict(Language.Defaults.lex_attr_getters) lex_attr_getters[LANG] = lambda text: 'fr' tokenizer_exceptions = update_exc(TOKENIZER_EXCEPTIONS) stop_words = STOP_WORDS infixes = TOKENIZER_INFIXES + [SPLIT_INFIX] return French.Defaults.create_tokenizer() @pytest.mark.parametrize('text,expected_tokens', [("l'avion", ["l'", "avion"]), ("j'ai", ["j'", "ai"])]) def test_issue768(fr_tokenizer_w_infix, text, expected_tokens): """Allow zero-width 'infix' token during the tokenization process.""" tokens = fr_tokenizer_w_infix(text) assert len(tokens) == 2 assert [t.text for t in tokens] == expected_tokens
# coding: utf-8 from __future__ import unicode_literals from ...language import Language from ...attrs import LANG from ...fr.language_data import get_tokenizer_exceptions, STOP_WORDS from ...language_data.punctuation import TOKENIZER_INFIXES, ALPHA import pytest @pytest.fixture def fr_tokenizer_w_infix(): SPLIT_INFIX = r'(?<=[{a}]\')(?=[{a}])'.format(a=ALPHA) # create new Language subclass to add to default infixes class French(Language): lang = 'fr' class Defaults(Language.Defaults): lex_attr_getters = dict(Language.Defaults.lex_attr_getters) lex_attr_getters[LANG] = lambda text: 'fr' tokenizer_exceptions = get_tokenizer_exceptions() stop_words = STOP_WORDS infixes = TOKENIZER_INFIXES + [SPLIT_INFIX] return French.Defaults.create_tokenizer() @pytest.mark.parametrize('text,expected_tokens', [("l'avion", ["l'", "avion"]), ("j'ai", ["j'", "ai"])]) def test_issue768(fr_tokenizer_w_infix, text, expected_tokens): """Allow zero-width 'infix' token during the tokenization process.""" tokens = fr_tokenizer_w_infix(text) assert len(tokens) == 2 assert [t.text for t in tokens] == expected_tokens Fix import and tokenizer exceptions# coding: utf-8 from __future__ import unicode_literals from ...language import Language from ...attrs import LANG from ...fr.stop_words import STOP_WORDS from ...fr.tokenizer_exceptions import TOKENIZER_EXCEPTIONS from ...language_data.punctuation import TOKENIZER_INFIXES, ALPHA from ...util import update_exc import pytest @pytest.fixture def fr_tokenizer_w_infix(): SPLIT_INFIX = r'(?<=[{a}]\')(?=[{a}])'.format(a=ALPHA) # create new Language subclass to add to default infixes class French(Language): lang = 'fr' class Defaults(Language.Defaults): lex_attr_getters = dict(Language.Defaults.lex_attr_getters) lex_attr_getters[LANG] = lambda text: 'fr' tokenizer_exceptions = update_exc(TOKENIZER_EXCEPTIONS) stop_words = STOP_WORDS infixes = TOKENIZER_INFIXES + [SPLIT_INFIX] return French.Defaults.create_tokenizer() @pytest.mark.parametrize('text,expected_tokens', [("l'avion", ["l'", "avion"]), ("j'ai", ["j'", "ai"])]) def test_issue768(fr_tokenizer_w_infix, text, expected_tokens): """Allow zero-width 'infix' token during the tokenization process.""" tokens = fr_tokenizer_w_infix(text) assert len(tokens) == 2 assert [t.text for t in tokens] == expected_tokens
<commit_before># coding: utf-8 from __future__ import unicode_literals from ...language import Language from ...attrs import LANG from ...fr.language_data import get_tokenizer_exceptions, STOP_WORDS from ...language_data.punctuation import TOKENIZER_INFIXES, ALPHA import pytest @pytest.fixture def fr_tokenizer_w_infix(): SPLIT_INFIX = r'(?<=[{a}]\')(?=[{a}])'.format(a=ALPHA) # create new Language subclass to add to default infixes class French(Language): lang = 'fr' class Defaults(Language.Defaults): lex_attr_getters = dict(Language.Defaults.lex_attr_getters) lex_attr_getters[LANG] = lambda text: 'fr' tokenizer_exceptions = get_tokenizer_exceptions() stop_words = STOP_WORDS infixes = TOKENIZER_INFIXES + [SPLIT_INFIX] return French.Defaults.create_tokenizer() @pytest.mark.parametrize('text,expected_tokens', [("l'avion", ["l'", "avion"]), ("j'ai", ["j'", "ai"])]) def test_issue768(fr_tokenizer_w_infix, text, expected_tokens): """Allow zero-width 'infix' token during the tokenization process.""" tokens = fr_tokenizer_w_infix(text) assert len(tokens) == 2 assert [t.text for t in tokens] == expected_tokens <commit_msg>Fix import and tokenizer exceptions<commit_after># coding: utf-8 from __future__ import unicode_literals from ...language import Language from ...attrs import LANG from ...fr.stop_words import STOP_WORDS from ...fr.tokenizer_exceptions import TOKENIZER_EXCEPTIONS from ...language_data.punctuation import TOKENIZER_INFIXES, ALPHA from ...util import update_exc import pytest @pytest.fixture def fr_tokenizer_w_infix(): SPLIT_INFIX = r'(?<=[{a}]\')(?=[{a}])'.format(a=ALPHA) # create new Language subclass to add to default infixes class French(Language): lang = 'fr' class Defaults(Language.Defaults): lex_attr_getters = dict(Language.Defaults.lex_attr_getters) lex_attr_getters[LANG] = lambda text: 'fr' tokenizer_exceptions = update_exc(TOKENIZER_EXCEPTIONS) stop_words = STOP_WORDS infixes = TOKENIZER_INFIXES + [SPLIT_INFIX] return French.Defaults.create_tokenizer() @pytest.mark.parametrize('text,expected_tokens', [("l'avion", ["l'", "avion"]), ("j'ai", ["j'", "ai"])]) def test_issue768(fr_tokenizer_w_infix, text, expected_tokens): """Allow zero-width 'infix' token during the tokenization process.""" tokens = fr_tokenizer_w_infix(text) assert len(tokens) == 2 assert [t.text for t in tokens] == expected_tokens
99ef8377b5bf540542efe718a4eb4345a4b4d5a4
drf_writable_nested/__init__.py
drf_writable_nested/__init__.py
__title__ = 'DRF writable nested' __version__ = '0.4.3' __author__ = 'beda.software' __license__ = 'BSD 2-Clause' __copyright__ = 'Copyright 2014-2018 beda.software' # Version synonym VERSION = __version__ from .mixins import NestedUpdateMixin, NestedCreateMixin from .serializers import WritableNestedModelSerializer
__title__ = 'DRF writable nested' __version__ = '0.4.3' __author__ = 'beda.software' __license__ = 'BSD 2-Clause' __copyright__ = 'Copyright 2014-2018 beda.software' # Version synonym VERSION = __version__ from .mixins import NestedUpdateMixin, NestedCreateMixin, UniqueFieldsMixin from .serializers import WritableNestedModelSerializer
Add UniqueMixin import to init
Add UniqueMixin import to init
Python
bsd-2-clause
Brogency/drf-writable-nested
__title__ = 'DRF writable nested' __version__ = '0.4.3' __author__ = 'beda.software' __license__ = 'BSD 2-Clause' __copyright__ = 'Copyright 2014-2018 beda.software' # Version synonym VERSION = __version__ from .mixins import NestedUpdateMixin, NestedCreateMixin from .serializers import WritableNestedModelSerializer Add UniqueMixin import to init
__title__ = 'DRF writable nested' __version__ = '0.4.3' __author__ = 'beda.software' __license__ = 'BSD 2-Clause' __copyright__ = 'Copyright 2014-2018 beda.software' # Version synonym VERSION = __version__ from .mixins import NestedUpdateMixin, NestedCreateMixin, UniqueFieldsMixin from .serializers import WritableNestedModelSerializer
<commit_before>__title__ = 'DRF writable nested' __version__ = '0.4.3' __author__ = 'beda.software' __license__ = 'BSD 2-Clause' __copyright__ = 'Copyright 2014-2018 beda.software' # Version synonym VERSION = __version__ from .mixins import NestedUpdateMixin, NestedCreateMixin from .serializers import WritableNestedModelSerializer <commit_msg>Add UniqueMixin import to init<commit_after>
__title__ = 'DRF writable nested' __version__ = '0.4.3' __author__ = 'beda.software' __license__ = 'BSD 2-Clause' __copyright__ = 'Copyright 2014-2018 beda.software' # Version synonym VERSION = __version__ from .mixins import NestedUpdateMixin, NestedCreateMixin, UniqueFieldsMixin from .serializers import WritableNestedModelSerializer
__title__ = 'DRF writable nested' __version__ = '0.4.3' __author__ = 'beda.software' __license__ = 'BSD 2-Clause' __copyright__ = 'Copyright 2014-2018 beda.software' # Version synonym VERSION = __version__ from .mixins import NestedUpdateMixin, NestedCreateMixin from .serializers import WritableNestedModelSerializer Add UniqueMixin import to init__title__ = 'DRF writable nested' __version__ = '0.4.3' __author__ = 'beda.software' __license__ = 'BSD 2-Clause' __copyright__ = 'Copyright 2014-2018 beda.software' # Version synonym VERSION = __version__ from .mixins import NestedUpdateMixin, NestedCreateMixin, UniqueFieldsMixin from .serializers import WritableNestedModelSerializer
<commit_before>__title__ = 'DRF writable nested' __version__ = '0.4.3' __author__ = 'beda.software' __license__ = 'BSD 2-Clause' __copyright__ = 'Copyright 2014-2018 beda.software' # Version synonym VERSION = __version__ from .mixins import NestedUpdateMixin, NestedCreateMixin from .serializers import WritableNestedModelSerializer <commit_msg>Add UniqueMixin import to init<commit_after>__title__ = 'DRF writable nested' __version__ = '0.4.3' __author__ = 'beda.software' __license__ = 'BSD 2-Clause' __copyright__ = 'Copyright 2014-2018 beda.software' # Version synonym VERSION = __version__ from .mixins import NestedUpdateMixin, NestedCreateMixin, UniqueFieldsMixin from .serializers import WritableNestedModelSerializer
dedf620bba97541505790b6b3f66468113e9488f
server/tests/base.py
server/tests/base.py
import tempfile import unittest import os from server import app from server.models import db class BaseTestCase(unittest.TestCase): def setUp(self): self.db_fd, self.test_db_path = tempfile.mkstemp('.db') test_db_uri = 'sqlite:///{}'.format(self.test_db_path) app.config['SQLALCHEMY_DATABASE_URI'] = test_db_uri app.config['TESTING'] = True self.app = app.test_client() db.drop_all() db.create_all() def tearDown(self): os.close(self.db_fd) os.unlink(self.test_db_path)
import tempfile import unittest import os from server import app from server.models import db class BaseTestCase(unittest.TestCase): def setUp(self): self.db_fd, self.test_db_path = tempfile.mkstemp('.db') # test_db_uri = 'sqlite:///{}'.format(self.test_db_path) # app.config['SQLALCHEMY_DATABASE_URI'] = test_db_uri app.config['TESTING'] = True self.app = app.test_client() db.drop_all() db.create_all() def tearDown(self): os.close(self.db_fd) os.unlink(self.test_db_path)
Add a hack for fixing failing tests
Add a hack for fixing failing tests Though it might actually be a proper fix. Need to talk to Nikita.
Python
mit
MACSIFS/IFS,MACSIFS/IFS,MACSIFS/IFS,MACSIFS/IFS
import tempfile import unittest import os from server import app from server.models import db class BaseTestCase(unittest.TestCase): def setUp(self): self.db_fd, self.test_db_path = tempfile.mkstemp('.db') test_db_uri = 'sqlite:///{}'.format(self.test_db_path) app.config['SQLALCHEMY_DATABASE_URI'] = test_db_uri app.config['TESTING'] = True self.app = app.test_client() db.drop_all() db.create_all() def tearDown(self): os.close(self.db_fd) os.unlink(self.test_db_path) Add a hack for fixing failing tests Though it might actually be a proper fix. Need to talk to Nikita.
import tempfile import unittest import os from server import app from server.models import db class BaseTestCase(unittest.TestCase): def setUp(self): self.db_fd, self.test_db_path = tempfile.mkstemp('.db') # test_db_uri = 'sqlite:///{}'.format(self.test_db_path) # app.config['SQLALCHEMY_DATABASE_URI'] = test_db_uri app.config['TESTING'] = True self.app = app.test_client() db.drop_all() db.create_all() def tearDown(self): os.close(self.db_fd) os.unlink(self.test_db_path)
<commit_before>import tempfile import unittest import os from server import app from server.models import db class BaseTestCase(unittest.TestCase): def setUp(self): self.db_fd, self.test_db_path = tempfile.mkstemp('.db') test_db_uri = 'sqlite:///{}'.format(self.test_db_path) app.config['SQLALCHEMY_DATABASE_URI'] = test_db_uri app.config['TESTING'] = True self.app = app.test_client() db.drop_all() db.create_all() def tearDown(self): os.close(self.db_fd) os.unlink(self.test_db_path) <commit_msg>Add a hack for fixing failing tests Though it might actually be a proper fix. Need to talk to Nikita.<commit_after>
import tempfile import unittest import os from server import app from server.models import db class BaseTestCase(unittest.TestCase): def setUp(self): self.db_fd, self.test_db_path = tempfile.mkstemp('.db') # test_db_uri = 'sqlite:///{}'.format(self.test_db_path) # app.config['SQLALCHEMY_DATABASE_URI'] = test_db_uri app.config['TESTING'] = True self.app = app.test_client() db.drop_all() db.create_all() def tearDown(self): os.close(self.db_fd) os.unlink(self.test_db_path)
import tempfile import unittest import os from server import app from server.models import db class BaseTestCase(unittest.TestCase): def setUp(self): self.db_fd, self.test_db_path = tempfile.mkstemp('.db') test_db_uri = 'sqlite:///{}'.format(self.test_db_path) app.config['SQLALCHEMY_DATABASE_URI'] = test_db_uri app.config['TESTING'] = True self.app = app.test_client() db.drop_all() db.create_all() def tearDown(self): os.close(self.db_fd) os.unlink(self.test_db_path) Add a hack for fixing failing tests Though it might actually be a proper fix. Need to talk to Nikita.import tempfile import unittest import os from server import app from server.models import db class BaseTestCase(unittest.TestCase): def setUp(self): self.db_fd, self.test_db_path = tempfile.mkstemp('.db') # test_db_uri = 'sqlite:///{}'.format(self.test_db_path) # app.config['SQLALCHEMY_DATABASE_URI'] = test_db_uri app.config['TESTING'] = True self.app = app.test_client() db.drop_all() db.create_all() def tearDown(self): os.close(self.db_fd) os.unlink(self.test_db_path)
<commit_before>import tempfile import unittest import os from server import app from server.models import db class BaseTestCase(unittest.TestCase): def setUp(self): self.db_fd, self.test_db_path = tempfile.mkstemp('.db') test_db_uri = 'sqlite:///{}'.format(self.test_db_path) app.config['SQLALCHEMY_DATABASE_URI'] = test_db_uri app.config['TESTING'] = True self.app = app.test_client() db.drop_all() db.create_all() def tearDown(self): os.close(self.db_fd) os.unlink(self.test_db_path) <commit_msg>Add a hack for fixing failing tests Though it might actually be a proper fix. Need to talk to Nikita.<commit_after>import tempfile import unittest import os from server import app from server.models import db class BaseTestCase(unittest.TestCase): def setUp(self): self.db_fd, self.test_db_path = tempfile.mkstemp('.db') # test_db_uri = 'sqlite:///{}'.format(self.test_db_path) # app.config['SQLALCHEMY_DATABASE_URI'] = test_db_uri app.config['TESTING'] = True self.app = app.test_client() db.drop_all() db.create_all() def tearDown(self): os.close(self.db_fd) os.unlink(self.test_db_path)
a80b95f64a17c4bc5c506313fe94e66b4ad2e836
cyclonejet/__init__.py
cyclonejet/__init__.py
# -*- encoding:utf-8 -*- from flask import Flask from cyclonejet.views.frontend import frontend from flaskext.sqlalchemy import SQLAlchemy import settings app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = settings.DB_URI app.register_module(frontend) db = SQLAlchemy(app)
# -*- encoding:utf-8 -*- from flask import Flask, render_template from cyclonejet.views.frontend import frontend from cyclonejet.views.errors import errors from flaskext.sqlalchemy import SQLAlchemy import settings app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = settings.DB_URI #Blueprint registration app.register_blueprint(frontend) app.register_blueprint(errors) #DB intialization db = SQLAlchemy(app) #Custom Error handling (move this somewhere else?) @app.errorhandler(404) def page_not_found(e): return render_template('404.html'), 404
Switch to Blueprints, custom 404 handler.
Switch to Blueprints, custom 404 handler.
Python
agpl-3.0
tsoporan/cyclonejet
# -*- encoding:utf-8 -*- from flask import Flask from cyclonejet.views.frontend import frontend from flaskext.sqlalchemy import SQLAlchemy import settings app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = settings.DB_URI app.register_module(frontend) db = SQLAlchemy(app) Switch to Blueprints, custom 404 handler.
# -*- encoding:utf-8 -*- from flask import Flask, render_template from cyclonejet.views.frontend import frontend from cyclonejet.views.errors import errors from flaskext.sqlalchemy import SQLAlchemy import settings app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = settings.DB_URI #Blueprint registration app.register_blueprint(frontend) app.register_blueprint(errors) #DB intialization db = SQLAlchemy(app) #Custom Error handling (move this somewhere else?) @app.errorhandler(404) def page_not_found(e): return render_template('404.html'), 404
<commit_before># -*- encoding:utf-8 -*- from flask import Flask from cyclonejet.views.frontend import frontend from flaskext.sqlalchemy import SQLAlchemy import settings app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = settings.DB_URI app.register_module(frontend) db = SQLAlchemy(app) <commit_msg>Switch to Blueprints, custom 404 handler.<commit_after>
# -*- encoding:utf-8 -*- from flask import Flask, render_template from cyclonejet.views.frontend import frontend from cyclonejet.views.errors import errors from flaskext.sqlalchemy import SQLAlchemy import settings app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = settings.DB_URI #Blueprint registration app.register_blueprint(frontend) app.register_blueprint(errors) #DB intialization db = SQLAlchemy(app) #Custom Error handling (move this somewhere else?) @app.errorhandler(404) def page_not_found(e): return render_template('404.html'), 404
# -*- encoding:utf-8 -*- from flask import Flask from cyclonejet.views.frontend import frontend from flaskext.sqlalchemy import SQLAlchemy import settings app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = settings.DB_URI app.register_module(frontend) db = SQLAlchemy(app) Switch to Blueprints, custom 404 handler.# -*- encoding:utf-8 -*- from flask import Flask, render_template from cyclonejet.views.frontend import frontend from cyclonejet.views.errors import errors from flaskext.sqlalchemy import SQLAlchemy import settings app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = settings.DB_URI #Blueprint registration app.register_blueprint(frontend) app.register_blueprint(errors) #DB intialization db = SQLAlchemy(app) #Custom Error handling (move this somewhere else?) @app.errorhandler(404) def page_not_found(e): return render_template('404.html'), 404
<commit_before># -*- encoding:utf-8 -*- from flask import Flask from cyclonejet.views.frontend import frontend from flaskext.sqlalchemy import SQLAlchemy import settings app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = settings.DB_URI app.register_module(frontend) db = SQLAlchemy(app) <commit_msg>Switch to Blueprints, custom 404 handler.<commit_after># -*- encoding:utf-8 -*- from flask import Flask, render_template from cyclonejet.views.frontend import frontend from cyclonejet.views.errors import errors from flaskext.sqlalchemy import SQLAlchemy import settings app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = settings.DB_URI #Blueprint registration app.register_blueprint(frontend) app.register_blueprint(errors) #DB intialization db = SQLAlchemy(app) #Custom Error handling (move this somewhere else?) @app.errorhandler(404) def page_not_found(e): return render_template('404.html'), 404
0fa9458e876f8361ac79f66b4cb0a845e3eb740d
src/fastpbkdf2/__init__.py
src/fastpbkdf2/__init__.py
from __future__ import absolute_import, division, print_function from fastpbkdf2._fastpbkdf2 import ffi, lib def pbkdf2_hmac(name, password, salt, rounds, dklen=None): if name not in ["sha1", "sha256", "sha512"]: raise ValueError( "Algorithm {} not supported. " "Please use sha1, sha256 or sha512".format(name) ) algorithm = { "sha1": (lib.fastpbkdf2_hmac_sha1, 20), "sha256": (lib.fastpbkdf2_hmac_sha256, 32), "sha512": (lib.fastpbkdf2_hmac_sha512, 64), } out_length = dklen or algorithm[name][1] out = ffi.new("uint8_t[]", out_length) algorithm[name][0]( password, len(password), salt, len(salt), rounds, out, out_length ) return ffi.buffer(out)[:]
from __future__ import absolute_import, division, print_function from fastpbkdf2._fastpbkdf2 import ffi, lib def pbkdf2_hmac(name, password, salt, rounds, dklen=None): if name not in ["sha1", "sha256", "sha512"]: raise ValueError("unsupported hash type") algorithm = { "sha1": (lib.fastpbkdf2_hmac_sha1, 20), "sha256": (lib.fastpbkdf2_hmac_sha256, 32), "sha512": (lib.fastpbkdf2_hmac_sha512, 64), } out_length = dklen or algorithm[name][1] out = ffi.new("uint8_t[]", out_length) algorithm[name][0]( password, len(password), salt, len(salt), rounds, out, out_length ) return ffi.buffer(out)[:]
Change exception message to be same as stdlib.
Change exception message to be same as stdlib.
Python
apache-2.0
Ayrx/python-fastpbkdf2,Ayrx/python-fastpbkdf2
from __future__ import absolute_import, division, print_function from fastpbkdf2._fastpbkdf2 import ffi, lib def pbkdf2_hmac(name, password, salt, rounds, dklen=None): if name not in ["sha1", "sha256", "sha512"]: raise ValueError( "Algorithm {} not supported. " "Please use sha1, sha256 or sha512".format(name) ) algorithm = { "sha1": (lib.fastpbkdf2_hmac_sha1, 20), "sha256": (lib.fastpbkdf2_hmac_sha256, 32), "sha512": (lib.fastpbkdf2_hmac_sha512, 64), } out_length = dklen or algorithm[name][1] out = ffi.new("uint8_t[]", out_length) algorithm[name][0]( password, len(password), salt, len(salt), rounds, out, out_length ) return ffi.buffer(out)[:] Change exception message to be same as stdlib.
from __future__ import absolute_import, division, print_function from fastpbkdf2._fastpbkdf2 import ffi, lib def pbkdf2_hmac(name, password, salt, rounds, dklen=None): if name not in ["sha1", "sha256", "sha512"]: raise ValueError("unsupported hash type") algorithm = { "sha1": (lib.fastpbkdf2_hmac_sha1, 20), "sha256": (lib.fastpbkdf2_hmac_sha256, 32), "sha512": (lib.fastpbkdf2_hmac_sha512, 64), } out_length = dklen or algorithm[name][1] out = ffi.new("uint8_t[]", out_length) algorithm[name][0]( password, len(password), salt, len(salt), rounds, out, out_length ) return ffi.buffer(out)[:]
<commit_before>from __future__ import absolute_import, division, print_function from fastpbkdf2._fastpbkdf2 import ffi, lib def pbkdf2_hmac(name, password, salt, rounds, dklen=None): if name not in ["sha1", "sha256", "sha512"]: raise ValueError( "Algorithm {} not supported. " "Please use sha1, sha256 or sha512".format(name) ) algorithm = { "sha1": (lib.fastpbkdf2_hmac_sha1, 20), "sha256": (lib.fastpbkdf2_hmac_sha256, 32), "sha512": (lib.fastpbkdf2_hmac_sha512, 64), } out_length = dklen or algorithm[name][1] out = ffi.new("uint8_t[]", out_length) algorithm[name][0]( password, len(password), salt, len(salt), rounds, out, out_length ) return ffi.buffer(out)[:] <commit_msg>Change exception message to be same as stdlib.<commit_after>
from __future__ import absolute_import, division, print_function from fastpbkdf2._fastpbkdf2 import ffi, lib def pbkdf2_hmac(name, password, salt, rounds, dklen=None): if name not in ["sha1", "sha256", "sha512"]: raise ValueError("unsupported hash type") algorithm = { "sha1": (lib.fastpbkdf2_hmac_sha1, 20), "sha256": (lib.fastpbkdf2_hmac_sha256, 32), "sha512": (lib.fastpbkdf2_hmac_sha512, 64), } out_length = dklen or algorithm[name][1] out = ffi.new("uint8_t[]", out_length) algorithm[name][0]( password, len(password), salt, len(salt), rounds, out, out_length ) return ffi.buffer(out)[:]
from __future__ import absolute_import, division, print_function from fastpbkdf2._fastpbkdf2 import ffi, lib def pbkdf2_hmac(name, password, salt, rounds, dklen=None): if name not in ["sha1", "sha256", "sha512"]: raise ValueError( "Algorithm {} not supported. " "Please use sha1, sha256 or sha512".format(name) ) algorithm = { "sha1": (lib.fastpbkdf2_hmac_sha1, 20), "sha256": (lib.fastpbkdf2_hmac_sha256, 32), "sha512": (lib.fastpbkdf2_hmac_sha512, 64), } out_length = dklen or algorithm[name][1] out = ffi.new("uint8_t[]", out_length) algorithm[name][0]( password, len(password), salt, len(salt), rounds, out, out_length ) return ffi.buffer(out)[:] Change exception message to be same as stdlib.from __future__ import absolute_import, division, print_function from fastpbkdf2._fastpbkdf2 import ffi, lib def pbkdf2_hmac(name, password, salt, rounds, dklen=None): if name not in ["sha1", "sha256", "sha512"]: raise ValueError("unsupported hash type") algorithm = { "sha1": (lib.fastpbkdf2_hmac_sha1, 20), "sha256": (lib.fastpbkdf2_hmac_sha256, 32), "sha512": (lib.fastpbkdf2_hmac_sha512, 64), } out_length = dklen or algorithm[name][1] out = ffi.new("uint8_t[]", out_length) algorithm[name][0]( password, len(password), salt, len(salt), rounds, out, out_length ) return ffi.buffer(out)[:]
<commit_before>from __future__ import absolute_import, division, print_function from fastpbkdf2._fastpbkdf2 import ffi, lib def pbkdf2_hmac(name, password, salt, rounds, dklen=None): if name not in ["sha1", "sha256", "sha512"]: raise ValueError( "Algorithm {} not supported. " "Please use sha1, sha256 or sha512".format(name) ) algorithm = { "sha1": (lib.fastpbkdf2_hmac_sha1, 20), "sha256": (lib.fastpbkdf2_hmac_sha256, 32), "sha512": (lib.fastpbkdf2_hmac_sha512, 64), } out_length = dklen or algorithm[name][1] out = ffi.new("uint8_t[]", out_length) algorithm[name][0]( password, len(password), salt, len(salt), rounds, out, out_length ) return ffi.buffer(out)[:] <commit_msg>Change exception message to be same as stdlib.<commit_after>from __future__ import absolute_import, division, print_function from fastpbkdf2._fastpbkdf2 import ffi, lib def pbkdf2_hmac(name, password, salt, rounds, dklen=None): if name not in ["sha1", "sha256", "sha512"]: raise ValueError("unsupported hash type") algorithm = { "sha1": (lib.fastpbkdf2_hmac_sha1, 20), "sha256": (lib.fastpbkdf2_hmac_sha256, 32), "sha512": (lib.fastpbkdf2_hmac_sha512, 64), } out_length = dklen or algorithm[name][1] out = ffi.new("uint8_t[]", out_length) algorithm[name][0]( password, len(password), salt, len(salt), rounds, out, out_length ) return ffi.buffer(out)[:]
32b51cb7d63d9d122c0d678a46d56a735a9bea3e
dodo_commands/framework/decorator_scope.py
dodo_commands/framework/decorator_scope.py
from dodo_commands.framework.singleton import Dodo # Resp: add the current command_name # to the list of commands decorated by decorator_name. class DecoratorScope: def __init__(self, decorator_name): self.decorators = Dodo.get_config('/ROOT').setdefault( 'decorators', {}).setdefault(decorator_name, []) def __enter__(self): # noqa self.decorators.append(Dodo.command_name) def __exit__(self, type, value, traceback): # noqa self.decorators.remove(Dodo.command_name)
from dodo_commands.framework.singleton import Dodo # Resp: add the current command_name # to the list of commands decorated by decorator_name. class DecoratorScope: def __init__(self, decorator_name, remove=False): self.decorators = Dodo.get_config('/ROOT').setdefault( 'decorators', {}).setdefault(decorator_name, []) self.prefix = "!" if remove else "" def __enter__(self): # noqa self.decorators.append(self.prefix + Dodo.command_name) def __exit__(self, type, value, traceback): # noqa self.decorators.remove(self.prefix + Dodo.command_name)
Add ``remove`` flag to DecoratorScope
Add ``remove`` flag to DecoratorScope
Python
mit
mnieber/dodo_commands
from dodo_commands.framework.singleton import Dodo # Resp: add the current command_name # to the list of commands decorated by decorator_name. class DecoratorScope: def __init__(self, decorator_name): self.decorators = Dodo.get_config('/ROOT').setdefault( 'decorators', {}).setdefault(decorator_name, []) def __enter__(self): # noqa self.decorators.append(Dodo.command_name) def __exit__(self, type, value, traceback): # noqa self.decorators.remove(Dodo.command_name) Add ``remove`` flag to DecoratorScope
from dodo_commands.framework.singleton import Dodo # Resp: add the current command_name # to the list of commands decorated by decorator_name. class DecoratorScope: def __init__(self, decorator_name, remove=False): self.decorators = Dodo.get_config('/ROOT').setdefault( 'decorators', {}).setdefault(decorator_name, []) self.prefix = "!" if remove else "" def __enter__(self): # noqa self.decorators.append(self.prefix + Dodo.command_name) def __exit__(self, type, value, traceback): # noqa self.decorators.remove(self.prefix + Dodo.command_name)
<commit_before>from dodo_commands.framework.singleton import Dodo # Resp: add the current command_name # to the list of commands decorated by decorator_name. class DecoratorScope: def __init__(self, decorator_name): self.decorators = Dodo.get_config('/ROOT').setdefault( 'decorators', {}).setdefault(decorator_name, []) def __enter__(self): # noqa self.decorators.append(Dodo.command_name) def __exit__(self, type, value, traceback): # noqa self.decorators.remove(Dodo.command_name) <commit_msg>Add ``remove`` flag to DecoratorScope<commit_after>
from dodo_commands.framework.singleton import Dodo # Resp: add the current command_name # to the list of commands decorated by decorator_name. class DecoratorScope: def __init__(self, decorator_name, remove=False): self.decorators = Dodo.get_config('/ROOT').setdefault( 'decorators', {}).setdefault(decorator_name, []) self.prefix = "!" if remove else "" def __enter__(self): # noqa self.decorators.append(self.prefix + Dodo.command_name) def __exit__(self, type, value, traceback): # noqa self.decorators.remove(self.prefix + Dodo.command_name)
from dodo_commands.framework.singleton import Dodo # Resp: add the current command_name # to the list of commands decorated by decorator_name. class DecoratorScope: def __init__(self, decorator_name): self.decorators = Dodo.get_config('/ROOT').setdefault( 'decorators', {}).setdefault(decorator_name, []) def __enter__(self): # noqa self.decorators.append(Dodo.command_name) def __exit__(self, type, value, traceback): # noqa self.decorators.remove(Dodo.command_name) Add ``remove`` flag to DecoratorScopefrom dodo_commands.framework.singleton import Dodo # Resp: add the current command_name # to the list of commands decorated by decorator_name. class DecoratorScope: def __init__(self, decorator_name, remove=False): self.decorators = Dodo.get_config('/ROOT').setdefault( 'decorators', {}).setdefault(decorator_name, []) self.prefix = "!" if remove else "" def __enter__(self): # noqa self.decorators.append(self.prefix + Dodo.command_name) def __exit__(self, type, value, traceback): # noqa self.decorators.remove(self.prefix + Dodo.command_name)
<commit_before>from dodo_commands.framework.singleton import Dodo # Resp: add the current command_name # to the list of commands decorated by decorator_name. class DecoratorScope: def __init__(self, decorator_name): self.decorators = Dodo.get_config('/ROOT').setdefault( 'decorators', {}).setdefault(decorator_name, []) def __enter__(self): # noqa self.decorators.append(Dodo.command_name) def __exit__(self, type, value, traceback): # noqa self.decorators.remove(Dodo.command_name) <commit_msg>Add ``remove`` flag to DecoratorScope<commit_after>from dodo_commands.framework.singleton import Dodo # Resp: add the current command_name # to the list of commands decorated by decorator_name. class DecoratorScope: def __init__(self, decorator_name, remove=False): self.decorators = Dodo.get_config('/ROOT').setdefault( 'decorators', {}).setdefault(decorator_name, []) self.prefix = "!" if remove else "" def __enter__(self): # noqa self.decorators.append(self.prefix + Dodo.command_name) def __exit__(self, type, value, traceback): # noqa self.decorators.remove(self.prefix + Dodo.command_name)
a8874713c5b34c19fe42a96ad495270fe3298841
python/hxActor/main.py
python/hxActor/main.py
#!/usr/bin/env python import actorcore.ICC class OurActor(actorcore.ICC.ICC): def __init__(self, name, productName=None, configFile=None, modelNames=('charis', 'hx'), debugLevel=30): """ Setup an Actor instance. See help for actorcore.Actor for details. """ # This sets up the connections to/from the hub, the logger, and the twisted reactor. # actorcore.ICC.ICC.__init__(self, name, productName=productName, configFile=configFile, modelNames=modelNames) # # To work def main(): theActor = OurActor('hx', productName='hxActor') theActor.run() if __name__ == '__main__': main()
#!/usr/bin/env python import actorcore.ICC class OurActor(actorcore.ICC.ICC): def __init__(self, name, productName=None, configFile=None, modelNames=('charis', 'hx'), debugLevel=30): """ Setup an Actor instance. See help for actorcore.Actor for details. """ # This sets up the connections to/from the hub, the logger, and the twisted reactor. # actorcore.ICC.ICC.__init__(self, name, productName=productName, configFile=configFile, modelNames=modelNames) self.everConnected = False def connectionMade(self): if self.everConnected is False: self.logger.info("Attaching all controllers...") self.allControllers = [s.strip() for s in self.config.get(self.name, 'startingControllers').split(',')] self.attachAllControllers() self.everConnected = True # # To work def main(): theActor = OurActor('hx', productName='hxActor') theActor.run() if __name__ == '__main__': main()
Make sure we auto-connect to the IDL server
Make sure we auto-connect to the IDL server
Python
mit
CraigLoomis/ics_hxActor,CraigLoomis/ics_hxActor
#!/usr/bin/env python import actorcore.ICC class OurActor(actorcore.ICC.ICC): def __init__(self, name, productName=None, configFile=None, modelNames=('charis', 'hx'), debugLevel=30): """ Setup an Actor instance. See help for actorcore.Actor for details. """ # This sets up the connections to/from the hub, the logger, and the twisted reactor. # actorcore.ICC.ICC.__init__(self, name, productName=productName, configFile=configFile, modelNames=modelNames) # # To work def main(): theActor = OurActor('hx', productName='hxActor') theActor.run() if __name__ == '__main__': main() Make sure we auto-connect to the IDL server
#!/usr/bin/env python import actorcore.ICC class OurActor(actorcore.ICC.ICC): def __init__(self, name, productName=None, configFile=None, modelNames=('charis', 'hx'), debugLevel=30): """ Setup an Actor instance. See help for actorcore.Actor for details. """ # This sets up the connections to/from the hub, the logger, and the twisted reactor. # actorcore.ICC.ICC.__init__(self, name, productName=productName, configFile=configFile, modelNames=modelNames) self.everConnected = False def connectionMade(self): if self.everConnected is False: self.logger.info("Attaching all controllers...") self.allControllers = [s.strip() for s in self.config.get(self.name, 'startingControllers').split(',')] self.attachAllControllers() self.everConnected = True # # To work def main(): theActor = OurActor('hx', productName='hxActor') theActor.run() if __name__ == '__main__': main()
<commit_before>#!/usr/bin/env python import actorcore.ICC class OurActor(actorcore.ICC.ICC): def __init__(self, name, productName=None, configFile=None, modelNames=('charis', 'hx'), debugLevel=30): """ Setup an Actor instance. See help for actorcore.Actor for details. """ # This sets up the connections to/from the hub, the logger, and the twisted reactor. # actorcore.ICC.ICC.__init__(self, name, productName=productName, configFile=configFile, modelNames=modelNames) # # To work def main(): theActor = OurActor('hx', productName='hxActor') theActor.run() if __name__ == '__main__': main() <commit_msg>Make sure we auto-connect to the IDL server<commit_after>
#!/usr/bin/env python import actorcore.ICC class OurActor(actorcore.ICC.ICC): def __init__(self, name, productName=None, configFile=None, modelNames=('charis', 'hx'), debugLevel=30): """ Setup an Actor instance. See help for actorcore.Actor for details. """ # This sets up the connections to/from the hub, the logger, and the twisted reactor. # actorcore.ICC.ICC.__init__(self, name, productName=productName, configFile=configFile, modelNames=modelNames) self.everConnected = False def connectionMade(self): if self.everConnected is False: self.logger.info("Attaching all controllers...") self.allControllers = [s.strip() for s in self.config.get(self.name, 'startingControllers').split(',')] self.attachAllControllers() self.everConnected = True # # To work def main(): theActor = OurActor('hx', productName='hxActor') theActor.run() if __name__ == '__main__': main()
#!/usr/bin/env python import actorcore.ICC class OurActor(actorcore.ICC.ICC): def __init__(self, name, productName=None, configFile=None, modelNames=('charis', 'hx'), debugLevel=30): """ Setup an Actor instance. See help for actorcore.Actor for details. """ # This sets up the connections to/from the hub, the logger, and the twisted reactor. # actorcore.ICC.ICC.__init__(self, name, productName=productName, configFile=configFile, modelNames=modelNames) # # To work def main(): theActor = OurActor('hx', productName='hxActor') theActor.run() if __name__ == '__main__': main() Make sure we auto-connect to the IDL server#!/usr/bin/env python import actorcore.ICC class OurActor(actorcore.ICC.ICC): def __init__(self, name, productName=None, configFile=None, modelNames=('charis', 'hx'), debugLevel=30): """ Setup an Actor instance. See help for actorcore.Actor for details. """ # This sets up the connections to/from the hub, the logger, and the twisted reactor. # actorcore.ICC.ICC.__init__(self, name, productName=productName, configFile=configFile, modelNames=modelNames) self.everConnected = False def connectionMade(self): if self.everConnected is False: self.logger.info("Attaching all controllers...") self.allControllers = [s.strip() for s in self.config.get(self.name, 'startingControllers').split(',')] self.attachAllControllers() self.everConnected = True # # To work def main(): theActor = OurActor('hx', productName='hxActor') theActor.run() if __name__ == '__main__': main()
<commit_before>#!/usr/bin/env python import actorcore.ICC class OurActor(actorcore.ICC.ICC): def __init__(self, name, productName=None, configFile=None, modelNames=('charis', 'hx'), debugLevel=30): """ Setup an Actor instance. See help for actorcore.Actor for details. """ # This sets up the connections to/from the hub, the logger, and the twisted reactor. # actorcore.ICC.ICC.__init__(self, name, productName=productName, configFile=configFile, modelNames=modelNames) # # To work def main(): theActor = OurActor('hx', productName='hxActor') theActor.run() if __name__ == '__main__': main() <commit_msg>Make sure we auto-connect to the IDL server<commit_after>#!/usr/bin/env python import actorcore.ICC class OurActor(actorcore.ICC.ICC): def __init__(self, name, productName=None, configFile=None, modelNames=('charis', 'hx'), debugLevel=30): """ Setup an Actor instance. See help for actorcore.Actor for details. """ # This sets up the connections to/from the hub, the logger, and the twisted reactor. # actorcore.ICC.ICC.__init__(self, name, productName=productName, configFile=configFile, modelNames=modelNames) self.everConnected = False def connectionMade(self): if self.everConnected is False: self.logger.info("Attaching all controllers...") self.allControllers = [s.strip() for s in self.config.get(self.name, 'startingControllers').split(',')] self.attachAllControllers() self.everConnected = True # # To work def main(): theActor = OurActor('hx', productName='hxActor') theActor.run() if __name__ == '__main__': main()
866b55d9160d274772aa796946492549eea6ca17
tests/asttools/test_compiler.py
tests/asttools/test_compiler.py
"""Test suite for asttools.compiler.""" from __future__ import division from __future__ import absolute_import from __future__ import print_function from __future__ import unicode_literals import pytest from pycc.asttools import parse from pycc.asttools import compiler source = """ x = True for y in range(10): pass """ @pytest.fixture def node(): """Get as AST node from the source.""" return parse.parse(source) def test_bytecode_compiler(node): """Ensure that bytecode can be generated without errors.""" compiler.ByteCodeCompiler()(node) def test_source_code_compilter(node): """Ensure that source code can be generated without errors.""" compiler.SourceCodeCompiler()(node)
"""Test suite for asttools.compiler.""" from __future__ import division from __future__ import absolute_import from __future__ import print_function from __future__ import unicode_literals import pytest from pycc import pycompat from pycc.asttools import parse from pycc.asttools import compiler source = """ x = True for y in range(10): pass """ @pytest.fixture def node(): """Get as AST node from the source.""" return parse.parse(source) def test_bytecode_compiler(node): """Ensure that bytecode can be generated without errors.""" compiler.ByteCodeCompiler()(node) @pytest.mark.skipif( pycompat.PY3 and pycompat.VERSION.minor > 3, reason="astkit does not yet support >=PY34", ) def test_source_code_compilter(node): """Ensure that source code can be generated without errors.""" compiler.SourceCodeCompiler()(node)
Add a skiptest to support PY34 testing
Add a skiptest to support PY34 testing The third party astkit library does not yet support the latest PY34 changes to the ast module. Until this is resolved the PY34 tests will skip any use of that library. Signed-off-by: Kevin Conway <3473c1f185ca03eadc40ad288d84425b54fd7d57@gmail.com>
Python
apache-2.0
kevinconway/pycc,kevinconway/pycc
"""Test suite for asttools.compiler.""" from __future__ import division from __future__ import absolute_import from __future__ import print_function from __future__ import unicode_literals import pytest from pycc.asttools import parse from pycc.asttools import compiler source = """ x = True for y in range(10): pass """ @pytest.fixture def node(): """Get as AST node from the source.""" return parse.parse(source) def test_bytecode_compiler(node): """Ensure that bytecode can be generated without errors.""" compiler.ByteCodeCompiler()(node) def test_source_code_compilter(node): """Ensure that source code can be generated without errors.""" compiler.SourceCodeCompiler()(node) Add a skiptest to support PY34 testing The third party astkit library does not yet support the latest PY34 changes to the ast module. Until this is resolved the PY34 tests will skip any use of that library. Signed-off-by: Kevin Conway <3473c1f185ca03eadc40ad288d84425b54fd7d57@gmail.com>
"""Test suite for asttools.compiler.""" from __future__ import division from __future__ import absolute_import from __future__ import print_function from __future__ import unicode_literals import pytest from pycc import pycompat from pycc.asttools import parse from pycc.asttools import compiler source = """ x = True for y in range(10): pass """ @pytest.fixture def node(): """Get as AST node from the source.""" return parse.parse(source) def test_bytecode_compiler(node): """Ensure that bytecode can be generated without errors.""" compiler.ByteCodeCompiler()(node) @pytest.mark.skipif( pycompat.PY3 and pycompat.VERSION.minor > 3, reason="astkit does not yet support >=PY34", ) def test_source_code_compilter(node): """Ensure that source code can be generated without errors.""" compiler.SourceCodeCompiler()(node)
<commit_before>"""Test suite for asttools.compiler.""" from __future__ import division from __future__ import absolute_import from __future__ import print_function from __future__ import unicode_literals import pytest from pycc.asttools import parse from pycc.asttools import compiler source = """ x = True for y in range(10): pass """ @pytest.fixture def node(): """Get as AST node from the source.""" return parse.parse(source) def test_bytecode_compiler(node): """Ensure that bytecode can be generated without errors.""" compiler.ByteCodeCompiler()(node) def test_source_code_compilter(node): """Ensure that source code can be generated without errors.""" compiler.SourceCodeCompiler()(node) <commit_msg>Add a skiptest to support PY34 testing The third party astkit library does not yet support the latest PY34 changes to the ast module. Until this is resolved the PY34 tests will skip any use of that library. Signed-off-by: Kevin Conway <3473c1f185ca03eadc40ad288d84425b54fd7d57@gmail.com><commit_after>
"""Test suite for asttools.compiler.""" from __future__ import division from __future__ import absolute_import from __future__ import print_function from __future__ import unicode_literals import pytest from pycc import pycompat from pycc.asttools import parse from pycc.asttools import compiler source = """ x = True for y in range(10): pass """ @pytest.fixture def node(): """Get as AST node from the source.""" return parse.parse(source) def test_bytecode_compiler(node): """Ensure that bytecode can be generated without errors.""" compiler.ByteCodeCompiler()(node) @pytest.mark.skipif( pycompat.PY3 and pycompat.VERSION.minor > 3, reason="astkit does not yet support >=PY34", ) def test_source_code_compilter(node): """Ensure that source code can be generated without errors.""" compiler.SourceCodeCompiler()(node)
"""Test suite for asttools.compiler.""" from __future__ import division from __future__ import absolute_import from __future__ import print_function from __future__ import unicode_literals import pytest from pycc.asttools import parse from pycc.asttools import compiler source = """ x = True for y in range(10): pass """ @pytest.fixture def node(): """Get as AST node from the source.""" return parse.parse(source) def test_bytecode_compiler(node): """Ensure that bytecode can be generated without errors.""" compiler.ByteCodeCompiler()(node) def test_source_code_compilter(node): """Ensure that source code can be generated without errors.""" compiler.SourceCodeCompiler()(node) Add a skiptest to support PY34 testing The third party astkit library does not yet support the latest PY34 changes to the ast module. Until this is resolved the PY34 tests will skip any use of that library. Signed-off-by: Kevin Conway <3473c1f185ca03eadc40ad288d84425b54fd7d57@gmail.com>"""Test suite for asttools.compiler.""" from __future__ import division from __future__ import absolute_import from __future__ import print_function from __future__ import unicode_literals import pytest from pycc import pycompat from pycc.asttools import parse from pycc.asttools import compiler source = """ x = True for y in range(10): pass """ @pytest.fixture def node(): """Get as AST node from the source.""" return parse.parse(source) def test_bytecode_compiler(node): """Ensure that bytecode can be generated without errors.""" compiler.ByteCodeCompiler()(node) @pytest.mark.skipif( pycompat.PY3 and pycompat.VERSION.minor > 3, reason="astkit does not yet support >=PY34", ) def test_source_code_compilter(node): """Ensure that source code can be generated without errors.""" compiler.SourceCodeCompiler()(node)
<commit_before>"""Test suite for asttools.compiler.""" from __future__ import division from __future__ import absolute_import from __future__ import print_function from __future__ import unicode_literals import pytest from pycc.asttools import parse from pycc.asttools import compiler source = """ x = True for y in range(10): pass """ @pytest.fixture def node(): """Get as AST node from the source.""" return parse.parse(source) def test_bytecode_compiler(node): """Ensure that bytecode can be generated without errors.""" compiler.ByteCodeCompiler()(node) def test_source_code_compilter(node): """Ensure that source code can be generated without errors.""" compiler.SourceCodeCompiler()(node) <commit_msg>Add a skiptest to support PY34 testing The third party astkit library does not yet support the latest PY34 changes to the ast module. Until this is resolved the PY34 tests will skip any use of that library. Signed-off-by: Kevin Conway <3473c1f185ca03eadc40ad288d84425b54fd7d57@gmail.com><commit_after>"""Test suite for asttools.compiler.""" from __future__ import division from __future__ import absolute_import from __future__ import print_function from __future__ import unicode_literals import pytest from pycc import pycompat from pycc.asttools import parse from pycc.asttools import compiler source = """ x = True for y in range(10): pass """ @pytest.fixture def node(): """Get as AST node from the source.""" return parse.parse(source) def test_bytecode_compiler(node): """Ensure that bytecode can be generated without errors.""" compiler.ByteCodeCompiler()(node) @pytest.mark.skipif( pycompat.PY3 and pycompat.VERSION.minor > 3, reason="astkit does not yet support >=PY34", ) def test_source_code_compilter(node): """Ensure that source code can be generated without errors.""" compiler.SourceCodeCompiler()(node)
6ec7465b5ec96b44e82cae9db58d6529e60ff920
tests/linters/test_lint_nwod.py
tests/linters/test_lint_nwod.py
import npc import pytest import os from tests.util import fixture_dir def test_has_virtue(): char_file = fixture_dir('linter', 'nwod', 'Has Virtue.nwod') with open(char_file, 'r') as char_file: problems = npc.linters.nwod.lint_vice_virtue(char_file.read()) assert 'Missing virtue' not in problems def test_missing_virtue(): char_file = fixture_dir('linter', 'nwod', 'Gotta Nada.nwod') with open(char_file, 'r') as char_file: problems = npc.linters.nwod.lint_vice_virtue(char_file.read()) assert 'Missing virtue' in problems def test_has_vice(): char_file = fixture_dir('linter', 'nwod', 'Has Vice.nwod') with open(char_file, 'r') as char_file: problems = npc.linters.nwod.lint_vice_virtue(char_file.read()) assert 'Missing virtue' not in problems def test_missing_vice(): char_file = fixture_dir('linter', 'nwod', 'Gotta Nada.nwod') with open(char_file, 'r') as char_file: problems = npc.linters.nwod.lint_vice_virtue(char_file.read()) assert 'Missing vice' in problems
"""Tests the helpers for linting generic nwod characters""" import npc import pytest import os from tests.util import fixture_dir def test_has_virtue(): char_file = fixture_dir('linter', 'nwod', 'Has Virtue.nwod') with open(char_file, 'r') as char_file: problems = npc.linters.nwod.lint_vice_virtue(char_file.read()) assert 'Missing virtue' not in problems def test_missing_virtue(): char_file = fixture_dir('linter', 'nwod', 'Gotta Nada.nwod') with open(char_file, 'r') as char_file: problems = npc.linters.nwod.lint_vice_virtue(char_file.read()) assert 'Missing virtue' in problems def test_has_vice(): char_file = fixture_dir('linter', 'nwod', 'Has Vice.nwod') with open(char_file, 'r') as char_file: problems = npc.linters.nwod.lint_vice_virtue(char_file.read()) assert 'Missing virtue' not in problems def test_missing_vice(): char_file = fixture_dir('linter', 'nwod', 'Gotta Nada.nwod') with open(char_file, 'r') as char_file: problems = npc.linters.nwod.lint_vice_virtue(char_file.read()) assert 'Missing vice' in problems
Add doc comment to nwod lint tests
Add doc comment to nwod lint tests
Python
mit
aurule/npc,aurule/npc
import npc import pytest import os from tests.util import fixture_dir def test_has_virtue(): char_file = fixture_dir('linter', 'nwod', 'Has Virtue.nwod') with open(char_file, 'r') as char_file: problems = npc.linters.nwod.lint_vice_virtue(char_file.read()) assert 'Missing virtue' not in problems def test_missing_virtue(): char_file = fixture_dir('linter', 'nwod', 'Gotta Nada.nwod') with open(char_file, 'r') as char_file: problems = npc.linters.nwod.lint_vice_virtue(char_file.read()) assert 'Missing virtue' in problems def test_has_vice(): char_file = fixture_dir('linter', 'nwod', 'Has Vice.nwod') with open(char_file, 'r') as char_file: problems = npc.linters.nwod.lint_vice_virtue(char_file.read()) assert 'Missing virtue' not in problems def test_missing_vice(): char_file = fixture_dir('linter', 'nwod', 'Gotta Nada.nwod') with open(char_file, 'r') as char_file: problems = npc.linters.nwod.lint_vice_virtue(char_file.read()) assert 'Missing vice' in problems Add doc comment to nwod lint tests
"""Tests the helpers for linting generic nwod characters""" import npc import pytest import os from tests.util import fixture_dir def test_has_virtue(): char_file = fixture_dir('linter', 'nwod', 'Has Virtue.nwod') with open(char_file, 'r') as char_file: problems = npc.linters.nwod.lint_vice_virtue(char_file.read()) assert 'Missing virtue' not in problems def test_missing_virtue(): char_file = fixture_dir('linter', 'nwod', 'Gotta Nada.nwod') with open(char_file, 'r') as char_file: problems = npc.linters.nwod.lint_vice_virtue(char_file.read()) assert 'Missing virtue' in problems def test_has_vice(): char_file = fixture_dir('linter', 'nwod', 'Has Vice.nwod') with open(char_file, 'r') as char_file: problems = npc.linters.nwod.lint_vice_virtue(char_file.read()) assert 'Missing virtue' not in problems def test_missing_vice(): char_file = fixture_dir('linter', 'nwod', 'Gotta Nada.nwod') with open(char_file, 'r') as char_file: problems = npc.linters.nwod.lint_vice_virtue(char_file.read()) assert 'Missing vice' in problems
<commit_before>import npc import pytest import os from tests.util import fixture_dir def test_has_virtue(): char_file = fixture_dir('linter', 'nwod', 'Has Virtue.nwod') with open(char_file, 'r') as char_file: problems = npc.linters.nwod.lint_vice_virtue(char_file.read()) assert 'Missing virtue' not in problems def test_missing_virtue(): char_file = fixture_dir('linter', 'nwod', 'Gotta Nada.nwod') with open(char_file, 'r') as char_file: problems = npc.linters.nwod.lint_vice_virtue(char_file.read()) assert 'Missing virtue' in problems def test_has_vice(): char_file = fixture_dir('linter', 'nwod', 'Has Vice.nwod') with open(char_file, 'r') as char_file: problems = npc.linters.nwod.lint_vice_virtue(char_file.read()) assert 'Missing virtue' not in problems def test_missing_vice(): char_file = fixture_dir('linter', 'nwod', 'Gotta Nada.nwod') with open(char_file, 'r') as char_file: problems = npc.linters.nwod.lint_vice_virtue(char_file.read()) assert 'Missing vice' in problems <commit_msg>Add doc comment to nwod lint tests<commit_after>
"""Tests the helpers for linting generic nwod characters""" import npc import pytest import os from tests.util import fixture_dir def test_has_virtue(): char_file = fixture_dir('linter', 'nwod', 'Has Virtue.nwod') with open(char_file, 'r') as char_file: problems = npc.linters.nwod.lint_vice_virtue(char_file.read()) assert 'Missing virtue' not in problems def test_missing_virtue(): char_file = fixture_dir('linter', 'nwod', 'Gotta Nada.nwod') with open(char_file, 'r') as char_file: problems = npc.linters.nwod.lint_vice_virtue(char_file.read()) assert 'Missing virtue' in problems def test_has_vice(): char_file = fixture_dir('linter', 'nwod', 'Has Vice.nwod') with open(char_file, 'r') as char_file: problems = npc.linters.nwod.lint_vice_virtue(char_file.read()) assert 'Missing virtue' not in problems def test_missing_vice(): char_file = fixture_dir('linter', 'nwod', 'Gotta Nada.nwod') with open(char_file, 'r') as char_file: problems = npc.linters.nwod.lint_vice_virtue(char_file.read()) assert 'Missing vice' in problems
import npc import pytest import os from tests.util import fixture_dir def test_has_virtue(): char_file = fixture_dir('linter', 'nwod', 'Has Virtue.nwod') with open(char_file, 'r') as char_file: problems = npc.linters.nwod.lint_vice_virtue(char_file.read()) assert 'Missing virtue' not in problems def test_missing_virtue(): char_file = fixture_dir('linter', 'nwod', 'Gotta Nada.nwod') with open(char_file, 'r') as char_file: problems = npc.linters.nwod.lint_vice_virtue(char_file.read()) assert 'Missing virtue' in problems def test_has_vice(): char_file = fixture_dir('linter', 'nwod', 'Has Vice.nwod') with open(char_file, 'r') as char_file: problems = npc.linters.nwod.lint_vice_virtue(char_file.read()) assert 'Missing virtue' not in problems def test_missing_vice(): char_file = fixture_dir('linter', 'nwod', 'Gotta Nada.nwod') with open(char_file, 'r') as char_file: problems = npc.linters.nwod.lint_vice_virtue(char_file.read()) assert 'Missing vice' in problems Add doc comment to nwod lint tests"""Tests the helpers for linting generic nwod characters""" import npc import pytest import os from tests.util import fixture_dir def test_has_virtue(): char_file = fixture_dir('linter', 'nwod', 'Has Virtue.nwod') with open(char_file, 'r') as char_file: problems = npc.linters.nwod.lint_vice_virtue(char_file.read()) assert 'Missing virtue' not in problems def test_missing_virtue(): char_file = fixture_dir('linter', 'nwod', 'Gotta Nada.nwod') with open(char_file, 'r') as char_file: problems = npc.linters.nwod.lint_vice_virtue(char_file.read()) assert 'Missing virtue' in problems def test_has_vice(): char_file = fixture_dir('linter', 'nwod', 'Has Vice.nwod') with open(char_file, 'r') as char_file: problems = npc.linters.nwod.lint_vice_virtue(char_file.read()) assert 'Missing virtue' not in problems def test_missing_vice(): char_file = fixture_dir('linter', 'nwod', 'Gotta Nada.nwod') with open(char_file, 'r') as char_file: problems = npc.linters.nwod.lint_vice_virtue(char_file.read()) assert 'Missing vice' in problems
<commit_before>import npc import pytest import os from tests.util import fixture_dir def test_has_virtue(): char_file = fixture_dir('linter', 'nwod', 'Has Virtue.nwod') with open(char_file, 'r') as char_file: problems = npc.linters.nwod.lint_vice_virtue(char_file.read()) assert 'Missing virtue' not in problems def test_missing_virtue(): char_file = fixture_dir('linter', 'nwod', 'Gotta Nada.nwod') with open(char_file, 'r') as char_file: problems = npc.linters.nwod.lint_vice_virtue(char_file.read()) assert 'Missing virtue' in problems def test_has_vice(): char_file = fixture_dir('linter', 'nwod', 'Has Vice.nwod') with open(char_file, 'r') as char_file: problems = npc.linters.nwod.lint_vice_virtue(char_file.read()) assert 'Missing virtue' not in problems def test_missing_vice(): char_file = fixture_dir('linter', 'nwod', 'Gotta Nada.nwod') with open(char_file, 'r') as char_file: problems = npc.linters.nwod.lint_vice_virtue(char_file.read()) assert 'Missing vice' in problems <commit_msg>Add doc comment to nwod lint tests<commit_after>"""Tests the helpers for linting generic nwod characters""" import npc import pytest import os from tests.util import fixture_dir def test_has_virtue(): char_file = fixture_dir('linter', 'nwod', 'Has Virtue.nwod') with open(char_file, 'r') as char_file: problems = npc.linters.nwod.lint_vice_virtue(char_file.read()) assert 'Missing virtue' not in problems def test_missing_virtue(): char_file = fixture_dir('linter', 'nwod', 'Gotta Nada.nwod') with open(char_file, 'r') as char_file: problems = npc.linters.nwod.lint_vice_virtue(char_file.read()) assert 'Missing virtue' in problems def test_has_vice(): char_file = fixture_dir('linter', 'nwod', 'Has Vice.nwod') with open(char_file, 'r') as char_file: problems = npc.linters.nwod.lint_vice_virtue(char_file.read()) assert 'Missing virtue' not in problems def test_missing_vice(): char_file = fixture_dir('linter', 'nwod', 'Gotta Nada.nwod') with open(char_file, 'r') as char_file: problems = npc.linters.nwod.lint_vice_virtue(char_file.read()) assert 'Missing vice' in problems
4bf7af66d6948d262d1115e460326fda720060de
datacleaner/_version.py
datacleaner/_version.py
# -*- coding: utf-8 -*- """ Copyright (c) 2016 Randal S. Olson 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. """ __version__ = '0.1.3'
# -*- coding: utf-8 -*- """ Copyright (c) 2016 Randal S. Olson 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. """ __version__ = '0.1.4'
Increment version for minor release
Increment version for minor release
Python
mit
rhiever/datacleaner,rhiever/datacleaner
# -*- coding: utf-8 -*- """ Copyright (c) 2016 Randal S. Olson 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. """ __version__ = '0.1.3' Increment version for minor release
# -*- coding: utf-8 -*- """ Copyright (c) 2016 Randal S. Olson 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. """ __version__ = '0.1.4'
<commit_before># -*- coding: utf-8 -*- """ Copyright (c) 2016 Randal S. Olson 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. """ __version__ = '0.1.3' <commit_msg>Increment version for minor release<commit_after>
# -*- coding: utf-8 -*- """ Copyright (c) 2016 Randal S. Olson 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. """ __version__ = '0.1.4'
# -*- coding: utf-8 -*- """ Copyright (c) 2016 Randal S. Olson 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. """ __version__ = '0.1.3' Increment version for minor release# -*- coding: utf-8 -*- """ Copyright (c) 2016 Randal S. Olson 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. """ __version__ = '0.1.4'
<commit_before># -*- coding: utf-8 -*- """ Copyright (c) 2016 Randal S. Olson 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. """ __version__ = '0.1.3' <commit_msg>Increment version for minor release<commit_after># -*- coding: utf-8 -*- """ Copyright (c) 2016 Randal S. Olson 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. """ __version__ = '0.1.4'
65c347af4bb75154390744b53d6f2e0c75948f6b
src/proposals/admin.py
src/proposals/admin.py
from django.contrib import admin from django.contrib.contenttypes.admin import GenericTabularInline from import_export.admin import ExportMixin from .models import AdditionalSpeaker, TalkProposal, TutorialProposal from .resources import TalkProposalResource class AdditionalSpeakerInline(GenericTabularInline): model = AdditionalSpeaker fields = ['user', 'status', 'cancelled'] ct_field = 'proposal_type' ct_fk_field = 'proposal_id' extra = 0 class ProposalAdmin(admin.ModelAdmin): fields = [ 'conference', 'submitter', 'title', 'category', 'duration', 'language', 'abstract', 'python_level', 'objective', 'detailed_description', 'outline', 'supplementary', 'recording_policy', 'slide_link', 'cancelled', ] readonly_fields = ['conference', 'submitter'] search_fields = ['title', 'abstract'] inlines = [AdditionalSpeakerInline] @admin.register(TalkProposal) class TalkProposalAdmin(ExportMixin, ProposalAdmin): fields = ProposalAdmin.fields + ['accepted'] list_display = [ 'title', 'category', 'duration', 'language', 'python_level', 'accepted', ] list_filter = [ 'category', 'duration', 'language', 'python_level', 'accepted', ] resource_class = TalkProposalResource @admin.register(TutorialProposal) class TutorialProposalAdmin(ProposalAdmin): list_display = ['title', 'category', 'language', 'python_level'] list_filter = ['category', 'language', 'python_level']
from django.contrib import admin from django.contrib.contenttypes.admin import GenericTabularInline from import_export.admin import ExportMixin from .models import AdditionalSpeaker, TalkProposal, TutorialProposal from .resources import TalkProposalResource class AdditionalSpeakerInline(GenericTabularInline): model = AdditionalSpeaker fields = ['user', 'status', 'cancelled'] ct_field = 'proposal_type' ct_fk_field = 'proposal_id' extra = 0 class ProposalAdmin(admin.ModelAdmin): fields = [ 'conference', 'submitter', 'title', 'category', 'duration', 'language', 'abstract', 'python_level', 'objective', 'detailed_description', 'outline', 'supplementary', 'recording_policy', 'slide_link', 'cancelled', ] search_fields = ['title', 'abstract'] inlines = [AdditionalSpeakerInline] @admin.register(TalkProposal) class TalkProposalAdmin(ExportMixin, ProposalAdmin): fields = ProposalAdmin.fields + ['accepted'] list_display = [ 'title', 'category', 'duration', 'language', 'python_level', 'accepted', ] list_filter = [ 'category', 'duration', 'language', 'python_level', 'accepted', ] resource_class = TalkProposalResource @admin.register(TutorialProposal) class TutorialProposalAdmin(ProposalAdmin): list_display = ['title', 'category', 'language', 'python_level'] list_filter = ['category', 'language', 'python_level']
Make ProposalAdmin work when creating
Make ProposalAdmin work when creating
Python
mit
pycontw/pycontw2016,pycontw/pycontw2016,pycontw/pycontw2016,pycontw/pycontw2016
from django.contrib import admin from django.contrib.contenttypes.admin import GenericTabularInline from import_export.admin import ExportMixin from .models import AdditionalSpeaker, TalkProposal, TutorialProposal from .resources import TalkProposalResource class AdditionalSpeakerInline(GenericTabularInline): model = AdditionalSpeaker fields = ['user', 'status', 'cancelled'] ct_field = 'proposal_type' ct_fk_field = 'proposal_id' extra = 0 class ProposalAdmin(admin.ModelAdmin): fields = [ 'conference', 'submitter', 'title', 'category', 'duration', 'language', 'abstract', 'python_level', 'objective', 'detailed_description', 'outline', 'supplementary', 'recording_policy', 'slide_link', 'cancelled', ] readonly_fields = ['conference', 'submitter'] search_fields = ['title', 'abstract'] inlines = [AdditionalSpeakerInline] @admin.register(TalkProposal) class TalkProposalAdmin(ExportMixin, ProposalAdmin): fields = ProposalAdmin.fields + ['accepted'] list_display = [ 'title', 'category', 'duration', 'language', 'python_level', 'accepted', ] list_filter = [ 'category', 'duration', 'language', 'python_level', 'accepted', ] resource_class = TalkProposalResource @admin.register(TutorialProposal) class TutorialProposalAdmin(ProposalAdmin): list_display = ['title', 'category', 'language', 'python_level'] list_filter = ['category', 'language', 'python_level'] Make ProposalAdmin work when creating
from django.contrib import admin from django.contrib.contenttypes.admin import GenericTabularInline from import_export.admin import ExportMixin from .models import AdditionalSpeaker, TalkProposal, TutorialProposal from .resources import TalkProposalResource class AdditionalSpeakerInline(GenericTabularInline): model = AdditionalSpeaker fields = ['user', 'status', 'cancelled'] ct_field = 'proposal_type' ct_fk_field = 'proposal_id' extra = 0 class ProposalAdmin(admin.ModelAdmin): fields = [ 'conference', 'submitter', 'title', 'category', 'duration', 'language', 'abstract', 'python_level', 'objective', 'detailed_description', 'outline', 'supplementary', 'recording_policy', 'slide_link', 'cancelled', ] search_fields = ['title', 'abstract'] inlines = [AdditionalSpeakerInline] @admin.register(TalkProposal) class TalkProposalAdmin(ExportMixin, ProposalAdmin): fields = ProposalAdmin.fields + ['accepted'] list_display = [ 'title', 'category', 'duration', 'language', 'python_level', 'accepted', ] list_filter = [ 'category', 'duration', 'language', 'python_level', 'accepted', ] resource_class = TalkProposalResource @admin.register(TutorialProposal) class TutorialProposalAdmin(ProposalAdmin): list_display = ['title', 'category', 'language', 'python_level'] list_filter = ['category', 'language', 'python_level']
<commit_before>from django.contrib import admin from django.contrib.contenttypes.admin import GenericTabularInline from import_export.admin import ExportMixin from .models import AdditionalSpeaker, TalkProposal, TutorialProposal from .resources import TalkProposalResource class AdditionalSpeakerInline(GenericTabularInline): model = AdditionalSpeaker fields = ['user', 'status', 'cancelled'] ct_field = 'proposal_type' ct_fk_field = 'proposal_id' extra = 0 class ProposalAdmin(admin.ModelAdmin): fields = [ 'conference', 'submitter', 'title', 'category', 'duration', 'language', 'abstract', 'python_level', 'objective', 'detailed_description', 'outline', 'supplementary', 'recording_policy', 'slide_link', 'cancelled', ] readonly_fields = ['conference', 'submitter'] search_fields = ['title', 'abstract'] inlines = [AdditionalSpeakerInline] @admin.register(TalkProposal) class TalkProposalAdmin(ExportMixin, ProposalAdmin): fields = ProposalAdmin.fields + ['accepted'] list_display = [ 'title', 'category', 'duration', 'language', 'python_level', 'accepted', ] list_filter = [ 'category', 'duration', 'language', 'python_level', 'accepted', ] resource_class = TalkProposalResource @admin.register(TutorialProposal) class TutorialProposalAdmin(ProposalAdmin): list_display = ['title', 'category', 'language', 'python_level'] list_filter = ['category', 'language', 'python_level'] <commit_msg>Make ProposalAdmin work when creating<commit_after>
from django.contrib import admin from django.contrib.contenttypes.admin import GenericTabularInline from import_export.admin import ExportMixin from .models import AdditionalSpeaker, TalkProposal, TutorialProposal from .resources import TalkProposalResource class AdditionalSpeakerInline(GenericTabularInline): model = AdditionalSpeaker fields = ['user', 'status', 'cancelled'] ct_field = 'proposal_type' ct_fk_field = 'proposal_id' extra = 0 class ProposalAdmin(admin.ModelAdmin): fields = [ 'conference', 'submitter', 'title', 'category', 'duration', 'language', 'abstract', 'python_level', 'objective', 'detailed_description', 'outline', 'supplementary', 'recording_policy', 'slide_link', 'cancelled', ] search_fields = ['title', 'abstract'] inlines = [AdditionalSpeakerInline] @admin.register(TalkProposal) class TalkProposalAdmin(ExportMixin, ProposalAdmin): fields = ProposalAdmin.fields + ['accepted'] list_display = [ 'title', 'category', 'duration', 'language', 'python_level', 'accepted', ] list_filter = [ 'category', 'duration', 'language', 'python_level', 'accepted', ] resource_class = TalkProposalResource @admin.register(TutorialProposal) class TutorialProposalAdmin(ProposalAdmin): list_display = ['title', 'category', 'language', 'python_level'] list_filter = ['category', 'language', 'python_level']
from django.contrib import admin from django.contrib.contenttypes.admin import GenericTabularInline from import_export.admin import ExportMixin from .models import AdditionalSpeaker, TalkProposal, TutorialProposal from .resources import TalkProposalResource class AdditionalSpeakerInline(GenericTabularInline): model = AdditionalSpeaker fields = ['user', 'status', 'cancelled'] ct_field = 'proposal_type' ct_fk_field = 'proposal_id' extra = 0 class ProposalAdmin(admin.ModelAdmin): fields = [ 'conference', 'submitter', 'title', 'category', 'duration', 'language', 'abstract', 'python_level', 'objective', 'detailed_description', 'outline', 'supplementary', 'recording_policy', 'slide_link', 'cancelled', ] readonly_fields = ['conference', 'submitter'] search_fields = ['title', 'abstract'] inlines = [AdditionalSpeakerInline] @admin.register(TalkProposal) class TalkProposalAdmin(ExportMixin, ProposalAdmin): fields = ProposalAdmin.fields + ['accepted'] list_display = [ 'title', 'category', 'duration', 'language', 'python_level', 'accepted', ] list_filter = [ 'category', 'duration', 'language', 'python_level', 'accepted', ] resource_class = TalkProposalResource @admin.register(TutorialProposal) class TutorialProposalAdmin(ProposalAdmin): list_display = ['title', 'category', 'language', 'python_level'] list_filter = ['category', 'language', 'python_level'] Make ProposalAdmin work when creatingfrom django.contrib import admin from django.contrib.contenttypes.admin import GenericTabularInline from import_export.admin import ExportMixin from .models import AdditionalSpeaker, TalkProposal, TutorialProposal from .resources import TalkProposalResource class AdditionalSpeakerInline(GenericTabularInline): model = AdditionalSpeaker fields = ['user', 'status', 'cancelled'] ct_field = 'proposal_type' ct_fk_field = 'proposal_id' extra = 0 class ProposalAdmin(admin.ModelAdmin): fields = [ 'conference', 'submitter', 'title', 'category', 'duration', 'language', 'abstract', 'python_level', 'objective', 'detailed_description', 'outline', 'supplementary', 'recording_policy', 'slide_link', 'cancelled', ] search_fields = ['title', 'abstract'] inlines = [AdditionalSpeakerInline] @admin.register(TalkProposal) class TalkProposalAdmin(ExportMixin, ProposalAdmin): fields = ProposalAdmin.fields + ['accepted'] list_display = [ 'title', 'category', 'duration', 'language', 'python_level', 'accepted', ] list_filter = [ 'category', 'duration', 'language', 'python_level', 'accepted', ] resource_class = TalkProposalResource @admin.register(TutorialProposal) class TutorialProposalAdmin(ProposalAdmin): list_display = ['title', 'category', 'language', 'python_level'] list_filter = ['category', 'language', 'python_level']
<commit_before>from django.contrib import admin from django.contrib.contenttypes.admin import GenericTabularInline from import_export.admin import ExportMixin from .models import AdditionalSpeaker, TalkProposal, TutorialProposal from .resources import TalkProposalResource class AdditionalSpeakerInline(GenericTabularInline): model = AdditionalSpeaker fields = ['user', 'status', 'cancelled'] ct_field = 'proposal_type' ct_fk_field = 'proposal_id' extra = 0 class ProposalAdmin(admin.ModelAdmin): fields = [ 'conference', 'submitter', 'title', 'category', 'duration', 'language', 'abstract', 'python_level', 'objective', 'detailed_description', 'outline', 'supplementary', 'recording_policy', 'slide_link', 'cancelled', ] readonly_fields = ['conference', 'submitter'] search_fields = ['title', 'abstract'] inlines = [AdditionalSpeakerInline] @admin.register(TalkProposal) class TalkProposalAdmin(ExportMixin, ProposalAdmin): fields = ProposalAdmin.fields + ['accepted'] list_display = [ 'title', 'category', 'duration', 'language', 'python_level', 'accepted', ] list_filter = [ 'category', 'duration', 'language', 'python_level', 'accepted', ] resource_class = TalkProposalResource @admin.register(TutorialProposal) class TutorialProposalAdmin(ProposalAdmin): list_display = ['title', 'category', 'language', 'python_level'] list_filter = ['category', 'language', 'python_level'] <commit_msg>Make ProposalAdmin work when creating<commit_after>from django.contrib import admin from django.contrib.contenttypes.admin import GenericTabularInline from import_export.admin import ExportMixin from .models import AdditionalSpeaker, TalkProposal, TutorialProposal from .resources import TalkProposalResource class AdditionalSpeakerInline(GenericTabularInline): model = AdditionalSpeaker fields = ['user', 'status', 'cancelled'] ct_field = 'proposal_type' ct_fk_field = 'proposal_id' extra = 0 class ProposalAdmin(admin.ModelAdmin): fields = [ 'conference', 'submitter', 'title', 'category', 'duration', 'language', 'abstract', 'python_level', 'objective', 'detailed_description', 'outline', 'supplementary', 'recording_policy', 'slide_link', 'cancelled', ] search_fields = ['title', 'abstract'] inlines = [AdditionalSpeakerInline] @admin.register(TalkProposal) class TalkProposalAdmin(ExportMixin, ProposalAdmin): fields = ProposalAdmin.fields + ['accepted'] list_display = [ 'title', 'category', 'duration', 'language', 'python_level', 'accepted', ] list_filter = [ 'category', 'duration', 'language', 'python_level', 'accepted', ] resource_class = TalkProposalResource @admin.register(TutorialProposal) class TutorialProposalAdmin(ProposalAdmin): list_display = ['title', 'category', 'language', 'python_level'] list_filter = ['category', 'language', 'python_level']
77179ef9375640eb300171e5bd38e68b999f9daf
monitor.py
monitor.py
import re from subprocess import Popen, PIPE, STDOUT from sys import stdout p = Popen(('stdbuf', '-oL', 'udevadm', 'monitor', '-k'), stdout=PIPE, stderr=STDOUT, bufsize=1) c = re.compile(r'KERNEL\[[^]]*\]\s*add\s*(?P<dev_path>\S*)\s*\(block\)') for line in iter(p.stdout.readline, b''): m = c.match(line) if m: dev_path = m.groupdict()['dev_path'] print dev_path
from __future__ import unicode_literals import re from subprocess import Popen, PIPE, STDOUT from sys import stdout from time import sleep bit_bucket = open('/dev/null', 'w') monitor_p = Popen(('stdbuf', '-oL', 'udevadm', 'monitor', '-k'), stdout=PIPE, stderr=PIPE, bufsize=1) block_add_pattern = re.compile( r'KERNEL\[[^]]*\]\s*add\s*(?P<path>\S*)\s*\(block\)') block_remove_pattern = re.compile( r'KERNEL\[[^]]*\]\s*remove\s*(?P<path>\S*)\s*\(block\)') info_uuid_pattern = re.compile( r'S:\s*disk/by-uuid/(?P<uuid>\S*)') info_label_pattern = re.compile( r'S:\s*disk/by-label/(?P<label>\S*)') info_name_pattern = re.compile( r'N:\s*(?P<name>\S*)') def get_dev_identifier(path): info_p = Popen(('udevadm', 'info', '-p', path), stdout=PIPE, stderr=PIPE) info, _ = info_p.communicate() info = info.decode('string_escape').decode('utf_8') identifier = {} for info_line in info.splitlines(): for pattern in (info_uuid_pattern, info_label_pattern, info_name_pattern): m = pattern.match(info_line) if m is not None: identifier.update(m.groupdict()) break return identifier def monitor_loop(): plugged = {} for monitor_line in iter(monitor_p.stdout.readline, b''): m = block_add_pattern.match(monitor_line) if m: path = m.groupdict()['path'] Popen(('udevadm', 'settle'), stdout=bit_bucket, stderr=bit_bucket).wait() iden = get_dev_identifier(path) #stdout.write('{} inserted\n'.format(iden)) print plugged plugged[path] = iden m = block_remove_pattern.match(monitor_line) if m: path = m.groupdict()['path'] iden = plugged.pop(path, None) if iden: #stdout.write('{} removed\n'.format(iden)) print plugged if __name__ == '__main__': monitor_loop()
Handle removal; keep track of devices and info
Handle removal; keep track of devices and info
Python
mit
drkitty/arise
import re from subprocess import Popen, PIPE, STDOUT from sys import stdout p = Popen(('stdbuf', '-oL', 'udevadm', 'monitor', '-k'), stdout=PIPE, stderr=STDOUT, bufsize=1) c = re.compile(r'KERNEL\[[^]]*\]\s*add\s*(?P<dev_path>\S*)\s*\(block\)') for line in iter(p.stdout.readline, b''): m = c.match(line) if m: dev_path = m.groupdict()['dev_path'] print dev_path Handle removal; keep track of devices and info
from __future__ import unicode_literals import re from subprocess import Popen, PIPE, STDOUT from sys import stdout from time import sleep bit_bucket = open('/dev/null', 'w') monitor_p = Popen(('stdbuf', '-oL', 'udevadm', 'monitor', '-k'), stdout=PIPE, stderr=PIPE, bufsize=1) block_add_pattern = re.compile( r'KERNEL\[[^]]*\]\s*add\s*(?P<path>\S*)\s*\(block\)') block_remove_pattern = re.compile( r'KERNEL\[[^]]*\]\s*remove\s*(?P<path>\S*)\s*\(block\)') info_uuid_pattern = re.compile( r'S:\s*disk/by-uuid/(?P<uuid>\S*)') info_label_pattern = re.compile( r'S:\s*disk/by-label/(?P<label>\S*)') info_name_pattern = re.compile( r'N:\s*(?P<name>\S*)') def get_dev_identifier(path): info_p = Popen(('udevadm', 'info', '-p', path), stdout=PIPE, stderr=PIPE) info, _ = info_p.communicate() info = info.decode('string_escape').decode('utf_8') identifier = {} for info_line in info.splitlines(): for pattern in (info_uuid_pattern, info_label_pattern, info_name_pattern): m = pattern.match(info_line) if m is not None: identifier.update(m.groupdict()) break return identifier def monitor_loop(): plugged = {} for monitor_line in iter(monitor_p.stdout.readline, b''): m = block_add_pattern.match(monitor_line) if m: path = m.groupdict()['path'] Popen(('udevadm', 'settle'), stdout=bit_bucket, stderr=bit_bucket).wait() iden = get_dev_identifier(path) #stdout.write('{} inserted\n'.format(iden)) print plugged plugged[path] = iden m = block_remove_pattern.match(monitor_line) if m: path = m.groupdict()['path'] iden = plugged.pop(path, None) if iden: #stdout.write('{} removed\n'.format(iden)) print plugged if __name__ == '__main__': monitor_loop()
<commit_before>import re from subprocess import Popen, PIPE, STDOUT from sys import stdout p = Popen(('stdbuf', '-oL', 'udevadm', 'monitor', '-k'), stdout=PIPE, stderr=STDOUT, bufsize=1) c = re.compile(r'KERNEL\[[^]]*\]\s*add\s*(?P<dev_path>\S*)\s*\(block\)') for line in iter(p.stdout.readline, b''): m = c.match(line) if m: dev_path = m.groupdict()['dev_path'] print dev_path <commit_msg>Handle removal; keep track of devices and info<commit_after>
from __future__ import unicode_literals import re from subprocess import Popen, PIPE, STDOUT from sys import stdout from time import sleep bit_bucket = open('/dev/null', 'w') monitor_p = Popen(('stdbuf', '-oL', 'udevadm', 'monitor', '-k'), stdout=PIPE, stderr=PIPE, bufsize=1) block_add_pattern = re.compile( r'KERNEL\[[^]]*\]\s*add\s*(?P<path>\S*)\s*\(block\)') block_remove_pattern = re.compile( r'KERNEL\[[^]]*\]\s*remove\s*(?P<path>\S*)\s*\(block\)') info_uuid_pattern = re.compile( r'S:\s*disk/by-uuid/(?P<uuid>\S*)') info_label_pattern = re.compile( r'S:\s*disk/by-label/(?P<label>\S*)') info_name_pattern = re.compile( r'N:\s*(?P<name>\S*)') def get_dev_identifier(path): info_p = Popen(('udevadm', 'info', '-p', path), stdout=PIPE, stderr=PIPE) info, _ = info_p.communicate() info = info.decode('string_escape').decode('utf_8') identifier = {} for info_line in info.splitlines(): for pattern in (info_uuid_pattern, info_label_pattern, info_name_pattern): m = pattern.match(info_line) if m is not None: identifier.update(m.groupdict()) break return identifier def monitor_loop(): plugged = {} for monitor_line in iter(monitor_p.stdout.readline, b''): m = block_add_pattern.match(monitor_line) if m: path = m.groupdict()['path'] Popen(('udevadm', 'settle'), stdout=bit_bucket, stderr=bit_bucket).wait() iden = get_dev_identifier(path) #stdout.write('{} inserted\n'.format(iden)) print plugged plugged[path] = iden m = block_remove_pattern.match(monitor_line) if m: path = m.groupdict()['path'] iden = plugged.pop(path, None) if iden: #stdout.write('{} removed\n'.format(iden)) print plugged if __name__ == '__main__': monitor_loop()
import re from subprocess import Popen, PIPE, STDOUT from sys import stdout p = Popen(('stdbuf', '-oL', 'udevadm', 'monitor', '-k'), stdout=PIPE, stderr=STDOUT, bufsize=1) c = re.compile(r'KERNEL\[[^]]*\]\s*add\s*(?P<dev_path>\S*)\s*\(block\)') for line in iter(p.stdout.readline, b''): m = c.match(line) if m: dev_path = m.groupdict()['dev_path'] print dev_path Handle removal; keep track of devices and infofrom __future__ import unicode_literals import re from subprocess import Popen, PIPE, STDOUT from sys import stdout from time import sleep bit_bucket = open('/dev/null', 'w') monitor_p = Popen(('stdbuf', '-oL', 'udevadm', 'monitor', '-k'), stdout=PIPE, stderr=PIPE, bufsize=1) block_add_pattern = re.compile( r'KERNEL\[[^]]*\]\s*add\s*(?P<path>\S*)\s*\(block\)') block_remove_pattern = re.compile( r'KERNEL\[[^]]*\]\s*remove\s*(?P<path>\S*)\s*\(block\)') info_uuid_pattern = re.compile( r'S:\s*disk/by-uuid/(?P<uuid>\S*)') info_label_pattern = re.compile( r'S:\s*disk/by-label/(?P<label>\S*)') info_name_pattern = re.compile( r'N:\s*(?P<name>\S*)') def get_dev_identifier(path): info_p = Popen(('udevadm', 'info', '-p', path), stdout=PIPE, stderr=PIPE) info, _ = info_p.communicate() info = info.decode('string_escape').decode('utf_8') identifier = {} for info_line in info.splitlines(): for pattern in (info_uuid_pattern, info_label_pattern, info_name_pattern): m = pattern.match(info_line) if m is not None: identifier.update(m.groupdict()) break return identifier def monitor_loop(): plugged = {} for monitor_line in iter(monitor_p.stdout.readline, b''): m = block_add_pattern.match(monitor_line) if m: path = m.groupdict()['path'] Popen(('udevadm', 'settle'), stdout=bit_bucket, stderr=bit_bucket).wait() iden = get_dev_identifier(path) #stdout.write('{} inserted\n'.format(iden)) print plugged plugged[path] = iden m = block_remove_pattern.match(monitor_line) if m: path = m.groupdict()['path'] iden = plugged.pop(path, None) if iden: #stdout.write('{} removed\n'.format(iden)) print plugged if __name__ == '__main__': monitor_loop()
<commit_before>import re from subprocess import Popen, PIPE, STDOUT from sys import stdout p = Popen(('stdbuf', '-oL', 'udevadm', 'monitor', '-k'), stdout=PIPE, stderr=STDOUT, bufsize=1) c = re.compile(r'KERNEL\[[^]]*\]\s*add\s*(?P<dev_path>\S*)\s*\(block\)') for line in iter(p.stdout.readline, b''): m = c.match(line) if m: dev_path = m.groupdict()['dev_path'] print dev_path <commit_msg>Handle removal; keep track of devices and info<commit_after>from __future__ import unicode_literals import re from subprocess import Popen, PIPE, STDOUT from sys import stdout from time import sleep bit_bucket = open('/dev/null', 'w') monitor_p = Popen(('stdbuf', '-oL', 'udevadm', 'monitor', '-k'), stdout=PIPE, stderr=PIPE, bufsize=1) block_add_pattern = re.compile( r'KERNEL\[[^]]*\]\s*add\s*(?P<path>\S*)\s*\(block\)') block_remove_pattern = re.compile( r'KERNEL\[[^]]*\]\s*remove\s*(?P<path>\S*)\s*\(block\)') info_uuid_pattern = re.compile( r'S:\s*disk/by-uuid/(?P<uuid>\S*)') info_label_pattern = re.compile( r'S:\s*disk/by-label/(?P<label>\S*)') info_name_pattern = re.compile( r'N:\s*(?P<name>\S*)') def get_dev_identifier(path): info_p = Popen(('udevadm', 'info', '-p', path), stdout=PIPE, stderr=PIPE) info, _ = info_p.communicate() info = info.decode('string_escape').decode('utf_8') identifier = {} for info_line in info.splitlines(): for pattern in (info_uuid_pattern, info_label_pattern, info_name_pattern): m = pattern.match(info_line) if m is not None: identifier.update(m.groupdict()) break return identifier def monitor_loop(): plugged = {} for monitor_line in iter(monitor_p.stdout.readline, b''): m = block_add_pattern.match(monitor_line) if m: path = m.groupdict()['path'] Popen(('udevadm', 'settle'), stdout=bit_bucket, stderr=bit_bucket).wait() iden = get_dev_identifier(path) #stdout.write('{} inserted\n'.format(iden)) print plugged plugged[path] = iden m = block_remove_pattern.match(monitor_line) if m: path = m.groupdict()['path'] iden = plugged.pop(path, None) if iden: #stdout.write('{} removed\n'.format(iden)) print plugged if __name__ == '__main__': monitor_loop()
aa092529bb643eabae45ae051ecd99d6bebb88ea
src/som/vmobjects/abstract_object.py
src/som/vmobjects/abstract_object.py
class AbstractObject(object): def __init__(self): pass def send(self, frame, selector_string, arguments, universe): # Turn the selector string into a selector selector = universe.symbol_for(selector_string) invokable = self.get_class(universe).lookup_invokable(selector) return invokable.invoke(frame, self, arguments) def send_does_not_understand(self, frame, selector, arguments, universe): # Compute the number of arguments number_of_arguments = selector.get_number_of_signature_arguments() arguments_array = universe.new_array_with_length(number_of_arguments) for i in range(0, number_of_arguments): arguments_array.set_indexable_field(i, arguments[i]) args = [selector, arguments_array] self.send(frame, "doesNotUnderstand:arguments:", args, universe) def send_unknown_global(self, frame, global_name, universe): arguments = [global_name] self.send(frame, "unknownGlobal:", arguments, universe) def send_escaped_block(self, frame, block, universe): arguments = [block] self.send(frame, "escapedBlock:", arguments, universe) def get_class(self, universe): raise NotImplementedError("Subclasses need to implement get_class(universe).") def is_invokable(self): return False def __str__(self): from som.vm.universe import get_current return "a " + self.get_class(get_current()).get_name().get_string()
class AbstractObject(object): def __init__(self): pass def send(self, frame, selector_string, arguments, universe): # Turn the selector string into a selector selector = universe.symbol_for(selector_string) invokable = self.get_class(universe).lookup_invokable(selector) return invokable.invoke(frame, self, arguments) def send_does_not_understand(self, frame, selector, arguments, universe): # Compute the number of arguments number_of_arguments = selector.get_number_of_signature_arguments() arguments_array = universe.new_array_with_length(number_of_arguments) for i in range(0, number_of_arguments): arguments_array.set_indexable_field(i, arguments[i]) args = [selector, arguments_array] return self.send(frame, "doesNotUnderstand:arguments:", args, universe) def send_unknown_global(self, frame, global_name, universe): arguments = [global_name] return self.send(frame, "unknownGlobal:", arguments, universe) def send_escaped_block(self, frame, block, universe): arguments = [block] return self.send(frame, "escapedBlock:", arguments, universe) def get_class(self, universe): raise NotImplementedError("Subclasses need to implement get_class(universe).") def is_invokable(self): return False def __str__(self): from som.vm.universe import get_current return "a " + self.get_class(get_current()).get_name().get_string()
Send methods need to return the result
Send methods need to return the result Signed-off-by: Stefan Marr <46f1a0bd5592a2f9244ca321b129902a06b53e03@stefan-marr.de>
Python
mit
smarr/RTruffleSOM,SOM-st/PySOM,SOM-st/RPySOM,smarr/PySOM,SOM-st/RTruffleSOM,SOM-st/RPySOM,SOM-st/RTruffleSOM,SOM-st/PySOM,smarr/RTruffleSOM,smarr/PySOM
class AbstractObject(object): def __init__(self): pass def send(self, frame, selector_string, arguments, universe): # Turn the selector string into a selector selector = universe.symbol_for(selector_string) invokable = self.get_class(universe).lookup_invokable(selector) return invokable.invoke(frame, self, arguments) def send_does_not_understand(self, frame, selector, arguments, universe): # Compute the number of arguments number_of_arguments = selector.get_number_of_signature_arguments() arguments_array = universe.new_array_with_length(number_of_arguments) for i in range(0, number_of_arguments): arguments_array.set_indexable_field(i, arguments[i]) args = [selector, arguments_array] self.send(frame, "doesNotUnderstand:arguments:", args, universe) def send_unknown_global(self, frame, global_name, universe): arguments = [global_name] self.send(frame, "unknownGlobal:", arguments, universe) def send_escaped_block(self, frame, block, universe): arguments = [block] self.send(frame, "escapedBlock:", arguments, universe) def get_class(self, universe): raise NotImplementedError("Subclasses need to implement get_class(universe).") def is_invokable(self): return False def __str__(self): from som.vm.universe import get_current return "a " + self.get_class(get_current()).get_name().get_string() Send methods need to return the result Signed-off-by: Stefan Marr <46f1a0bd5592a2f9244ca321b129902a06b53e03@stefan-marr.de>
class AbstractObject(object): def __init__(self): pass def send(self, frame, selector_string, arguments, universe): # Turn the selector string into a selector selector = universe.symbol_for(selector_string) invokable = self.get_class(universe).lookup_invokable(selector) return invokable.invoke(frame, self, arguments) def send_does_not_understand(self, frame, selector, arguments, universe): # Compute the number of arguments number_of_arguments = selector.get_number_of_signature_arguments() arguments_array = universe.new_array_with_length(number_of_arguments) for i in range(0, number_of_arguments): arguments_array.set_indexable_field(i, arguments[i]) args = [selector, arguments_array] return self.send(frame, "doesNotUnderstand:arguments:", args, universe) def send_unknown_global(self, frame, global_name, universe): arguments = [global_name] return self.send(frame, "unknownGlobal:", arguments, universe) def send_escaped_block(self, frame, block, universe): arguments = [block] return self.send(frame, "escapedBlock:", arguments, universe) def get_class(self, universe): raise NotImplementedError("Subclasses need to implement get_class(universe).") def is_invokable(self): return False def __str__(self): from som.vm.universe import get_current return "a " + self.get_class(get_current()).get_name().get_string()
<commit_before>class AbstractObject(object): def __init__(self): pass def send(self, frame, selector_string, arguments, universe): # Turn the selector string into a selector selector = universe.symbol_for(selector_string) invokable = self.get_class(universe).lookup_invokable(selector) return invokable.invoke(frame, self, arguments) def send_does_not_understand(self, frame, selector, arguments, universe): # Compute the number of arguments number_of_arguments = selector.get_number_of_signature_arguments() arguments_array = universe.new_array_with_length(number_of_arguments) for i in range(0, number_of_arguments): arguments_array.set_indexable_field(i, arguments[i]) args = [selector, arguments_array] self.send(frame, "doesNotUnderstand:arguments:", args, universe) def send_unknown_global(self, frame, global_name, universe): arguments = [global_name] self.send(frame, "unknownGlobal:", arguments, universe) def send_escaped_block(self, frame, block, universe): arguments = [block] self.send(frame, "escapedBlock:", arguments, universe) def get_class(self, universe): raise NotImplementedError("Subclasses need to implement get_class(universe).") def is_invokable(self): return False def __str__(self): from som.vm.universe import get_current return "a " + self.get_class(get_current()).get_name().get_string() <commit_msg>Send methods need to return the result Signed-off-by: Stefan Marr <46f1a0bd5592a2f9244ca321b129902a06b53e03@stefan-marr.de><commit_after>
class AbstractObject(object): def __init__(self): pass def send(self, frame, selector_string, arguments, universe): # Turn the selector string into a selector selector = universe.symbol_for(selector_string) invokable = self.get_class(universe).lookup_invokable(selector) return invokable.invoke(frame, self, arguments) def send_does_not_understand(self, frame, selector, arguments, universe): # Compute the number of arguments number_of_arguments = selector.get_number_of_signature_arguments() arguments_array = universe.new_array_with_length(number_of_arguments) for i in range(0, number_of_arguments): arguments_array.set_indexable_field(i, arguments[i]) args = [selector, arguments_array] return self.send(frame, "doesNotUnderstand:arguments:", args, universe) def send_unknown_global(self, frame, global_name, universe): arguments = [global_name] return self.send(frame, "unknownGlobal:", arguments, universe) def send_escaped_block(self, frame, block, universe): arguments = [block] return self.send(frame, "escapedBlock:", arguments, universe) def get_class(self, universe): raise NotImplementedError("Subclasses need to implement get_class(universe).") def is_invokable(self): return False def __str__(self): from som.vm.universe import get_current return "a " + self.get_class(get_current()).get_name().get_string()
class AbstractObject(object): def __init__(self): pass def send(self, frame, selector_string, arguments, universe): # Turn the selector string into a selector selector = universe.symbol_for(selector_string) invokable = self.get_class(universe).lookup_invokable(selector) return invokable.invoke(frame, self, arguments) def send_does_not_understand(self, frame, selector, arguments, universe): # Compute the number of arguments number_of_arguments = selector.get_number_of_signature_arguments() arguments_array = universe.new_array_with_length(number_of_arguments) for i in range(0, number_of_arguments): arguments_array.set_indexable_field(i, arguments[i]) args = [selector, arguments_array] self.send(frame, "doesNotUnderstand:arguments:", args, universe) def send_unknown_global(self, frame, global_name, universe): arguments = [global_name] self.send(frame, "unknownGlobal:", arguments, universe) def send_escaped_block(self, frame, block, universe): arguments = [block] self.send(frame, "escapedBlock:", arguments, universe) def get_class(self, universe): raise NotImplementedError("Subclasses need to implement get_class(universe).") def is_invokable(self): return False def __str__(self): from som.vm.universe import get_current return "a " + self.get_class(get_current()).get_name().get_string() Send methods need to return the result Signed-off-by: Stefan Marr <46f1a0bd5592a2f9244ca321b129902a06b53e03@stefan-marr.de>class AbstractObject(object): def __init__(self): pass def send(self, frame, selector_string, arguments, universe): # Turn the selector string into a selector selector = universe.symbol_for(selector_string) invokable = self.get_class(universe).lookup_invokable(selector) return invokable.invoke(frame, self, arguments) def send_does_not_understand(self, frame, selector, arguments, universe): # Compute the number of arguments number_of_arguments = selector.get_number_of_signature_arguments() arguments_array = universe.new_array_with_length(number_of_arguments) for i in range(0, number_of_arguments): arguments_array.set_indexable_field(i, arguments[i]) args = [selector, arguments_array] return self.send(frame, "doesNotUnderstand:arguments:", args, universe) def send_unknown_global(self, frame, global_name, universe): arguments = [global_name] return self.send(frame, "unknownGlobal:", arguments, universe) def send_escaped_block(self, frame, block, universe): arguments = [block] return self.send(frame, "escapedBlock:", arguments, universe) def get_class(self, universe): raise NotImplementedError("Subclasses need to implement get_class(universe).") def is_invokable(self): return False def __str__(self): from som.vm.universe import get_current return "a " + self.get_class(get_current()).get_name().get_string()
<commit_before>class AbstractObject(object): def __init__(self): pass def send(self, frame, selector_string, arguments, universe): # Turn the selector string into a selector selector = universe.symbol_for(selector_string) invokable = self.get_class(universe).lookup_invokable(selector) return invokable.invoke(frame, self, arguments) def send_does_not_understand(self, frame, selector, arguments, universe): # Compute the number of arguments number_of_arguments = selector.get_number_of_signature_arguments() arguments_array = universe.new_array_with_length(number_of_arguments) for i in range(0, number_of_arguments): arguments_array.set_indexable_field(i, arguments[i]) args = [selector, arguments_array] self.send(frame, "doesNotUnderstand:arguments:", args, universe) def send_unknown_global(self, frame, global_name, universe): arguments = [global_name] self.send(frame, "unknownGlobal:", arguments, universe) def send_escaped_block(self, frame, block, universe): arguments = [block] self.send(frame, "escapedBlock:", arguments, universe) def get_class(self, universe): raise NotImplementedError("Subclasses need to implement get_class(universe).") def is_invokable(self): return False def __str__(self): from som.vm.universe import get_current return "a " + self.get_class(get_current()).get_name().get_string() <commit_msg>Send methods need to return the result Signed-off-by: Stefan Marr <46f1a0bd5592a2f9244ca321b129902a06b53e03@stefan-marr.de><commit_after>class AbstractObject(object): def __init__(self): pass def send(self, frame, selector_string, arguments, universe): # Turn the selector string into a selector selector = universe.symbol_for(selector_string) invokable = self.get_class(universe).lookup_invokable(selector) return invokable.invoke(frame, self, arguments) def send_does_not_understand(self, frame, selector, arguments, universe): # Compute the number of arguments number_of_arguments = selector.get_number_of_signature_arguments() arguments_array = universe.new_array_with_length(number_of_arguments) for i in range(0, number_of_arguments): arguments_array.set_indexable_field(i, arguments[i]) args = [selector, arguments_array] return self.send(frame, "doesNotUnderstand:arguments:", args, universe) def send_unknown_global(self, frame, global_name, universe): arguments = [global_name] return self.send(frame, "unknownGlobal:", arguments, universe) def send_escaped_block(self, frame, block, universe): arguments = [block] return self.send(frame, "escapedBlock:", arguments, universe) def get_class(self, universe): raise NotImplementedError("Subclasses need to implement get_class(universe).") def is_invokable(self): return False def __str__(self): from som.vm.universe import get_current return "a " + self.get_class(get_current()).get_name().get_string()
539f0c6626f4ec18a0995f90727425748a5eaee9
migrations/versions/2f3192e76e5_.py
migrations/versions/2f3192e76e5_.py
"""empty message Revision ID: 2f3192e76e5 Revises: 3dbc20af3c9 Create Date: 2015-11-24 15:28:41.695124 """ # revision identifiers, used by Alembic. revision = '2f3192e76e5' down_revision = '3dbc20af3c9' from alembic import op import sqlalchemy as sa import sqlalchemy_utils def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.add_column('word', sa.Column('search_vector', sqlalchemy_utils.TSVectorType(), nullable=True)) op.create_index('ix_word_search_vector', 'word', ['search_vector'], unique=False, postgresql_using='gin') ### end Alembic commands ### def downgrade(): ### commands auto generated by Alembic - please adjust! ### op.drop_index('ix_word_search_vector', table_name='word') op.drop_column('word', 'search_vector') ### end Alembic commands ###
"""empty message Revision ID: 2f3192e76e5 Revises: 3dbc20af3c9 Create Date: 2015-11-24 15:28:41.695124 """ # revision identifiers, used by Alembic. revision = '2f3192e76e5' down_revision = '3dbc20af3c9' from alembic import op import sqlalchemy as sa import sqlalchemy_utils from sqlalchemy_searchable import sync_trigger def upgrade(): conn = op.get_bind() sync_trigger(conn, 'word', 'search_vector', ["singular", "plural", "infinitive", "past_tense", "present_perfect_tense", "positive", "comparative", "superlative", "adverb", "conjunction", "preposition", "meaning", "examples"]) ### commands auto generated by Alembic - please adjust! ### op.add_column('word', sa.Column('search_vector', sqlalchemy_utils.TSVectorType(), nullable=True)) op.create_index('ix_word_search_vector', 'word', ['search_vector'], unique=False, postgresql_using='gin') ### end Alembic commands ### def downgrade(): ### commands auto generated by Alembic - please adjust! ### op.drop_index('ix_word_search_vector', table_name='word') op.drop_column('word', 'search_vector') ### end Alembic commands ###
Add sync trigger to latest migration
Add sync trigger to latest migration
Python
mit
Encrylize/MyDictionary,Encrylize/MyDictionary,Encrylize/MyDictionary
"""empty message Revision ID: 2f3192e76e5 Revises: 3dbc20af3c9 Create Date: 2015-11-24 15:28:41.695124 """ # revision identifiers, used by Alembic. revision = '2f3192e76e5' down_revision = '3dbc20af3c9' from alembic import op import sqlalchemy as sa import sqlalchemy_utils def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.add_column('word', sa.Column('search_vector', sqlalchemy_utils.TSVectorType(), nullable=True)) op.create_index('ix_word_search_vector', 'word', ['search_vector'], unique=False, postgresql_using='gin') ### end Alembic commands ### def downgrade(): ### commands auto generated by Alembic - please adjust! ### op.drop_index('ix_word_search_vector', table_name='word') op.drop_column('word', 'search_vector') ### end Alembic commands ### Add sync trigger to latest migration
"""empty message Revision ID: 2f3192e76e5 Revises: 3dbc20af3c9 Create Date: 2015-11-24 15:28:41.695124 """ # revision identifiers, used by Alembic. revision = '2f3192e76e5' down_revision = '3dbc20af3c9' from alembic import op import sqlalchemy as sa import sqlalchemy_utils from sqlalchemy_searchable import sync_trigger def upgrade(): conn = op.get_bind() sync_trigger(conn, 'word', 'search_vector', ["singular", "plural", "infinitive", "past_tense", "present_perfect_tense", "positive", "comparative", "superlative", "adverb", "conjunction", "preposition", "meaning", "examples"]) ### commands auto generated by Alembic - please adjust! ### op.add_column('word', sa.Column('search_vector', sqlalchemy_utils.TSVectorType(), nullable=True)) op.create_index('ix_word_search_vector', 'word', ['search_vector'], unique=False, postgresql_using='gin') ### end Alembic commands ### def downgrade(): ### commands auto generated by Alembic - please adjust! ### op.drop_index('ix_word_search_vector', table_name='word') op.drop_column('word', 'search_vector') ### end Alembic commands ###
<commit_before>"""empty message Revision ID: 2f3192e76e5 Revises: 3dbc20af3c9 Create Date: 2015-11-24 15:28:41.695124 """ # revision identifiers, used by Alembic. revision = '2f3192e76e5' down_revision = '3dbc20af3c9' from alembic import op import sqlalchemy as sa import sqlalchemy_utils def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.add_column('word', sa.Column('search_vector', sqlalchemy_utils.TSVectorType(), nullable=True)) op.create_index('ix_word_search_vector', 'word', ['search_vector'], unique=False, postgresql_using='gin') ### end Alembic commands ### def downgrade(): ### commands auto generated by Alembic - please adjust! ### op.drop_index('ix_word_search_vector', table_name='word') op.drop_column('word', 'search_vector') ### end Alembic commands ### <commit_msg>Add sync trigger to latest migration<commit_after>
"""empty message Revision ID: 2f3192e76e5 Revises: 3dbc20af3c9 Create Date: 2015-11-24 15:28:41.695124 """ # revision identifiers, used by Alembic. revision = '2f3192e76e5' down_revision = '3dbc20af3c9' from alembic import op import sqlalchemy as sa import sqlalchemy_utils from sqlalchemy_searchable import sync_trigger def upgrade(): conn = op.get_bind() sync_trigger(conn, 'word', 'search_vector', ["singular", "plural", "infinitive", "past_tense", "present_perfect_tense", "positive", "comparative", "superlative", "adverb", "conjunction", "preposition", "meaning", "examples"]) ### commands auto generated by Alembic - please adjust! ### op.add_column('word', sa.Column('search_vector', sqlalchemy_utils.TSVectorType(), nullable=True)) op.create_index('ix_word_search_vector', 'word', ['search_vector'], unique=False, postgresql_using='gin') ### end Alembic commands ### def downgrade(): ### commands auto generated by Alembic - please adjust! ### op.drop_index('ix_word_search_vector', table_name='word') op.drop_column('word', 'search_vector') ### end Alembic commands ###
"""empty message Revision ID: 2f3192e76e5 Revises: 3dbc20af3c9 Create Date: 2015-11-24 15:28:41.695124 """ # revision identifiers, used by Alembic. revision = '2f3192e76e5' down_revision = '3dbc20af3c9' from alembic import op import sqlalchemy as sa import sqlalchemy_utils def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.add_column('word', sa.Column('search_vector', sqlalchemy_utils.TSVectorType(), nullable=True)) op.create_index('ix_word_search_vector', 'word', ['search_vector'], unique=False, postgresql_using='gin') ### end Alembic commands ### def downgrade(): ### commands auto generated by Alembic - please adjust! ### op.drop_index('ix_word_search_vector', table_name='word') op.drop_column('word', 'search_vector') ### end Alembic commands ### Add sync trigger to latest migration"""empty message Revision ID: 2f3192e76e5 Revises: 3dbc20af3c9 Create Date: 2015-11-24 15:28:41.695124 """ # revision identifiers, used by Alembic. revision = '2f3192e76e5' down_revision = '3dbc20af3c9' from alembic import op import sqlalchemy as sa import sqlalchemy_utils from sqlalchemy_searchable import sync_trigger def upgrade(): conn = op.get_bind() sync_trigger(conn, 'word', 'search_vector', ["singular", "plural", "infinitive", "past_tense", "present_perfect_tense", "positive", "comparative", "superlative", "adverb", "conjunction", "preposition", "meaning", "examples"]) ### commands auto generated by Alembic - please adjust! ### op.add_column('word', sa.Column('search_vector', sqlalchemy_utils.TSVectorType(), nullable=True)) op.create_index('ix_word_search_vector', 'word', ['search_vector'], unique=False, postgresql_using='gin') ### end Alembic commands ### def downgrade(): ### commands auto generated by Alembic - please adjust! ### op.drop_index('ix_word_search_vector', table_name='word') op.drop_column('word', 'search_vector') ### end Alembic commands ###
<commit_before>"""empty message Revision ID: 2f3192e76e5 Revises: 3dbc20af3c9 Create Date: 2015-11-24 15:28:41.695124 """ # revision identifiers, used by Alembic. revision = '2f3192e76e5' down_revision = '3dbc20af3c9' from alembic import op import sqlalchemy as sa import sqlalchemy_utils def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.add_column('word', sa.Column('search_vector', sqlalchemy_utils.TSVectorType(), nullable=True)) op.create_index('ix_word_search_vector', 'word', ['search_vector'], unique=False, postgresql_using='gin') ### end Alembic commands ### def downgrade(): ### commands auto generated by Alembic - please adjust! ### op.drop_index('ix_word_search_vector', table_name='word') op.drop_column('word', 'search_vector') ### end Alembic commands ### <commit_msg>Add sync trigger to latest migration<commit_after>"""empty message Revision ID: 2f3192e76e5 Revises: 3dbc20af3c9 Create Date: 2015-11-24 15:28:41.695124 """ # revision identifiers, used by Alembic. revision = '2f3192e76e5' down_revision = '3dbc20af3c9' from alembic import op import sqlalchemy as sa import sqlalchemy_utils from sqlalchemy_searchable import sync_trigger def upgrade(): conn = op.get_bind() sync_trigger(conn, 'word', 'search_vector', ["singular", "plural", "infinitive", "past_tense", "present_perfect_tense", "positive", "comparative", "superlative", "adverb", "conjunction", "preposition", "meaning", "examples"]) ### commands auto generated by Alembic - please adjust! ### op.add_column('word', sa.Column('search_vector', sqlalchemy_utils.TSVectorType(), nullable=True)) op.create_index('ix_word_search_vector', 'word', ['search_vector'], unique=False, postgresql_using='gin') ### end Alembic commands ### def downgrade(): ### commands auto generated by Alembic - please adjust! ### op.drop_index('ix_word_search_vector', table_name='word') op.drop_column('word', 'search_vector') ### end Alembic commands ###
0821e31867bac4704248a63d846c9e5fc0377ac3
storage/test_driver.py
storage/test_driver.py
#!/usr/bin/env python from storage import Storage NEW_REPORT = {'foo': 'bar', 'boo': 'baz'} def main(): db_store = Storage.get_storage() for key, value in db_store.__dict__.iteritems(): print '%s: %s' % (key, value) print '\n' # report_id = db_store.store(NEW_REPORT) report_id = 'AVM0dGOF6iQbRONBw9yB' print db_store.get_report(report_id) print db_store.get_report(3) # db_store.delete(report_id) # print db_store.delete(2) if __name__ == '__main__': main()
#!/usr/bin/env python from storage import Storage NEW_REPORT = {'foo': 'bar', 'boo': 'baz'} REPORTS = [ {'report_id': 1, 'report': {"/tmp/example": {"MD5": "53f43f9591749b8cae536ff13e48d6de", "SHA256": "815d310bdbc8684c1163b62f583dbaffb2df74b9104e2aadabf8f8491bafab66", "libmagic": "ASCII text"}}}, {'report_id': 2, 'report': {"/opt/other_file": {"MD5": "96b47da202ddba8d7a6b91fecbf89a41", "SHA256": "26d11f0ea5cc77a59b6e47deee859440f26d2d14440beb712dbac8550d35ef1f", "libmagic": "a /bin/python script text executable"}}}, ] def populate_es(): db_store = Storage.get_storage() for report in REPORTS: db_store.store(report) def main(): db_store = Storage.get_storage() for key, value in db_store.__dict__.iteritems(): print '%s: %s' % (key, value) print '\n' # report_id = db_store.store(NEW_REPORT) report_id = 'AVM0dGOF6iQbRONBw9yB' print db_store.get_report(report_id) print db_store.get_report(3) # db_store.delete(report_id) # print db_store.delete(2) if __name__ == '__main__': main()
Add populate es function to test driver
Add populate es function to test driver
Python
mpl-2.0
MITRECND/multiscanner,awest1339/multiscanner,mitre/multiscanner,awest1339/multiscanner,awest1339/multiscanner,jmlong1027/multiscanner,jmlong1027/multiscanner,jmlong1027/multiscanner,mitre/multiscanner,awest1339/multiscanner,MITRECND/multiscanner,mitre/multiscanner,jmlong1027/multiscanner
#!/usr/bin/env python from storage import Storage NEW_REPORT = {'foo': 'bar', 'boo': 'baz'} def main(): db_store = Storage.get_storage() for key, value in db_store.__dict__.iteritems(): print '%s: %s' % (key, value) print '\n' # report_id = db_store.store(NEW_REPORT) report_id = 'AVM0dGOF6iQbRONBw9yB' print db_store.get_report(report_id) print db_store.get_report(3) # db_store.delete(report_id) # print db_store.delete(2) if __name__ == '__main__': main() Add populate es function to test driver
#!/usr/bin/env python from storage import Storage NEW_REPORT = {'foo': 'bar', 'boo': 'baz'} REPORTS = [ {'report_id': 1, 'report': {"/tmp/example": {"MD5": "53f43f9591749b8cae536ff13e48d6de", "SHA256": "815d310bdbc8684c1163b62f583dbaffb2df74b9104e2aadabf8f8491bafab66", "libmagic": "ASCII text"}}}, {'report_id': 2, 'report': {"/opt/other_file": {"MD5": "96b47da202ddba8d7a6b91fecbf89a41", "SHA256": "26d11f0ea5cc77a59b6e47deee859440f26d2d14440beb712dbac8550d35ef1f", "libmagic": "a /bin/python script text executable"}}}, ] def populate_es(): db_store = Storage.get_storage() for report in REPORTS: db_store.store(report) def main(): db_store = Storage.get_storage() for key, value in db_store.__dict__.iteritems(): print '%s: %s' % (key, value) print '\n' # report_id = db_store.store(NEW_REPORT) report_id = 'AVM0dGOF6iQbRONBw9yB' print db_store.get_report(report_id) print db_store.get_report(3) # db_store.delete(report_id) # print db_store.delete(2) if __name__ == '__main__': main()
<commit_before>#!/usr/bin/env python from storage import Storage NEW_REPORT = {'foo': 'bar', 'boo': 'baz'} def main(): db_store = Storage.get_storage() for key, value in db_store.__dict__.iteritems(): print '%s: %s' % (key, value) print '\n' # report_id = db_store.store(NEW_REPORT) report_id = 'AVM0dGOF6iQbRONBw9yB' print db_store.get_report(report_id) print db_store.get_report(3) # db_store.delete(report_id) # print db_store.delete(2) if __name__ == '__main__': main() <commit_msg>Add populate es function to test driver<commit_after>
#!/usr/bin/env python from storage import Storage NEW_REPORT = {'foo': 'bar', 'boo': 'baz'} REPORTS = [ {'report_id': 1, 'report': {"/tmp/example": {"MD5": "53f43f9591749b8cae536ff13e48d6de", "SHA256": "815d310bdbc8684c1163b62f583dbaffb2df74b9104e2aadabf8f8491bafab66", "libmagic": "ASCII text"}}}, {'report_id': 2, 'report': {"/opt/other_file": {"MD5": "96b47da202ddba8d7a6b91fecbf89a41", "SHA256": "26d11f0ea5cc77a59b6e47deee859440f26d2d14440beb712dbac8550d35ef1f", "libmagic": "a /bin/python script text executable"}}}, ] def populate_es(): db_store = Storage.get_storage() for report in REPORTS: db_store.store(report) def main(): db_store = Storage.get_storage() for key, value in db_store.__dict__.iteritems(): print '%s: %s' % (key, value) print '\n' # report_id = db_store.store(NEW_REPORT) report_id = 'AVM0dGOF6iQbRONBw9yB' print db_store.get_report(report_id) print db_store.get_report(3) # db_store.delete(report_id) # print db_store.delete(2) if __name__ == '__main__': main()
#!/usr/bin/env python from storage import Storage NEW_REPORT = {'foo': 'bar', 'boo': 'baz'} def main(): db_store = Storage.get_storage() for key, value in db_store.__dict__.iteritems(): print '%s: %s' % (key, value) print '\n' # report_id = db_store.store(NEW_REPORT) report_id = 'AVM0dGOF6iQbRONBw9yB' print db_store.get_report(report_id) print db_store.get_report(3) # db_store.delete(report_id) # print db_store.delete(2) if __name__ == '__main__': main() Add populate es function to test driver#!/usr/bin/env python from storage import Storage NEW_REPORT = {'foo': 'bar', 'boo': 'baz'} REPORTS = [ {'report_id': 1, 'report': {"/tmp/example": {"MD5": "53f43f9591749b8cae536ff13e48d6de", "SHA256": "815d310bdbc8684c1163b62f583dbaffb2df74b9104e2aadabf8f8491bafab66", "libmagic": "ASCII text"}}}, {'report_id': 2, 'report': {"/opt/other_file": {"MD5": "96b47da202ddba8d7a6b91fecbf89a41", "SHA256": "26d11f0ea5cc77a59b6e47deee859440f26d2d14440beb712dbac8550d35ef1f", "libmagic": "a /bin/python script text executable"}}}, ] def populate_es(): db_store = Storage.get_storage() for report in REPORTS: db_store.store(report) def main(): db_store = Storage.get_storage() for key, value in db_store.__dict__.iteritems(): print '%s: %s' % (key, value) print '\n' # report_id = db_store.store(NEW_REPORT) report_id = 'AVM0dGOF6iQbRONBw9yB' print db_store.get_report(report_id) print db_store.get_report(3) # db_store.delete(report_id) # print db_store.delete(2) if __name__ == '__main__': main()
<commit_before>#!/usr/bin/env python from storage import Storage NEW_REPORT = {'foo': 'bar', 'boo': 'baz'} def main(): db_store = Storage.get_storage() for key, value in db_store.__dict__.iteritems(): print '%s: %s' % (key, value) print '\n' # report_id = db_store.store(NEW_REPORT) report_id = 'AVM0dGOF6iQbRONBw9yB' print db_store.get_report(report_id) print db_store.get_report(3) # db_store.delete(report_id) # print db_store.delete(2) if __name__ == '__main__': main() <commit_msg>Add populate es function to test driver<commit_after>#!/usr/bin/env python from storage import Storage NEW_REPORT = {'foo': 'bar', 'boo': 'baz'} REPORTS = [ {'report_id': 1, 'report': {"/tmp/example": {"MD5": "53f43f9591749b8cae536ff13e48d6de", "SHA256": "815d310bdbc8684c1163b62f583dbaffb2df74b9104e2aadabf8f8491bafab66", "libmagic": "ASCII text"}}}, {'report_id': 2, 'report': {"/opt/other_file": {"MD5": "96b47da202ddba8d7a6b91fecbf89a41", "SHA256": "26d11f0ea5cc77a59b6e47deee859440f26d2d14440beb712dbac8550d35ef1f", "libmagic": "a /bin/python script text executable"}}}, ] def populate_es(): db_store = Storage.get_storage() for report in REPORTS: db_store.store(report) def main(): db_store = Storage.get_storage() for key, value in db_store.__dict__.iteritems(): print '%s: %s' % (key, value) print '\n' # report_id = db_store.store(NEW_REPORT) report_id = 'AVM0dGOF6iQbRONBw9yB' print db_store.get_report(report_id) print db_store.get_report(3) # db_store.delete(report_id) # print db_store.delete(2) if __name__ == '__main__': main()
bdcb57264574fdfa5af33bdaae1654fd3f008ed5
app/conf/celeryschedule.py
app/conf/celeryschedule.py
from datetime import timedelta CELERYBEAT_SCHEDULE = { "reddit-validations": { "task": "reddit.tasks.process_validations", "schedule": timedelta(minutes=10), }, "eveapi-update": { "task": "eve_api.tasks.account.queue_apikey_updates", "schedule": timedelta(minutes=10), }, "alliance-update": { "task": "eve_api.tasks.alliance.import_alliance_details", "schedule": timedelta(hours=6), }, "api-log-clear": { "task": "eve_proxy.tasks.clear_old_logs", "schedule": timedelta(days=1), }, "blacklist-check": { "task": "hr.tasks.blacklist_check", "schedule": timedelta(days=1), }, "reddit-update": { "task": "reddit.tasks.queue_account_updates", "schedule": timedelta(minutes=15), } } CELERY_ROUTES = { "sso.tasks.update_service_groups": {'queue': 'bulk'}, }
from datetime import timedelta CELERYBEAT_SCHEDULE = { "reddit-validations": { "task": "reddit.tasks.process_validations", "schedule": timedelta(minutes=10), }, "eveapi-update": { "task": "eve_api.tasks.account.queue_apikey_updates", "schedule": timedelta(minutes=10), }, "alliance-update": { "task": "eve_api.tasks.alliance.import_alliance_details", "schedule": timedelta(hours=6), }, "api-log-clear": { "task": "eve_proxy.tasks.clear_old_logs", "schedule": timedelta(days=1), }, "blacklist-check": { "task": "hr.tasks.blacklist_check", "schedule": timedelta(days=1), }, "reddit-update": { "task": "reddit.tasks.queue_account_updates", "schedule": timedelta(minutes=15), } } CELERY_ROUTES = { "sso.tasks.update_service_groups": {'queue': 'bulk'}, "hr.tasks.blacklist_check": {'queue': 'bulk'}, }
Add the blacklist checking to the bulk
Add the blacklist checking to the bulk
Python
bsd-3-clause
nikdoof/test-auth
from datetime import timedelta CELERYBEAT_SCHEDULE = { "reddit-validations": { "task": "reddit.tasks.process_validations", "schedule": timedelta(minutes=10), }, "eveapi-update": { "task": "eve_api.tasks.account.queue_apikey_updates", "schedule": timedelta(minutes=10), }, "alliance-update": { "task": "eve_api.tasks.alliance.import_alliance_details", "schedule": timedelta(hours=6), }, "api-log-clear": { "task": "eve_proxy.tasks.clear_old_logs", "schedule": timedelta(days=1), }, "blacklist-check": { "task": "hr.tasks.blacklist_check", "schedule": timedelta(days=1), }, "reddit-update": { "task": "reddit.tasks.queue_account_updates", "schedule": timedelta(minutes=15), } } CELERY_ROUTES = { "sso.tasks.update_service_groups": {'queue': 'bulk'}, } Add the blacklist checking to the bulk
from datetime import timedelta CELERYBEAT_SCHEDULE = { "reddit-validations": { "task": "reddit.tasks.process_validations", "schedule": timedelta(minutes=10), }, "eveapi-update": { "task": "eve_api.tasks.account.queue_apikey_updates", "schedule": timedelta(minutes=10), }, "alliance-update": { "task": "eve_api.tasks.alliance.import_alliance_details", "schedule": timedelta(hours=6), }, "api-log-clear": { "task": "eve_proxy.tasks.clear_old_logs", "schedule": timedelta(days=1), }, "blacklist-check": { "task": "hr.tasks.blacklist_check", "schedule": timedelta(days=1), }, "reddit-update": { "task": "reddit.tasks.queue_account_updates", "schedule": timedelta(minutes=15), } } CELERY_ROUTES = { "sso.tasks.update_service_groups": {'queue': 'bulk'}, "hr.tasks.blacklist_check": {'queue': 'bulk'}, }
<commit_before>from datetime import timedelta CELERYBEAT_SCHEDULE = { "reddit-validations": { "task": "reddit.tasks.process_validations", "schedule": timedelta(minutes=10), }, "eveapi-update": { "task": "eve_api.tasks.account.queue_apikey_updates", "schedule": timedelta(minutes=10), }, "alliance-update": { "task": "eve_api.tasks.alliance.import_alliance_details", "schedule": timedelta(hours=6), }, "api-log-clear": { "task": "eve_proxy.tasks.clear_old_logs", "schedule": timedelta(days=1), }, "blacklist-check": { "task": "hr.tasks.blacklist_check", "schedule": timedelta(days=1), }, "reddit-update": { "task": "reddit.tasks.queue_account_updates", "schedule": timedelta(minutes=15), } } CELERY_ROUTES = { "sso.tasks.update_service_groups": {'queue': 'bulk'}, } <commit_msg>Add the blacklist checking to the bulk<commit_after>
from datetime import timedelta CELERYBEAT_SCHEDULE = { "reddit-validations": { "task": "reddit.tasks.process_validations", "schedule": timedelta(minutes=10), }, "eveapi-update": { "task": "eve_api.tasks.account.queue_apikey_updates", "schedule": timedelta(minutes=10), }, "alliance-update": { "task": "eve_api.tasks.alliance.import_alliance_details", "schedule": timedelta(hours=6), }, "api-log-clear": { "task": "eve_proxy.tasks.clear_old_logs", "schedule": timedelta(days=1), }, "blacklist-check": { "task": "hr.tasks.blacklist_check", "schedule": timedelta(days=1), }, "reddit-update": { "task": "reddit.tasks.queue_account_updates", "schedule": timedelta(minutes=15), } } CELERY_ROUTES = { "sso.tasks.update_service_groups": {'queue': 'bulk'}, "hr.tasks.blacklist_check": {'queue': 'bulk'}, }
from datetime import timedelta CELERYBEAT_SCHEDULE = { "reddit-validations": { "task": "reddit.tasks.process_validations", "schedule": timedelta(minutes=10), }, "eveapi-update": { "task": "eve_api.tasks.account.queue_apikey_updates", "schedule": timedelta(minutes=10), }, "alliance-update": { "task": "eve_api.tasks.alliance.import_alliance_details", "schedule": timedelta(hours=6), }, "api-log-clear": { "task": "eve_proxy.tasks.clear_old_logs", "schedule": timedelta(days=1), }, "blacklist-check": { "task": "hr.tasks.blacklist_check", "schedule": timedelta(days=1), }, "reddit-update": { "task": "reddit.tasks.queue_account_updates", "schedule": timedelta(minutes=15), } } CELERY_ROUTES = { "sso.tasks.update_service_groups": {'queue': 'bulk'}, } Add the blacklist checking to the bulkfrom datetime import timedelta CELERYBEAT_SCHEDULE = { "reddit-validations": { "task": "reddit.tasks.process_validations", "schedule": timedelta(minutes=10), }, "eveapi-update": { "task": "eve_api.tasks.account.queue_apikey_updates", "schedule": timedelta(minutes=10), }, "alliance-update": { "task": "eve_api.tasks.alliance.import_alliance_details", "schedule": timedelta(hours=6), }, "api-log-clear": { "task": "eve_proxy.tasks.clear_old_logs", "schedule": timedelta(days=1), }, "blacklist-check": { "task": "hr.tasks.blacklist_check", "schedule": timedelta(days=1), }, "reddit-update": { "task": "reddit.tasks.queue_account_updates", "schedule": timedelta(minutes=15), } } CELERY_ROUTES = { "sso.tasks.update_service_groups": {'queue': 'bulk'}, "hr.tasks.blacklist_check": {'queue': 'bulk'}, }
<commit_before>from datetime import timedelta CELERYBEAT_SCHEDULE = { "reddit-validations": { "task": "reddit.tasks.process_validations", "schedule": timedelta(minutes=10), }, "eveapi-update": { "task": "eve_api.tasks.account.queue_apikey_updates", "schedule": timedelta(minutes=10), }, "alliance-update": { "task": "eve_api.tasks.alliance.import_alliance_details", "schedule": timedelta(hours=6), }, "api-log-clear": { "task": "eve_proxy.tasks.clear_old_logs", "schedule": timedelta(days=1), }, "blacklist-check": { "task": "hr.tasks.blacklist_check", "schedule": timedelta(days=1), }, "reddit-update": { "task": "reddit.tasks.queue_account_updates", "schedule": timedelta(minutes=15), } } CELERY_ROUTES = { "sso.tasks.update_service_groups": {'queue': 'bulk'}, } <commit_msg>Add the blacklist checking to the bulk<commit_after>from datetime import timedelta CELERYBEAT_SCHEDULE = { "reddit-validations": { "task": "reddit.tasks.process_validations", "schedule": timedelta(minutes=10), }, "eveapi-update": { "task": "eve_api.tasks.account.queue_apikey_updates", "schedule": timedelta(minutes=10), }, "alliance-update": { "task": "eve_api.tasks.alliance.import_alliance_details", "schedule": timedelta(hours=6), }, "api-log-clear": { "task": "eve_proxy.tasks.clear_old_logs", "schedule": timedelta(days=1), }, "blacklist-check": { "task": "hr.tasks.blacklist_check", "schedule": timedelta(days=1), }, "reddit-update": { "task": "reddit.tasks.queue_account_updates", "schedule": timedelta(minutes=15), } } CELERY_ROUTES = { "sso.tasks.update_service_groups": {'queue': 'bulk'}, "hr.tasks.blacklist_check": {'queue': 'bulk'}, }
475ff9a1b1eed0cd5f1b20f0a42926b735a4c163
txircd/modules/extra/conn_umodes.py
txircd/modules/extra/conn_umodes.py
from twisted.plugin import IPlugin from txircd.module_interface import IModuleData, ModuleData from txircd.utils import ModeType from zope.interface import implements class AutoUserModes(ModuleData): implements(IPlugin, IModuleData) name = "AutoUserModes" def actions(self): return [ ("welcome", 50, self.autoSetUserModes) ] def autoSetUserModes(self, user): try: modes = self.ircd.config["client_umodes_on_connect"] params = modes.split() modes = params.pop(0) parsedModes = [] for mode in modes: if mode not in self.ircd.userModeTypes: continue modeType = self.ircd.userModeTypes[mode] if modeType in (ModeType.List, ModeType.ParamOnUnset, ModeType.Param): parsedModes.append((True, mode, params.pop(0))) else: parsedModes.append((True, mode, None)) user.setModes(parsedModes, self.ircd.serverID) except KeyError: pass # No umodes defined. No action required. autoUserModes = AutoUserModes()
from twisted.plugin import IPlugin from txircd.module_interface import IModuleData, ModuleData from txircd.utils import ModeType from zope.interface import implements class AutoUserModes(ModuleData): implements(IPlugin, IModuleData) name = "AutoUserModes" def actions(self): return [ ("welcome", 50, self.autoSetUserModes) ] def autoSetUserModes(self, user): try: modes = self.ircd.config["client_umodes_on_connect"] params = modes.split() modes = params.pop(0) parsedModes = [] for mode in modes: if mode not in self.ircd.userModeTypes: continue modeType = self.ircd.userModeTypes[mode] if modeType != ModeType.NoParam: parsedModes.append((True, mode, params.pop(0))) else: parsedModes.append((True, mode, None)) user.setModes(parsedModes, self.ircd.serverID) except KeyError: pass # No umodes defined. No action required. autoUserModes = AutoUserModes()
Simplify the AutoUserModes mode type check
Simplify the AutoUserModes mode type check
Python
bsd-3-clause
ElementalAlchemist/txircd,Heufneutje/txircd
from twisted.plugin import IPlugin from txircd.module_interface import IModuleData, ModuleData from txircd.utils import ModeType from zope.interface import implements class AutoUserModes(ModuleData): implements(IPlugin, IModuleData) name = "AutoUserModes" def actions(self): return [ ("welcome", 50, self.autoSetUserModes) ] def autoSetUserModes(self, user): try: modes = self.ircd.config["client_umodes_on_connect"] params = modes.split() modes = params.pop(0) parsedModes = [] for mode in modes: if mode not in self.ircd.userModeTypes: continue modeType = self.ircd.userModeTypes[mode] if modeType in (ModeType.List, ModeType.ParamOnUnset, ModeType.Param): parsedModes.append((True, mode, params.pop(0))) else: parsedModes.append((True, mode, None)) user.setModes(parsedModes, self.ircd.serverID) except KeyError: pass # No umodes defined. No action required. autoUserModes = AutoUserModes()Simplify the AutoUserModes mode type check
from twisted.plugin import IPlugin from txircd.module_interface import IModuleData, ModuleData from txircd.utils import ModeType from zope.interface import implements class AutoUserModes(ModuleData): implements(IPlugin, IModuleData) name = "AutoUserModes" def actions(self): return [ ("welcome", 50, self.autoSetUserModes) ] def autoSetUserModes(self, user): try: modes = self.ircd.config["client_umodes_on_connect"] params = modes.split() modes = params.pop(0) parsedModes = [] for mode in modes: if mode not in self.ircd.userModeTypes: continue modeType = self.ircd.userModeTypes[mode] if modeType != ModeType.NoParam: parsedModes.append((True, mode, params.pop(0))) else: parsedModes.append((True, mode, None)) user.setModes(parsedModes, self.ircd.serverID) except KeyError: pass # No umodes defined. No action required. autoUserModes = AutoUserModes()
<commit_before>from twisted.plugin import IPlugin from txircd.module_interface import IModuleData, ModuleData from txircd.utils import ModeType from zope.interface import implements class AutoUserModes(ModuleData): implements(IPlugin, IModuleData) name = "AutoUserModes" def actions(self): return [ ("welcome", 50, self.autoSetUserModes) ] def autoSetUserModes(self, user): try: modes = self.ircd.config["client_umodes_on_connect"] params = modes.split() modes = params.pop(0) parsedModes = [] for mode in modes: if mode not in self.ircd.userModeTypes: continue modeType = self.ircd.userModeTypes[mode] if modeType in (ModeType.List, ModeType.ParamOnUnset, ModeType.Param): parsedModes.append((True, mode, params.pop(0))) else: parsedModes.append((True, mode, None)) user.setModes(parsedModes, self.ircd.serverID) except KeyError: pass # No umodes defined. No action required. autoUserModes = AutoUserModes()<commit_msg>Simplify the AutoUserModes mode type check<commit_after>
from twisted.plugin import IPlugin from txircd.module_interface import IModuleData, ModuleData from txircd.utils import ModeType from zope.interface import implements class AutoUserModes(ModuleData): implements(IPlugin, IModuleData) name = "AutoUserModes" def actions(self): return [ ("welcome", 50, self.autoSetUserModes) ] def autoSetUserModes(self, user): try: modes = self.ircd.config["client_umodes_on_connect"] params = modes.split() modes = params.pop(0) parsedModes = [] for mode in modes: if mode not in self.ircd.userModeTypes: continue modeType = self.ircd.userModeTypes[mode] if modeType != ModeType.NoParam: parsedModes.append((True, mode, params.pop(0))) else: parsedModes.append((True, mode, None)) user.setModes(parsedModes, self.ircd.serverID) except KeyError: pass # No umodes defined. No action required. autoUserModes = AutoUserModes()
from twisted.plugin import IPlugin from txircd.module_interface import IModuleData, ModuleData from txircd.utils import ModeType from zope.interface import implements class AutoUserModes(ModuleData): implements(IPlugin, IModuleData) name = "AutoUserModes" def actions(self): return [ ("welcome", 50, self.autoSetUserModes) ] def autoSetUserModes(self, user): try: modes = self.ircd.config["client_umodes_on_connect"] params = modes.split() modes = params.pop(0) parsedModes = [] for mode in modes: if mode not in self.ircd.userModeTypes: continue modeType = self.ircd.userModeTypes[mode] if modeType in (ModeType.List, ModeType.ParamOnUnset, ModeType.Param): parsedModes.append((True, mode, params.pop(0))) else: parsedModes.append((True, mode, None)) user.setModes(parsedModes, self.ircd.serverID) except KeyError: pass # No umodes defined. No action required. autoUserModes = AutoUserModes()Simplify the AutoUserModes mode type checkfrom twisted.plugin import IPlugin from txircd.module_interface import IModuleData, ModuleData from txircd.utils import ModeType from zope.interface import implements class AutoUserModes(ModuleData): implements(IPlugin, IModuleData) name = "AutoUserModes" def actions(self): return [ ("welcome", 50, self.autoSetUserModes) ] def autoSetUserModes(self, user): try: modes = self.ircd.config["client_umodes_on_connect"] params = modes.split() modes = params.pop(0) parsedModes = [] for mode in modes: if mode not in self.ircd.userModeTypes: continue modeType = self.ircd.userModeTypes[mode] if modeType != ModeType.NoParam: parsedModes.append((True, mode, params.pop(0))) else: parsedModes.append((True, mode, None)) user.setModes(parsedModes, self.ircd.serverID) except KeyError: pass # No umodes defined. No action required. autoUserModes = AutoUserModes()
<commit_before>from twisted.plugin import IPlugin from txircd.module_interface import IModuleData, ModuleData from txircd.utils import ModeType from zope.interface import implements class AutoUserModes(ModuleData): implements(IPlugin, IModuleData) name = "AutoUserModes" def actions(self): return [ ("welcome", 50, self.autoSetUserModes) ] def autoSetUserModes(self, user): try: modes = self.ircd.config["client_umodes_on_connect"] params = modes.split() modes = params.pop(0) parsedModes = [] for mode in modes: if mode not in self.ircd.userModeTypes: continue modeType = self.ircd.userModeTypes[mode] if modeType in (ModeType.List, ModeType.ParamOnUnset, ModeType.Param): parsedModes.append((True, mode, params.pop(0))) else: parsedModes.append((True, mode, None)) user.setModes(parsedModes, self.ircd.serverID) except KeyError: pass # No umodes defined. No action required. autoUserModes = AutoUserModes()<commit_msg>Simplify the AutoUserModes mode type check<commit_after>from twisted.plugin import IPlugin from txircd.module_interface import IModuleData, ModuleData from txircd.utils import ModeType from zope.interface import implements class AutoUserModes(ModuleData): implements(IPlugin, IModuleData) name = "AutoUserModes" def actions(self): return [ ("welcome", 50, self.autoSetUserModes) ] def autoSetUserModes(self, user): try: modes = self.ircd.config["client_umodes_on_connect"] params = modes.split() modes = params.pop(0) parsedModes = [] for mode in modes: if mode not in self.ircd.userModeTypes: continue modeType = self.ircd.userModeTypes[mode] if modeType != ModeType.NoParam: parsedModes.append((True, mode, params.pop(0))) else: parsedModes.append((True, mode, None)) user.setModes(parsedModes, self.ircd.serverID) except KeyError: pass # No umodes defined. No action required. autoUserModes = AutoUserModes()
c6cb543f35356769dcc0f7fedb099a160e267473
run_tests.py
run_tests.py
#!/usr/bin/env python import os, sys, re, shutil os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings' # Use psycopg2cffi for PyPy try: import psycopg2 # noqa except ImportError: # Fall back to psycopg2cffi from psycopg2cffi import compat compat.register() # Set up Django import django from django.core.management import call_command django.setup() # Derive test names names = next((a for a in sys.argv[1:] if not a.startswith('-')), None) if not names: names = 'tests' elif re.search(r'^\d+', names): names = 'tests.tests.IssueTests.test_' + names elif not names.startswith('tests.'): names = 'tests.tests.' + names # NOTE: we create migrations each time since they depend on type of database, # python and django versions try: shutil.rmtree('tests/migrations', True) call_command('makemigrations', 'tests', verbosity=2 if '-v' in sys.argv else 0) call_command('test', names, failfast='-x' in sys.argv, verbosity=2 if '-v' in sys.argv else 1) finally: shutil.rmtree('tests/migrations')
#!/usr/bin/env python import os, sys, re, shutil os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings' # Use psycopg2cffi for PyPy try: import psycopg2 # noqa except ImportError: # Fall back to psycopg2cffi try: from psycopg2cffi import compat compat.register() except ImportError: # Hope we are not testing against PostgreSQL :) pass # Set up Django import django from django.core.management import call_command django.setup() # Derive test names names = next((a for a in sys.argv[1:] if not a.startswith('-')), None) if not names: names = 'tests' elif re.search(r'^\d+', names): names = 'tests.tests.IssueTests.test_' + names elif not names.startswith('tests.'): names = 'tests.tests.' + names # NOTE: we create migrations each time since they depend on type of database, # python and django versions try: shutil.rmtree('tests/migrations', True) call_command('makemigrations', 'tests', verbosity=2 if '-v' in sys.argv else 0) call_command('test', names, failfast='-x' in sys.argv, verbosity=2 if '-v' in sys.argv else 1) finally: shutil.rmtree('tests/migrations')
Stop requiring psycopg2 to run tests
Stop requiring psycopg2 to run tests
Python
bsd-3-clause
LPgenerator/django-cacheops,Suor/django-cacheops
#!/usr/bin/env python import os, sys, re, shutil os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings' # Use psycopg2cffi for PyPy try: import psycopg2 # noqa except ImportError: # Fall back to psycopg2cffi from psycopg2cffi import compat compat.register() # Set up Django import django from django.core.management import call_command django.setup() # Derive test names names = next((a for a in sys.argv[1:] if not a.startswith('-')), None) if not names: names = 'tests' elif re.search(r'^\d+', names): names = 'tests.tests.IssueTests.test_' + names elif not names.startswith('tests.'): names = 'tests.tests.' + names # NOTE: we create migrations each time since they depend on type of database, # python and django versions try: shutil.rmtree('tests/migrations', True) call_command('makemigrations', 'tests', verbosity=2 if '-v' in sys.argv else 0) call_command('test', names, failfast='-x' in sys.argv, verbosity=2 if '-v' in sys.argv else 1) finally: shutil.rmtree('tests/migrations') Stop requiring psycopg2 to run tests
#!/usr/bin/env python import os, sys, re, shutil os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings' # Use psycopg2cffi for PyPy try: import psycopg2 # noqa except ImportError: # Fall back to psycopg2cffi try: from psycopg2cffi import compat compat.register() except ImportError: # Hope we are not testing against PostgreSQL :) pass # Set up Django import django from django.core.management import call_command django.setup() # Derive test names names = next((a for a in sys.argv[1:] if not a.startswith('-')), None) if not names: names = 'tests' elif re.search(r'^\d+', names): names = 'tests.tests.IssueTests.test_' + names elif not names.startswith('tests.'): names = 'tests.tests.' + names # NOTE: we create migrations each time since they depend on type of database, # python and django versions try: shutil.rmtree('tests/migrations', True) call_command('makemigrations', 'tests', verbosity=2 if '-v' in sys.argv else 0) call_command('test', names, failfast='-x' in sys.argv, verbosity=2 if '-v' in sys.argv else 1) finally: shutil.rmtree('tests/migrations')
<commit_before>#!/usr/bin/env python import os, sys, re, shutil os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings' # Use psycopg2cffi for PyPy try: import psycopg2 # noqa except ImportError: # Fall back to psycopg2cffi from psycopg2cffi import compat compat.register() # Set up Django import django from django.core.management import call_command django.setup() # Derive test names names = next((a for a in sys.argv[1:] if not a.startswith('-')), None) if not names: names = 'tests' elif re.search(r'^\d+', names): names = 'tests.tests.IssueTests.test_' + names elif not names.startswith('tests.'): names = 'tests.tests.' + names # NOTE: we create migrations each time since they depend on type of database, # python and django versions try: shutil.rmtree('tests/migrations', True) call_command('makemigrations', 'tests', verbosity=2 if '-v' in sys.argv else 0) call_command('test', names, failfast='-x' in sys.argv, verbosity=2 if '-v' in sys.argv else 1) finally: shutil.rmtree('tests/migrations') <commit_msg>Stop requiring psycopg2 to run tests<commit_after>
#!/usr/bin/env python import os, sys, re, shutil os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings' # Use psycopg2cffi for PyPy try: import psycopg2 # noqa except ImportError: # Fall back to psycopg2cffi try: from psycopg2cffi import compat compat.register() except ImportError: # Hope we are not testing against PostgreSQL :) pass # Set up Django import django from django.core.management import call_command django.setup() # Derive test names names = next((a for a in sys.argv[1:] if not a.startswith('-')), None) if not names: names = 'tests' elif re.search(r'^\d+', names): names = 'tests.tests.IssueTests.test_' + names elif not names.startswith('tests.'): names = 'tests.tests.' + names # NOTE: we create migrations each time since they depend on type of database, # python and django versions try: shutil.rmtree('tests/migrations', True) call_command('makemigrations', 'tests', verbosity=2 if '-v' in sys.argv else 0) call_command('test', names, failfast='-x' in sys.argv, verbosity=2 if '-v' in sys.argv else 1) finally: shutil.rmtree('tests/migrations')
#!/usr/bin/env python import os, sys, re, shutil os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings' # Use psycopg2cffi for PyPy try: import psycopg2 # noqa except ImportError: # Fall back to psycopg2cffi from psycopg2cffi import compat compat.register() # Set up Django import django from django.core.management import call_command django.setup() # Derive test names names = next((a for a in sys.argv[1:] if not a.startswith('-')), None) if not names: names = 'tests' elif re.search(r'^\d+', names): names = 'tests.tests.IssueTests.test_' + names elif not names.startswith('tests.'): names = 'tests.tests.' + names # NOTE: we create migrations each time since they depend on type of database, # python and django versions try: shutil.rmtree('tests/migrations', True) call_command('makemigrations', 'tests', verbosity=2 if '-v' in sys.argv else 0) call_command('test', names, failfast='-x' in sys.argv, verbosity=2 if '-v' in sys.argv else 1) finally: shutil.rmtree('tests/migrations') Stop requiring psycopg2 to run tests#!/usr/bin/env python import os, sys, re, shutil os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings' # Use psycopg2cffi for PyPy try: import psycopg2 # noqa except ImportError: # Fall back to psycopg2cffi try: from psycopg2cffi import compat compat.register() except ImportError: # Hope we are not testing against PostgreSQL :) pass # Set up Django import django from django.core.management import call_command django.setup() # Derive test names names = next((a for a in sys.argv[1:] if not a.startswith('-')), None) if not names: names = 'tests' elif re.search(r'^\d+', names): names = 'tests.tests.IssueTests.test_' + names elif not names.startswith('tests.'): names = 'tests.tests.' + names # NOTE: we create migrations each time since they depend on type of database, # python and django versions try: shutil.rmtree('tests/migrations', True) call_command('makemigrations', 'tests', verbosity=2 if '-v' in sys.argv else 0) call_command('test', names, failfast='-x' in sys.argv, verbosity=2 if '-v' in sys.argv else 1) finally: shutil.rmtree('tests/migrations')
<commit_before>#!/usr/bin/env python import os, sys, re, shutil os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings' # Use psycopg2cffi for PyPy try: import psycopg2 # noqa except ImportError: # Fall back to psycopg2cffi from psycopg2cffi import compat compat.register() # Set up Django import django from django.core.management import call_command django.setup() # Derive test names names = next((a for a in sys.argv[1:] if not a.startswith('-')), None) if not names: names = 'tests' elif re.search(r'^\d+', names): names = 'tests.tests.IssueTests.test_' + names elif not names.startswith('tests.'): names = 'tests.tests.' + names # NOTE: we create migrations each time since they depend on type of database, # python and django versions try: shutil.rmtree('tests/migrations', True) call_command('makemigrations', 'tests', verbosity=2 if '-v' in sys.argv else 0) call_command('test', names, failfast='-x' in sys.argv, verbosity=2 if '-v' in sys.argv else 1) finally: shutil.rmtree('tests/migrations') <commit_msg>Stop requiring psycopg2 to run tests<commit_after>#!/usr/bin/env python import os, sys, re, shutil os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings' # Use psycopg2cffi for PyPy try: import psycopg2 # noqa except ImportError: # Fall back to psycopg2cffi try: from psycopg2cffi import compat compat.register() except ImportError: # Hope we are not testing against PostgreSQL :) pass # Set up Django import django from django.core.management import call_command django.setup() # Derive test names names = next((a for a in sys.argv[1:] if not a.startswith('-')), None) if not names: names = 'tests' elif re.search(r'^\d+', names): names = 'tests.tests.IssueTests.test_' + names elif not names.startswith('tests.'): names = 'tests.tests.' + names # NOTE: we create migrations each time since they depend on type of database, # python and django versions try: shutil.rmtree('tests/migrations', True) call_command('makemigrations', 'tests', verbosity=2 if '-v' in sys.argv else 0) call_command('test', names, failfast='-x' in sys.argv, verbosity=2 if '-v' in sys.argv else 1) finally: shutil.rmtree('tests/migrations')
320f26632ee3462aaeb1a88fcdcfe69dbbb2322b
runserver.py
runserver.py
if __name__ == "__main__": from plenario import create_app application = create_app() application.run(host="0.0.0.0")
from plenario import create_app application = create_app() if __name__ == "__main__": application.run(host="0.0.0.0")
Move 'application' outside of if '__main__' -.-
Move 'application' outside of if '__main__' -.-
Python
mit
UrbanCCD-UChicago/plenario,UrbanCCD-UChicago/plenario,UrbanCCD-UChicago/plenario
if __name__ == "__main__": from plenario import create_app application = create_app() application.run(host="0.0.0.0") Move 'application' outside of if '__main__' -.-
from plenario import create_app application = create_app() if __name__ == "__main__": application.run(host="0.0.0.0")
<commit_before>if __name__ == "__main__": from plenario import create_app application = create_app() application.run(host="0.0.0.0") <commit_msg>Move 'application' outside of if '__main__' -.-<commit_after>
from plenario import create_app application = create_app() if __name__ == "__main__": application.run(host="0.0.0.0")
if __name__ == "__main__": from plenario import create_app application = create_app() application.run(host="0.0.0.0") Move 'application' outside of if '__main__' -.-from plenario import create_app application = create_app() if __name__ == "__main__": application.run(host="0.0.0.0")
<commit_before>if __name__ == "__main__": from plenario import create_app application = create_app() application.run(host="0.0.0.0") <commit_msg>Move 'application' outside of if '__main__' -.-<commit_after>from plenario import create_app application = create_app() if __name__ == "__main__": application.run(host="0.0.0.0")
c36301ec14e6d10762e613c0c52bf0e48baf9df9
goatools/godag/consts.py
goatools/godag/consts.py
"""GO-DAG constants.""" __copyright__ = "Copyright (C) 2010-2018, DV Klopfenstein, H Tang, All rights reserved." __author__ = "DV Klopfenstein" # pylint: disable=too-few-public-methods class Consts(object): """Constants commonly used in GO-DAG operations.""" NAMESPACE2NS = { 'biological_process' : 'BP', 'molecular_function' : 'MF', 'cellular_component' : 'CC'} RELATIONSHIP_LIST = ['part_of', 'regulates', 'negatively_regulates', 'positively_regulates'] def __init__(self): self.relationships = set(self.RELATIONSHIP_LIST) # Copyright (C) 2010-2018, DV Klopfenstein, H Tang, All rights reserved.
"""GO-DAG constants.""" __copyright__ = "Copyright (C) 2010-2018, DV Klopfenstein, H Tang, All rights reserved." __author__ = "DV Klopfenstein" # pylint: disable=too-few-public-methods class Consts(object): """Constants commonly used in GO-DAG operations.""" NAMESPACE2NS = { 'biological_process' : 'BP', 'molecular_function' : 'MF', 'cellular_component' : 'CC'} # https://owlcollab.github.io/oboformat/doc/GO.format.obo-1_4.html RELATIONSHIP_LIST = ['part_of', 'regulates', 'negatively_regulates', 'positively_regulates'] def __init__(self): self.relationships = set(self.RELATIONSHIP_LIST) # Copyright (C) 2010-2018, DV Klopfenstein, H Tang, All rights reserved.
Add comment with link to more info
Add comment with link to more info
Python
bsd-2-clause
tanghaibao/goatools,tanghaibao/goatools
"""GO-DAG constants.""" __copyright__ = "Copyright (C) 2010-2018, DV Klopfenstein, H Tang, All rights reserved." __author__ = "DV Klopfenstein" # pylint: disable=too-few-public-methods class Consts(object): """Constants commonly used in GO-DAG operations.""" NAMESPACE2NS = { 'biological_process' : 'BP', 'molecular_function' : 'MF', 'cellular_component' : 'CC'} RELATIONSHIP_LIST = ['part_of', 'regulates', 'negatively_regulates', 'positively_regulates'] def __init__(self): self.relationships = set(self.RELATIONSHIP_LIST) # Copyright (C) 2010-2018, DV Klopfenstein, H Tang, All rights reserved. Add comment with link to more info
"""GO-DAG constants.""" __copyright__ = "Copyright (C) 2010-2018, DV Klopfenstein, H Tang, All rights reserved." __author__ = "DV Klopfenstein" # pylint: disable=too-few-public-methods class Consts(object): """Constants commonly used in GO-DAG operations.""" NAMESPACE2NS = { 'biological_process' : 'BP', 'molecular_function' : 'MF', 'cellular_component' : 'CC'} # https://owlcollab.github.io/oboformat/doc/GO.format.obo-1_4.html RELATIONSHIP_LIST = ['part_of', 'regulates', 'negatively_regulates', 'positively_regulates'] def __init__(self): self.relationships = set(self.RELATIONSHIP_LIST) # Copyright (C) 2010-2018, DV Klopfenstein, H Tang, All rights reserved.
<commit_before>"""GO-DAG constants.""" __copyright__ = "Copyright (C) 2010-2018, DV Klopfenstein, H Tang, All rights reserved." __author__ = "DV Klopfenstein" # pylint: disable=too-few-public-methods class Consts(object): """Constants commonly used in GO-DAG operations.""" NAMESPACE2NS = { 'biological_process' : 'BP', 'molecular_function' : 'MF', 'cellular_component' : 'CC'} RELATIONSHIP_LIST = ['part_of', 'regulates', 'negatively_regulates', 'positively_regulates'] def __init__(self): self.relationships = set(self.RELATIONSHIP_LIST) # Copyright (C) 2010-2018, DV Klopfenstein, H Tang, All rights reserved. <commit_msg>Add comment with link to more info<commit_after>
"""GO-DAG constants.""" __copyright__ = "Copyright (C) 2010-2018, DV Klopfenstein, H Tang, All rights reserved." __author__ = "DV Klopfenstein" # pylint: disable=too-few-public-methods class Consts(object): """Constants commonly used in GO-DAG operations.""" NAMESPACE2NS = { 'biological_process' : 'BP', 'molecular_function' : 'MF', 'cellular_component' : 'CC'} # https://owlcollab.github.io/oboformat/doc/GO.format.obo-1_4.html RELATIONSHIP_LIST = ['part_of', 'regulates', 'negatively_regulates', 'positively_regulates'] def __init__(self): self.relationships = set(self.RELATIONSHIP_LIST) # Copyright (C) 2010-2018, DV Klopfenstein, H Tang, All rights reserved.
"""GO-DAG constants.""" __copyright__ = "Copyright (C) 2010-2018, DV Klopfenstein, H Tang, All rights reserved." __author__ = "DV Klopfenstein" # pylint: disable=too-few-public-methods class Consts(object): """Constants commonly used in GO-DAG operations.""" NAMESPACE2NS = { 'biological_process' : 'BP', 'molecular_function' : 'MF', 'cellular_component' : 'CC'} RELATIONSHIP_LIST = ['part_of', 'regulates', 'negatively_regulates', 'positively_regulates'] def __init__(self): self.relationships = set(self.RELATIONSHIP_LIST) # Copyright (C) 2010-2018, DV Klopfenstein, H Tang, All rights reserved. Add comment with link to more info"""GO-DAG constants.""" __copyright__ = "Copyright (C) 2010-2018, DV Klopfenstein, H Tang, All rights reserved." __author__ = "DV Klopfenstein" # pylint: disable=too-few-public-methods class Consts(object): """Constants commonly used in GO-DAG operations.""" NAMESPACE2NS = { 'biological_process' : 'BP', 'molecular_function' : 'MF', 'cellular_component' : 'CC'} # https://owlcollab.github.io/oboformat/doc/GO.format.obo-1_4.html RELATIONSHIP_LIST = ['part_of', 'regulates', 'negatively_regulates', 'positively_regulates'] def __init__(self): self.relationships = set(self.RELATIONSHIP_LIST) # Copyright (C) 2010-2018, DV Klopfenstein, H Tang, All rights reserved.
<commit_before>"""GO-DAG constants.""" __copyright__ = "Copyright (C) 2010-2018, DV Klopfenstein, H Tang, All rights reserved." __author__ = "DV Klopfenstein" # pylint: disable=too-few-public-methods class Consts(object): """Constants commonly used in GO-DAG operations.""" NAMESPACE2NS = { 'biological_process' : 'BP', 'molecular_function' : 'MF', 'cellular_component' : 'CC'} RELATIONSHIP_LIST = ['part_of', 'regulates', 'negatively_regulates', 'positively_regulates'] def __init__(self): self.relationships = set(self.RELATIONSHIP_LIST) # Copyright (C) 2010-2018, DV Klopfenstein, H Tang, All rights reserved. <commit_msg>Add comment with link to more info<commit_after>"""GO-DAG constants.""" __copyright__ = "Copyright (C) 2010-2018, DV Klopfenstein, H Tang, All rights reserved." __author__ = "DV Klopfenstein" # pylint: disable=too-few-public-methods class Consts(object): """Constants commonly used in GO-DAG operations.""" NAMESPACE2NS = { 'biological_process' : 'BP', 'molecular_function' : 'MF', 'cellular_component' : 'CC'} # https://owlcollab.github.io/oboformat/doc/GO.format.obo-1_4.html RELATIONSHIP_LIST = ['part_of', 'regulates', 'negatively_regulates', 'positively_regulates'] def __init__(self): self.relationships = set(self.RELATIONSHIP_LIST) # Copyright (C) 2010-2018, DV Klopfenstein, H Tang, All rights reserved.
9ff4f1e64f8d8208bfe83ed497fa280febcf5ce7
citrination_client/views/descriptors/real_descriptor.py
citrination_client/views/descriptors/real_descriptor.py
from citrination_client.views.descriptors.descriptor import MaterialDescriptor class RealDescriptor(MaterialDescriptor): def __init__(self, key, lower_bound="-Infinity", upper_bound="Infinity", units=""): self.options = dict(lower_bound=lower_bound, upper_bound=upper_bound, units=units) super(RealDescriptor, self).__init__(key, "Real") def validate(self): raw_lower = self.options["lower_bound"] raw_upper = self.options["upper_bound"] try: lower = float(str(raw_lower).replace("Infinity", "inf")) upper = float(str(raw_upper).replace("Infinity", "inf")) except ValueError: raise ValueError( "lower_bound and upper_bound must be floats (or Infinity/-Infinity) but got {} and {} respectively".format( raw_lower, raw_upper) ) if lower > upper: raise ValueError("Lower ({}) must be smaller than upper ({})".format(lower, upper))
from citrination_client.views.descriptors.descriptor import MaterialDescriptor class RealDescriptor(MaterialDescriptor): def __init__(self, key, lower_bound, upper_bound, units=""): self.options = dict(lower_bound=lower_bound, upper_bound=upper_bound, units=units) super(RealDescriptor, self).__init__(key, "Real") def validate(self): raw_lower = self.options["lower_bound"] raw_upper = self.options["upper_bound"] try: lower = float(str(raw_lower)) upper = float(str(raw_upper)) except ValueError: raise ValueError( "lower_bound and upper_bound must be floats but got {} and {} respectively".format( raw_lower, raw_upper) ) if lower > upper: raise ValueError("Lower ({}) must be smaller than upper ({})".format(lower, upper))
Remove infinity from valid bounds
Remove infinity from valid bounds
Python
apache-2.0
CitrineInformatics/python-citrination-client
from citrination_client.views.descriptors.descriptor import MaterialDescriptor class RealDescriptor(MaterialDescriptor): def __init__(self, key, lower_bound="-Infinity", upper_bound="Infinity", units=""): self.options = dict(lower_bound=lower_bound, upper_bound=upper_bound, units=units) super(RealDescriptor, self).__init__(key, "Real") def validate(self): raw_lower = self.options["lower_bound"] raw_upper = self.options["upper_bound"] try: lower = float(str(raw_lower).replace("Infinity", "inf")) upper = float(str(raw_upper).replace("Infinity", "inf")) except ValueError: raise ValueError( "lower_bound and upper_bound must be floats (or Infinity/-Infinity) but got {} and {} respectively".format( raw_lower, raw_upper) ) if lower > upper: raise ValueError("Lower ({}) must be smaller than upper ({})".format(lower, upper)) Remove infinity from valid bounds
from citrination_client.views.descriptors.descriptor import MaterialDescriptor class RealDescriptor(MaterialDescriptor): def __init__(self, key, lower_bound, upper_bound, units=""): self.options = dict(lower_bound=lower_bound, upper_bound=upper_bound, units=units) super(RealDescriptor, self).__init__(key, "Real") def validate(self): raw_lower = self.options["lower_bound"] raw_upper = self.options["upper_bound"] try: lower = float(str(raw_lower)) upper = float(str(raw_upper)) except ValueError: raise ValueError( "lower_bound and upper_bound must be floats but got {} and {} respectively".format( raw_lower, raw_upper) ) if lower > upper: raise ValueError("Lower ({}) must be smaller than upper ({})".format(lower, upper))
<commit_before>from citrination_client.views.descriptors.descriptor import MaterialDescriptor class RealDescriptor(MaterialDescriptor): def __init__(self, key, lower_bound="-Infinity", upper_bound="Infinity", units=""): self.options = dict(lower_bound=lower_bound, upper_bound=upper_bound, units=units) super(RealDescriptor, self).__init__(key, "Real") def validate(self): raw_lower = self.options["lower_bound"] raw_upper = self.options["upper_bound"] try: lower = float(str(raw_lower).replace("Infinity", "inf")) upper = float(str(raw_upper).replace("Infinity", "inf")) except ValueError: raise ValueError( "lower_bound and upper_bound must be floats (or Infinity/-Infinity) but got {} and {} respectively".format( raw_lower, raw_upper) ) if lower > upper: raise ValueError("Lower ({}) must be smaller than upper ({})".format(lower, upper)) <commit_msg>Remove infinity from valid bounds<commit_after>
from citrination_client.views.descriptors.descriptor import MaterialDescriptor class RealDescriptor(MaterialDescriptor): def __init__(self, key, lower_bound, upper_bound, units=""): self.options = dict(lower_bound=lower_bound, upper_bound=upper_bound, units=units) super(RealDescriptor, self).__init__(key, "Real") def validate(self): raw_lower = self.options["lower_bound"] raw_upper = self.options["upper_bound"] try: lower = float(str(raw_lower)) upper = float(str(raw_upper)) except ValueError: raise ValueError( "lower_bound and upper_bound must be floats but got {} and {} respectively".format( raw_lower, raw_upper) ) if lower > upper: raise ValueError("Lower ({}) must be smaller than upper ({})".format(lower, upper))
from citrination_client.views.descriptors.descriptor import MaterialDescriptor class RealDescriptor(MaterialDescriptor): def __init__(self, key, lower_bound="-Infinity", upper_bound="Infinity", units=""): self.options = dict(lower_bound=lower_bound, upper_bound=upper_bound, units=units) super(RealDescriptor, self).__init__(key, "Real") def validate(self): raw_lower = self.options["lower_bound"] raw_upper = self.options["upper_bound"] try: lower = float(str(raw_lower).replace("Infinity", "inf")) upper = float(str(raw_upper).replace("Infinity", "inf")) except ValueError: raise ValueError( "lower_bound and upper_bound must be floats (or Infinity/-Infinity) but got {} and {} respectively".format( raw_lower, raw_upper) ) if lower > upper: raise ValueError("Lower ({}) must be smaller than upper ({})".format(lower, upper)) Remove infinity from valid boundsfrom citrination_client.views.descriptors.descriptor import MaterialDescriptor class RealDescriptor(MaterialDescriptor): def __init__(self, key, lower_bound, upper_bound, units=""): self.options = dict(lower_bound=lower_bound, upper_bound=upper_bound, units=units) super(RealDescriptor, self).__init__(key, "Real") def validate(self): raw_lower = self.options["lower_bound"] raw_upper = self.options["upper_bound"] try: lower = float(str(raw_lower)) upper = float(str(raw_upper)) except ValueError: raise ValueError( "lower_bound and upper_bound must be floats but got {} and {} respectively".format( raw_lower, raw_upper) ) if lower > upper: raise ValueError("Lower ({}) must be smaller than upper ({})".format(lower, upper))
<commit_before>from citrination_client.views.descriptors.descriptor import MaterialDescriptor class RealDescriptor(MaterialDescriptor): def __init__(self, key, lower_bound="-Infinity", upper_bound="Infinity", units=""): self.options = dict(lower_bound=lower_bound, upper_bound=upper_bound, units=units) super(RealDescriptor, self).__init__(key, "Real") def validate(self): raw_lower = self.options["lower_bound"] raw_upper = self.options["upper_bound"] try: lower = float(str(raw_lower).replace("Infinity", "inf")) upper = float(str(raw_upper).replace("Infinity", "inf")) except ValueError: raise ValueError( "lower_bound and upper_bound must be floats (or Infinity/-Infinity) but got {} and {} respectively".format( raw_lower, raw_upper) ) if lower > upper: raise ValueError("Lower ({}) must be smaller than upper ({})".format(lower, upper)) <commit_msg>Remove infinity from valid bounds<commit_after>from citrination_client.views.descriptors.descriptor import MaterialDescriptor class RealDescriptor(MaterialDescriptor): def __init__(self, key, lower_bound, upper_bound, units=""): self.options = dict(lower_bound=lower_bound, upper_bound=upper_bound, units=units) super(RealDescriptor, self).__init__(key, "Real") def validate(self): raw_lower = self.options["lower_bound"] raw_upper = self.options["upper_bound"] try: lower = float(str(raw_lower)) upper = float(str(raw_upper)) except ValueError: raise ValueError( "lower_bound and upper_bound must be floats but got {} and {} respectively".format( raw_lower, raw_upper) ) if lower > upper: raise ValueError("Lower ({}) must be smaller than upper ({})".format(lower, upper))
50202a70b4d68c628696904d28ffc58f5f4fb54b
sqla_nose.py
sqla_nose.py
#!/usr/bin/env python """ nose runner script. Only use this script if setuptools is not available, i.e. such as on Python 3K. Otherwise consult README.unittests for the recommended methods of running tests. """ try: import sqlalchemy except ImportError: from os import path import sys sys.path.append(path.join(path.dirname(__file__), 'lib')) import nose from sqlalchemy.test.noseplugin import NoseSQLAlchemy from sqlalchemy.util import py3k if __name__ == '__main__': if py3k: # this version breaks verbose output, # but is the only API that nose3 currently supports nose.main(plugins=[NoseSQLAlchemy()]) else: # this is the "correct" API nose.main(addplugins=[NoseSQLAlchemy()])
#!/usr/bin/env python """ nose runner script. Only use this script if setuptools is not available, i.e. such as on Python 3K. Otherwise consult README.unittests for the recommended methods of running tests. """ import sys try: from sqlalchemy_nose.noseplugin import NoseSQLAlchemy except ImportError: from os import path sys.path.append(path.join(path.dirname(path.abspath(__file__)), 'lib')) from sqlalchemy_nose.noseplugin import NoseSQLAlchemy import nose if __name__ == '__main__': py3k = getattr(sys, 'py3kwarning', False) or sys.version_info >= (3, 0) if py3k: # this version breaks verbose output, # but is the only API that nose3 currently supports nose.main(plugins=[NoseSQLAlchemy()]) else: # this is the "correct" API nose.main(addplugins=[NoseSQLAlchemy()])
Update for new nose plugin location.
Update for new nose plugin location.
Python
mit
elelianghh/sqlalchemy,sandan/sqlalchemy,dstufft/sqlalchemy,wfxiang08/sqlalchemy,Cito/sqlalchemy,wujuguang/sqlalchemy,alex/sqlalchemy,olemis/sqlalchemy,276361270/sqlalchemy,brianv0/sqlalchemy,wfxiang08/sqlalchemy,Akrog/sqlalchemy,bdupharm/sqlalchemy,davidjb/sqlalchemy,monetate/sqlalchemy,brianv0/sqlalchemy,hsum/sqlalchemy,alex/sqlalchemy,epa/sqlalchemy,Cito/sqlalchemy,dstufft/sqlalchemy,inspirehep/sqlalchemy,wujuguang/sqlalchemy,halfcrazy/sqlalchemy,j5int/sqlalchemy,sandan/sqlalchemy,Akrog/sqlalchemy,hsum/sqlalchemy,itkovian/sqlalchemy,davidfraser/sqlalchemy,ThiefMaster/sqlalchemy,zzzeek/sqlalchemy,bootandy/sqlalchemy,EvaSDK/sqlalchemy,bdupharm/sqlalchemy,graingert/sqlalchemy,halfcrazy/sqlalchemy,bootandy/sqlalchemy,ThiefMaster/sqlalchemy,monetate/sqlalchemy,Cito/sqlalchemy,j5int/sqlalchemy,epa/sqlalchemy,itkovian/sqlalchemy,davidjb/sqlalchemy,WinterNis/sqlalchemy,alex/sqlalchemy,sqlalchemy/sqlalchemy,olemis/sqlalchemy,elelianghh/sqlalchemy,EvaSDK/sqlalchemy,WinterNis/sqlalchemy,graingert/sqlalchemy,276361270/sqlalchemy,robin900/sqlalchemy,pdufour/sqlalchemy,inspirehep/sqlalchemy,robin900/sqlalchemy,davidfraser/sqlalchemy,pdufour/sqlalchemy
#!/usr/bin/env python """ nose runner script. Only use this script if setuptools is not available, i.e. such as on Python 3K. Otherwise consult README.unittests for the recommended methods of running tests. """ try: import sqlalchemy except ImportError: from os import path import sys sys.path.append(path.join(path.dirname(__file__), 'lib')) import nose from sqlalchemy.test.noseplugin import NoseSQLAlchemy from sqlalchemy.util import py3k if __name__ == '__main__': if py3k: # this version breaks verbose output, # but is the only API that nose3 currently supports nose.main(plugins=[NoseSQLAlchemy()]) else: # this is the "correct" API nose.main(addplugins=[NoseSQLAlchemy()]) Update for new nose plugin location.
#!/usr/bin/env python """ nose runner script. Only use this script if setuptools is not available, i.e. such as on Python 3K. Otherwise consult README.unittests for the recommended methods of running tests. """ import sys try: from sqlalchemy_nose.noseplugin import NoseSQLAlchemy except ImportError: from os import path sys.path.append(path.join(path.dirname(path.abspath(__file__)), 'lib')) from sqlalchemy_nose.noseplugin import NoseSQLAlchemy import nose if __name__ == '__main__': py3k = getattr(sys, 'py3kwarning', False) or sys.version_info >= (3, 0) if py3k: # this version breaks verbose output, # but is the only API that nose3 currently supports nose.main(plugins=[NoseSQLAlchemy()]) else: # this is the "correct" API nose.main(addplugins=[NoseSQLAlchemy()])
<commit_before>#!/usr/bin/env python """ nose runner script. Only use this script if setuptools is not available, i.e. such as on Python 3K. Otherwise consult README.unittests for the recommended methods of running tests. """ try: import sqlalchemy except ImportError: from os import path import sys sys.path.append(path.join(path.dirname(__file__), 'lib')) import nose from sqlalchemy.test.noseplugin import NoseSQLAlchemy from sqlalchemy.util import py3k if __name__ == '__main__': if py3k: # this version breaks verbose output, # but is the only API that nose3 currently supports nose.main(plugins=[NoseSQLAlchemy()]) else: # this is the "correct" API nose.main(addplugins=[NoseSQLAlchemy()]) <commit_msg>Update for new nose plugin location.<commit_after>
#!/usr/bin/env python """ nose runner script. Only use this script if setuptools is not available, i.e. such as on Python 3K. Otherwise consult README.unittests for the recommended methods of running tests. """ import sys try: from sqlalchemy_nose.noseplugin import NoseSQLAlchemy except ImportError: from os import path sys.path.append(path.join(path.dirname(path.abspath(__file__)), 'lib')) from sqlalchemy_nose.noseplugin import NoseSQLAlchemy import nose if __name__ == '__main__': py3k = getattr(sys, 'py3kwarning', False) or sys.version_info >= (3, 0) if py3k: # this version breaks verbose output, # but is the only API that nose3 currently supports nose.main(plugins=[NoseSQLAlchemy()]) else: # this is the "correct" API nose.main(addplugins=[NoseSQLAlchemy()])
#!/usr/bin/env python """ nose runner script. Only use this script if setuptools is not available, i.e. such as on Python 3K. Otherwise consult README.unittests for the recommended methods of running tests. """ try: import sqlalchemy except ImportError: from os import path import sys sys.path.append(path.join(path.dirname(__file__), 'lib')) import nose from sqlalchemy.test.noseplugin import NoseSQLAlchemy from sqlalchemy.util import py3k if __name__ == '__main__': if py3k: # this version breaks verbose output, # but is the only API that nose3 currently supports nose.main(plugins=[NoseSQLAlchemy()]) else: # this is the "correct" API nose.main(addplugins=[NoseSQLAlchemy()]) Update for new nose plugin location.#!/usr/bin/env python """ nose runner script. Only use this script if setuptools is not available, i.e. such as on Python 3K. Otherwise consult README.unittests for the recommended methods of running tests. """ import sys try: from sqlalchemy_nose.noseplugin import NoseSQLAlchemy except ImportError: from os import path sys.path.append(path.join(path.dirname(path.abspath(__file__)), 'lib')) from sqlalchemy_nose.noseplugin import NoseSQLAlchemy import nose if __name__ == '__main__': py3k = getattr(sys, 'py3kwarning', False) or sys.version_info >= (3, 0) if py3k: # this version breaks verbose output, # but is the only API that nose3 currently supports nose.main(plugins=[NoseSQLAlchemy()]) else: # this is the "correct" API nose.main(addplugins=[NoseSQLAlchemy()])
<commit_before>#!/usr/bin/env python """ nose runner script. Only use this script if setuptools is not available, i.e. such as on Python 3K. Otherwise consult README.unittests for the recommended methods of running tests. """ try: import sqlalchemy except ImportError: from os import path import sys sys.path.append(path.join(path.dirname(__file__), 'lib')) import nose from sqlalchemy.test.noseplugin import NoseSQLAlchemy from sqlalchemy.util import py3k if __name__ == '__main__': if py3k: # this version breaks verbose output, # but is the only API that nose3 currently supports nose.main(plugins=[NoseSQLAlchemy()]) else: # this is the "correct" API nose.main(addplugins=[NoseSQLAlchemy()]) <commit_msg>Update for new nose plugin location.<commit_after>#!/usr/bin/env python """ nose runner script. Only use this script if setuptools is not available, i.e. such as on Python 3K. Otherwise consult README.unittests for the recommended methods of running tests. """ import sys try: from sqlalchemy_nose.noseplugin import NoseSQLAlchemy except ImportError: from os import path sys.path.append(path.join(path.dirname(path.abspath(__file__)), 'lib')) from sqlalchemy_nose.noseplugin import NoseSQLAlchemy import nose if __name__ == '__main__': py3k = getattr(sys, 'py3kwarning', False) or sys.version_info >= (3, 0) if py3k: # this version breaks verbose output, # but is the only API that nose3 currently supports nose.main(plugins=[NoseSQLAlchemy()]) else: # this is the "correct" API nose.main(addplugins=[NoseSQLAlchemy()])
f861ca1f315a414f809993170ea95640505c0506
c2corg_api/scripts/migration/sequences.py
c2corg_api/scripts/migration/sequences.py
from sqlalchemy.sql import text from c2corg_api.scripts.migration.migrate_base import MigrateBase class UpdateSequences(MigrateBase): sequences = [ ('guidebook', 'documents_archives', 'id', 'documents_archives_id_seq'), ('guidebook', 'documents', 'document_id', 'documents_document_id_seq'), ('guidebook', 'documents_geometries_archives', 'id', 'documents_geometries_archives_id_seq'), ('guidebook', 'documents_locales_archives', 'id', 'documents_locales_archives_id_seq'), ('guidebook', 'documents_locales', 'id', 'documents_locales_id_seq'), ('guidebook', 'documents_versions', 'id', 'documents_versions_id_seq'), ('guidebook', 'history_metadata', 'id', 'history_metadata_id_seq'), ] def migrate(self): self.start('sequences') stmt = "select setval('{0}.{1}', (select max({2}) from {0}.{3}));" for schema, table, field, sequence in UpdateSequences.sequences: self.session_target.execute(text( stmt.format(schema, sequence, field, table))) self.stop()
from sqlalchemy.sql import text from c2corg_api.scripts.migration.migrate_base import MigrateBase class UpdateSequences(MigrateBase): sequences = [ ('guidebook', 'documents_archives', 'id', 'documents_archives_id_seq'), ('guidebook', 'documents', 'document_id', 'documents_document_id_seq'), ('guidebook', 'documents_geometries_archives', 'id', 'documents_geometries_archives_id_seq'), ('guidebook', 'documents_locales_archives', 'id', 'documents_locales_archives_id_seq'), ('guidebook', 'documents_locales', 'id', 'documents_locales_id_seq'), ('guidebook', 'documents_versions', 'id', 'documents_versions_id_seq'), ('guidebook', 'history_metadata', 'id', 'history_metadata_id_seq'), ('users', 'user', 'id', 'user_id_seq'), ] def migrate(self): self.start('sequences') stmt = "select setval('{0}.{1}', (select max({2}) from {0}.{3}));" for schema, table, field, sequence in UpdateSequences.sequences: self.session_target.execute(text( stmt.format(schema, sequence, field, table))) self.stop()
Add missing user_id_seq in migration script
Add missing user_id_seq in migration script
Python
agpl-3.0
c2corg/v6_api,c2corg/v6_api,c2corg/v6_api
from sqlalchemy.sql import text from c2corg_api.scripts.migration.migrate_base import MigrateBase class UpdateSequences(MigrateBase): sequences = [ ('guidebook', 'documents_archives', 'id', 'documents_archives_id_seq'), ('guidebook', 'documents', 'document_id', 'documents_document_id_seq'), ('guidebook', 'documents_geometries_archives', 'id', 'documents_geometries_archives_id_seq'), ('guidebook', 'documents_locales_archives', 'id', 'documents_locales_archives_id_seq'), ('guidebook', 'documents_locales', 'id', 'documents_locales_id_seq'), ('guidebook', 'documents_versions', 'id', 'documents_versions_id_seq'), ('guidebook', 'history_metadata', 'id', 'history_metadata_id_seq'), ] def migrate(self): self.start('sequences') stmt = "select setval('{0}.{1}', (select max({2}) from {0}.{3}));" for schema, table, field, sequence in UpdateSequences.sequences: self.session_target.execute(text( stmt.format(schema, sequence, field, table))) self.stop() Add missing user_id_seq in migration script
from sqlalchemy.sql import text from c2corg_api.scripts.migration.migrate_base import MigrateBase class UpdateSequences(MigrateBase): sequences = [ ('guidebook', 'documents_archives', 'id', 'documents_archives_id_seq'), ('guidebook', 'documents', 'document_id', 'documents_document_id_seq'), ('guidebook', 'documents_geometries_archives', 'id', 'documents_geometries_archives_id_seq'), ('guidebook', 'documents_locales_archives', 'id', 'documents_locales_archives_id_seq'), ('guidebook', 'documents_locales', 'id', 'documents_locales_id_seq'), ('guidebook', 'documents_versions', 'id', 'documents_versions_id_seq'), ('guidebook', 'history_metadata', 'id', 'history_metadata_id_seq'), ('users', 'user', 'id', 'user_id_seq'), ] def migrate(self): self.start('sequences') stmt = "select setval('{0}.{1}', (select max({2}) from {0}.{3}));" for schema, table, field, sequence in UpdateSequences.sequences: self.session_target.execute(text( stmt.format(schema, sequence, field, table))) self.stop()
<commit_before>from sqlalchemy.sql import text from c2corg_api.scripts.migration.migrate_base import MigrateBase class UpdateSequences(MigrateBase): sequences = [ ('guidebook', 'documents_archives', 'id', 'documents_archives_id_seq'), ('guidebook', 'documents', 'document_id', 'documents_document_id_seq'), ('guidebook', 'documents_geometries_archives', 'id', 'documents_geometries_archives_id_seq'), ('guidebook', 'documents_locales_archives', 'id', 'documents_locales_archives_id_seq'), ('guidebook', 'documents_locales', 'id', 'documents_locales_id_seq'), ('guidebook', 'documents_versions', 'id', 'documents_versions_id_seq'), ('guidebook', 'history_metadata', 'id', 'history_metadata_id_seq'), ] def migrate(self): self.start('sequences') stmt = "select setval('{0}.{1}', (select max({2}) from {0}.{3}));" for schema, table, field, sequence in UpdateSequences.sequences: self.session_target.execute(text( stmt.format(schema, sequence, field, table))) self.stop() <commit_msg>Add missing user_id_seq in migration script<commit_after>
from sqlalchemy.sql import text from c2corg_api.scripts.migration.migrate_base import MigrateBase class UpdateSequences(MigrateBase): sequences = [ ('guidebook', 'documents_archives', 'id', 'documents_archives_id_seq'), ('guidebook', 'documents', 'document_id', 'documents_document_id_seq'), ('guidebook', 'documents_geometries_archives', 'id', 'documents_geometries_archives_id_seq'), ('guidebook', 'documents_locales_archives', 'id', 'documents_locales_archives_id_seq'), ('guidebook', 'documents_locales', 'id', 'documents_locales_id_seq'), ('guidebook', 'documents_versions', 'id', 'documents_versions_id_seq'), ('guidebook', 'history_metadata', 'id', 'history_metadata_id_seq'), ('users', 'user', 'id', 'user_id_seq'), ] def migrate(self): self.start('sequences') stmt = "select setval('{0}.{1}', (select max({2}) from {0}.{3}));" for schema, table, field, sequence in UpdateSequences.sequences: self.session_target.execute(text( stmt.format(schema, sequence, field, table))) self.stop()
from sqlalchemy.sql import text from c2corg_api.scripts.migration.migrate_base import MigrateBase class UpdateSequences(MigrateBase): sequences = [ ('guidebook', 'documents_archives', 'id', 'documents_archives_id_seq'), ('guidebook', 'documents', 'document_id', 'documents_document_id_seq'), ('guidebook', 'documents_geometries_archives', 'id', 'documents_geometries_archives_id_seq'), ('guidebook', 'documents_locales_archives', 'id', 'documents_locales_archives_id_seq'), ('guidebook', 'documents_locales', 'id', 'documents_locales_id_seq'), ('guidebook', 'documents_versions', 'id', 'documents_versions_id_seq'), ('guidebook', 'history_metadata', 'id', 'history_metadata_id_seq'), ] def migrate(self): self.start('sequences') stmt = "select setval('{0}.{1}', (select max({2}) from {0}.{3}));" for schema, table, field, sequence in UpdateSequences.sequences: self.session_target.execute(text( stmt.format(schema, sequence, field, table))) self.stop() Add missing user_id_seq in migration scriptfrom sqlalchemy.sql import text from c2corg_api.scripts.migration.migrate_base import MigrateBase class UpdateSequences(MigrateBase): sequences = [ ('guidebook', 'documents_archives', 'id', 'documents_archives_id_seq'), ('guidebook', 'documents', 'document_id', 'documents_document_id_seq'), ('guidebook', 'documents_geometries_archives', 'id', 'documents_geometries_archives_id_seq'), ('guidebook', 'documents_locales_archives', 'id', 'documents_locales_archives_id_seq'), ('guidebook', 'documents_locales', 'id', 'documents_locales_id_seq'), ('guidebook', 'documents_versions', 'id', 'documents_versions_id_seq'), ('guidebook', 'history_metadata', 'id', 'history_metadata_id_seq'), ('users', 'user', 'id', 'user_id_seq'), ] def migrate(self): self.start('sequences') stmt = "select setval('{0}.{1}', (select max({2}) from {0}.{3}));" for schema, table, field, sequence in UpdateSequences.sequences: self.session_target.execute(text( stmt.format(schema, sequence, field, table))) self.stop()
<commit_before>from sqlalchemy.sql import text from c2corg_api.scripts.migration.migrate_base import MigrateBase class UpdateSequences(MigrateBase): sequences = [ ('guidebook', 'documents_archives', 'id', 'documents_archives_id_seq'), ('guidebook', 'documents', 'document_id', 'documents_document_id_seq'), ('guidebook', 'documents_geometries_archives', 'id', 'documents_geometries_archives_id_seq'), ('guidebook', 'documents_locales_archives', 'id', 'documents_locales_archives_id_seq'), ('guidebook', 'documents_locales', 'id', 'documents_locales_id_seq'), ('guidebook', 'documents_versions', 'id', 'documents_versions_id_seq'), ('guidebook', 'history_metadata', 'id', 'history_metadata_id_seq'), ] def migrate(self): self.start('sequences') stmt = "select setval('{0}.{1}', (select max({2}) from {0}.{3}));" for schema, table, field, sequence in UpdateSequences.sequences: self.session_target.execute(text( stmt.format(schema, sequence, field, table))) self.stop() <commit_msg>Add missing user_id_seq in migration script<commit_after>from sqlalchemy.sql import text from c2corg_api.scripts.migration.migrate_base import MigrateBase class UpdateSequences(MigrateBase): sequences = [ ('guidebook', 'documents_archives', 'id', 'documents_archives_id_seq'), ('guidebook', 'documents', 'document_id', 'documents_document_id_seq'), ('guidebook', 'documents_geometries_archives', 'id', 'documents_geometries_archives_id_seq'), ('guidebook', 'documents_locales_archives', 'id', 'documents_locales_archives_id_seq'), ('guidebook', 'documents_locales', 'id', 'documents_locales_id_seq'), ('guidebook', 'documents_versions', 'id', 'documents_versions_id_seq'), ('guidebook', 'history_metadata', 'id', 'history_metadata_id_seq'), ('users', 'user', 'id', 'user_id_seq'), ] def migrate(self): self.start('sequences') stmt = "select setval('{0}.{1}', (select max({2}) from {0}.{3}));" for schema, table, field, sequence in UpdateSequences.sequences: self.session_target.execute(text( stmt.format(schema, sequence, field, table))) self.stop()
0e0f61edd95bef03a470ae4717d5d4e390011ae3
chatterbot/ext/django_chatterbot/views.py
chatterbot/ext/django_chatterbot/views.py
from django.views.generic import View from django.http import JsonResponse from chatterbot import ChatBot from chatterbot.ext.django_chatterbot import settings class ChatterBotView(View): chatterbot = ChatBot(**settings.CHATTERBOT) def post(self, request, *args, **kwargs): input_statement = request.POST.get('text') response_data = self.chatterbot.get_response(input_statement) return JsonResponse(response_data, status=200) def get(self, request, *args, **kwargs): data = { 'detail': 'You should make a POST request to this endpoint.', 'name': self.chatterbot.name } # Return a method not allowed response return JsonResponse(data, status=405) def patch(self, request, *args, **kwargs): data = { 'detail': 'You should make a POST request to this endpoint.' } # Return a method not allowed response return JsonResponse(data, status=405) def delete(self, request, *args, **kwargs): data = { 'detail': 'You should make a POST request to this endpoint.' } # Return a method not allowed response return JsonResponse(data, status=405)
from django.views.generic import View from django.http import JsonResponse from chatterbot import ChatBot from chatterbot.ext.django_chatterbot import settings import json class ChatterBotView(View): chatterbot = ChatBot(**settings.CHATTERBOT) def _serialize_recent_statements(self): if self.chatterbot.recent_statements.empty(): return [] recent_statements = [] for statement, response in self.chatterbot.recent_statements: recent_statements.append([statement.serialize(), response.serialize()]) return recent_statements def post(self, request, *args, **kwargs): if request.is_ajax(): data = json.loads(request.body) input_statement = data.get('text') else: input_statement = request.POST.get('text') response_data = self.chatterbot.get_response(input_statement) return JsonResponse(response_data, status=200) def get(self, request, *args, **kwargs): data = { 'detail': 'You should make a POST request to this endpoint.', 'name': self.chatterbot.name, 'recent_statements': self._serialize_recent_statements() } # Return a method not allowed response return JsonResponse(data, status=405) def patch(self, request, *args, **kwargs): data = { 'detail': 'You should make a POST request to this endpoint.' } # Return a method not allowed response return JsonResponse(data, status=405) def delete(self, request, *args, **kwargs): data = { 'detail': 'You should make a POST request to this endpoint.' } # Return a method not allowed response return JsonResponse(data, status=405)
Return recent statement data in GET response.
Return recent statement data in GET response.
Python
bsd-3-clause
Reinaesaya/OUIRL-ChatBot,Gustavo6046/ChatterBot,davizucon/ChatterBot,vkosuri/ChatterBot,Reinaesaya/OUIRL-ChatBot,maclogan/VirtualPenPal,gunthercox/ChatterBot
from django.views.generic import View from django.http import JsonResponse from chatterbot import ChatBot from chatterbot.ext.django_chatterbot import settings class ChatterBotView(View): chatterbot = ChatBot(**settings.CHATTERBOT) def post(self, request, *args, **kwargs): input_statement = request.POST.get('text') response_data = self.chatterbot.get_response(input_statement) return JsonResponse(response_data, status=200) def get(self, request, *args, **kwargs): data = { 'detail': 'You should make a POST request to this endpoint.', 'name': self.chatterbot.name } # Return a method not allowed response return JsonResponse(data, status=405) def patch(self, request, *args, **kwargs): data = { 'detail': 'You should make a POST request to this endpoint.' } # Return a method not allowed response return JsonResponse(data, status=405) def delete(self, request, *args, **kwargs): data = { 'detail': 'You should make a POST request to this endpoint.' } # Return a method not allowed response return JsonResponse(data, status=405) Return recent statement data in GET response.
from django.views.generic import View from django.http import JsonResponse from chatterbot import ChatBot from chatterbot.ext.django_chatterbot import settings import json class ChatterBotView(View): chatterbot = ChatBot(**settings.CHATTERBOT) def _serialize_recent_statements(self): if self.chatterbot.recent_statements.empty(): return [] recent_statements = [] for statement, response in self.chatterbot.recent_statements: recent_statements.append([statement.serialize(), response.serialize()]) return recent_statements def post(self, request, *args, **kwargs): if request.is_ajax(): data = json.loads(request.body) input_statement = data.get('text') else: input_statement = request.POST.get('text') response_data = self.chatterbot.get_response(input_statement) return JsonResponse(response_data, status=200) def get(self, request, *args, **kwargs): data = { 'detail': 'You should make a POST request to this endpoint.', 'name': self.chatterbot.name, 'recent_statements': self._serialize_recent_statements() } # Return a method not allowed response return JsonResponse(data, status=405) def patch(self, request, *args, **kwargs): data = { 'detail': 'You should make a POST request to this endpoint.' } # Return a method not allowed response return JsonResponse(data, status=405) def delete(self, request, *args, **kwargs): data = { 'detail': 'You should make a POST request to this endpoint.' } # Return a method not allowed response return JsonResponse(data, status=405)
<commit_before>from django.views.generic import View from django.http import JsonResponse from chatterbot import ChatBot from chatterbot.ext.django_chatterbot import settings class ChatterBotView(View): chatterbot = ChatBot(**settings.CHATTERBOT) def post(self, request, *args, **kwargs): input_statement = request.POST.get('text') response_data = self.chatterbot.get_response(input_statement) return JsonResponse(response_data, status=200) def get(self, request, *args, **kwargs): data = { 'detail': 'You should make a POST request to this endpoint.', 'name': self.chatterbot.name } # Return a method not allowed response return JsonResponse(data, status=405) def patch(self, request, *args, **kwargs): data = { 'detail': 'You should make a POST request to this endpoint.' } # Return a method not allowed response return JsonResponse(data, status=405) def delete(self, request, *args, **kwargs): data = { 'detail': 'You should make a POST request to this endpoint.' } # Return a method not allowed response return JsonResponse(data, status=405) <commit_msg>Return recent statement data in GET response.<commit_after>
from django.views.generic import View from django.http import JsonResponse from chatterbot import ChatBot from chatterbot.ext.django_chatterbot import settings import json class ChatterBotView(View): chatterbot = ChatBot(**settings.CHATTERBOT) def _serialize_recent_statements(self): if self.chatterbot.recent_statements.empty(): return [] recent_statements = [] for statement, response in self.chatterbot.recent_statements: recent_statements.append([statement.serialize(), response.serialize()]) return recent_statements def post(self, request, *args, **kwargs): if request.is_ajax(): data = json.loads(request.body) input_statement = data.get('text') else: input_statement = request.POST.get('text') response_data = self.chatterbot.get_response(input_statement) return JsonResponse(response_data, status=200) def get(self, request, *args, **kwargs): data = { 'detail': 'You should make a POST request to this endpoint.', 'name': self.chatterbot.name, 'recent_statements': self._serialize_recent_statements() } # Return a method not allowed response return JsonResponse(data, status=405) def patch(self, request, *args, **kwargs): data = { 'detail': 'You should make a POST request to this endpoint.' } # Return a method not allowed response return JsonResponse(data, status=405) def delete(self, request, *args, **kwargs): data = { 'detail': 'You should make a POST request to this endpoint.' } # Return a method not allowed response return JsonResponse(data, status=405)
from django.views.generic import View from django.http import JsonResponse from chatterbot import ChatBot from chatterbot.ext.django_chatterbot import settings class ChatterBotView(View): chatterbot = ChatBot(**settings.CHATTERBOT) def post(self, request, *args, **kwargs): input_statement = request.POST.get('text') response_data = self.chatterbot.get_response(input_statement) return JsonResponse(response_data, status=200) def get(self, request, *args, **kwargs): data = { 'detail': 'You should make a POST request to this endpoint.', 'name': self.chatterbot.name } # Return a method not allowed response return JsonResponse(data, status=405) def patch(self, request, *args, **kwargs): data = { 'detail': 'You should make a POST request to this endpoint.' } # Return a method not allowed response return JsonResponse(data, status=405) def delete(self, request, *args, **kwargs): data = { 'detail': 'You should make a POST request to this endpoint.' } # Return a method not allowed response return JsonResponse(data, status=405) Return recent statement data in GET response.from django.views.generic import View from django.http import JsonResponse from chatterbot import ChatBot from chatterbot.ext.django_chatterbot import settings import json class ChatterBotView(View): chatterbot = ChatBot(**settings.CHATTERBOT) def _serialize_recent_statements(self): if self.chatterbot.recent_statements.empty(): return [] recent_statements = [] for statement, response in self.chatterbot.recent_statements: recent_statements.append([statement.serialize(), response.serialize()]) return recent_statements def post(self, request, *args, **kwargs): if request.is_ajax(): data = json.loads(request.body) input_statement = data.get('text') else: input_statement = request.POST.get('text') response_data = self.chatterbot.get_response(input_statement) return JsonResponse(response_data, status=200) def get(self, request, *args, **kwargs): data = { 'detail': 'You should make a POST request to this endpoint.', 'name': self.chatterbot.name, 'recent_statements': self._serialize_recent_statements() } # Return a method not allowed response return JsonResponse(data, status=405) def patch(self, request, *args, **kwargs): data = { 'detail': 'You should make a POST request to this endpoint.' } # Return a method not allowed response return JsonResponse(data, status=405) def delete(self, request, *args, **kwargs): data = { 'detail': 'You should make a POST request to this endpoint.' } # Return a method not allowed response return JsonResponse(data, status=405)
<commit_before>from django.views.generic import View from django.http import JsonResponse from chatterbot import ChatBot from chatterbot.ext.django_chatterbot import settings class ChatterBotView(View): chatterbot = ChatBot(**settings.CHATTERBOT) def post(self, request, *args, **kwargs): input_statement = request.POST.get('text') response_data = self.chatterbot.get_response(input_statement) return JsonResponse(response_data, status=200) def get(self, request, *args, **kwargs): data = { 'detail': 'You should make a POST request to this endpoint.', 'name': self.chatterbot.name } # Return a method not allowed response return JsonResponse(data, status=405) def patch(self, request, *args, **kwargs): data = { 'detail': 'You should make a POST request to this endpoint.' } # Return a method not allowed response return JsonResponse(data, status=405) def delete(self, request, *args, **kwargs): data = { 'detail': 'You should make a POST request to this endpoint.' } # Return a method not allowed response return JsonResponse(data, status=405) <commit_msg>Return recent statement data in GET response.<commit_after>from django.views.generic import View from django.http import JsonResponse from chatterbot import ChatBot from chatterbot.ext.django_chatterbot import settings import json class ChatterBotView(View): chatterbot = ChatBot(**settings.CHATTERBOT) def _serialize_recent_statements(self): if self.chatterbot.recent_statements.empty(): return [] recent_statements = [] for statement, response in self.chatterbot.recent_statements: recent_statements.append([statement.serialize(), response.serialize()]) return recent_statements def post(self, request, *args, **kwargs): if request.is_ajax(): data = json.loads(request.body) input_statement = data.get('text') else: input_statement = request.POST.get('text') response_data = self.chatterbot.get_response(input_statement) return JsonResponse(response_data, status=200) def get(self, request, *args, **kwargs): data = { 'detail': 'You should make a POST request to this endpoint.', 'name': self.chatterbot.name, 'recent_statements': self._serialize_recent_statements() } # Return a method not allowed response return JsonResponse(data, status=405) def patch(self, request, *args, **kwargs): data = { 'detail': 'You should make a POST request to this endpoint.' } # Return a method not allowed response return JsonResponse(data, status=405) def delete(self, request, *args, **kwargs): data = { 'detail': 'You should make a POST request to this endpoint.' } # Return a method not allowed response return JsonResponse(data, status=405)
e739771d18177e482fb9b3e2aa084e28a11680b5
run_tests.py
run_tests.py
import unittest def main(): # pragma: no cover test_suite = unittest.TestLoader().discover('tests/') results = unittest.TextTestRunner(verbosity=1).run(test_suite) if results.errors or results.failures: exit(1) else: exit(0) if __name__ == '__main__': main()
#!/usr/bin/env python3 import unittest def main(): # pragma: no cover test_suite = unittest.TestLoader().discover('tests/') results = unittest.TextTestRunner(verbosity=1).run(test_suite) if results.errors or results.failures: exit(1) else: exit(0) if __name__ == '__main__': main()
Allow run-test.py to be launched by './run-test.py' command.
Allow run-test.py to be launched by './run-test.py' command.
Python
mit
ProjetPP/PPP-QuestionParsing-ML-Standalone,ProjetPP/PPP-QuestionParsing-ML-Standalone
import unittest def main(): # pragma: no cover test_suite = unittest.TestLoader().discover('tests/') results = unittest.TextTestRunner(verbosity=1).run(test_suite) if results.errors or results.failures: exit(1) else: exit(0) if __name__ == '__main__': main() Allow run-test.py to be launched by './run-test.py' command.
#!/usr/bin/env python3 import unittest def main(): # pragma: no cover test_suite = unittest.TestLoader().discover('tests/') results = unittest.TextTestRunner(verbosity=1).run(test_suite) if results.errors or results.failures: exit(1) else: exit(0) if __name__ == '__main__': main()
<commit_before>import unittest def main(): # pragma: no cover test_suite = unittest.TestLoader().discover('tests/') results = unittest.TextTestRunner(verbosity=1).run(test_suite) if results.errors or results.failures: exit(1) else: exit(0) if __name__ == '__main__': main() <commit_msg>Allow run-test.py to be launched by './run-test.py' command.<commit_after>
#!/usr/bin/env python3 import unittest def main(): # pragma: no cover test_suite = unittest.TestLoader().discover('tests/') results = unittest.TextTestRunner(verbosity=1).run(test_suite) if results.errors or results.failures: exit(1) else: exit(0) if __name__ == '__main__': main()
import unittest def main(): # pragma: no cover test_suite = unittest.TestLoader().discover('tests/') results = unittest.TextTestRunner(verbosity=1).run(test_suite) if results.errors or results.failures: exit(1) else: exit(0) if __name__ == '__main__': main() Allow run-test.py to be launched by './run-test.py' command.#!/usr/bin/env python3 import unittest def main(): # pragma: no cover test_suite = unittest.TestLoader().discover('tests/') results = unittest.TextTestRunner(verbosity=1).run(test_suite) if results.errors or results.failures: exit(1) else: exit(0) if __name__ == '__main__': main()
<commit_before>import unittest def main(): # pragma: no cover test_suite = unittest.TestLoader().discover('tests/') results = unittest.TextTestRunner(verbosity=1).run(test_suite) if results.errors or results.failures: exit(1) else: exit(0) if __name__ == '__main__': main() <commit_msg>Allow run-test.py to be launched by './run-test.py' command.<commit_after>#!/usr/bin/env python3 import unittest def main(): # pragma: no cover test_suite = unittest.TestLoader().discover('tests/') results = unittest.TextTestRunner(verbosity=1).run(test_suite) if results.errors or results.failures: exit(1) else: exit(0) if __name__ == '__main__': main()
5f601f742f7a63a1a504e9af3fca61df9deb4707
util.py
util.py
def topological_sort(start_nodes, dependencies): """ Return a topologically sorted list of :param:`start_nodes` and :param:`dependencies`. Nodes are checked on identity, not equality. Raises a ValueError if no topological sort is possible. :param start_nodes: list of nodes of graph with no incoming edges :param dependencies: list of dependency edges; ([dependencies], target), dependencies may be of any sequence or be atomic :returns: topologically sorted nodes :rtype: list of nodes """ seen = set(start_nodes) for deps, target in dependencies: if deps is None: seen.add(target) order = list(seen) old_dependencies = [] while True: dependencies = [(deps, target) for deps, target in dependencies if target not in seen] if not dependencies: return order if old_dependencies == dependencies: raise ValueError("no topological sort possible") for deps, target in dependencies: # test for sequences try: deps = iter(deps) # atomic object except TypeError: deps = [deps] if all(dep in seen for dep in deps): order.append(target) seen.add(target) # copy dependencies to check progress old_dependencies = list(dependencies)
def topological_sort(start_nodes, dependencies): """ Return a topologically sorted list of :param:`start_nodes` and :param:`dependencies`. Nodes are checked on identity, not equality. Raises a ValueError if no topological sort is possible. :param start_nodes: sequence of nodes of graph with no incoming edges :param dependencies: sequence of dependency edges; ([dependencies], target), dependencies may be of any sequence or be atomic, if there is no dependency it must be ``None`` :returns: topologically sorted nodes :rtype: list of nodes """ seen = set(start_nodes) for deps, target in dependencies: if deps is None: seen.add(target) order = list(seen) old_dependencies = [] while True: dependencies = [(deps, target) for deps, target in dependencies if target not in seen] if not dependencies: return order if old_dependencies == dependencies: raise ValueError("no topological sort possible") for deps, target in dependencies: # test for sequences try: deps = iter(deps) # atomic object except TypeError: deps = [deps] if all(dep in seen for dep in deps): order.append(target) seen.add(target) # copy dependencies to check progress old_dependencies = list(dependencies)
Fix documentation of top sort.
Fix documentation of top sort. Change wording from list to sequence and include note about how to specify no dependencies. Signed-off-by: Michael Markert <5eb998b7ac86da375651a4cd767b88c9dad25896@googlemail.com>
Python
mit
fhirschmann/penchy,fhirschmann/penchy
def topological_sort(start_nodes, dependencies): """ Return a topologically sorted list of :param:`start_nodes` and :param:`dependencies`. Nodes are checked on identity, not equality. Raises a ValueError if no topological sort is possible. :param start_nodes: list of nodes of graph with no incoming edges :param dependencies: list of dependency edges; ([dependencies], target), dependencies may be of any sequence or be atomic :returns: topologically sorted nodes :rtype: list of nodes """ seen = set(start_nodes) for deps, target in dependencies: if deps is None: seen.add(target) order = list(seen) old_dependencies = [] while True: dependencies = [(deps, target) for deps, target in dependencies if target not in seen] if not dependencies: return order if old_dependencies == dependencies: raise ValueError("no topological sort possible") for deps, target in dependencies: # test for sequences try: deps = iter(deps) # atomic object except TypeError: deps = [deps] if all(dep in seen for dep in deps): order.append(target) seen.add(target) # copy dependencies to check progress old_dependencies = list(dependencies) Fix documentation of top sort. Change wording from list to sequence and include note about how to specify no dependencies. Signed-off-by: Michael Markert <5eb998b7ac86da375651a4cd767b88c9dad25896@googlemail.com>
def topological_sort(start_nodes, dependencies): """ Return a topologically sorted list of :param:`start_nodes` and :param:`dependencies`. Nodes are checked on identity, not equality. Raises a ValueError if no topological sort is possible. :param start_nodes: sequence of nodes of graph with no incoming edges :param dependencies: sequence of dependency edges; ([dependencies], target), dependencies may be of any sequence or be atomic, if there is no dependency it must be ``None`` :returns: topologically sorted nodes :rtype: list of nodes """ seen = set(start_nodes) for deps, target in dependencies: if deps is None: seen.add(target) order = list(seen) old_dependencies = [] while True: dependencies = [(deps, target) for deps, target in dependencies if target not in seen] if not dependencies: return order if old_dependencies == dependencies: raise ValueError("no topological sort possible") for deps, target in dependencies: # test for sequences try: deps = iter(deps) # atomic object except TypeError: deps = [deps] if all(dep in seen for dep in deps): order.append(target) seen.add(target) # copy dependencies to check progress old_dependencies = list(dependencies)
<commit_before> def topological_sort(start_nodes, dependencies): """ Return a topologically sorted list of :param:`start_nodes` and :param:`dependencies`. Nodes are checked on identity, not equality. Raises a ValueError if no topological sort is possible. :param start_nodes: list of nodes of graph with no incoming edges :param dependencies: list of dependency edges; ([dependencies], target), dependencies may be of any sequence or be atomic :returns: topologically sorted nodes :rtype: list of nodes """ seen = set(start_nodes) for deps, target in dependencies: if deps is None: seen.add(target) order = list(seen) old_dependencies = [] while True: dependencies = [(deps, target) for deps, target in dependencies if target not in seen] if not dependencies: return order if old_dependencies == dependencies: raise ValueError("no topological sort possible") for deps, target in dependencies: # test for sequences try: deps = iter(deps) # atomic object except TypeError: deps = [deps] if all(dep in seen for dep in deps): order.append(target) seen.add(target) # copy dependencies to check progress old_dependencies = list(dependencies) <commit_msg>Fix documentation of top sort. Change wording from list to sequence and include note about how to specify no dependencies. Signed-off-by: Michael Markert <5eb998b7ac86da375651a4cd767b88c9dad25896@googlemail.com><commit_after>
def topological_sort(start_nodes, dependencies): """ Return a topologically sorted list of :param:`start_nodes` and :param:`dependencies`. Nodes are checked on identity, not equality. Raises a ValueError if no topological sort is possible. :param start_nodes: sequence of nodes of graph with no incoming edges :param dependencies: sequence of dependency edges; ([dependencies], target), dependencies may be of any sequence or be atomic, if there is no dependency it must be ``None`` :returns: topologically sorted nodes :rtype: list of nodes """ seen = set(start_nodes) for deps, target in dependencies: if deps is None: seen.add(target) order = list(seen) old_dependencies = [] while True: dependencies = [(deps, target) for deps, target in dependencies if target not in seen] if not dependencies: return order if old_dependencies == dependencies: raise ValueError("no topological sort possible") for deps, target in dependencies: # test for sequences try: deps = iter(deps) # atomic object except TypeError: deps = [deps] if all(dep in seen for dep in deps): order.append(target) seen.add(target) # copy dependencies to check progress old_dependencies = list(dependencies)
def topological_sort(start_nodes, dependencies): """ Return a topologically sorted list of :param:`start_nodes` and :param:`dependencies`. Nodes are checked on identity, not equality. Raises a ValueError if no topological sort is possible. :param start_nodes: list of nodes of graph with no incoming edges :param dependencies: list of dependency edges; ([dependencies], target), dependencies may be of any sequence or be atomic :returns: topologically sorted nodes :rtype: list of nodes """ seen = set(start_nodes) for deps, target in dependencies: if deps is None: seen.add(target) order = list(seen) old_dependencies = [] while True: dependencies = [(deps, target) for deps, target in dependencies if target not in seen] if not dependencies: return order if old_dependencies == dependencies: raise ValueError("no topological sort possible") for deps, target in dependencies: # test for sequences try: deps = iter(deps) # atomic object except TypeError: deps = [deps] if all(dep in seen for dep in deps): order.append(target) seen.add(target) # copy dependencies to check progress old_dependencies = list(dependencies) Fix documentation of top sort. Change wording from list to sequence and include note about how to specify no dependencies. Signed-off-by: Michael Markert <5eb998b7ac86da375651a4cd767b88c9dad25896@googlemail.com> def topological_sort(start_nodes, dependencies): """ Return a topologically sorted list of :param:`start_nodes` and :param:`dependencies`. Nodes are checked on identity, not equality. Raises a ValueError if no topological sort is possible. :param start_nodes: sequence of nodes of graph with no incoming edges :param dependencies: sequence of dependency edges; ([dependencies], target), dependencies may be of any sequence or be atomic, if there is no dependency it must be ``None`` :returns: topologically sorted nodes :rtype: list of nodes """ seen = set(start_nodes) for deps, target in dependencies: if deps is None: seen.add(target) order = list(seen) old_dependencies = [] while True: dependencies = [(deps, target) for deps, target in dependencies if target not in seen] if not dependencies: return order if old_dependencies == dependencies: raise ValueError("no topological sort possible") for deps, target in dependencies: # test for sequences try: deps = iter(deps) # atomic object except TypeError: deps = [deps] if all(dep in seen for dep in deps): order.append(target) seen.add(target) # copy dependencies to check progress old_dependencies = list(dependencies)
<commit_before> def topological_sort(start_nodes, dependencies): """ Return a topologically sorted list of :param:`start_nodes` and :param:`dependencies`. Nodes are checked on identity, not equality. Raises a ValueError if no topological sort is possible. :param start_nodes: list of nodes of graph with no incoming edges :param dependencies: list of dependency edges; ([dependencies], target), dependencies may be of any sequence or be atomic :returns: topologically sorted nodes :rtype: list of nodes """ seen = set(start_nodes) for deps, target in dependencies: if deps is None: seen.add(target) order = list(seen) old_dependencies = [] while True: dependencies = [(deps, target) for deps, target in dependencies if target not in seen] if not dependencies: return order if old_dependencies == dependencies: raise ValueError("no topological sort possible") for deps, target in dependencies: # test for sequences try: deps = iter(deps) # atomic object except TypeError: deps = [deps] if all(dep in seen for dep in deps): order.append(target) seen.add(target) # copy dependencies to check progress old_dependencies = list(dependencies) <commit_msg>Fix documentation of top sort. Change wording from list to sequence and include note about how to specify no dependencies. Signed-off-by: Michael Markert <5eb998b7ac86da375651a4cd767b88c9dad25896@googlemail.com><commit_after> def topological_sort(start_nodes, dependencies): """ Return a topologically sorted list of :param:`start_nodes` and :param:`dependencies`. Nodes are checked on identity, not equality. Raises a ValueError if no topological sort is possible. :param start_nodes: sequence of nodes of graph with no incoming edges :param dependencies: sequence of dependency edges; ([dependencies], target), dependencies may be of any sequence or be atomic, if there is no dependency it must be ``None`` :returns: topologically sorted nodes :rtype: list of nodes """ seen = set(start_nodes) for deps, target in dependencies: if deps is None: seen.add(target) order = list(seen) old_dependencies = [] while True: dependencies = [(deps, target) for deps, target in dependencies if target not in seen] if not dependencies: return order if old_dependencies == dependencies: raise ValueError("no topological sort possible") for deps, target in dependencies: # test for sequences try: deps = iter(deps) # atomic object except TypeError: deps = [deps] if all(dep in seen for dep in deps): order.append(target) seen.add(target) # copy dependencies to check progress old_dependencies = list(dependencies)
b444113a3bb71f30cfd61043e026674cc09f5a94
app/__init__.py
app/__init__.py
from flask import Flask from flask_login import LoginManager from flask_misaka import Misaka from flask_moment import Moment from flask_security import Security, SQLAlchemyUserDatastore from flask_sqlalchemy import SQLAlchemy from flask_whooshalchemy import whoosh_index from config import config db = SQLAlchemy() lm = LoginManager() markdown = Misaka() moment = Moment() security = Security() from app.models import Post, User, Role user_datastore = SQLAlchemyUserDatastore(db, User, Role) def create_app(config_name): """ Initializes a Flask app. Args: config_name: The configuration object to use. Returns: The Flask app object. """ app = Flask(__name__) app.config.from_object(config[config_name]) db.init_app(app) lm.init_app(app) markdown.init_app(app) moment.init_app(app) security.init_app(app, user_datastore) whoosh_index(app, Post) from app.main.views import main from app.admin.views import admin app.register_blueprint(main) app.register_blueprint(admin, url_prefix='/admin') return app
from flask import Flask from flask_login import LoginManager from flask_misaka import Misaka from flask_moment import Moment from flask_security import Security, SQLAlchemyUserDatastore from flask_sqlalchemy import SQLAlchemy from flask_whooshalchemy import whoosh_index from config import config db = SQLAlchemy() lm = LoginManager() markdown = Misaka() moment = Moment() security = Security() from app.models import Post, User, Role user_datastore = SQLAlchemyUserDatastore(db, User, Role) def create_app(config_name): """ Initializes a Flask app. Args: config_name: The configuration object to use. Returns: The Flask app object. """ app = Flask(__name__) app.config.from_object(config[config_name]) db.init_app(app) lm.init_app(app) markdown.init_app(app) moment.init_app(app) security.init_app(app, user_datastore) whoosh_index(app, Post) from app.utils.settings import AppSettings with app.app_context(): app.config['SETTINGS'] = AppSettings() @app.context_processor def inject_settings(): return {'settings': app.config['SETTINGS']} from app.main.views import main from app.admin.views import admin app.register_blueprint(main) app.register_blueprint(admin, url_prefix='/admin') return app
Add AppSettings dict to app config and inject it
Add AppSettings dict to app config and inject it
Python
mit
Encrylize/flask-blogger,Encrylize/flask-blogger,Encrylize/flask-blogger
from flask import Flask from flask_login import LoginManager from flask_misaka import Misaka from flask_moment import Moment from flask_security import Security, SQLAlchemyUserDatastore from flask_sqlalchemy import SQLAlchemy from flask_whooshalchemy import whoosh_index from config import config db = SQLAlchemy() lm = LoginManager() markdown = Misaka() moment = Moment() security = Security() from app.models import Post, User, Role user_datastore = SQLAlchemyUserDatastore(db, User, Role) def create_app(config_name): """ Initializes a Flask app. Args: config_name: The configuration object to use. Returns: The Flask app object. """ app = Flask(__name__) app.config.from_object(config[config_name]) db.init_app(app) lm.init_app(app) markdown.init_app(app) moment.init_app(app) security.init_app(app, user_datastore) whoosh_index(app, Post) from app.main.views import main from app.admin.views import admin app.register_blueprint(main) app.register_blueprint(admin, url_prefix='/admin') return app Add AppSettings dict to app config and inject it
from flask import Flask from flask_login import LoginManager from flask_misaka import Misaka from flask_moment import Moment from flask_security import Security, SQLAlchemyUserDatastore from flask_sqlalchemy import SQLAlchemy from flask_whooshalchemy import whoosh_index from config import config db = SQLAlchemy() lm = LoginManager() markdown = Misaka() moment = Moment() security = Security() from app.models import Post, User, Role user_datastore = SQLAlchemyUserDatastore(db, User, Role) def create_app(config_name): """ Initializes a Flask app. Args: config_name: The configuration object to use. Returns: The Flask app object. """ app = Flask(__name__) app.config.from_object(config[config_name]) db.init_app(app) lm.init_app(app) markdown.init_app(app) moment.init_app(app) security.init_app(app, user_datastore) whoosh_index(app, Post) from app.utils.settings import AppSettings with app.app_context(): app.config['SETTINGS'] = AppSettings() @app.context_processor def inject_settings(): return {'settings': app.config['SETTINGS']} from app.main.views import main from app.admin.views import admin app.register_blueprint(main) app.register_blueprint(admin, url_prefix='/admin') return app
<commit_before>from flask import Flask from flask_login import LoginManager from flask_misaka import Misaka from flask_moment import Moment from flask_security import Security, SQLAlchemyUserDatastore from flask_sqlalchemy import SQLAlchemy from flask_whooshalchemy import whoosh_index from config import config db = SQLAlchemy() lm = LoginManager() markdown = Misaka() moment = Moment() security = Security() from app.models import Post, User, Role user_datastore = SQLAlchemyUserDatastore(db, User, Role) def create_app(config_name): """ Initializes a Flask app. Args: config_name: The configuration object to use. Returns: The Flask app object. """ app = Flask(__name__) app.config.from_object(config[config_name]) db.init_app(app) lm.init_app(app) markdown.init_app(app) moment.init_app(app) security.init_app(app, user_datastore) whoosh_index(app, Post) from app.main.views import main from app.admin.views import admin app.register_blueprint(main) app.register_blueprint(admin, url_prefix='/admin') return app <commit_msg>Add AppSettings dict to app config and inject it<commit_after>
from flask import Flask from flask_login import LoginManager from flask_misaka import Misaka from flask_moment import Moment from flask_security import Security, SQLAlchemyUserDatastore from flask_sqlalchemy import SQLAlchemy from flask_whooshalchemy import whoosh_index from config import config db = SQLAlchemy() lm = LoginManager() markdown = Misaka() moment = Moment() security = Security() from app.models import Post, User, Role user_datastore = SQLAlchemyUserDatastore(db, User, Role) def create_app(config_name): """ Initializes a Flask app. Args: config_name: The configuration object to use. Returns: The Flask app object. """ app = Flask(__name__) app.config.from_object(config[config_name]) db.init_app(app) lm.init_app(app) markdown.init_app(app) moment.init_app(app) security.init_app(app, user_datastore) whoosh_index(app, Post) from app.utils.settings import AppSettings with app.app_context(): app.config['SETTINGS'] = AppSettings() @app.context_processor def inject_settings(): return {'settings': app.config['SETTINGS']} from app.main.views import main from app.admin.views import admin app.register_blueprint(main) app.register_blueprint(admin, url_prefix='/admin') return app
from flask import Flask from flask_login import LoginManager from flask_misaka import Misaka from flask_moment import Moment from flask_security import Security, SQLAlchemyUserDatastore from flask_sqlalchemy import SQLAlchemy from flask_whooshalchemy import whoosh_index from config import config db = SQLAlchemy() lm = LoginManager() markdown = Misaka() moment = Moment() security = Security() from app.models import Post, User, Role user_datastore = SQLAlchemyUserDatastore(db, User, Role) def create_app(config_name): """ Initializes a Flask app. Args: config_name: The configuration object to use. Returns: The Flask app object. """ app = Flask(__name__) app.config.from_object(config[config_name]) db.init_app(app) lm.init_app(app) markdown.init_app(app) moment.init_app(app) security.init_app(app, user_datastore) whoosh_index(app, Post) from app.main.views import main from app.admin.views import admin app.register_blueprint(main) app.register_blueprint(admin, url_prefix='/admin') return app Add AppSettings dict to app config and inject itfrom flask import Flask from flask_login import LoginManager from flask_misaka import Misaka from flask_moment import Moment from flask_security import Security, SQLAlchemyUserDatastore from flask_sqlalchemy import SQLAlchemy from flask_whooshalchemy import whoosh_index from config import config db = SQLAlchemy() lm = LoginManager() markdown = Misaka() moment = Moment() security = Security() from app.models import Post, User, Role user_datastore = SQLAlchemyUserDatastore(db, User, Role) def create_app(config_name): """ Initializes a Flask app. Args: config_name: The configuration object to use. Returns: The Flask app object. """ app = Flask(__name__) app.config.from_object(config[config_name]) db.init_app(app) lm.init_app(app) markdown.init_app(app) moment.init_app(app) security.init_app(app, user_datastore) whoosh_index(app, Post) from app.utils.settings import AppSettings with app.app_context(): app.config['SETTINGS'] = AppSettings() @app.context_processor def inject_settings(): return {'settings': app.config['SETTINGS']} from app.main.views import main from app.admin.views import admin app.register_blueprint(main) app.register_blueprint(admin, url_prefix='/admin') return app
<commit_before>from flask import Flask from flask_login import LoginManager from flask_misaka import Misaka from flask_moment import Moment from flask_security import Security, SQLAlchemyUserDatastore from flask_sqlalchemy import SQLAlchemy from flask_whooshalchemy import whoosh_index from config import config db = SQLAlchemy() lm = LoginManager() markdown = Misaka() moment = Moment() security = Security() from app.models import Post, User, Role user_datastore = SQLAlchemyUserDatastore(db, User, Role) def create_app(config_name): """ Initializes a Flask app. Args: config_name: The configuration object to use. Returns: The Flask app object. """ app = Flask(__name__) app.config.from_object(config[config_name]) db.init_app(app) lm.init_app(app) markdown.init_app(app) moment.init_app(app) security.init_app(app, user_datastore) whoosh_index(app, Post) from app.main.views import main from app.admin.views import admin app.register_blueprint(main) app.register_blueprint(admin, url_prefix='/admin') return app <commit_msg>Add AppSettings dict to app config and inject it<commit_after>from flask import Flask from flask_login import LoginManager from flask_misaka import Misaka from flask_moment import Moment from flask_security import Security, SQLAlchemyUserDatastore from flask_sqlalchemy import SQLAlchemy from flask_whooshalchemy import whoosh_index from config import config db = SQLAlchemy() lm = LoginManager() markdown = Misaka() moment = Moment() security = Security() from app.models import Post, User, Role user_datastore = SQLAlchemyUserDatastore(db, User, Role) def create_app(config_name): """ Initializes a Flask app. Args: config_name: The configuration object to use. Returns: The Flask app object. """ app = Flask(__name__) app.config.from_object(config[config_name]) db.init_app(app) lm.init_app(app) markdown.init_app(app) moment.init_app(app) security.init_app(app, user_datastore) whoosh_index(app, Post) from app.utils.settings import AppSettings with app.app_context(): app.config['SETTINGS'] = AppSettings() @app.context_processor def inject_settings(): return {'settings': app.config['SETTINGS']} from app.main.views import main from app.admin.views import admin app.register_blueprint(main) app.register_blueprint(admin, url_prefix='/admin') return app
849a4e5daf2eb845213ea76179d7a8143148f39a
lib/mixins.py
lib/mixins.py
class Countable(object): @classmethod def count(cls, options={}): return int(cls.get("count", **options)) class Metafields(object): def metafields(self): return Metafield.find(resource=self.__class__.plural, resource_id=self.id) def add_metafield(self, metafield): if self.is_new(): raise ValueError("You can only add metafields to a resource that has been saved") metafield._prefix_options = dict(resource=self.__class__.plural, resource_id=self.id) metafield.save() return metafield class Events(object): def events(self): return Event.find(resource=self.__class__.plural, resource_id=self.id)
class Countable(object): @classmethod def count(cls, _options=None, **kwargs): if _options is None: _options = kwargs return int(cls.get("count", **_options)) class Metafields(object): def metafields(self): return Metafield.find(resource=self.__class__.plural, resource_id=self.id) def add_metafield(self, metafield): if self.is_new(): raise ValueError("You can only add metafields to a resource that has been saved") metafield._prefix_options = dict(resource=self.__class__.plural, resource_id=self.id) metafield.save() return metafield class Events(object): def events(self): return Event.find(resource=self.__class__.plural, resource_id=self.id)
Allow count method to be used the same way as find.
Allow count method to be used the same way as find.
Python
mit
varesa/shopify_python_api,metric-collective/shopify_python_api,gavinballard/shopify_python_api,asiviero/shopify_python_api,ifnull/shopify_python_api,Shopify/shopify_python_api,SmileyJames/shopify_python_api
class Countable(object): @classmethod def count(cls, options={}): return int(cls.get("count", **options)) class Metafields(object): def metafields(self): return Metafield.find(resource=self.__class__.plural, resource_id=self.id) def add_metafield(self, metafield): if self.is_new(): raise ValueError("You can only add metafields to a resource that has been saved") metafield._prefix_options = dict(resource=self.__class__.plural, resource_id=self.id) metafield.save() return metafield class Events(object): def events(self): return Event.find(resource=self.__class__.plural, resource_id=self.id) Allow count method to be used the same way as find.
class Countable(object): @classmethod def count(cls, _options=None, **kwargs): if _options is None: _options = kwargs return int(cls.get("count", **_options)) class Metafields(object): def metafields(self): return Metafield.find(resource=self.__class__.plural, resource_id=self.id) def add_metafield(self, metafield): if self.is_new(): raise ValueError("You can only add metafields to a resource that has been saved") metafield._prefix_options = dict(resource=self.__class__.plural, resource_id=self.id) metafield.save() return metafield class Events(object): def events(self): return Event.find(resource=self.__class__.plural, resource_id=self.id)
<commit_before>class Countable(object): @classmethod def count(cls, options={}): return int(cls.get("count", **options)) class Metafields(object): def metafields(self): return Metafield.find(resource=self.__class__.plural, resource_id=self.id) def add_metafield(self, metafield): if self.is_new(): raise ValueError("You can only add metafields to a resource that has been saved") metafield._prefix_options = dict(resource=self.__class__.plural, resource_id=self.id) metafield.save() return metafield class Events(object): def events(self): return Event.find(resource=self.__class__.plural, resource_id=self.id) <commit_msg>Allow count method to be used the same way as find.<commit_after>
class Countable(object): @classmethod def count(cls, _options=None, **kwargs): if _options is None: _options = kwargs return int(cls.get("count", **_options)) class Metafields(object): def metafields(self): return Metafield.find(resource=self.__class__.plural, resource_id=self.id) def add_metafield(self, metafield): if self.is_new(): raise ValueError("You can only add metafields to a resource that has been saved") metafield._prefix_options = dict(resource=self.__class__.plural, resource_id=self.id) metafield.save() return metafield class Events(object): def events(self): return Event.find(resource=self.__class__.plural, resource_id=self.id)
class Countable(object): @classmethod def count(cls, options={}): return int(cls.get("count", **options)) class Metafields(object): def metafields(self): return Metafield.find(resource=self.__class__.plural, resource_id=self.id) def add_metafield(self, metafield): if self.is_new(): raise ValueError("You can only add metafields to a resource that has been saved") metafield._prefix_options = dict(resource=self.__class__.plural, resource_id=self.id) metafield.save() return metafield class Events(object): def events(self): return Event.find(resource=self.__class__.plural, resource_id=self.id) Allow count method to be used the same way as find.class Countable(object): @classmethod def count(cls, _options=None, **kwargs): if _options is None: _options = kwargs return int(cls.get("count", **_options)) class Metafields(object): def metafields(self): return Metafield.find(resource=self.__class__.plural, resource_id=self.id) def add_metafield(self, metafield): if self.is_new(): raise ValueError("You can only add metafields to a resource that has been saved") metafield._prefix_options = dict(resource=self.__class__.plural, resource_id=self.id) metafield.save() return metafield class Events(object): def events(self): return Event.find(resource=self.__class__.plural, resource_id=self.id)
<commit_before>class Countable(object): @classmethod def count(cls, options={}): return int(cls.get("count", **options)) class Metafields(object): def metafields(self): return Metafield.find(resource=self.__class__.plural, resource_id=self.id) def add_metafield(self, metafield): if self.is_new(): raise ValueError("You can only add metafields to a resource that has been saved") metafield._prefix_options = dict(resource=self.__class__.plural, resource_id=self.id) metafield.save() return metafield class Events(object): def events(self): return Event.find(resource=self.__class__.plural, resource_id=self.id) <commit_msg>Allow count method to be used the same way as find.<commit_after>class Countable(object): @classmethod def count(cls, _options=None, **kwargs): if _options is None: _options = kwargs return int(cls.get("count", **_options)) class Metafields(object): def metafields(self): return Metafield.find(resource=self.__class__.plural, resource_id=self.id) def add_metafield(self, metafield): if self.is_new(): raise ValueError("You can only add metafields to a resource that has been saved") metafield._prefix_options = dict(resource=self.__class__.plural, resource_id=self.id) metafield.save() return metafield class Events(object): def events(self): return Event.find(resource=self.__class__.plural, resource_id=self.id)
1efdb6034fbf04cd41c4575b09b2e9da1a08eddc
redash/cli/database.py
redash/cli/database.py
from flask.cli import AppGroup from flask_migrate import stamp manager = AppGroup(help="Manage the database (create/drop tables).") @manager.command() def create_tables(): """Create the database tables.""" from redash.models import db db.create_all() # Need to mark current DB as up to date stamp() @manager.command() def drop_tables(): """Drop the database tables.""" from redash.models import db db.drop_all()
import time from flask.cli import AppGroup from flask_migrate import stamp from sqlalchemy.exc import DatabaseError manager = AppGroup(help="Manage the database (create/drop tables).") def _wait_for_db_connection(db): retried = False while not retried: try: db.engine.execute('SELECT 1;') return except DatabaseError: time.sleep(30) retried = True @manager.command() def create_tables(): """Create the database tables.""" from redash.models import db _wait_for_db_connection(db) db.create_all() # Need to mark current DB as up to date stamp() @manager.command() def drop_tables(): """Drop the database tables.""" from redash.models import db _wait_for_db_connection(db) db.drop_all()
Fix connection error when you run "create_tables"
Fix connection error when you run "create_tables"
Python
bsd-2-clause
chriszs/redash,denisov-vlad/redash,denisov-vlad/redash,denisov-vlad/redash,moritz9/redash,44px/redash,alexanderlz/redash,getredash/redash,alexanderlz/redash,moritz9/redash,alexanderlz/redash,44px/redash,moritz9/redash,moritz9/redash,44px/redash,denisov-vlad/redash,chriszs/redash,getredash/redash,getredash/redash,44px/redash,getredash/redash,denisov-vlad/redash,getredash/redash,chriszs/redash,alexanderlz/redash,chriszs/redash
from flask.cli import AppGroup from flask_migrate import stamp manager = AppGroup(help="Manage the database (create/drop tables).") @manager.command() def create_tables(): """Create the database tables.""" from redash.models import db db.create_all() # Need to mark current DB as up to date stamp() @manager.command() def drop_tables(): """Drop the database tables.""" from redash.models import db db.drop_all() Fix connection error when you run "create_tables"
import time from flask.cli import AppGroup from flask_migrate import stamp from sqlalchemy.exc import DatabaseError manager = AppGroup(help="Manage the database (create/drop tables).") def _wait_for_db_connection(db): retried = False while not retried: try: db.engine.execute('SELECT 1;') return except DatabaseError: time.sleep(30) retried = True @manager.command() def create_tables(): """Create the database tables.""" from redash.models import db _wait_for_db_connection(db) db.create_all() # Need to mark current DB as up to date stamp() @manager.command() def drop_tables(): """Drop the database tables.""" from redash.models import db _wait_for_db_connection(db) db.drop_all()
<commit_before>from flask.cli import AppGroup from flask_migrate import stamp manager = AppGroup(help="Manage the database (create/drop tables).") @manager.command() def create_tables(): """Create the database tables.""" from redash.models import db db.create_all() # Need to mark current DB as up to date stamp() @manager.command() def drop_tables(): """Drop the database tables.""" from redash.models import db db.drop_all() <commit_msg>Fix connection error when you run "create_tables"<commit_after>
import time from flask.cli import AppGroup from flask_migrate import stamp from sqlalchemy.exc import DatabaseError manager = AppGroup(help="Manage the database (create/drop tables).") def _wait_for_db_connection(db): retried = False while not retried: try: db.engine.execute('SELECT 1;') return except DatabaseError: time.sleep(30) retried = True @manager.command() def create_tables(): """Create the database tables.""" from redash.models import db _wait_for_db_connection(db) db.create_all() # Need to mark current DB as up to date stamp() @manager.command() def drop_tables(): """Drop the database tables.""" from redash.models import db _wait_for_db_connection(db) db.drop_all()
from flask.cli import AppGroup from flask_migrate import stamp manager = AppGroup(help="Manage the database (create/drop tables).") @manager.command() def create_tables(): """Create the database tables.""" from redash.models import db db.create_all() # Need to mark current DB as up to date stamp() @manager.command() def drop_tables(): """Drop the database tables.""" from redash.models import db db.drop_all() Fix connection error when you run "create_tables"import time from flask.cli import AppGroup from flask_migrate import stamp from sqlalchemy.exc import DatabaseError manager = AppGroup(help="Manage the database (create/drop tables).") def _wait_for_db_connection(db): retried = False while not retried: try: db.engine.execute('SELECT 1;') return except DatabaseError: time.sleep(30) retried = True @manager.command() def create_tables(): """Create the database tables.""" from redash.models import db _wait_for_db_connection(db) db.create_all() # Need to mark current DB as up to date stamp() @manager.command() def drop_tables(): """Drop the database tables.""" from redash.models import db _wait_for_db_connection(db) db.drop_all()
<commit_before>from flask.cli import AppGroup from flask_migrate import stamp manager = AppGroup(help="Manage the database (create/drop tables).") @manager.command() def create_tables(): """Create the database tables.""" from redash.models import db db.create_all() # Need to mark current DB as up to date stamp() @manager.command() def drop_tables(): """Drop the database tables.""" from redash.models import db db.drop_all() <commit_msg>Fix connection error when you run "create_tables"<commit_after>import time from flask.cli import AppGroup from flask_migrate import stamp from sqlalchemy.exc import DatabaseError manager = AppGroup(help="Manage the database (create/drop tables).") def _wait_for_db_connection(db): retried = False while not retried: try: db.engine.execute('SELECT 1;') return except DatabaseError: time.sleep(30) retried = True @manager.command() def create_tables(): """Create the database tables.""" from redash.models import db _wait_for_db_connection(db) db.create_all() # Need to mark current DB as up to date stamp() @manager.command() def drop_tables(): """Drop the database tables.""" from redash.models import db _wait_for_db_connection(db) db.drop_all()
48ded0ea4def623884d5709768c87e19de279479
modules/mod_nsfw.py
modules/mod_nsfw.py
from modules.module_base import ModuleBase from tools.nsfw import Nsfw class ModuleNSFW(ModuleBase): def __init__(self, bot): ModuleBase.__init__(self, bot) self.name = "NSFW" self.nsfw = Nsfw(self.logger) def notify_command(self, message_id, from_attr, date, chat, commandName, commandStr): if commandName == "bonjour": if commandStr == "": text = "Bonjours : %s" % ", ".join(self.nsfw.bonjours) self.bot.sendMessage(text, chat["id"]) return parserResult = self.nsfw.parse(commandStr) for key in parserResult.unknown(): self.bot.sendMessage("bonjour %s not found" % key, chat["id"]) for key in parserResult.known(): result = self.nsfw.image(key, parserResult.mode(), "out.jpg") if result.ok(): self.bot.sendPhoto(chat["id"], "out.jpg", result.message()) else: self.bot.sendMessage(result.message(), chat["id"]) def get_commands(self): return [ ("bonjour", "Bonjour. Keywords: <%s> <last/random>" % "/".join(self.nsfw.bonjours)), ]
from modules.module_base import ModuleBase from tools.nsfw import Nsfw class ModuleNSFW(ModuleBase): def __init__(self, bot): ModuleBase.__init__(self, bot) self.name = "NSFW" self.nsfw = Nsfw(self.logger) def notify_command(self, message_id, from_attr, date, chat, commandName, commandStr): if commandName == "bonjour": if commandStr == "": text = "Bonjours : %s" % ", ".join(self.nsfw.bonjours) self.bot.sendMessage(text, chat["id"]) return parserResult = self.nsfw.parse(commandStr) for key in parserResult.unknown(): self.bot.sendMessage("bonjour %s not found" % key, chat["id"]) for key in parserResult.known(): result = self.nsfw.image(key, parserResult.mode(), "out.jpg") if result.ok(): self.bot.sendPhoto(chat["id"], "out.jpg", result.message()) break; else: self.bot.sendMessage(result.message(), chat["id"]) def get_commands(self): return [ ("bonjour", "Bonjour. Keywords: <%s> <last/random>" % "/".join(self.nsfw.bonjours)), ]
Fix bot infinte image loop
Fix bot infinte image loop
Python
mit
mamaddeveloper/teleadmin,mamaddeveloper/telegrambot,mamaddeveloper/teleadmin,mamaddeveloper/telegrambot
from modules.module_base import ModuleBase from tools.nsfw import Nsfw class ModuleNSFW(ModuleBase): def __init__(self, bot): ModuleBase.__init__(self, bot) self.name = "NSFW" self.nsfw = Nsfw(self.logger) def notify_command(self, message_id, from_attr, date, chat, commandName, commandStr): if commandName == "bonjour": if commandStr == "": text = "Bonjours : %s" % ", ".join(self.nsfw.bonjours) self.bot.sendMessage(text, chat["id"]) return parserResult = self.nsfw.parse(commandStr) for key in parserResult.unknown(): self.bot.sendMessage("bonjour %s not found" % key, chat["id"]) for key in parserResult.known(): result = self.nsfw.image(key, parserResult.mode(), "out.jpg") if result.ok(): self.bot.sendPhoto(chat["id"], "out.jpg", result.message()) else: self.bot.sendMessage(result.message(), chat["id"]) def get_commands(self): return [ ("bonjour", "Bonjour. Keywords: <%s> <last/random>" % "/".join(self.nsfw.bonjours)), ] Fix bot infinte image loop
from modules.module_base import ModuleBase from tools.nsfw import Nsfw class ModuleNSFW(ModuleBase): def __init__(self, bot): ModuleBase.__init__(self, bot) self.name = "NSFW" self.nsfw = Nsfw(self.logger) def notify_command(self, message_id, from_attr, date, chat, commandName, commandStr): if commandName == "bonjour": if commandStr == "": text = "Bonjours : %s" % ", ".join(self.nsfw.bonjours) self.bot.sendMessage(text, chat["id"]) return parserResult = self.nsfw.parse(commandStr) for key in parserResult.unknown(): self.bot.sendMessage("bonjour %s not found" % key, chat["id"]) for key in parserResult.known(): result = self.nsfw.image(key, parserResult.mode(), "out.jpg") if result.ok(): self.bot.sendPhoto(chat["id"], "out.jpg", result.message()) break; else: self.bot.sendMessage(result.message(), chat["id"]) def get_commands(self): return [ ("bonjour", "Bonjour. Keywords: <%s> <last/random>" % "/".join(self.nsfw.bonjours)), ]
<commit_before>from modules.module_base import ModuleBase from tools.nsfw import Nsfw class ModuleNSFW(ModuleBase): def __init__(self, bot): ModuleBase.__init__(self, bot) self.name = "NSFW" self.nsfw = Nsfw(self.logger) def notify_command(self, message_id, from_attr, date, chat, commandName, commandStr): if commandName == "bonjour": if commandStr == "": text = "Bonjours : %s" % ", ".join(self.nsfw.bonjours) self.bot.sendMessage(text, chat["id"]) return parserResult = self.nsfw.parse(commandStr) for key in parserResult.unknown(): self.bot.sendMessage("bonjour %s not found" % key, chat["id"]) for key in parserResult.known(): result = self.nsfw.image(key, parserResult.mode(), "out.jpg") if result.ok(): self.bot.sendPhoto(chat["id"], "out.jpg", result.message()) else: self.bot.sendMessage(result.message(), chat["id"]) def get_commands(self): return [ ("bonjour", "Bonjour. Keywords: <%s> <last/random>" % "/".join(self.nsfw.bonjours)), ] <commit_msg>Fix bot infinte image loop<commit_after>
from modules.module_base import ModuleBase from tools.nsfw import Nsfw class ModuleNSFW(ModuleBase): def __init__(self, bot): ModuleBase.__init__(self, bot) self.name = "NSFW" self.nsfw = Nsfw(self.logger) def notify_command(self, message_id, from_attr, date, chat, commandName, commandStr): if commandName == "bonjour": if commandStr == "": text = "Bonjours : %s" % ", ".join(self.nsfw.bonjours) self.bot.sendMessage(text, chat["id"]) return parserResult = self.nsfw.parse(commandStr) for key in parserResult.unknown(): self.bot.sendMessage("bonjour %s not found" % key, chat["id"]) for key in parserResult.known(): result = self.nsfw.image(key, parserResult.mode(), "out.jpg") if result.ok(): self.bot.sendPhoto(chat["id"], "out.jpg", result.message()) break; else: self.bot.sendMessage(result.message(), chat["id"]) def get_commands(self): return [ ("bonjour", "Bonjour. Keywords: <%s> <last/random>" % "/".join(self.nsfw.bonjours)), ]
from modules.module_base import ModuleBase from tools.nsfw import Nsfw class ModuleNSFW(ModuleBase): def __init__(self, bot): ModuleBase.__init__(self, bot) self.name = "NSFW" self.nsfw = Nsfw(self.logger) def notify_command(self, message_id, from_attr, date, chat, commandName, commandStr): if commandName == "bonjour": if commandStr == "": text = "Bonjours : %s" % ", ".join(self.nsfw.bonjours) self.bot.sendMessage(text, chat["id"]) return parserResult = self.nsfw.parse(commandStr) for key in parserResult.unknown(): self.bot.sendMessage("bonjour %s not found" % key, chat["id"]) for key in parserResult.known(): result = self.nsfw.image(key, parserResult.mode(), "out.jpg") if result.ok(): self.bot.sendPhoto(chat["id"], "out.jpg", result.message()) else: self.bot.sendMessage(result.message(), chat["id"]) def get_commands(self): return [ ("bonjour", "Bonjour. Keywords: <%s> <last/random>" % "/".join(self.nsfw.bonjours)), ] Fix bot infinte image loopfrom modules.module_base import ModuleBase from tools.nsfw import Nsfw class ModuleNSFW(ModuleBase): def __init__(self, bot): ModuleBase.__init__(self, bot) self.name = "NSFW" self.nsfw = Nsfw(self.logger) def notify_command(self, message_id, from_attr, date, chat, commandName, commandStr): if commandName == "bonjour": if commandStr == "": text = "Bonjours : %s" % ", ".join(self.nsfw.bonjours) self.bot.sendMessage(text, chat["id"]) return parserResult = self.nsfw.parse(commandStr) for key in parserResult.unknown(): self.bot.sendMessage("bonjour %s not found" % key, chat["id"]) for key in parserResult.known(): result = self.nsfw.image(key, parserResult.mode(), "out.jpg") if result.ok(): self.bot.sendPhoto(chat["id"], "out.jpg", result.message()) break; else: self.bot.sendMessage(result.message(), chat["id"]) def get_commands(self): return [ ("bonjour", "Bonjour. Keywords: <%s> <last/random>" % "/".join(self.nsfw.bonjours)), ]
<commit_before>from modules.module_base import ModuleBase from tools.nsfw import Nsfw class ModuleNSFW(ModuleBase): def __init__(self, bot): ModuleBase.__init__(self, bot) self.name = "NSFW" self.nsfw = Nsfw(self.logger) def notify_command(self, message_id, from_attr, date, chat, commandName, commandStr): if commandName == "bonjour": if commandStr == "": text = "Bonjours : %s" % ", ".join(self.nsfw.bonjours) self.bot.sendMessage(text, chat["id"]) return parserResult = self.nsfw.parse(commandStr) for key in parserResult.unknown(): self.bot.sendMessage("bonjour %s not found" % key, chat["id"]) for key in parserResult.known(): result = self.nsfw.image(key, parserResult.mode(), "out.jpg") if result.ok(): self.bot.sendPhoto(chat["id"], "out.jpg", result.message()) else: self.bot.sendMessage(result.message(), chat["id"]) def get_commands(self): return [ ("bonjour", "Bonjour. Keywords: <%s> <last/random>" % "/".join(self.nsfw.bonjours)), ] <commit_msg>Fix bot infinte image loop<commit_after>from modules.module_base import ModuleBase from tools.nsfw import Nsfw class ModuleNSFW(ModuleBase): def __init__(self, bot): ModuleBase.__init__(self, bot) self.name = "NSFW" self.nsfw = Nsfw(self.logger) def notify_command(self, message_id, from_attr, date, chat, commandName, commandStr): if commandName == "bonjour": if commandStr == "": text = "Bonjours : %s" % ", ".join(self.nsfw.bonjours) self.bot.sendMessage(text, chat["id"]) return parserResult = self.nsfw.parse(commandStr) for key in parserResult.unknown(): self.bot.sendMessage("bonjour %s not found" % key, chat["id"]) for key in parserResult.known(): result = self.nsfw.image(key, parserResult.mode(), "out.jpg") if result.ok(): self.bot.sendPhoto(chat["id"], "out.jpg", result.message()) break; else: self.bot.sendMessage(result.message(), chat["id"]) def get_commands(self): return [ ("bonjour", "Bonjour. Keywords: <%s> <last/random>" % "/".join(self.nsfw.bonjours)), ]
2431ce65da38d50c83f2f23b55dab64a6b4c0b89
boxsdk/object/__init__.py
boxsdk/object/__init__.py
# coding: utf-8 from __future__ import unicode_literals import six __all__ = [ 'collaboration', 'events', 'file', 'folder', 'group', 'group_membership', 'search', 'user', ] if six.PY2: __all__ = [unicode.encode(x, 'utf-8') for x in __all__]
# coding: utf-8 from __future__ import unicode_literals from six.moves import map # pylint:disable=redefined-builtin __all__ = list(map(str, ['collaboration', 'events', 'file', 'folder', 'group', 'group_membership', 'search', 'user']))
Change format of sub-module names in the object module to str
Change format of sub-module names in the object module to str
Python
apache-2.0
box/box-python-sdk
# coding: utf-8 from __future__ import unicode_literals import six __all__ = [ 'collaboration', 'events', 'file', 'folder', 'group', 'group_membership', 'search', 'user', ] if six.PY2: __all__ = [unicode.encode(x, 'utf-8') for x in __all__] Change format of sub-module names in the object module to str
# coding: utf-8 from __future__ import unicode_literals from six.moves import map # pylint:disable=redefined-builtin __all__ = list(map(str, ['collaboration', 'events', 'file', 'folder', 'group', 'group_membership', 'search', 'user']))
<commit_before># coding: utf-8 from __future__ import unicode_literals import six __all__ = [ 'collaboration', 'events', 'file', 'folder', 'group', 'group_membership', 'search', 'user', ] if six.PY2: __all__ = [unicode.encode(x, 'utf-8') for x in __all__] <commit_msg>Change format of sub-module names in the object module to str<commit_after>
# coding: utf-8 from __future__ import unicode_literals from six.moves import map # pylint:disable=redefined-builtin __all__ = list(map(str, ['collaboration', 'events', 'file', 'folder', 'group', 'group_membership', 'search', 'user']))
# coding: utf-8 from __future__ import unicode_literals import six __all__ = [ 'collaboration', 'events', 'file', 'folder', 'group', 'group_membership', 'search', 'user', ] if six.PY2: __all__ = [unicode.encode(x, 'utf-8') for x in __all__] Change format of sub-module names in the object module to str# coding: utf-8 from __future__ import unicode_literals from six.moves import map # pylint:disable=redefined-builtin __all__ = list(map(str, ['collaboration', 'events', 'file', 'folder', 'group', 'group_membership', 'search', 'user']))
<commit_before># coding: utf-8 from __future__ import unicode_literals import six __all__ = [ 'collaboration', 'events', 'file', 'folder', 'group', 'group_membership', 'search', 'user', ] if six.PY2: __all__ = [unicode.encode(x, 'utf-8') for x in __all__] <commit_msg>Change format of sub-module names in the object module to str<commit_after># coding: utf-8 from __future__ import unicode_literals from six.moves import map # pylint:disable=redefined-builtin __all__ = list(map(str, ['collaboration', 'events', 'file', 'folder', 'group', 'group_membership', 'search', 'user']))
3b8c76aaee54e0d49656f640c3f18d2a6c6fbe13
tests/test_api.py
tests/test_api.py
"""Tests the isort API module""" import pytest from isort import api, exceptions def test_sort_file_invalid_syntax(tmpdir) -> None: """Test to ensure file encoding is respected""" tmp_file = tmpdir.join(f"test_bad_syntax.py") tmp_file.write_text("""print('mismathing quotes")""", "utf8") with pytest.warns(UserWarning): api.sort_file(tmp_file, atomic=True)
"""Tests the isort API module""" import pytest from isort import api, exceptions def test_sort_file_invalid_syntax(tmpdir) -> None: """Test to ensure file encoding is respected""" tmp_file = tmpdir.join(f"test_bad_syntax.py") tmp_file.write_text("""print('mismathing quotes")""", "utf8") with pytest.warns(UserWarning): api.sort_file(tmp_file, atomic=True) def test_check_file(tmpdir) -> None: perfect = tmpdir.join(f"test_no_changes.py") perfect.write_text("import a\nimport b\n", "utf8") assert api.check_file(perfect, show_diff=True)
Add initial check file check
Add initial check file check
Python
mit
PyCQA/isort,PyCQA/isort
"""Tests the isort API module""" import pytest from isort import api, exceptions def test_sort_file_invalid_syntax(tmpdir) -> None: """Test to ensure file encoding is respected""" tmp_file = tmpdir.join(f"test_bad_syntax.py") tmp_file.write_text("""print('mismathing quotes")""", "utf8") with pytest.warns(UserWarning): api.sort_file(tmp_file, atomic=True) Add initial check file check
"""Tests the isort API module""" import pytest from isort import api, exceptions def test_sort_file_invalid_syntax(tmpdir) -> None: """Test to ensure file encoding is respected""" tmp_file = tmpdir.join(f"test_bad_syntax.py") tmp_file.write_text("""print('mismathing quotes")""", "utf8") with pytest.warns(UserWarning): api.sort_file(tmp_file, atomic=True) def test_check_file(tmpdir) -> None: perfect = tmpdir.join(f"test_no_changes.py") perfect.write_text("import a\nimport b\n", "utf8") assert api.check_file(perfect, show_diff=True)
<commit_before>"""Tests the isort API module""" import pytest from isort import api, exceptions def test_sort_file_invalid_syntax(tmpdir) -> None: """Test to ensure file encoding is respected""" tmp_file = tmpdir.join(f"test_bad_syntax.py") tmp_file.write_text("""print('mismathing quotes")""", "utf8") with pytest.warns(UserWarning): api.sort_file(tmp_file, atomic=True) <commit_msg>Add initial check file check<commit_after>
"""Tests the isort API module""" import pytest from isort import api, exceptions def test_sort_file_invalid_syntax(tmpdir) -> None: """Test to ensure file encoding is respected""" tmp_file = tmpdir.join(f"test_bad_syntax.py") tmp_file.write_text("""print('mismathing quotes")""", "utf8") with pytest.warns(UserWarning): api.sort_file(tmp_file, atomic=True) def test_check_file(tmpdir) -> None: perfect = tmpdir.join(f"test_no_changes.py") perfect.write_text("import a\nimport b\n", "utf8") assert api.check_file(perfect, show_diff=True)
"""Tests the isort API module""" import pytest from isort import api, exceptions def test_sort_file_invalid_syntax(tmpdir) -> None: """Test to ensure file encoding is respected""" tmp_file = tmpdir.join(f"test_bad_syntax.py") tmp_file.write_text("""print('mismathing quotes")""", "utf8") with pytest.warns(UserWarning): api.sort_file(tmp_file, atomic=True) Add initial check file check"""Tests the isort API module""" import pytest from isort import api, exceptions def test_sort_file_invalid_syntax(tmpdir) -> None: """Test to ensure file encoding is respected""" tmp_file = tmpdir.join(f"test_bad_syntax.py") tmp_file.write_text("""print('mismathing quotes")""", "utf8") with pytest.warns(UserWarning): api.sort_file(tmp_file, atomic=True) def test_check_file(tmpdir) -> None: perfect = tmpdir.join(f"test_no_changes.py") perfect.write_text("import a\nimport b\n", "utf8") assert api.check_file(perfect, show_diff=True)
<commit_before>"""Tests the isort API module""" import pytest from isort import api, exceptions def test_sort_file_invalid_syntax(tmpdir) -> None: """Test to ensure file encoding is respected""" tmp_file = tmpdir.join(f"test_bad_syntax.py") tmp_file.write_text("""print('mismathing quotes")""", "utf8") with pytest.warns(UserWarning): api.sort_file(tmp_file, atomic=True) <commit_msg>Add initial check file check<commit_after>"""Tests the isort API module""" import pytest from isort import api, exceptions def test_sort_file_invalid_syntax(tmpdir) -> None: """Test to ensure file encoding is respected""" tmp_file = tmpdir.join(f"test_bad_syntax.py") tmp_file.write_text("""print('mismathing quotes")""", "utf8") with pytest.warns(UserWarning): api.sort_file(tmp_file, atomic=True) def test_check_file(tmpdir) -> None: perfect = tmpdir.join(f"test_no_changes.py") perfect.write_text("import a\nimport b\n", "utf8") assert api.check_file(perfect, show_diff=True)
1e64e4f5c584ffaf88cc419765e408cc725f0c19
models.py
models.py
#!/usr/bin/env python3 from enum import Enum class LineChange: class ChangeType(Enum): added = 1 deleted = 2 modified = 3 def __init__(self, number=None, change_type=None, filename=None, commit=None): self.number = number self.change_type = change_type self.filename = filename self.commit = commit self.author = None def __str__(self): return ', '.join("{}: {}".format(k, str(v)) for k,v in vars(self).items()) def __repr__(self): return "<{klass} {str}>".format(klass=self.__class__.__name__, str=str(self))
#!/usr/bin/env python3 from enum import Enum class LineChange: class ChangeType(Enum): added = 1 deleted = 2 modified = 3 def __init__(self, line_number=None, change_type=None, file_path=None, commit_sha=None): self.line_number = line_number self.change_type = change_type self.file_path = file_path self.commit_sha = commit_sha self.author = None def __str__(self): return ', '.join("{}: {}".format(k, str(v)) for k,v in vars(self).items()) def __repr__(self): return "<{klass} {str}>".format(klass=self.__class__.__name__, str=str(self)) def __eq__(self, other): if isinstance(other, self.__class__): return self.__dict__ == other.__dict__ else: return False def __ne__(self, other): return not self.__eq__(other)
Add equlaity comparisons to LineChange class.
Add equlaity comparisons to LineChange class.
Python
mit
chrisma/marvin,chrisma/marvin
#!/usr/bin/env python3 from enum import Enum class LineChange: class ChangeType(Enum): added = 1 deleted = 2 modified = 3 def __init__(self, number=None, change_type=None, filename=None, commit=None): self.number = number self.change_type = change_type self.filename = filename self.commit = commit self.author = None def __str__(self): return ', '.join("{}: {}".format(k, str(v)) for k,v in vars(self).items()) def __repr__(self): return "<{klass} {str}>".format(klass=self.__class__.__name__, str=str(self)) Add equlaity comparisons to LineChange class.
#!/usr/bin/env python3 from enum import Enum class LineChange: class ChangeType(Enum): added = 1 deleted = 2 modified = 3 def __init__(self, line_number=None, change_type=None, file_path=None, commit_sha=None): self.line_number = line_number self.change_type = change_type self.file_path = file_path self.commit_sha = commit_sha self.author = None def __str__(self): return ', '.join("{}: {}".format(k, str(v)) for k,v in vars(self).items()) def __repr__(self): return "<{klass} {str}>".format(klass=self.__class__.__name__, str=str(self)) def __eq__(self, other): if isinstance(other, self.__class__): return self.__dict__ == other.__dict__ else: return False def __ne__(self, other): return not self.__eq__(other)
<commit_before>#!/usr/bin/env python3 from enum import Enum class LineChange: class ChangeType(Enum): added = 1 deleted = 2 modified = 3 def __init__(self, number=None, change_type=None, filename=None, commit=None): self.number = number self.change_type = change_type self.filename = filename self.commit = commit self.author = None def __str__(self): return ', '.join("{}: {}".format(k, str(v)) for k,v in vars(self).items()) def __repr__(self): return "<{klass} {str}>".format(klass=self.__class__.__name__, str=str(self)) <commit_msg>Add equlaity comparisons to LineChange class.<commit_after>
#!/usr/bin/env python3 from enum import Enum class LineChange: class ChangeType(Enum): added = 1 deleted = 2 modified = 3 def __init__(self, line_number=None, change_type=None, file_path=None, commit_sha=None): self.line_number = line_number self.change_type = change_type self.file_path = file_path self.commit_sha = commit_sha self.author = None def __str__(self): return ', '.join("{}: {}".format(k, str(v)) for k,v in vars(self).items()) def __repr__(self): return "<{klass} {str}>".format(klass=self.__class__.__name__, str=str(self)) def __eq__(self, other): if isinstance(other, self.__class__): return self.__dict__ == other.__dict__ else: return False def __ne__(self, other): return not self.__eq__(other)
#!/usr/bin/env python3 from enum import Enum class LineChange: class ChangeType(Enum): added = 1 deleted = 2 modified = 3 def __init__(self, number=None, change_type=None, filename=None, commit=None): self.number = number self.change_type = change_type self.filename = filename self.commit = commit self.author = None def __str__(self): return ', '.join("{}: {}".format(k, str(v)) for k,v in vars(self).items()) def __repr__(self): return "<{klass} {str}>".format(klass=self.__class__.__name__, str=str(self)) Add equlaity comparisons to LineChange class.#!/usr/bin/env python3 from enum import Enum class LineChange: class ChangeType(Enum): added = 1 deleted = 2 modified = 3 def __init__(self, line_number=None, change_type=None, file_path=None, commit_sha=None): self.line_number = line_number self.change_type = change_type self.file_path = file_path self.commit_sha = commit_sha self.author = None def __str__(self): return ', '.join("{}: {}".format(k, str(v)) for k,v in vars(self).items()) def __repr__(self): return "<{klass} {str}>".format(klass=self.__class__.__name__, str=str(self)) def __eq__(self, other): if isinstance(other, self.__class__): return self.__dict__ == other.__dict__ else: return False def __ne__(self, other): return not self.__eq__(other)
<commit_before>#!/usr/bin/env python3 from enum import Enum class LineChange: class ChangeType(Enum): added = 1 deleted = 2 modified = 3 def __init__(self, number=None, change_type=None, filename=None, commit=None): self.number = number self.change_type = change_type self.filename = filename self.commit = commit self.author = None def __str__(self): return ', '.join("{}: {}".format(k, str(v)) for k,v in vars(self).items()) def __repr__(self): return "<{klass} {str}>".format(klass=self.__class__.__name__, str=str(self)) <commit_msg>Add equlaity comparisons to LineChange class.<commit_after>#!/usr/bin/env python3 from enum import Enum class LineChange: class ChangeType(Enum): added = 1 deleted = 2 modified = 3 def __init__(self, line_number=None, change_type=None, file_path=None, commit_sha=None): self.line_number = line_number self.change_type = change_type self.file_path = file_path self.commit_sha = commit_sha self.author = None def __str__(self): return ', '.join("{}: {}".format(k, str(v)) for k,v in vars(self).items()) def __repr__(self): return "<{klass} {str}>".format(klass=self.__class__.__name__, str=str(self)) def __eq__(self, other): if isinstance(other, self.__class__): return self.__dict__ == other.__dict__ else: return False def __ne__(self, other): return not self.__eq__(other)
a19e8785e0a13dc854ab626af00144585f946828
models.py
models.py
class Color(object): def __init__(self, r, g, b): self.r = r self.g = g self.b = b class Line(object): def __init__(self, name, api_code, bg_color, fg_color): self.name = name self.api_code = api_code self.bg_color = bg_color self.fg_color = fg_color def __repr__(self): return self.name __unicode__ = __repr__ class Station(object): def __init__(self, name, api_code): self.name = name self.api_code = api_code self.lines = [] self.connections = {} def __repr__(self): return self.name __unicode__ = __repr__ class Map(object): pass
class Color(object): def __init__(self, r, g, b): self.r = r self.g = g self.b = b class Line(object): def __init__(self, name, api_code, bg_color, fg_color): self.name = name self.api_code = api_code self.bg_color = bg_color self.fg_color = fg_color def __repr__(self): return self.name __unicode__ = __repr__ class Station(object): def __init__(self, name, api_code): self.name = name self.api_code = api_code self.connections = {} def __repr__(self): return self.name __unicode__ = __repr__ @property def lines(self): return self.connections.keys() class Map(object): pass
Make Station.lines into a property
Make Station.lines into a property
Python
mit
kirberich/tube_status
class Color(object): def __init__(self, r, g, b): self.r = r self.g = g self.b = b class Line(object): def __init__(self, name, api_code, bg_color, fg_color): self.name = name self.api_code = api_code self.bg_color = bg_color self.fg_color = fg_color def __repr__(self): return self.name __unicode__ = __repr__ class Station(object): def __init__(self, name, api_code): self.name = name self.api_code = api_code self.lines = [] self.connections = {} def __repr__(self): return self.name __unicode__ = __repr__ class Map(object): pass Make Station.lines into a property
class Color(object): def __init__(self, r, g, b): self.r = r self.g = g self.b = b class Line(object): def __init__(self, name, api_code, bg_color, fg_color): self.name = name self.api_code = api_code self.bg_color = bg_color self.fg_color = fg_color def __repr__(self): return self.name __unicode__ = __repr__ class Station(object): def __init__(self, name, api_code): self.name = name self.api_code = api_code self.connections = {} def __repr__(self): return self.name __unicode__ = __repr__ @property def lines(self): return self.connections.keys() class Map(object): pass
<commit_before>class Color(object): def __init__(self, r, g, b): self.r = r self.g = g self.b = b class Line(object): def __init__(self, name, api_code, bg_color, fg_color): self.name = name self.api_code = api_code self.bg_color = bg_color self.fg_color = fg_color def __repr__(self): return self.name __unicode__ = __repr__ class Station(object): def __init__(self, name, api_code): self.name = name self.api_code = api_code self.lines = [] self.connections = {} def __repr__(self): return self.name __unicode__ = __repr__ class Map(object): pass <commit_msg>Make Station.lines into a property<commit_after>
class Color(object): def __init__(self, r, g, b): self.r = r self.g = g self.b = b class Line(object): def __init__(self, name, api_code, bg_color, fg_color): self.name = name self.api_code = api_code self.bg_color = bg_color self.fg_color = fg_color def __repr__(self): return self.name __unicode__ = __repr__ class Station(object): def __init__(self, name, api_code): self.name = name self.api_code = api_code self.connections = {} def __repr__(self): return self.name __unicode__ = __repr__ @property def lines(self): return self.connections.keys() class Map(object): pass
class Color(object): def __init__(self, r, g, b): self.r = r self.g = g self.b = b class Line(object): def __init__(self, name, api_code, bg_color, fg_color): self.name = name self.api_code = api_code self.bg_color = bg_color self.fg_color = fg_color def __repr__(self): return self.name __unicode__ = __repr__ class Station(object): def __init__(self, name, api_code): self.name = name self.api_code = api_code self.lines = [] self.connections = {} def __repr__(self): return self.name __unicode__ = __repr__ class Map(object): pass Make Station.lines into a propertyclass Color(object): def __init__(self, r, g, b): self.r = r self.g = g self.b = b class Line(object): def __init__(self, name, api_code, bg_color, fg_color): self.name = name self.api_code = api_code self.bg_color = bg_color self.fg_color = fg_color def __repr__(self): return self.name __unicode__ = __repr__ class Station(object): def __init__(self, name, api_code): self.name = name self.api_code = api_code self.connections = {} def __repr__(self): return self.name __unicode__ = __repr__ @property def lines(self): return self.connections.keys() class Map(object): pass
<commit_before>class Color(object): def __init__(self, r, g, b): self.r = r self.g = g self.b = b class Line(object): def __init__(self, name, api_code, bg_color, fg_color): self.name = name self.api_code = api_code self.bg_color = bg_color self.fg_color = fg_color def __repr__(self): return self.name __unicode__ = __repr__ class Station(object): def __init__(self, name, api_code): self.name = name self.api_code = api_code self.lines = [] self.connections = {} def __repr__(self): return self.name __unicode__ = __repr__ class Map(object): pass <commit_msg>Make Station.lines into a property<commit_after>class Color(object): def __init__(self, r, g, b): self.r = r self.g = g self.b = b class Line(object): def __init__(self, name, api_code, bg_color, fg_color): self.name = name self.api_code = api_code self.bg_color = bg_color self.fg_color = fg_color def __repr__(self): return self.name __unicode__ = __repr__ class Station(object): def __init__(self, name, api_code): self.name = name self.api_code = api_code self.connections = {} def __repr__(self): return self.name __unicode__ = __repr__ @property def lines(self): return self.connections.keys() class Map(object): pass
d3925a1577476c6754e0d5e9fdb6927d2ee78396
tests/test_ec2.py
tests/test_ec2.py
import unittest import logging import types import time from util import EC2 class TestEC2(unittest.TestCase): def test_metadata(self): # Skip this step on travis if os.environ.get('TRAVIS', False): return # Test gathering metadata from ec2 start = time.time() d = EC2.get_metadata() end = time.time() assert type(d) == types.DictType # Either we're on ec2 or we're not (at least 7 attributes expected) assert len(d) == 0 or len(d) >= 7, d if "instance-id" in d: assert d["instance-id"].startswith("i-"), d assert d["hostname"].startswith("i-") or d["hostname"].startswith("domU-"), d assert end - start <= 1.1, "It took %s seconds to get ec2 metadata" % (end-start) if __name__ == "__main__": unittest.main()
import unittest import os import types import time from util import EC2 class TestEC2(unittest.TestCase): def test_metadata(self): # Skip this step on travis if os.environ.get('TRAVIS', False): return # Test gathering metadata from ec2 start = time.time() d = EC2.get_metadata() end = time.time() assert type(d) == types.DictType # Either we're on ec2 or we're not (at least 7 attributes expected) assert len(d) == 0 or len(d) >= 7, d if "instance-id" in d: assert d["instance-id"].startswith("i-"), d assert d["hostname"].startswith("i-") or d["hostname"].startswith("domU-"), d assert end - start <= 1.1, "It took %s seconds to get ec2 metadata" % (end-start) if __name__ == "__main__": unittest.main()
Add missing import to test to fix travis
Add missing import to test to fix travis
Python
bsd-3-clause
packetloop/dd-agent,oneandoneis2/dd-agent,brettlangdon/dd-agent,cberry777/dd-agent,polynomial/dd-agent,AniruddhaSAtre/dd-agent,Wattpad/dd-agent,oneandoneis2/dd-agent,truthbk/dd-agent,packetloop/dd-agent,zendesk/dd-agent,jamesandariese/dd-agent,joelvanvelden/dd-agent,jvassev/dd-agent,polynomial/dd-agent,huhongbo/dd-agent,PagerDuty/dd-agent,JohnLZeller/dd-agent,mderomph-coolblue/dd-agent,Shopify/dd-agent,tebriel/dd-agent,manolama/dd-agent,a20012251/dd-agent,jraede/dd-agent,AntoCard/powerdns-recursor_check,Mashape/dd-agent,citrusleaf/dd-agent,AntoCard/powerdns-recursor_check,oneandoneis2/dd-agent,joelvanvelden/dd-agent,GabrielNicolasAvellaneda/dd-agent,manolama/dd-agent,PagerDuty/dd-agent,takus/dd-agent,packetloop/dd-agent,jyogi/purvar-agent,citrusleaf/dd-agent,jyogi/purvar-agent,darron/dd-agent,urosgruber/dd-agent,yuecong/dd-agent,jraede/dd-agent,Wattpad/dd-agent,eeroniemi/dd-agent,relateiq/dd-agent,zendesk/dd-agent,guruxu/dd-agent,brettlangdon/dd-agent,relateiq/dd-agent,truthbk/dd-agent,guruxu/dd-agent,takus/dd-agent,pmav99/praktoras,lookout/dd-agent,citrusleaf/dd-agent,mderomph-coolblue/dd-agent,urosgruber/dd-agent,huhongbo/dd-agent,GabrielNicolasAvellaneda/dd-agent,pfmooney/dd-agent,mderomph-coolblue/dd-agent,c960657/dd-agent,indeedops/dd-agent,polynomial/dd-agent,jamesandariese/dd-agent,benmccann/dd-agent,jshum/dd-agent,Shopify/dd-agent,relateiq/dd-agent,guruxu/dd-agent,gphat/dd-agent,darron/dd-agent,c960657/dd-agent,pmav99/praktoras,truthbk/dd-agent,tebriel/dd-agent,urosgruber/dd-agent,oneandoneis2/dd-agent,yuecong/dd-agent,benmccann/dd-agent,jvassev/dd-agent,pmav99/praktoras,takus/dd-agent,brettlangdon/dd-agent,pmav99/praktoras,c960657/dd-agent,AniruddhaSAtre/dd-agent,pfmooney/dd-agent,Wattpad/dd-agent,urosgruber/dd-agent,tebriel/dd-agent,Shopify/dd-agent,jshum/dd-agent,PagerDuty/dd-agent,jyogi/purvar-agent,Shopify/dd-agent,AniruddhaSAtre/dd-agent,benmccann/dd-agent,pfmooney/dd-agent,amalakar/dd-agent,a20012251/dd-agent,darron/dd-agent,relateiq/dd-agent,remh/dd-agent,Mashape/dd-agent,remh/dd-agent,huhongbo/dd-agent,truthbk/dd-agent,jvassev/dd-agent,a20012251/dd-agent,joelvanvelden/dd-agent,indeedops/dd-agent,AniruddhaSAtre/dd-agent,Shopify/dd-agent,eeroniemi/dd-agent,amalakar/dd-agent,packetloop/dd-agent,zendesk/dd-agent,jamesandariese/dd-agent,pfmooney/dd-agent,benmccann/dd-agent,yuecong/dd-agent,pmav99/praktoras,amalakar/dd-agent,jraede/dd-agent,JohnLZeller/dd-agent,urosgruber/dd-agent,indeedops/dd-agent,ess/dd-agent,Wattpad/dd-agent,PagerDuty/dd-agent,lookout/dd-agent,jamesandariese/dd-agent,truthbk/dd-agent,yuecong/dd-agent,a20012251/dd-agent,GabrielNicolasAvellaneda/dd-agent,brettlangdon/dd-agent,GabrielNicolasAvellaneda/dd-agent,c960657/dd-agent,darron/dd-agent,ess/dd-agent,manolama/dd-agent,mderomph-coolblue/dd-agent,jvassev/dd-agent,amalakar/dd-agent,jraede/dd-agent,Wattpad/dd-agent,jyogi/purvar-agent,tebriel/dd-agent,ess/dd-agent,oneandoneis2/dd-agent,joelvanvelden/dd-agent,pfmooney/dd-agent,gphat/dd-agent,huhongbo/dd-agent,AntoCard/powerdns-recursor_check,packetloop/dd-agent,tebriel/dd-agent,jshum/dd-agent,cberry777/dd-agent,cberry777/dd-agent,zendesk/dd-agent,remh/dd-agent,joelvanvelden/dd-agent,zendesk/dd-agent,PagerDuty/dd-agent,JohnLZeller/dd-agent,huhongbo/dd-agent,cberry777/dd-agent,Mashape/dd-agent,Mashape/dd-agent,citrusleaf/dd-agent,a20012251/dd-agent,lookout/dd-agent,jshum/dd-agent,guruxu/dd-agent,relateiq/dd-agent,gphat/dd-agent,eeroniemi/dd-agent,AntoCard/powerdns-recursor_check,ess/dd-agent,GabrielNicolasAvellaneda/dd-agent,polynomial/dd-agent,jamesandariese/dd-agent,benmccann/dd-agent,cberry777/dd-agent,brettlangdon/dd-agent,jshum/dd-agent,AntoCard/powerdns-recursor_check,remh/dd-agent,jyogi/purvar-agent,gphat/dd-agent,guruxu/dd-agent,indeedops/dd-agent,eeroniemi/dd-agent,eeroniemi/dd-agent,yuecong/dd-agent,jraede/dd-agent,ess/dd-agent,citrusleaf/dd-agent,remh/dd-agent,mderomph-coolblue/dd-agent,lookout/dd-agent,gphat/dd-agent,amalakar/dd-agent,manolama/dd-agent,takus/dd-agent,JohnLZeller/dd-agent,takus/dd-agent,lookout/dd-agent,c960657/dd-agent,jvassev/dd-agent,JohnLZeller/dd-agent,darron/dd-agent,Mashape/dd-agent,polynomial/dd-agent,indeedops/dd-agent,AniruddhaSAtre/dd-agent,manolama/dd-agent
import unittest import logging import types import time from util import EC2 class TestEC2(unittest.TestCase): def test_metadata(self): # Skip this step on travis if os.environ.get('TRAVIS', False): return # Test gathering metadata from ec2 start = time.time() d = EC2.get_metadata() end = time.time() assert type(d) == types.DictType # Either we're on ec2 or we're not (at least 7 attributes expected) assert len(d) == 0 or len(d) >= 7, d if "instance-id" in d: assert d["instance-id"].startswith("i-"), d assert d["hostname"].startswith("i-") or d["hostname"].startswith("domU-"), d assert end - start <= 1.1, "It took %s seconds to get ec2 metadata" % (end-start) if __name__ == "__main__": unittest.main() Add missing import to test to fix travis
import unittest import os import types import time from util import EC2 class TestEC2(unittest.TestCase): def test_metadata(self): # Skip this step on travis if os.environ.get('TRAVIS', False): return # Test gathering metadata from ec2 start = time.time() d = EC2.get_metadata() end = time.time() assert type(d) == types.DictType # Either we're on ec2 or we're not (at least 7 attributes expected) assert len(d) == 0 or len(d) >= 7, d if "instance-id" in d: assert d["instance-id"].startswith("i-"), d assert d["hostname"].startswith("i-") or d["hostname"].startswith("domU-"), d assert end - start <= 1.1, "It took %s seconds to get ec2 metadata" % (end-start) if __name__ == "__main__": unittest.main()
<commit_before>import unittest import logging import types import time from util import EC2 class TestEC2(unittest.TestCase): def test_metadata(self): # Skip this step on travis if os.environ.get('TRAVIS', False): return # Test gathering metadata from ec2 start = time.time() d = EC2.get_metadata() end = time.time() assert type(d) == types.DictType # Either we're on ec2 or we're not (at least 7 attributes expected) assert len(d) == 0 or len(d) >= 7, d if "instance-id" in d: assert d["instance-id"].startswith("i-"), d assert d["hostname"].startswith("i-") or d["hostname"].startswith("domU-"), d assert end - start <= 1.1, "It took %s seconds to get ec2 metadata" % (end-start) if __name__ == "__main__": unittest.main() <commit_msg>Add missing import to test to fix travis<commit_after>
import unittest import os import types import time from util import EC2 class TestEC2(unittest.TestCase): def test_metadata(self): # Skip this step on travis if os.environ.get('TRAVIS', False): return # Test gathering metadata from ec2 start = time.time() d = EC2.get_metadata() end = time.time() assert type(d) == types.DictType # Either we're on ec2 or we're not (at least 7 attributes expected) assert len(d) == 0 or len(d) >= 7, d if "instance-id" in d: assert d["instance-id"].startswith("i-"), d assert d["hostname"].startswith("i-") or d["hostname"].startswith("domU-"), d assert end - start <= 1.1, "It took %s seconds to get ec2 metadata" % (end-start) if __name__ == "__main__": unittest.main()
import unittest import logging import types import time from util import EC2 class TestEC2(unittest.TestCase): def test_metadata(self): # Skip this step on travis if os.environ.get('TRAVIS', False): return # Test gathering metadata from ec2 start = time.time() d = EC2.get_metadata() end = time.time() assert type(d) == types.DictType # Either we're on ec2 or we're not (at least 7 attributes expected) assert len(d) == 0 or len(d) >= 7, d if "instance-id" in d: assert d["instance-id"].startswith("i-"), d assert d["hostname"].startswith("i-") or d["hostname"].startswith("domU-"), d assert end - start <= 1.1, "It took %s seconds to get ec2 metadata" % (end-start) if __name__ == "__main__": unittest.main() Add missing import to test to fix travisimport unittest import os import types import time from util import EC2 class TestEC2(unittest.TestCase): def test_metadata(self): # Skip this step on travis if os.environ.get('TRAVIS', False): return # Test gathering metadata from ec2 start = time.time() d = EC2.get_metadata() end = time.time() assert type(d) == types.DictType # Either we're on ec2 or we're not (at least 7 attributes expected) assert len(d) == 0 or len(d) >= 7, d if "instance-id" in d: assert d["instance-id"].startswith("i-"), d assert d["hostname"].startswith("i-") or d["hostname"].startswith("domU-"), d assert end - start <= 1.1, "It took %s seconds to get ec2 metadata" % (end-start) if __name__ == "__main__": unittest.main()
<commit_before>import unittest import logging import types import time from util import EC2 class TestEC2(unittest.TestCase): def test_metadata(self): # Skip this step on travis if os.environ.get('TRAVIS', False): return # Test gathering metadata from ec2 start = time.time() d = EC2.get_metadata() end = time.time() assert type(d) == types.DictType # Either we're on ec2 or we're not (at least 7 attributes expected) assert len(d) == 0 or len(d) >= 7, d if "instance-id" in d: assert d["instance-id"].startswith("i-"), d assert d["hostname"].startswith("i-") or d["hostname"].startswith("domU-"), d assert end - start <= 1.1, "It took %s seconds to get ec2 metadata" % (end-start) if __name__ == "__main__": unittest.main() <commit_msg>Add missing import to test to fix travis<commit_after>import unittest import os import types import time from util import EC2 class TestEC2(unittest.TestCase): def test_metadata(self): # Skip this step on travis if os.environ.get('TRAVIS', False): return # Test gathering metadata from ec2 start = time.time() d = EC2.get_metadata() end = time.time() assert type(d) == types.DictType # Either we're on ec2 or we're not (at least 7 attributes expected) assert len(d) == 0 or len(d) >= 7, d if "instance-id" in d: assert d["instance-id"].startswith("i-"), d assert d["hostname"].startswith("i-") or d["hostname"].startswith("domU-"), d assert end - start <= 1.1, "It took %s seconds to get ec2 metadata" % (end-start) if __name__ == "__main__": unittest.main()
50224b985a2215b8598f274efd33fc5c20054417
tests/test_str.py
tests/test_str.py
import pytest from hypothesis import given from hypothesis.strategies import lists, text from datatyping.datatyping import validate @given(ss=lists(text())) def test_simple(ss): assert validate([str], ss) is None @given(s=text()) def test_simple_error(s): with pytest.raises(TypeError): validate([str], s) @given(ss=lists(lists(text()))) def test_nested(ss): assert validate([[str]], ss) is None
import pytest from hypothesis import given from hypothesis.strategies import integers, text from datatyping.datatyping import validate @given(string=text()) def test_simple(string): assert validate(str, string) is None @given(not_string=integers()) def test_simple_error(not_string): with pytest.raises(TypeError): validate(str, not_string)
Rewrite str tests with hypothesis Remove lists from testing
Rewrite str tests with hypothesis Remove lists from testing
Python
mit
Zaab1t/datatyping
import pytest from hypothesis import given from hypothesis.strategies import lists, text from datatyping.datatyping import validate @given(ss=lists(text())) def test_simple(ss): assert validate([str], ss) is None @given(s=text()) def test_simple_error(s): with pytest.raises(TypeError): validate([str], s) @given(ss=lists(lists(text()))) def test_nested(ss): assert validate([[str]], ss) is None Rewrite str tests with hypothesis Remove lists from testing
import pytest from hypothesis import given from hypothesis.strategies import integers, text from datatyping.datatyping import validate @given(string=text()) def test_simple(string): assert validate(str, string) is None @given(not_string=integers()) def test_simple_error(not_string): with pytest.raises(TypeError): validate(str, not_string)
<commit_before>import pytest from hypothesis import given from hypothesis.strategies import lists, text from datatyping.datatyping import validate @given(ss=lists(text())) def test_simple(ss): assert validate([str], ss) is None @given(s=text()) def test_simple_error(s): with pytest.raises(TypeError): validate([str], s) @given(ss=lists(lists(text()))) def test_nested(ss): assert validate([[str]], ss) is None <commit_msg>Rewrite str tests with hypothesis Remove lists from testing<commit_after>
import pytest from hypothesis import given from hypothesis.strategies import integers, text from datatyping.datatyping import validate @given(string=text()) def test_simple(string): assert validate(str, string) is None @given(not_string=integers()) def test_simple_error(not_string): with pytest.raises(TypeError): validate(str, not_string)
import pytest from hypothesis import given from hypothesis.strategies import lists, text from datatyping.datatyping import validate @given(ss=lists(text())) def test_simple(ss): assert validate([str], ss) is None @given(s=text()) def test_simple_error(s): with pytest.raises(TypeError): validate([str], s) @given(ss=lists(lists(text()))) def test_nested(ss): assert validate([[str]], ss) is None Rewrite str tests with hypothesis Remove lists from testingimport pytest from hypothesis import given from hypothesis.strategies import integers, text from datatyping.datatyping import validate @given(string=text()) def test_simple(string): assert validate(str, string) is None @given(not_string=integers()) def test_simple_error(not_string): with pytest.raises(TypeError): validate(str, not_string)
<commit_before>import pytest from hypothesis import given from hypothesis.strategies import lists, text from datatyping.datatyping import validate @given(ss=lists(text())) def test_simple(ss): assert validate([str], ss) is None @given(s=text()) def test_simple_error(s): with pytest.raises(TypeError): validate([str], s) @given(ss=lists(lists(text()))) def test_nested(ss): assert validate([[str]], ss) is None <commit_msg>Rewrite str tests with hypothesis Remove lists from testing<commit_after>import pytest from hypothesis import given from hypothesis.strategies import integers, text from datatyping.datatyping import validate @given(string=text()) def test_simple(string): assert validate(str, string) is None @given(not_string=integers()) def test_simple_error(not_string): with pytest.raises(TypeError): validate(str, not_string)
5f8befe38592c75464cf03f698123d5e9f6606b8
src/tutorials/code/python/chat/1.py
src/tutorials/code/python/chat/1.py
# Address of the beam website. # No trailing slash. beam_addr = 'https://beam.pro' # Username of the account. username = 'username' # Password of the account. password = 'password' # The id of the channel you want to connect to. channel = 12345
# Address of the beam website. # No trailing slash. BEAM_ADDR = 'https://beam.pro' # Username of the account. USERNAME = 'username' # Password of the account. PASSWORD = 'password' # The id of the channel you want to connect to. CHANNEL = 12345
FIx broken Python code in chat bot tutorial
FIx broken Python code in chat bot tutorial
Python
mit
WatchBeam/developers,WatchBeam/developers,WatchBeam/developers,WatchBeam/developers,WatchBeam/developers
# Address of the beam website. # No trailing slash. beam_addr = 'https://beam.pro' # Username of the account. username = 'username' # Password of the account. password = 'password' # The id of the channel you want to connect to. channel = 12345 FIx broken Python code in chat bot tutorial
# Address of the beam website. # No trailing slash. BEAM_ADDR = 'https://beam.pro' # Username of the account. USERNAME = 'username' # Password of the account. PASSWORD = 'password' # The id of the channel you want to connect to. CHANNEL = 12345
<commit_before># Address of the beam website. # No trailing slash. beam_addr = 'https://beam.pro' # Username of the account. username = 'username' # Password of the account. password = 'password' # The id of the channel you want to connect to. channel = 12345 <commit_msg>FIx broken Python code in chat bot tutorial<commit_after>
# Address of the beam website. # No trailing slash. BEAM_ADDR = 'https://beam.pro' # Username of the account. USERNAME = 'username' # Password of the account. PASSWORD = 'password' # The id of the channel you want to connect to. CHANNEL = 12345
# Address of the beam website. # No trailing slash. beam_addr = 'https://beam.pro' # Username of the account. username = 'username' # Password of the account. password = 'password' # The id of the channel you want to connect to. channel = 12345 FIx broken Python code in chat bot tutorial# Address of the beam website. # No trailing slash. BEAM_ADDR = 'https://beam.pro' # Username of the account. USERNAME = 'username' # Password of the account. PASSWORD = 'password' # The id of the channel you want to connect to. CHANNEL = 12345
<commit_before># Address of the beam website. # No trailing slash. beam_addr = 'https://beam.pro' # Username of the account. username = 'username' # Password of the account. password = 'password' # The id of the channel you want to connect to. channel = 12345 <commit_msg>FIx broken Python code in chat bot tutorial<commit_after># Address of the beam website. # No trailing slash. BEAM_ADDR = 'https://beam.pro' # Username of the account. USERNAME = 'username' # Password of the account. PASSWORD = 'password' # The id of the channel you want to connect to. CHANNEL = 12345
f0118092290355b486ed1c524c7f41cdb7c5697e
server.py
server.py
from PodSixNet.Channel import Channel from PodSixNet.Server import Server from time import sleep #Create the channel to deal with our incoming requests from the client #A new channel is created every time a client connects class ClientChannel(Channel): #Create a function that will respond to every request from the client def Network(self, data): #Print the contents of the packet print(data) #Create a new server for our game def GameServer(Server): #Set the channel to deal with incoming requests channelClass = ClientChannel #Constructor to initialize the server objects def __init__(self, *args, **kwargs): #Call the super constructor Server.__init__(self, *args, **kwargs) #Create the objects to hold our game ID and list of running games self.games = [] self.queue = None self.gameIndex = 0 #Function to deal with new connections def Connected(self, channel, addr): print("New connection: {}".format(channel)) #Start the server, but only if the file wasn't imported if __name__ == "__main__": print("Server starting on LOCALHOST...\n") #Create a server s = GameServer() #Pump the server at regular intervals (check for new requests) while True: s.Pump() sleep(0.0001)
from PodSixNet.Channel import Channel from PodSixNet.Server import Server from time import sleep #Create the channel to deal with our incoming requests from the client #A new channel is created every time a client connects class ClientChannel(Channel): #Create a function that will respond to every request from the client def Network(self, data): #Print the contents of the packet print(data) #Create a new server for our game def GameServer(Server): #Set the channel to deal with incoming requests channelClass = ClientChannel #Constructor to initialize the server objects def __init__(self, *args, **kwargs): #Call the super constructor Server.__init__(self, *args, **kwargs) #Create the objects to hold our game ID and list of running games self.games = [] self.queue = None self.gameIndex = 0 #Function to deal with new connections def Connected(self, channel, addr): print("New connection: {}".format(channel)) #Create the game class to hold information about any particular game class Game(object): #Constructor def __init__(self, player0, gameIndex): #Set the initial positions of each player self.p1x = 0 self.p1y = 0 self.p2x = 550 self.p2y = 0 #Store the network channel of each client self.player0 = player0 self.player1 = None #Set the game id self.gameID = gameIndex #Start the server, but only if the file wasn't imported if __name__ == "__main__": print("Server starting on LOCALHOST...\n") #Create a server s = GameServer() #Pump the server at regular intervals (check for new requests) while True: s.Pump() sleep(0.0001)
Create a game class to store information about an instantiated game object
Create a game class to store information about an instantiated game object
Python
mit
thebillington/pygame_multiplayer_server
from PodSixNet.Channel import Channel from PodSixNet.Server import Server from time import sleep #Create the channel to deal with our incoming requests from the client #A new channel is created every time a client connects class ClientChannel(Channel): #Create a function that will respond to every request from the client def Network(self, data): #Print the contents of the packet print(data) #Create a new server for our game def GameServer(Server): #Set the channel to deal with incoming requests channelClass = ClientChannel #Constructor to initialize the server objects def __init__(self, *args, **kwargs): #Call the super constructor Server.__init__(self, *args, **kwargs) #Create the objects to hold our game ID and list of running games self.games = [] self.queue = None self.gameIndex = 0 #Function to deal with new connections def Connected(self, channel, addr): print("New connection: {}".format(channel)) #Start the server, but only if the file wasn't imported if __name__ == "__main__": print("Server starting on LOCALHOST...\n") #Create a server s = GameServer() #Pump the server at regular intervals (check for new requests) while True: s.Pump() sleep(0.0001) Create a game class to store information about an instantiated game object
from PodSixNet.Channel import Channel from PodSixNet.Server import Server from time import sleep #Create the channel to deal with our incoming requests from the client #A new channel is created every time a client connects class ClientChannel(Channel): #Create a function that will respond to every request from the client def Network(self, data): #Print the contents of the packet print(data) #Create a new server for our game def GameServer(Server): #Set the channel to deal with incoming requests channelClass = ClientChannel #Constructor to initialize the server objects def __init__(self, *args, **kwargs): #Call the super constructor Server.__init__(self, *args, **kwargs) #Create the objects to hold our game ID and list of running games self.games = [] self.queue = None self.gameIndex = 0 #Function to deal with new connections def Connected(self, channel, addr): print("New connection: {}".format(channel)) #Create the game class to hold information about any particular game class Game(object): #Constructor def __init__(self, player0, gameIndex): #Set the initial positions of each player self.p1x = 0 self.p1y = 0 self.p2x = 550 self.p2y = 0 #Store the network channel of each client self.player0 = player0 self.player1 = None #Set the game id self.gameID = gameIndex #Start the server, but only if the file wasn't imported if __name__ == "__main__": print("Server starting on LOCALHOST...\n") #Create a server s = GameServer() #Pump the server at regular intervals (check for new requests) while True: s.Pump() sleep(0.0001)
<commit_before>from PodSixNet.Channel import Channel from PodSixNet.Server import Server from time import sleep #Create the channel to deal with our incoming requests from the client #A new channel is created every time a client connects class ClientChannel(Channel): #Create a function that will respond to every request from the client def Network(self, data): #Print the contents of the packet print(data) #Create a new server for our game def GameServer(Server): #Set the channel to deal with incoming requests channelClass = ClientChannel #Constructor to initialize the server objects def __init__(self, *args, **kwargs): #Call the super constructor Server.__init__(self, *args, **kwargs) #Create the objects to hold our game ID and list of running games self.games = [] self.queue = None self.gameIndex = 0 #Function to deal with new connections def Connected(self, channel, addr): print("New connection: {}".format(channel)) #Start the server, but only if the file wasn't imported if __name__ == "__main__": print("Server starting on LOCALHOST...\n") #Create a server s = GameServer() #Pump the server at regular intervals (check for new requests) while True: s.Pump() sleep(0.0001) <commit_msg>Create a game class to store information about an instantiated game object<commit_after>
from PodSixNet.Channel import Channel from PodSixNet.Server import Server from time import sleep #Create the channel to deal with our incoming requests from the client #A new channel is created every time a client connects class ClientChannel(Channel): #Create a function that will respond to every request from the client def Network(self, data): #Print the contents of the packet print(data) #Create a new server for our game def GameServer(Server): #Set the channel to deal with incoming requests channelClass = ClientChannel #Constructor to initialize the server objects def __init__(self, *args, **kwargs): #Call the super constructor Server.__init__(self, *args, **kwargs) #Create the objects to hold our game ID and list of running games self.games = [] self.queue = None self.gameIndex = 0 #Function to deal with new connections def Connected(self, channel, addr): print("New connection: {}".format(channel)) #Create the game class to hold information about any particular game class Game(object): #Constructor def __init__(self, player0, gameIndex): #Set the initial positions of each player self.p1x = 0 self.p1y = 0 self.p2x = 550 self.p2y = 0 #Store the network channel of each client self.player0 = player0 self.player1 = None #Set the game id self.gameID = gameIndex #Start the server, but only if the file wasn't imported if __name__ == "__main__": print("Server starting on LOCALHOST...\n") #Create a server s = GameServer() #Pump the server at regular intervals (check for new requests) while True: s.Pump() sleep(0.0001)
from PodSixNet.Channel import Channel from PodSixNet.Server import Server from time import sleep #Create the channel to deal with our incoming requests from the client #A new channel is created every time a client connects class ClientChannel(Channel): #Create a function that will respond to every request from the client def Network(self, data): #Print the contents of the packet print(data) #Create a new server for our game def GameServer(Server): #Set the channel to deal with incoming requests channelClass = ClientChannel #Constructor to initialize the server objects def __init__(self, *args, **kwargs): #Call the super constructor Server.__init__(self, *args, **kwargs) #Create the objects to hold our game ID and list of running games self.games = [] self.queue = None self.gameIndex = 0 #Function to deal with new connections def Connected(self, channel, addr): print("New connection: {}".format(channel)) #Start the server, but only if the file wasn't imported if __name__ == "__main__": print("Server starting on LOCALHOST...\n") #Create a server s = GameServer() #Pump the server at regular intervals (check for new requests) while True: s.Pump() sleep(0.0001) Create a game class to store information about an instantiated game objectfrom PodSixNet.Channel import Channel from PodSixNet.Server import Server from time import sleep #Create the channel to deal with our incoming requests from the client #A new channel is created every time a client connects class ClientChannel(Channel): #Create a function that will respond to every request from the client def Network(self, data): #Print the contents of the packet print(data) #Create a new server for our game def GameServer(Server): #Set the channel to deal with incoming requests channelClass = ClientChannel #Constructor to initialize the server objects def __init__(self, *args, **kwargs): #Call the super constructor Server.__init__(self, *args, **kwargs) #Create the objects to hold our game ID and list of running games self.games = [] self.queue = None self.gameIndex = 0 #Function to deal with new connections def Connected(self, channel, addr): print("New connection: {}".format(channel)) #Create the game class to hold information about any particular game class Game(object): #Constructor def __init__(self, player0, gameIndex): #Set the initial positions of each player self.p1x = 0 self.p1y = 0 self.p2x = 550 self.p2y = 0 #Store the network channel of each client self.player0 = player0 self.player1 = None #Set the game id self.gameID = gameIndex #Start the server, but only if the file wasn't imported if __name__ == "__main__": print("Server starting on LOCALHOST...\n") #Create a server s = GameServer() #Pump the server at regular intervals (check for new requests) while True: s.Pump() sleep(0.0001)
<commit_before>from PodSixNet.Channel import Channel from PodSixNet.Server import Server from time import sleep #Create the channel to deal with our incoming requests from the client #A new channel is created every time a client connects class ClientChannel(Channel): #Create a function that will respond to every request from the client def Network(self, data): #Print the contents of the packet print(data) #Create a new server for our game def GameServer(Server): #Set the channel to deal with incoming requests channelClass = ClientChannel #Constructor to initialize the server objects def __init__(self, *args, **kwargs): #Call the super constructor Server.__init__(self, *args, **kwargs) #Create the objects to hold our game ID and list of running games self.games = [] self.queue = None self.gameIndex = 0 #Function to deal with new connections def Connected(self, channel, addr): print("New connection: {}".format(channel)) #Start the server, but only if the file wasn't imported if __name__ == "__main__": print("Server starting on LOCALHOST...\n") #Create a server s = GameServer() #Pump the server at regular intervals (check for new requests) while True: s.Pump() sleep(0.0001) <commit_msg>Create a game class to store information about an instantiated game object<commit_after>from PodSixNet.Channel import Channel from PodSixNet.Server import Server from time import sleep #Create the channel to deal with our incoming requests from the client #A new channel is created every time a client connects class ClientChannel(Channel): #Create a function that will respond to every request from the client def Network(self, data): #Print the contents of the packet print(data) #Create a new server for our game def GameServer(Server): #Set the channel to deal with incoming requests channelClass = ClientChannel #Constructor to initialize the server objects def __init__(self, *args, **kwargs): #Call the super constructor Server.__init__(self, *args, **kwargs) #Create the objects to hold our game ID and list of running games self.games = [] self.queue = None self.gameIndex = 0 #Function to deal with new connections def Connected(self, channel, addr): print("New connection: {}".format(channel)) #Create the game class to hold information about any particular game class Game(object): #Constructor def __init__(self, player0, gameIndex): #Set the initial positions of each player self.p1x = 0 self.p1y = 0 self.p2x = 550 self.p2y = 0 #Store the network channel of each client self.player0 = player0 self.player1 = None #Set the game id self.gameID = gameIndex #Start the server, but only if the file wasn't imported if __name__ == "__main__": print("Server starting on LOCALHOST...\n") #Create a server s = GameServer() #Pump the server at regular intervals (check for new requests) while True: s.Pump() sleep(0.0001)
c6837af1af2939965976bfb45099bf7c2407a9da
twitter_api/middleware/ghetto_oauth.py
twitter_api/middleware/ghetto_oauth.py
from django.contrib.auth.models import User import re class GhettoOAuthMiddleware(object): def process_view(self, request, view_func, view_args, view_kwargs): user_id = None if 'HTTP_AUTHORIZATION' in request.META and request.META['HTTP_AUTHORIZATION'].startswith('OAuth'): m = re.search(r'oauth_token="(\d+)"', request.META['HTTP_AUTHORIZATION']) if m: user_id = m.group(1) if 'oauth_token' in request.GET: user_id = request.GET['oauth_token'] if user_id: request.user = User.objects.get(pk=user_id) return view_func(request, *view_args, **view_kwargs)
from django.contrib.auth.models import User import re class GhettoOAuthMiddleware(object): def process_view(self, request, view_func, view_args, view_kwargs): user_id = self._get_token_from_header(request, 'HTTP_AUTHORIZATION') if not user_id: user_id = self._get_token_from_header(request, 'HTTP_X_VERIFY_CREDENTIALS_AUTHORIZATION') if 'oauth_token' in request.GET: user_id = request.GET['oauth_token'] if user_id: request.user = User.objects.get(pk=user_id) return view_func(request, *view_args, **view_kwargs) def _get_token_from_header(self, request, header): if header in request.META and request.META[header].startswith('OAuth'): m = re.search(r'oauth_token="(\d+)"', request.META[header]) if m: return m.group(1)
Add more HTTP headers to GhettoOauth
Add more HTTP headers to GhettoOauth The official iPhone Twitter client uses HTTP_X_VERIFY_CREDENTIALS_AUTHORIZATION when it's connecting to image upload services.
Python
bsd-2-clause
simonw/bugle_project,devfort/bugle,simonw/bugle_project,devfort/bugle,devfort/bugle
from django.contrib.auth.models import User import re class GhettoOAuthMiddleware(object): def process_view(self, request, view_func, view_args, view_kwargs): user_id = None if 'HTTP_AUTHORIZATION' in request.META and request.META['HTTP_AUTHORIZATION'].startswith('OAuth'): m = re.search(r'oauth_token="(\d+)"', request.META['HTTP_AUTHORIZATION']) if m: user_id = m.group(1) if 'oauth_token' in request.GET: user_id = request.GET['oauth_token'] if user_id: request.user = User.objects.get(pk=user_id) return view_func(request, *view_args, **view_kwargs) Add more HTTP headers to GhettoOauth The official iPhone Twitter client uses HTTP_X_VERIFY_CREDENTIALS_AUTHORIZATION when it's connecting to image upload services.
from django.contrib.auth.models import User import re class GhettoOAuthMiddleware(object): def process_view(self, request, view_func, view_args, view_kwargs): user_id = self._get_token_from_header(request, 'HTTP_AUTHORIZATION') if not user_id: user_id = self._get_token_from_header(request, 'HTTP_X_VERIFY_CREDENTIALS_AUTHORIZATION') if 'oauth_token' in request.GET: user_id = request.GET['oauth_token'] if user_id: request.user = User.objects.get(pk=user_id) return view_func(request, *view_args, **view_kwargs) def _get_token_from_header(self, request, header): if header in request.META and request.META[header].startswith('OAuth'): m = re.search(r'oauth_token="(\d+)"', request.META[header]) if m: return m.group(1)
<commit_before>from django.contrib.auth.models import User import re class GhettoOAuthMiddleware(object): def process_view(self, request, view_func, view_args, view_kwargs): user_id = None if 'HTTP_AUTHORIZATION' in request.META and request.META['HTTP_AUTHORIZATION'].startswith('OAuth'): m = re.search(r'oauth_token="(\d+)"', request.META['HTTP_AUTHORIZATION']) if m: user_id = m.group(1) if 'oauth_token' in request.GET: user_id = request.GET['oauth_token'] if user_id: request.user = User.objects.get(pk=user_id) return view_func(request, *view_args, **view_kwargs) <commit_msg>Add more HTTP headers to GhettoOauth The official iPhone Twitter client uses HTTP_X_VERIFY_CREDENTIALS_AUTHORIZATION when it's connecting to image upload services.<commit_after>
from django.contrib.auth.models import User import re class GhettoOAuthMiddleware(object): def process_view(self, request, view_func, view_args, view_kwargs): user_id = self._get_token_from_header(request, 'HTTP_AUTHORIZATION') if not user_id: user_id = self._get_token_from_header(request, 'HTTP_X_VERIFY_CREDENTIALS_AUTHORIZATION') if 'oauth_token' in request.GET: user_id = request.GET['oauth_token'] if user_id: request.user = User.objects.get(pk=user_id) return view_func(request, *view_args, **view_kwargs) def _get_token_from_header(self, request, header): if header in request.META and request.META[header].startswith('OAuth'): m = re.search(r'oauth_token="(\d+)"', request.META[header]) if m: return m.group(1)
from django.contrib.auth.models import User import re class GhettoOAuthMiddleware(object): def process_view(self, request, view_func, view_args, view_kwargs): user_id = None if 'HTTP_AUTHORIZATION' in request.META and request.META['HTTP_AUTHORIZATION'].startswith('OAuth'): m = re.search(r'oauth_token="(\d+)"', request.META['HTTP_AUTHORIZATION']) if m: user_id = m.group(1) if 'oauth_token' in request.GET: user_id = request.GET['oauth_token'] if user_id: request.user = User.objects.get(pk=user_id) return view_func(request, *view_args, **view_kwargs) Add more HTTP headers to GhettoOauth The official iPhone Twitter client uses HTTP_X_VERIFY_CREDENTIALS_AUTHORIZATION when it's connecting to image upload services.from django.contrib.auth.models import User import re class GhettoOAuthMiddleware(object): def process_view(self, request, view_func, view_args, view_kwargs): user_id = self._get_token_from_header(request, 'HTTP_AUTHORIZATION') if not user_id: user_id = self._get_token_from_header(request, 'HTTP_X_VERIFY_CREDENTIALS_AUTHORIZATION') if 'oauth_token' in request.GET: user_id = request.GET['oauth_token'] if user_id: request.user = User.objects.get(pk=user_id) return view_func(request, *view_args, **view_kwargs) def _get_token_from_header(self, request, header): if header in request.META and request.META[header].startswith('OAuth'): m = re.search(r'oauth_token="(\d+)"', request.META[header]) if m: return m.group(1)
<commit_before>from django.contrib.auth.models import User import re class GhettoOAuthMiddleware(object): def process_view(self, request, view_func, view_args, view_kwargs): user_id = None if 'HTTP_AUTHORIZATION' in request.META and request.META['HTTP_AUTHORIZATION'].startswith('OAuth'): m = re.search(r'oauth_token="(\d+)"', request.META['HTTP_AUTHORIZATION']) if m: user_id = m.group(1) if 'oauth_token' in request.GET: user_id = request.GET['oauth_token'] if user_id: request.user = User.objects.get(pk=user_id) return view_func(request, *view_args, **view_kwargs) <commit_msg>Add more HTTP headers to GhettoOauth The official iPhone Twitter client uses HTTP_X_VERIFY_CREDENTIALS_AUTHORIZATION when it's connecting to image upload services.<commit_after>from django.contrib.auth.models import User import re class GhettoOAuthMiddleware(object): def process_view(self, request, view_func, view_args, view_kwargs): user_id = self._get_token_from_header(request, 'HTTP_AUTHORIZATION') if not user_id: user_id = self._get_token_from_header(request, 'HTTP_X_VERIFY_CREDENTIALS_AUTHORIZATION') if 'oauth_token' in request.GET: user_id = request.GET['oauth_token'] if user_id: request.user = User.objects.get(pk=user_id) return view_func(request, *view_args, **view_kwargs) def _get_token_from_header(self, request, header): if header in request.META and request.META[header].startswith('OAuth'): m = re.search(r'oauth_token="(\d+)"', request.META[header]) if m: return m.group(1)
a84bd0dd803243b20874137fdb2d72d52bcee984
app/views/post_view.py
app/views/post_view.py
from flask import render_template, redirect, url_for from flask_classy import FlaskView, route from flask_user import login_required from ..models import PostModel from ..forms import PostForm class Post(FlaskView): """ Here will handle post creations, delete and update.""" def get(self, entity_id): post = PostModel() post = post.get(entity_id) return render_template("post/post.html", post=post) @login_required @route("/new/", methods=["GET", "POST"]) def new(self): form = PostForm() if form.validate_on_submit(): post = PostModel(**form.data) post.put() return redirect(url_for("Post:get", entity_id=post.id)) return render_template("post/post_form.html", form=form, url="Post:new") @login_required @route("/edit/<entity_id>", methods=["GET", "POST"]) def edit(self, entity_id): post = PostModel() entity = post.get(entity_id) form = PostForm(**entity) if form.validate_on_submit(): post.update(entity_id, form.data) return redirect(url_for("Post:get", entity_id=entity_id)) return render_template("post/post_form.html", form=form, url="Post:edit", entity_id=entity_id)
from flask import render_template, redirect, url_for from flask_classy import FlaskView, route from flask_user import login_required, current_user from ..models import PostModel from ..forms import PostForm class Post(FlaskView): """ Here will handle post creations, delete and update.""" def get(self, entity_id): post = PostModel() post = post.get(entity_id) return render_template("post/post.html", post=post) @login_required @route("/new/", methods=["GET", "POST"]) def new(self): form = PostForm() if form.validate_on_submit(): post = PostModel(user=current_user.username, **form.data) post.put() current_user.add_post(post.id) return redirect(url_for("Post:get", entity_id=post.id)) return render_template("post/post_form.html", form=form, url="Post:new") @login_required @route("/edit/<entity_id>", methods=["GET", "POST"]) def edit(self, entity_id): post = PostModel() entity = post.get(entity_id) form = PostForm(**entity) if form.validate_on_submit(): post.update(entity_id, form.data) return redirect(url_for("Post:get", entity_id=entity_id)) return render_template("post/post_form.html", form=form, url="Post:edit", entity_id=entity_id)
Update post view to save username references and save a post id in user entity
Update post view to save username references and save a post id in user entity
Python
mit
oldani/nanodegree-blog,oldani/nanodegree-blog,oldani/nanodegree-blog
from flask import render_template, redirect, url_for from flask_classy import FlaskView, route from flask_user import login_required from ..models import PostModel from ..forms import PostForm class Post(FlaskView): """ Here will handle post creations, delete and update.""" def get(self, entity_id): post = PostModel() post = post.get(entity_id) return render_template("post/post.html", post=post) @login_required @route("/new/", methods=["GET", "POST"]) def new(self): form = PostForm() if form.validate_on_submit(): post = PostModel(**form.data) post.put() return redirect(url_for("Post:get", entity_id=post.id)) return render_template("post/post_form.html", form=form, url="Post:new") @login_required @route("/edit/<entity_id>", methods=["GET", "POST"]) def edit(self, entity_id): post = PostModel() entity = post.get(entity_id) form = PostForm(**entity) if form.validate_on_submit(): post.update(entity_id, form.data) return redirect(url_for("Post:get", entity_id=entity_id)) return render_template("post/post_form.html", form=form, url="Post:edit", entity_id=entity_id) Update post view to save username references and save a post id in user entity
from flask import render_template, redirect, url_for from flask_classy import FlaskView, route from flask_user import login_required, current_user from ..models import PostModel from ..forms import PostForm class Post(FlaskView): """ Here will handle post creations, delete and update.""" def get(self, entity_id): post = PostModel() post = post.get(entity_id) return render_template("post/post.html", post=post) @login_required @route("/new/", methods=["GET", "POST"]) def new(self): form = PostForm() if form.validate_on_submit(): post = PostModel(user=current_user.username, **form.data) post.put() current_user.add_post(post.id) return redirect(url_for("Post:get", entity_id=post.id)) return render_template("post/post_form.html", form=form, url="Post:new") @login_required @route("/edit/<entity_id>", methods=["GET", "POST"]) def edit(self, entity_id): post = PostModel() entity = post.get(entity_id) form = PostForm(**entity) if form.validate_on_submit(): post.update(entity_id, form.data) return redirect(url_for("Post:get", entity_id=entity_id)) return render_template("post/post_form.html", form=form, url="Post:edit", entity_id=entity_id)
<commit_before>from flask import render_template, redirect, url_for from flask_classy import FlaskView, route from flask_user import login_required from ..models import PostModel from ..forms import PostForm class Post(FlaskView): """ Here will handle post creations, delete and update.""" def get(self, entity_id): post = PostModel() post = post.get(entity_id) return render_template("post/post.html", post=post) @login_required @route("/new/", methods=["GET", "POST"]) def new(self): form = PostForm() if form.validate_on_submit(): post = PostModel(**form.data) post.put() return redirect(url_for("Post:get", entity_id=post.id)) return render_template("post/post_form.html", form=form, url="Post:new") @login_required @route("/edit/<entity_id>", methods=["GET", "POST"]) def edit(self, entity_id): post = PostModel() entity = post.get(entity_id) form = PostForm(**entity) if form.validate_on_submit(): post.update(entity_id, form.data) return redirect(url_for("Post:get", entity_id=entity_id)) return render_template("post/post_form.html", form=form, url="Post:edit", entity_id=entity_id) <commit_msg>Update post view to save username references and save a post id in user entity<commit_after>
from flask import render_template, redirect, url_for from flask_classy import FlaskView, route from flask_user import login_required, current_user from ..models import PostModel from ..forms import PostForm class Post(FlaskView): """ Here will handle post creations, delete and update.""" def get(self, entity_id): post = PostModel() post = post.get(entity_id) return render_template("post/post.html", post=post) @login_required @route("/new/", methods=["GET", "POST"]) def new(self): form = PostForm() if form.validate_on_submit(): post = PostModel(user=current_user.username, **form.data) post.put() current_user.add_post(post.id) return redirect(url_for("Post:get", entity_id=post.id)) return render_template("post/post_form.html", form=form, url="Post:new") @login_required @route("/edit/<entity_id>", methods=["GET", "POST"]) def edit(self, entity_id): post = PostModel() entity = post.get(entity_id) form = PostForm(**entity) if form.validate_on_submit(): post.update(entity_id, form.data) return redirect(url_for("Post:get", entity_id=entity_id)) return render_template("post/post_form.html", form=form, url="Post:edit", entity_id=entity_id)
from flask import render_template, redirect, url_for from flask_classy import FlaskView, route from flask_user import login_required from ..models import PostModel from ..forms import PostForm class Post(FlaskView): """ Here will handle post creations, delete and update.""" def get(self, entity_id): post = PostModel() post = post.get(entity_id) return render_template("post/post.html", post=post) @login_required @route("/new/", methods=["GET", "POST"]) def new(self): form = PostForm() if form.validate_on_submit(): post = PostModel(**form.data) post.put() return redirect(url_for("Post:get", entity_id=post.id)) return render_template("post/post_form.html", form=form, url="Post:new") @login_required @route("/edit/<entity_id>", methods=["GET", "POST"]) def edit(self, entity_id): post = PostModel() entity = post.get(entity_id) form = PostForm(**entity) if form.validate_on_submit(): post.update(entity_id, form.data) return redirect(url_for("Post:get", entity_id=entity_id)) return render_template("post/post_form.html", form=form, url="Post:edit", entity_id=entity_id) Update post view to save username references and save a post id in user entityfrom flask import render_template, redirect, url_for from flask_classy import FlaskView, route from flask_user import login_required, current_user from ..models import PostModel from ..forms import PostForm class Post(FlaskView): """ Here will handle post creations, delete and update.""" def get(self, entity_id): post = PostModel() post = post.get(entity_id) return render_template("post/post.html", post=post) @login_required @route("/new/", methods=["GET", "POST"]) def new(self): form = PostForm() if form.validate_on_submit(): post = PostModel(user=current_user.username, **form.data) post.put() current_user.add_post(post.id) return redirect(url_for("Post:get", entity_id=post.id)) return render_template("post/post_form.html", form=form, url="Post:new") @login_required @route("/edit/<entity_id>", methods=["GET", "POST"]) def edit(self, entity_id): post = PostModel() entity = post.get(entity_id) form = PostForm(**entity) if form.validate_on_submit(): post.update(entity_id, form.data) return redirect(url_for("Post:get", entity_id=entity_id)) return render_template("post/post_form.html", form=form, url="Post:edit", entity_id=entity_id)
<commit_before>from flask import render_template, redirect, url_for from flask_classy import FlaskView, route from flask_user import login_required from ..models import PostModel from ..forms import PostForm class Post(FlaskView): """ Here will handle post creations, delete and update.""" def get(self, entity_id): post = PostModel() post = post.get(entity_id) return render_template("post/post.html", post=post) @login_required @route("/new/", methods=["GET", "POST"]) def new(self): form = PostForm() if form.validate_on_submit(): post = PostModel(**form.data) post.put() return redirect(url_for("Post:get", entity_id=post.id)) return render_template("post/post_form.html", form=form, url="Post:new") @login_required @route("/edit/<entity_id>", methods=["GET", "POST"]) def edit(self, entity_id): post = PostModel() entity = post.get(entity_id) form = PostForm(**entity) if form.validate_on_submit(): post.update(entity_id, form.data) return redirect(url_for("Post:get", entity_id=entity_id)) return render_template("post/post_form.html", form=form, url="Post:edit", entity_id=entity_id) <commit_msg>Update post view to save username references and save a post id in user entity<commit_after>from flask import render_template, redirect, url_for from flask_classy import FlaskView, route from flask_user import login_required, current_user from ..models import PostModel from ..forms import PostForm class Post(FlaskView): """ Here will handle post creations, delete and update.""" def get(self, entity_id): post = PostModel() post = post.get(entity_id) return render_template("post/post.html", post=post) @login_required @route("/new/", methods=["GET", "POST"]) def new(self): form = PostForm() if form.validate_on_submit(): post = PostModel(user=current_user.username, **form.data) post.put() current_user.add_post(post.id) return redirect(url_for("Post:get", entity_id=post.id)) return render_template("post/post_form.html", form=form, url="Post:new") @login_required @route("/edit/<entity_id>", methods=["GET", "POST"]) def edit(self, entity_id): post = PostModel() entity = post.get(entity_id) form = PostForm(**entity) if form.validate_on_submit(): post.update(entity_id, form.data) return redirect(url_for("Post:get", entity_id=entity_id)) return render_template("post/post_form.html", form=form, url="Post:edit", entity_id=entity_id)
4688d48ceeb365174353ab710d03c39dda10a115
tssim/__init__.py
tssim/__init__.py
# -*- coding: utf-8 -*- __author__ = """Franz Woellert""" __email__ = 'franz.woellert@gmail.com' __version__ = '0.1.0'
# -*- coding: utf-8 -*- __author__ = """Franz Woellert""" __email__ = 'franz.woellert@gmail.com' __version__ = '0.1.0' from tssim.core.series import TimeSeries from tssim.core.function import TimeFunction from tssim.core.track import TimeTrack from tssim.functions import random
Adjust module and class references to accessible from package top level.
Adjust module and class references to accessible from package top level.
Python
mit
mansenfranzen/tssim
# -*- coding: utf-8 -*- __author__ = """Franz Woellert""" __email__ = 'franz.woellert@gmail.com' __version__ = '0.1.0' Adjust module and class references to accessible from package top level.
# -*- coding: utf-8 -*- __author__ = """Franz Woellert""" __email__ = 'franz.woellert@gmail.com' __version__ = '0.1.0' from tssim.core.series import TimeSeries from tssim.core.function import TimeFunction from tssim.core.track import TimeTrack from tssim.functions import random
<commit_before># -*- coding: utf-8 -*- __author__ = """Franz Woellert""" __email__ = 'franz.woellert@gmail.com' __version__ = '0.1.0' <commit_msg>Adjust module and class references to accessible from package top level.<commit_after>
# -*- coding: utf-8 -*- __author__ = """Franz Woellert""" __email__ = 'franz.woellert@gmail.com' __version__ = '0.1.0' from tssim.core.series import TimeSeries from tssim.core.function import TimeFunction from tssim.core.track import TimeTrack from tssim.functions import random
# -*- coding: utf-8 -*- __author__ = """Franz Woellert""" __email__ = 'franz.woellert@gmail.com' __version__ = '0.1.0' Adjust module and class references to accessible from package top level.# -*- coding: utf-8 -*- __author__ = """Franz Woellert""" __email__ = 'franz.woellert@gmail.com' __version__ = '0.1.0' from tssim.core.series import TimeSeries from tssim.core.function import TimeFunction from tssim.core.track import TimeTrack from tssim.functions import random
<commit_before># -*- coding: utf-8 -*- __author__ = """Franz Woellert""" __email__ = 'franz.woellert@gmail.com' __version__ = '0.1.0' <commit_msg>Adjust module and class references to accessible from package top level.<commit_after># -*- coding: utf-8 -*- __author__ = """Franz Woellert""" __email__ = 'franz.woellert@gmail.com' __version__ = '0.1.0' from tssim.core.series import TimeSeries from tssim.core.function import TimeFunction from tssim.core.track import TimeTrack from tssim.functions import random
88ca9a64468a15f7f5b1000a763a8b1c928ea7a1
kbkdna/cli.py
kbkdna/cli.py
#!/usr/bin/env python2 """\ Perform various simple manipulations on DNA sequences. Usage: dna len <seq> dna rc <seq> dna gc <seq> [--fraction] Commands: len: Print the length of the given DNA sequence. rc: Print the reverse-complement of the given DNA sequence. gc: Print the GC content of the given DNA sequence. Arguments: <seq>: The DNA sequence to work with. Options: --fraction For the 'gc' command, display the result as a raw fraction (e.g. a number between 0 and 1) rather than a percentage. """ from . import dna def main(): import docopt args = docopt.docopt(__doc__) seq = args['<seq>'] if args['len']: print len(seq) if args['rc']: print dna.reverse_complement(seq) if args['gc']: gc = dna.gc_content(seq) if args['--fraction']: print gc else: print '{.2f}\%'.format(gc / 100)
#!/usr/bin/env python2 """\ Perform various simple manipulations on DNA sequences. Usage: dna len <seq> dna rc <seq> dna gc <seq> [--fraction] Commands: len: Print the length of the given DNA sequence. rc: Print the reverse-complement of the given DNA sequence. gc: Print the GC content of the given DNA sequence. Arguments: <seq>: The DNA sequence to work with. Options: --fraction For the 'gc' command, display the result as a raw fraction (e.g. a number between 0 and 1) rather than a percentage. """ from . import dna def main(): import docopt args = docopt.docopt(__doc__) seq = args['<seq>'] if args['len']: print len(seq) if args['rc']: print dna.reverse_complement(seq) if args['gc']: gc = dna.gc_content(seq) if args['--fraction']: print gc else: print '{:.2f}%'.format(gc / 100.)
Fix a bug in the GC% formatting.
Fix a bug in the GC% formatting.
Python
mit
kalekundert/kbkdna
#!/usr/bin/env python2 """\ Perform various simple manipulations on DNA sequences. Usage: dna len <seq> dna rc <seq> dna gc <seq> [--fraction] Commands: len: Print the length of the given DNA sequence. rc: Print the reverse-complement of the given DNA sequence. gc: Print the GC content of the given DNA sequence. Arguments: <seq>: The DNA sequence to work with. Options: --fraction For the 'gc' command, display the result as a raw fraction (e.g. a number between 0 and 1) rather than a percentage. """ from . import dna def main(): import docopt args = docopt.docopt(__doc__) seq = args['<seq>'] if args['len']: print len(seq) if args['rc']: print dna.reverse_complement(seq) if args['gc']: gc = dna.gc_content(seq) if args['--fraction']: print gc else: print '{.2f}\%'.format(gc / 100) Fix a bug in the GC% formatting.
#!/usr/bin/env python2 """\ Perform various simple manipulations on DNA sequences. Usage: dna len <seq> dna rc <seq> dna gc <seq> [--fraction] Commands: len: Print the length of the given DNA sequence. rc: Print the reverse-complement of the given DNA sequence. gc: Print the GC content of the given DNA sequence. Arguments: <seq>: The DNA sequence to work with. Options: --fraction For the 'gc' command, display the result as a raw fraction (e.g. a number between 0 and 1) rather than a percentage. """ from . import dna def main(): import docopt args = docopt.docopt(__doc__) seq = args['<seq>'] if args['len']: print len(seq) if args['rc']: print dna.reverse_complement(seq) if args['gc']: gc = dna.gc_content(seq) if args['--fraction']: print gc else: print '{:.2f}%'.format(gc / 100.)
<commit_before>#!/usr/bin/env python2 """\ Perform various simple manipulations on DNA sequences. Usage: dna len <seq> dna rc <seq> dna gc <seq> [--fraction] Commands: len: Print the length of the given DNA sequence. rc: Print the reverse-complement of the given DNA sequence. gc: Print the GC content of the given DNA sequence. Arguments: <seq>: The DNA sequence to work with. Options: --fraction For the 'gc' command, display the result as a raw fraction (e.g. a number between 0 and 1) rather than a percentage. """ from . import dna def main(): import docopt args = docopt.docopt(__doc__) seq = args['<seq>'] if args['len']: print len(seq) if args['rc']: print dna.reverse_complement(seq) if args['gc']: gc = dna.gc_content(seq) if args['--fraction']: print gc else: print '{.2f}\%'.format(gc / 100) <commit_msg>Fix a bug in the GC% formatting.<commit_after>
#!/usr/bin/env python2 """\ Perform various simple manipulations on DNA sequences. Usage: dna len <seq> dna rc <seq> dna gc <seq> [--fraction] Commands: len: Print the length of the given DNA sequence. rc: Print the reverse-complement of the given DNA sequence. gc: Print the GC content of the given DNA sequence. Arguments: <seq>: The DNA sequence to work with. Options: --fraction For the 'gc' command, display the result as a raw fraction (e.g. a number between 0 and 1) rather than a percentage. """ from . import dna def main(): import docopt args = docopt.docopt(__doc__) seq = args['<seq>'] if args['len']: print len(seq) if args['rc']: print dna.reverse_complement(seq) if args['gc']: gc = dna.gc_content(seq) if args['--fraction']: print gc else: print '{:.2f}%'.format(gc / 100.)
#!/usr/bin/env python2 """\ Perform various simple manipulations on DNA sequences. Usage: dna len <seq> dna rc <seq> dna gc <seq> [--fraction] Commands: len: Print the length of the given DNA sequence. rc: Print the reverse-complement of the given DNA sequence. gc: Print the GC content of the given DNA sequence. Arguments: <seq>: The DNA sequence to work with. Options: --fraction For the 'gc' command, display the result as a raw fraction (e.g. a number between 0 and 1) rather than a percentage. """ from . import dna def main(): import docopt args = docopt.docopt(__doc__) seq = args['<seq>'] if args['len']: print len(seq) if args['rc']: print dna.reverse_complement(seq) if args['gc']: gc = dna.gc_content(seq) if args['--fraction']: print gc else: print '{.2f}\%'.format(gc / 100) Fix a bug in the GC% formatting.#!/usr/bin/env python2 """\ Perform various simple manipulations on DNA sequences. Usage: dna len <seq> dna rc <seq> dna gc <seq> [--fraction] Commands: len: Print the length of the given DNA sequence. rc: Print the reverse-complement of the given DNA sequence. gc: Print the GC content of the given DNA sequence. Arguments: <seq>: The DNA sequence to work with. Options: --fraction For the 'gc' command, display the result as a raw fraction (e.g. a number between 0 and 1) rather than a percentage. """ from . import dna def main(): import docopt args = docopt.docopt(__doc__) seq = args['<seq>'] if args['len']: print len(seq) if args['rc']: print dna.reverse_complement(seq) if args['gc']: gc = dna.gc_content(seq) if args['--fraction']: print gc else: print '{:.2f}%'.format(gc / 100.)
<commit_before>#!/usr/bin/env python2 """\ Perform various simple manipulations on DNA sequences. Usage: dna len <seq> dna rc <seq> dna gc <seq> [--fraction] Commands: len: Print the length of the given DNA sequence. rc: Print the reverse-complement of the given DNA sequence. gc: Print the GC content of the given DNA sequence. Arguments: <seq>: The DNA sequence to work with. Options: --fraction For the 'gc' command, display the result as a raw fraction (e.g. a number between 0 and 1) rather than a percentage. """ from . import dna def main(): import docopt args = docopt.docopt(__doc__) seq = args['<seq>'] if args['len']: print len(seq) if args['rc']: print dna.reverse_complement(seq) if args['gc']: gc = dna.gc_content(seq) if args['--fraction']: print gc else: print '{.2f}\%'.format(gc / 100) <commit_msg>Fix a bug in the GC% formatting.<commit_after>#!/usr/bin/env python2 """\ Perform various simple manipulations on DNA sequences. Usage: dna len <seq> dna rc <seq> dna gc <seq> [--fraction] Commands: len: Print the length of the given DNA sequence. rc: Print the reverse-complement of the given DNA sequence. gc: Print the GC content of the given DNA sequence. Arguments: <seq>: The DNA sequence to work with. Options: --fraction For the 'gc' command, display the result as a raw fraction (e.g. a number between 0 and 1) rather than a percentage. """ from . import dna def main(): import docopt args = docopt.docopt(__doc__) seq = args['<seq>'] if args['len']: print len(seq) if args['rc']: print dna.reverse_complement(seq) if args['gc']: gc = dna.gc_content(seq) if args['--fraction']: print gc else: print '{:.2f}%'.format(gc / 100.)
57a02c9e3bb0ed82ee84a08dbadba0dac4e7f2f4
test_insertion_sort.py
test_insertion_sort.py
from random import shuffle import pytest from insertion_sort import in_sort def test_insertion_sort(): expected = range(20) unsorted = expected[:] shuffle(unsorted) in_sort(unsorted) actual = unsorted assert expected == actual def test_insertion_sort_wrong_type(): with pytest.raises(TypeError): in_sort('some string')
from random import shuffle import pytest from insertion_sort import in_sort def test_insertion_sort(): expected = range(20) unsorted = expected[:] shuffle(unsorted) in_sort(unsorted) actual = unsorted assert expected == actual def test_insertion_sort_with_duplicates(): expected = [1, 3, 3, 6, 7, 8, 8, 8] unsorted = expected[:] shuffle(unsorted) in_sort(unsorted) actual = unsorted assert expected == actual def test_insertion_sort_wrong_type(): with pytest.raises(TypeError): in_sort('some string')
Add insertion sort with duplicate values test
Add insertion sort with duplicate values test
Python
mit
jonathanstallings/data-structures
from random import shuffle import pytest from insertion_sort import in_sort def test_insertion_sort(): expected = range(20) unsorted = expected[:] shuffle(unsorted) in_sort(unsorted) actual = unsorted assert expected == actual def test_insertion_sort_wrong_type(): with pytest.raises(TypeError): in_sort('some string') Add insertion sort with duplicate values test
from random import shuffle import pytest from insertion_sort import in_sort def test_insertion_sort(): expected = range(20) unsorted = expected[:] shuffle(unsorted) in_sort(unsorted) actual = unsorted assert expected == actual def test_insertion_sort_with_duplicates(): expected = [1, 3, 3, 6, 7, 8, 8, 8] unsorted = expected[:] shuffle(unsorted) in_sort(unsorted) actual = unsorted assert expected == actual def test_insertion_sort_wrong_type(): with pytest.raises(TypeError): in_sort('some string')
<commit_before>from random import shuffle import pytest from insertion_sort import in_sort def test_insertion_sort(): expected = range(20) unsorted = expected[:] shuffle(unsorted) in_sort(unsorted) actual = unsorted assert expected == actual def test_insertion_sort_wrong_type(): with pytest.raises(TypeError): in_sort('some string') <commit_msg>Add insertion sort with duplicate values test<commit_after>
from random import shuffle import pytest from insertion_sort import in_sort def test_insertion_sort(): expected = range(20) unsorted = expected[:] shuffle(unsorted) in_sort(unsorted) actual = unsorted assert expected == actual def test_insertion_sort_with_duplicates(): expected = [1, 3, 3, 6, 7, 8, 8, 8] unsorted = expected[:] shuffle(unsorted) in_sort(unsorted) actual = unsorted assert expected == actual def test_insertion_sort_wrong_type(): with pytest.raises(TypeError): in_sort('some string')
from random import shuffle import pytest from insertion_sort import in_sort def test_insertion_sort(): expected = range(20) unsorted = expected[:] shuffle(unsorted) in_sort(unsorted) actual = unsorted assert expected == actual def test_insertion_sort_wrong_type(): with pytest.raises(TypeError): in_sort('some string') Add insertion sort with duplicate values testfrom random import shuffle import pytest from insertion_sort import in_sort def test_insertion_sort(): expected = range(20) unsorted = expected[:] shuffle(unsorted) in_sort(unsorted) actual = unsorted assert expected == actual def test_insertion_sort_with_duplicates(): expected = [1, 3, 3, 6, 7, 8, 8, 8] unsorted = expected[:] shuffle(unsorted) in_sort(unsorted) actual = unsorted assert expected == actual def test_insertion_sort_wrong_type(): with pytest.raises(TypeError): in_sort('some string')
<commit_before>from random import shuffle import pytest from insertion_sort import in_sort def test_insertion_sort(): expected = range(20) unsorted = expected[:] shuffle(unsorted) in_sort(unsorted) actual = unsorted assert expected == actual def test_insertion_sort_wrong_type(): with pytest.raises(TypeError): in_sort('some string') <commit_msg>Add insertion sort with duplicate values test<commit_after>from random import shuffle import pytest from insertion_sort import in_sort def test_insertion_sort(): expected = range(20) unsorted = expected[:] shuffle(unsorted) in_sort(unsorted) actual = unsorted assert expected == actual def test_insertion_sort_with_duplicates(): expected = [1, 3, 3, 6, 7, 8, 8, 8] unsorted = expected[:] shuffle(unsorted) in_sort(unsorted) actual = unsorted assert expected == actual def test_insertion_sort_wrong_type(): with pytest.raises(TypeError): in_sort('some string')
a6a8141bcc40ac124a0425a63594578538852a02
linter.py
linter.py
# # linter.py # Linter for SublimeLinter3, a code checking framework for Sublime Text 3 # # Written by Ilya Akhmadullin # Copyright (c) 2013 Ilya Akhmadullin # # License: MIT # """This module exports the jscs plugin class.""" from SublimeLinter.lint import Linter class Jscs(Linter): """Provides an interface to jscs.""" syntax = ('javascript', 'html', 'html 5') cmd = 'jscs -r checkstyle' config_file = ('-c', '.jscs.json') regex = ( r'^\s+?<error line="(?P<line>\d+)" ' r'column="(?P<col>\d+)" ' # jscs always reports with error severity; show as warning r'severity="(?P<warning>error)" ' r'message="(?P<message>.+?)"' ) multiline = True selectors = {'html': 'source.js.embedded.html'} tempfile_suffix = 'js'
# # linter.py # Linter for SublimeLinter3, a code checking framework for Sublime Text 3 # # Written by Ilya Akhmadullin # Copyright (c) 2013 Ilya Akhmadullin # # License: MIT # """This module exports the jscs plugin class.""" from SublimeLinter.lint import Linter class Jscs(Linter): """Provides an interface to jscs.""" syntax = ('javascript', 'html', 'html 5') cmd = 'jscs -r checkstyle' regex = ( r'^\s+?<error line="(?P<line>\d+)" ' r'column="(?P<col>\d+)" ' # jscs always reports with error severity; show as warning r'severity="(?P<warning>error)" ' r'message="(?P<message>.+?)"' ) multiline = True selectors = {'html': 'source.js.embedded.html'} tempfile_suffix = 'js' config_file = ('--config', '.jscs.json', '~')
Use the full option name for clarity and also search in the user's home directory
Use the full option name for clarity and also search in the user's home directory
Python
mit
roberthoog/SublimeLinter-jscs,SublimeLinter/SublimeLinter-jscs
# # linter.py # Linter for SublimeLinter3, a code checking framework for Sublime Text 3 # # Written by Ilya Akhmadullin # Copyright (c) 2013 Ilya Akhmadullin # # License: MIT # """This module exports the jscs plugin class.""" from SublimeLinter.lint import Linter class Jscs(Linter): """Provides an interface to jscs.""" syntax = ('javascript', 'html', 'html 5') cmd = 'jscs -r checkstyle' config_file = ('-c', '.jscs.json') regex = ( r'^\s+?<error line="(?P<line>\d+)" ' r'column="(?P<col>\d+)" ' # jscs always reports with error severity; show as warning r'severity="(?P<warning>error)" ' r'message="(?P<message>.+?)"' ) multiline = True selectors = {'html': 'source.js.embedded.html'} tempfile_suffix = 'js' Use the full option name for clarity and also search in the user's home directory
# # linter.py # Linter for SublimeLinter3, a code checking framework for Sublime Text 3 # # Written by Ilya Akhmadullin # Copyright (c) 2013 Ilya Akhmadullin # # License: MIT # """This module exports the jscs plugin class.""" from SublimeLinter.lint import Linter class Jscs(Linter): """Provides an interface to jscs.""" syntax = ('javascript', 'html', 'html 5') cmd = 'jscs -r checkstyle' regex = ( r'^\s+?<error line="(?P<line>\d+)" ' r'column="(?P<col>\d+)" ' # jscs always reports with error severity; show as warning r'severity="(?P<warning>error)" ' r'message="(?P<message>.+?)"' ) multiline = True selectors = {'html': 'source.js.embedded.html'} tempfile_suffix = 'js' config_file = ('--config', '.jscs.json', '~')
<commit_before># # linter.py # Linter for SublimeLinter3, a code checking framework for Sublime Text 3 # # Written by Ilya Akhmadullin # Copyright (c) 2013 Ilya Akhmadullin # # License: MIT # """This module exports the jscs plugin class.""" from SublimeLinter.lint import Linter class Jscs(Linter): """Provides an interface to jscs.""" syntax = ('javascript', 'html', 'html 5') cmd = 'jscs -r checkstyle' config_file = ('-c', '.jscs.json') regex = ( r'^\s+?<error line="(?P<line>\d+)" ' r'column="(?P<col>\d+)" ' # jscs always reports with error severity; show as warning r'severity="(?P<warning>error)" ' r'message="(?P<message>.+?)"' ) multiline = True selectors = {'html': 'source.js.embedded.html'} tempfile_suffix = 'js' <commit_msg>Use the full option name for clarity and also search in the user's home directory<commit_after>
# # linter.py # Linter for SublimeLinter3, a code checking framework for Sublime Text 3 # # Written by Ilya Akhmadullin # Copyright (c) 2013 Ilya Akhmadullin # # License: MIT # """This module exports the jscs plugin class.""" from SublimeLinter.lint import Linter class Jscs(Linter): """Provides an interface to jscs.""" syntax = ('javascript', 'html', 'html 5') cmd = 'jscs -r checkstyle' regex = ( r'^\s+?<error line="(?P<line>\d+)" ' r'column="(?P<col>\d+)" ' # jscs always reports with error severity; show as warning r'severity="(?P<warning>error)" ' r'message="(?P<message>.+?)"' ) multiline = True selectors = {'html': 'source.js.embedded.html'} tempfile_suffix = 'js' config_file = ('--config', '.jscs.json', '~')
# # linter.py # Linter for SublimeLinter3, a code checking framework for Sublime Text 3 # # Written by Ilya Akhmadullin # Copyright (c) 2013 Ilya Akhmadullin # # License: MIT # """This module exports the jscs plugin class.""" from SublimeLinter.lint import Linter class Jscs(Linter): """Provides an interface to jscs.""" syntax = ('javascript', 'html', 'html 5') cmd = 'jscs -r checkstyle' config_file = ('-c', '.jscs.json') regex = ( r'^\s+?<error line="(?P<line>\d+)" ' r'column="(?P<col>\d+)" ' # jscs always reports with error severity; show as warning r'severity="(?P<warning>error)" ' r'message="(?P<message>.+?)"' ) multiline = True selectors = {'html': 'source.js.embedded.html'} tempfile_suffix = 'js' Use the full option name for clarity and also search in the user's home directory# # linter.py # Linter for SublimeLinter3, a code checking framework for Sublime Text 3 # # Written by Ilya Akhmadullin # Copyright (c) 2013 Ilya Akhmadullin # # License: MIT # """This module exports the jscs plugin class.""" from SublimeLinter.lint import Linter class Jscs(Linter): """Provides an interface to jscs.""" syntax = ('javascript', 'html', 'html 5') cmd = 'jscs -r checkstyle' regex = ( r'^\s+?<error line="(?P<line>\d+)" ' r'column="(?P<col>\d+)" ' # jscs always reports with error severity; show as warning r'severity="(?P<warning>error)" ' r'message="(?P<message>.+?)"' ) multiline = True selectors = {'html': 'source.js.embedded.html'} tempfile_suffix = 'js' config_file = ('--config', '.jscs.json', '~')
<commit_before># # linter.py # Linter for SublimeLinter3, a code checking framework for Sublime Text 3 # # Written by Ilya Akhmadullin # Copyright (c) 2013 Ilya Akhmadullin # # License: MIT # """This module exports the jscs plugin class.""" from SublimeLinter.lint import Linter class Jscs(Linter): """Provides an interface to jscs.""" syntax = ('javascript', 'html', 'html 5') cmd = 'jscs -r checkstyle' config_file = ('-c', '.jscs.json') regex = ( r'^\s+?<error line="(?P<line>\d+)" ' r'column="(?P<col>\d+)" ' # jscs always reports with error severity; show as warning r'severity="(?P<warning>error)" ' r'message="(?P<message>.+?)"' ) multiline = True selectors = {'html': 'source.js.embedded.html'} tempfile_suffix = 'js' <commit_msg>Use the full option name for clarity and also search in the user's home directory<commit_after># # linter.py # Linter for SublimeLinter3, a code checking framework for Sublime Text 3 # # Written by Ilya Akhmadullin # Copyright (c) 2013 Ilya Akhmadullin # # License: MIT # """This module exports the jscs plugin class.""" from SublimeLinter.lint import Linter class Jscs(Linter): """Provides an interface to jscs.""" syntax = ('javascript', 'html', 'html 5') cmd = 'jscs -r checkstyle' regex = ( r'^\s+?<error line="(?P<line>\d+)" ' r'column="(?P<col>\d+)" ' # jscs always reports with error severity; show as warning r'severity="(?P<warning>error)" ' r'message="(?P<message>.+?)"' ) multiline = True selectors = {'html': 'source.js.embedded.html'} tempfile_suffix = 'js' config_file = ('--config', '.jscs.json', '~')
5bc0a40ccd05d3226181d29c0c5cecb0287cb56c
brightml/features.py
brightml/features.py
# todo: chargedness of battery import time from datetime import datetime import numpy as np try: from whereami.predict import Predicter p = Predicter() except ImportError: p = None from brightml.battery import get_battery_feature from brightml.xdisplay import Display d = Display() DATE_FORMAT = '%Y-%m-%dT%H:%M:%S%z' def get_ambient_light(): try: # please, if your ambient light sensor doesn't work, post the path in the issues on github with open("/sys/devices/platform/applesmc.768/light") as f: return int(f.read()[1:-1].split(",")[0]) except: return np.nan def get_time_features(): now = datetime.strptime(time.strftime(DATE_FORMAT, time.localtime()), DATE_FORMAT) data = { "datetime_hour": now.hour, "datetime_timezone": str(now.tzinfo), "datetime_date": str(now.date()), "datetime_full": str(now) } return data def get_features(): if p is None: whereami_value = np.nan else: whereami_value = p.predicted_value or p.predict() data = { "ambient_light": get_ambient_light(), "whereami": whereami_value } data.update(get_time_features()) data.update(d.last_value or d.get_window_info()) data.update({"battery": get_battery_feature()}) return data
# todo: chargedness of battery import time from datetime import datetime import numpy as np try: from whereami.predict import Predicter p = Predicter() except ImportError: p = None from brightml.battery import get_battery_feature from brightml.xdisplay import Display d = Display() DATE_FORMAT = '%Y-%m-%dT%H:%M:%S%z' def get_ambient_light(): try: # please, if your ambient light sensor doesn't work, post the path in the issues on github with open("/sys/bus/iio/devices/iio:device0/in_illuminance0_input") as f: return int(f.read()) except: return np.nan def get_time_features(): now = datetime.strptime(time.strftime(DATE_FORMAT, time.localtime()), DATE_FORMAT) data = { "datetime_hour": now.hour, "datetime_timezone": str(now.tzinfo), "datetime_date": str(now.date()), "datetime_full": str(now) } return data def get_features(): if p is None: whereami_value = np.nan else: whereami_value = p.predicted_value or p.predict() data = { "ambient_light": get_ambient_light(), "whereami": whereami_value } data.update(get_time_features()) data.update(d.last_value or d.get_window_info()) data.update({"battery": get_battery_feature()}) return data
Use generic path for ALS on iio device0.
Use generic path for ALS on iio device0.
Python
mit
kootenpv/brightml,kootenpv/brightml
# todo: chargedness of battery import time from datetime import datetime import numpy as np try: from whereami.predict import Predicter p = Predicter() except ImportError: p = None from brightml.battery import get_battery_feature from brightml.xdisplay import Display d = Display() DATE_FORMAT = '%Y-%m-%dT%H:%M:%S%z' def get_ambient_light(): try: # please, if your ambient light sensor doesn't work, post the path in the issues on github with open("/sys/devices/platform/applesmc.768/light") as f: return int(f.read()[1:-1].split(",")[0]) except: return np.nan def get_time_features(): now = datetime.strptime(time.strftime(DATE_FORMAT, time.localtime()), DATE_FORMAT) data = { "datetime_hour": now.hour, "datetime_timezone": str(now.tzinfo), "datetime_date": str(now.date()), "datetime_full": str(now) } return data def get_features(): if p is None: whereami_value = np.nan else: whereami_value = p.predicted_value or p.predict() data = { "ambient_light": get_ambient_light(), "whereami": whereami_value } data.update(get_time_features()) data.update(d.last_value or d.get_window_info()) data.update({"battery": get_battery_feature()}) return data Use generic path for ALS on iio device0.
# todo: chargedness of battery import time from datetime import datetime import numpy as np try: from whereami.predict import Predicter p = Predicter() except ImportError: p = None from brightml.battery import get_battery_feature from brightml.xdisplay import Display d = Display() DATE_FORMAT = '%Y-%m-%dT%H:%M:%S%z' def get_ambient_light(): try: # please, if your ambient light sensor doesn't work, post the path in the issues on github with open("/sys/bus/iio/devices/iio:device0/in_illuminance0_input") as f: return int(f.read()) except: return np.nan def get_time_features(): now = datetime.strptime(time.strftime(DATE_FORMAT, time.localtime()), DATE_FORMAT) data = { "datetime_hour": now.hour, "datetime_timezone": str(now.tzinfo), "datetime_date": str(now.date()), "datetime_full": str(now) } return data def get_features(): if p is None: whereami_value = np.nan else: whereami_value = p.predicted_value or p.predict() data = { "ambient_light": get_ambient_light(), "whereami": whereami_value } data.update(get_time_features()) data.update(d.last_value or d.get_window_info()) data.update({"battery": get_battery_feature()}) return data
<commit_before># todo: chargedness of battery import time from datetime import datetime import numpy as np try: from whereami.predict import Predicter p = Predicter() except ImportError: p = None from brightml.battery import get_battery_feature from brightml.xdisplay import Display d = Display() DATE_FORMAT = '%Y-%m-%dT%H:%M:%S%z' def get_ambient_light(): try: # please, if your ambient light sensor doesn't work, post the path in the issues on github with open("/sys/devices/platform/applesmc.768/light") as f: return int(f.read()[1:-1].split(",")[0]) except: return np.nan def get_time_features(): now = datetime.strptime(time.strftime(DATE_FORMAT, time.localtime()), DATE_FORMAT) data = { "datetime_hour": now.hour, "datetime_timezone": str(now.tzinfo), "datetime_date": str(now.date()), "datetime_full": str(now) } return data def get_features(): if p is None: whereami_value = np.nan else: whereami_value = p.predicted_value or p.predict() data = { "ambient_light": get_ambient_light(), "whereami": whereami_value } data.update(get_time_features()) data.update(d.last_value or d.get_window_info()) data.update({"battery": get_battery_feature()}) return data <commit_msg>Use generic path for ALS on iio device0.<commit_after>
# todo: chargedness of battery import time from datetime import datetime import numpy as np try: from whereami.predict import Predicter p = Predicter() except ImportError: p = None from brightml.battery import get_battery_feature from brightml.xdisplay import Display d = Display() DATE_FORMAT = '%Y-%m-%dT%H:%M:%S%z' def get_ambient_light(): try: # please, if your ambient light sensor doesn't work, post the path in the issues on github with open("/sys/bus/iio/devices/iio:device0/in_illuminance0_input") as f: return int(f.read()) except: return np.nan def get_time_features(): now = datetime.strptime(time.strftime(DATE_FORMAT, time.localtime()), DATE_FORMAT) data = { "datetime_hour": now.hour, "datetime_timezone": str(now.tzinfo), "datetime_date": str(now.date()), "datetime_full": str(now) } return data def get_features(): if p is None: whereami_value = np.nan else: whereami_value = p.predicted_value or p.predict() data = { "ambient_light": get_ambient_light(), "whereami": whereami_value } data.update(get_time_features()) data.update(d.last_value or d.get_window_info()) data.update({"battery": get_battery_feature()}) return data
# todo: chargedness of battery import time from datetime import datetime import numpy as np try: from whereami.predict import Predicter p = Predicter() except ImportError: p = None from brightml.battery import get_battery_feature from brightml.xdisplay import Display d = Display() DATE_FORMAT = '%Y-%m-%dT%H:%M:%S%z' def get_ambient_light(): try: # please, if your ambient light sensor doesn't work, post the path in the issues on github with open("/sys/devices/platform/applesmc.768/light") as f: return int(f.read()[1:-1].split(",")[0]) except: return np.nan def get_time_features(): now = datetime.strptime(time.strftime(DATE_FORMAT, time.localtime()), DATE_FORMAT) data = { "datetime_hour": now.hour, "datetime_timezone": str(now.tzinfo), "datetime_date": str(now.date()), "datetime_full": str(now) } return data def get_features(): if p is None: whereami_value = np.nan else: whereami_value = p.predicted_value or p.predict() data = { "ambient_light": get_ambient_light(), "whereami": whereami_value } data.update(get_time_features()) data.update(d.last_value or d.get_window_info()) data.update({"battery": get_battery_feature()}) return data Use generic path for ALS on iio device0.# todo: chargedness of battery import time from datetime import datetime import numpy as np try: from whereami.predict import Predicter p = Predicter() except ImportError: p = None from brightml.battery import get_battery_feature from brightml.xdisplay import Display d = Display() DATE_FORMAT = '%Y-%m-%dT%H:%M:%S%z' def get_ambient_light(): try: # please, if your ambient light sensor doesn't work, post the path in the issues on github with open("/sys/bus/iio/devices/iio:device0/in_illuminance0_input") as f: return int(f.read()) except: return np.nan def get_time_features(): now = datetime.strptime(time.strftime(DATE_FORMAT, time.localtime()), DATE_FORMAT) data = { "datetime_hour": now.hour, "datetime_timezone": str(now.tzinfo), "datetime_date": str(now.date()), "datetime_full": str(now) } return data def get_features(): if p is None: whereami_value = np.nan else: whereami_value = p.predicted_value or p.predict() data = { "ambient_light": get_ambient_light(), "whereami": whereami_value } data.update(get_time_features()) data.update(d.last_value or d.get_window_info()) data.update({"battery": get_battery_feature()}) return data
<commit_before># todo: chargedness of battery import time from datetime import datetime import numpy as np try: from whereami.predict import Predicter p = Predicter() except ImportError: p = None from brightml.battery import get_battery_feature from brightml.xdisplay import Display d = Display() DATE_FORMAT = '%Y-%m-%dT%H:%M:%S%z' def get_ambient_light(): try: # please, if your ambient light sensor doesn't work, post the path in the issues on github with open("/sys/devices/platform/applesmc.768/light") as f: return int(f.read()[1:-1].split(",")[0]) except: return np.nan def get_time_features(): now = datetime.strptime(time.strftime(DATE_FORMAT, time.localtime()), DATE_FORMAT) data = { "datetime_hour": now.hour, "datetime_timezone": str(now.tzinfo), "datetime_date": str(now.date()), "datetime_full": str(now) } return data def get_features(): if p is None: whereami_value = np.nan else: whereami_value = p.predicted_value or p.predict() data = { "ambient_light": get_ambient_light(), "whereami": whereami_value } data.update(get_time_features()) data.update(d.last_value or d.get_window_info()) data.update({"battery": get_battery_feature()}) return data <commit_msg>Use generic path for ALS on iio device0.<commit_after># todo: chargedness of battery import time from datetime import datetime import numpy as np try: from whereami.predict import Predicter p = Predicter() except ImportError: p = None from brightml.battery import get_battery_feature from brightml.xdisplay import Display d = Display() DATE_FORMAT = '%Y-%m-%dT%H:%M:%S%z' def get_ambient_light(): try: # please, if your ambient light sensor doesn't work, post the path in the issues on github with open("/sys/bus/iio/devices/iio:device0/in_illuminance0_input") as f: return int(f.read()) except: return np.nan def get_time_features(): now = datetime.strptime(time.strftime(DATE_FORMAT, time.localtime()), DATE_FORMAT) data = { "datetime_hour": now.hour, "datetime_timezone": str(now.tzinfo), "datetime_date": str(now.date()), "datetime_full": str(now) } return data def get_features(): if p is None: whereami_value = np.nan else: whereami_value = p.predicted_value or p.predict() data = { "ambient_light": get_ambient_light(), "whereami": whereami_value } data.update(get_time_features()) data.update(d.last_value or d.get_window_info()) data.update({"battery": get_battery_feature()}) return data
ce92ad058f24e884e196e793027c7a53e00739e8
memory.py
memory.py
class Memory(object): def __init__(self, size): self.size = size self.memory = bytearray([0] * size) def read(self, addr, count): if addr + count > len(self.memory): raise Exception('read exceeds memory bounds') return str(self.memory[addr:addr+count]) def write(self, addr, buffer): if addr + len(buffer) > len(self.memory): raise Exception('write exceeds memory bounds') self.memory[addr:addr+len(buffer)] = buffer def dump(self): print repr(self.memory)
class Memory(object): def __init__(self, size): self.size = size self.memory = bytearray([0] * size) def read(self, addr, count): if addr + count > self.size: raise Exception('read exceeds memory bounds') return str(self.memory[addr:addr+count]) def write(self, addr, buffer): if addr + len(buffer) > self.size: raise Exception('write exceeds memory bounds') self.memory[addr:addr+len(buffer)] = buffer def dump(self): print repr(self.memory)
Use Memory.size field for read/write checks
Use Memory.size field for read/write checks
Python
mit
mossberg/spym,mossberg/spym
class Memory(object): def __init__(self, size): self.size = size self.memory = bytearray([0] * size) def read(self, addr, count): if addr + count > len(self.memory): raise Exception('read exceeds memory bounds') return str(self.memory[addr:addr+count]) def write(self, addr, buffer): if addr + len(buffer) > len(self.memory): raise Exception('write exceeds memory bounds') self.memory[addr:addr+len(buffer)] = buffer def dump(self): print repr(self.memory) Use Memory.size field for read/write checks
class Memory(object): def __init__(self, size): self.size = size self.memory = bytearray([0] * size) def read(self, addr, count): if addr + count > self.size: raise Exception('read exceeds memory bounds') return str(self.memory[addr:addr+count]) def write(self, addr, buffer): if addr + len(buffer) > self.size: raise Exception('write exceeds memory bounds') self.memory[addr:addr+len(buffer)] = buffer def dump(self): print repr(self.memory)
<commit_before>class Memory(object): def __init__(self, size): self.size = size self.memory = bytearray([0] * size) def read(self, addr, count): if addr + count > len(self.memory): raise Exception('read exceeds memory bounds') return str(self.memory[addr:addr+count]) def write(self, addr, buffer): if addr + len(buffer) > len(self.memory): raise Exception('write exceeds memory bounds') self.memory[addr:addr+len(buffer)] = buffer def dump(self): print repr(self.memory) <commit_msg>Use Memory.size field for read/write checks<commit_after>
class Memory(object): def __init__(self, size): self.size = size self.memory = bytearray([0] * size) def read(self, addr, count): if addr + count > self.size: raise Exception('read exceeds memory bounds') return str(self.memory[addr:addr+count]) def write(self, addr, buffer): if addr + len(buffer) > self.size: raise Exception('write exceeds memory bounds') self.memory[addr:addr+len(buffer)] = buffer def dump(self): print repr(self.memory)
class Memory(object): def __init__(self, size): self.size = size self.memory = bytearray([0] * size) def read(self, addr, count): if addr + count > len(self.memory): raise Exception('read exceeds memory bounds') return str(self.memory[addr:addr+count]) def write(self, addr, buffer): if addr + len(buffer) > len(self.memory): raise Exception('write exceeds memory bounds') self.memory[addr:addr+len(buffer)] = buffer def dump(self): print repr(self.memory) Use Memory.size field for read/write checksclass Memory(object): def __init__(self, size): self.size = size self.memory = bytearray([0] * size) def read(self, addr, count): if addr + count > self.size: raise Exception('read exceeds memory bounds') return str(self.memory[addr:addr+count]) def write(self, addr, buffer): if addr + len(buffer) > self.size: raise Exception('write exceeds memory bounds') self.memory[addr:addr+len(buffer)] = buffer def dump(self): print repr(self.memory)
<commit_before>class Memory(object): def __init__(self, size): self.size = size self.memory = bytearray([0] * size) def read(self, addr, count): if addr + count > len(self.memory): raise Exception('read exceeds memory bounds') return str(self.memory[addr:addr+count]) def write(self, addr, buffer): if addr + len(buffer) > len(self.memory): raise Exception('write exceeds memory bounds') self.memory[addr:addr+len(buffer)] = buffer def dump(self): print repr(self.memory) <commit_msg>Use Memory.size field for read/write checks<commit_after>class Memory(object): def __init__(self, size): self.size = size self.memory = bytearray([0] * size) def read(self, addr, count): if addr + count > self.size: raise Exception('read exceeds memory bounds') return str(self.memory[addr:addr+count]) def write(self, addr, buffer): if addr + len(buffer) > self.size: raise Exception('write exceeds memory bounds') self.memory[addr:addr+len(buffer)] = buffer def dump(self): print repr(self.memory)
9cd3bb79126fa2431ba4ae03811ac30fb77b9b46
netcat.py
netcat.py
#!/usr/bin/python2 import argparse import socket import sys parser = argparse.ArgumentParser(description='Simple netcat in pure python.') parser.add_argument('-z', '--scan', action='store_true') parser.add_argument('-w', '--timeout', metavar='SECONDS', type=int) parser.add_argument('-v', '--verbose', action='store_true') parser.add_argument('host') parser.add_argument('port', type=int) args = parser.parse_args() if args.scan: try: connection = socket.create_connection((args.host, args.port), args.timeout) if args.verbose: print "Connection to {} {} port (tcp) succeeded!".format(args.host, args.port) sys.exit(0) except socket.error as msg: if args.verbose: print "Connection to {} {} port (tcp) failed. {}".format(args.host, args.port, msg) sys.exit(1) else: print 'Not implemented'
#!/usr/bin/python import argparse import socket import sys parser = argparse.ArgumentParser(description='Simple netcat in pure python.') parser.add_argument('-s', '--source', metavar='ADDRESS') parser.add_argument('-v', '--verbose', action='store_true') parser.add_argument('-w', '--wait', metavar='SECONDS', type=int) parser.add_argument('-z', '--zero', action='store_true') parser.add_argument('host') parser.add_argument('port') args = parser.parse_args() # Set a souce address for socket connection source = ('', 0) if args.source: source = (args.source, 0) # port 0 specifies that the OS will choose a port # exit successfully if the connection succeeds if args.zero: try: connection = socket.create_connection((args.host, args.port), args.wait, source) if args.verbose: print("Connection to {} {} port (tcp) succeeded!".format(args.host, args.port)) sys.exit(0) except socket.error as msg: if args.verbose: print("Connection to {} {} port (tcp) failed. {}".format(args.host, args.port, msg)) sys.exit(1) else: print('Not implemented')
Support python 2 and 3
Support python 2 and 3 Add source argument. Update arguments to use long names from GNU netcat.
Python
unlicense
benformosa/Toolbox,benformosa/Toolbox
#!/usr/bin/python2 import argparse import socket import sys parser = argparse.ArgumentParser(description='Simple netcat in pure python.') parser.add_argument('-z', '--scan', action='store_true') parser.add_argument('-w', '--timeout', metavar='SECONDS', type=int) parser.add_argument('-v', '--verbose', action='store_true') parser.add_argument('host') parser.add_argument('port', type=int) args = parser.parse_args() if args.scan: try: connection = socket.create_connection((args.host, args.port), args.timeout) if args.verbose: print "Connection to {} {} port (tcp) succeeded!".format(args.host, args.port) sys.exit(0) except socket.error as msg: if args.verbose: print "Connection to {} {} port (tcp) failed. {}".format(args.host, args.port, msg) sys.exit(1) else: print 'Not implemented' Support python 2 and 3 Add source argument. Update arguments to use long names from GNU netcat.
#!/usr/bin/python import argparse import socket import sys parser = argparse.ArgumentParser(description='Simple netcat in pure python.') parser.add_argument('-s', '--source', metavar='ADDRESS') parser.add_argument('-v', '--verbose', action='store_true') parser.add_argument('-w', '--wait', metavar='SECONDS', type=int) parser.add_argument('-z', '--zero', action='store_true') parser.add_argument('host') parser.add_argument('port') args = parser.parse_args() # Set a souce address for socket connection source = ('', 0) if args.source: source = (args.source, 0) # port 0 specifies that the OS will choose a port # exit successfully if the connection succeeds if args.zero: try: connection = socket.create_connection((args.host, args.port), args.wait, source) if args.verbose: print("Connection to {} {} port (tcp) succeeded!".format(args.host, args.port)) sys.exit(0) except socket.error as msg: if args.verbose: print("Connection to {} {} port (tcp) failed. {}".format(args.host, args.port, msg)) sys.exit(1) else: print('Not implemented')
<commit_before>#!/usr/bin/python2 import argparse import socket import sys parser = argparse.ArgumentParser(description='Simple netcat in pure python.') parser.add_argument('-z', '--scan', action='store_true') parser.add_argument('-w', '--timeout', metavar='SECONDS', type=int) parser.add_argument('-v', '--verbose', action='store_true') parser.add_argument('host') parser.add_argument('port', type=int) args = parser.parse_args() if args.scan: try: connection = socket.create_connection((args.host, args.port), args.timeout) if args.verbose: print "Connection to {} {} port (tcp) succeeded!".format(args.host, args.port) sys.exit(0) except socket.error as msg: if args.verbose: print "Connection to {} {} port (tcp) failed. {}".format(args.host, args.port, msg) sys.exit(1) else: print 'Not implemented' <commit_msg>Support python 2 and 3 Add source argument. Update arguments to use long names from GNU netcat.<commit_after>
#!/usr/bin/python import argparse import socket import sys parser = argparse.ArgumentParser(description='Simple netcat in pure python.') parser.add_argument('-s', '--source', metavar='ADDRESS') parser.add_argument('-v', '--verbose', action='store_true') parser.add_argument('-w', '--wait', metavar='SECONDS', type=int) parser.add_argument('-z', '--zero', action='store_true') parser.add_argument('host') parser.add_argument('port') args = parser.parse_args() # Set a souce address for socket connection source = ('', 0) if args.source: source = (args.source, 0) # port 0 specifies that the OS will choose a port # exit successfully if the connection succeeds if args.zero: try: connection = socket.create_connection((args.host, args.port), args.wait, source) if args.verbose: print("Connection to {} {} port (tcp) succeeded!".format(args.host, args.port)) sys.exit(0) except socket.error as msg: if args.verbose: print("Connection to {} {} port (tcp) failed. {}".format(args.host, args.port, msg)) sys.exit(1) else: print('Not implemented')
#!/usr/bin/python2 import argparse import socket import sys parser = argparse.ArgumentParser(description='Simple netcat in pure python.') parser.add_argument('-z', '--scan', action='store_true') parser.add_argument('-w', '--timeout', metavar='SECONDS', type=int) parser.add_argument('-v', '--verbose', action='store_true') parser.add_argument('host') parser.add_argument('port', type=int) args = parser.parse_args() if args.scan: try: connection = socket.create_connection((args.host, args.port), args.timeout) if args.verbose: print "Connection to {} {} port (tcp) succeeded!".format(args.host, args.port) sys.exit(0) except socket.error as msg: if args.verbose: print "Connection to {} {} port (tcp) failed. {}".format(args.host, args.port, msg) sys.exit(1) else: print 'Not implemented' Support python 2 and 3 Add source argument. Update arguments to use long names from GNU netcat.#!/usr/bin/python import argparse import socket import sys parser = argparse.ArgumentParser(description='Simple netcat in pure python.') parser.add_argument('-s', '--source', metavar='ADDRESS') parser.add_argument('-v', '--verbose', action='store_true') parser.add_argument('-w', '--wait', metavar='SECONDS', type=int) parser.add_argument('-z', '--zero', action='store_true') parser.add_argument('host') parser.add_argument('port') args = parser.parse_args() # Set a souce address for socket connection source = ('', 0) if args.source: source = (args.source, 0) # port 0 specifies that the OS will choose a port # exit successfully if the connection succeeds if args.zero: try: connection = socket.create_connection((args.host, args.port), args.wait, source) if args.verbose: print("Connection to {} {} port (tcp) succeeded!".format(args.host, args.port)) sys.exit(0) except socket.error as msg: if args.verbose: print("Connection to {} {} port (tcp) failed. {}".format(args.host, args.port, msg)) sys.exit(1) else: print('Not implemented')
<commit_before>#!/usr/bin/python2 import argparse import socket import sys parser = argparse.ArgumentParser(description='Simple netcat in pure python.') parser.add_argument('-z', '--scan', action='store_true') parser.add_argument('-w', '--timeout', metavar='SECONDS', type=int) parser.add_argument('-v', '--verbose', action='store_true') parser.add_argument('host') parser.add_argument('port', type=int) args = parser.parse_args() if args.scan: try: connection = socket.create_connection((args.host, args.port), args.timeout) if args.verbose: print "Connection to {} {} port (tcp) succeeded!".format(args.host, args.port) sys.exit(0) except socket.error as msg: if args.verbose: print "Connection to {} {} port (tcp) failed. {}".format(args.host, args.port, msg) sys.exit(1) else: print 'Not implemented' <commit_msg>Support python 2 and 3 Add source argument. Update arguments to use long names from GNU netcat.<commit_after>#!/usr/bin/python import argparse import socket import sys parser = argparse.ArgumentParser(description='Simple netcat in pure python.') parser.add_argument('-s', '--source', metavar='ADDRESS') parser.add_argument('-v', '--verbose', action='store_true') parser.add_argument('-w', '--wait', metavar='SECONDS', type=int) parser.add_argument('-z', '--zero', action='store_true') parser.add_argument('host') parser.add_argument('port') args = parser.parse_args() # Set a souce address for socket connection source = ('', 0) if args.source: source = (args.source, 0) # port 0 specifies that the OS will choose a port # exit successfully if the connection succeeds if args.zero: try: connection = socket.create_connection((args.host, args.port), args.wait, source) if args.verbose: print("Connection to {} {} port (tcp) succeeded!".format(args.host, args.port)) sys.exit(0) except socket.error as msg: if args.verbose: print("Connection to {} {} port (tcp) failed. {}".format(args.host, args.port, msg)) sys.exit(1) else: print('Not implemented')
f8dcceb9702c079e16bda30582e561ffeb2e857b
billjobs/urls.py
billjobs/urls.py
from django.conf.urls import url, include from . import views urlpatterns = [ url(r'^generate_pdf/(?P<bill_id>\d+)$', views.generate_pdf, name='generate-pdf'), url(r'^users/$', views.UserAdmin.as_view(), name='users'), url(r'^users/(?P<pk>[0-9]+)/$', views.UserAdminDetail.as_view(), name='user-detail'), url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')) ]
from django.conf.urls import url, include from rest_framework.authtoken.views import obtain_auth_token from . import views urlpatterns = [ url(r'^generate_pdf/(?P<bill_id>\d+)$', views.generate_pdf, name='generate-pdf'), url(r'^users/$', views.UserAdmin.as_view(), name='users'), url(r'^users/(?P<pk>[0-9]+)/$', views.UserAdminDetail.as_view(), name='user-detail'), url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')), url(r'^api-token-auth/', obtain_auth_token) ]
Add rest_framework view to obtain auth token
Add rest_framework view to obtain auth token
Python
mit
ioO/billjobs
from django.conf.urls import url, include from . import views urlpatterns = [ url(r'^generate_pdf/(?P<bill_id>\d+)$', views.generate_pdf, name='generate-pdf'), url(r'^users/$', views.UserAdmin.as_view(), name='users'), url(r'^users/(?P<pk>[0-9]+)/$', views.UserAdminDetail.as_view(), name='user-detail'), url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')) ] Add rest_framework view to obtain auth token
from django.conf.urls import url, include from rest_framework.authtoken.views import obtain_auth_token from . import views urlpatterns = [ url(r'^generate_pdf/(?P<bill_id>\d+)$', views.generate_pdf, name='generate-pdf'), url(r'^users/$', views.UserAdmin.as_view(), name='users'), url(r'^users/(?P<pk>[0-9]+)/$', views.UserAdminDetail.as_view(), name='user-detail'), url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')), url(r'^api-token-auth/', obtain_auth_token) ]
<commit_before>from django.conf.urls import url, include from . import views urlpatterns = [ url(r'^generate_pdf/(?P<bill_id>\d+)$', views.generate_pdf, name='generate-pdf'), url(r'^users/$', views.UserAdmin.as_view(), name='users'), url(r'^users/(?P<pk>[0-9]+)/$', views.UserAdminDetail.as_view(), name='user-detail'), url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')) ] <commit_msg>Add rest_framework view to obtain auth token<commit_after>
from django.conf.urls import url, include from rest_framework.authtoken.views import obtain_auth_token from . import views urlpatterns = [ url(r'^generate_pdf/(?P<bill_id>\d+)$', views.generate_pdf, name='generate-pdf'), url(r'^users/$', views.UserAdmin.as_view(), name='users'), url(r'^users/(?P<pk>[0-9]+)/$', views.UserAdminDetail.as_view(), name='user-detail'), url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')), url(r'^api-token-auth/', obtain_auth_token) ]
from django.conf.urls import url, include from . import views urlpatterns = [ url(r'^generate_pdf/(?P<bill_id>\d+)$', views.generate_pdf, name='generate-pdf'), url(r'^users/$', views.UserAdmin.as_view(), name='users'), url(r'^users/(?P<pk>[0-9]+)/$', views.UserAdminDetail.as_view(), name='user-detail'), url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')) ] Add rest_framework view to obtain auth tokenfrom django.conf.urls import url, include from rest_framework.authtoken.views import obtain_auth_token from . import views urlpatterns = [ url(r'^generate_pdf/(?P<bill_id>\d+)$', views.generate_pdf, name='generate-pdf'), url(r'^users/$', views.UserAdmin.as_view(), name='users'), url(r'^users/(?P<pk>[0-9]+)/$', views.UserAdminDetail.as_view(), name='user-detail'), url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')), url(r'^api-token-auth/', obtain_auth_token) ]
<commit_before>from django.conf.urls import url, include from . import views urlpatterns = [ url(r'^generate_pdf/(?P<bill_id>\d+)$', views.generate_pdf, name='generate-pdf'), url(r'^users/$', views.UserAdmin.as_view(), name='users'), url(r'^users/(?P<pk>[0-9]+)/$', views.UserAdminDetail.as_view(), name='user-detail'), url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')) ] <commit_msg>Add rest_framework view to obtain auth token<commit_after>from django.conf.urls import url, include from rest_framework.authtoken.views import obtain_auth_token from . import views urlpatterns = [ url(r'^generate_pdf/(?P<bill_id>\d+)$', views.generate_pdf, name='generate-pdf'), url(r'^users/$', views.UserAdmin.as_view(), name='users'), url(r'^users/(?P<pk>[0-9]+)/$', views.UserAdminDetail.as_view(), name='user-detail'), url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')), url(r'^api-token-auth/', obtain_auth_token) ]
68e83bafc9584f32ebcaa854211affbfeaf92f36
downstream_node/models.py
downstream_node/models.py
#!/usr/bin/env python # -*- coding: utf-8 -*- from downstream_node.startup import db class Files(db.Model): __tablename__ = 'files' id = db.Column(db.Integer(), primary_key=True, autoincrement=True) name = db.Column(db.String(512), unique=True) class Challenges(db.Model): __tablename__ = 'challenges' id = db.Column(db.Integer(), primary_key=True, autoincrement=True) filename = db.Column(db.ForeignKey('files.name')) rootseed = db.Column(db.String(128), nullable=False) block = db.Column(db.String(128), nullable=False) seed = db.Column(db.String(128), nullable=False) response = db.Column(db.String(128))
#!/usr/bin/env python # -*- coding: utf-8 -*- from downstream_node.startup import db class Files(db.Model): __tablename__ = 'files' id = db.Column(db.Integer(), primary_key=True, autoincrement=True) name = db.Column(db.String(512), unique=True) class Challenges(db.Model): __tablename__ = 'challenges' id = db.Column(db.Integer(), primary_key=True, autoincrement=True) filename = db.Column(db.ForeignKey('files.name')) rootseed = db.Column(db.String(128), nullable=False) block = db.Column(db.Integer(), nullable=False) seed = db.Column(db.String(128), nullable=False) response = db.Column(db.String(128))
Change Challenges model block column to type Integer
Change Challenges model block column to type Integer
Python
mit
Storj/downstream-node,Storj/downstream-node
#!/usr/bin/env python # -*- coding: utf-8 -*- from downstream_node.startup import db class Files(db.Model): __tablename__ = 'files' id = db.Column(db.Integer(), primary_key=True, autoincrement=True) name = db.Column(db.String(512), unique=True) class Challenges(db.Model): __tablename__ = 'challenges' id = db.Column(db.Integer(), primary_key=True, autoincrement=True) filename = db.Column(db.ForeignKey('files.name')) rootseed = db.Column(db.String(128), nullable=False) block = db.Column(db.String(128), nullable=False) seed = db.Column(db.String(128), nullable=False) response = db.Column(db.String(128)) Change Challenges model block column to type Integer
#!/usr/bin/env python # -*- coding: utf-8 -*- from downstream_node.startup import db class Files(db.Model): __tablename__ = 'files' id = db.Column(db.Integer(), primary_key=True, autoincrement=True) name = db.Column(db.String(512), unique=True) class Challenges(db.Model): __tablename__ = 'challenges' id = db.Column(db.Integer(), primary_key=True, autoincrement=True) filename = db.Column(db.ForeignKey('files.name')) rootseed = db.Column(db.String(128), nullable=False) block = db.Column(db.Integer(), nullable=False) seed = db.Column(db.String(128), nullable=False) response = db.Column(db.String(128))
<commit_before>#!/usr/bin/env python # -*- coding: utf-8 -*- from downstream_node.startup import db class Files(db.Model): __tablename__ = 'files' id = db.Column(db.Integer(), primary_key=True, autoincrement=True) name = db.Column(db.String(512), unique=True) class Challenges(db.Model): __tablename__ = 'challenges' id = db.Column(db.Integer(), primary_key=True, autoincrement=True) filename = db.Column(db.ForeignKey('files.name')) rootseed = db.Column(db.String(128), nullable=False) block = db.Column(db.String(128), nullable=False) seed = db.Column(db.String(128), nullable=False) response = db.Column(db.String(128)) <commit_msg>Change Challenges model block column to type Integer<commit_after>
#!/usr/bin/env python # -*- coding: utf-8 -*- from downstream_node.startup import db class Files(db.Model): __tablename__ = 'files' id = db.Column(db.Integer(), primary_key=True, autoincrement=True) name = db.Column(db.String(512), unique=True) class Challenges(db.Model): __tablename__ = 'challenges' id = db.Column(db.Integer(), primary_key=True, autoincrement=True) filename = db.Column(db.ForeignKey('files.name')) rootseed = db.Column(db.String(128), nullable=False) block = db.Column(db.Integer(), nullable=False) seed = db.Column(db.String(128), nullable=False) response = db.Column(db.String(128))
#!/usr/bin/env python # -*- coding: utf-8 -*- from downstream_node.startup import db class Files(db.Model): __tablename__ = 'files' id = db.Column(db.Integer(), primary_key=True, autoincrement=True) name = db.Column(db.String(512), unique=True) class Challenges(db.Model): __tablename__ = 'challenges' id = db.Column(db.Integer(), primary_key=True, autoincrement=True) filename = db.Column(db.ForeignKey('files.name')) rootseed = db.Column(db.String(128), nullable=False) block = db.Column(db.String(128), nullable=False) seed = db.Column(db.String(128), nullable=False) response = db.Column(db.String(128)) Change Challenges model block column to type Integer#!/usr/bin/env python # -*- coding: utf-8 -*- from downstream_node.startup import db class Files(db.Model): __tablename__ = 'files' id = db.Column(db.Integer(), primary_key=True, autoincrement=True) name = db.Column(db.String(512), unique=True) class Challenges(db.Model): __tablename__ = 'challenges' id = db.Column(db.Integer(), primary_key=True, autoincrement=True) filename = db.Column(db.ForeignKey('files.name')) rootseed = db.Column(db.String(128), nullable=False) block = db.Column(db.Integer(), nullable=False) seed = db.Column(db.String(128), nullable=False) response = db.Column(db.String(128))
<commit_before>#!/usr/bin/env python # -*- coding: utf-8 -*- from downstream_node.startup import db class Files(db.Model): __tablename__ = 'files' id = db.Column(db.Integer(), primary_key=True, autoincrement=True) name = db.Column(db.String(512), unique=True) class Challenges(db.Model): __tablename__ = 'challenges' id = db.Column(db.Integer(), primary_key=True, autoincrement=True) filename = db.Column(db.ForeignKey('files.name')) rootseed = db.Column(db.String(128), nullable=False) block = db.Column(db.String(128), nullable=False) seed = db.Column(db.String(128), nullable=False) response = db.Column(db.String(128)) <commit_msg>Change Challenges model block column to type Integer<commit_after>#!/usr/bin/env python # -*- coding: utf-8 -*- from downstream_node.startup import db class Files(db.Model): __tablename__ = 'files' id = db.Column(db.Integer(), primary_key=True, autoincrement=True) name = db.Column(db.String(512), unique=True) class Challenges(db.Model): __tablename__ = 'challenges' id = db.Column(db.Integer(), primary_key=True, autoincrement=True) filename = db.Column(db.ForeignKey('files.name')) rootseed = db.Column(db.String(128), nullable=False) block = db.Column(db.Integer(), nullable=False) seed = db.Column(db.String(128), nullable=False) response = db.Column(db.String(128))
423775b89ff4c6fd2f493aca273d0abc64d39bda
masters/master.chromium.webkit/master_gatekeeper_cfg.py
masters/master.chromium.webkit/master_gatekeeper_cfg.py
# Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. from master import gatekeeper from master import master_utils # This is the list of the builder categories and the corresponding critical # steps. If one critical step fails, gatekeeper will close the tree # automatically. # Note: don't include 'update scripts' since we can't do much about it when # it's failing and the tree is still technically fine. categories_steps = { '': ['update', 'runhooks', 'compile'], } exclusions = { 'WebKit XP': ['runhooks'], # crbug.com/262577 } forgiving_steps = ['update_scripts', 'update', 'gclient_revert'] def Update(config, active_master, c): c['status'].append(gatekeeper.GateKeeper( fromaddr=active_master.from_address, categories_steps=categories_steps, exclusions=exclusions, relayhost=config.Master.smtp, subject='buildbot %(result)s in %(projectName)s on %(builder)s, ' 'revision %(revision)s', extraRecipients=active_master.tree_closing_notification_recipients, lookup=master_utils.FilterDomain(), forgiving_steps=forgiving_steps, public_html='../master.chromium/public_html', tree_status_url=active_master.tree_status_url, use_getname=True, sheriffs=[]))
# Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. from master import gatekeeper from master import master_utils # This is the list of the builder categories and the corresponding critical # steps. If one critical step fails, gatekeeper will close the tree # automatically. # Note: don't include 'update scripts' since we can't do much about it when # it's failing and the tree is still technically fine. categories_steps = { '': ['update', 'runhooks', 'compile'], } exclusions = { 'WebKit XP': ['runhooks'], # crbug.com/262577 } forgiving_steps = ['update_scripts', 'update', 'gclient_revert'] def Update(config, active_master, c): c['status'].append(gatekeeper.GateKeeper( fromaddr=active_master.from_address, categories_steps=categories_steps, exclusions=exclusions, relayhost=config.Master.smtp, subject='buildbot %(result)s in %(projectName)s on %(builder)s, ' 'revision %(revision)s', extraRecipients=active_master.tree_closing_notification_recipients, lookup=master_utils.FilterDomain(), forgiving_steps=forgiving_steps, public_html='../master.chromium/public_html', tree_status_url=active_master.tree_status_url, use_getname=True, sheriffs=['sheriff_webkit']))
Send email to Blink gardeners when tree closes.
Send email to Blink gardeners when tree closes. R=eseidel@chromium.org,iannucci@chromium.org BUG=323059 Review URL: https://codereview.chromium.org/84973002 git-svn-id: 239fca9b83025a0b6f823aeeca02ba5be3d9fd76@237359 0039d316-1c4b-4281-b951-d872f2087c98
Python
bsd-3-clause
eunchong/build,eunchong/build,eunchong/build,eunchong/build
# Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. from master import gatekeeper from master import master_utils # This is the list of the builder categories and the corresponding critical # steps. If one critical step fails, gatekeeper will close the tree # automatically. # Note: don't include 'update scripts' since we can't do much about it when # it's failing and the tree is still technically fine. categories_steps = { '': ['update', 'runhooks', 'compile'], } exclusions = { 'WebKit XP': ['runhooks'], # crbug.com/262577 } forgiving_steps = ['update_scripts', 'update', 'gclient_revert'] def Update(config, active_master, c): c['status'].append(gatekeeper.GateKeeper( fromaddr=active_master.from_address, categories_steps=categories_steps, exclusions=exclusions, relayhost=config.Master.smtp, subject='buildbot %(result)s in %(projectName)s on %(builder)s, ' 'revision %(revision)s', extraRecipients=active_master.tree_closing_notification_recipients, lookup=master_utils.FilterDomain(), forgiving_steps=forgiving_steps, public_html='../master.chromium/public_html', tree_status_url=active_master.tree_status_url, use_getname=True, sheriffs=[])) Send email to Blink gardeners when tree closes. R=eseidel@chromium.org,iannucci@chromium.org BUG=323059 Review URL: https://codereview.chromium.org/84973002 git-svn-id: 239fca9b83025a0b6f823aeeca02ba5be3d9fd76@237359 0039d316-1c4b-4281-b951-d872f2087c98
# Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. from master import gatekeeper from master import master_utils # This is the list of the builder categories and the corresponding critical # steps. If one critical step fails, gatekeeper will close the tree # automatically. # Note: don't include 'update scripts' since we can't do much about it when # it's failing and the tree is still technically fine. categories_steps = { '': ['update', 'runhooks', 'compile'], } exclusions = { 'WebKit XP': ['runhooks'], # crbug.com/262577 } forgiving_steps = ['update_scripts', 'update', 'gclient_revert'] def Update(config, active_master, c): c['status'].append(gatekeeper.GateKeeper( fromaddr=active_master.from_address, categories_steps=categories_steps, exclusions=exclusions, relayhost=config.Master.smtp, subject='buildbot %(result)s in %(projectName)s on %(builder)s, ' 'revision %(revision)s', extraRecipients=active_master.tree_closing_notification_recipients, lookup=master_utils.FilterDomain(), forgiving_steps=forgiving_steps, public_html='../master.chromium/public_html', tree_status_url=active_master.tree_status_url, use_getname=True, sheriffs=['sheriff_webkit']))
<commit_before># Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. from master import gatekeeper from master import master_utils # This is the list of the builder categories and the corresponding critical # steps. If one critical step fails, gatekeeper will close the tree # automatically. # Note: don't include 'update scripts' since we can't do much about it when # it's failing and the tree is still technically fine. categories_steps = { '': ['update', 'runhooks', 'compile'], } exclusions = { 'WebKit XP': ['runhooks'], # crbug.com/262577 } forgiving_steps = ['update_scripts', 'update', 'gclient_revert'] def Update(config, active_master, c): c['status'].append(gatekeeper.GateKeeper( fromaddr=active_master.from_address, categories_steps=categories_steps, exclusions=exclusions, relayhost=config.Master.smtp, subject='buildbot %(result)s in %(projectName)s on %(builder)s, ' 'revision %(revision)s', extraRecipients=active_master.tree_closing_notification_recipients, lookup=master_utils.FilterDomain(), forgiving_steps=forgiving_steps, public_html='../master.chromium/public_html', tree_status_url=active_master.tree_status_url, use_getname=True, sheriffs=[])) <commit_msg>Send email to Blink gardeners when tree closes. R=eseidel@chromium.org,iannucci@chromium.org BUG=323059 Review URL: https://codereview.chromium.org/84973002 git-svn-id: 239fca9b83025a0b6f823aeeca02ba5be3d9fd76@237359 0039d316-1c4b-4281-b951-d872f2087c98<commit_after>
# Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. from master import gatekeeper from master import master_utils # This is the list of the builder categories and the corresponding critical # steps. If one critical step fails, gatekeeper will close the tree # automatically. # Note: don't include 'update scripts' since we can't do much about it when # it's failing and the tree is still technically fine. categories_steps = { '': ['update', 'runhooks', 'compile'], } exclusions = { 'WebKit XP': ['runhooks'], # crbug.com/262577 } forgiving_steps = ['update_scripts', 'update', 'gclient_revert'] def Update(config, active_master, c): c['status'].append(gatekeeper.GateKeeper( fromaddr=active_master.from_address, categories_steps=categories_steps, exclusions=exclusions, relayhost=config.Master.smtp, subject='buildbot %(result)s in %(projectName)s on %(builder)s, ' 'revision %(revision)s', extraRecipients=active_master.tree_closing_notification_recipients, lookup=master_utils.FilterDomain(), forgiving_steps=forgiving_steps, public_html='../master.chromium/public_html', tree_status_url=active_master.tree_status_url, use_getname=True, sheriffs=['sheriff_webkit']))
# Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. from master import gatekeeper from master import master_utils # This is the list of the builder categories and the corresponding critical # steps. If one critical step fails, gatekeeper will close the tree # automatically. # Note: don't include 'update scripts' since we can't do much about it when # it's failing and the tree is still technically fine. categories_steps = { '': ['update', 'runhooks', 'compile'], } exclusions = { 'WebKit XP': ['runhooks'], # crbug.com/262577 } forgiving_steps = ['update_scripts', 'update', 'gclient_revert'] def Update(config, active_master, c): c['status'].append(gatekeeper.GateKeeper( fromaddr=active_master.from_address, categories_steps=categories_steps, exclusions=exclusions, relayhost=config.Master.smtp, subject='buildbot %(result)s in %(projectName)s on %(builder)s, ' 'revision %(revision)s', extraRecipients=active_master.tree_closing_notification_recipients, lookup=master_utils.FilterDomain(), forgiving_steps=forgiving_steps, public_html='../master.chromium/public_html', tree_status_url=active_master.tree_status_url, use_getname=True, sheriffs=[])) Send email to Blink gardeners when tree closes. R=eseidel@chromium.org,iannucci@chromium.org BUG=323059 Review URL: https://codereview.chromium.org/84973002 git-svn-id: 239fca9b83025a0b6f823aeeca02ba5be3d9fd76@237359 0039d316-1c4b-4281-b951-d872f2087c98# Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. from master import gatekeeper from master import master_utils # This is the list of the builder categories and the corresponding critical # steps. If one critical step fails, gatekeeper will close the tree # automatically. # Note: don't include 'update scripts' since we can't do much about it when # it's failing and the tree is still technically fine. categories_steps = { '': ['update', 'runhooks', 'compile'], } exclusions = { 'WebKit XP': ['runhooks'], # crbug.com/262577 } forgiving_steps = ['update_scripts', 'update', 'gclient_revert'] def Update(config, active_master, c): c['status'].append(gatekeeper.GateKeeper( fromaddr=active_master.from_address, categories_steps=categories_steps, exclusions=exclusions, relayhost=config.Master.smtp, subject='buildbot %(result)s in %(projectName)s on %(builder)s, ' 'revision %(revision)s', extraRecipients=active_master.tree_closing_notification_recipients, lookup=master_utils.FilterDomain(), forgiving_steps=forgiving_steps, public_html='../master.chromium/public_html', tree_status_url=active_master.tree_status_url, use_getname=True, sheriffs=['sheriff_webkit']))
<commit_before># Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. from master import gatekeeper from master import master_utils # This is the list of the builder categories and the corresponding critical # steps. If one critical step fails, gatekeeper will close the tree # automatically. # Note: don't include 'update scripts' since we can't do much about it when # it's failing and the tree is still technically fine. categories_steps = { '': ['update', 'runhooks', 'compile'], } exclusions = { 'WebKit XP': ['runhooks'], # crbug.com/262577 } forgiving_steps = ['update_scripts', 'update', 'gclient_revert'] def Update(config, active_master, c): c['status'].append(gatekeeper.GateKeeper( fromaddr=active_master.from_address, categories_steps=categories_steps, exclusions=exclusions, relayhost=config.Master.smtp, subject='buildbot %(result)s in %(projectName)s on %(builder)s, ' 'revision %(revision)s', extraRecipients=active_master.tree_closing_notification_recipients, lookup=master_utils.FilterDomain(), forgiving_steps=forgiving_steps, public_html='../master.chromium/public_html', tree_status_url=active_master.tree_status_url, use_getname=True, sheriffs=[])) <commit_msg>Send email to Blink gardeners when tree closes. R=eseidel@chromium.org,iannucci@chromium.org BUG=323059 Review URL: https://codereview.chromium.org/84973002 git-svn-id: 239fca9b83025a0b6f823aeeca02ba5be3d9fd76@237359 0039d316-1c4b-4281-b951-d872f2087c98<commit_after># Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. from master import gatekeeper from master import master_utils # This is the list of the builder categories and the corresponding critical # steps. If one critical step fails, gatekeeper will close the tree # automatically. # Note: don't include 'update scripts' since we can't do much about it when # it's failing and the tree is still technically fine. categories_steps = { '': ['update', 'runhooks', 'compile'], } exclusions = { 'WebKit XP': ['runhooks'], # crbug.com/262577 } forgiving_steps = ['update_scripts', 'update', 'gclient_revert'] def Update(config, active_master, c): c['status'].append(gatekeeper.GateKeeper( fromaddr=active_master.from_address, categories_steps=categories_steps, exclusions=exclusions, relayhost=config.Master.smtp, subject='buildbot %(result)s in %(projectName)s on %(builder)s, ' 'revision %(revision)s', extraRecipients=active_master.tree_closing_notification_recipients, lookup=master_utils.FilterDomain(), forgiving_steps=forgiving_steps, public_html='../master.chromium/public_html', tree_status_url=active_master.tree_status_url, use_getname=True, sheriffs=['sheriff_webkit']))
3342c9fbef948056f4a4ecc10739e8584e76dea0
cmfieldguide/cmsdetector/signatures/hippo.py
cmfieldguide/cmsdetector/signatures/hippo.py
""" This signature contains tests to see if the site is running on Hippo CMS. """ __author__ = "Jeroen Reijn" __copyright__ = "CM Fieldguide" __credits__ = ["Jeroen Reijn",] __license__ = "Unlicense" __version__ = "0.1" __maintainer__ = "Jeroen Reijn" __email__ = "j.reijn@onehippo.com" __status__ = "Experimental" from cmfieldguide.cmsdetector.signatures import BaseSignature class Signature(BaseSignature): NAME = 'Hippo CMS' WEBSITE = 'http://www.onehippo.com/en/products/cms' KNOWN_POSITIVE = 'www.onehippo.com' TECHNOLOGY = 'JAVA' def test_binaries_file_paths(self, site): """ Hippo CMS exposes image data generally from the binaries path. """ if site.home_page.contains_any_pattern( ['/binaries/content/gallery/'] ): return 1 else: return 0
""" This signature contains tests to see if the site is running on Hippo CMS. """ __author__ = "Jeroen Reijn" __copyright__ = "CM Fieldguide" __credits__ = ["Jeroen Reijn",] __license__ = "Unlicense" __version__ = "0.1" __maintainer__ = "Jeroen Reijn" __email__ = "j.reijn@onehippo.com" __status__ = "Experimental" from cmfieldguide.cmsdetector.signatures import BaseSignature class Signature(BaseSignature): NAME = 'Hippo CMS' WEBSITE = 'http://www.onehippo.com/en/products/cms' KNOWN_POSITIVE = 'http://www.onehippo.com' TECHNOLOGY = 'JAVA' def test_binaries_file_paths(self, site): """ Hippo CMS exposes image data generally from the binaries path. """ if site.home_page.contains_any_pattern( ['/binaries/content/gallery/'] ): return 1 else: return 0
Fix signature because of test failure
Fix signature because of test failure
Python
unlicense
sggottlieb/cmfieldguide
""" This signature contains tests to see if the site is running on Hippo CMS. """ __author__ = "Jeroen Reijn" __copyright__ = "CM Fieldguide" __credits__ = ["Jeroen Reijn",] __license__ = "Unlicense" __version__ = "0.1" __maintainer__ = "Jeroen Reijn" __email__ = "j.reijn@onehippo.com" __status__ = "Experimental" from cmfieldguide.cmsdetector.signatures import BaseSignature class Signature(BaseSignature): NAME = 'Hippo CMS' WEBSITE = 'http://www.onehippo.com/en/products/cms' KNOWN_POSITIVE = 'www.onehippo.com' TECHNOLOGY = 'JAVA' def test_binaries_file_paths(self, site): """ Hippo CMS exposes image data generally from the binaries path. """ if site.home_page.contains_any_pattern( ['/binaries/content/gallery/'] ): return 1 else: return 0 Fix signature because of test failure
""" This signature contains tests to see if the site is running on Hippo CMS. """ __author__ = "Jeroen Reijn" __copyright__ = "CM Fieldguide" __credits__ = ["Jeroen Reijn",] __license__ = "Unlicense" __version__ = "0.1" __maintainer__ = "Jeroen Reijn" __email__ = "j.reijn@onehippo.com" __status__ = "Experimental" from cmfieldguide.cmsdetector.signatures import BaseSignature class Signature(BaseSignature): NAME = 'Hippo CMS' WEBSITE = 'http://www.onehippo.com/en/products/cms' KNOWN_POSITIVE = 'http://www.onehippo.com' TECHNOLOGY = 'JAVA' def test_binaries_file_paths(self, site): """ Hippo CMS exposes image data generally from the binaries path. """ if site.home_page.contains_any_pattern( ['/binaries/content/gallery/'] ): return 1 else: return 0
<commit_before>""" This signature contains tests to see if the site is running on Hippo CMS. """ __author__ = "Jeroen Reijn" __copyright__ = "CM Fieldguide" __credits__ = ["Jeroen Reijn",] __license__ = "Unlicense" __version__ = "0.1" __maintainer__ = "Jeroen Reijn" __email__ = "j.reijn@onehippo.com" __status__ = "Experimental" from cmfieldguide.cmsdetector.signatures import BaseSignature class Signature(BaseSignature): NAME = 'Hippo CMS' WEBSITE = 'http://www.onehippo.com/en/products/cms' KNOWN_POSITIVE = 'www.onehippo.com' TECHNOLOGY = 'JAVA' def test_binaries_file_paths(self, site): """ Hippo CMS exposes image data generally from the binaries path. """ if site.home_page.contains_any_pattern( ['/binaries/content/gallery/'] ): return 1 else: return 0 <commit_msg>Fix signature because of test failure<commit_after>
""" This signature contains tests to see if the site is running on Hippo CMS. """ __author__ = "Jeroen Reijn" __copyright__ = "CM Fieldguide" __credits__ = ["Jeroen Reijn",] __license__ = "Unlicense" __version__ = "0.1" __maintainer__ = "Jeroen Reijn" __email__ = "j.reijn@onehippo.com" __status__ = "Experimental" from cmfieldguide.cmsdetector.signatures import BaseSignature class Signature(BaseSignature): NAME = 'Hippo CMS' WEBSITE = 'http://www.onehippo.com/en/products/cms' KNOWN_POSITIVE = 'http://www.onehippo.com' TECHNOLOGY = 'JAVA' def test_binaries_file_paths(self, site): """ Hippo CMS exposes image data generally from the binaries path. """ if site.home_page.contains_any_pattern( ['/binaries/content/gallery/'] ): return 1 else: return 0
""" This signature contains tests to see if the site is running on Hippo CMS. """ __author__ = "Jeroen Reijn" __copyright__ = "CM Fieldguide" __credits__ = ["Jeroen Reijn",] __license__ = "Unlicense" __version__ = "0.1" __maintainer__ = "Jeroen Reijn" __email__ = "j.reijn@onehippo.com" __status__ = "Experimental" from cmfieldguide.cmsdetector.signatures import BaseSignature class Signature(BaseSignature): NAME = 'Hippo CMS' WEBSITE = 'http://www.onehippo.com/en/products/cms' KNOWN_POSITIVE = 'www.onehippo.com' TECHNOLOGY = 'JAVA' def test_binaries_file_paths(self, site): """ Hippo CMS exposes image data generally from the binaries path. """ if site.home_page.contains_any_pattern( ['/binaries/content/gallery/'] ): return 1 else: return 0 Fix signature because of test failure""" This signature contains tests to see if the site is running on Hippo CMS. """ __author__ = "Jeroen Reijn" __copyright__ = "CM Fieldguide" __credits__ = ["Jeroen Reijn",] __license__ = "Unlicense" __version__ = "0.1" __maintainer__ = "Jeroen Reijn" __email__ = "j.reijn@onehippo.com" __status__ = "Experimental" from cmfieldguide.cmsdetector.signatures import BaseSignature class Signature(BaseSignature): NAME = 'Hippo CMS' WEBSITE = 'http://www.onehippo.com/en/products/cms' KNOWN_POSITIVE = 'http://www.onehippo.com' TECHNOLOGY = 'JAVA' def test_binaries_file_paths(self, site): """ Hippo CMS exposes image data generally from the binaries path. """ if site.home_page.contains_any_pattern( ['/binaries/content/gallery/'] ): return 1 else: return 0
<commit_before>""" This signature contains tests to see if the site is running on Hippo CMS. """ __author__ = "Jeroen Reijn" __copyright__ = "CM Fieldguide" __credits__ = ["Jeroen Reijn",] __license__ = "Unlicense" __version__ = "0.1" __maintainer__ = "Jeroen Reijn" __email__ = "j.reijn@onehippo.com" __status__ = "Experimental" from cmfieldguide.cmsdetector.signatures import BaseSignature class Signature(BaseSignature): NAME = 'Hippo CMS' WEBSITE = 'http://www.onehippo.com/en/products/cms' KNOWN_POSITIVE = 'www.onehippo.com' TECHNOLOGY = 'JAVA' def test_binaries_file_paths(self, site): """ Hippo CMS exposes image data generally from the binaries path. """ if site.home_page.contains_any_pattern( ['/binaries/content/gallery/'] ): return 1 else: return 0 <commit_msg>Fix signature because of test failure<commit_after>""" This signature contains tests to see if the site is running on Hippo CMS. """ __author__ = "Jeroen Reijn" __copyright__ = "CM Fieldguide" __credits__ = ["Jeroen Reijn",] __license__ = "Unlicense" __version__ = "0.1" __maintainer__ = "Jeroen Reijn" __email__ = "j.reijn@onehippo.com" __status__ = "Experimental" from cmfieldguide.cmsdetector.signatures import BaseSignature class Signature(BaseSignature): NAME = 'Hippo CMS' WEBSITE = 'http://www.onehippo.com/en/products/cms' KNOWN_POSITIVE = 'http://www.onehippo.com' TECHNOLOGY = 'JAVA' def test_binaries_file_paths(self, site): """ Hippo CMS exposes image data generally from the binaries path. """ if site.home_page.contains_any_pattern( ['/binaries/content/gallery/'] ): return 1 else: return 0
0101bdc12b00ecb0a1a208f6a1f49e670a5362a6
user_profile/models.py
user_profile/models.py
from django.db import models from django.contrib.auth.models import User class UserProfile(models.Model): user = models.OneToOneField(User) description = models.TextField(max_length=3000) picture = models.ImageField(blank=True, upload_to='media/profiles/') thumbnail = models.ImageField( upload_to='media/profiles/thumb/', max_length=500, null=True, blank=True ) follows = models.ManyToManyField("self", blank=True)
from django.db import models from django.contrib.auth.models import User from django.db.models.signals import post_save from django.dispatch import receiver from django.contrib.auth.models import User class UserProfile(models.Model): user = models.OneToOneField(User) description = models.TextField(max_length=3000) picture = models.ImageField(blank=True, upload_to='media/profiles/') thumbnail = models.ImageField( upload_to='media/profiles/thumb/', max_length=500, null=True, blank=True ) follows = models.ManyToManyField("self", blank=True) # Create UserProfile when user is created @receiver(post_save, sender=User) def create_profile(sender, **kwargs): user = kwargs["instance"] if kwargs["created"]: profile = UserProfile(user=user) profile.save()
Create user_profile automatically after user creation
Create user_profile automatically after user creation
Python
mit
DeWaster/Tviserrys,DeWaster/Tviserrys
from django.db import models from django.contrib.auth.models import User class UserProfile(models.Model): user = models.OneToOneField(User) description = models.TextField(max_length=3000) picture = models.ImageField(blank=True, upload_to='media/profiles/') thumbnail = models.ImageField( upload_to='media/profiles/thumb/', max_length=500, null=True, blank=True ) follows = models.ManyToManyField("self", blank=True) Create user_profile automatically after user creation
from django.db import models from django.contrib.auth.models import User from django.db.models.signals import post_save from django.dispatch import receiver from django.contrib.auth.models import User class UserProfile(models.Model): user = models.OneToOneField(User) description = models.TextField(max_length=3000) picture = models.ImageField(blank=True, upload_to='media/profiles/') thumbnail = models.ImageField( upload_to='media/profiles/thumb/', max_length=500, null=True, blank=True ) follows = models.ManyToManyField("self", blank=True) # Create UserProfile when user is created @receiver(post_save, sender=User) def create_profile(sender, **kwargs): user = kwargs["instance"] if kwargs["created"]: profile = UserProfile(user=user) profile.save()
<commit_before>from django.db import models from django.contrib.auth.models import User class UserProfile(models.Model): user = models.OneToOneField(User) description = models.TextField(max_length=3000) picture = models.ImageField(blank=True, upload_to='media/profiles/') thumbnail = models.ImageField( upload_to='media/profiles/thumb/', max_length=500, null=True, blank=True ) follows = models.ManyToManyField("self", blank=True) <commit_msg>Create user_profile automatically after user creation<commit_after>
from django.db import models from django.contrib.auth.models import User from django.db.models.signals import post_save from django.dispatch import receiver from django.contrib.auth.models import User class UserProfile(models.Model): user = models.OneToOneField(User) description = models.TextField(max_length=3000) picture = models.ImageField(blank=True, upload_to='media/profiles/') thumbnail = models.ImageField( upload_to='media/profiles/thumb/', max_length=500, null=True, blank=True ) follows = models.ManyToManyField("self", blank=True) # Create UserProfile when user is created @receiver(post_save, sender=User) def create_profile(sender, **kwargs): user = kwargs["instance"] if kwargs["created"]: profile = UserProfile(user=user) profile.save()
from django.db import models from django.contrib.auth.models import User class UserProfile(models.Model): user = models.OneToOneField(User) description = models.TextField(max_length=3000) picture = models.ImageField(blank=True, upload_to='media/profiles/') thumbnail = models.ImageField( upload_to='media/profiles/thumb/', max_length=500, null=True, blank=True ) follows = models.ManyToManyField("self", blank=True) Create user_profile automatically after user creationfrom django.db import models from django.contrib.auth.models import User from django.db.models.signals import post_save from django.dispatch import receiver from django.contrib.auth.models import User class UserProfile(models.Model): user = models.OneToOneField(User) description = models.TextField(max_length=3000) picture = models.ImageField(blank=True, upload_to='media/profiles/') thumbnail = models.ImageField( upload_to='media/profiles/thumb/', max_length=500, null=True, blank=True ) follows = models.ManyToManyField("self", blank=True) # Create UserProfile when user is created @receiver(post_save, sender=User) def create_profile(sender, **kwargs): user = kwargs["instance"] if kwargs["created"]: profile = UserProfile(user=user) profile.save()
<commit_before>from django.db import models from django.contrib.auth.models import User class UserProfile(models.Model): user = models.OneToOneField(User) description = models.TextField(max_length=3000) picture = models.ImageField(blank=True, upload_to='media/profiles/') thumbnail = models.ImageField( upload_to='media/profiles/thumb/', max_length=500, null=True, blank=True ) follows = models.ManyToManyField("self", blank=True) <commit_msg>Create user_profile automatically after user creation<commit_after>from django.db import models from django.contrib.auth.models import User from django.db.models.signals import post_save from django.dispatch import receiver from django.contrib.auth.models import User class UserProfile(models.Model): user = models.OneToOneField(User) description = models.TextField(max_length=3000) picture = models.ImageField(blank=True, upload_to='media/profiles/') thumbnail = models.ImageField( upload_to='media/profiles/thumb/', max_length=500, null=True, blank=True ) follows = models.ManyToManyField("self", blank=True) # Create UserProfile when user is created @receiver(post_save, sender=User) def create_profile(sender, **kwargs): user = kwargs["instance"] if kwargs["created"]: profile = UserProfile(user=user) profile.save()
523e5780fd467222967bce3c03186d5af7f3623f
entrec/char_rnn_test.py
entrec/char_rnn_test.py
import tensorflow as tf from .char_rnn import char_rnn def test_char_rnn(): for i, (sentence_shape, labels_shape) in enumerate([ [[None, 64, 8], [None, 64]], [[None, None, 8], [None, None]], [[None, None, None], [None, None]]]): for mode in [tf.contrib.learn.ModeKeys.TRAIN, tf.contrib.learn.ModeKeys.EVAL, tf.contrib.learn.ModeKeys.INFER]: with tf.variable_scope('model_{}_{}'.format(i, mode)): char_rnn(tf.placeholder(tf.int32, sentence_shape), tf.placeholder(tf.int32, labels_shape), mode=mode, num_classes=7, char_space_size=128, char_embedding_size=128, word_embedding_size=128, context_vector_size=128)
import tensorflow as tf from .char_rnn import char_rnn def test_char_rnn(): for i, (sentence_shape, labels_shape) in enumerate([ [[11, 64, 8], [11, 64]], [[None, 64, 8], [None, 64]], [[None, None, 8], [None, None]], [[None, None, None], [None, None]]]): for mode in [tf.contrib.learn.ModeKeys.TRAIN, tf.contrib.learn.ModeKeys.EVAL, tf.contrib.learn.ModeKeys.INFER]: with tf.variable_scope('model_{}_{}'.format(i, mode)): char_rnn(tf.placeholder(tf.int32, sentence_shape), tf.placeholder(tf.int32, labels_shape), mode=mode, num_classes=7, char_space_size=128, char_embedding_size=128, word_embedding_size=128, context_vector_size=128)
Test char rnn with static batch size
Test char rnn with static batch size
Python
unlicense
raviqqe/tensorflow-entrec,raviqqe/tensorflow-entrec
import tensorflow as tf from .char_rnn import char_rnn def test_char_rnn(): for i, (sentence_shape, labels_shape) in enumerate([ [[None, 64, 8], [None, 64]], [[None, None, 8], [None, None]], [[None, None, None], [None, None]]]): for mode in [tf.contrib.learn.ModeKeys.TRAIN, tf.contrib.learn.ModeKeys.EVAL, tf.contrib.learn.ModeKeys.INFER]: with tf.variable_scope('model_{}_{}'.format(i, mode)): char_rnn(tf.placeholder(tf.int32, sentence_shape), tf.placeholder(tf.int32, labels_shape), mode=mode, num_classes=7, char_space_size=128, char_embedding_size=128, word_embedding_size=128, context_vector_size=128) Test char rnn with static batch size
import tensorflow as tf from .char_rnn import char_rnn def test_char_rnn(): for i, (sentence_shape, labels_shape) in enumerate([ [[11, 64, 8], [11, 64]], [[None, 64, 8], [None, 64]], [[None, None, 8], [None, None]], [[None, None, None], [None, None]]]): for mode in [tf.contrib.learn.ModeKeys.TRAIN, tf.contrib.learn.ModeKeys.EVAL, tf.contrib.learn.ModeKeys.INFER]: with tf.variable_scope('model_{}_{}'.format(i, mode)): char_rnn(tf.placeholder(tf.int32, sentence_shape), tf.placeholder(tf.int32, labels_shape), mode=mode, num_classes=7, char_space_size=128, char_embedding_size=128, word_embedding_size=128, context_vector_size=128)
<commit_before>import tensorflow as tf from .char_rnn import char_rnn def test_char_rnn(): for i, (sentence_shape, labels_shape) in enumerate([ [[None, 64, 8], [None, 64]], [[None, None, 8], [None, None]], [[None, None, None], [None, None]]]): for mode in [tf.contrib.learn.ModeKeys.TRAIN, tf.contrib.learn.ModeKeys.EVAL, tf.contrib.learn.ModeKeys.INFER]: with tf.variable_scope('model_{}_{}'.format(i, mode)): char_rnn(tf.placeholder(tf.int32, sentence_shape), tf.placeholder(tf.int32, labels_shape), mode=mode, num_classes=7, char_space_size=128, char_embedding_size=128, word_embedding_size=128, context_vector_size=128) <commit_msg>Test char rnn with static batch size<commit_after>
import tensorflow as tf from .char_rnn import char_rnn def test_char_rnn(): for i, (sentence_shape, labels_shape) in enumerate([ [[11, 64, 8], [11, 64]], [[None, 64, 8], [None, 64]], [[None, None, 8], [None, None]], [[None, None, None], [None, None]]]): for mode in [tf.contrib.learn.ModeKeys.TRAIN, tf.contrib.learn.ModeKeys.EVAL, tf.contrib.learn.ModeKeys.INFER]: with tf.variable_scope('model_{}_{}'.format(i, mode)): char_rnn(tf.placeholder(tf.int32, sentence_shape), tf.placeholder(tf.int32, labels_shape), mode=mode, num_classes=7, char_space_size=128, char_embedding_size=128, word_embedding_size=128, context_vector_size=128)
import tensorflow as tf from .char_rnn import char_rnn def test_char_rnn(): for i, (sentence_shape, labels_shape) in enumerate([ [[None, 64, 8], [None, 64]], [[None, None, 8], [None, None]], [[None, None, None], [None, None]]]): for mode in [tf.contrib.learn.ModeKeys.TRAIN, tf.contrib.learn.ModeKeys.EVAL, tf.contrib.learn.ModeKeys.INFER]: with tf.variable_scope('model_{}_{}'.format(i, mode)): char_rnn(tf.placeholder(tf.int32, sentence_shape), tf.placeholder(tf.int32, labels_shape), mode=mode, num_classes=7, char_space_size=128, char_embedding_size=128, word_embedding_size=128, context_vector_size=128) Test char rnn with static batch sizeimport tensorflow as tf from .char_rnn import char_rnn def test_char_rnn(): for i, (sentence_shape, labels_shape) in enumerate([ [[11, 64, 8], [11, 64]], [[None, 64, 8], [None, 64]], [[None, None, 8], [None, None]], [[None, None, None], [None, None]]]): for mode in [tf.contrib.learn.ModeKeys.TRAIN, tf.contrib.learn.ModeKeys.EVAL, tf.contrib.learn.ModeKeys.INFER]: with tf.variable_scope('model_{}_{}'.format(i, mode)): char_rnn(tf.placeholder(tf.int32, sentence_shape), tf.placeholder(tf.int32, labels_shape), mode=mode, num_classes=7, char_space_size=128, char_embedding_size=128, word_embedding_size=128, context_vector_size=128)
<commit_before>import tensorflow as tf from .char_rnn import char_rnn def test_char_rnn(): for i, (sentence_shape, labels_shape) in enumerate([ [[None, 64, 8], [None, 64]], [[None, None, 8], [None, None]], [[None, None, None], [None, None]]]): for mode in [tf.contrib.learn.ModeKeys.TRAIN, tf.contrib.learn.ModeKeys.EVAL, tf.contrib.learn.ModeKeys.INFER]: with tf.variable_scope('model_{}_{}'.format(i, mode)): char_rnn(tf.placeholder(tf.int32, sentence_shape), tf.placeholder(tf.int32, labels_shape), mode=mode, num_classes=7, char_space_size=128, char_embedding_size=128, word_embedding_size=128, context_vector_size=128) <commit_msg>Test char rnn with static batch size<commit_after>import tensorflow as tf from .char_rnn import char_rnn def test_char_rnn(): for i, (sentence_shape, labels_shape) in enumerate([ [[11, 64, 8], [11, 64]], [[None, 64, 8], [None, 64]], [[None, None, 8], [None, None]], [[None, None, None], [None, None]]]): for mode in [tf.contrib.learn.ModeKeys.TRAIN, tf.contrib.learn.ModeKeys.EVAL, tf.contrib.learn.ModeKeys.INFER]: with tf.variable_scope('model_{}_{}'.format(i, mode)): char_rnn(tf.placeholder(tf.int32, sentence_shape), tf.placeholder(tf.int32, labels_shape), mode=mode, num_classes=7, char_space_size=128, char_embedding_size=128, word_embedding_size=128, context_vector_size=128)
52cbbadd3cf56ebc6783313058dbe129a4852a1d
call_server/extensions.py
call_server/extensions.py
# define flask extensions in separate file, to resolve import dependencies from flask_sqlalchemy import SQLAlchemy db = SQLAlchemy() from flask_caching import Cache cache = Cache() from flask_assets import Environment assets = Environment() from flask_babel import Babel babel = Babel() from flask_mail import Mail mail = Mail() from flask_login import LoginManager login_manager = LoginManager() from flask_restless import APIManager rest = APIManager() from flask_wtf.csrf import CSRFProtect csrf = CSRFProtect() from flask_store import Store store = Store() from flask_rq2 import RQ rq = RQ() from flask_talisman import Talisman CALLPOWER_CSP = { 'default-src':'\'self\'', 'script-src':['\'self\'', '\'unsafe-inline\'', '\'unsafe-eval\'', 'cdnjs.cloudflare.com', 'media.twiliocdn.com'], 'style-src': ['\'self\'', '\'unsafe-inline\'', 'fonts.googleapis.com'], 'font-src': ['\'self\'', 'fonts.gstatic.com'], 'media-src': ['\'self\'', 'media.twiliocdn.com'], 'connect-src': ['\'self\'', 'wss://*.twilio.com', ] } # unsafe-inline needed to render <script> tags without nonce # unsafe-eval needed to run bootstrap templates talisman = Talisman()
# define flask extensions in separate file, to resolve import dependencies from flask_sqlalchemy import SQLAlchemy db = SQLAlchemy() from flask_caching import Cache cache = Cache() from flask_assets import Environment assets = Environment() from flask_babel import Babel babel = Babel() from flask_mail import Mail mail = Mail() from flask_login import LoginManager login_manager = LoginManager() from flask_restless import APIManager rest = APIManager() from flask_wtf.csrf import CSRFProtect csrf = CSRFProtect() from flask_store import Store store = Store() from flask_rq2 import RQ rq = RQ() from flask_talisman import Talisman CALLPOWER_CSP = { 'default-src':'\'self\'', 'script-src':['\'self\'', '\'unsafe-inline\'', '\'unsafe-eval\'', 'cdnjs.cloudflare.com', 'media.twiliocdn.com', 'js-agent.newrelic.com'], 'style-src': ['\'self\'', '\'unsafe-inline\'', 'fonts.googleapis.com'], 'font-src': ['\'self\'', 'fonts.gstatic.com'], 'media-src': ['\'self\'', 'media.twiliocdn.com'], 'connect-src': ['\'self\'', 'wss://*.twilio.com', ] } # unsafe-inline needed to render <script> tags without nonce # unsafe-eval needed to run bootstrap templates talisman = Talisman()
Update script-src to include newrelic
Update script-src to include newrelic
Python
agpl-3.0
OpenSourceActivismTech/call-power,18mr/call-congress,spacedogXYZ/call-power,18mr/call-congress,spacedogXYZ/call-power,18mr/call-congress,OpenSourceActivismTech/call-power,OpenSourceActivismTech/call-power,spacedogXYZ/call-power,spacedogXYZ/call-power,18mr/call-congress,OpenSourceActivismTech/call-power
# define flask extensions in separate file, to resolve import dependencies from flask_sqlalchemy import SQLAlchemy db = SQLAlchemy() from flask_caching import Cache cache = Cache() from flask_assets import Environment assets = Environment() from flask_babel import Babel babel = Babel() from flask_mail import Mail mail = Mail() from flask_login import LoginManager login_manager = LoginManager() from flask_restless import APIManager rest = APIManager() from flask_wtf.csrf import CSRFProtect csrf = CSRFProtect() from flask_store import Store store = Store() from flask_rq2 import RQ rq = RQ() from flask_talisman import Talisman CALLPOWER_CSP = { 'default-src':'\'self\'', 'script-src':['\'self\'', '\'unsafe-inline\'', '\'unsafe-eval\'', 'cdnjs.cloudflare.com', 'media.twiliocdn.com'], 'style-src': ['\'self\'', '\'unsafe-inline\'', 'fonts.googleapis.com'], 'font-src': ['\'self\'', 'fonts.gstatic.com'], 'media-src': ['\'self\'', 'media.twiliocdn.com'], 'connect-src': ['\'self\'', 'wss://*.twilio.com', ] } # unsafe-inline needed to render <script> tags without nonce # unsafe-eval needed to run bootstrap templates talisman = Talisman()Update script-src to include newrelic
# define flask extensions in separate file, to resolve import dependencies from flask_sqlalchemy import SQLAlchemy db = SQLAlchemy() from flask_caching import Cache cache = Cache() from flask_assets import Environment assets = Environment() from flask_babel import Babel babel = Babel() from flask_mail import Mail mail = Mail() from flask_login import LoginManager login_manager = LoginManager() from flask_restless import APIManager rest = APIManager() from flask_wtf.csrf import CSRFProtect csrf = CSRFProtect() from flask_store import Store store = Store() from flask_rq2 import RQ rq = RQ() from flask_talisman import Talisman CALLPOWER_CSP = { 'default-src':'\'self\'', 'script-src':['\'self\'', '\'unsafe-inline\'', '\'unsafe-eval\'', 'cdnjs.cloudflare.com', 'media.twiliocdn.com', 'js-agent.newrelic.com'], 'style-src': ['\'self\'', '\'unsafe-inline\'', 'fonts.googleapis.com'], 'font-src': ['\'self\'', 'fonts.gstatic.com'], 'media-src': ['\'self\'', 'media.twiliocdn.com'], 'connect-src': ['\'self\'', 'wss://*.twilio.com', ] } # unsafe-inline needed to render <script> tags without nonce # unsafe-eval needed to run bootstrap templates talisman = Talisman()
<commit_before># define flask extensions in separate file, to resolve import dependencies from flask_sqlalchemy import SQLAlchemy db = SQLAlchemy() from flask_caching import Cache cache = Cache() from flask_assets import Environment assets = Environment() from flask_babel import Babel babel = Babel() from flask_mail import Mail mail = Mail() from flask_login import LoginManager login_manager = LoginManager() from flask_restless import APIManager rest = APIManager() from flask_wtf.csrf import CSRFProtect csrf = CSRFProtect() from flask_store import Store store = Store() from flask_rq2 import RQ rq = RQ() from flask_talisman import Talisman CALLPOWER_CSP = { 'default-src':'\'self\'', 'script-src':['\'self\'', '\'unsafe-inline\'', '\'unsafe-eval\'', 'cdnjs.cloudflare.com', 'media.twiliocdn.com'], 'style-src': ['\'self\'', '\'unsafe-inline\'', 'fonts.googleapis.com'], 'font-src': ['\'self\'', 'fonts.gstatic.com'], 'media-src': ['\'self\'', 'media.twiliocdn.com'], 'connect-src': ['\'self\'', 'wss://*.twilio.com', ] } # unsafe-inline needed to render <script> tags without nonce # unsafe-eval needed to run bootstrap templates talisman = Talisman()<commit_msg>Update script-src to include newrelic<commit_after>
# define flask extensions in separate file, to resolve import dependencies from flask_sqlalchemy import SQLAlchemy db = SQLAlchemy() from flask_caching import Cache cache = Cache() from flask_assets import Environment assets = Environment() from flask_babel import Babel babel = Babel() from flask_mail import Mail mail = Mail() from flask_login import LoginManager login_manager = LoginManager() from flask_restless import APIManager rest = APIManager() from flask_wtf.csrf import CSRFProtect csrf = CSRFProtect() from flask_store import Store store = Store() from flask_rq2 import RQ rq = RQ() from flask_talisman import Talisman CALLPOWER_CSP = { 'default-src':'\'self\'', 'script-src':['\'self\'', '\'unsafe-inline\'', '\'unsafe-eval\'', 'cdnjs.cloudflare.com', 'media.twiliocdn.com', 'js-agent.newrelic.com'], 'style-src': ['\'self\'', '\'unsafe-inline\'', 'fonts.googleapis.com'], 'font-src': ['\'self\'', 'fonts.gstatic.com'], 'media-src': ['\'self\'', 'media.twiliocdn.com'], 'connect-src': ['\'self\'', 'wss://*.twilio.com', ] } # unsafe-inline needed to render <script> tags without nonce # unsafe-eval needed to run bootstrap templates talisman = Talisman()
# define flask extensions in separate file, to resolve import dependencies from flask_sqlalchemy import SQLAlchemy db = SQLAlchemy() from flask_caching import Cache cache = Cache() from flask_assets import Environment assets = Environment() from flask_babel import Babel babel = Babel() from flask_mail import Mail mail = Mail() from flask_login import LoginManager login_manager = LoginManager() from flask_restless import APIManager rest = APIManager() from flask_wtf.csrf import CSRFProtect csrf = CSRFProtect() from flask_store import Store store = Store() from flask_rq2 import RQ rq = RQ() from flask_talisman import Talisman CALLPOWER_CSP = { 'default-src':'\'self\'', 'script-src':['\'self\'', '\'unsafe-inline\'', '\'unsafe-eval\'', 'cdnjs.cloudflare.com', 'media.twiliocdn.com'], 'style-src': ['\'self\'', '\'unsafe-inline\'', 'fonts.googleapis.com'], 'font-src': ['\'self\'', 'fonts.gstatic.com'], 'media-src': ['\'self\'', 'media.twiliocdn.com'], 'connect-src': ['\'self\'', 'wss://*.twilio.com', ] } # unsafe-inline needed to render <script> tags without nonce # unsafe-eval needed to run bootstrap templates talisman = Talisman()Update script-src to include newrelic# define flask extensions in separate file, to resolve import dependencies from flask_sqlalchemy import SQLAlchemy db = SQLAlchemy() from flask_caching import Cache cache = Cache() from flask_assets import Environment assets = Environment() from flask_babel import Babel babel = Babel() from flask_mail import Mail mail = Mail() from flask_login import LoginManager login_manager = LoginManager() from flask_restless import APIManager rest = APIManager() from flask_wtf.csrf import CSRFProtect csrf = CSRFProtect() from flask_store import Store store = Store() from flask_rq2 import RQ rq = RQ() from flask_talisman import Talisman CALLPOWER_CSP = { 'default-src':'\'self\'', 'script-src':['\'self\'', '\'unsafe-inline\'', '\'unsafe-eval\'', 'cdnjs.cloudflare.com', 'media.twiliocdn.com', 'js-agent.newrelic.com'], 'style-src': ['\'self\'', '\'unsafe-inline\'', 'fonts.googleapis.com'], 'font-src': ['\'self\'', 'fonts.gstatic.com'], 'media-src': ['\'self\'', 'media.twiliocdn.com'], 'connect-src': ['\'self\'', 'wss://*.twilio.com', ] } # unsafe-inline needed to render <script> tags without nonce # unsafe-eval needed to run bootstrap templates talisman = Talisman()
<commit_before># define flask extensions in separate file, to resolve import dependencies from flask_sqlalchemy import SQLAlchemy db = SQLAlchemy() from flask_caching import Cache cache = Cache() from flask_assets import Environment assets = Environment() from flask_babel import Babel babel = Babel() from flask_mail import Mail mail = Mail() from flask_login import LoginManager login_manager = LoginManager() from flask_restless import APIManager rest = APIManager() from flask_wtf.csrf import CSRFProtect csrf = CSRFProtect() from flask_store import Store store = Store() from flask_rq2 import RQ rq = RQ() from flask_talisman import Talisman CALLPOWER_CSP = { 'default-src':'\'self\'', 'script-src':['\'self\'', '\'unsafe-inline\'', '\'unsafe-eval\'', 'cdnjs.cloudflare.com', 'media.twiliocdn.com'], 'style-src': ['\'self\'', '\'unsafe-inline\'', 'fonts.googleapis.com'], 'font-src': ['\'self\'', 'fonts.gstatic.com'], 'media-src': ['\'self\'', 'media.twiliocdn.com'], 'connect-src': ['\'self\'', 'wss://*.twilio.com', ] } # unsafe-inline needed to render <script> tags without nonce # unsafe-eval needed to run bootstrap templates talisman = Talisman()<commit_msg>Update script-src to include newrelic<commit_after># define flask extensions in separate file, to resolve import dependencies from flask_sqlalchemy import SQLAlchemy db = SQLAlchemy() from flask_caching import Cache cache = Cache() from flask_assets import Environment assets = Environment() from flask_babel import Babel babel = Babel() from flask_mail import Mail mail = Mail() from flask_login import LoginManager login_manager = LoginManager() from flask_restless import APIManager rest = APIManager() from flask_wtf.csrf import CSRFProtect csrf = CSRFProtect() from flask_store import Store store = Store() from flask_rq2 import RQ rq = RQ() from flask_talisman import Talisman CALLPOWER_CSP = { 'default-src':'\'self\'', 'script-src':['\'self\'', '\'unsafe-inline\'', '\'unsafe-eval\'', 'cdnjs.cloudflare.com', 'media.twiliocdn.com', 'js-agent.newrelic.com'], 'style-src': ['\'self\'', '\'unsafe-inline\'', 'fonts.googleapis.com'], 'font-src': ['\'self\'', 'fonts.gstatic.com'], 'media-src': ['\'self\'', 'media.twiliocdn.com'], 'connect-src': ['\'self\'', 'wss://*.twilio.com', ] } # unsafe-inline needed to render <script> tags without nonce # unsafe-eval needed to run bootstrap templates talisman = Talisman()
a8107b6877ffa19e51ba1bfbee5143ca82df6602
joequery/blog/posts/code/screenx-tv-first-impressions/meta.py
joequery/blog/posts/code/screenx-tv-first-impressions/meta.py
title="ScreenX TV: First Impressions" description=""" My initial thoughts of [ScreenX TV](http://screenx.tv), a way to broadcast your terminal to the world. """ time="2012-12-07 Fri 09:53 PM" # related=[("Some article", "its/url")]
title="ScreenX TV: First Impressions" description=""" My initial thoughts of [ScreenX TV](http://screenx.tv), a way to broadcast your terminal to the world. """ time="2012-12-08 Sat 03:11 AM" # related=[("Some article", "its/url")]
Update timestamp on screenx post
Update timestamp on screenx post
Python
mit
joequery/joequery.me,joequery/joequery.me,joequery/joequery.me,joequery/joequery.me
title="ScreenX TV: First Impressions" description=""" My initial thoughts of [ScreenX TV](http://screenx.tv), a way to broadcast your terminal to the world. """ time="2012-12-07 Fri 09:53 PM" # related=[("Some article", "its/url")] Update timestamp on screenx post
title="ScreenX TV: First Impressions" description=""" My initial thoughts of [ScreenX TV](http://screenx.tv), a way to broadcast your terminal to the world. """ time="2012-12-08 Sat 03:11 AM" # related=[("Some article", "its/url")]
<commit_before>title="ScreenX TV: First Impressions" description=""" My initial thoughts of [ScreenX TV](http://screenx.tv), a way to broadcast your terminal to the world. """ time="2012-12-07 Fri 09:53 PM" # related=[("Some article", "its/url")] <commit_msg>Update timestamp on screenx post<commit_after>
title="ScreenX TV: First Impressions" description=""" My initial thoughts of [ScreenX TV](http://screenx.tv), a way to broadcast your terminal to the world. """ time="2012-12-08 Sat 03:11 AM" # related=[("Some article", "its/url")]
title="ScreenX TV: First Impressions" description=""" My initial thoughts of [ScreenX TV](http://screenx.tv), a way to broadcast your terminal to the world. """ time="2012-12-07 Fri 09:53 PM" # related=[("Some article", "its/url")] Update timestamp on screenx posttitle="ScreenX TV: First Impressions" description=""" My initial thoughts of [ScreenX TV](http://screenx.tv), a way to broadcast your terminal to the world. """ time="2012-12-08 Sat 03:11 AM" # related=[("Some article", "its/url")]
<commit_before>title="ScreenX TV: First Impressions" description=""" My initial thoughts of [ScreenX TV](http://screenx.tv), a way to broadcast your terminal to the world. """ time="2012-12-07 Fri 09:53 PM" # related=[("Some article", "its/url")] <commit_msg>Update timestamp on screenx post<commit_after>title="ScreenX TV: First Impressions" description=""" My initial thoughts of [ScreenX TV](http://screenx.tv), a way to broadcast your terminal to the world. """ time="2012-12-08 Sat 03:11 AM" # related=[("Some article", "its/url")]
0aee34bc19d43f2369a121da2f9cfff05225fdbc
comet/__init__.py
comet/__init__.py
__description__ = "VOEvent Broker" __url__ = "http://comet.transientskp.org/" __author__ = "John Swinbank" __contact__ = "swinbank@princeton.edu" __version__ = "2.1.0-pre"
__description__ = "VOEvent Broker" __url__ = "http://comet.transientskp.org/" __author__ = "John Swinbank" __contact__ = "swinbank@princeton.edu" __version__ = "2.1.0-pre" import sys if sys.version_info.major <= 2: BINARY_TYPE = str else: BINARY_TYPE = bytes
Add alias to appropriate raw bytes for this Python.
Add alias to appropriate raw bytes for this Python.
Python
bsd-2-clause
jdswinbank/Comet,jdswinbank/Comet
__description__ = "VOEvent Broker" __url__ = "http://comet.transientskp.org/" __author__ = "John Swinbank" __contact__ = "swinbank@princeton.edu" __version__ = "2.1.0-pre" Add alias to appropriate raw bytes for this Python.
__description__ = "VOEvent Broker" __url__ = "http://comet.transientskp.org/" __author__ = "John Swinbank" __contact__ = "swinbank@princeton.edu" __version__ = "2.1.0-pre" import sys if sys.version_info.major <= 2: BINARY_TYPE = str else: BINARY_TYPE = bytes
<commit_before>__description__ = "VOEvent Broker" __url__ = "http://comet.transientskp.org/" __author__ = "John Swinbank" __contact__ = "swinbank@princeton.edu" __version__ = "2.1.0-pre" <commit_msg>Add alias to appropriate raw bytes for this Python.<commit_after>
__description__ = "VOEvent Broker" __url__ = "http://comet.transientskp.org/" __author__ = "John Swinbank" __contact__ = "swinbank@princeton.edu" __version__ = "2.1.0-pre" import sys if sys.version_info.major <= 2: BINARY_TYPE = str else: BINARY_TYPE = bytes
__description__ = "VOEvent Broker" __url__ = "http://comet.transientskp.org/" __author__ = "John Swinbank" __contact__ = "swinbank@princeton.edu" __version__ = "2.1.0-pre" Add alias to appropriate raw bytes for this Python.__description__ = "VOEvent Broker" __url__ = "http://comet.transientskp.org/" __author__ = "John Swinbank" __contact__ = "swinbank@princeton.edu" __version__ = "2.1.0-pre" import sys if sys.version_info.major <= 2: BINARY_TYPE = str else: BINARY_TYPE = bytes
<commit_before>__description__ = "VOEvent Broker" __url__ = "http://comet.transientskp.org/" __author__ = "John Swinbank" __contact__ = "swinbank@princeton.edu" __version__ = "2.1.0-pre" <commit_msg>Add alias to appropriate raw bytes for this Python.<commit_after>__description__ = "VOEvent Broker" __url__ = "http://comet.transientskp.org/" __author__ = "John Swinbank" __contact__ = "swinbank@princeton.edu" __version__ = "2.1.0-pre" import sys if sys.version_info.major <= 2: BINARY_TYPE = str else: BINARY_TYPE = bytes
68ea11b5beb24aebc0276f9fc84e552cf4882ac9
tensorflow_datasets/image/places365_small_test.py
tensorflow_datasets/image/places365_small_test.py
from __future__ import absolute_import from __future__ import division from __future__ import print_function import tensorflow as tf from tensorflow_datasets.image import places365_small import tensorflow_datasets.testing as tfds_test class Places365SmallTest(tfds_test.DatasetBuilderTestCase): DATASET_CLASS = places365_small.Places365Small SPLITS = { "train": 2, "test":2, "validation":2 } DL_EXTRACT_RESULT = { 'train':'data_256', 'test':'test_256', 'extra':'val_256' } if __name__ == "__main__": tfds_test.test_main()
from __future__ import absolute_import from __future__ import division from __future__ import print_function import tensorflow as tf from tensorflow_datasets.image import places365_small import tensorflow_datasets.testing as tfds_test class Places365SmallTest(tfds_test.DatasetBuilderTestCase): DATASET_CLASS = places365_small.Places365Small SPLITS = { "train": 2, "test":2, "validation":2 } DL_EXTRACT_RESULT = { 'train':'data_256', 'test':'test_256', 'validation':'val_256' } if __name__ == "__main__": tfds_test.test_main()
Fix in test file key error
Fix in test file key error
Python
apache-2.0
tensorflow/datasets,tensorflow/datasets,tensorflow/datasets,tensorflow/datasets,tensorflow/datasets
from __future__ import absolute_import from __future__ import division from __future__ import print_function import tensorflow as tf from tensorflow_datasets.image import places365_small import tensorflow_datasets.testing as tfds_test class Places365SmallTest(tfds_test.DatasetBuilderTestCase): DATASET_CLASS = places365_small.Places365Small SPLITS = { "train": 2, "test":2, "validation":2 } DL_EXTRACT_RESULT = { 'train':'data_256', 'test':'test_256', 'extra':'val_256' } if __name__ == "__main__": tfds_test.test_main() Fix in test file key error
from __future__ import absolute_import from __future__ import division from __future__ import print_function import tensorflow as tf from tensorflow_datasets.image import places365_small import tensorflow_datasets.testing as tfds_test class Places365SmallTest(tfds_test.DatasetBuilderTestCase): DATASET_CLASS = places365_small.Places365Small SPLITS = { "train": 2, "test":2, "validation":2 } DL_EXTRACT_RESULT = { 'train':'data_256', 'test':'test_256', 'validation':'val_256' } if __name__ == "__main__": tfds_test.test_main()
<commit_before>from __future__ import absolute_import from __future__ import division from __future__ import print_function import tensorflow as tf from tensorflow_datasets.image import places365_small import tensorflow_datasets.testing as tfds_test class Places365SmallTest(tfds_test.DatasetBuilderTestCase): DATASET_CLASS = places365_small.Places365Small SPLITS = { "train": 2, "test":2, "validation":2 } DL_EXTRACT_RESULT = { 'train':'data_256', 'test':'test_256', 'extra':'val_256' } if __name__ == "__main__": tfds_test.test_main() <commit_msg>Fix in test file key error<commit_after>
from __future__ import absolute_import from __future__ import division from __future__ import print_function import tensorflow as tf from tensorflow_datasets.image import places365_small import tensorflow_datasets.testing as tfds_test class Places365SmallTest(tfds_test.DatasetBuilderTestCase): DATASET_CLASS = places365_small.Places365Small SPLITS = { "train": 2, "test":2, "validation":2 } DL_EXTRACT_RESULT = { 'train':'data_256', 'test':'test_256', 'validation':'val_256' } if __name__ == "__main__": tfds_test.test_main()
from __future__ import absolute_import from __future__ import division from __future__ import print_function import tensorflow as tf from tensorflow_datasets.image import places365_small import tensorflow_datasets.testing as tfds_test class Places365SmallTest(tfds_test.DatasetBuilderTestCase): DATASET_CLASS = places365_small.Places365Small SPLITS = { "train": 2, "test":2, "validation":2 } DL_EXTRACT_RESULT = { 'train':'data_256', 'test':'test_256', 'extra':'val_256' } if __name__ == "__main__": tfds_test.test_main() Fix in test file key errorfrom __future__ import absolute_import from __future__ import division from __future__ import print_function import tensorflow as tf from tensorflow_datasets.image import places365_small import tensorflow_datasets.testing as tfds_test class Places365SmallTest(tfds_test.DatasetBuilderTestCase): DATASET_CLASS = places365_small.Places365Small SPLITS = { "train": 2, "test":2, "validation":2 } DL_EXTRACT_RESULT = { 'train':'data_256', 'test':'test_256', 'validation':'val_256' } if __name__ == "__main__": tfds_test.test_main()
<commit_before>from __future__ import absolute_import from __future__ import division from __future__ import print_function import tensorflow as tf from tensorflow_datasets.image import places365_small import tensorflow_datasets.testing as tfds_test class Places365SmallTest(tfds_test.DatasetBuilderTestCase): DATASET_CLASS = places365_small.Places365Small SPLITS = { "train": 2, "test":2, "validation":2 } DL_EXTRACT_RESULT = { 'train':'data_256', 'test':'test_256', 'extra':'val_256' } if __name__ == "__main__": tfds_test.test_main() <commit_msg>Fix in test file key error<commit_after>from __future__ import absolute_import from __future__ import division from __future__ import print_function import tensorflow as tf from tensorflow_datasets.image import places365_small import tensorflow_datasets.testing as tfds_test class Places365SmallTest(tfds_test.DatasetBuilderTestCase): DATASET_CLASS = places365_small.Places365Small SPLITS = { "train": 2, "test":2, "validation":2 } DL_EXTRACT_RESULT = { 'train':'data_256', 'test':'test_256', 'validation':'val_256' } if __name__ == "__main__": tfds_test.test_main()
eda3a836adf4ea1a08b7f75743aaf895e45df562
sigh/utils.py
sigh/utils.py
import datetime import misaka from flask.ext.babel import gettext as _ def timeago(dt): now = datetime.datetime.now() delta = now - dt print delta if delta < datetime.timedelta(minutes=2): return _('Just now') if delta < datetime.timedelta(hours=1): return _('{} minutes ago').format(delta.seconds / 60) if delta < datetime.timedelta(hours=2): return _('1 hour ago') if delta < datetime.timedelta(days=1): return _('{} hours ago').format(delta.seconds / 3600) if delta < datetime.timedelta(days=2): return _('1 day ago') return _('{} days ago').format(delta.days) def plain_markdown(text): renderer = misaka.HtmlRenderer(flags=misaka.HTML_ESCAPE) md = misaka.Markdown(renderer) return md.render(text)
import datetime import misaka from flask.ext.babel import gettext as _ def timeago(dt): now = datetime.datetime.utcnow() delta = now - dt print delta if delta < datetime.timedelta(minutes=2): return _('Just now') if delta < datetime.timedelta(hours=1): return _('{} minutes ago').format(delta.seconds / 60) if delta < datetime.timedelta(hours=2): return _('1 hour ago') if delta < datetime.timedelta(days=1): return _('{} hours ago').format(delta.seconds / 3600) if delta < datetime.timedelta(days=2): return _('1 day ago') return _('{} days ago').format(delta.days) def plain_markdown(text): renderer = misaka.HtmlRenderer(flags=misaka.HTML_ESCAPE) md = misaka.Markdown(renderer) return md.render(text)
Fix time delta with utcnow
Fix time delta with utcnow
Python
mit
kxxoling/Programmer-Sign,kxxoling/Programmer-Sign,kxxoling/Programmer-Sign
import datetime import misaka from flask.ext.babel import gettext as _ def timeago(dt): now = datetime.datetime.now() delta = now - dt print delta if delta < datetime.timedelta(minutes=2): return _('Just now') if delta < datetime.timedelta(hours=1): return _('{} minutes ago').format(delta.seconds / 60) if delta < datetime.timedelta(hours=2): return _('1 hour ago') if delta < datetime.timedelta(days=1): return _('{} hours ago').format(delta.seconds / 3600) if delta < datetime.timedelta(days=2): return _('1 day ago') return _('{} days ago').format(delta.days) def plain_markdown(text): renderer = misaka.HtmlRenderer(flags=misaka.HTML_ESCAPE) md = misaka.Markdown(renderer) return md.render(text) Fix time delta with utcnow
import datetime import misaka from flask.ext.babel import gettext as _ def timeago(dt): now = datetime.datetime.utcnow() delta = now - dt print delta if delta < datetime.timedelta(minutes=2): return _('Just now') if delta < datetime.timedelta(hours=1): return _('{} minutes ago').format(delta.seconds / 60) if delta < datetime.timedelta(hours=2): return _('1 hour ago') if delta < datetime.timedelta(days=1): return _('{} hours ago').format(delta.seconds / 3600) if delta < datetime.timedelta(days=2): return _('1 day ago') return _('{} days ago').format(delta.days) def plain_markdown(text): renderer = misaka.HtmlRenderer(flags=misaka.HTML_ESCAPE) md = misaka.Markdown(renderer) return md.render(text)
<commit_before>import datetime import misaka from flask.ext.babel import gettext as _ def timeago(dt): now = datetime.datetime.now() delta = now - dt print delta if delta < datetime.timedelta(minutes=2): return _('Just now') if delta < datetime.timedelta(hours=1): return _('{} minutes ago').format(delta.seconds / 60) if delta < datetime.timedelta(hours=2): return _('1 hour ago') if delta < datetime.timedelta(days=1): return _('{} hours ago').format(delta.seconds / 3600) if delta < datetime.timedelta(days=2): return _('1 day ago') return _('{} days ago').format(delta.days) def plain_markdown(text): renderer = misaka.HtmlRenderer(flags=misaka.HTML_ESCAPE) md = misaka.Markdown(renderer) return md.render(text) <commit_msg>Fix time delta with utcnow<commit_after>
import datetime import misaka from flask.ext.babel import gettext as _ def timeago(dt): now = datetime.datetime.utcnow() delta = now - dt print delta if delta < datetime.timedelta(minutes=2): return _('Just now') if delta < datetime.timedelta(hours=1): return _('{} minutes ago').format(delta.seconds / 60) if delta < datetime.timedelta(hours=2): return _('1 hour ago') if delta < datetime.timedelta(days=1): return _('{} hours ago').format(delta.seconds / 3600) if delta < datetime.timedelta(days=2): return _('1 day ago') return _('{} days ago').format(delta.days) def plain_markdown(text): renderer = misaka.HtmlRenderer(flags=misaka.HTML_ESCAPE) md = misaka.Markdown(renderer) return md.render(text)
import datetime import misaka from flask.ext.babel import gettext as _ def timeago(dt): now = datetime.datetime.now() delta = now - dt print delta if delta < datetime.timedelta(minutes=2): return _('Just now') if delta < datetime.timedelta(hours=1): return _('{} minutes ago').format(delta.seconds / 60) if delta < datetime.timedelta(hours=2): return _('1 hour ago') if delta < datetime.timedelta(days=1): return _('{} hours ago').format(delta.seconds / 3600) if delta < datetime.timedelta(days=2): return _('1 day ago') return _('{} days ago').format(delta.days) def plain_markdown(text): renderer = misaka.HtmlRenderer(flags=misaka.HTML_ESCAPE) md = misaka.Markdown(renderer) return md.render(text) Fix time delta with utcnowimport datetime import misaka from flask.ext.babel import gettext as _ def timeago(dt): now = datetime.datetime.utcnow() delta = now - dt print delta if delta < datetime.timedelta(minutes=2): return _('Just now') if delta < datetime.timedelta(hours=1): return _('{} minutes ago').format(delta.seconds / 60) if delta < datetime.timedelta(hours=2): return _('1 hour ago') if delta < datetime.timedelta(days=1): return _('{} hours ago').format(delta.seconds / 3600) if delta < datetime.timedelta(days=2): return _('1 day ago') return _('{} days ago').format(delta.days) def plain_markdown(text): renderer = misaka.HtmlRenderer(flags=misaka.HTML_ESCAPE) md = misaka.Markdown(renderer) return md.render(text)
<commit_before>import datetime import misaka from flask.ext.babel import gettext as _ def timeago(dt): now = datetime.datetime.now() delta = now - dt print delta if delta < datetime.timedelta(minutes=2): return _('Just now') if delta < datetime.timedelta(hours=1): return _('{} minutes ago').format(delta.seconds / 60) if delta < datetime.timedelta(hours=2): return _('1 hour ago') if delta < datetime.timedelta(days=1): return _('{} hours ago').format(delta.seconds / 3600) if delta < datetime.timedelta(days=2): return _('1 day ago') return _('{} days ago').format(delta.days) def plain_markdown(text): renderer = misaka.HtmlRenderer(flags=misaka.HTML_ESCAPE) md = misaka.Markdown(renderer) return md.render(text) <commit_msg>Fix time delta with utcnow<commit_after>import datetime import misaka from flask.ext.babel import gettext as _ def timeago(dt): now = datetime.datetime.utcnow() delta = now - dt print delta if delta < datetime.timedelta(minutes=2): return _('Just now') if delta < datetime.timedelta(hours=1): return _('{} minutes ago').format(delta.seconds / 60) if delta < datetime.timedelta(hours=2): return _('1 hour ago') if delta < datetime.timedelta(days=1): return _('{} hours ago').format(delta.seconds / 3600) if delta < datetime.timedelta(days=2): return _('1 day ago') return _('{} days ago').format(delta.days) def plain_markdown(text): renderer = misaka.HtmlRenderer(flags=misaka.HTML_ESCAPE) md = misaka.Markdown(renderer) return md.render(text)
664ce646983abc10fc6437b400b18bdca26b48c5
linter.py
linter.py
# # linter.py # Linter for SublimeLinter3, a code checking framework for Sublime Text 3 # # Written by skulanov,,, # Copyright (c) 2015 skulanov,,, # # License: MIT # """This module exports the Rpmlint plugin class.""" from SublimeLinter.lint import Linter, util class Rpmlint(Linter): """Provides an interface to rpmlint.""" syntax = 'rpm spec' cmd = 'rpmlint' executable = None regex = ( r'^(?P<line>\d+):' r'((?P<warning>W\:)|(?P<error>error\:)):' r'(?P<message>.+)' ) tempfile_suffix = '-' error_stream = util.STREAM_STDOUT word_re = r'^(".*?"|[-\w]+)'
# # linter.py # Linter for SublimeLinter3, a code checking framework for Sublime Text 3 # # Written by skulanov,,, # Copyright (c) 2015 skulanov,,, # # License: MIT # """This module exports the Rpmlint plugin class.""" from SublimeLinter.lint import Linter, util class Rpmlint(Linter): """Provides an interface to rpmlint.""" syntax = 'rpm spec' cmd = 'rpmlint' executable = None regex = ( r'(?P<line>\d+):' r'(?:(?P<warning>W)|(?P<error>error))' r'(?:P<message>.+)' ) tempfile_suffix = '-' error_stream = util.STREAM_STDOUT
Fix regexp for rpmlint output
Fix regexp for rpmlint output
Python
mit
SergK/SublimeLinter-contrib-rpmlint
# # linter.py # Linter for SublimeLinter3, a code checking framework for Sublime Text 3 # # Written by skulanov,,, # Copyright (c) 2015 skulanov,,, # # License: MIT # """This module exports the Rpmlint plugin class.""" from SublimeLinter.lint import Linter, util class Rpmlint(Linter): """Provides an interface to rpmlint.""" syntax = 'rpm spec' cmd = 'rpmlint' executable = None regex = ( r'^(?P<line>\d+):' r'((?P<warning>W\:)|(?P<error>error\:)):' r'(?P<message>.+)' ) tempfile_suffix = '-' error_stream = util.STREAM_STDOUT word_re = r'^(".*?"|[-\w]+)' Fix regexp for rpmlint output
# # linter.py # Linter for SublimeLinter3, a code checking framework for Sublime Text 3 # # Written by skulanov,,, # Copyright (c) 2015 skulanov,,, # # License: MIT # """This module exports the Rpmlint plugin class.""" from SublimeLinter.lint import Linter, util class Rpmlint(Linter): """Provides an interface to rpmlint.""" syntax = 'rpm spec' cmd = 'rpmlint' executable = None regex = ( r'(?P<line>\d+):' r'(?:(?P<warning>W)|(?P<error>error))' r'(?:P<message>.+)' ) tempfile_suffix = '-' error_stream = util.STREAM_STDOUT
<commit_before># # linter.py # Linter for SublimeLinter3, a code checking framework for Sublime Text 3 # # Written by skulanov,,, # Copyright (c) 2015 skulanov,,, # # License: MIT # """This module exports the Rpmlint plugin class.""" from SublimeLinter.lint import Linter, util class Rpmlint(Linter): """Provides an interface to rpmlint.""" syntax = 'rpm spec' cmd = 'rpmlint' executable = None regex = ( r'^(?P<line>\d+):' r'((?P<warning>W\:)|(?P<error>error\:)):' r'(?P<message>.+)' ) tempfile_suffix = '-' error_stream = util.STREAM_STDOUT word_re = r'^(".*?"|[-\w]+)' <commit_msg>Fix regexp for rpmlint output<commit_after>
# # linter.py # Linter for SublimeLinter3, a code checking framework for Sublime Text 3 # # Written by skulanov,,, # Copyright (c) 2015 skulanov,,, # # License: MIT # """This module exports the Rpmlint plugin class.""" from SublimeLinter.lint import Linter, util class Rpmlint(Linter): """Provides an interface to rpmlint.""" syntax = 'rpm spec' cmd = 'rpmlint' executable = None regex = ( r'(?P<line>\d+):' r'(?:(?P<warning>W)|(?P<error>error))' r'(?:P<message>.+)' ) tempfile_suffix = '-' error_stream = util.STREAM_STDOUT
# # linter.py # Linter for SublimeLinter3, a code checking framework for Sublime Text 3 # # Written by skulanov,,, # Copyright (c) 2015 skulanov,,, # # License: MIT # """This module exports the Rpmlint plugin class.""" from SublimeLinter.lint import Linter, util class Rpmlint(Linter): """Provides an interface to rpmlint.""" syntax = 'rpm spec' cmd = 'rpmlint' executable = None regex = ( r'^(?P<line>\d+):' r'((?P<warning>W\:)|(?P<error>error\:)):' r'(?P<message>.+)' ) tempfile_suffix = '-' error_stream = util.STREAM_STDOUT word_re = r'^(".*?"|[-\w]+)' Fix regexp for rpmlint output# # linter.py # Linter for SublimeLinter3, a code checking framework for Sublime Text 3 # # Written by skulanov,,, # Copyright (c) 2015 skulanov,,, # # License: MIT # """This module exports the Rpmlint plugin class.""" from SublimeLinter.lint import Linter, util class Rpmlint(Linter): """Provides an interface to rpmlint.""" syntax = 'rpm spec' cmd = 'rpmlint' executable = None regex = ( r'(?P<line>\d+):' r'(?:(?P<warning>W)|(?P<error>error))' r'(?:P<message>.+)' ) tempfile_suffix = '-' error_stream = util.STREAM_STDOUT
<commit_before># # linter.py # Linter for SublimeLinter3, a code checking framework for Sublime Text 3 # # Written by skulanov,,, # Copyright (c) 2015 skulanov,,, # # License: MIT # """This module exports the Rpmlint plugin class.""" from SublimeLinter.lint import Linter, util class Rpmlint(Linter): """Provides an interface to rpmlint.""" syntax = 'rpm spec' cmd = 'rpmlint' executable = None regex = ( r'^(?P<line>\d+):' r'((?P<warning>W\:)|(?P<error>error\:)):' r'(?P<message>.+)' ) tempfile_suffix = '-' error_stream = util.STREAM_STDOUT word_re = r'^(".*?"|[-\w]+)' <commit_msg>Fix regexp for rpmlint output<commit_after># # linter.py # Linter for SublimeLinter3, a code checking framework for Sublime Text 3 # # Written by skulanov,,, # Copyright (c) 2015 skulanov,,, # # License: MIT # """This module exports the Rpmlint plugin class.""" from SublimeLinter.lint import Linter, util class Rpmlint(Linter): """Provides an interface to rpmlint.""" syntax = 'rpm spec' cmd = 'rpmlint' executable = None regex = ( r'(?P<line>\d+):' r'(?:(?P<warning>W)|(?P<error>error))' r'(?:P<message>.+)' ) tempfile_suffix = '-' error_stream = util.STREAM_STDOUT